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] Sharable/shared pages need to be unshared

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] Sharable/shared pages need to be unshared in responce to a write attempt. This
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 16 Dec 2009 22:40:57 -0800
Delivery-date: Wed, 16 Dec 2009 22:42:38 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 1261031276 0
# Node ID 34d620a47c636c0c72b1270ef6410953909a1bdc
# Parent  7d841016536f4e5de66b387114c8e4ed67f76148
Sharable/shared pages need to be unshared in responce to a write attempt. This
is handled through custom gfn_to_mfn transation functions called from generic
host page table page fault handler. This should handle both SVM and VTX alike.

Signed-off-by: Grzegorz Milos <Grzegorz.Milos@xxxxxxxxxx>
---
 xen/arch/x86/hvm/hvm.c    |   15 +++++++++++++--
 xen/include/asm-x86/p2m.h |   25 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff -r 7d841016536f -r 34d620a47c63 xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu Dec 17 06:27:56 2009 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Thu Dec 17 06:27:56 2009 +0000
@@ -1325,12 +1325,14 @@ static void *hvm_map_entry(unsigned long
     gfn = paging_gva_to_gfn(current, va, &pfec);
     if ( pfec == PFEC_page_paged )
         return NULL;
-    mfn = mfn_x(gfn_to_mfn_current(gfn, &p2mt));
+    mfn = mfn_x(gfn_to_mfn_unshare(current->domain, gfn, &p2mt, 0));
     if ( p2m_is_paging(p2mt) )
     {
         p2m_mem_paging_populate(current->domain, gfn);
         return NULL;
     }
+    if ( p2m_is_shared(p2mt) )
+        return NULL;
     if ( !p2m_is_ram(p2mt) )
     {
         gdprintk(XENLOG_ERR, "Failed to look up descriptor table entry\n");
@@ -2986,6 +2988,10 @@ long do_hvm_op(unsigned long op, XEN_GUE
                 rc = -EINVAL;
                 goto param_fail3;
             }
+            if( p2m_is_shared(t) )
+                gdprintk(XENLOG_WARNING,
+                         "shared pfn 0x%lx modified?\n", pfn);
+            
             if ( mfn_x(mfn) != INVALID_MFN )
             {
                 paging_mark_dirty(d, mfn_x(mfn));
@@ -3038,7 +3044,7 @@ long do_hvm_op(unsigned long op, XEN_GUE
             p2m_type_t t;
             p2m_type_t nt;
             mfn_t mfn;
-            mfn = gfn_to_mfn(d, pfn, &t);
+            mfn = gfn_to_mfn_unshare(d, pfn, &t, 0);
             if ( p2m_is_paging(t) )
             {
                 p2m_mem_paging_populate(d, pfn);
@@ -3046,6 +3052,11 @@ long do_hvm_op(unsigned long op, XEN_GUE
                 rc = -EINVAL;
                 goto param_fail4;
             }
+            if ( p2m_is_shared(t) )
+            {
+                rc = -EINVAL;
+                goto param_fail4;
+            } 
             if ( p2m_is_grant(t) )
             {
                 gdprintk(XENLOG_WARNING,
diff -r 7d841016536f -r 34d620a47c63 xen/include/asm-x86/p2m.h
--- a/xen/include/asm-x86/p2m.h Thu Dec 17 06:27:56 2009 +0000
+++ b/xen/include/asm-x86/p2m.h Thu Dec 17 06:27:56 2009 +0000
@@ -308,6 +308,31 @@ static inline mfn_t _gfn_to_mfn_type(str
 #define gfn_to_mfn_current(g, t) gfn_to_mfn_type_current((g), (t), p2m_alloc)
 #define gfn_to_mfn_foreign(d, g, t) gfn_to_mfn_type_foreign((d), (g), (t), 
p2m_alloc)
 
+static inline mfn_t gfn_to_mfn_unshare(struct domain *d,
+                                       unsigned long gfn,
+                                       p2m_type_t *p2mt,
+                                       int must_succeed)
+{
+    mfn_t mfn;
+    int ret;
+
+    mfn = gfn_to_mfn(d, gfn, p2mt);
+    if(p2m_is_shared(*p2mt))
+    {
+        ret = mem_sharing_unshare_page(d, gfn,
+                must_succeed ? MEM_SHARING_MUST_SUCCEED : 0);
+        if(ret < 0)
+        {
+            BUG_ON(must_succeed);
+            return mfn;
+        }
+        mfn = gfn_to_mfn(d, gfn, p2mt);
+    }
+
+    return mfn;
+}
+
+
 /* Compatibility function exporting the old untyped interface */
 static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gpfn)
 {

_______________________________________________
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] Sharable/shared pages need to be unshared in responce to a write attempt. This, Xen patchbot-unstable <=