direct-io.hg

changeset 5457:9a502087e263

bitkeeper revision 1.1713.1.9 (42af306adOSGlJaEmolMoERc4oAXYg)

[PATCH] x86_64 entry.S cleanup - take 3

This patch cleans up x86_64 entry.S. Namely, it updates the Xen relevant
macros to be the simpler version that's found in i386. This means that:

- XEN_[UN]BLOCK_EVENTS interface now takes care of dealing with
SMP issues and is no longer conditionally defined
- XEN_LOCKED_[UN]BLOCK_EVENTS is identical in both cases (SMP and UP)
and no longer needs to be conditionally defined
- XEN_[UN]LOCK_VPCU_INFO_SMP is dropped in favor of XEN_GET/PUT_VCPU_INFO

This cleans up the code, minimizes the differences with i386 code, and
lays the groundwork for SMP support (the real reason I did this ;-).
It's booting, executing syscalls, taking interrupts, etc (it's what I'm
using to send this e-mail).

Signed-off-by: Chris Wright <chrisw@osdl.org>

===== linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S 1.10 vs edited =====
author chrisw@osdl.org[kaf24]
date Tue Jun 14 19:30:50 2005 +0000 (2005-06-14)
parents 1696560591a6
children 21bfdeafeec2
files linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Tue Jun 14 13:06:33 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/x86_64/kernel/entry.S	Tue Jun 14 19:30:50 2005 +0000
     1.3 @@ -63,42 +63,28 @@ VGCF_IN_SYSCALL = (1<<8)
     1.4  #define sizeof_vcpu_shift		3
     1.5  
     1.6  #ifdef CONFIG_SMP
     1.7 -#define XEN_GET_VCPU_INFO(reg)
     1.8 -#define preempt_disable(reg)	incl TI_preempt_count(reg)
     1.9 -#define preempt_enable(reg)	decl TI_preempt_count(reg)
    1.10 -#define XEN_LOCK_VCPU_INFO_SMP(reg) preempt_disable(%rbp)		; \
    1.11 -				movq TI_cpu(%rbp),reg			; \
    1.12 +#define preempt_disable(reg)	incl threadinfo_preempt_count(reg)
    1.13 +#define preempt_enable(reg)	decl threadinfo_preempt_count(reg)
    1.14 +#define XEN_GET_VCPU_INFO(reg)	preempt_disable(%rbp)			; \
    1.15 +				movq %gs:pda_cpunumber,reg		; \
    1.16  				shl  $sizeof_vcpu_shift,reg		; \
    1.17  				addq HYPERVISOR_shared_info,reg
    1.18 -#define XEN_UNLOCK_VCPU_INFO_SMP(reg) preempt_enable(%rbp)
    1.19 -#define XEN_UNLOCK_VCPU_INFO_SMP_fixup .byte 0xff,0xff,0xff
    1.20 -#define Ux00 0xff
    1.21 -#define XEN_LOCKED_BLOCK_EVENTS(reg)	movb $1,evtchn_upcall_mask(reg)
    1.22 -#define XEN_BLOCK_EVENTS(reg)	XEN_LOCK_VCPU_INFO_SMP(reg)		; \
    1.23 -				XEN_LOCKED_BLOCK_EVENTS(reg)		; \
    1.24 -    				XEN_UNLOCK_VCPU_INFO_SMP(reg)
    1.25 -#define XEN_UNBLOCK_EVENTS(reg)	XEN_LOCK_VCPU_INFO_SMP(reg)		; \
    1.26 -				movb $0,evtchn_upcall_mask(reg)		; \
    1.27 -    				XEN_UNLOCK_VCPU_INFO_SMP(reg)
    1.28 -#define XEN_SAVE_UPCALL_MASK(reg,tmp,off) GET_THREAD_INFO(%rbp)		; \
    1.29 -				XEN_LOCK_VCPU_INFO_SMP(reg)		; \
    1.30 -				movb evtchn_upcall_mask(reg), tmp	; \
    1.31 -				movb tmp, off(%rsp)			; \
    1.32 -    				XEN_UNLOCK_VCPU_INFO_SMP(reg)
    1.33 +#define XEN_PUT_VCPU_INFO(reg)	preempt_enable(%rbp)			; \
    1.34 +#define XEN_PUT_VCPU_INFO_fixup .byte 0xff,0xff,0xff
    1.35  #else
    1.36  #define XEN_GET_VCPU_INFO(reg)	movq HYPERVISOR_shared_info,reg
    1.37 -#define XEN_LOCK_VCPU_INFO_SMP(reg) movq HYPERVISOR_shared_info,reg
    1.38 -#define XEN_UNLOCK_VCPU_INFO_SMP(reg)
    1.39 -#define XEN_UNLOCK_VCPU_INFO_SMP_fixup
    1.40 -#define Ux00 0x00
    1.41 -#define XEN_LOCKED_BLOCK_EVENTS(reg)	movb $1,evtchn_upcall_mask(reg)
    1.42 -#define XEN_BLOCK_EVENTS(reg)	XEN_LOCKED_BLOCK_EVENTS(reg)
    1.43 -#define XEN_UNBLOCK_EVENTS(reg)	movb $0,evtchn_upcall_mask(reg)
    1.44 -#define XEN_SAVE_UPCALL_MASK(reg,tmp,off) \
    1.45 -	movb evtchn_upcall_mask(reg), tmp; \
    1.46 -	movb tmp, off(%rsp)
    1.47 +#define XEN_PUT_VCPU_INFO(reg)
    1.48 +#define XEN_PUT_VCPU_INFO_fixup
    1.49  #endif
    1.50  
    1.51 +#define XEN_LOCKED_BLOCK_EVENTS(reg)	movb $1,evtchn_upcall_mask(reg)
    1.52 +#define XEN_LOCKED_UNBLOCK_EVENTS(reg)	movb $0,evtchn_upcall_mask(reg)
    1.53 +#define XEN_BLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
    1.54 +				XEN_LOCKED_BLOCK_EVENTS(reg)		; \
    1.55 +    				XEN_PUT_VCPU_INFO(reg)
    1.56 +#define XEN_UNBLOCK_EVENTS(reg)	XEN_GET_VCPU_INFO(reg)			; \
    1.57 +				XEN_LOCKED_UNBLOCK_EVENTS(reg)		; \
    1.58 +    				XEN_PUT_VCPU_INFO(reg)
    1.59  #define XEN_TEST_PENDING(reg)	testb $0xFF,evtchn_upcall_pending(reg)
    1.60  
    1.61  	.code64
    1.62 @@ -256,8 +242,6 @@ ENTRY(system_call)
    1.63  	CFI_STARTPROC
    1.64  	SAVE_ARGS -8,0
    1.65  	movq  %rax,ORIG_RAX-ARGOFFSET(%rsp) 
    1.66 -        XEN_GET_VCPU_INFO(%r11)
    1.67 -        XEN_SAVE_UPCALL_MASK(%r11,%cl,EVENT_MASK-ARGOFFSET)      # saved %rcx          
    1.68          XEN_UNBLOCK_EVENTS(%r11)        
    1.69  	GET_THREAD_INFO(%rcx)
    1.70  	testl $(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT),threadinfo_flags(%rcx)
    1.71 @@ -277,7 +261,6 @@ ret_from_sys_call:
    1.72  	/* edi:	flagmask */
    1.73  sysret_check:		
    1.74  	GET_THREAD_INFO(%rcx)
    1.75 -        XEN_GET_VCPU_INFO(%rsi)
    1.76          XEN_BLOCK_EVENTS(%rsi)        
    1.77  	movl threadinfo_flags(%rcx),%edx
    1.78  	andl %edi,%edx
    1.79 @@ -291,7 +274,6 @@ sysret_check:
    1.80  sysret_careful:
    1.81  	bt $TIF_NEED_RESCHED,%edx
    1.82  	jnc sysret_signal
    1.83 -        XEN_GET_VCPU_INFO(%rsi)
    1.84          XEN_BLOCK_EVENTS(%rsi)        
    1.85  	pushq %rdi
    1.86  	call schedule
    1.87 @@ -301,7 +283,6 @@ sysret_careful:
    1.88  	/* Handle a signal */ 
    1.89  sysret_signal:
    1.90  /*	sti */
    1.91 -        XEN_GET_VCPU_INFO(%rsi)
    1.92          XEN_UNBLOCK_EVENTS(%rsi)        
    1.93  	testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
    1.94  	jz    1f
    1.95 @@ -345,7 +326,6 @@ badsys:
    1.96   * Has correct top of stack, but partial stack frame.
    1.97   */ 	
    1.98  ENTRY(int_ret_from_sys_call)	
    1.99 -        XEN_GET_VCPU_INFO(%rsi)
   1.100          XEN_BLOCK_EVENTS(%rsi)
   1.101  	testb $3,CS-ARGOFFSET(%rsp)
   1.102          jnz 1f
   1.103 @@ -369,7 +349,6 @@ int_careful:
   1.104  	bt $TIF_NEED_RESCHED,%edx
   1.105  	jnc  int_very_careful
   1.106  /*	sti */
   1.107 -        XEN_GET_VCPU_INFO(%rsi)
   1.108          XEN_UNBLOCK_EVENTS(%rsi)
   1.109  	pushq %rdi
   1.110  	call schedule
   1.111 @@ -379,7 +358,6 @@ int_careful:
   1.112  	/* handle signals and tracing -- both require a full stack frame */
   1.113  int_very_careful:
   1.114  /*	sti */
   1.115 -        XEN_GET_VCPU_INFO(%rsi)
   1.116          XEN_UNBLOCK_EVENTS(%rsi)
   1.117  	SAVE_REST
   1.118  	/* Check for syscall exit trace */	
   1.119 @@ -529,11 +507,11 @@ retint_check:
   1.120  retint_restore_args:
   1.121          movb EVENT_MASK-REST_SKIP(%rsp), %al
   1.122          notb %al			# %al == ~saved_mask
   1.123 -        XEN_LOCK_VCPU_INFO_SMP(%rsi)
   1.124 +        XEN_GET_VCPU_INFO(%rsi)
   1.125          andb evtchn_upcall_mask(%rsi),%al
   1.126  	andb $1,%al			# %al == mask & ~saved_mask
   1.127  	jnz restore_all_enable_events	# != 0 => reenable event delivery      
   1.128 -        XEN_UNLOCK_VCPU_INFO_SMP(%rsi)
   1.129 +        XEN_PUT_VCPU_INFO(%rsi)
   1.130  		
   1.131  	RESTORE_ARGS 0,8,0						
   1.132  	testb $3,8(%rsp)                # check CS
   1.133 @@ -548,13 +526,11 @@ user_mode:
   1.134  retint_careful:
   1.135  	bt    $TIF_NEED_RESCHED,%edx
   1.136  	jnc   retint_signal
   1.137 -	XEN_GET_VCPU_INFO(%rsi)
   1.138  	XEN_UNBLOCK_EVENTS(%rsi)
   1.139  /*	sti */        
   1.140  	pushq %rdi
   1.141  	call  schedule
   1.142  	popq %rdi		
   1.143 -	XEN_GET_VCPU_INFO(%rsi)        
   1.144  	XEN_BLOCK_EVENTS(%rsi)		
   1.145  	GET_THREAD_INFO(%rcx)
   1.146  /*	cli */
   1.147 @@ -563,7 +539,6 @@ retint_careful:
   1.148  retint_signal:
   1.149  	testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx
   1.150  	jz    retint_restore_args
   1.151 -        XEN_GET_VCPU_INFO(%rsi)
   1.152          XEN_UNBLOCK_EVENTS(%rsi)
   1.153  	SAVE_REST
   1.154  	movq $-1,ORIG_RAX(%rsp) 			
   1.155 @@ -571,7 +546,6 @@ retint_signal:
   1.156  	movq %rsp,%rdi		# &pt_regs
   1.157  	call do_notify_resume
   1.158  	RESTORE_REST
   1.159 -        XEN_GET_VCPU_INFO(%rsi)        
   1.160          XEN_BLOCK_EVENTS(%rsi)		
   1.161  	movl $_TIF_NEED_RESCHED,%edi
   1.162  	GET_THREAD_INFO(%rcx)	
   1.163 @@ -590,10 +564,8 @@ retint_kernel:
   1.164  	jc   retint_restore_args
   1.165  	movl $PREEMPT_ACTIVE,threadinfo_preempt_count(%rcx)
   1.166  /*	sti */
   1.167 -	XEN_GET_VCPU_INFO(%rsi)
   1.168  	XEN_UNBLOCK_EVENTS(%rsi)
   1.169  	call schedule
   1.170 -	XEN_GET_VCPU_INFO(%rsi) /* %esi can be different */
   1.171  	XEN_BLOCK_EVENTS(%rsi)
   1.172  /*	cli */
   1.173  	GET_THREAD_INFO(%rcx)
   1.174 @@ -728,17 +700,10 @@ error_call_handler:
   1.175  	movq %rsp,%rdi
   1.176  	movq ORIG_RAX(%rsp),%rsi	# get error code 
   1.177  	movq $-1,ORIG_RAX(%rsp)
   1.178 -        leaq do_hypervisor_callback,%rcx
   1.179 -        cmpq %rax,%rcx
   1.180 -        je 0f                           # don't save event mask for callbacks
   1.181 -        XEN_GET_VCPU_INFO(%r11)
   1.182 -        XEN_SAVE_UPCALL_MASK(%r11,%cl,EVENT_MASK)
   1.183 -0:              
   1.184  	call *%rax
   1.185  error_exit:		
   1.186  	RESTORE_REST
   1.187  /*	cli */
   1.188 -	XEN_GET_VCPU_INFO(%rsi)        
   1.189  	XEN_BLOCK_EVENTS(%rsi)		
   1.190  	GET_THREAD_INFO(%rcx)	
   1.191  	testb $3,CS-ARGOFFSET(%rsp)
   1.192 @@ -807,7 +772,7 @@ restore_all_enable_events:
   1.193  scrit:	/**** START OF CRITICAL REGION ****/
   1.194  	XEN_TEST_PENDING(%rsi)
   1.195  	jnz  14f			# process more events if necessary...
   1.196 -	XEN_UNLOCK_VCPU_INFO_SMP(%rsi)
   1.197 +	XEN_PUT_VCPU_INFO(%rsi)
   1.198          RESTORE_ARGS 0,8,0
   1.199          testb $3,8(%rsp)                # check CS
   1.200          jnz  crit_user_mode
   1.201 @@ -817,7 +782,7 @@ crit_user_mode:
   1.202          SWITCH_TO_USER 0
   1.203          
   1.204  14:	XEN_LOCKED_BLOCK_EVENTS(%rsi)
   1.205 -	XEN_UNLOCK_VCPU_INFO_SMP(%rsi)
   1.206 +	XEN_PUT_VCPU_INFO(%rsi)
   1.207  	SAVE_REST
   1.208          movq %rsp,%rdi                  # set the argument again
   1.209  	jmp  11b