Skip to content

Commit 38e9326

Browse files
ahunter6bonzini
authored andcommitted
KVM: x86: Do not use kvm_rip_read() unconditionally for KVM_PROFILING
Not all VMs allow access to RIP. Check guest_state_protected before calling kvm_rip_read(). This avoids, for example, hitting WARN_ON_ONCE in vt_cache_reg() for TDX VMs. Fixes: 81bf912b2c15 ("KVM: TDX: Implement TDX vcpu enter/exit path") Signed-off-by: Adrian Hunter <[email protected]> Message-ID: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent ca4f113 commit 38e9326

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kvm/x86.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -11098,7 +11098,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
1109811098
/*
1109911099
* Profile KVM exit RIPs:
1110011100
*/
11101-
if (unlikely(prof_on == KVM_PROFILING)) {
11101+
if (unlikely(prof_on == KVM_PROFILING &&
11102+
!vcpu->arch.guest_state_protected)) {
1110211103
unsigned long rip = kvm_rip_read(vcpu);
1110311104
profile_hit(KVM_PROFILING, (void *)rip);
1110411105
}

0 commit comments

Comments
 (0)