HomeFreeBSD

MFC 339312,339364: Restore more descriptors during VM exits.

Description

MFC 339312,339364: Restore more descriptors during VM exits.

339312:
Fully restore the GDTR, IDTR, and LDTR after VT-x VM exits.

The VT-x VMCS only stores the base address of the GDTR and IDTR. As a
result, VM exits use a fixed limit of 0xffff for the host GDTR and
IDTR losing the smaller limits set in when the initial GDT is loaded
on each CPU during boot. Explicitly save and restore the full GDTR
and IDTR contents around VM entries and exits to restore the correct
limit.

Similarly, explicitly save and restore the LDT selector. VM exits
always clear the host LDTR as if the LDT was loaded with a NULL
selector and a userspace hypervisor is probably using a NULL selector
anyway, but save and restore the LDT explicitly just to be safe.

339364:
Reload the LDT selector after an AMD-v #VMEXIT.

cpu_switch() always reloads the LDT, so this can only affect the
hypervisor process itself. Fix this by explicitly reloading the host
LDT selector after each #VMEXIT. The stock bhyve process on FreeBSD
never uses a custom LDT, so this change is cosmetic.

PR: 230773

Details

Provenance
jhbAuthored on
Parents
rS340544: Revert r340541. It requires VNET_DEFINE_STATIC() macro that is not yet
Branches
Unknown
Tags
Unknown