Skip to contentSkip to conversation

Xen: ARM: Zero reserved fields of xatp before making hypervisor call

PATCH In review Jiandi An 4 participants 7 messages Dec 28, 2016 – Jan 16, 2017 Xen hypervisor interface

lore
Share & tools
lore

Jiandi An

author
#0 lore raw

PATCH v2 1/1 Xen: ARM: Zero reserved fields of xatp before making hypervisor call

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +5 -3
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+
 		r = &resources[i];
 		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
 		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
 			idxs[j] = XEN_PFN_DOWN(r->start) + j;
 		}
 
-		xatp.domid = DOMID_SELF;
 		xatp.size = nr;
-		xatp.space = XENMAPSPACE_dev_mmio;
 
 		set_xen_guest_handle(xatp.gpfns, gpfns);
 		set_xen_guest_handle(xatp.idxs, idxs);
Signature · 3 lines
Jiandi An
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
maintainer
#1 lore raw
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

Juergen

Quoted 14 lines
drivers/xen/arm-device.c +0 -2
 		r = &resources[i];
 		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
 		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
 			idxs[j] = XEN_PFN_DOWN(r->start) + j;
 		}
 
-		xatp.domid = DOMID_SELF;
 		xatp.size = nr;
-		xatp.space = XENMAPSPACE_dev_mmio;
 
 		set_xen_guest_handle(xatp.gpfns, gpfns);
 		set_xen_guest_handle(xatp.idxs, idxs);
#2 lore raw
Quoted 36 lines · Juergen Gross
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

Quoted 2 lines

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

I don't feel strongly about this either - I think this patch is good enough. I'll apply to xentip.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#3 lore raw
In reply to Juergen Gross
Quoted 36 lines · Juergen Gross
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

Quoted 2 lines

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

I don't feel strongly about this either - I think this patch is good enough. I'll apply to xentip.

#4 lore raw

Hi Stefano,

Quoted 37 lines · Stefano Stabellini
Quoted 36 lines · Juergen Gross
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

Quoted 5 lines
Quoted 2 lines

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

I don't feel strongly about this either - I think this patch is good enough. I'll apply to xentip.

I think this patch should be backported to stable trees because the issue could appear depending on the compiler.

Cheers,

Signature · 1 line
Julien Grall
#5 lore raw
In reply to Stefano Stabellini

Hi Stefano,

Quoted 37 lines · Stefano Stabellini
Quoted 36 lines · Juergen Gross
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

Quoted 5 lines
Quoted 2 lines

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

I don't feel strongly about this either - I think this patch is good enough. I'll apply to xentip.

I think this patch should be backported to stable trees because the issue could appear depending on the compiler.

Cheers,

Signature · 6 lines
Julien Grall

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
maintainer
#6 lore raw
In reply to Jiandi An
Quoted 20 lines · Jiandi An

Ensure all reserved fields of xatp are zero before making hypervisor call to XEN in xen_map_device_mmio(). xenmem_add_to_physmap_one() in XEN fails the mapping request if extra.res reserved field in xatp is not zero for XENMAPSPACE_dev_mmio request.

---
Changed zeroing xatp to a static initialization
of .domid and .space for xatp.

 drivers/xen/arm-device.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/xen/arm-device.c +0 -0
index 778acf8..85dd20e 100644
@@ -58,9 +58,13 @@ static int xen_map_device_mmio(const struct resource *resources,
 	xen_pfn_t *gpfns;

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 67

Quoted 10 lines
drivers/xen/arm-device.c +5 -1
 	xen_ulong_t *idxs;
 	int *errs;
-	struct xen_add_to_physmap_range xatp;
 
 	for (i = 0; i < count; i++) {
+		struct xen_add_to_physmap_range xatp = {
+			.domid = DOMID_SELF,
+			.space = XENMAPSPACE_dev_mmio
+		};
+

I still don't see the need to re-initialize the input parts of xatp on each loop iteration unless you can show the need for it (e.g. a buggy hypervisor version not conforming to the interface specification).

OTOH I don't feel really strong about it and let Stefano being the maintainer for the ARM parts decide.

Juergen

Quoted 5 lines
drivers/xen/arm-device.c +0 -0
 		r = &resources[i];
 		nr = DIV_ROUND_UP(resource_size(r), XEN_PAGE_SIZE);
 		if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))

drivers/xen/arm-device.c static int xen_map_device_mmio(const struct resource *resources, · line 97

Quoted 9 lines
drivers/xen/arm-device.c +0 -2
@@ -87,9 +91,7 @@ static int xen_map_device_mmio(const struct resource *resources,
 			idxs[j] = XEN_PFN_DOWN(r->start) + j;
 		}
 
-		xatp.domid = DOMID_SELF;
 		xatp.size = nr;
-		xatp.space = XENMAPSPACE_dev_mmio;
 
 		set_xen_guest_handle(xatp.gpfns, gpfns);
 		set_xen_guest_handle(xatp.idxs, idxs);

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel