]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode
authorSean Christopherson <seanjc@google.com>
Tue, 2 Feb 2021 16:55:46 +0000 (08:55 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 2 Feb 2021 17:03:54 +0000 (12:03 -0500)
commit2532533684cdbce676021a7f3f2e408a046f5c61
tree49a968d74703012a1514d9ce6b4191dbdf26bc90
parentc7806e1ee05d63f9b10fc8cc1c2349204cfbe2da
KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode

Set the emulator context to PROT64 if SYSENTER transitions from 32-bit
userspace (compat mode) to a 64-bit kernel, otherwise the RIP update at
the end of x86_emulate_insn() will incorrectly truncate the new RIP.

Note, this bug is mostly limited to running an Intel virtual CPU model on
an AMD physical CPU, as other combinations of virtual and physical CPUs
do not trigger full emulation.  On Intel CPUs, SYSENTER in compatibility
mode is legal, and unconditionally transitions to 64-bit mode.  On AMD
CPUs, SYSENTER is illegal in compatibility mode and #UDs.  If the vCPU is
AMD, KVM injects a #UD on SYSENTER in compat mode.  If the pCPU is Intel,
SYSENTER will execute natively and not trigger #UD->VM-Exit (ignoring
guest TLB shenanigans).

Fixes: ce2b01cf6714 ("KVM: x86: handle wrap around 32-bit address space")
Cc: stable@vger.kernel.org
Signed-off-by: Jonny Barker <jonny@jonnybarker.com>
[sean: wrote changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210202165546.2390296-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/emulate.c