]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SVM: Massage name and param of helper that merges vmcb01 and vmcb12 MSRPMs
authorSean Christopherson <seanjc@google.com>
Tue, 10 Jun 2025 22:57:13 +0000 (15:57 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 20 Jun 2025 20:05:40 +0000 (13:05 -0700)
Rename nested_svm_vmrun_msrpm() to nested_svm_merge_msrpm() to better
capture its role, and opportunistically feed it @vcpu instead of @svm, as
grabbing "svm" only to turn around and grab svm->vcpu is rather silly.

No functional change intended.

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20250610225737.156318-9-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c

index 8427a48b8b7adb23eb3e5acc2c7fd262d082c13c..89a77f0f1cc82fa5574ec89c6f2a9e3796bdff51 100644 (file)
@@ -189,8 +189,9 @@ void recalc_intercepts(struct vcpu_svm *svm)
  * is optimized in that it only merges the parts where KVM MSR permission bitmap
  * may contain zero bits.
  */
-static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
+static bool nested_svm_merge_msrpm(struct kvm_vcpu *vcpu)
 {
+       struct vcpu_svm *svm = to_svm(vcpu);
        int i;
 
        /*
@@ -205,7 +206,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
        if (!svm->nested.force_msr_bitmap_recalc) {
                struct hv_vmcb_enlightenments *hve = &svm->nested.ctl.hv_enlightenments;
 
-               if (kvm_hv_hypercall_enabled(&svm->vcpu) &&
+               if (kvm_hv_hypercall_enabled(vcpu) &&
                    hve->hv_enlightenments_control.msr_bitmap &&
                    (svm->nested.ctl.clean & BIT(HV_VMCB_NESTED_ENLIGHTENMENTS)))
                        goto set_msrpm_base_pa;
@@ -230,7 +231,7 @@ static bool nested_svm_vmrun_msrpm(struct vcpu_svm *svm)
 
                offset = svm->nested.ctl.msrpm_base_pa + (p * 4);
 
-               if (kvm_vcpu_read_guest(&svm->vcpu, offset, &value, 4))
+               if (kvm_vcpu_read_guest(vcpu, offset, &value, 4))
                        return false;
 
                svm->nested.msrpm[p] = svm->msrpm[p] | value;
@@ -937,7 +938,7 @@ int nested_svm_vmrun(struct kvm_vcpu *vcpu)
        if (enter_svm_guest_mode(vcpu, vmcb12_gpa, vmcb12, true))
                goto out_exit_err;
 
-       if (nested_svm_vmrun_msrpm(svm))
+       if (nested_svm_merge_msrpm(vcpu))
                goto out;
 
 out_exit_err:
@@ -1819,13 +1820,11 @@ out_free:
 
 static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu)
 {
-       struct vcpu_svm *svm = to_svm(vcpu);
-
        if (WARN_ON(!is_guest_mode(vcpu)))
                return true;
 
        if (!vcpu->arch.pdptrs_from_userspace &&
-           !nested_npt_enabled(svm) && is_pae_paging(vcpu))
+           !nested_npt_enabled(to_svm(vcpu)) && is_pae_paging(vcpu))
                /*
                 * Reload the guest's PDPTRs since after a migration
                 * the guest CR3 might be restored prior to setting the nested
@@ -1834,7 +1833,7 @@ static bool svm_get_nested_state_pages(struct kvm_vcpu *vcpu)
                if (CC(!load_pdptrs(vcpu, vcpu->arch.cr3)))
                        return false;
 
-       if (!nested_svm_vmrun_msrpm(svm)) {
+       if (!nested_svm_merge_msrpm(vcpu)) {
                vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
                vcpu->run->internal.suberror =
                        KVM_INTERNAL_ERROR_EMULATION;
index 9dce32cae4852ec4a01123ff325c1ee996469520..4d90dd3a3b3ae38c9f00f2ff234de4d973fce66a 100644 (file)
@@ -3124,7 +3124,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr)
                 *
                 * For nested:
                 * The handling of the MSR bitmap for L2 guests is done in
-                * nested_svm_vmrun_msrpm.
+                * nested_svm_merge_msrpm().
                 * We update the L1 MSR bit as well since it will end up
                 * touching the MSR anyway now.
                 */