HomeFreeBSD

Clear the upper 32-bits of registers in x86_emulate_cpuid().

Description

Clear the upper 32-bits of registers in x86_emulate_cpuid().

Per the Intel manuals, CPUID is supposed to unconditionally zero the
upper 32 bits of the involved (rax/rbx/rcx/rdx) registers.
Previously, the emulation would cast pointers to the 64-bit register
values down to uint32_t, which while properly manipulating the lower
bits, would leave any garbage in the upper bits uncleared. While no
existing guest OSes seem to stumble over this in practice, the bhyve
emulation should match x86 expectations.

This was discovered through alignment warnings emitted by gcc9, while
testing it against SmartOS/bhyve.

SmartOS bug: https://smartos.org/bugview/OS-8168
Submitted by: Patrick Mooney
Reviewed by: rgrimes
Differential Revision: https://reviews.freebsd.org/D24727

Details

Provenance
jhbAuthored on
Reviewer
rgrimes
Differential Revision
D24727: x86_emulate_cpuid() should clear upper 32 bits
Parents
rS366327: Eliminate duplicate `afterinstallconfigs` target
Branches
Unknown
Tags
Unknown