]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nSVM: Use PAGE_MASK to drop lower bits of bitmap GPAs from vmcb12
authorYosry Ahmed <yosry@kernel.org>
Tue, 3 Mar 2026 00:34:16 +0000 (00:34 +0000)
committerSean Christopherson <seanjc@google.com>
Thu, 5 Mar 2026 00:09:06 +0000 (16:09 -0800)
Use PAGE_MASK to drop the lower bits from IOPM_BASE_PA and MSRPM_BASE_PA
while copying them instead of dropping the bits afterward with a
hardcoded mask.

No functional change intended.

Signed-off-by: Yosry Ahmed <yosry@kernel.org>
Link: https://patch.msgid.link/20260303003421.2185681-23-yosry@kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c

index c61b4923963e4a1f0a013297fa51c68fa683fd3f..fd704590494801e67b07f8b3801ef7be23cad4b8 100644 (file)
@@ -482,8 +482,8 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
        if (!guest_cpu_cap_has(vcpu, X86_FEATURE_NPT))
                to->misc_ctl &= ~SVM_MISC_ENABLE_NP;
 
-       to->iopm_base_pa        = from->iopm_base_pa;
-       to->msrpm_base_pa       = from->msrpm_base_pa;
+       to->iopm_base_pa        = from->iopm_base_pa & PAGE_MASK;
+       to->msrpm_base_pa       = from->msrpm_base_pa & PAGE_MASK;
        to->tsc_offset          = from->tsc_offset;
        to->tlb_ctl             = from->tlb_ctl;
        to->erap_ctl            = from->erap_ctl;
@@ -505,8 +505,6 @@ void __nested_copy_vmcb_control_to_cache(struct kvm_vcpu *vcpu,
 
        /* Copy asid here because nested_vmcb_check_controls() will check it */
        to->asid           = from->asid;
-       to->msrpm_base_pa &= ~0x0fffULL;
-       to->iopm_base_pa  &= ~0x0fffULL;
        to->clean = from->clean;
 
 #ifdef CONFIG_KVM_HYPERV