]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: nVMX: Mark vmcs12's APIC access page dirty when unmapping
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:34 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 16:58:00 +0000 (12:58 -0400)
Mark the APIC access page as dirty when unmapping it from KVM.  The fact
that the page _shouldn't_ be written doesn't guarantee the page _won't_ be
written.  And while the contents are likely irrelevant, the values _are_
visible to the guest, i.e. dropping writes would be visible to the guest
(though obviously highly unlikely to be problematic in practice).

Marking the map dirty will allow specifying the write vs. read-only when
*mapping* the memory, which in turn will allow creating read-only maps.

Tested-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-ID: <20241010182427.1434605-33-seanjc@google.com>

arch/x86/kvm/vmx/nested.c

index 81865db18e129b5528a9180eac28589c6def75a2..ff83b56fe2fa218d5e1b264e505a727cf77c572d 100644 (file)
@@ -318,12 +318,7 @@ static void nested_put_vmcs12_pages(struct kvm_vcpu *vcpu)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
 
-       /*
-        * Unpin physical memory we referred to in the vmcs02.  The APIC access
-        * page's backing page (yeah, confusing) shouldn't actually be accessed,
-        * and if it is written, the contents are irrelevant.
-        */
-       kvm_vcpu_unmap(vcpu, &vmx->nested.apic_access_page_map, false);
+       kvm_vcpu_unmap(vcpu, &vmx->nested.apic_access_page_map, true);
        kvm_vcpu_unmap(vcpu, &vmx->nested.virtual_apic_map, true);
        kvm_vcpu_unmap(vcpu, &vmx->nested.pi_desc_map, true);
        vmx->nested.pi_desc = NULL;