From: Sean Christopherson Date: Thu, 10 Oct 2024 18:23:05 +0000 (-0700) Subject: KVM: Add kvm_release_page_unused() API to put pages that KVM never consumes X-Git-Tag: v6.13-rc1~97^2~17^2~82 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3af91068b7e10dba438f70eae94d877f20842fa1;p=thirdparty%2Fkernel%2Flinux.git KVM: Add kvm_release_page_unused() API to put pages that KVM never consumes Add an API to release an unused page, i.e. to put a page without marking it accessed or dirty. The API will be used when KVM faults-in a page but bails before installing the guest mapping (and other similar flows). Reviewed-by: Alex Bennée Tested-by: Alex Bennée Signed-off-by: Sean Christopherson Tested-by: Dmitry Osipenko Signed-off-by: Paolo Bonzini Message-ID: <20241010182427.1434605-4-seanjc@google.com> --- diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 0b280e5bad0a5..8de9acb0b35ec 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1216,6 +1216,15 @@ unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable); unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn); unsigned long gfn_to_hva_memslot_prot(struct kvm_memory_slot *slot, gfn_t gfn, bool *writable); + +static inline void kvm_release_page_unused(struct page *page) +{ + if (!page) + return; + + put_page(page); +} + void kvm_release_page_clean(struct page *page); void kvm_release_page_dirty(struct page *page);