diff options
author | Jeremy Fitzhardinge <jeremy@xensource.com> | 2007-07-17 21:37:07 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-07-18 11:47:46 -0400 |
commit | 9ec2b804e099e8a326369e6cccab10dee1d172ee (patch) | |
tree | 2626129bc8c8ce0be42290bb216517939be98f96 /arch/i386/kernel/entry.S | |
parent | 600b2fc242992e552e0b4e24c8c1f084b341f39b (diff) |
xen: use iret directly when possible
Most of the time we can simply use the iret instruction to exit the
kernel, rather than having to use the iret hypercall - the only
exception is if we're returning into vm86 mode, or from delivering an
NMI (which we don't support yet).
When running native, iret has the behaviour of testing for a pending
interrupt atomically with re-enabling interrupts. Unfortunately
there's no way to do this with Xen, so there's a window in which we
could get a recursive exception after enabling events but before
actually returning to userspace.
This causes a problem: if the nested interrupt causes one of the
task's TIF_WORK_MASK flags to be set, they will not be checked again
before returning to userspace. This means that pending work may be
left pending indefinitely, until the process enters and leaves the
kernel again. The net effect is that a pending signal or reschedule
event could be delayed for an unbounded amount of time.
To deal with this, the xen event upcall handler checks to see if the
EIP is within the critical section of the iret code, after events
are (potentially) enabled up to the iret itself. If its within this
range, it calls the iret critical section fixup, which adjusts the
stack to deal with any unrestored registers, and then shifts the
stack frame up to replace the previous invocation.
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Diffstat (limited to 'arch/i386/kernel/entry.S')
-rw-r--r-- | arch/i386/kernel/entry.S | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S index ffb236544270..32980b834935 100644 --- a/arch/i386/kernel/entry.S +++ b/arch/i386/kernel/entry.S | |||
@@ -1030,7 +1030,21 @@ ENTRY(xen_hypervisor_callback) | |||
1030 | CFI_ADJUST_CFA_OFFSET 4 | 1030 | CFI_ADJUST_CFA_OFFSET 4 |
1031 | SAVE_ALL | 1031 | SAVE_ALL |
1032 | TRACE_IRQS_OFF | 1032 | TRACE_IRQS_OFF |
1033 | mov %esp, %eax | 1033 | |
1034 | /* Check to see if we got the event in the critical | ||
1035 | region in xen_iret_direct, after we've reenabled | ||
1036 | events and checked for pending events. This simulates | ||
1037 | iret instruction's behaviour where it delivers a | ||
1038 | pending interrupt when enabling interrupts. */ | ||
1039 | movl PT_EIP(%esp),%eax | ||
1040 | cmpl $xen_iret_start_crit,%eax | ||
1041 | jb 1f | ||
1042 | cmpl $xen_iret_end_crit,%eax | ||
1043 | jae 1f | ||
1044 | |||
1045 | call xen_iret_crit_fixup | ||
1046 | |||
1047 | 1: mov %esp, %eax | ||
1034 | call xen_evtchn_do_upcall | 1048 | call xen_evtchn_do_upcall |
1035 | jmp ret_from_intr | 1049 | jmp ret_from_intr |
1036 | CFI_ENDPROC | 1050 | CFI_ENDPROC |