Commit 38e93267 authored by Adrian Hunter's avatar Adrian Hunter Committed by Paolo Bonzini
Browse files

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: 81bf912b ("KVM: TDX: Implement TDX vcpu enter/exit path")
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Message-ID: <20250415104821.247234-3-adrian.hunter@intel.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent ca4f113b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -11098,7 +11098,8 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu)
	/*
	 * Profile KVM exit RIPs:
	 */
	if (unlikely(prof_on == KVM_PROFILING)) {
	if (unlikely(prof_on == KVM_PROFILING &&
		     !vcpu->arch.guest_state_protected)) {
		unsigned long rip = kvm_rip_read(vcpu);
		profile_hit(KVM_PROFILING, (void *)rip);
	}