CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]        2025/11/27 04:11:27

Modified files:
        usr.sbin/vmd   : loadfile_elf.c 

Log message:
vmd(8): Use 32-bit direct kernel launch for both amd64 and i386

When bootet by /boot (or EFI boot loaders) both amd64 and i386
kernel start in a 32-bit mode.

When launching kernel directly (vmctl start -b <path>) vmd(8)
configures a flat 64-bit register set as default register set.  The
GDT provides a 32-bit flat code segment.

For the i386 kernel the default register set is reconfigured to
32-bit legacy mode; paging is enabled and uses 4 Mb pages.  This
is different to i386 being bootet by /boot.  /boot launches the
i386 kernel with paging disabled.

The amd64 kernel uses the default register set, i.e. long mode is
enabled in EFER.  However, it uses the 32-bit code segment of the
GDT.  Thus ther kernel is effectively running in 32-bit compatibility
mode.

This has implications when using SEV-ES as #VC traps are delivered
by 64-bit rules.  Booting an amd64 kernel on Linux/KVM the kernel
is actually running in 32-bit legacy mode, thus #VC traps are
delivered by 32-bit rules.  Therefore, we have two #VC trap handlers
for locore0, a 32-bit and a 64-bit one.

To simplify this, start both i386 and amd64 in 32-bit legacy mode
with paging disabled.

All in all with this diff the run time configuration is similar to
what /boot provides for both amd64 and i386.

In a later diff #VC trap handling in locore0 can be simplified.

ok mlarkin

Reply via email to