mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
KVM: Move kvm_{set,release}_page_{clean,dirty}() helpers up in kvm_main.c
Hoist the kvm_{set,release}_page_{clean,dirty}() APIs further up in kvm_main.c so that they can be used by the kvm_follow_pfn family of APIs. No functional change intended. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> 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-29-seanjc@google.com>
This commit is contained in:
parent
3dd48ecfac
commit
775e3ff7bf
@ -2746,6 +2746,47 @@ unsigned long kvm_vcpu_gfn_to_hva_prot(struct kvm_vcpu *vcpu, gfn_t gfn, bool *w
|
||||
return gfn_to_hva_memslot_prot(slot, gfn, writable);
|
||||
}
|
||||
|
||||
static bool kvm_is_ad_tracked_page(struct page *page)
|
||||
{
|
||||
/*
|
||||
* Per page-flags.h, pages tagged PG_reserved "should in general not be
|
||||
* touched (e.g. set dirty) except by its owner".
|
||||
*/
|
||||
return !PageReserved(page);
|
||||
}
|
||||
|
||||
static void kvm_set_page_dirty(struct page *page)
|
||||
{
|
||||
if (kvm_is_ad_tracked_page(page))
|
||||
SetPageDirty(page);
|
||||
}
|
||||
|
||||
static void kvm_set_page_accessed(struct page *page)
|
||||
{
|
||||
if (kvm_is_ad_tracked_page(page))
|
||||
mark_page_accessed(page);
|
||||
}
|
||||
|
||||
void kvm_release_page_clean(struct page *page)
|
||||
{
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
kvm_set_page_accessed(page);
|
||||
put_page(page);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_release_page_clean);
|
||||
|
||||
void kvm_release_page_dirty(struct page *page)
|
||||
{
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
kvm_set_page_dirty(page);
|
||||
kvm_release_page_clean(page);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_release_page_dirty);
|
||||
|
||||
static kvm_pfn_t kvm_resolve_pfn(struct kvm_follow_pfn *kfp, struct page *page,
|
||||
struct follow_pfnmap_args *map, bool writable)
|
||||
{
|
||||
@ -3099,37 +3140,6 @@ void kvm_vcpu_unmap(struct kvm_vcpu *vcpu, struct kvm_host_map *map, bool dirty)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_vcpu_unmap);
|
||||
|
||||
static bool kvm_is_ad_tracked_page(struct page *page)
|
||||
{
|
||||
/*
|
||||
* Per page-flags.h, pages tagged PG_reserved "should in general not be
|
||||
* touched (e.g. set dirty) except by its owner".
|
||||
*/
|
||||
return !PageReserved(page);
|
||||
}
|
||||
|
||||
static void kvm_set_page_dirty(struct page *page)
|
||||
{
|
||||
if (kvm_is_ad_tracked_page(page))
|
||||
SetPageDirty(page);
|
||||
}
|
||||
|
||||
static void kvm_set_page_accessed(struct page *page)
|
||||
{
|
||||
if (kvm_is_ad_tracked_page(page))
|
||||
mark_page_accessed(page);
|
||||
}
|
||||
|
||||
void kvm_release_page_clean(struct page *page)
|
||||
{
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
kvm_set_page_accessed(page);
|
||||
put_page(page);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_release_page_clean);
|
||||
|
||||
void kvm_release_pfn_clean(kvm_pfn_t pfn)
|
||||
{
|
||||
struct page *page;
|
||||
@ -3145,16 +3155,6 @@ void kvm_release_pfn_clean(kvm_pfn_t pfn)
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);
|
||||
|
||||
void kvm_release_page_dirty(struct page *page)
|
||||
{
|
||||
if (!page)
|
||||
return;
|
||||
|
||||
kvm_set_page_dirty(page);
|
||||
kvm_release_page_clean(page);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kvm_release_page_dirty);
|
||||
|
||||
void kvm_release_pfn_dirty(kvm_pfn_t pfn)
|
||||
{
|
||||
struct page *page;
|
||||
|
Loading…
Reference in New Issue
Block a user