Page MenuHomeFreeBSD

vmm: Suspend the VM on a hardware triple fault
AcceptedPublic

Authored by hayzam_gmail.com on Sat, Sep 19, 1:49 PM.
Tags
None
Referenced Files
F173021569: D59840.id187404.diff
Tue, Sep 22, 10:39 PM
F173006876: D59840.id.diff
Tue, Sep 22, 8:00 PM
Restricted File
Mon, Sep 21, 9:01 AM
Restricted File
Mon, Sep 21, 9:01 AM
Restricted File
Mon, Sep 21, 9:01 AM
Restricted File
Mon, Sep 21, 9:01 AM
Restricted File
Mon, Sep 21, 9:01 AM
Restricted File
Mon, Sep 21, 9:01 AM

Details

Reviewers
markj
bnovkov
Group Reviewers
bhyve
Summary

The VMX backend did not handle EXIT_REASON_TRIPLE_FAULT, so a hardware
triple fault fell through as an unhandled exit: bhyve printed a raw VMX
exit dump and aborted, instead of suspending the VM with the
reason the software exception path already uses.

Add the missing case so the VM suspends with VM_SUSPEND_TRIPLEFAULT and
bhyve exits with BHYVE_EXIT_TRIPLEFAULT. This matches illumos change 14664.

Obtained from: illumos 83b49c54d9c0766e810b6c8ff849dfb6693fc68a

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 77089
Build 73972: arc lint + arc unit

Event Timeline

bnovkov added a subscriber: bnovkov.

LGTM, I'll give the patch a spin tomorrow before landing it. Have you tested this change somehow already?

This revision is now accepted and ready to land.Sat, Sep 19, 5:15 PM

LGTM, I'll give the patch a spin tomorrow before landing it. Have you tested this change somehow already?

Yep, I tested with a small 16-bit payload that loads a null IDT and executes ud2, so the guest takes a hardware triple fault (VMX exit reason 2).

Before: raw VMX dump, then abort.
After patch: no dump, exits 3 (BHYVE_EXIT_TRIPLEFAULT).

Only the VMX side is covered though as you can see, the SVM side still injects #UD for VMCB_EXIT_SHUTDOWN (illumos I believe handles it in 13170), and I have no AMD hardware here.

I can attach the payload image and both serial logs if that's useful.

LGTM, I'll give the patch a spin tomorrow before landing it. Have you tested this change somehow already?

Yep, I tested with a small 16-bit payload that loads a null IDT and executes ud2, so the guest takes a hardware triple fault (VMX exit reason 2).

I can attach the payload image and both serial logs if that's useful.

That would be great, thank you! How did you generate the payload?

Sure. It's a 34-byte multiboot kernel that GRUB loads; no guest OS involved:

cli
lidt    null_idt        /* base 0, limit 0 */
ud2

built with:

clang --target=i386-freebsd -c tfmb.S -o tfmb.o
ld.lld -m elf_i386 -N --image-base 0x100000 -Ttext 0x100000 \
    -e _start -o tfmb.elf tfmb.o

(-N matters: without it lld emits two load segments at the same address and GRUB rejects the ELF with "overlap detected".)

I dropped it on a small FAT image with GRUB as \EFI\BOOT\BOOTX64.EFI and a grub.cfg of:

multiboot /boot/tfmb.elf
boot

and booted that with plain bhyve + BHYVE_UEFI.fd + com1. Same image both times, only the kernel module changed, Please find the attached payload source, the ELF, grub.cfg, the 8 MB image and both serial logs. The README has the full image recipe if you want to rebuild it.

Just for posterity: illumos hit this while running the Windows kernel debugger under propolis (https://www.illumos.org/issues/14664), and their regression test is just a ud2a with an unpopulated IDT. I don't have the bhyve-tests framework here, so this is the equivalent thing with a tiny multiboot payload; and it was a useful excuse to go through the VMX exit path properly.

{F172828669}

{F172828667}

{F172828666}

{F172828665}

{F172828664}

{F172828663}

{F172828662}

markj added inline comments.
sys/amd64/vmm/intel/vmx.c
2477
This revision now requires review to proceed.Tue, Sep 22, 2:13 PM
This revision is now accepted and ready to land.Tue, Sep 22, 2:18 PM