mirror of
https://github.com/xen-project/xen.git
synced 2026-10-30 03:00:05 +01:00
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@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 2d1c82261d
master date: 2018-01-05 19:57:08 +0000
This commit is contained in:
1 parent
237a58b1d0
commit
628b6af24f
1 file changed
+24
-7
+24
-7
@@ -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 */
|
||||
|
||||