[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH v3 2/3] x86/mm: Do not validate/devalidate PGT_none type



This commit prevents PGT_none type pages to be validated/devalidated.
This is required for the use-case in which a guest-agnostic resource is
allocated. In this case, these pages may be accessible by an "owning" PV
domain. To lock the page from guest pov, pages are required to be marked
with PGT_none with a single type ref. In particular, this commit makes
the stats_table resource type to use this flag during
get_page_and_type(). 

Signed-off-by: Matias Ezequiel Vara Larsen <matias.vara@xxxxxxxx>
---
 xen/arch/x86/mm.c   | 3 ++-
 xen/common/memory.c | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 5812321cae..d2f311abe4 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2787,6 +2787,7 @@ static int _put_page_type(struct page_info *page, 
unsigned int flags,
         {
         case 0:
             if ( unlikely((nx & PGT_type_mask) <= PGT_l4_page_table) &&
+                 unlikely((nx & PGT_type_mask) >= PGT_l1_page_table) &&
                  likely(nx & (PGT_validated|PGT_partial)) )
             {
                 int rc;
@@ -3072,7 +3073,7 @@ static int _get_page_type(struct page_info *page, 
unsigned long type,
          *
          * per validate_page(), non-atomic updates are fine here.
          */
-        if ( type == PGT_writable_page || type == PGT_shared_page )
+        if ( type == PGT_writable_page || type == PGT_shared_page || type == 
PGT_none )
             page->u.inuse.type_info |= PGT_validated;
         else
         {
diff --git a/xen/common/memory.c b/xen/common/memory.c
index 2acac40c63..e26ba21d75 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -1254,7 +1254,7 @@ static int stats_vcpu_alloc_mfn(struct domain *d)
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        if ( unlikely(!get_page_and_type(&pg[i], d, PGT_writable_page)) )
+        if ( unlikely(!get_page_and_type(&pg[i], d, PGT_none)) )
             /*
              * The domain can't possibly know about this page yet, so failure
              * here is a clear indication of something fishy going on.
-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.