ia64/xen-unstable
changeset 3783:0069a2f1f55d
bitkeeper revision 1.1175 (420bacd51yx4f66j0Yv3tnUwEmeDtw)
Fix x86/64 SYSCALL handling. Handle return to compatibility mode as
well as long mode.
Signed-off-by: keir.fraser@cl.cam.ac.uk
Fix x86/64 SYSCALL handling. Handle return to compatibility mode as
well as long mode.
Signed-off-by: keir.fraser@cl.cam.ac.uk
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Thu Feb 10 18:49:57 2005 +0000 (2005-02-10) |
parents | 0cd8803a1553 |
children | 554a3a18069d |
files | xen/arch/x86/x86_64/entry.S xen/arch/x86/x86_64/traps.c xen/include/asm-x86/config.h |
line diff
1.1 --- a/xen/arch/x86/x86_64/entry.S Thu Feb 10 18:11:07 2005 +0000 1.2 +++ b/xen/arch/x86/x86_64/entry.S Thu Feb 10 18:49:57 2005 +0000 1.3 @@ -24,14 +24,21 @@ restore_all_guest: 1.4 jc failsafe_callback 1.5 RESTORE_ALL 1.6 testw $TRAP_syscall,4(%rsp) 1.7 - jz 1f 1.8 - addq $8,%rsp 1.9 - popq %rcx 1.10 + jz iret_exit_to_guest 1.11 + 1.12 addq $8,%rsp 1.13 - popq %r11 1.14 - popq %rsp 1.15 + popq %rcx # RIP 1.16 + popq %r11 # CS 1.17 + cmpw $__GUEST_CS32,%r11 1.18 + popq %r11 # RFLAGS 1.19 + popq %rsp # RSP 1.20 + je 1f 1.21 sysretq 1.22 -1: addq $8,%rsp 1.23 +1: sysretl 1.24 + 1.25 + ALIGN 1.26 +iret_exit_to_guest: 1.27 + addq $8,%rsp 1.28 FLT1: iretq 1.29 .section .fixup,"ax" 1.30 FIX1: popq -15*8-8(%rsp) # error_code/entry_vector 1.31 @@ -89,16 +96,24 @@ restore_all_xen: 1.32 iretq 1.33 1.34 /* 1.35 - * %rax = hypercall vector 1.36 - * %rdi, %rsi, %rdx, %r10, %r8, %9 = hypercall arguments 1.37 - * %r11, %rcx = SYSCALL-saved %rflags and %rip 1.38 - * NB. We must move %r10 to %rcx for C function-calling ABI. 1.39 + * When entering SYSCALL from kernel mode: 1.40 + * %rax = hypercall vector 1.41 + * %rdi, %rsi, %rdx, %r10, %r8, %9 = hypercall arguments 1.42 + * %r11, %rcx = SYSCALL-saved %rflags and %rip 1.43 + * NB. We must move %r10 to %rcx for C function-calling ABI. 1.44 + * 1.45 + * When entering SYSCALL from user mode: 1.46 + * Vector directly to the registered arch.syscall_addr. 1.47 + * 1.48 + * Initial work is done by per-CPU stack trampolines. At this point %rsp 1.49 + * has been initialised to point at the correct Xen stack, and %rsp, %rflags 1.50 + * and %cs have been saved. All other registers are still to be saved onto 1.51 + * the stack, starting with %rip, and an appropriate %ss must be saved into 1.52 + * the space left by the trampoline. 1.53 */ 1.54 ALIGN 1.55 ENTRY(syscall_enter) 1.56 - movl $__GUEST_SS,8(%rsp) 1.57 - pushq %r11 1.58 - pushq $__GUEST_CS 1.59 + movl $__GUEST_SS,24(%rsp) 1.60 pushq %rcx 1.61 pushq $0 1.62 movl $TRAP_syscall,4(%rsp)
2.1 --- a/xen/arch/x86/x86_64/traps.c Thu Feb 10 18:11:07 2005 +0000 2.2 +++ b/xen/arch/x86/x86_64/traps.c Thu Feb 10 18:49:57 2005 +0000 2.3 @@ -196,16 +196,24 @@ void __init percpu_traps_init(void) 2.4 stack[9] = 0x25; 2.5 *(u32 *)&stack[10] = (stack_bottom - &stack[14]) - 16; 2.6 2.7 + /* pushq %r11 */ 2.8 + stack[14] = 0x41; 2.9 + stack[15] = 0x53; 2.10 + 2.11 + /* pushq $__GUEST_CS64 */ 2.12 + stack[16] = 0x68; 2.13 + *(u32 *)&stack[17] = __GUEST_CS64; 2.14 + 2.15 /* jmp syscall_enter */ 2.16 - stack[14] = 0xe9; 2.17 - *(u32 *)&stack[15] = (char *)syscall_enter - &stack[19]; 2.18 + stack[21] = 0xe9; 2.19 + *(u32 *)&stack[22] = (char *)syscall_enter - &stack[26]; 2.20 2.21 /* 2.22 * Trampoline for SYSCALL entry from compatibility mode. 2.23 */ 2.24 2.25 /* Skip the long-mode entry trampoline. */ 2.26 - stack = &stack[19]; 2.27 + stack = &stack[26]; 2.28 wrmsr(MSR_CSTAR, (unsigned long)stack, ((unsigned long)stack>>32)); 2.29 2.30 /* movq %rsp, saversp(%rip) */ 2.31 @@ -220,9 +228,17 @@ void __init percpu_traps_init(void) 2.32 stack[9] = 0x25; 2.33 *(u32 *)&stack[10] = (stack_bottom - &stack[14]) - 16; 2.34 2.35 + /* pushq %r11 */ 2.36 + stack[14] = 0x41; 2.37 + stack[15] = 0x53; 2.38 + 2.39 + /* pushq $__GUEST_CS32 */ 2.40 + stack[16] = 0x68; 2.41 + *(u32 *)&stack[17] = __GUEST_CS32; 2.42 + 2.43 /* jmp syscall_enter */ 2.44 - stack[14] = 0xe9; 2.45 - *(u32 *)&stack[15] = (char *)syscall_enter - &stack[19]; 2.46 + stack[21] = 0xe9; 2.47 + *(u32 *)&stack[22] = (char *)syscall_enter - &stack[26]; 2.48 2.49 /* 2.50 * Common SYSCALL parameters.
3.1 --- a/xen/include/asm-x86/config.h Thu Feb 10 18:11:07 2005 +0000 3.2 +++ b/xen/include/asm-x86/config.h Thu Feb 10 18:49:57 2005 +0000 3.3 @@ -202,7 +202,9 @@ extern void __out_of_line_bug(int line) 3.4 #define __HYPERVISOR_DS32 0x0818 3.5 #define __HYPERVISOR_DS __HYPERVISOR_DS64 3.6 3.7 -#define __GUEST_CS 0x0833 3.8 +#define __GUEST_CS64 0x0833 3.9 +#define __GUEST_CS32 0x0823 3.10 +#define __GUEST_CS __GUEST_CS64 3.11 #define __GUEST_DS 0x0000 3.12 #define __GUEST_SS 0x082b 3.13