Skip to contentSkip to conversation

linux/x86: make hypercall wrapper functions' arguments unsigned where possible

PATCH New Jan Beulich 1 participant 1 message Jan 18, 2008 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux/x86: make hypercall wrapper functions' arguments unsigned where possible

.., producing better code on 64-bits (and done on 32-bits for consistency).

As usual, written and tested on 2.6.24-rc7 and made apply to the 2.6.18 tree without further testing.

include/asm-i386/mach-xen/asm/hypercall.h +9 -7
Index: head-2007-12-11/include/asm-i386/mach-xen/asm/hypercall.h
===================================================================
@@ -132,21 +132,23 @@ HYPERVISOR_set_trap_table(
 
 static inline int
 HYPERVISOR_mmu_update(
-	mmu_update_t *req, int count, int *success_count, domid_t domid)
+	mmu_update_t *req, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmu_update, req, count, success_count, domid);
 }
 
 static inline int
 HYPERVISOR_mmuext_op(
-	struct mmuext_op *op, int count, int *success_count, domid_t domid)
+	struct mmuext_op *op, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmuext_op, op, count, success_count, domid);
 }
 
 static inline int
 HYPERVISOR_set_gdt(
-	unsigned long *frame_list, int entries)
+	unsigned long *frame_list, unsigned int entries)
 {
 	return _hypercall2(int, set_gdt, frame_list, entries);
 }
@@ -208,14 +210,14 @@ HYPERVISOR_platform_op(
 
 static inline int
 HYPERVISOR_set_debugreg(
-	int reg, unsigned long value)
+	unsigned int reg, unsigned long value)
 {
 	return _hypercall2(int, set_debugreg, reg, value);
 }
 
 static inline unsigned long
 HYPERVISOR_get_debugreg(
-	int reg)
+	unsigned int reg)
 {
 	return _hypercall1(unsigned long, get_debugreg, reg);
 }
@@ -236,7 +238,7 @@ HYPERVISOR_memory_op(
 
 static inline int
 HYPERVISOR_multicall(
-	multicall_entry_t *call_list, int nr_calls)
+	multicall_entry_t *call_list, unsigned int nr_calls)
 {
 	return _hypercall2(int, multicall, call_list, nr_calls);
 }
@@ -288,7 +290,7 @@ HYPERVISOR_xen_version(
 
 static inline int
 HYPERVISOR_console_io(
-	int cmd, int count, char *str)
+	int cmd, unsigned int count, char *str)
 {
 	return _hypercall3(int, console_io, cmd, count, str);
 }
include/asm-x86_64/mach-xen/asm/hypercall.h +9 -7
Index: head-2007-12-11/include/asm-x86_64/mach-xen/asm/hypercall.h
===================================================================
@@ -138,21 +138,23 @@ HYPERVISOR_set_trap_table(
 
 static inline int
 HYPERVISOR_mmu_update(
-	mmu_update_t *req, int count, int *success_count, domid_t domid)
+	mmu_update_t *req, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmu_update, req, count, success_count, domid);
 }
 
 static inline int
 HYPERVISOR_mmuext_op(
-	struct mmuext_op *op, int count, int *success_count, domid_t domid)
+	struct mmuext_op *op, unsigned int count, unsigned int *success_count,
+	domid_t domid)
 {
 	return _hypercall4(int, mmuext_op, op, count, success_count, domid);
 }
 
 static inline int
 HYPERVISOR_set_gdt(
-	unsigned long *frame_list, int entries)
+	unsigned long *frame_list, unsigned int entries)
 {
 	return _hypercall2(int, set_gdt, frame_list, entries);
 }
@@ -211,14 +213,14 @@ HYPERVISOR_platform_op(
 
 static inline int
 HYPERVISOR_set_debugreg(
-	int reg, unsigned long value)
+	unsigned int reg, unsigned long value)
 {
 	return _hypercall2(int, set_debugreg, reg, value);
 }
 
 static inline unsigned long
 HYPERVISOR_get_debugreg(
-	int reg)
+	unsigned int reg)
 {
 	return _hypercall1(unsigned long, get_debugreg, reg);
 }
@@ -239,7 +241,7 @@ HYPERVISOR_memory_op(
 
 static inline int
 HYPERVISOR_multicall(
-	multicall_entry_t *call_list, int nr_calls)
+	multicall_entry_t *call_list, unsigned int nr_calls)
 {
 	return _hypercall2(int, multicall, call_list, nr_calls);
 }
@@ -286,7 +288,7 @@ HYPERVISOR_xen_version(
 
 static inline int
 HYPERVISOR_console_io(
-	int cmd, int count, char *str)
+	int cmd, unsigned int count, char *str)
 {
 	return _hypercall3(int, console_io, cmd, count, str);
 }
include/xen/hypercall.h +2 -1
Index: head-2007-12-11/include/xen/hypercall.h
===================================================================
@@ -5,7 +5,7 @@
 
 static inline int
 HYPERVISOR_multicall_check(
-	multicall_entry_t *call_list, int nr_calls,
+	multicall_entry_t *call_list, unsigned int nr_calls,
 	const unsigned long *rc_list)
 {
 	int rc = HYPERVISOR_multicall(call_list, nr_calls);
@@ -13,6 +13,7 @@ HYPERVISOR_multicall_check(
 	if (unlikely(rc < 0))
 		return rc;
 	BUG_ON(rc);
+	BUG_ON((int)nr_calls < 0);
 
 	for ( ; nr_calls > 0; --nr_calls, ++call_list)
 		if (unlikely(call_list->result != (rc_list ? *rc_list++ : 0)))