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

[Xen-changelog] [xen master] Revert "tools/dombuilder: Switch to using gfn terminology for console and xenstore rings"



commit 1f61c07d79abda1e747d70d83edffe4efca48e17
Author:     Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Mon Nov 6 14:52:39 2017 +0000
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon Nov 6 14:52:39 2017 +0000

    Revert "tools/dombuilder: Switch to using gfn terminology for console and 
xenstore rings"
    
    This reverts commit f48b5449dabc770acdde6d25cfbd265cfb71034d, which
    breaks pvgrub.
    
    Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 stubdom/grub/kexec.c              |  4 ++--
 tools/libxc/include/xc_dom.h      | 10 ++-------
 tools/libxc/xc_dom_arm.c          | 12 +++++------
 tools/libxc/xc_dom_boot.c         | 45 +++++++++++++++++++++------------------
 tools/libxc/xc_dom_compat_linux.c |  4 ++--
 tools/libxc/xc_dom_x86.c          | 45 +++++++++++++++++++--------------------
 tools/libxl/libxl_dom.c           | 11 +++++++---
 7 files changed, 66 insertions(+), 65 deletions(-)

diff --git a/stubdom/grub/kexec.c b/stubdom/grub/kexec.c
index e744561..437a0a9 100644
--- a/stubdom/grub/kexec.c
+++ b/stubdom/grub/kexec.c
@@ -312,8 +312,8 @@ void kexec(void *kernel, long kernel_size, void *module, 
long module_size, char
     }
 
     /* Move current console, xenstore and boot MFNs to the allocated place */
-    do_exchange(dom, dom->console_gfn, start_info.console.domU.mfn);
-    do_exchange(dom, dom->xenstore_gfn, start_info.store_mfn);
+    do_exchange(dom, dom->console_pfn, start_info.console.domU.mfn);
+    do_exchange(dom, dom->xenstore_pfn, start_info.store_mfn);
     DEBUG("virt base at %llx\n", dom->parms.virt_base);
     DEBUG("bootstack_pfn %lx\n", dom->bootstack_pfn);
     _boot_target = dom->parms.virt_base + PFN_PHYS(dom->bootstack_pfn);
diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h
index 5907559..cdcdd07 100644
--- a/tools/libxc/include/xc_dom.h
+++ b/tools/libxc/include/xc_dom.h
@@ -94,6 +94,8 @@ struct xc_dom_image {
     struct xc_dom_seg devicetree_seg;
     struct xc_dom_seg start_info_seg; /* HVMlite only */
     xen_pfn_t start_info_pfn;
+    xen_pfn_t console_pfn;
+    xen_pfn_t xenstore_pfn;
     xen_pfn_t shared_info_pfn;
     xen_pfn_t bootstack_pfn;
     xen_pfn_t pfn_alloc_end;
@@ -101,14 +103,6 @@ struct xc_dom_image {
     xen_vaddr_t bsd_symtab_start;
 
     /*
-     * Details for the toolstack-prepared rings.
-     *
-     * *_gfn fields are allocated by the domain builder.
-     */
-    xen_pfn_t console_gfn;
-    xen_pfn_t xenstore_gfn;
-
-    /*
      * initrd parameters as specified in start_info page
      * Depending on capabilities of the booted kernel this may be a virtual
      * address or a pfn. Type is neutral and large enough to hold a virtual
diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c
index 2fe75cd..fce151d 100644
--- a/tools/libxc/xc_dom_arm.c
+++ b/tools/libxc/xc_dom_arm.c
@@ -84,19 +84,19 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
     if ( rc < 0 )
         return rc;
 
-    dom->console_gfn = base + CONSOLE_PFN_OFFSET;
-    dom->xenstore_gfn = base + XENSTORE_PFN_OFFSET;
+    dom->console_pfn = base + CONSOLE_PFN_OFFSET;
+    dom->xenstore_pfn = base + XENSTORE_PFN_OFFSET;
     dom->vuart_gfn = base + VUART_PFN_OFFSET;
 
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn);
     xc_clear_domain_page(dom->xch, dom->guest_domid, base + 
MEMACCESS_PFN_OFFSET);
     xc_clear_domain_page(dom->xch, dom->guest_domid, dom->vuart_gfn);
 
     xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_CONSOLE_PFN,
-            dom->console_gfn);
+            dom->console_pfn);
     xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_PFN,
-            dom->xenstore_gfn);
+            dom->xenstore_pfn);
     xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_MONITOR_RING_PFN,
             base + MEMACCESS_PFN_OFFSET);
     /* allocated by toolstack */
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index bbf98b6..2e5681d 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -257,23 +257,24 @@ static xen_pfn_t xc_dom_gnttab_setup(xc_interface *xch, 
uint32_t domid)
 }
 
 int xc_dom_gnttab_seed(xc_interface *xch, uint32_t domid,
-                       xen_pfn_t console_gfn,
-                       xen_pfn_t xenstore_gfn,
+                       xen_pfn_t console_gmfn,
+                       xen_pfn_t xenstore_gmfn,
                        uint32_t console_domid,
                        uint32_t xenstore_domid)
 {
-    xen_pfn_t gnttab_gfn;
+
+    xen_pfn_t gnttab_gmfn;
     grant_entry_v1_t *gnttab;
 
-    gnttab_gfn = xc_dom_gnttab_setup(xch, domid);
-    if ( gnttab_gfn == -1 )
+    gnttab_gmfn = xc_dom_gnttab_setup(xch, domid);
+    if ( gnttab_gmfn == -1 )
         return -1;
 
     gnttab = xc_map_foreign_range(xch,
                                   domid,
                                   PAGE_SIZE,
                                   PROT_READ|PROT_WRITE,
-                                  gnttab_gfn);
+                                  gnttab_gmfn);
     if ( gnttab == NULL )
     {
         xc_dom_panic(xch, XC_INTERNAL_ERROR,
@@ -283,17 +284,17 @@ int xc_dom_gnttab_seed(xc_interface *xch, uint32_t domid,
         return -1;
     }
 
-    if ( domid != console_domid && console_gfn != -1 )
+    if ( domid != console_domid  && console_gmfn != -1)
     {
         gnttab[GNTTAB_RESERVED_CONSOLE].flags = GTF_permit_access;
         gnttab[GNTTAB_RESERVED_CONSOLE].domid = console_domid;
-        gnttab[GNTTAB_RESERVED_CONSOLE].frame = console_gfn;
+        gnttab[GNTTAB_RESERVED_CONSOLE].frame = console_gmfn;
     }
-    if ( domid != xenstore_domid && xenstore_gfn != -1 )
+    if ( domid != xenstore_domid && xenstore_gmfn != -1)
     {
         gnttab[GNTTAB_RESERVED_XENSTORE].flags = GTF_permit_access;
         gnttab[GNTTAB_RESERVED_XENSTORE].domid = xenstore_domid;
-        gnttab[GNTTAB_RESERVED_XENSTORE].frame = xenstore_gfn;
+        gnttab[GNTTAB_RESERVED_XENSTORE].frame = xenstore_gmfn;
     }
 
     if ( munmap(gnttab, PAGE_SIZE) == -1 )
@@ -307,19 +308,19 @@ int xc_dom_gnttab_seed(xc_interface *xch, uint32_t domid,
 
     /* Guest shouldn't really touch its grant table until it has
      * enabled its caches. But lets be nice. */
-    xc_domain_cacheflush(xch, domid, gnttab_gfn, 1);
+    xc_domain_cacheflush(xch, domid, gnttab_gmfn, 1);
 
     return 0;
 }
 
 int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t domid,
-                           xen_pfn_t console_gfn,
-                           xen_pfn_t xenstore_gfn,
+                           xen_pfn_t console_gpfn,
+                           xen_pfn_t xenstore_gpfn,
                            uint32_t console_domid,
                            uint32_t xenstore_domid)
 {
     int rc;
-    xen_pfn_t scratch_gfn;
+    xen_pfn_t scratch_gpfn;
     struct xen_add_to_physmap xatp = {
         .domid = domid,
         .space = XENMAPSPACE_grant_table,
@@ -329,7 +330,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t 
domid,
         .domid = domid,
     };
 
-    rc = xc_core_arch_get_scratch_gpfn(xch, domid, &scratch_gfn);
+    rc = xc_core_arch_get_scratch_gpfn(xch, domid, &scratch_gpfn);
     if ( rc < 0 )
     {
         xc_dom_panic(xch, XC_INTERNAL_ERROR,
@@ -338,10 +339,11 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t 
domid,
                      __FUNCTION__, errno);
         return -1;
     }
-    xatp.gpfn = xrfp.gpfn = scratch_gfn;
+    xatp.gpfn = scratch_gpfn;
+    xrfp.gpfn = scratch_gpfn;
 
-    xc_dom_printf(xch, "%s: called, scratch gfn=0x%"PRI_xen_pfn, __FUNCTION__,
-                  scratch_gfn);
+    xc_dom_printf(xch, "%s: called, pfn=0x%"PRI_xen_pfn, __FUNCTION__,
+                  scratch_gpfn);
 
 
     rc = do_memory_op(xch, XENMEM_add_to_physmap, &xatp, sizeof(xatp));
@@ -355,7 +357,7 @@ int xc_dom_gnttab_hvm_seed(xc_interface *xch, uint32_t 
domid,
     }
 
     rc = xc_dom_gnttab_seed(xch, domid,
-                            console_gfn, xenstore_gfn,
+                            console_gpfn, xenstore_gpfn,
                             console_domid, xenstore_domid);
     if (rc != 0)
     {
@@ -383,11 +385,12 @@ int xc_dom_gnttab_init(struct xc_dom_image *dom)
 {
     if ( xc_dom_translated(dom) ) {
         return xc_dom_gnttab_hvm_seed(dom->xch, dom->guest_domid,
-                                      dom->console_gfn, dom->xenstore_gfn,
+                                      dom->console_pfn, dom->xenstore_pfn,
                                       dom->console_domid, dom->xenstore_domid);
     } else {
         return xc_dom_gnttab_seed(dom->xch, dom->guest_domid,
-                                  dom->console_gfn, dom->xenstore_gfn,
+                                  xc_dom_p2m(dom, dom->console_pfn),
+                                  xc_dom_p2m(dom, dom->xenstore_pfn),
                                   dom->console_domid, dom->xenstore_domid);
     }
 }
diff --git a/tools/libxc/xc_dom_compat_linux.c 
b/tools/libxc/xc_dom_compat_linux.c
index 6d27ec2..c922c61 100644
--- a/tools/libxc/xc_dom_compat_linux.c
+++ b/tools/libxc/xc_dom_compat_linux.c
@@ -78,8 +78,8 @@ int xc_linux_build(xc_interface *xch, uint32_t domid,
     if ( (rc = xc_dom_gnttab_init(dom)) != 0)
         goto out;
 
-    *console_mfn = dom->console_gfn;
-    *store_mfn = dom->xenstore_gfn;
+    *console_mfn = xc_dom_p2m(dom, dom->console_pfn);
+    *store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
 
  out:
     xc_dom_release(dom);
diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index c74fb96..bff68a0 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -536,23 +536,21 @@ static int alloc_p2m_list_x86_64(struct xc_dom_image *dom)
 
 static int alloc_magic_pages_pv(struct xc_dom_image *dom)
 {
-    xen_pfn_t pfn;
-
     dom->start_info_pfn = xc_dom_alloc_page(dom, "start info");
     if ( dom->start_info_pfn == INVALID_PFN )
         return -1;
 
-    pfn = xc_dom_alloc_page(dom, "xenstore");
-    if ( pfn == INVALID_PFN )
+    dom->xenstore_pfn = xc_dom_alloc_page(dom, "xenstore");
+    if ( dom->xenstore_pfn == INVALID_PFN )
         return -1;
-    dom->xenstore_gfn = xc_dom_p2m(dom, pfn);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid,
+                         xc_dom_p2m(dom, dom->xenstore_pfn));
 
-    pfn = xc_dom_alloc_page(dom, "console");
-    if ( pfn == INVALID_PFN )
+    dom->console_pfn = xc_dom_alloc_page(dom, "console");
+    if ( dom->console_pfn == INVALID_PFN )
         return -1;
-    dom->console_gfn = xc_dom_p2m(dom, pfn);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
+    xc_clear_domain_page(dom->xch, dom->guest_domid,
+                         xc_dom_p2m(dom, dom->console_pfn));
 
     dom->alloc_bootstack = 1;
 
@@ -614,19 +612,14 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
                                X86_HVM_NR_SPECIAL_PAGES) )
             goto error_out;
 
-    dom->xenstore_gfn = special_pfn(SPECIALPAGE_XENSTORE);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_gfn);
-    xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN, dom->xenstore_gfn);
-
+    xc_hvm_param_set(xch, domid, HVM_PARAM_STORE_PFN,
+                     special_pfn(SPECIALPAGE_XENSTORE));
     xc_hvm_param_set(xch, domid, HVM_PARAM_BUFIOREQ_PFN,
                      special_pfn(SPECIALPAGE_BUFIOREQ));
     xc_hvm_param_set(xch, domid, HVM_PARAM_IOREQ_PFN,
                      special_pfn(SPECIALPAGE_IOREQ));
-
-    dom->console_gfn = special_pfn(SPECIALPAGE_CONSOLE);
-    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_gfn);
-    xc_hvm_param_set(xch, domid, HVM_PARAM_CONSOLE_PFN, dom->console_gfn);
-
+    xc_hvm_param_set(xch, domid, HVM_PARAM_CONSOLE_PFN,
+                     special_pfn(SPECIALPAGE_CONSOLE));
     xc_hvm_param_set(xch, domid, HVM_PARAM_PAGING_RING_PFN,
                      special_pfn(SPECIALPAGE_PAGING));
     xc_hvm_param_set(xch, domid, HVM_PARAM_MONITOR_RING_PFN,
@@ -706,6 +699,12 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom)
     xc_hvm_param_set(xch, domid, HVM_PARAM_IDENT_PT,
                      special_pfn(SPECIALPAGE_IDENT_PT) << PAGE_SHIFT);
 
