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

[Xen-devel] [PATCH 2/4 v3] libxl: Change the type of console_mfn to xen_pfn_t



Currently the type of console mfn is unsigned long in libxl. This may be
an issue for 32-bit toolstack running on 64-bit Xen, where the pfn are
64 bit. To ensure that console_mfn can hold any valid 64-bit pfn, the
type of console_mfn is changed to xen_pfn_t.

Also the name console_mfn is misleading as it is actually a gfn. This
patch also modifies the name to console_gfn.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@xxxxxxxxxx>
---
CC: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
CC: Wei Liu <wei.liu2@xxxxxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien.grall@xxxxxxx>

This patch is as per the review of commit fa1f157
    libxl: Fix the bug introduced in commit "libxl: use correct type

 tools/libxc/include/xenctrl_compat.h |  2 +-
 tools/libxc/xc_foreign_memory.c      |  4 ++--
 tools/libxl/libxl_console.c          |  2 +-
 tools/libxl/libxl_create.c           | 10 +++++-----
 tools/libxl/libxl_dom.c              | 12 ++++++------
 tools/libxl/libxl_internal.h         |  2 +-
 tools/libxl/libxl_save_helper.c      |  6 +++---
 7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/tools/libxc/include/xenctrl_compat.h 
b/tools/libxc/include/xenctrl_compat.h
index a655e47..5ee72bf 100644
--- a/tools/libxc/include/xenctrl_compat.h
+++ b/tools/libxc/include/xenctrl_compat.h
@@ -26,7 +26,7 @@
  */
 void *xc_map_foreign_range(xc_interface *xch, uint32_t dom,
                             int size, int prot,
-                            unsigned long mfn );
+                            xen_pfn_t pfn);
 
 void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, int prot,
                            const xen_pfn_t *arr, int num );
diff --git a/tools/libxc/xc_foreign_memory.c b/tools/libxc/xc_foreign_memory.c
index 4053d26..c1f114a 100644
--- a/tools/libxc/xc_foreign_memory.c
+++ b/tools/libxc/xc_foreign_memory.c
@@ -33,7 +33,7 @@ void *xc_map_foreign_pages(xc_interface *xch, uint32_t dom, 
int prot,
 
 void *xc_map_foreign_range(xc_interface *xch,
                            uint32_t dom, int size, int prot,
-                           unsigned long mfn)
+                           xen_pfn_t pfn)
 {
     xen_pfn_t *arr;
     int num;
@@ -46,7 +46,7 @@ void *xc_map_foreign_range(xc_interface *xch,
         return NULL;
 
     for ( i = 0; i < num; i++ )
-        arr[i] = mfn + i;
+        arr[i] = pfn + i;
 
     ret = xc_map_foreign_pages(xch, dom, prot, arr, num);
     free(arr);
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 6bfc0e5..f2ca689 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -329,7 +329,7 @@ int libxl__device_console_add(libxl__gc *gc, uint32_t domid,
         flexarray_append(ro_front, "port");
         flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->console_port));
         flexarray_append(ro_front, "ring-ref");
-        flexarray_append(ro_front, GCSPRINTF("%lu", state->console_mfn));
+        flexarray_append(ro_front, GCSPRINTF("%"PRIu_xen_pfn, 
state->console_mfn));
     } else {
         flexarray_append(front, "state");
         flexarray_append(front, GCSPRINTF("%d", XenbusStateInitialising));
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index f15fb21..26870ca 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1134,7 +1134,7 @@ static void domcreate_bootloader_done(libxl__egc *egc,
 }
 
 void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn,
-          xen_pfn_t console_mfn, void *user)
+          xen_pfn_t console_gfn, void *user)
 {
     libxl__save_helper_state *shs = user;
     libxl__domain_create_state *dcs = shs->caller_state;
@@ -1142,7 +1142,7 @@ void 
libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn,
     libxl__domain_build_state *const state = &dcs->build_state;
 
     state->store_mfn =            store_mfn;
-    state->console_mfn =          console_mfn;
+    state->console_gfn =          console_gfn;
     shs->need_results =           0;
 }
 
@@ -1740,7 +1740,7 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
     libxl__domain_create_state *dcs;
     libxl__domain_build_state *state;
     libxl__domain_save_state *dss;
