]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: guest_memfd: Pass index, not gfn, to __kvm_gmem_get_pfn()
authorSean Christopherson <seanjc@google.com>
Thu, 10 Oct 2024 18:23:47 +0000 (11:23 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 25 Oct 2024 17:00:47 +0000 (13:00 -0400)
commit4af18dc6a9204464db76d9771d1f40e2b46bf6ae
treefa47ec2dddf36ae9a5dbec467072ab90f7ab078a
parent54ba8c98a2589f816c52545c9cd3db6665ee0c67
KVM: guest_memfd: Pass index, not gfn, to __kvm_gmem_get_pfn()

Refactor guest_memfd usage of __kvm_gmem_get_pfn() to pass the index into
the guest_memfd file instead of the gfn, i.e. resolve the index based on
the slot+gfn in the caller instead of in __kvm_gmem_get_pfn().  This will
allow kvm_gmem_get_pfn() to retrieve and return the specific "struct page",
which requires the index into the folio, without a redoing the index
calculation multiple times (which isn't costly, just hard to follow).

Opportunistically add a kvm_gmem_get_index() helper to make the copy+pasted
code easier to understand.

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