ia64/xen-unstable

changeset 5550:25ceeee71ab6

bitkeeper revision 1.1732 (42ba7fc5JvRaJiT14LMkB8SUdohfeA)

The attached patch now allows x86_64 xenlinux to run 32-bit x86 binaries
as the native x86_64 Linux does. I checked LTP using 32-bit binaries,
and got the same results on the native x86_64 Linux. At this point, 'int
0x80' is used for system calls, as it's unlikely that the fast systems
(sysenter or syscall) are significantly faster under the current
trampoline mechanism. However, it should be easy to replace
vsyscall-int80 with the fast system calls if one wants to do so (look at
USE_INT80 in the patch).

I found bugs with LDT handling in x86_64 Xen/XenLinux (exposed by 32-bit
LTP testcases fork05 and modify_ldt02), and the bugs have been fixed by
a separate patch in the next email:=20
[PATCH] [x86_64] Fixing LDT handling with x86_64 Xen

Signed-off-by: Jun Nakajima <jun.nakajima@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Jun 23 09:24:21 2005 +0000 (2005-06-23)
parents e1627c8b4e45
children 30082c72ed69
files .rootkeys linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64 linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64 linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/Makefile linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/ia32entry.S linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/syscall32.c linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/vsyscall-int80.S linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/fault.c
line diff
     1.1 --- a/.rootkeys	Thu Jun 23 09:19:35 2005 +0000
     1.2 +++ b/.rootkeys	Thu Jun 23 09:24:21 2005 +0000
     1.3 @@ -263,6 +263,10 @@ 418f90e4lGdeJK9rmbOB1kN-IKSjsQ linux-2.6
     1.4  3f68905c5eiA-lBMQSvXLMWS1ikDEA linux-2.6.11-xen-sparse/arch/xen/kernel/xen_proc.c
     1.5  424efaa6xahU2q85_dT-SjUJEaivfg linux-2.6.11-xen-sparse/arch/xen/x86_64/Kconfig
     1.6  424efaa6kKleWe45IrqsG8gkejgEQA linux-2.6.11-xen-sparse/arch/xen/x86_64/Makefile
     1.7 +42ba7fc4lb16rk9fVJeOBTPpy7bHFQ linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/Makefile
     1.8 +42ba7fc4URo9Q9gyOqemf4cCcAfYCg linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/ia32entry.S
     1.9 +42ba7fc4qPAX8G1HhVUPmps8xw_Odw linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/syscall32.c
    1.10 +42ba7fc4xqwiER7U_2NvNwqxhRMo1g linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/vsyscall-int80.S
    1.11  424efaa6HSyuVodl6SxFGj39vlp6MA linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/Makefile
    1.12  428f0973_moB26LYt56xXKYCTqEdXw linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/acpi/Makefile
    1.13  428f0973NBdgINmWOEJjoIDL73SDbQ linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/apic.c
    1.14 @@ -289,6 +293,7 @@ 424efaa778MkpdkAIq0An1FjQENN_Q linux-2.6
    1.15  424efaa7szEu90xkjpXk5TufZxxa4g linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c
    1.16  424efaa6sJsuHdGIGxm0r-ugsss3OQ linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/vsyscall.c
    1.17  424efaa6xbX9LkKyaXvgbL9s_39Trw linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/x8664_ksyms.c
    1.18 +42ba7fc4mg4zVSdJUO5Wc9PM-KUbqg linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S
    1.19  424efaa670zlQTtnOYK_aNgqhmSx-Q linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/Makefile
    1.20  424efaa6HUC68-hBHgiWOMDfKZogIA linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/fault.c
    1.21  424efaa65ELRJ3JfgQQKLzW6y0ECYQ linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/init.c
     2.1 --- a/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Thu Jun 23 09:19:35 2005 +0000
     2.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xen0_defconfig_x86_64	Thu Jun 23 09:24:21 2005 +0000
     2.3 @@ -133,8 +133,8 @@ CONFIG_DUMMY_IOMMU=y
     2.4  #
     2.5  # Executable file formats / Emulations
     2.6  #
     2.7 -# CONFIG_IA32_EMULATION is not set
     2.8 -
     2.9 +CONFIG_IA32_EMULATION=y
    2.10 +# CONFIG_IA32_AOUT is not set
    2.11  #
    2.12  # Executable file formats
    2.13  #
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Thu Jun 23 09:19:35 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/configs/xenU_defconfig_x86_64	Thu Jun 23 09:24:21 2005 +0000
     3.3 @@ -128,8 +128,8 @@ CONFIG_DUMMY_IOMMU=y
     3.4  #
     3.5  # Executable file formats / Emulations
     3.6  #
     3.7 -# CONFIG_IA32_EMULATION is not set
     3.8 -
     3.9 +CONFIG_IA32_EMULATION=y
    3.10 +# CONFIG_IA32_AOUT is not set
    3.11  #
    3.12  # Executable file formats
    3.13  #
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/Makefile	Thu Jun 23 09:24:21 2005 +0000
     4.3 @@ -0,0 +1,58 @@
     4.4 +#
     4.5 +# Makefile for the ia32 kernel emulation subsystem.
     4.6 +#
     4.7 +XENARCH	:= $(subst ",,$(CONFIG_XENARCH))
     4.8 +
     4.9 +CFLAGS	+= -Iarch/$(XENARCH)/kernel
    4.10 +
    4.11 +obj-$(CONFIG_IA32_EMULATION) := ia32entry.o syscall32.o
    4.12 +
    4.13 +c-obj-$(CONFIG_IA32_EMULATION) := sys_ia32.o ia32_ioctl.o \
    4.14 +	ia32_signal.o tls32.o \
    4.15 +	ia32_binfmt.o fpu32.o ptrace32.o 
    4.16 +
    4.17 +s-obj-y :=
    4.18 +
    4.19 +sysv-$(CONFIG_SYSVIPC) := ipc32.o
    4.20 +c-obj-$(CONFIG_IA32_EMULATION) += $(sysv-y)
    4.21 +
    4.22 +c-obj-$(CONFIG_IA32_AOUT) += ia32_aout.o
    4.23 +
    4.24 +$(obj)/syscall32.o: $(src)/syscall32.c \
    4.25 +	$(foreach F,int80 sysenter syscall,$(obj)/vsyscall-$F.so)
    4.26 +
    4.27 +# Teach kbuild about targets
    4.28 +targets := $(foreach F,int80 sysenter syscall,vsyscall-$F.o vsyscall-$F.so)
    4.29 +
    4.30 +# The DSO images are built using a special linker script
    4.31 +quiet_cmd_syscall = SYSCALL $@
    4.32 +      cmd_syscall = $(CC) -m32 -nostdlib -shared -s \
    4.33 +			   -Wl,-soname=linux-gate.so.1 -o $@ \
    4.34 +			   -Wl,-T,$(filter-out FORCE,$^)
    4.35 +
    4.36 +
    4.37 +$(obj)/vsyscall-int80.so $(obj)/vsyscall-sysenter.so $(obj)/vsyscall-syscall.so: \
    4.38 +$(obj)/vsyscall-%.so: $(src)/vsyscall.lds $(src)/vsyscall-%.o FORCE
    4.39 +	$(call if_changed,syscall)
    4.40 +
    4.41 +AFLAGS_vsyscall-int80.o = -m32
    4.42 +AFLAGS_vsyscall-sysenter.o = -m32
    4.43 +AFLAGS_vsyscall-syscall.o = -m32
    4.44 +CFLAGS_ia32_ioctl.o += -Ifs/
    4.45 +
    4.46 +s-link	:= vsyscall-syscall.o vsyscall-sysenter.o vsyscall-sigreturn.o
    4.47 +
    4.48 +$(src)/vsyscall.lds:
    4.49 +	@ln -fsn $(srctree)/arch/x86_64/ia32/$(notdir $@) $@
    4.50 +
    4.51 +$(patsubst %.o,$(obj)/%.c,$(c-obj-y) $(c-link)) $(patsubst %.o,$(obj)/%.S,$(s-obj-y) $(s-link)):
    4.52 +	@ln -fsn $(srctree)/arch/x86_64/ia32/$(notdir $@) $@
    4.53 +
    4.54 +$(obj)/vsyscall-int80.S: $(obj)/vsyscall-sigreturn.S
    4.55 +$(obj)/vsyscall-sysenter.S: $(obj)/vsyscall-sigreturn.S
    4.56 +$(obj)/vsyscall-syscall.S: $(obj)/vsyscall-sigreturn.S
    4.57 +
    4.58 +obj-y	+= $(c-obj-y) $(s-obj-y)
    4.59 +
    4.60 +clean-files += $(patsubst %.o,%.c,$(c-obj-y) $(c-obj-) $(c-link))
    4.61 +clean-files += $(patsubst %.o,%.S,$(s-obj-y) $(s-obj-) $(s-link))
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/ia32entry.S	Thu Jun 23 09:24:21 2005 +0000
     5.3 @@ -0,0 +1,629 @@
     5.4 +/*
     5.5 + * Compatibility mode system call entry point for x86-64. 
     5.6 + * 		
     5.7 + * Copyright 2000-2002 Andi Kleen, SuSE Labs.
     5.8 + */		 
     5.9 +
    5.10 +#include <asm/dwarf2.h>
    5.11 +#include <asm/calling.h>
    5.12 +#include <asm/offset.h>
    5.13 +#include <asm/current.h>
    5.14 +#include <asm/errno.h>
    5.15 +#include <asm/ia32_unistd.h>	
    5.16 +#include <asm/thread_info.h>	
    5.17 +#include <asm/segment.h>
    5.18 +#include <asm/vsyscall32.h>
    5.19 +#include <linux/linkage.h>
    5.20 +
    5.21 +#define __XEN_X86_64 1
    5.22 +	
    5.23 +	.macro IA32_ARG_FIXUP noebp=0
    5.24 +	movl	%edi,%r8d
    5.25 +	.if \noebp
    5.26 +	.else
    5.27 +	movl	%ebp,%r9d
    5.28 +	.endif
    5.29 +	xchg	%ecx,%esi
    5.30 +	movl	%ebx,%edi
    5.31 +	movl	%edx,%edx	/* zero extension */
    5.32 +	.endm 
    5.33 +
    5.34 +	/* clobbers %eax */	
    5.35 +	.macro  CLEAR_RREGS
    5.36 +	xorl 	%eax,%eax
    5.37 +	movq	%rax,R11(%rsp)
    5.38 +	movq	%rax,R10(%rsp)
    5.39 +	movq	%rax,R9(%rsp)
    5.40 +	movq	%rax,R8(%rsp)
    5.41 +	.endm
    5.42 +
    5.43 +#if defined (__XEN_X86_64)
    5.44 +#include "../kernel/xen_entry.S"
    5.45 +		
    5.46 +#define	__swapgs
    5.47 +#define __cli
    5.48 +#define __sti	
    5.49 +#else
    5.50 +/*
    5.51 + * Use the native instructions
    5.52 + */	
    5.53 +#define	__swapgs	swapgs
    5.54 +#define __cli		cli
    5.55 +#define __sti		sti	
    5.56 +#endif			
    5.57 +
    5.58 +/*
    5.59 + * 32bit SYSENTER instruction entry.
    5.60 + *
    5.61 + * Arguments:
    5.62 + * %eax	System call number.
    5.63 + * %ebx Arg1
    5.64 + * %ecx Arg2
    5.65 + * %edx Arg3
    5.66 + * %esi Arg4
    5.67 + * %edi Arg5
    5.68 + * %ebp user stack
    5.69 + * 0(%ebp) Arg6	
    5.70 + * 	
    5.71 + * Interrupts off.
    5.72 + *	
    5.73 + * This is purely a fast path. For anything complicated we use the int 0x80
    5.74 + * path below.	Set up a complete hardware stack frame to share code
    5.75 + * with the int 0x80 path.
    5.76 + */ 	
    5.77 +ENTRY(ia32_sysenter_target)
    5.78 +	CFI_STARTPROC
    5.79 +	__swapgs 
    5.80 +	movq	%gs:pda_kernelstack, %rsp
    5.81 +	addq	$(PDA_STACKOFFSET),%rsp
    5.82 +	XEN_UNBLOCK_EVENTS(%r11)	
    5.83 +	__sti
    5.84 + 	movl	%ebp,%ebp		/* zero extension */
    5.85 +	pushq	$__USER32_DS
    5.86 +	pushq	%rbp
    5.87 +	pushfq
    5.88 +	movl	$VSYSCALL32_SYSEXIT, %r10d
    5.89 +	pushq	$__USER32_CS
    5.90 +	movl	%eax, %eax
    5.91 +	pushq	%r10
    5.92 +	pushq	%rax
    5.93 +	cld
    5.94 +	SAVE_ARGS 0,0,1
    5.95 + 	/* no need to do an access_ok check here because rbp has been
    5.96 + 	   32bit zero extended */ 
    5.97 +1:	movl	(%rbp),%r9d
    5.98 + 	.section __ex_table,"a"
    5.99 + 	.quad 1b,ia32_badarg
   5.100 + 	.previous	
   5.101 +	GET_THREAD_INFO(%r10)
   5.102 +	testl  $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
   5.103 +	jnz  sysenter_tracesys
   5.104 +sysenter_do_call:	
   5.105 +	cmpl	$(IA32_NR_syscalls),%eax
   5.106 +	jae	ia32_badsys
   5.107 +	IA32_ARG_FIXUP 1
   5.108 +	call	*ia32_sys_call_table(,%rax,8)
   5.109 +	movq	%rax,RAX-ARGOFFSET(%rsp)
   5.110 +	GET_THREAD_INFO(%r10)
   5.111 +	XEN_BLOCK_EVENTS(%r11)	
   5.112 +	__cli
   5.113 +	testl	$_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
   5.114 +	jnz	int_ret_from_sys_call
   5.115 +	/* clear IF, that popfq doesn't enable interrupts early */
   5.116 +	andl  $~0x200,EFLAGS-R11(%rsp) 
   5.117 +	RESTORE_ARGS 1,24,1,1,1,1
   5.118 +	popfq
   5.119 +	popq	%rcx				/* User %esp */
   5.120 +	movl	$VSYSCALL32_SYSEXIT,%edx	/* User %eip */
   5.121 +	__swapgs
   5.122 +	XEN_UNBLOCK_EVENTS(%r11)		
   5.123 +	__sti		/* sti only takes effect after the next instruction */
   5.124 +	/* sysexit */
   5.125 +	.byte	0xf, 0x35  /* TBD */
   5.126 +
   5.127 +sysenter_tracesys:
   5.128 +	SAVE_REST
   5.129 +	CLEAR_RREGS
   5.130 +	movq	$-ENOSYS,RAX(%rsp)	/* really needed? */
   5.131 +	movq	%rsp,%rdi        /* &pt_regs -> arg1 */
   5.132 +	call	syscall_trace_enter
   5.133 +	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
   5.134 +	RESTORE_REST
   5.135 +	movl	%ebp, %ebp
   5.136 +	/* no need to do an access_ok check here because rbp has been
   5.137 +	   32bit zero extended */ 
   5.138 +1:	movl	(%rbp),%r9d
   5.139 +	.section __ex_table,"a"
   5.140 +	.quad 1b,ia32_badarg
   5.141 +	.previous
   5.142 +	jmp	sysenter_do_call
   5.143 +	CFI_ENDPROC
   5.144 +
   5.145 +/*
   5.146 + * 32bit SYSCALL instruction entry.
   5.147 + *
   5.148 + * Arguments:
   5.149 + * %eax	System call number.
   5.150 + * %ebx Arg1
   5.151 + * %ecx return EIP 
   5.152 + * %edx Arg3
   5.153 + * %esi Arg4
   5.154 + * %edi Arg5
   5.155 + * %ebp Arg2    [note: not saved in the stack frame, should not be touched]
   5.156 + * %esp user stack 
   5.157 + * 0(%esp) Arg6
   5.158 + * 	
   5.159 + * Interrupts off.
   5.160 + *	
   5.161 + * This is purely a fast path. For anything complicated we use the int 0x80
   5.162 + * path below.	Set up a complete hardware stack frame to share code
   5.163 + * with the int 0x80 path.	
   5.164 + */ 	
   5.165 +ENTRY(ia32_cstar_target)
   5.166 +	CFI_STARTPROC
   5.167 +	__swapgs
   5.168 +	movl	%esp,%r8d
   5.169 +	movq	%gs:pda_kernelstack,%rsp
   5.170 +	XEN_UNBLOCK_EVENTS(%r11)	
   5.171 +	__sti
   5.172 +	SAVE_ARGS 8,1,1
   5.173 +	movl 	%eax,%eax	/* zero extension */
   5.174 +	movq	%rax,ORIG_RAX-ARGOFFSET(%rsp)
   5.175 +	movq	%rcx,RIP-ARGOFFSET(%rsp)
   5.176 +	movq	%rbp,RCX-ARGOFFSET(%rsp) /* this lies slightly to ptrace */
   5.177 +	movl	%ebp,%ecx
   5.178 +	movq	$__USER32_CS,CS-ARGOFFSET(%rsp)
   5.179 +	movq	$__USER32_DS,SS-ARGOFFSET(%rsp)
   5.180 +	movq	%r11,EFLAGS-ARGOFFSET(%rsp)
   5.181 +	movq	%r8,RSP-ARGOFFSET(%rsp)	
   5.182 +	/* no need to do an access_ok check here because r8 has been
   5.183 +	   32bit zero extended */ 
   5.184 +	/* hardware stack frame is complete now */	
   5.185 +1:	movl	(%r8),%r9d
   5.186 +	.section __ex_table,"a"
   5.187 +	.quad 1b,ia32_badarg
   5.188 +	.previous	
   5.189 +	GET_THREAD_INFO(%r10)
   5.190 +	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
   5.191 +	jnz   cstar_tracesys
   5.192 +cstar_do_call:	
   5.193 +	cmpl $IA32_NR_syscalls,%eax
   5.194 +	jae  ia32_badsys
   5.195 +	IA32_ARG_FIXUP 1
   5.196 +	call *ia32_sys_call_table(,%rax,8)
   5.197 +	movq %rax,RAX-ARGOFFSET(%rsp)
   5.198 +	GET_THREAD_INFO(%r10)
   5.199 +	XEN_BLOCK_EVENTS(%r11)		
   5.200 +	__cli
   5.201 +	testl $_TIF_ALLWORK_MASK,threadinfo_flags(%r10)
   5.202 +	jnz  int_ret_from_sys_call
   5.203 +	RESTORE_ARGS 1,-ARG_SKIP,1,1,1
   5.204 +	movl RIP-ARGOFFSET(%rsp),%ecx
   5.205 +	movl EFLAGS-ARGOFFSET(%rsp),%r11d	
   5.206 +	movl RSP-ARGOFFSET(%rsp),%esp
   5.207 +	__swapgs
   5.208 +	sysretl  /* TBD */
   5.209 +	
   5.210 +cstar_tracesys:	
   5.211 +	SAVE_REST
   5.212 +	CLEAR_RREGS
   5.213 +	movq $-ENOSYS,RAX(%rsp)	/* really needed? */
   5.214 +	movq %rsp,%rdi        /* &pt_regs -> arg1 */
   5.215 +	call syscall_trace_enter
   5.216 +	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
   5.217 +	RESTORE_REST
   5.218 +	movl RSP-ARGOFFSET(%rsp), %r8d
   5.219 +	/* no need to do an access_ok check here because r8 has been
   5.220 +	   32bit zero extended */ 
   5.221 +1:	movl	(%r8),%r9d
   5.222 +	.section __ex_table,"a"
   5.223 +	.quad 1b,ia32_badarg
   5.224 +	.previous
   5.225 +	jmp cstar_do_call
   5.226 +				
   5.227 +ia32_badarg:
   5.228 +	movq $-EFAULT,%rax
   5.229 +	jmp ia32_sysret
   5.230 +	CFI_ENDPROC
   5.231 +
   5.232 +/* 
   5.233 + * Emulated IA32 system calls via int 0x80. 
   5.234 + *
   5.235 + * Arguments:	 
   5.236 + * %eax	System call number.
   5.237 + * %ebx Arg1
   5.238 + * %ecx Arg2
   5.239 + * %edx Arg3
   5.240 + * %esi Arg4
   5.241 + * %edi Arg5
   5.242 + * %ebp Arg6    [note: not saved in the stack frame, should not be touched]
   5.243 + *
   5.244 + * Notes:
   5.245 + * Uses the same stack frame as the x86-64 version.	
   5.246 + * All registers except %eax must be saved (but ptrace may violate that)
   5.247 + * Arguments are zero extended. For system calls that want sign extension and
   5.248 + * take long arguments a wrapper is needed. Most calls can just be called
   5.249 + * directly.
   5.250 + * Assumes it is only called from user space and entered with interrupts off.	
   5.251 + */ 				
   5.252 +
   5.253 +ENTRY(ia32_syscall)
   5.254 +	CFI_STARTPROC
   5.255 +	__swapgs
   5.256 +	XEN_UNBLOCK_EVENTS(%r11)
   5.257 +	__sti
   5.258 +	movq (%rsp),%rcx
   5.259 +	movq 8(%rsp),%r11
   5.260 +        addq $0x10,%rsp /* skip rcx and r11 */
   5.261 +	movl %eax,%eax
   5.262 +	pushq %rax
   5.263 +	cld
   5.264 +/* 1:	jmp 1b	 */
   5.265 +	/* note the registers are not zero extended to the sf.
   5.266 +	   this could be a problem. */
   5.267 +	SAVE_ARGS 0,0,1
   5.268 +	GET_THREAD_INFO(%r10)
   5.269 +	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%r10)
   5.270 +	jnz ia32_tracesys
   5.271 +ia32_do_syscall:	
   5.272 +	cmpl $(IA32_NR_syscalls),%eax
   5.273 +	jae  ia32_badsys
   5.274 +	IA32_ARG_FIXUP
   5.275 +	call *ia32_sys_call_table(,%rax,8) # xxx: rip relative
   5.276 +ia32_sysret:
   5.277 +	movq %rax,RAX-ARGOFFSET(%rsp)
   5.278 +	jmp int_ret_from_sys_call 
   5.279 +
   5.280 +ia32_tracesys:			 
   5.281 +	SAVE_REST
   5.282 +	movq $-ENOSYS,RAX(%rsp)	/* really needed? */
   5.283 +	movq %rsp,%rdi        /* &pt_regs -> arg1 */
   5.284 +	call syscall_trace_enter
   5.285 +	LOAD_ARGS ARGOFFSET  /* reload args from stack in case ptrace changed it */
   5.286 +	RESTORE_REST
   5.287 +	jmp ia32_do_syscall
   5.288 +
   5.289 +ia32_badsys:
   5.290 +	movq $0,ORIG_RAX-ARGOFFSET(%rsp)
   5.291 +	movq $-ENOSYS,RAX-ARGOFFSET(%rsp)
   5.292 +	jmp int_ret_from_sys_call
   5.293 +
   5.294 +ni_syscall:
   5.295 +	movq %rax,%rdi
   5.296 +	jmp  sys32_ni_syscall			
   5.297 +
   5.298 +quiet_ni_syscall:
   5.299 +	movq $-ENOSYS,%rax
   5.300 +	ret
   5.301 +	CFI_ENDPROC
   5.302 +	
   5.303 +	.macro PTREGSCALL label, func, arg
   5.304 +	.globl \label
   5.305 +\label:
   5.306 +	leaq \func(%rip),%rax
   5.307 +	leaq -ARGOFFSET+8(%rsp),\arg	/* 8 for return address */
   5.308 +	jmp  ia32_ptregs_common	
   5.309 +	.endm
   5.310 +
   5.311 +	PTREGSCALL stub32_rt_sigreturn, sys32_rt_sigreturn, %rdi
   5.312 +	PTREGSCALL stub32_sigreturn, sys32_sigreturn, %rdi
   5.313 +	PTREGSCALL stub32_sigaltstack, sys32_sigaltstack, %rdx
   5.314 +	PTREGSCALL stub32_sigsuspend, sys32_sigsuspend, %rcx
   5.315 +	PTREGSCALL stub32_execve, sys32_execve, %rcx
   5.316 +	PTREGSCALL stub32_fork, sys_fork, %rdi
   5.317 +	PTREGSCALL stub32_clone, sys32_clone, %rdx
   5.318 +	PTREGSCALL stub32_vfork, sys_vfork, %rdi
   5.319 +	PTREGSCALL stub32_iopl, sys_iopl, %rsi
   5.320 +	PTREGSCALL stub32_rt_sigsuspend, sys_rt_sigsuspend, %rdx
   5.321 +
   5.322 +ENTRY(ia32_ptregs_common)
   5.323 +	CFI_STARTPROC
   5.324 +	popq %r11
   5.325 +	SAVE_REST
   5.326 +	call *%rax
   5.327 +	RESTORE_REST
   5.328 +	jmp  ia32_sysret	/* misbalances the return cache */
   5.329 +	CFI_ENDPROC
   5.330 +
   5.331 +	.data
   5.332 +	.align 8
   5.333 +	.globl ia32_sys_call_table
   5.334 +ia32_sys_call_table:
   5.335 +	.quad sys_restart_syscall
   5.336 +	.quad sys_exit
   5.337 +	.quad stub32_fork
   5.338 +	.quad sys_read
   5.339 +	.quad sys_write
   5.340 +	.quad sys32_open		/* 5 */
   5.341 +	.quad sys_close
   5.342 +	.quad sys32_waitpid
   5.343 +	.quad sys_creat
   5.344 +	.quad sys_link
   5.345 +	.quad sys_unlink		/* 10 */
   5.346 +	.quad stub32_execve
   5.347 +	.quad sys_chdir
   5.348 +	.quad compat_sys_time
   5.349 +	.quad sys_mknod
   5.350 +	.quad sys_chmod		/* 15 */
   5.351 +	.quad sys_lchown16
   5.352 +	.quad quiet_ni_syscall			/* old break syscall holder */
   5.353 +	.quad sys_stat
   5.354 +	.quad sys32_lseek
   5.355 +	.quad sys_getpid		/* 20 */
   5.356 +	.quad compat_sys_mount	/* mount  */
   5.357 +	.quad sys_oldumount	/* old_umount  */
   5.358 +	.quad sys_setuid16
   5.359 +	.quad sys_getuid16
   5.360 +	.quad compat_sys_stime	/* stime */		/* 25 */
   5.361 +	.quad sys32_ptrace	/* ptrace */
   5.362 +	.quad sys_alarm
   5.363 +	.quad sys_fstat	/* (old)fstat */
   5.364 +	.quad sys_pause
   5.365 +	.quad compat_sys_utime	/* 30 */
   5.366 +	.quad quiet_ni_syscall	/* old stty syscall holder */
   5.367 +	.quad quiet_ni_syscall	/* old gtty syscall holder */
   5.368 +	.quad sys_access
   5.369 +	.quad sys_nice	
   5.370 +	.quad quiet_ni_syscall	/* 35 */	/* old ftime syscall holder */
   5.371 +	.quad sys_sync
   5.372 +	.quad sys32_kill
   5.373 +	.quad sys_rename
   5.374 +	.quad sys_mkdir
   5.375 +	.quad sys_rmdir		/* 40 */
   5.376 +	.quad sys_dup
   5.377 +	.quad sys32_pipe
   5.378 +	.quad compat_sys_times
   5.379 +	.quad quiet_ni_syscall			/* old prof syscall holder */
   5.380 +	.quad sys_brk		/* 45 */
   5.381 +	.quad sys_setgid16
   5.382 +	.quad sys_getgid16
   5.383 +	.quad sys_signal
   5.384 +	.quad sys_geteuid16
   5.385 +	.quad sys_getegid16	/* 50 */
   5.386 +	.quad sys_acct
   5.387 +	.quad sys_umount			/* new_umount */
   5.388 +	.quad quiet_ni_syscall			/* old lock syscall holder */
   5.389 +	.quad compat_sys_ioctl
   5.390 +	.quad compat_sys_fcntl64		/* 55 */
   5.391 +	.quad quiet_ni_syscall			/* old mpx syscall holder */
   5.392 +	.quad sys_setpgid
   5.393 +	.quad quiet_ni_syscall			/* old ulimit syscall holder */
   5.394 +	.quad sys32_olduname
   5.395 +	.quad sys_umask		/* 60 */
   5.396 +	.quad sys_chroot
   5.397 +	.quad sys32_ustat
   5.398 +	.quad sys_dup2
   5.399 +	.quad sys_getppid
   5.400 +	.quad sys_getpgrp		/* 65 */
   5.401 +	.quad sys_setsid
   5.402 +	.quad sys32_sigaction
   5.403 +	.quad sys_sgetmask
   5.404 +	.quad sys_ssetmask
   5.405 +	.quad sys_setreuid16	/* 70 */
   5.406 +	.quad sys_setregid16
   5.407 +	.quad stub32_sigsuspend
   5.408 +	.quad compat_sys_sigpending
   5.409 +	.quad sys_sethostname
   5.410 +	.quad compat_sys_setrlimit	/* 75 */
   5.411 +	.quad compat_sys_old_getrlimit	/* old_getrlimit */
   5.412 +	.quad compat_sys_getrusage
   5.413 +	.quad sys32_gettimeofday
   5.414 +	.quad sys32_settimeofday
   5.415 +	.quad sys_getgroups16	/* 80 */
   5.416 +	.quad sys_setgroups16
   5.417 +	.quad sys32_old_select
   5.418 +	.quad sys_symlink
   5.419 +	.quad sys_lstat
   5.420 +	.quad sys_readlink		/* 85 */
   5.421 +#ifdef CONFIG_IA32_AOUT
   5.422 +	.quad sys_uselib
   5.423 +#else
   5.424 +	.quad quiet_ni_syscall
   5.425 +#endif
   5.426 +	.quad sys_swapon
   5.427 +	.quad sys_reboot
   5.428 +	.quad compat_sys_old_readdir
   5.429 +	.quad sys32_mmap		/* 90 */
   5.430 +	.quad sys_munmap
   5.431 +	.quad sys_truncate
   5.432 +	.quad sys_ftruncate
   5.433 +	.quad sys_fchmod
   5.434 +	.quad sys_fchown16		/* 95 */
   5.435 +	.quad sys_getpriority
   5.436 +	.quad sys_setpriority
   5.437 +	.quad quiet_ni_syscall			/* old profil syscall holder */
   5.438 +	.quad compat_sys_statfs
   5.439 +	.quad compat_sys_fstatfs		/* 100 */
   5.440 +	.quad sys_ioperm
   5.441 +	.quad compat_sys_socketcall
   5.442 +	.quad sys_syslog
   5.443 +	.quad compat_sys_setitimer
   5.444 +	.quad compat_sys_getitimer	/* 105 */
   5.445 +	.quad compat_sys_newstat
   5.446 +	.quad compat_sys_newlstat
   5.447 +	.quad compat_sys_newfstat
   5.448 +	.quad sys32_uname
   5.449 +	.quad stub32_iopl		/* 110 */
   5.450 +	.quad sys_vhangup
   5.451 +	.quad quiet_ni_syscall	/* old "idle" system call */
   5.452 +	.quad sys32_vm86_warning	/* vm86old */ 
   5.453 +	.quad compat_sys_wait4
   5.454 +	.quad sys_swapoff		/* 115 */
   5.455 +	.quad sys32_sysinfo
   5.456 +	.quad sys32_ipc
   5.457 +	.quad sys_fsync
   5.458 +	.quad stub32_sigreturn
   5.459 +	.quad stub32_clone		/* 120 */
   5.460 +	.quad sys_setdomainname
   5.461 +	.quad sys_uname
   5.462 +	.quad sys_modify_ldt
   5.463 +	.quad sys32_adjtimex
   5.464 +	.quad sys32_mprotect		/* 125 */
   5.465 +	.quad compat_sys_sigprocmask
   5.466 +	.quad quiet_ni_syscall		/* create_module */
   5.467 +	.quad sys_init_module
   5.468 +	.quad sys_delete_module
   5.469 +	.quad quiet_ni_syscall		/* 130  get_kernel_syms */
   5.470 +	.quad sys_quotactl
   5.471 +	.quad sys_getpgid
   5.472 +	.quad sys_fchdir
   5.473 +	.quad quiet_ni_syscall	/* bdflush */
   5.474 +	.quad sys_sysfs		/* 135 */
   5.475 +	.quad sys_personality
   5.476 +	.quad quiet_ni_syscall	/* for afs_syscall */
   5.477 +	.quad sys_setfsuid16
   5.478 +	.quad sys_setfsgid16
   5.479 +	.quad sys_llseek		/* 140 */
   5.480 +	.quad compat_sys_getdents
   5.481 +	.quad compat_sys_select
   5.482 +	.quad sys_flock
   5.483 +	.quad sys_msync
   5.484 +	.quad compat_sys_readv		/* 145 */
   5.485 +	.quad compat_sys_writev
   5.486 +	.quad sys_getsid
   5.487 +	.quad sys_fdatasync
   5.488 +	.quad sys32_sysctl	/* sysctl */
   5.489 +	.quad sys_mlock		/* 150 */
   5.490 +	.quad sys_munlock
   5.491 +	.quad sys_mlockall
   5.492 +	.quad sys_munlockall
   5.493 +	.quad sys_sched_setparam
   5.494 +	.quad sys_sched_getparam   /* 155 */
   5.495 +	.quad sys_sched_setscheduler
   5.496 +	.quad sys_sched_getscheduler
   5.497 +	.quad sys_sched_yield
   5.498 +	.quad sys_sched_get_priority_max
   5.499 +	.quad sys_sched_get_priority_min  /* 160 */
   5.500 +	.quad sys_sched_rr_get_interval
   5.501 +	.quad compat_sys_nanosleep
   5.502 +	.quad sys_mremap
   5.503 +	.quad sys_setresuid16
   5.504 +	.quad sys_getresuid16	/* 165 */
   5.505 +	.quad sys32_vm86_warning	/* vm86 */ 
   5.506 +	.quad quiet_ni_syscall	/* query_module */
   5.507 +	.quad sys_poll
   5.508 +	.quad compat_sys_nfsservctl
   5.509 +	.quad sys_setresgid16	/* 170 */
   5.510 +	.quad sys_getresgid16
   5.511 +	.quad sys_prctl
   5.512 +	.quad stub32_rt_sigreturn
   5.513 +	.quad sys32_rt_sigaction
   5.514 +	.quad sys32_rt_sigprocmask	/* 175 */
   5.515 +	.quad sys32_rt_sigpending
   5.516 +	.quad compat_sys_rt_sigtimedwait
   5.517 +	.quad sys32_rt_sigqueueinfo
   5.518 +	.quad stub32_rt_sigsuspend
   5.519 +	.quad sys32_pread		/* 180 */
   5.520 +	.quad sys32_pwrite
   5.521 +	.quad sys_chown16
   5.522 +	.quad sys_getcwd
   5.523 +	.quad sys_capget
   5.524 +	.quad sys_capset
   5.525 +	.quad stub32_sigaltstack
   5.526 +	.quad sys32_sendfile
   5.527 +	.quad quiet_ni_syscall		/* streams1 */
   5.528 +	.quad quiet_ni_syscall		/* streams2 */
   5.529 +	.quad stub32_vfork            /* 190 */
   5.530 +	.quad compat_sys_getrlimit
   5.531 +	.quad sys32_mmap2
   5.532 +	.quad sys32_truncate64
   5.533 +	.quad sys32_ftruncate64
   5.534 +	.quad sys32_stat64		/* 195 */
   5.535 +	.quad sys32_lstat64
   5.536 +	.quad sys32_fstat64
   5.537 +	.quad sys_lchown
   5.538 +	.quad sys_getuid
   5.539 +	.quad sys_getgid		/* 200 */
   5.540 +	.quad sys_geteuid
   5.541 +	.quad sys_getegid
   5.542 +	.quad sys_setreuid
   5.543 +	.quad sys_setregid
   5.544 +	.quad sys_getgroups	/* 205 */
   5.545 +	.quad sys_setgroups
   5.546 +	.quad sys_fchown
   5.547 +	.quad sys_setresuid
   5.548 +	.quad sys_getresuid
   5.549 +	.quad sys_setresgid	/* 210 */
   5.550 +	.quad sys_getresgid
   5.551 +	.quad sys_chown
   5.552 +	.quad sys_setuid
   5.553 +	.quad sys_setgid
   5.554 +	.quad sys_setfsuid		/* 215 */
   5.555 +	.quad sys_setfsgid
   5.556 +	.quad sys_pivot_root
   5.557 +	.quad sys_mincore
   5.558 +	.quad sys_madvise
   5.559 +	.quad compat_sys_getdents64	/* 220 getdents64 */
   5.560 +	.quad compat_sys_fcntl64	
   5.561 +	.quad quiet_ni_syscall		/* tux */
   5.562 +	.quad quiet_ni_syscall    	/* security */
   5.563 +	.quad sys_gettid	
   5.564 +	.quad sys_readahead	/* 225 */
   5.565 +	.quad sys_setxattr
   5.566 +	.quad sys_lsetxattr
   5.567 +	.quad sys_fsetxattr
   5.568 +	.quad sys_getxattr
   5.569 +	.quad sys_lgetxattr	/* 230 */
   5.570 +	.quad sys_fgetxattr
   5.571 +	.quad sys_listxattr
   5.572 +	.quad sys_llistxattr
   5.573 +	.quad sys_flistxattr
   5.574 +	.quad sys_removexattr	/* 235 */
   5.575 +	.quad sys_lremovexattr
   5.576 +	.quad sys_fremovexattr
   5.577 +	.quad sys_tkill
   5.578 +	.quad sys_sendfile64 
   5.579 +	.quad compat_sys_futex		/* 240 */
   5.580 +	.quad compat_sys_sched_setaffinity
   5.581 +	.quad compat_sys_sched_getaffinity
   5.582 +	.quad sys32_set_thread_area
   5.583 +	.quad sys32_get_thread_area
   5.584 +	.quad compat_sys_io_setup	/* 245 */
   5.585 +	.quad sys_io_destroy
   5.586 +	.quad compat_sys_io_getevents
   5.587 +	.quad compat_sys_io_submit
   5.588 +	.quad sys_io_cancel
   5.589 +	.quad sys_fadvise64		/* 250 */
   5.590 +	.quad quiet_ni_syscall 	/* free_huge_pages */
   5.591 +	.quad sys_exit_group
   5.592 +	.quad sys32_lookup_dcookie
   5.593 +	.quad sys_epoll_create
   5.594 +	.quad sys_epoll_ctl		/* 255 */
   5.595 +	.quad sys_epoll_wait
   5.596 +	.quad sys_remap_file_pages
   5.597 +	.quad sys_set_tid_address
   5.598 +	.quad sys32_timer_create
   5.599 +	.quad compat_sys_timer_settime	/* 260 */
   5.600 +	.quad compat_sys_timer_gettime
   5.601 +	.quad sys_timer_getoverrun
   5.602 +	.quad sys_timer_delete
   5.603 +	.quad compat_sys_clock_settime
   5.604 +	.quad compat_sys_clock_gettime	/* 265 */
   5.605 +	.quad compat_sys_clock_getres
   5.606 +	.quad compat_sys_clock_nanosleep
   5.607 +	.quad compat_sys_statfs64
   5.608 +	.quad compat_sys_fstatfs64
   5.609 +	.quad sys_tgkill		/* 270 */
   5.610 +	.quad compat_sys_utimes
   5.611 +	.quad sys32_fadvise64_64
   5.612 +	.quad quiet_ni_syscall	/* sys_vserver */
   5.613 +	.quad sys_mbind
   5.614 +	.quad compat_sys_get_mempolicy	/* 275 */
   5.615 +	.quad sys_set_mempolicy
   5.616 +	.quad compat_sys_mq_open
   5.617 +	.quad sys_mq_unlink
   5.618 +	.quad compat_sys_mq_timedsend
   5.619 +	.quad compat_sys_mq_timedreceive	/* 280 */
   5.620 +	.quad compat_sys_mq_notify
   5.621 +	.quad compat_sys_mq_getsetattr
   5.622 +	.quad quiet_ni_syscall		/* reserved for kexec */
   5.623 +	.quad sys32_waitid
   5.624 +	.quad quiet_ni_syscall		/* sys_altroot */
   5.625 +	.quad sys_add_key
   5.626 +	.quad sys_request_key
   5.627 +	.quad sys_keyctl
   5.628 +	/* don't forget to change IA32_NR_syscalls */
   5.629 +ia32_syscall_end:		
   5.630 +	.rept IA32_NR_syscalls-(ia32_syscall_end-ia32_sys_call_table)/8
   5.631 +		.quad ni_syscall
   5.632 +	.endr
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/syscall32.c	Thu Jun 23 09:24:21 2005 +0000
     6.3 @@ -0,0 +1,143 @@
     6.4 +/* Copyright 2002,2003 Andi Kleen, SuSE Labs */
     6.5 +
     6.6 +/* vsyscall handling for 32bit processes. Map a stub page into it 
     6.7 +   on demand because 32bit cannot reach the kernel's fixmaps */
     6.8 +
     6.9 +#include <linux/mm.h>
    6.10 +#include <linux/string.h>
    6.11 +#include <linux/kernel.h>
    6.12 +#include <linux/gfp.h>
    6.13 +#include <linux/init.h>
    6.14 +#include <linux/stringify.h>
    6.15 +#include <asm/proto.h>
    6.16 +#include <asm/tlbflush.h>
    6.17 +#include <asm/ia32_unistd.h>
    6.18 +
    6.19 +#define USE_INT80
    6.20 +
    6.21 +#ifdef USE_INT80
    6.22 +/* 32bit VDSOs mapped into user space. */ 
    6.23 +asm(".section \".init.data\",\"aw\"\n"
    6.24 +    "syscall32_int80:\n"
    6.25 +    ".incbin \"arch/xen/x86_64/ia32/vsyscall-int80.so\"\n"
    6.26 +    "syscall32_int80_end:\n"
    6.27 +    "syscall32_syscall:\n"
    6.28 +    ".incbin \"arch/xen/x86_64/ia32/vsyscall-syscall.so\"\n"
    6.29 +    "syscall32_syscall_end:\n"
    6.30 +    "syscall32_sysenter:\n"
    6.31 +    ".incbin \"arch/xen/x86_64/ia32/vsyscall-sysenter.so\"\n"
    6.32 +    "syscall32_sysenter_end:\n"
    6.33 +    ".previous");
    6.34 +
    6.35 +extern unsigned char syscall32_int80[], syscall32_int80_end[];
    6.36 +#else
    6.37 +/* 32bit VDSOs mapped into user space. */ 
    6.38 +asm(".section \".init.data\",\"aw\"\n"
    6.39 +    "syscall32_syscall:\n"
    6.40 +    ".incbin \"arch/xen/x86_64/ia32/vsyscall-syscall.so\"\n"
    6.41 +    "syscall32_syscall_end:\n"
    6.42 +    "syscall32_sysenter:\n"
    6.43 +    ".incbin \"arch/xen/x86_64/ia32/vsyscall-sysenter.so\"\n"
    6.44 +    "syscall32_sysenter_end:\n"
    6.45 +    ".previous");
    6.46 +
    6.47 +static int use_sysenter = -1;
    6.48 +#endif
    6.49 +
    6.50 +extern unsigned char syscall32_syscall[], syscall32_syscall_end[];
    6.51 +extern unsigned char syscall32_sysenter[], syscall32_sysenter_end[];
    6.52 +extern int sysctl_vsyscall32;
    6.53 +
    6.54 +char *syscall32_page; 
    6.55 +
    6.56 +/*
    6.57 + * Map the 32bit vsyscall page on demand.
    6.58 + *
    6.59 + * RED-PEN: This knows too much about high level VM.
    6.60 + *
    6.61 + * Alternative would be to generate a vma with appropriate backing options
    6.62 + * and let it be handled by generic VM.
    6.63 + */
    6.64 +int __map_syscall32(struct mm_struct *mm, unsigned long address)
    6.65 +{ 
    6.66 +	pgd_t *pgd;
    6.67 +	pud_t *pud;
    6.68 +	pte_t *pte;
    6.69 +	pmd_t *pmd;
    6.70 +	int err = -ENOMEM;
    6.71 +
    6.72 +	spin_lock(&mm->page_table_lock); 
    6.73 + 	pgd = pgd_offset(mm, address);
    6.74 + 	pud = pud_alloc(mm, pgd, address);
    6.75 + 	if (pud) {
    6.76 + 		pmd = pmd_alloc(mm, pud, address);
    6.77 + 		if (pmd && (pte = pte_alloc_map(mm, pmd, address)) != NULL) {
    6.78 + 			if (pte_none(*pte)) {
    6.79 + 				set_pte(pte,
    6.80 + 					mk_pte(virt_to_page(syscall32_page),
    6.81 + 					       PAGE_KERNEL_VSYSCALL32));
    6.82 + 			}
    6.83 + 			/* Flush only the local CPU. Other CPUs taking a fault
    6.84 + 			   will just end up here again
    6.85 +			   This probably not needed and just paranoia. */
    6.86 + 			__flush_tlb_one(address);
    6.87 + 			err = 0;
    6.88 +		}
    6.89 +	}
    6.90 +	spin_unlock(&mm->page_table_lock);
    6.91 +	return err;
    6.92 +}
    6.93 +
    6.94 +int map_syscall32(struct mm_struct *mm, unsigned long address)
    6.95 +{
    6.96 +	int err;
    6.97 +	down_read(&mm->mmap_sem);
    6.98 +	err = __map_syscall32(mm, address);
    6.99 +	up_read(&mm->mmap_sem);
   6.100 +	return err;
   6.101 +}
   6.102 +
   6.103 +static int __init init_syscall32(void)
   6.104 +{ 
   6.105 +	syscall32_page = (void *)get_zeroed_page(GFP_KERNEL); 
   6.106 +	if (!syscall32_page) 
   6.107 +		panic("Cannot allocate syscall32 page"); 
   6.108 +	SetPageReserved(virt_to_page(syscall32_page));
   6.109 +
   6.110 +#ifdef USE_INT80
   6.111 +	/*
   6.112 +	 * At this point we use int 0x80.
   6.113 +	 */
   6.114 +	memcpy(syscall32_page, syscall32_int80,
   6.115 +	       syscall32_int80_end - syscall32_int80);
   6.116 +#else
   6.117 +
   6.118 + 	if (use_sysenter > 0) {
   6.119 + 		memcpy(syscall32_page, syscall32_sysenter,
   6.120 + 		       syscall32_sysenter_end - syscall32_sysenter);
   6.121 + 	} else {
   6.122 +  		memcpy(syscall32_page, syscall32_syscall,
   6.123 +  		       syscall32_syscall_end - syscall32_syscall);
   6.124 +  	}	
   6.125 +#endif
   6.126 +	return 0;
   6.127 +} 
   6.128 +	
   6.129 +__initcall(init_syscall32); 
   6.130 +
   6.131 +/* May not be __init: called during resume */
   6.132 +void syscall32_cpu_init(void)
   6.133 +{
   6.134 +#ifndef USE_INT80
   6.135 +	if (use_sysenter < 0)
   6.136 + 		use_sysenter = (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL);
   6.137 +
   6.138 +	/* Load these always in case some future AMD CPU supports
   6.139 +	   SYSENTER from compat mode too. */
   6.140 +	checking_wrmsrl(MSR_IA32_SYSENTER_CS, (u64)(__KERNEL_CS | 3));
   6.141 +	checking_wrmsrl(MSR_IA32_SYSENTER_ESP, 0ULL);
   6.142 +	checking_wrmsrl(MSR_IA32_SYSENTER_EIP, (u64)ia32_sysenter_target);
   6.143 +
   6.144 +	wrmsrl(MSR_CSTAR, ia32_cstar_target);
   6.145 +#endif
   6.146 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/ia32/vsyscall-int80.S	Thu Jun 23 09:24:21 2005 +0000
     7.3 @@ -0,0 +1,57 @@
     7.4 +/*
     7.5 + * Code for the vsyscall page.  This version uses the old int $0x80 method.
     7.6 + *
     7.7 + * NOTE:
     7.8 + * 1) __kernel_vsyscall _must_ be first in this page.
     7.9 + * 2) there are alignment constraints on this stub, see vsyscall-sigreturn.S
    7.10 + *    for details.
    7.11 + */
    7.12 +#include <asm/ia32_unistd.h>
    7.13 +#include <asm/offset.h>
    7.14 +
    7.15 +	.text
    7.16 +	.section .text.vsyscall,"ax"
    7.17 +	.globl __kernel_vsyscall
    7.18 +	.type __kernel_vsyscall,@function
    7.19 +__kernel_vsyscall:
    7.20 +.LSTART_vsyscall:
    7.21 +	int $0x80
    7.22 +	ret
    7.23 +.LEND_vsyscall:
    7.24 +	.size __kernel_vsyscall,.-.LSTART_vsyscall
    7.25 +	.previous
    7.26 +
    7.27 +	.section .eh_frame,"a",@progbits
    7.28 +.LSTARTFRAME:
    7.29 +	.long .LENDCIE-.LSTARTCIE
    7.30 +.LSTARTCIE:
    7.31 +	.long 0			/* CIE ID */
    7.32 +	.byte 1			/* Version number */
    7.33 +	.string "zR"		/* NUL-terminated augmentation string */
    7.34 +	.uleb128 1		/* Code alignment factor */
    7.35 +	.sleb128 -4		/* Data alignment factor */
    7.36 +	.byte 8			/* Return address register column */
    7.37 +	.uleb128 1		/* Augmentation value length */
    7.38 +	.byte 0x1b		/* DW_EH_PE_pcrel|DW_EH_PE_sdata4. */
    7.39 +	.byte 0x0c		/* DW_CFA_def_cfa */
    7.40 +	.uleb128 4
    7.41 +	.uleb128 4
    7.42 +	.byte 0x88		/* DW_CFA_offset, column 0x8 */
    7.43 +	.uleb128 1
    7.44 +	.align 4
    7.45 +.LENDCIE:
    7.46 +
    7.47 +	.long .LENDFDE1-.LSTARTFDE1	/* Length FDE */
    7.48 +.LSTARTFDE1:
    7.49 +	.long .LSTARTFDE1-.LSTARTFRAME	/* CIE pointer */
    7.50 +	.long .LSTART_vsyscall-.	/* PC-relative start address */
    7.51 +	.long .LEND_vsyscall-.LSTART_vsyscall
    7.52 +	.uleb128 0			/* Augmentation length */
    7.53 +	.align 4
    7.54 +.LENDFDE1:
    7.55 +		
    7.56 +/*
    7.57 + * Get the common code for the sigreturn entry points.
    7.58 + */
    7.59 +#define SYSCALL_ENTER_KERNEL    int $0x80
    7.60 +#include "vsyscall-sigreturn.S"
     8.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Thu Jun 23 09:19:35 2005 +0000
     8.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Thu Jun 23 09:24:21 2005 +0000
     8.3 @@ -50,43 +50,8 @@
     8.4  
     8.5  #include "irq_vectors.h"
     8.6  
     8.7 -EVENT_MASK      = (CS+4)
     8.8 -VGCF_IN_SYSCALL = (1<<8)
     8.9 -        
    8.10 -/*
    8.11 - * Copied from arch/xen/i386/kernel/entry.S
    8.12 - */                        
    8.13 -/* Offsets into shared_info_t. */                
    8.14 -#define evtchn_upcall_pending		0
    8.15 -#define evtchn_upcall_mask		1
    8.16 -
    8.17 -#define sizeof_vcpu_shift		3
    8.18 -
    8.19 -#ifdef CONFIG_SMP
    8.20 -#define preempt_disable(reg)	incl threadinfo_preempt_count(reg)
    8.21 -#define preempt_enable(reg)	decl threadinfo_preempt_count(reg)
    8.22 -#define XEN_GET_VCPU_INFO(reg)	preempt_disable(%rbp)			; \
    8.23 -				movq %gs:pda_cpunumber,reg		; \
    8.24 -				shl  $sizeof_vcpu_shift,reg		; \
    8.25 -				addq HYPERVISOR_shared_info,reg
    8.26 -#define XEN_PUT_VCPU_INFO(reg)	preempt_enable(%rbp)			; \
    8.27 -#define XEN_PUT_VCPU_INFO_fixup .byte 0xff,0xff,0xff
    8.28 -#else
    8.29 -#define XEN_GET_VCPU_INFO(reg)	movq HYPERVISOR_shared_info,reg
    8.30 -#define XEN_PUT_VCPU_INFO(reg)
    8.31 -#define XEN_PUT_VCPU_INFO_fixup
    8.32 -#endif
    8.33 -
    8.34 -#define XEN_LOCKED_BLOCK_EVENTS(reg)	movb $1,evtchn_upcall_mask(reg)
    8.35 -#define XEN_LOCKED_UNBLOCK_EVENTS(reg)	movb $0,evtchn_upcall_mask(reg)
    8.36 -#define XEN_BLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
    8.37 -				XEN_LOCKED_BLOCK_EVENTS(reg)		; \
    8.38 -    				XEN_PUT_VCPU_INFO(reg)
    8.39 -#define XEN_UNBLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
    8.40 -				XEN_LOCKED_UNBLOCK_EVENTS(reg)		; \
    8.41 -    				XEN_PUT_VCPU_INFO(reg)
    8.42 -#define XEN_TEST_PENDING(reg)	testb $0xFF,evtchn_upcall_pending(reg)
    8.43 -
    8.44 +#include "xen_entry.S"
    8.45 +	
    8.46  	.code64
    8.47  
    8.48  #ifdef CONFIG_PREEMPT
    8.49 @@ -172,8 +137,6 @@ VGCF_IN_SYSCALL = (1<<8)
    8.50          movq %r11,1*8(%rsp)
    8.51          movq %rcx,2*8(%rsp)              # we saved %rcx upon exceptions
    8.52          movq $\flag,3*8(%rsp)
    8.53 -        movq $__USER_CS,5*8(%rsp)
    8.54 -        movq $__USER_DS,8*8(%rsp)
    8.55          movq $__HYPERVISOR_switch_to_user,%rax
    8.56          syscall
    8.57          .endm
     9.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c	Thu Jun 23 09:19:35 2005 +0000
     9.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/traps.c	Thu Jun 23 09:24:21 2005 +0000
     9.3 @@ -931,6 +931,9 @@ static trap_info_t trap_table[] = {
     9.4  #endif
     9.5          { 19, 0, (__KERNEL_CS|0x3), 0, (unsigned long)simd_coprocessor_error     },
     9.6          { SYSCALL_VECTOR,  3, (__KERNEL_CS|0x3), 0, (unsigned long)system_call   },
     9.7 +#ifdef CONFIG_IA32_EMULATION
     9.8 +	{ IA32_SYSCALL_VECTOR, 3, (__KERNEL_CS|0x3), 0, (unsigned long)ia32_syscall},
     9.9 +#endif
    9.10          {  0, 0,           0, 0,  0                                              }
    9.11  };
    9.12  
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/xen_entry.S	Thu Jun 23 09:24:21 2005 +0000
    10.3 @@ -0,0 +1,38 @@
    10.4 +/*
    10.5 + * Copied from arch/xen/i386/kernel/entry.S
    10.6 + */                        
    10.7 +/* Offsets into shared_info_t. */                
    10.8 +#define evtchn_upcall_pending		0
    10.9 +#define evtchn_upcall_mask		1
   10.10 +
   10.11 +#define sizeof_vcpu_shift		3
   10.12 +
   10.13 +#ifdef CONFIG_SMP
   10.14 +#define preempt_disable(reg)	incl threadinfo_preempt_count(reg)
   10.15 +#define preempt_enable(reg)	decl threadinfo_preempt_count(reg)
   10.16 +#define XEN_GET_VCPU_INFO(reg)	preempt_disable(%rbp)			; \
   10.17 +				movq %gs:pda_cpunumber,reg		; \
   10.18 +				shl  $sizeof_vcpu_shift,reg		; \
   10.19 +				addq HYPERVISOR_shared_info,reg
   10.20 +#define XEN_PUT_VCPU_INFO(reg)	preempt_enable(%rbp)			; \
   10.21 +#define XEN_PUT_VCPU_INFO_fixup .byte 0xff,0xff,0xff
   10.22 +#else
   10.23 +#define XEN_GET_VCPU_INFO(reg)	movq HYPERVISOR_shared_info,reg
   10.24 +#define XEN_PUT_VCPU_INFO(reg)
   10.25 +#define XEN_PUT_VCPU_INFO_fixup
   10.26 +#endif
   10.27 +
   10.28 +#define XEN_LOCKED_BLOCK_EVENTS(reg)	movb $1,evtchn_upcall_mask(reg)
   10.29 +#define XEN_LOCKED_UNBLOCK_EVENTS(reg)	movb $0,evtchn_upcall_mask(reg)
   10.30 +#define XEN_BLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
   10.31 +				XEN_LOCKED_BLOCK_EVENTS(reg)		; \
   10.32 +    				XEN_PUT_VCPU_INFO(reg)
   10.33 +#define XEN_UNBLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
   10.34 +				XEN_LOCKED_UNBLOCK_EVENTS(reg)		; \
   10.35 +    				XEN_PUT_VCPU_INFO(reg)
   10.36 +#define XEN_TEST_PENDING(reg)	testb $0xFF,evtchn_upcall_pending(reg)
   10.37 +
   10.38 +EVENT_MASK      = (CS+4)
   10.39 +VGCF_IN_SYSCALL = (1<<8)
   10.40 +        
   10.41 +	
    11.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/fault.c	Thu Jun 23 09:19:35 2005 +0000
    11.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/mm/fault.c	Thu Jun 23 09:24:21 2005 +0000
    11.3 @@ -563,6 +563,7 @@ no_context:
    11.4   */
    11.5  out_of_memory:
    11.6  	up_read(&mm->mmap_sem);
    11.7 +out_of_memory2:
    11.8  	if (current->pid == 1) { 
    11.9  		yield();
   11.10  		goto again;