+    dom->console_pfn = special_pfn(SPECIALPAGE_CONSOLE);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->console_pfn);
+
+    dom->xenstore_pfn = special_pfn(SPECIALPAGE_XENSTORE);
+    xc_clear_domain_page(dom->xch, dom->guest_domid, dom->xenstore_pfn);
+
     dom->parms.virt_hypercall = -1;
 
     rc = 0;
@@ -745,9 +744,9 @@ static int start_info_x86_32(struct xc_dom_image *dom)
     start_info->mfn_list = dom->p2m_seg.vstart;
 
     start_info->flags = dom->flags;
-    start_info->store_mfn = dom->xenstore_gfn;
+    start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
     start_info->store_evtchn = dom->xenstore_evtchn;
-    start_info->console.domU.mfn = dom->console_gfn;
+    start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn);
     start_info->console.domU.evtchn = dom->console_evtchn;
 
     if ( dom->ramdisk_blob )
@@ -796,9 +795,9 @@ static int start_info_x86_64(struct xc_dom_image *dom)
     }
 
     start_info->flags = dom->flags;
-    start_info->store_mfn = dom->xenstore_gfn;
+    start_info->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
     start_info->store_evtchn = dom->xenstore_evtchn;
-    start_info->console.domU.mfn = dom->console_gfn;
+    start_info->console.domU.mfn = xc_dom_p2m(dom, dom->console_pfn);
     start_info->console.domU.evtchn = dom->console_evtchn;
 
     if ( dom->ramdisk_blob )
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index 0389a06..ef834e6 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -851,9 +851,14 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
     if (ret != 0)
         goto out;
 
-    state->console_mfn = dom->console_gfn;
-    state->store_mfn = dom->xenstore_gfn;
-    state->vuart_gfn = dom->vuart_gfn;
+    if (xc_dom_translated(dom)) {
+        state->console_mfn = dom->console_pfn;
+        state->store_mfn = dom->xenstore_pfn;
+        state->vuart_gfn = dom->vuart_gfn;
+    } else {
+        state->console_mfn = xc_dom_p2m(dom, dom->console_pfn);
+        state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
+    }
 
     ret = 0;
 out:
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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