Skip to content

Commit 3244616

Browse files
committed
KVM: nVMX: Allow emulating RDPID on behalf of L2
Return X86EMUL_CONTINUE instead X86EMUL_UNHANDLEABLE when emulating RDPID on behalf of L2 and L1 _does_ expose RDPID/RDTSCP to L2. When RDPID emulation was added by commit fb6d4d3 ("KVM: x86: emulate RDPID"), KVM incorrectly allowed emulation by default. Commit 07721fe ("KVM: nVMX: Don't emulate instructions in guest mode") fixed that flaw, but missed that RDPID emulation was relying on the common return path to allow emulation on behalf of L2. Fixes: 07721fe ("KVM: nVMX: Don't emulate instructions in guest mode") Link: https://lore.kernel.org/r/20250201015518.689704-4-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent c8e612b commit 3244616

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8049,18 +8049,19 @@ int vmx_check_intercept(struct kvm_vcpu *vcpu,
80498049
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
80508050

80518051
switch (info->intercept) {
8052-
/*
8053-
* RDPID causes #UD if disabled through secondary execution controls.
8054-
* Because it is marked as EmulateOnUD, we need to intercept it here.
8055-
* Note, RDPID is hidden behind ENABLE_RDTSCP.
8056-
*/
80578052
case x86_intercept_rdpid:
8053+
/*
8054+
* RDPID causes #UD if not enabled through secondary execution
8055+
* controls (ENABLE_RDTSCP). Note, the implicit MSR access to
8056+
* TSC_AUX is NOT subject to interception, i.e. checking only
8057+
* the dedicated execution control is architecturally correct.
8058+
*/
80588059
if (!nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_RDTSCP)) {
80598060
exception->vector = UD_VECTOR;
80608061
exception->error_code_valid = false;
80618062
return X86EMUL_PROPAGATE_FAULT;
80628063
}
8063-
break;
8064+
return X86EMUL_CONTINUE;
80648065

80658066
case x86_intercept_in:
80668067
case x86_intercept_ins:

0 commit comments

Comments
 (0)