]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SVM: pass struct vcpu_svm to msr_write_intercepted
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 27 Apr 2026 17:57:52 +0000 (13:57 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 28 Apr 2026 10:56:06 +0000 (06:56 -0400)
Remove an unnecessary difference between Intel and AMD.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/svm.c

index e7fdd7a9c280d72f5a6cf2a9da71d3d41fccbc3f..0a2b85db89771bd6dbbc57c9f282a1c42ed2d191 100644 (file)
@@ -661,7 +661,7 @@ static void clr_dr_intercepts(struct vcpu_svm *svm)
        svm_mark_intercepts_dirty(svm);
 }
 
-static bool msr_write_intercepted(struct kvm_vcpu *vcpu, u32 msr)
+static bool msr_write_intercepted(struct vcpu_svm *svm, u32 msr)
 {
        /*
         * For non-nested case:
@@ -672,8 +672,7 @@ static bool msr_write_intercepted(struct kvm_vcpu *vcpu, u32 msr)
         * If the L02 MSR bitmap does not intercept the MSR, then we need to
         * save it.
         */
-       void *msrpm = is_guest_mode(vcpu) ? to_svm(vcpu)->nested.msrpm :
-                                           to_svm(vcpu)->msrpm;
+       void *msrpm = is_guest_mode(&svm->vcpu) ? svm->nested.msrpm : svm->msrpm;
 
        return svm_test_msr_bitmap_write(msrpm, msr);
 }
@@ -2764,7 +2763,7 @@ static bool sev_es_prevent_msr_access(struct kvm_vcpu *vcpu,
 {
        return is_sev_es_guest(vcpu) && vcpu->arch.guest_state_protected &&
               msr_info->index != MSR_IA32_XSS &&
-              !msr_write_intercepted(vcpu, msr_info->index);
+              !msr_write_intercepted(to_svm(vcpu), msr_info->index);
 }
 
 static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
@@ -4414,7 +4413,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
 {
        bool force_immediate_exit = run_flags & KVM_RUN_FORCE_IMMEDIATE_EXIT;
        struct vcpu_svm *svm = to_svm(vcpu);
-       bool spec_ctrl_intercepted = msr_write_intercepted(vcpu, MSR_IA32_SPEC_CTRL);
+       bool spec_ctrl_intercepted = msr_write_intercepted(svm, MSR_IA32_SPEC_CTRL);
 
        trace_kvm_entry(vcpu, force_immediate_exit);
 
@@ -4556,7 +4555,7 @@ static __no_kcsan fastpath_t svm_vcpu_run(struct kvm_vcpu *vcpu, u64 run_flags)
 
        vcpu->arch.regs_avail &= ~SVM_REGS_LAZY_LOAD_SET;
 
-       if (!msr_write_intercepted(vcpu, MSR_AMD64_PERF_CNTR_GLOBAL_CTL))
+       if (!msr_write_intercepted(svm, MSR_AMD64_PERF_CNTR_GLOBAL_CTL))
                rdmsrq(MSR_AMD64_PERF_CNTR_GLOBAL_CTL, vcpu_to_pmu(vcpu)->global_ctrl);
 
        trace_kvm_exit(vcpu, KVM_ISA_SVM);