-    const char *console_tty, *xs_store_mfn, *xs_console_mfn;
+    const char *console_tty, *xs_store_mfn, *xs_console_gfn;
     char *dom_path;
     uint32_t domid_out;
     int rc;
@@ -1781,12 +1781,12 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
 
     rc = libxl__xs_read_checked(gc, XBT_NULL,
                                 GCSPRINTF("%s/console/ring-ref", dom_path),
-                                &xs_console_mfn);
+                                &xs_console_gfn);
     if (rc) {
         LOGD(ERROR, domid_soft_reset, "failed to read console/ring-ref.");
         goto out;
     }
-    state->console_mfn = xs_console_mfn ? atol(xs_console_mfn): 0;
+    state->console_gfn = xs_console_gfn ? atol(xs_console_gfn): 0;
 
     rc = libxl__xs_read_mandatory(gc, XBT_NULL,
                                   GCSPRINTF("%s/console/tty", dom_path),
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index ef834e6..647dbf7 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -852,11 +852,11 @@ int libxl__build_pv(libxl__gc *gc, uint32_t domid,
         goto out;
 
     if (xc_dom_translated(dom)) {
-        state->console_mfn = dom->console_pfn;
+        state->console_gfn = 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->console_gfn = xc_dom_p2m(dom, dom->console_pfn);
         state->store_mfn = xc_dom_p2m(dom, dom->xenstore_pfn);
     }
 
@@ -869,7 +869,7 @@ out:
 static int hvm_build_set_params(xc_interface *handle, uint32_t domid,
                                 libxl_domain_build_info *info,
                                 int store_evtchn, unsigned long *store_mfn,
-                                int console_evtchn, unsigned long *console_mfn,
+                                int console_evtchn, xen_pfn_t *console_gfn,
                                 domid_t store_domid, domid_t console_domid)
 {
     struct hvm_info_table *va_hvm;
@@ -901,9 +901,9 @@ static int hvm_build_set_params(xc_interface *handle, 
uint32_t domid,
     xc_hvm_param_set(handle, domid, HVM_PARAM_CONSOLE_EVTCHN, console_evtchn);
 
     *store_mfn = str_mfn;
-    *console_mfn = cons_mfn;
+    *console_gfn = cons_mfn;
 
-    xc_dom_gnttab_hvm_seed(handle, domid, *console_mfn, *store_mfn, 
console_domid, store_domid);
+    xc_dom_gnttab_hvm_seed(handle, domid, *console_gfn, *store_mfn, 
console_domid, store_domid);
     return 0;
 }
 
@@ -1270,7 +1270,7 @@ int libxl__build_hvm(libxl__gc *gc, uint32_t domid,
 
     rc = hvm_build_set_params(ctx->xch, domid, info, state->store_port,
                                &state->store_mfn, state->console_port,
-                               &state->console_mfn, state->store_domid,
+                               &state->console_gfn, state->store_domid,
                                state->console_domid);
     if (rc != 0) {
         LOG(ERROR, "hvm build set params failed");
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index bfa95d8..49f7966 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1129,7 +1129,7 @@ typedef struct {
 
     uint32_t console_port;
     uint32_t console_domid;
-    unsigned long console_mfn;
+    xen_pfn_t console_gfn;
     char *console_tty;
 
     char *saved_state;
diff --git a/tools/libxl/libxl_save_helper.c b/tools/libxl/libxl_save_helper.c
index 38089a0..bf50ec8 100644
--- a/tools/libxl/libxl_save_helper.c
+++ b/tools/libxl/libxl_save_helper.c
@@ -284,17 +284,17 @@ int main(int argc, char **argv)
         helper_setcallbacks_restore(&helper_restore_callbacks, cbflags);
 
         unsigned long store_mfn = 0;
-        unsigned long console_mfn = 0;
+        unsigned long console_gfn = 0;
 
         startup("restore");
         setup_signals(SIG_DFL);
 
         r = xc_domain_restore(xch, io_fd, dom, store_evtchn, &store_mfn,
-                              store_domid, console_evtchn, &console_mfn,
+                              store_domid, console_evtchn, &console_gfn,
                               console_domid, hvm, pae,
                               stream_type,
                               &helper_restore_callbacks, send_back_fd);
-        helper_stub_restore_results(store_mfn,console_mfn,0);
+        helper_stub_restore_results(store_mfn,console_gfn,0);
         complete(r);
 
     } else {
-- 
2.7.4


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

 


Rackspace

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