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

Re: [Xen-devel] [PATCH RFC v13 19/20] PVH xen tools: libxc changes to build a PVH guest.



On 18/10/13 17:45, Roger Pau Monné wrote:
This patch is incomplete, PVH guests with 4GB of RAM or more will fail
to boot due to libxc temporary mapping the grant table to gfn 0xFFFFE,
which is an invalid gfn on HVM guests, but not on PVH guests. When
libxc removes the mapping of 0xFFFFE it will leave an invalid mfn in
the p2m table, that will make the guest crash when trying to access
that gfn.

The easiest way I've found to solve this is to temporary map the grant
table to the maximum gfn + 1. This fixes the PVH issue, and also seems
to work fine with HVM guests, here is the diff which should probably be
integrated into this patch:

Thanks Roger.  I assume it's OK to add your sign-off to this patch?

 -George


---
diff --git a/tools/libxc/xc_dom.h b/tools/libxc/xc_dom.h
index 5168bcd..90679da 100644
--- a/tools/libxc/xc_dom.h
+++ b/tools/libxc/xc_dom.h
@@ -18,9 +18,6 @@
#define INVALID_P2M_ENTRY ((xen_pfn_t)-1) -/* Scrach PFN for temporary mappings in HVM */
-#define SCRATCH_PFN_GNTTAB 0xFFFFE
-
  /* --- typedefs and structs ---------------------------------------- */
typedef uint64_t xen_vaddr_t;
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index 71e1897..fdfeaf8 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -361,17 +361,27 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, domid_t 
domid,
                             domid_t xenstore_domid)
  {
      int rc;
+    xen_pfn_t max_gfn;
      struct xen_add_to_physmap xatp = {
          .domid = domid,
          .space = XENMAPSPACE_grant_table,
          .idx   = 0,
-        .gpfn  = SCRATCH_PFN_GNTTAB
      };
      struct xen_remove_from_physmap xrfp = {
          .domid = domid,
-        .gpfn  = SCRATCH_PFN_GNTTAB
      };
+ max_gfn = xc_domain_maximum_gpfn(xch, domid);
+    if ( max_gfn <= 0 ) {
+        xc_dom_panic(xch, XC_INTERNAL_ERROR,
+                     "%s: failed to get max gfn "
+                     "[errno=%d]\n",
+                     __FUNCTION__, errno);
+        return -1;
+    }
+    xatp.gpfn = max_gfn + 1;
+    xrfp.gpfn = max_gfn + 1;
+
      rc = do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
      if ( rc != 0 )
      {



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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