Skip to content

Commit bdaff4f

Browse files
committed
KVM: x86: Open code vendor_intel() in string_registers_quirk()
Open code the is_guest_vendor_intel() check in string_registers_quirk() to discourage makiking exact vendor==Intel checks in the emulator, and to remove the rather awful #ifdeffery. The string quirk is literally the only Intel specific, *non-architectural* behavior that KVM emulates. All Intel specific behavior that is architecturally defined applies to all vendors that are compatible with Intel's architecture, i.e. should use guest_cpuid_is_intel_compatible(). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 4067c23 commit bdaff4f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

arch/x86/kvm/emulate.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2354,17 +2354,6 @@ setup_syscalls_segments(struct desc_struct *cs, struct desc_struct *ss)
23542354
ss->avl = 0;
23552355
}
23562356

2357-
#ifdef CONFIG_X86_64
2358-
static bool vendor_intel(struct x86_emulate_ctxt *ctxt)
2359-
{
2360-
u32 eax, ebx, ecx, edx;
2361-
2362-
eax = ecx = 0;
2363-
ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, true);
2364-
return is_guest_vendor_intel(ebx, ecx, edx);
2365-
}
2366-
#endif
2367-
23682357
static int em_syscall(struct x86_emulate_ctxt *ctxt)
23692358
{
23702359
const struct x86_emulate_ops *ops = ctxt->ops;
@@ -2622,7 +2611,14 @@ static void string_registers_quirk(struct x86_emulate_ctxt *ctxt)
26222611
* manner when ECX is zero due to REP-string optimizations.
26232612
*/
26242613
#ifdef CONFIG_X86_64
2625-
if (ctxt->ad_bytes != 4 || !vendor_intel(ctxt))
2614+
u32 eax, ebx, ecx, edx;
2615+
2616+
if (ctxt->ad_bytes != 4)
2617+
return;
2618+
2619+
eax = ecx = 0;
2620+
ctxt->ops->get_cpuid(ctxt, &eax, &ebx, &ecx, &edx, true);
2621+
if (!is_guest_vendor_intel(ebx, ecx, edx))
26262622
return;
26272623

26282624
*reg_write(ctxt, VCPU_REGS_RCX) = 0;

0 commit comments

Comments
 (0)