ia64/xen-unstable

view xen/include/asm-x86/multicall.h @ 10370:833d05bdb4a4

[XEN] Fix compatibility with future guests which may try to
use hypercalls >= NR_hypercalls. These must fail with ENOSYS,
but the current strategy of masking off the high-order bits of
the hypercall number means we instead map those hypercalls onto
lower-numbered hypercalls with unpredictable results. This patch
replaces masking with an explicit compare-and-jump.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Jun 13 11:28:20 2006 +0100 (2006-06-13)
parents d58565963ee7
children eee52c100996
line source
1 /******************************************************************************
2 * asm-x86/multicall.h
3 */
5 #ifndef __ASM_X86_MULTICALL_H__
6 #define __ASM_X86_MULTICALL_H__
8 #include <xen/errno.h>
9 #include <asm/asm_defns.h>
11 #ifdef __x86_64__
13 #define do_multicall_call(_call) \
14 do { \
15 __asm__ __volatile__ ( \
16 " movq "STR(MULTICALL_op)"(%0),%%rax; " \
17 " cmpq $("STR(NR_hypercalls)"),%%rax; " \
18 " jae 2f; " \
19 " leaq "STR(hypercall_table)"(%%rip),%%rdi; "\
20 " leaq (%%rdi,%%rax,8),%%rax; " \
21 " movq "STR(MULTICALL_arg0)"(%0),%%rdi; " \
22 " movq "STR(MULTICALL_arg1)"(%0),%%rsi; " \
23 " movq "STR(MULTICALL_arg2)"(%0),%%rdx; " \
24 " movq "STR(MULTICALL_arg3)"(%0),%%rcx; " \
25 " movq "STR(MULTICALL_arg4)"(%0),%%r8; " \
26 " callq *(%%rax); " \
27 "1: movq %%rax,"STR(MULTICALL_result)"(%0)\n" \
28 ".section .fixup,\"ax\"\n" \
29 "2: movq $-"STR(ENOSYS)",%%rax\n" \
30 " jmp 1b\n" \
31 ".previous\n" \
32 : : "b" (_call) \
33 /* all the caller-saves registers */ \
34 : "rax", "rcx", "rdx", "rsi", "rdi", \
35 "r8", "r9", "r10", "r11" ); \
36 } while ( 0 )
38 #else
40 #define do_multicall_call(_call) \
41 do { \
42 __asm__ __volatile__ ( \
43 " pushl "STR(MULTICALL_arg4)"(%0); " \
44 " pushl "STR(MULTICALL_arg3)"(%0); " \
45 " pushl "STR(MULTICALL_arg2)"(%0); " \
46 " pushl "STR(MULTICALL_arg1)"(%0); " \
47 " pushl "STR(MULTICALL_arg0)"(%0); " \
48 " movl "STR(MULTICALL_op)"(%0),%%eax; " \
49 " cmpl $("STR(NR_hypercalls)"),%%eax; " \
50 " jae 2f; " \
51 " call *hypercall_table(,%%eax,4); " \
52 "1: movl %%eax,"STR(MULTICALL_result)"(%0); " \
53 " addl $20,%%esp\n" \
54 ".section .fixup,\"ax\"\n" \
55 "2: movl $-"STR(ENOSYS)",%%eax\n" \
56 " jmp 1b\n" \
57 ".previous\n" \
58 : : "b" (_call) \
59 /* all the caller-saves registers */ \
60 : "eax", "ecx", "edx" ); \
61 } while ( 0 )
63 #endif
65 #endif /* __ASM_X86_MULTICALL_H__ */