Skip to contentSkip to conversation

xen: use correct type for HYPERVISOR_memory_op()

PATCH Applied Juergen Gross 3 participants 4 messages Sep 4, 2015 – Sep 28, 2015

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

Juergen Gross

author maintainer
#0 lore raw

PATCH 1/1 xen: use correct type for HYPERVISOR_memory_op()

HYPERVISOR_memory_op() is defined to return an "int" value. This is wrong, as the Xen hypervisor will return "long".

The sub-function XENMEM_maximum_reservation returns the maximum number of pages for the current domain. An int will overflow for a domain configured with 8TB of memory or more.

Correct this by using the correct type.

---
 arch/x86/include/asm/xen/hypercall.h | 4 ++--
 arch/x86/xen/setup.c                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/xen/hypercall.h +2 -2
index ca08a27..b7a735f 100644
@@ -336,10 +336,10 @@ HYPERVISOR_update_descriptor(u64 ma, u64 desc)
 	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
 }
 
-static inline int
+static inline long
 HYPERVISOR_memory_op(unsigned int cmd, void *arg)
 {
-	return _hypercall2(int, memory_op, cmd, arg);
+	return _hypercall2(long, memory_op, cmd, arg);
 }
 
 static inline int
arch/x86/xen/setup.c +1 -1
index f5ef674..4ebfcec 100644
@@ -548,7 +548,7 @@ static unsigned long __init xen_get_max_pages(void)
 {
 	unsigned long max_pages, limit;
 	domid_t domid = DOMID_SELF;
-	int ret;
+	long ret;
 
 	limit = xen_get_pages_limit();
 	max_pages = limit;
Signature · 1 line
2.1.4
author maintainer
#1 lore raw

Ping?

Quoted 46 lines · Juergen Gross

HYPERVISOR_memory_op() is defined to return an "int" value. This is wrong, as the Xen hypervisor will return "long".

The sub-function XENMEM_maximum_reservation returns the maximum number of pages for the current domain. An int will overflow for a domain configured with 8TB of memory or more.

Correct this by using the correct type.

---
  arch/x86/include/asm/xen/hypercall.h | 4 ++--
  arch/x86/xen/setup.c                 | 2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/xen/hypercall.h +2 -2
index ca08a27..b7a735f 100644
@@ -336,10 +336,10 @@ HYPERVISOR_update_descriptor(u64 ma, u64 desc)
  	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
  }
 
-static inline int
+static inline long
  HYPERVISOR_memory_op(unsigned int cmd, void *arg)
  {
-	return _hypercall2(int, memory_op, cmd, arg);
+	return _hypercall2(long, memory_op, cmd, arg);
  }
 
  static inline int
arch/x86/xen/setup.c +1 -1
index f5ef674..4ebfcec 100644
@@ -548,7 +548,7 @@ static unsigned long __init xen_get_max_pages(void)
  {
  	unsigned long max_pages, limit;
  	domid_t domid = DOMID_SELF;
-	int ret;
+	long ret;
 
  	limit = xen_get_pages_limit();
  	max_pages = limit;
#2 lore raw
In reply to Juergen Gross

Hi Juergen,

Quoted 8 lines · Juergen Gross

HYPERVISOR_memory_op() is defined to return an "int" value. This is wrong, as the Xen hypervisor will return "long".

The sub-function XENMEM_maximum_reservation returns the maximum number of pages for the current domain. An int will overflow for a domain configured with 8TB of memory or more.

Correct this by using the correct type.

Can you also fix the ARM version of the prototype (arm/include/asm/xen/hypercall.h) in order to keep them in sync?

Regards,

Quoted 37 lines
---
 arch/x86/include/asm/xen/hypercall.h | 4 ++--
 arch/x86/xen/setup.c                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/xen/hypercall.h +2 -2
index ca08a27..b7a735f 100644
@@ -336,10 +336,10 @@ HYPERVISOR_update_descriptor(u64 ma, u64 desc)
 	return _hypercall4(int, update_descriptor, ma, ma>>32, desc, desc>>32);
 }
 
-static inline int
+static inline long
 HYPERVISOR_memory_op(unsigned int cmd, void *arg)
 {
-	return _hypercall2(int, memory_op, cmd, arg);
+	return _hypercall2(long, memory_op, cmd, arg);
 }
 
 static inline int
arch/x86/xen/setup.c +1 -1
index f5ef674..4ebfcec 100644
@@ -548,7 +548,7 @@ static unsigned long __init xen_get_max_pages(void)
 {
 	unsigned long max_pages, limit;
 	domid_t domid = DOMID_SELF;
-	int ret;
+	long ret;
 
 	limit = xen_get_pages_limit();
 	max_pages = limit;
Signature · 1 line
Julien Grall
Applied
#3 lore raw
In reply to Juergen Gross
Quoted 8 lines · Juergen Gross

HYPERVISOR_memory_op() is defined to return an "int" value. This is wrong, as the Xen hypervisor will return "long".

The sub-function XENMEM_maximum_reservation returns the maximum number of pages for the current domain. An int will overflow for a domain configured with 8TB of memory or more.

Correct this by using the correct type.

Applied to for-linus-4.3, thanks.

David