WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] x86: Foreign mappings of HVM-guest pages

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86: Foreign mappings of HVM-guest pages should not affect type count,
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 25 Feb 2008 08:40:09 -0800
Delivery-date: Mon, 25 Feb 2008 08:40:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1203938646 0
# Node ID cb3e47897b85b34de1b2b3bee5812318618972a2
# Parent  746fc8fe9d75313c7be8c7e77786f5ce9226920d
x86: Foreign mappings of HVM-guest pages should not affect type count,
even when the mapping is made via a grant reference.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 xen/common/grant_table.c              |   24 +++++++++++++++---------
 xen/include/asm-ia64/grant_table.h    |    6 ++++--
 xen/include/asm-powerpc/grant_table.h |   11 ++++-------
 xen/include/asm-x86/grant_table.h     |   14 ++++++--------
 4 files changed, 29 insertions(+), 26 deletions(-)

diff -r 746fc8fe9d75 -r cb3e47897b85 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Mon Feb 25 10:56:23 2008 +0000
+++ b/xen/common/grant_table.c  Mon Feb 25 11:24:06 2008 +0000
@@ -350,10 +350,10 @@ __gnttab_map_grant_ref(
     else
     {
         if ( unlikely(!mfn_valid(frame)) ||
-             unlikely(!((op->flags & GNTMAP_readonly) ?
-                        get_page(mfn_to_page(frame), rd) :
+             unlikely(!(gnttab_host_mapping_get_page_type(op, ld, rd) ?
                         get_page_and_type(mfn_to_page(frame), rd,
-                                          PGT_writable_page))) )
+                                          PGT_writable_page) :
+                        get_page(mfn_to_page(frame), rd))) )
         {
             if ( !rd->is_dying )
                 gdprintk(XENLOG_WARNING, "Could not pin grant frame %lx\n",
@@ -367,7 +367,7 @@ __gnttab_map_grant_ref(
             rc = create_grant_host_mapping(op->host_addr, frame, op->flags, 0);
             if ( rc != GNTST_okay )
             {
-                if ( !(op->flags & GNTMAP_readonly) )
+                if ( gnttab_host_mapping_get_page_type(op, ld, rd) )
                     put_page_type(mfn_to_page(frame));
                 put_page(mfn_to_page(frame));
                 goto undo_out;
@@ -604,7 +604,7 @@ __gnttab_unmap_common_complete(struct gn
 
         if ( !is_iomem_page(op->frame) ) 
         {
-            if ( !(op->flags & GNTMAP_readonly) )
+            if ( gnttab_host_mapping_get_page_type(op, ld, rd) )
                 put_page_type(mfn_to_page(op->frame));
             put_page(mfn_to_page(op->frame));
         }
@@ -1662,8 +1662,9 @@ gnttab_release_mappings(
             {
                 BUG_ON(!(act->pin & GNTPIN_hstr_mask));
                 act->pin -= GNTPIN_hstr_inc;
-                if ( !is_iomem_page(act->frame) )
-                    gnttab_release_put_page(mfn_to_page(act->frame));
+                if ( gnttab_release_host_mappings &&
+                     !is_iomem_page(act->frame) )
+                    put_page(mfn_to_page(act->frame));
             }
         }
         else
@@ -1680,8 +1681,13 @@ gnttab_release_mappings(
             {
                 BUG_ON(!(act->pin & GNTPIN_hstw_mask));
                 act->pin -= GNTPIN_hstw_inc;
-                if ( !is_iomem_page(act->frame) )
-                    gnttab_release_put_page_and_type(mfn_to_page(act->frame));
+                if ( gnttab_release_host_mappings &&
+                     !is_iomem_page(act->frame) )
+                {
+                    if ( gnttab_host_mapping_get_page_type(map, d, rd) )
+                        put_page_type(mfn_to_page(act->frame));
+                    put_page(mfn_to_page(act->frame));
+                }
             }
 
             if ( (act->pin & (GNTPIN_devw_mask|GNTPIN_hstw_mask)) == 0 )
diff -r 746fc8fe9d75 -r cb3e47897b85 xen/include/asm-ia64/grant_table.h
--- a/xen/include/asm-ia64/grant_table.h        Mon Feb 25 10:56:23 2008 +0000
+++ b/xen/include/asm-ia64/grant_table.h        Mon Feb 25 11:24:06 2008 +0000
@@ -65,8 +65,10 @@ static inline void gnttab_clear_flag(uns
        clear_bit(nr, addr);
 }
 
-#define gnttab_release_put_page(page)           put_page((page))
-#define gnttab_release_put_page_and_type(page)  put_page_and_type((page))
+#define gnttab_host_mapping_get_page_type(op, ld, rd)   \
+    (!((op)->flags & GNTMAP_readonly))
+
+#define gnttab_release_host_mappings 1
 
 static inline int replace_grant_supported(void)
 {
diff -r 746fc8fe9d75 -r cb3e47897b85 xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h     Mon Feb 25 10:56:23 2008 +0000
+++ b/xen/include/asm-powerpc/grant_table.h     Mon Feb 25 11:24:06 2008 +0000
@@ -76,17 +76,14 @@ static inline uint cpu_foreign_map_order
     return 34 - PAGE_SHIFT;
 }
 
-#if 0
+#define gnttab_host_mapping_get_page_type(op, ld, rd)   \
+    (!((op)->flags & GNTMAP_readonly))
+
 /*
  * without put_page()/put_page_and_type() page might be leaked.
  * with put_page()/put_page_and_type() freed page might be accessed.
  */
-#define gnttab_release_put_page(page)           put_page((page))
-#define gnttab_release_put_page_and_type(page)  put_page_and_type((page))
-#else
-#define gnttab_release_put_page(page)           do { } while (0)
-#define gnttab_release_put_page_and_type(page)  do { } while (0)
-#endif
+#define gnttab_release_host_mappings 0
 
 static inline int replace_grant_supported(void)
 {
diff -r 746fc8fe9d75 -r cb3e47897b85 xen/include/asm-x86/grant_table.h
--- a/xen/include/asm-x86/grant_table.h Mon Feb 25 10:56:23 2008 +0000
+++ b/xen/include/asm-x86/grant_table.h Mon Feb 25 11:24:06 2008 +0000
@@ -38,15 +38,13 @@ static inline void gnttab_clear_flag(uns
     clear_bit(nr, addr);
 }
 
-#define gnttab_release_put_page(page)                           \
-    do {                                                        \
-        /* Done implicitly when page tables are destroyed. */   \
-    } while (0)
+/* Foreign mappings of HHVM-guest pages do not modify the type count. */
+#define gnttab_host_mapping_get_page_type(op, ld, rd)   \
+    (!((op)->flags & GNTMAP_readonly) &&                \
+     (((ld) == (rd)) || !paging_mode_external(rd)))
 
-#define gnttab_release_put_page_and_type(page)                  \
-    do {                                                        \
-        /* Done implicitly when page tables are destroyed. */   \
-    } while (0)
+/* Done implicitly when page tables are destroyed. */
+#define gnttab_release_host_mappings 0
 
 static inline int replace_grant_supported(void)
 {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86: Foreign mappings of HVM-guest pages should not affect type count,, Xen patchbot-unstable <=