Skip to content

Commit c092fc8

Browse files
committed
KVM: x86: Inhibit code #DBs in MOV-SS shadow for all Intel compat vCPUs
Treat code #DBs as inhibited in MOV/POP-SS shadows for vCPU models that are Intel compatible, not just strictly vCPUs with vendor==Intel. The behavior is explicitly called out in the SDM, and thus architectural, i.e. applies to all CPUs that implement Intel's architecture, and isn't a quirk that is unique to CPUs manufactured by Intel: However, if an instruction breakpoint is placed on an instruction located immediately after a POP SS/MOV SS instruction, the breakpoint will be suppressed as if EFLAGS.RF were 1. Applying the behavior strictly to Intel wasn't intentional, KVM simply didn't have a concept of "Intel compatible" as of commit baf67ca ("KVM: x86: Suppress code #DBs on Intel if MOV/POP SS blocking is active"). Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 6463e5e commit c092fc8

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

arch/x86/kvm/x86.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9028,19 +9028,17 @@ EXPORT_SYMBOL_GPL(kvm_skip_emulated_instruction);
90289028

90299029
static bool kvm_is_code_breakpoint_inhibited(struct kvm_vcpu *vcpu)
90309030
{
9031-
u32 shadow;
9032-
90339031
if (kvm_get_rflags(vcpu) & X86_EFLAGS_RF)
90349032
return true;
90359033

90369034
/*
9037-
* Intel CPUs inhibit code #DBs when MOV/POP SS blocking is active,
9038-
* but AMD CPUs do not. MOV/POP SS blocking is rare, check that first
9039-
* to avoid the relatively expensive CPUID lookup.
9035+
* Intel compatible CPUs inhibit code #DBs when MOV/POP SS blocking is
9036+
* active, but AMD compatible CPUs do not.
90409037
*/
9041-
shadow = static_call(kvm_x86_get_interrupt_shadow)(vcpu);
9042-
return (shadow & KVM_X86_SHADOW_INT_MOV_SS) &&
9043-
guest_cpuid_is_intel(vcpu);
9038+
if (!guest_cpuid_is_intel_compatible(vcpu))
9039+
return false;
9040+
9041+
return static_call(kvm_x86_get_interrupt_shadow)(vcpu) & KVM_X86_SHADOW_INT_MOV_SS;
90449042
}
90459043

90469044
static bool kvm_vcpu_check_code_breakpoint(struct kvm_vcpu *vcpu,

0 commit comments

Comments
 (0)