All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn"
@ 2017-10-25  9:27 Bhupinder Thakur
  2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-25  9:27 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Ian Jackson,
	Julien Grall, Jan Beulich

In libxl__device_vuart_add vuart_gfn is getting stored as a hex value:

> flexarray_append(ro_front, GCSPRINTF("%"PRI_xen_pfn, state->vuart_gfn));

However, xenstore reads this value as a decimal value and tries to map the
wrong address and fails.

This patch introduces a new format specifier "PRIu_xen_pfn" which formats the value as a
decimal value.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
Acked-by: Wei Liu <wei.liu2@citrix.com>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
CC: Jan Beulich <jbeulich@suse.com>
CC: Andrew Cooper <andrew.cooper3@citrix.com>

 tools/libxl/libxl_console.c       | 2 +-
 xen/include/public/arch-arm.h     | 1 +
 xen/include/public/arch-x86/xen.h | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index c05dc28..6bfc0e5 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -376,7 +376,7 @@ int libxl__device_vuart_add(libxl__gc *gc, uint32_t domid,
     flexarray_append(ro_front, "port");
     flexarray_append(ro_front, GCSPRINTF("%"PRIu32, state->vuart_port));
     flexarray_append(ro_front, "ring-ref");
-    flexarray_append(ro_front, GCSPRINTF("%"PRI_xen_pfn, state->vuart_gfn));
+    flexarray_append(ro_front, GCSPRINTF("%"PRIu_xen_pfn, state->vuart_gfn));
     flexarray_append(ro_front, "limit");
     flexarray_append(ro_front, GCSPRINTF("%d", LIBXL_XENCONSOLE_LIMIT));
     flexarray_append(ro_front, "type");
diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 5708cd2..05fd11c 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -274,6 +274,7 @@ DEFINE_XEN_GUEST_HANDLE(vcpu_guest_core_regs_t);
 
 typedef uint64_t xen_pfn_t;
 #define PRI_xen_pfn PRIx64
+#define PRIu_xen_pfn PRIu64
 
 /* Maximum number of virtual CPUs in legacy multi-processor guests. */
 /* Only one. All other VCPUS must use VCPUOP_register_vcpu_info */
diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x86/xen.h
index ff91831..3b0b1d6 100644
--- a/xen/include/public/arch-x86/xen.h
+++ b/xen/include/public/arch-x86/xen.h
@@ -75,6 +75,7 @@ __DeFiNe__ __DECL_REG_LO16(name) e ## name
 #ifndef __ASSEMBLY__
 typedef unsigned long xen_pfn_t;
 #define PRI_xen_pfn "lx"
+#define PRIu_xen_pfn "lu"
 #endif
 
 #define XEN_HAVE_PV_GUEST_ENTRY 1
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-25  9:27 [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
@ 2017-10-25  9:27 ` Bhupinder Thakur
  2017-10-26 11:05   ` Wei Liu
  2017-10-26 11:13   ` Wei Liu
  2017-10-25  9:27 ` [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range() Bhupinder Thakur
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-25  9:27 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

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.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

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

 tools/libxl/libxl_console.c  | 2 +-
 tools/libxl/libxl_dom.c      | 2 +-
 tools/libxl/libxl_internal.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

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_dom.c b/tools/libxl/libxl_dom.c
index ef834e6..a58e74f 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -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_mfn,
                                 domid_t store_domid, domid_t console_domid)
 {
     struct hvm_info_table *va_hvm;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 45e6df6..f52aeb3 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1128,7 +1128,7 @@ typedef struct {
 
     uint32_t console_port;
     uint32_t console_domid;
-    unsigned long console_mfn;
+    xen_pfn_t console_mfn;
     char *console_tty;
 
     char *saved_state;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range()
  2017-10-25  9:27 [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
  2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
@ 2017-10-25  9:27 ` Bhupinder Thakur
  2017-10-26 11:19   ` Wei Liu
  2017-10-25  9:27 ` [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring Bhupinder Thakur
  2017-10-25  9:27 ` [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1 Bhupinder Thakur
  3 siblings, 1 reply; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-25  9:27 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Currently the data type of mfn parameter passed to xc_map_foreign_range() is unsigned
long. This could be problem for 32-bit arm architectures where the lengh of long is
32 bits while mfn happens to be a 64-bit value.

To avoid truncating a 64-bit value, the type of mfn is changed from "unsigned long" to
xen_pfn_t. Also the parameter name "mfn" is changed to "pfn" which is a more accurate
indication of what this parameter represents.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

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 ++--
 2 files changed, 3 insertions(+), 3 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);
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring
  2017-10-25  9:27 [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
  2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
  2017-10-25  9:27 ` [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range() Bhupinder Thakur
@ 2017-10-25  9:27 ` Bhupinder Thakur
  2017-10-26 11:24   ` Wei Liu
  2017-10-25  9:27 ` [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1 Bhupinder Thakur
  3 siblings, 1 reply; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-25  9:27 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

Currently, ring_ref is read as an integer in console_create_ring which could lead to
truncation of the value as it is reading a 64-bit value.

The fix is to modify the type of ring_ref to xen_pfn_t and use the correct format
specifier to read the value correctly for all architectures.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

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

 tools/console/daemon/io.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index e22009a..1839973 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -19,6 +19,7 @@
 
 #define _GNU_SOURCE
 
+#include <inttypes.h>
 #include "utils.h"
 #include "io.h"
 #include <xenevtchn.h>
@@ -81,6 +82,12 @@ static unsigned int nr_fds;
 
 #define ROUNDUP(_x,_w) (((unsigned long)(_x)+(1UL<<(_w))-1) & ~((1UL<<(_w))-1))
 
+#if defined(CONFIG_ARM)
+# define SCNi_xen_pfn SCNi64
+#else
+# define SCNi_xen_pfn "li"
+#endif
+
 struct buffer {
 	char *data;
 	size_t consumed;
@@ -98,7 +105,7 @@ struct console {
 	struct buffer buffer;
 	char *xspath;
 	char *log_suffix;
-	int ring_ref;
+	xen_pfn_t ring_ref;
 	xenevtchn_handle *xce_handle;
 	int xce_pollfd_idx;
 	int event_count;
@@ -661,12 +668,13 @@ static void console_unmap_interface(struct console *con)
  
 static int console_create_ring(struct console *con)
 {
-	int err, remote_port, ring_ref, rc;
+	int err, remote_port, rc;
+	xen_pfn_t ring_ref;
 	char *type, path[PATH_MAX];
 	struct domain *dom = con->d;
 
 	err = xs_gather(xs, con->xspath,
-			"ring-ref", "%u", &ring_ref,
+			"ring-ref", "%"SCNi_xen_pfn, &ring_ref,
 			"port", "%i", &remote_port,
 			NULL);
 
@@ -705,7 +713,7 @@ static int console_create_ring(struct console *con)
 		con->interface = xc_map_foreign_range(
 			xc, dom->domid, XC_PAGE_SIZE,
 			PROT_READ|PROT_WRITE,
-			(unsigned long)ring_ref);
+			ring_ref);
 		if (con->interface == NULL) {
 			err = EINVAL;
 			goto out;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1
  2017-10-25  9:27 [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
                   ` (2 preceding siblings ...)
  2017-10-25  9:27 ` [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring Bhupinder Thakur
@ 2017-10-25  9:27 ` Bhupinder Thakur
  2017-10-26 11:26   ` Wei Liu
  3 siblings, 1 reply; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-25  9:27 UTC (permalink / raw)
  To: xen-devel; +Cc: Wei Liu, Julien Grall, Stefano Stabellini, Ian Jackson

xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.

Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
---
CC: Ian Jackson <ian.jackson@eu.citrix.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>

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

 tools/console/daemon/io.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 1839973..aa291db 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -62,6 +62,8 @@
 /* Duration of each time period in ms */
 #define RATE_LIMIT_PERIOD 200
 
+#define XEN_INVALID_PFN (~(xen_pfn_t)0)
+
 extern int log_reload;
 extern int log_guest;
 extern int log_hv;
@@ -658,12 +660,12 @@ static void console_unmap_interface(struct console *con)
 {
 	if (con->interface == NULL)
 		return;
-	if (xgt_handle && con->ring_ref == -1)
+	if (xgt_handle && con->ring_ref == XEN_INVALID_PFN)
 		xengnttab_unmap(xgt_handle, con->interface, 1);
 	else
 		munmap(con->interface, XC_PAGE_SIZE);
 	con->interface = NULL;
-	con->ring_ref = -1;
+	con->ring_ref = XEN_INVALID_PFN;
 }
  
 static int console_create_ring(struct console *con)
@@ -698,7 +700,7 @@ static int console_create_ring(struct console *con)
 	free(type);
 
 	/* If using ring_ref and it has changed, remap */
-	if (ring_ref != con->ring_ref && con->ring_ref != -1)
+	if (ring_ref != con->ring_ref && con->ring_ref != XEN_INVALID_PFN)
 		console_unmap_interface(con);
 
 	if (!con->interface && xgt_handle && con->use_gnttab) {
@@ -706,7 +708,7 @@ static int console_create_ring(struct console *con)
 		con->interface = xengnttab_map_grant_ref(xgt_handle,
 			dom->domid, GNTTAB_RESERVED_CONSOLE,
 			PROT_READ|PROT_WRITE);
-		con->ring_ref = -1;
+		con->ring_ref = XEN_INVALID_PFN;
 	}
 	if (!con->interface) {
 		/* Fall back to xc_map_foreign_range */
@@ -812,7 +814,7 @@ static int console_init(struct console *con, struct domain *dom, void **data)
 	con->master_pollfd_idx = -1;
 	con->slave_fd = -1;
 	con->log_fd = -1;
-	con->ring_ref = -1;
+	con->ring_ref = XEN_INVALID_PFN;
 	con->local_port = -1;
 	con->remote_port = -1;
 	con->xce_pollfd_idx = -1;
-- 
2.7.4


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

^ permalink raw reply related	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
@ 2017-10-26 11:05   ` Wei Liu
  2017-10-26 11:13   ` Wei Liu
  1 sibling, 0 replies; 15+ messages in thread
From: Wei Liu @ 2017-10-26 11:05 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Wed, Oct 25, 2017 at 02:57:05PM +0530, Bhupinder Thakur wrote:
> 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.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
  2017-10-26 11:05   ` Wei Liu
@ 2017-10-26 11:13   ` Wei Liu
  2017-10-26 11:17     ` Andrew Cooper
  1 sibling, 1 reply; 15+ messages in thread
From: Wei Liu @ 2017-10-26 11:13 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Wed, Oct 25, 2017 at 02:57:05PM +0530, Bhupinder Thakur wrote:
> 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.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> ---
> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> CC: Wei Liu <wei.liu2@citrix.com>
> CC: Stefano Stabellini <sstabellini@kernel.org>
> CC: Julien Grall <julien.grall@arm.com>
> 
> This patch is as per the review of commit fa1f157
>     libxl: Fix the bug introduced in commit "libxl: use correct type
> 
>  tools/libxl/libxl_console.c  | 2 +-
>  tools/libxl/libxl_dom.c      | 2 +-
>  tools/libxl/libxl_internal.h | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> 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));

Actually, please consider changing console_mfn to console_pfn.

You can keep my ack if you make such change.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-26 11:13   ` Wei Liu
@ 2017-10-26 11:17     ` Andrew Cooper
  2017-10-30  9:12       ` Bhupinder Thakur
  0 siblings, 1 reply; 15+ messages in thread
From: Andrew Cooper @ 2017-10-26 11:17 UTC (permalink / raw)
  To: Wei Liu, Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson

On 26/10/17 12:13, Wei Liu wrote:
> On Wed, Oct 25, 2017 at 02:57:05PM +0530, Bhupinder Thakur wrote:
>> 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.
>>
>> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
>> ---
>> CC: Ian Jackson <ian.jackson@eu.citrix.com>
>> CC: Wei Liu <wei.liu2@citrix.com>
>> CC: Stefano Stabellini <sstabellini@kernel.org>
>> CC: Julien Grall <julien.grall@arm.com>
>>
>> This patch is as per the review of commit fa1f157
>>     libxl: Fix the bug introduced in commit "libxl: use correct type
>>
>>  tools/libxl/libxl_console.c  | 2 +-
>>  tools/libxl/libxl_dom.c      | 2 +-
>>  tools/libxl/libxl_internal.h | 2 +-
>>  3 files changed, 3 insertions(+), 3 deletions(-)
>>
>> 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));
> Actually, please consider changing console_mfn to console_pfn.

If you are going to make this change, then it is a gfn, not a pfn. 
(console_pfn would be as equally wrong for PV guests as console_mfn is
currently wrong for HVM guest.)

~Andrew

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range()
  2017-10-25  9:27 ` [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range() Bhupinder Thakur
@ 2017-10-26 11:19   ` Wei Liu
  0 siblings, 0 replies; 15+ messages in thread
From: Wei Liu @ 2017-10-26 11:19 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Wed, Oct 25, 2017 at 02:57:06PM +0530, Bhupinder Thakur wrote:
> Currently the data type of mfn parameter passed to xc_map_foreign_range() is unsigned
> long. This could be problem for 32-bit arm architectures where the lengh of long is
> 32 bits while mfn happens to be a 64-bit value.
> 
> To avoid truncating a 64-bit value, the type of mfn is changed from "unsigned long" to
> xen_pfn_t. Also the parameter name "mfn" is changed to "pfn" which is a more accurate
> indication of what this parameter represents.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

But this should either come before #2 or be squashed into it.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring
  2017-10-25  9:27 ` [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring Bhupinder Thakur
@ 2017-10-26 11:24   ` Wei Liu
  0 siblings, 0 replies; 15+ messages in thread
From: Wei Liu @ 2017-10-26 11:24 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Wed, Oct 25, 2017 at 02:57:07PM +0530, Bhupinder Thakur wrote:
> Currently, ring_ref is read as an integer in console_create_ring which could lead to
> truncation of the value as it is reading a 64-bit value.
> 
> The fix is to modify the type of ring_ref to xen_pfn_t and use the correct format
> specifier to read the value correctly for all architectures.
> 
> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1
  2017-10-25  9:27 ` [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1 Bhupinder Thakur
@ 2017-10-26 11:26   ` Wei Liu
  2017-10-27  7:04     ` Bhupinder Thakur
  0 siblings, 1 reply; 15+ messages in thread
From: Wei Liu @ 2017-10-26 11:26 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson, Wei Liu

On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.

Can you please paste in the error if the compilation fails with -1?

The way this series is arranged make me wonder if the compilation is
broken half way. We should avoid that.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1
  2017-10-26 11:26   ` Wei Liu
@ 2017-10-27  7:04     ` Bhupinder Thakur
  2017-10-27  7:07       ` Bhupinder Thakur
  0 siblings, 1 reply; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-27  7:04 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson

Hi Wei,

On 26 October 2017 at 16:56, Wei Liu <wei.liu2@citrix.com> wrote:
> On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
>> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.
>
> Can you please paste in the error if the compilation fails with -1?
>
> The way this series is arranged make me wonder if the compilation is
> broken half way. We should avoid that.
It is not breaking the compilation. Since the type of ring_ref is
changed to xen_pfn_t (which is an unsigned value) assigning -1
appeared to be confusing. For better clarity, XEN_INVALID_PFN is
introduced.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1
  2017-10-27  7:04     ` Bhupinder Thakur
@ 2017-10-27  7:07       ` Bhupinder Thakur
  0 siblings, 0 replies; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-27  7:07 UTC (permalink / raw)
  To: Wei Liu; +Cc: Xen-devel, Julien Grall, Stefano Stabellini, Ian Jackson

On 27 October 2017 at 12:34, Bhupinder Thakur
<bhupinder.thakur@linaro.org> wrote:
> Hi Wei,
>
> On 26 October 2017 at 16:56, Wei Liu <wei.liu2@citrix.com> wrote:
>> On Wed, Oct 25, 2017 at 02:57:08PM +0530, Bhupinder Thakur wrote:
>>> xenconsole will use a new macro XEN_INVALID_PFN instead of -1 for initializing ring-ref.
>>
>> Can you please paste in the error if the compilation fails with -1?
>>
>> The way this series is arranged make me wonder if the compilation is
>> broken half way. We should avoid that.
> It is not breaking the compilation. Since the type of ring_ref is
> changed to xen_pfn_t (which is an unsigned value) assigning -1
> appeared to be confusing. For better clarity, XEN_INVALID_PFN is
> introduced.

I will update the commit message accordingly.

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-26 11:17     ` Andrew Cooper
@ 2017-10-30  9:12       ` Bhupinder Thakur
  2017-10-30 10:33         ` Wei Liu
  0 siblings, 1 reply; 15+ messages in thread
From: Bhupinder Thakur @ 2017-10-30  9:12 UTC (permalink / raw)
  To: Andrew Cooper
  Cc: Xen-devel, Julien Grall, Stefano Stabellini, Wei Liu, Ian Jackson

Hi,

On 26 October 2017 at 16:47, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> On 26/10/17 12:13, Wei Liu wrote:
>> On Wed, Oct 25, 2017 at 02:57:05PM +0530, Bhupinder Thakur wrote:
>>> 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.
>>>
>>> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
>>> ---
>>> CC: Ian Jackson <ian.jackson@eu.citrix.com>
>>> CC: Wei Liu <wei.liu2@citrix.com>
>>> CC: Stefano Stabellini <sstabellini@kernel.org>
>>> CC: Julien Grall <julien.grall@arm.com>
>>>
>>> This patch is as per the review of commit fa1f157
>>>     libxl: Fix the bug introduced in commit "libxl: use correct type
>>>
>>>  tools/libxl/libxl_console.c  | 2 +-
>>>  tools/libxl/libxl_dom.c      | 2 +-
>>>  tools/libxl/libxl_internal.h | 2 +-
>>>  3 files changed, 3 insertions(+), 3 deletions(-)
>>>
>>> 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));
>> Actually, please consider changing console_mfn to console_pfn.
>
> If you are going to make this change, then it is a gfn, not a pfn.
> (console_pfn would be as equally wrong for PV guests as console_mfn is
> currently wrong for HVM guest.)

Changing console_mfn to console_gfn will require changes in many
files. Should I go ahead and change all the files?

Regards,
Bhupinder

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t
  2017-10-30  9:12       ` Bhupinder Thakur
@ 2017-10-30 10:33         ` Wei Liu
  0 siblings, 0 replies; 15+ messages in thread
From: Wei Liu @ 2017-10-30 10:33 UTC (permalink / raw)
  To: Bhupinder Thakur
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Ian Jackson,
	Julien Grall, Xen-devel

On Mon, Oct 30, 2017 at 02:42:57PM +0530, Bhupinder Thakur wrote:
> Hi,
> 
> On 26 October 2017 at 16:47, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> > On 26/10/17 12:13, Wei Liu wrote:
> >> On Wed, Oct 25, 2017 at 02:57:05PM +0530, Bhupinder Thakur wrote:
> >>> 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.
> >>>
> >>> Signed-off-by: Bhupinder Thakur <bhupinder.thakur@linaro.org>
> >>> ---
> >>> CC: Ian Jackson <ian.jackson@eu.citrix.com>
> >>> CC: Wei Liu <wei.liu2@citrix.com>
> >>> CC: Stefano Stabellini <sstabellini@kernel.org>
> >>> CC: Julien Grall <julien.grall@arm.com>
> >>>
> >>> This patch is as per the review of commit fa1f157
> >>>     libxl: Fix the bug introduced in commit "libxl: use correct type
> >>>
> >>>  tools/libxl/libxl_console.c  | 2 +-
> >>>  tools/libxl/libxl_dom.c      | 2 +-
> >>>  tools/libxl/libxl_internal.h | 2 +-
> >>>  3 files changed, 3 insertions(+), 3 deletions(-)
> >>>
> >>> 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));
> >> Actually, please consider changing console_mfn to console_pfn.
> >
> > If you are going to make this change, then it is a gfn, not a pfn.
> > (console_pfn would be as equally wrong for PV guests as console_mfn is
> > currently wrong for HVM guest.)
> 
> Changing console_mfn to console_gfn will require changes in many
> files. Should I go ahead and change all the files?
> 

$ cd libxl && git grep \\bconsole_mfn | wc -l
14

Not too bad, so please go ahead.

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

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-10-30 10:33 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-25  9:27 [PATCH 1/5 v2] libxl: Fix the bug introduced in commit "libxl: use correct type modifier for vuart_gfn" Bhupinder Thakur
2017-10-25  9:27 ` [PATCH 2/5 v2] libxl: Change the type of console_mfn to xen_pfn_t Bhupinder Thakur
2017-10-26 11:05   ` Wei Liu
2017-10-26 11:13   ` Wei Liu
2017-10-26 11:17     ` Andrew Cooper
2017-10-30  9:12       ` Bhupinder Thakur
2017-10-30 10:33         ` Wei Liu
2017-10-25  9:27 ` [PATCH 3/5 v2] libxc: Fix the data type of mfn parameter passed to xc_map_foreign_range() Bhupinder Thakur
2017-10-26 11:19   ` Wei Liu
2017-10-25  9:27 ` [PATCH 4/5 v2] xenconsole: Change the type of ring_ref to xen_pfn_t in console_create_ring Bhupinder Thakur
2017-10-26 11:24   ` Wei Liu
2017-10-25  9:27 ` [PATCH 5/5 v2] xenconsole: Define and use a macro XEN_INVALID_PFN instead of -1 Bhupinder Thakur
2017-10-26 11:26   ` Wei Liu
2017-10-27  7:04     ` Bhupinder Thakur
2017-10-27  7:07       ` Bhupinder Thakur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.