]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit - sys/amd64/vmm/amd/svm.c
Clear the upper 32-bits of registers in x86_emulate_cpuid().
authorjhb <jhb@FreeBSD.org>
Thu, 1 Oct 2020 16:45:11 +0000 (16:45 +0000)
committerjhb <jhb@FreeBSD.org>
Thu, 1 Oct 2020 16:45:11 +0000 (16:45 +0000)
commitff41c89819ff1f1c3106510b0e83f49c34b4c676
tree2a6e26da2abaaca185e2f5c1f88ff898896fb63d
parentfbab0588a15724694a283014369048f1fa643f1b
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
sys/amd64/vmm/amd/svm.c
sys/amd64/vmm/intel/vmx.c
sys/amd64/vmm/x86.c
sys/amd64/vmm/x86.h