lkml.org 
[lkml]   [2018]   [Dec]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH RFC 3/3] kvm: Add additional check to determine if a page is refcounted
From
Date
The function kvm_is_refcounted_page is used primarily to determine if KVM
is allowed to take a reference on the page. It was using the PG_reserved
flag to determine this previously, however in the case of DAX the page has
the PG_reserved flag set, but supports pinning by taking a reference on
the page. As such I have updated the check to add a special case for
ZONE_DEVICE pages that have the new support_refcount_pinning flag set.

Signed-off-by: Alexander Duyck <alexander.h.duyck@linux.intel.com>
---
virt/kvm/kvm_main.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 5e666df5666d..2e7e9fbb67bf 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -148,8 +148,20 @@ __weak int kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,

bool kvm_is_refcounted_pfn(kvm_pfn_t pfn)
{
- if (pfn_valid(pfn))
- return !PageReserved(pfn_to_page(pfn));
+ if (pfn_valid(pfn)) {
+ struct page *page = pfn_to_page(pfn);
+
+ /*
+ * The reference count for MMIO pages are not updated.
+ * Previously this was being tested for with just the
+ * PageReserved check, however now ZONE_DEVICE pages may
+ * also allow for the refcount to be updated for the sake
+ * of pinning the pages so use the additional check provided
+ * to determine if the reference count on the page can be
+ * used to pin it.
+ */
+ return !PageReserved(page) || is_device_pinnable_page(page);
+ }

return false;
}
\
 
 \ /
  Last update: 2018-12-03 20:26    [W:0.096 / U:1.964 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site