Xen Test Framework
NMI Taskswitch with increasing privilege

32bit versions of Windows use a Task Gate for handling #NMI, and use NMI IPIs between vCPUs in some circumstances.

A regression was introduced during the Xen 4.9 development cycle which caused a task switch which changed CPL to corrupt VMCB/VMCS state and result in a vmentry failure. To make this regression test reliable, it is simplified to a single vCPU using a self-NMI IPI to trigger the task switch.

Notes for people writing reusable x86 tasks:

x86 Tasks and hardware task switching are basically unused in practice. As a result, there is precious little information online. The following issues caught me by surprise while developing this code. Some are now obvious in retrospect, while some are not.

See also
tests/nmi-taskswitch-priv/main.c