]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: Disallow direct access (w/o mmu_notifier) to unpinned pfn by default
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:37 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 16:59:08 +0000 (12:59 -0400)
commit68e51d0a437b09dcef621b4cc8e4fe02605bf5c4
tree6561b1dee6b8ef7281677328b73874604fc0943c
parent2e5fdf60a9a69971b5e642d32e09bd6b0223f47c
KVM: Disallow direct access (w/o mmu_notifier) to unpinned pfn by default

Add an off-by-default module param to control whether or not KVM is allowed
to map memory that isn't pinned, i.e. that KVM can't guarantee won't be
freed while it is mapped into KVM and/or the guest.  Don't remove the
functionality entirely, as there are use cases where mapping unpinned
memory is safe (as defined by the platform owner), e.g. when memory is
hidden from the kernel and managed by userspace, in which case userspace
is already fully trusted to not muck with guest memory mappings.

But for more typical setups, mapping unpinned memory is wildly unsafe, and
unnecessary.  The APIs are used exclusively by x86's nested virtualization
support, and there is no known (or sane) use case for mapping PFN-mapped
memory a KVM guest _and_ letting the guest use it for virtualization
structures.

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-36-seanjc@google.com>
virt/kvm/kvm_main.c