Xen Test Framework
FPU Exception Emulation

Various control register settings have a uniform effect on whether FPU instructions raise an exception or execute normally.

Each of the following cr0 bits are tested:

  • TS - Task Switched
  • MP - Monitor Coprocessor
  • EM - Emulate

against instructions from the following sets:

  • x87
  • x87 wait
  • MMX
  • SSE
  • AVX

checking that appropriate exceptions are raised (#NM or #UD), or that no exception is raised.

Each test is run against real hardware, and forced through the x86 instruction emulator (if FEP is available).

This test covers XSA-190, where #NM was not being raised appropriately, therefore interfering with lazy FPU task switching in the guest.

Todo:
Extend to include unmasked pending exceptions. There is definitely work required in the instruction emulator to support this properly.
See also
tests/fpu-exception-emulation/main.c