When L1 uses EPT for L2 and its tables lead L2 to an address of L1 that
is not memory, such as L1's local APIC or a device that bhyve(8)
emulates, L1 was told that L2 had a triple fault. On a CPU L2 gets to
L1's device.
The access is now emulated as it is for L1, by the instruction
emulation that vm_run() has:
- The instruction is fetched here, through L2's page tables, with every address in them translated by L1's EPT tables. The fetch of vm_run() cannot be used: it takes L2's page tables to be in L1's memory.
- The exit for the instruction emulation is made from vmcs02, with the instruction in it, and the handler of VM_EXITCODE_VMINSN in vm_run() goes on to the emulation when it finds this exit.
- Only instructions with no other memory operand than the device are emulated. MOVS, PUSH and POP are not, because the emulation would look for their second operand in L1's memory at an address that L2 chooses. For these, and during the delivery of an event, L1 is still told that L2 had a triple fault.
AI assistance: as D61708, this change was developed with an AI assistant (Anthropic's Claude) under my direction. The assistant wrote the code and this description. The tests in the test plan were run on real hardware.
Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Sponsored by: keelos.dev