[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 08/23] plat/xen/x86/entry64.S: Add more comments for critical region fixup
The implementation for handling event on Xen was ported from Mini-OS and has a race condition after handling an event and before returning to user (more details in entry64.S code). In order to support preemptive scheduling on Xen, the fix for the race condition had to be properly understood and extended. Therefore this patch adds the comments which helped me towards these goals. Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx> --- plat/xen/x86/entry64.S | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/plat/xen/x86/entry64.S b/plat/xen/x86/entry64.S index d34181be..1aba52c1 100644 --- a/plat/xen/x86/entry64.S +++ b/plat/xen/x86/entry64.S @@ -274,21 +274,21 @@ hypervisor_callback2: cmpq $ecrit,%rax jb critical_region_fixup -11: movq %gs:8,%rax - incl %gs:0 - cmovzq %rax,%rsp - pushq %rdi - call do_hypervisor_callback - popq %rsp - decl %gs:0 +11: movq %gs:8, %rax # load IRQ stack + incl %gs:0 # increment nested IRQ counter + cmovzq %rax, %rsp # if not nested IRQ, then set IRQ sp + pushq %rdi # save last sp + call do_hypervisor_callback # handle IRQ/event + popq %rsp # restore last sp + decl %gs:0 # decrement nested IRQ counter error_exit: movl OFFSETOF_REGS_EFLAGS(%rsp), %eax - shr $9, %eax # EAX[0] == IRET_RFLAGS.IF + shr $9, %eax # EAX[0] == IRET_RFLAGS.IF XEN_GET_VCPU_INFO(%rsi) - andb evtchn_upcall_mask(%rsi),%al - andb $1,%al # EAX[0] == IRET_RFLAGS.IF & event_mask - jnz restore_all_enable_events # != 0 => enable event delivery + andb evtchn_upcall_mask(%rsi), %al + andb $1, %al # EAX[0] == IRET_RFLAGS.IF & event_mask + jnz restore_all_enable_events # != 0 => enable event delivery RESTORE_ALL HYPERVISOR_IRET @@ -356,7 +356,7 @@ critical_region_fixup: andb $KERNEL_CS_MASK,OFFSETOF_REGS_CS(%rsp) # CS might have changed jmp 11b -#else +#else /* !CONFIG_PARAVIRT */ error_exit: RESTORE_ALL HYPERVISOR_IRET @@ -365,7 +365,7 @@ error_exit: * Xen event (virtual interrupt) entry point. */ TRAP_ENTRY hypervisor_callback, 0 -#endif +#endif /* CONFIG_PARAVIRT */ ENTRY(asm_failsafe_callback) #ifdef CONFIG_PARAVIRT -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |