Jan Beulich
2008-Jan-18 16:17 UTC
[Xen-devel] [PATCH] 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. Signed-off-by: Jan Beulich <jbeulich@novell.com> Index: head-2007-12-11/include/asm-i386/mach-xen/asm/hypercall.h ==================================================================--- head-2007-12-11.orig/include/asm-i386/mach-xen/asm/hypercall.h 2007-12-21 10:19:20.000000000 +0100 +++ head-2007-12-11/include/asm-i386/mach-xen/asm/hypercall.h 2007-12-21 10:47:37.000000000 +0100 @@ -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); } Index: head-2007-12-11/include/asm-x86_64/mach-xen/asm/hypercall.h ==================================================================--- head-2007-12-11.orig/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-12-21 10:19:16.000000000 +0100 +++ head-2007-12-11/include/asm-x86_64/mach-xen/asm/hypercall.h 2007-12-21 10:47:40.000000000 +0100 @@ -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); } Index: head-2007-12-11/include/xen/hypercall.h ==================================================================--- head-2007-12-11.orig/include/xen/hypercall.h 2007-12-21 12:30:40.000000000 +0100 +++ head-2007-12-11/include/xen/hypercall.h 2007-12-21 10:49:56.000000000 +0100 @@ -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))) _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel