Commit 4067c239 authored by Sean Christopherson's avatar Sean Christopherson

KVM: x86: Allow SYSENTER in Compatibility Mode for all Intel compat vCPUs

Emulate SYSENTER in Compatibility Mode for all vCPUs models that are
compatible with Intel's architecture, as the behavior if SYSENTER is
architecturally defined in Intel's SDM, i.e. should be followed by any
CPU that implements Intel's architecture.

Link: https://lore.kernel.org/r/20240405235603.1173076-9-seanjc@google.comSigned-off-by: default avatarSean Christopherson <seanjc@google.com>
parent dc2b8b2b
...@@ -2354,6 +2354,7 @@ setup_syscalls_segments(struct desc_struct *cs, struct desc_struct *ss) ...@@ -2354,6 +2354,7 @@ setup_syscalls_segments(struct desc_struct *cs, struct desc_struct *ss)
ss->avl = 0; ss->avl = 0;
} }
#ifdef CONFIG_X86_64
static bool vendor_intel(struct x86_emulate_ctxt *ctxt) static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
{ {
u32 eax, ebx, ecx, edx; u32 eax, ebx, ecx, edx;
...@@ -2362,6 +2363,7 @@ static bool vendor_intel(struct x86_emulate_ctxt *ctxt) ...@@ -2362,6 +2363,7 @@ static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, true); ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, true);
return is_guest_vendor_intel(ebx, ecx, edx); return is_guest_vendor_intel(ebx, ecx, edx);
} }
#endif
static int em_syscall(struct x86_emulate_ctxt *ctxt) static int em_syscall(struct x86_emulate_ctxt *ctxt)
{ {
...@@ -2444,11 +2446,11 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt) ...@@ -2444,11 +2446,11 @@ static int em_sysenter(struct x86_emulate_ctxt *ctxt)
return emulate_gp(ctxt, 0); return emulate_gp(ctxt, 0);
/* /*
* Not recognized on AMD in compat mode (but is recognized in legacy * Intel's architecture allows SYSENTER in compatibility mode, but AMD
* mode). * does not. Note, AMD does allow SYSENTER in legacy protected mode.
*/ */
if ((ctxt->mode != X86EMUL_MODE_PROT64) && (efer & EFER_LMA) if ((ctxt->mode != X86EMUL_MODE_PROT64) && (efer & EFER_LMA) &&
&& !vendor_intel(ctxt)) !ctxt->ops->guest_cpuid_is_intel_compatible(ctxt))
return emulate_ud(ctxt); return emulate_ud(ctxt);
/* sysenter/sysexit have not been tested in 64bit mode. */ /* sysenter/sysexit have not been tested in 64bit mode. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment