]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nSVM: Don't initialize vmcb02 MSRPM with vmcb01's "always passthrough"
authorSean Christopherson <seanjc@google.com>
Tue, 10 Jun 2025 22:57:17 +0000 (15:57 -0700)
committerSean Christopherson <seanjc@google.com>
Fri, 20 Jun 2025 20:07:24 +0000 (13:07 -0700)
Don't initialize vmcb02's MSRPM with KVM's set of "always passthrough"
MSRs, as KVM always needs to consult L1's intercepts, i.e. needs to merge
vmcb01 with vmcb12 and write the result to vmcb02.  This will eventually
allow for the removal of svm_vcpu_init_msrpm().

Note, the bitmaps are truly initialized by svm_vcpu_alloc_msrpm() (default
to intercepting all MSRs), e.g. if there is a bug lurking elsewhere, the
worst case scenario from dropping the call to svm_vcpu_init_msrpm() should
be that KVM would fail to passthrough MSRs to L2.

Link: https://lore.kernel.org/r/20250610225737.156318-13-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h

index 360dbd80a7288e2572889aea819fa83abe96aa96..cf148f7db88765f5bdfa705de30bd94d29699393 100644 (file)
@@ -1285,7 +1285,6 @@ int svm_allocate_nested(struct vcpu_svm *svm)
        svm->nested.msrpm = svm_vcpu_alloc_msrpm();
        if (!svm->nested.msrpm)
                goto err_free_vmcb02;
-       svm_vcpu_init_msrpm(&svm->vcpu, svm->nested.msrpm);
 
        svm->nested.initialized = true;
        return 0;
index d8b67bedf183a93df47eb7bab1939f1ba7c884de..290862b27aedb3567723d11c7e3639ac441bf8ee 100644 (file)
@@ -883,8 +883,9 @@ u32 *svm_vcpu_alloc_msrpm(void)
        return msrpm;
 }
 
-void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu, u32 *msrpm)
+static void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu)
 {
+       u32 *msrpm = to_svm(vcpu)->msrpm;
        int i;
 
        for (i = 0; i < ARRAY_SIZE(direct_access_msrs); i++) {
@@ -1396,7 +1397,7 @@ static void __svm_vcpu_reset(struct kvm_vcpu *vcpu)
 {
        struct vcpu_svm *svm = to_svm(vcpu);
 
-       svm_vcpu_init_msrpm(vcpu, svm->msrpm);
+       svm_vcpu_init_msrpm(vcpu);
 
        svm_init_osvw(vcpu);
 
index 9f750b2399e9209a6a30c0ec81a7176b040115fc..bce66afafa11241c392a078a635a886a87296003 100644 (file)
@@ -633,7 +633,6 @@ extern bool dump_invalid_vmcb;
 
 u32 svm_msrpm_offset(u32 msr);
 u32 *svm_vcpu_alloc_msrpm(void);
-void svm_vcpu_init_msrpm(struct kvm_vcpu *vcpu, u32 *msrpm);
 void svm_vcpu_free_msrpm(u32 *msrpm);
 void svm_copy_lbrs(struct vmcb *to_vmcb, struct vmcb *from_vmcb);
 void svm_enable_lbrv(struct kvm_vcpu *vcpu);