Skip to contentSkip to conversation

seed grant tables of new domUs with grant of store_mfn to xenstore domain

PATCH In review Alex Zeffertt 1 participant 1 message Mar 23, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 3/24 seed grant tables of new domUs with grant of store_mfn to xenstore domain

(Also seed grant table with grant of console page to consoled domain to support creation of a console stub domain in the future.)

This patch claims one reserved grant entry for the console and another for the xenstore. It modifies the builder to fill in the grant table entries for the console and the xenstore. At this stage, the grant entries just give access to domain 0 (addressed in a later patch).

This depends on Samuel's XENMEM_remove_from_physmap.

This has not been tested with regular or live migration, or anything too weird. I did test pausing and unpausing pv and hvm domains at some point.

TODO: Keir says not to call setup_table for hvm domains. It's a no-op in the hypervisor currently.

TODO: We don't want to even alloc the xenstore page for the xenstore domain, since it won't use it all. Theoretically, you might have the same thing with a console domain. The easiest way to handle this is to make {console,xenstore}_domid global and compare the domid we're allocating a page for to those.

A previous version of this patch was sent to xen-devel. See
http://lists.xensource.com/archives/html/xen-devel/2008-07/msg00610.html

Derek Murray is particularly interested in this, and previously made a similar patch series but instead modified the hypervisor to do the seeding.

---

tools/libxc/xc_dom.h +6 -0
diff -r c27d56b60dad tools/libxc/xc_dom.h
@@ -179,6 +179,12 @@
                            xen_pfn_t count);
 int xc_dom_boot_image(struct xc_dom_image *dom);
 int xc_dom_compat_check(struct xc_dom_image *dom);
+int xc_dom_gnttab_init(struct xc_dom_image *dom);
+int xc_dom_gnttab_hvm_seed(int xc_handle, uint32_t domid,
+                           unsigned long xenstore_gpfn);
+int xc_dom_gnttab_seed(int xc_handle, uint32_t domid,
+                       unsigned long console_gmfn,
+                       unsigned long xenstore_gmfn);
 
 /* --- debugging bits ---------------------------------------------- */
 
tools/libxc/xc_dom_boot.c +155 -0

167 lines not on this page · raw message

tools/libxc/xc_dom_compat_linux.c +2 -0
diff -r c27d56b60dad tools/libxc/xc_dom_compat_linux.c
@@ -47,6 +47,8 @@
     if ( (rc = xc_dom_build_image(dom)) != 0 )
         goto out;
     if ( (rc = xc_dom_boot_image(dom)) != 0 )
+        goto out;
+    if ( (rc = xc_dom_gnttab_init(dom)) != 0)
         goto out;
 
     *console_mfn = xc_dom_p2m_host(dom, dom->console_pfn);
tools/libxc/xc_domain_restore.c +16 -0
diff -r c27d56b60dad tools/libxc/xc_domain_restore.c
@@ -778,6 +778,13 @@
             goto out;
         }
 
+        rc = xc_dom_gnttab_hvm_seed(xc_handle, dom, *store_mfn);
+        if (rc != 0)
+        {
+            ERROR("error seeding grant table");
+            goto out;
+        }
+
         /* HVM success! */
         rc = 0;
         goto out;
@@ -1205,6 +1212,15 @@
         memcpy(live_p2m, p2m, p2m_size * sizeof(xen_pfn_t));
     munmap(live_p2m, P2M_FL_ENTRIES * PAGE_SIZE);
 
+    /* TODO: what about non-hvm but auto-translated? */
+    rc = xc_dom_gnttab_seed(xc_handle, dom,
+                            *console_mfn, *store_mfn);
+    if (rc != 0)
+    {
+        ERROR("error seeding grant table");
+        goto out;
+    }
+
     DPRINTF("Domain ready to be built.\n");
     rc = 0;
 
tools/libxc/xc_hvm_build.c +7 -0
diff -r c27d56b60dad tools/libxc/xc_hvm_build.c
@@ -10,6 +10,7 @@
 
 #include "xg_private.h"
 #include "xc_private.h"
+#include "xc_dom.h"
 
 #include <xen/foreign/x86_32.h>
 #include <xen/foreign/x86_64.h>
@@ -318,6 +319,12 @@
         munmap(page0, PAGE_SIZE);
     }
 
+    rc = xc_dom_gnttab_hvm_seed(xc_handle, dom,
+                                special_pfn(SPECIALPAGE_XENSTORE));
+ 
+    if (rc != 0)
+        goto error_out;
+
     free(page_array);
     return 0;
 
xen/include/public/grant_table.h +6 -0
diff -r c27d56b60dad xen/include/public/grant_table.h
@@ -101,6 +101,12 @@
     uint32_t frame;
 };
 typedef struct grant_entry grant_entry_t;
+
+/* External tools reserve first few grant table entries. */
+#define GNTTAB_NR_RESERVED_ENTRIES     8
+#define GNTTAB_RESERVED_CONSOLE        0
+#define GNTTAB_RESERVED_XENSTORE       1
+/* (the next 6 are reserved for future use) */
 
 /*
  * Type of grant entry.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel