[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v6.5 10/26] common/wait: Clarifications to wait infrastructure
This logic is not as clear as it could be. Add some comments to help. Rearrange the asm block in __prepare_to_wait() to separate the GPR saving/restoring from the internal logic. While tweaking, add an unreachable() following the jmp in check_wakeup_from_wait(). No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- v6: * New --- xen/common/wait.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/xen/common/wait.c b/xen/common/wait.c index c5fc094..3d3d9fe 100644 --- a/xen/common/wait.c +++ b/xen/common/wait.c @@ -138,14 +138,26 @@ static void __prepare_to_wait(struct waitqueue_vcpu *wqv) domain_crash_synchronous(); } + /* Hand-rolled setjmp(). */ asm volatile ( - "push %%rax; push %%rbx; push %%rdx; " - "push %%rbp; push %%r8; push %%r9; push %%r10; push %%r11; " - "push %%r12; push %%r13; push %%r14; push %%r15; call 1f; " - "1: addq $2f-1b,(%%rsp); sub %%esp,%%ecx; cmp %3,%%ecx; ja 3f; " - "mov %%rsp,%%rsi; 2: rep movsb; mov %%rsp,%%rsi; 3: pop %%rax; " - "pop %%r15; pop %%r14; pop %%r13; pop %%r12; " - "pop %%r11; pop %%r10; pop %%r9; pop %%r8; " + "push %%rax; push %%rbx; push %%rdx; push %%rbp;" + "push %%r8; push %%r9; push %%r10; push %%r11;" + "push %%r12; push %%r13; push %%r14; push %%r15;" + + "call 1f;" + "1: addq $2f-1b,(%%rsp);" + "sub %%esp,%%ecx;" + "cmp %3,%%ecx;" + "ja 3f;" + "mov %%rsp,%%rsi;" + + /* check_wakeup_from_wait() longjmp()'s to this point. */ + "2: rep movsb;" + "mov %%rsp,%%rsi;" + "3: pop %%rax;" + + "pop %%r15; pop %%r14; pop %%r13; pop %%r12;" + "pop %%r11; pop %%r10; pop %%r9; pop %%r8;" "pop %%rbp; pop %%rdx; pop %%rbx; pop %%rax" : "=&S" (wqv->esp), "=&c" (dummy), "=&D" (dummy) : "i" (PAGE_SIZE), "0" (0), "1" (cpu_info), "2" (wqv->stack) @@ -189,11 +201,16 @@ void check_wakeup_from_wait(void) wait(); /* takes us back into the scheduler */ } + /* + * Hand-rolled longjmp(). Returns to the pointer on the top of + * wqv->stack, and lands on a `rep movs` instruction. + */ asm volatile ( "mov %1,%%"__OP"sp; jmp *(%0)" : : "S" (wqv->stack), "D" (wqv->esp), "c" ((char *)get_cpu_info() - (char *)wqv->esp) : "memory" ); + unreachable(); } #else /* !CONFIG_X86 */ -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |