android_kernel_xiaomi_sdm845/arch/i386/xen
Jeremy Fitzhardinge 9ec2b804e0 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>
2007-07-18 08:47:46 -07:00
..
enlighten.c xen: use iret directly when possible 2007-07-18 08:47:46 -07:00
events.c xen: use the hvc console infrastructure for Xen console 2007-07-18 08:47:44 -07:00
features.c xen: Core Xen implementation 2007-07-18 08:47:42 -07:00
Kconfig xen: Add support for preemption 2007-07-18 08:47:44 -07:00
Makefile xen: Attempt to patch inline versions of common operations 2007-07-18 08:47:45 -07:00
manage.c xen: handle external requests for shutdown, reboot and sysrq 2007-07-18 08:47:45 -07:00
mmu.c xen: lazy-mmu operations 2007-07-18 08:47:44 -07:00
mmu.h xen: SMP guest support 2007-07-18 08:47:44 -07:00
multicalls.c xen: lazy-mmu operations 2007-07-18 08:47:44 -07:00
multicalls.h xen: Core Xen implementation 2007-07-18 08:47:42 -07:00
setup.c xen: Place vcpu_info structure into per-cpu memory 2007-07-18 08:47:45 -07:00
smp.c xen: Place vcpu_info structure into per-cpu memory 2007-07-18 08:47:45 -07:00
time.c xen: Add support for preemption 2007-07-18 08:47:44 -07:00
xen-asm.S xen: use iret directly when possible 2007-07-18 08:47:46 -07:00
xen-head.S xen: Core Xen implementation 2007-07-18 08:47:42 -07:00
xen-ops.h xen: use iret directly when possible 2007-07-18 08:47:46 -07:00