Get the network interface working in shadow translate mode. This
authorsos22@douglas.cl.cam.ac.uk <sos22@douglas.cl.cam.ac.uk>
Thu, 26 Jan 2006 13:33:20 +0000 (14:33 +0100)
committersos22@douglas.cl.cam.ac.uk <sos22@douglas.cl.cam.ac.uk>
Thu, 26 Jan 2006 13:33:20 +0000 (14:33 +0100)
required a few extra __gpfn_to_mfn translations, and also required a
minor change in the grant tables interface: if we're in shadow
translate mode, then shared->frame is supposed to be the pfn you want
to map the new mfn to when accepting a grant transfer, and Xen handles
updating the M2P and P2M tables for you.

Signed-off-by: Steven Smith, sos22@cam.ac.uk
xen/common/grant_table.c
xen/common/memory.c

index 3f788ca34f720537bdd7ff4dbaea4514dca8e912..6bdbca6269c9b932d82b0c879b57f492ab6e14c3 100644 (file)
@@ -711,6 +711,7 @@ gnttab_transfer(
     int i;
     grant_entry_t *sha;
     gnttab_transfer_t gop;
+    unsigned long real_mfn;
 
     for ( i = 0; i < count; i++ )
     {
@@ -731,7 +732,8 @@ gnttab_transfer(
             continue;
         }
 
-        page = pfn_to_page(gop.mfn);
+        real_mfn = __gpfn_to_mfn(d, gop.mfn);
+        page = pfn_to_page(real_mfn);
         if ( unlikely(IS_XEN_HEAP_FRAME(page)) )
         { 
             DPRINTK("gnttab_transfer: xen frame %lx\n",
@@ -792,7 +794,21 @@ gnttab_transfer(
 
         /* Tell the guest about its new page frame. */
         sha = &e->grant_table->shared[gop.ref];
-        sha->frame = gop.mfn;
+        if (shadow_mode_translate(e)) {
+            struct domain_mmap_cache c1, c2;
+            unsigned long pfn = sha->frame;
+            domain_mmap_cache_init(&c1);
+            domain_mmap_cache_init(&c2);
+            shadow_lock(e);
+            shadow_sync_and_drop_references(e, page);
+            set_p2m_entry(e, pfn, real_mfn, &c1, &c2);
+            set_pfn_from_mfn(real_mfn, pfn);
+            shadow_unlock(e);
+            domain_mmap_cache_destroy(&c1);
+            domain_mmap_cache_destroy(&c2);
+        } else {
+            sha->frame = real_mfn;
+        }
         wmb();
         sha->flags |= GTF_transfer_completed;
 
index ddad691d29a771d3671d3e7d06cc70485484ca13..c52107105418aa5d5f8cd3612f59b10e282f0d72 100644 (file)
@@ -76,7 +76,7 @@ decrease_reservation(
     int           *preempted)
 {
     struct pfn_info *page;
-    unsigned long    i, j, mpfn;
+    unsigned long    i, j, mpfn, mfn;
 
     if ( !array_access_ok(extent_list, nr_extents, sizeof(*extent_list)) )
         return 0;
@@ -94,14 +94,15 @@ decrease_reservation(
 
         for ( j = 0; j < (1 << extent_order); j++ )
         {
-            if ( unlikely((mpfn + j) >= max_page) )
+            mfn = __gpfn_to_mfn(d, mpfn + j);
+            if ( unlikely(mfn >= max_page) )
             {
                 DPRINTK("Domain %u page number out of range (%lx >= %lx)\n", 
-                        d->domain_id, mpfn + j, max_page);
+                        d->domain_id, mfn, max_page);
                 return i;
             }
             
-            page = pfn_to_page(mpfn + j);
+            page = pfn_to_page(mfn);
             if ( unlikely(!get_page(page, d)) )
             {
                 DPRINTK("Bad page free for domain %u\n", d->domain_id);