Skip to content

Commit d6d0f39

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: nVMX: Allow emulating RDPID on behalf of L2
JIRA: https://issues.redhat.com/browse/RHEL-95318 commit 3244616 Author: Sean Christopherson <seanjc@google.com> Date: Fri Jan 31 17:55:10 2025 -0800 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> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 8ff80db commit d6d0f39

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
@@ -7961,18 +7961,19 @@ int vmx_check_intercept(struct kvm_vcpu *vcpu,
79617961
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
79627962

79637963
switch (info->intercept) {
7964-
/*
7965-
* RDPID causes #UD if disabled through secondary execution controls.
7966-
* Because it is marked as EmulateOnUD, we need to intercept it here.
7967-
* Note, RDPID is hidden behind ENABLE_RDTSCP.
7968-
*/
79697964
case x86_intercept_rdpid:
7965+
/*
7966+
* RDPID causes #UD if not enabled through secondary execution
7967+
* controls (ENABLE_RDTSCP). Note, the implicit MSR access to
7968+
* TSC_AUX is NOT subject to interception, i.e. checking only
7969+
* the dedicated execution control is architecturally correct.
7970+
*/
79707971
if (!nested_cpu_has2(vmcs12, SECONDARY_EXEC_ENABLE_RDTSCP)) {
79717972
exception->vector = UD_VECTOR;
79727973
exception->error_code_valid = false;
79737974
return X86EMUL_PROPAGATE_FAULT;
79747975
}
7975-
break;
7976+
return X86EMUL_CONTINUE;
79767977

79777978
case x86_intercept_in:
79787979
case x86_intercept_ins:

0 commit comments

Comments
 (0)