ia64/xen-unstable

changeset 14255:b1f33c3a97fa

linux 2.6.18: assembly annotations

This adds (or moves to the proper place) annotations paralleling those
added in native code in 2.6.18. To make this look less ugly, it
required moving around a few things.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Mon Mar 05 13:49:11 2007 +0000 (2007-03-05)
parents ea40e314d8be
children bd66af1b5df2
files linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Mon Mar 05 13:33:42 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/entry-xen.S	Mon Mar 05 13:49:11 2007 +0000
     1.3 @@ -368,6 +368,7 @@ sysexit_scrit:	/**** START OF SYSEXIT CR
     1.4  	movl ESI(%esp), %esi
     1.5  	sysexit
     1.6  14:	__DISABLE_INTERRUPTS
     1.7 +	TRACE_IRQS_OFF
     1.8  sysexit_ecrit:	/**** END OF SYSEXIT CRITICAL REGION ****/
     1.9  	push %esp
    1.10  	call evtchn_do_upcall
    1.11 @@ -427,11 +428,13 @@ restore_nocheck:
    1.12  restore_nocheck:
    1.13  	movl EFLAGS(%esp), %eax
    1.14  	testl $(VM_MASK|NMI_MASK), %eax
    1.15 +	CFI_REMEMBER_STATE
    1.16  	jnz hypervisor_iret
    1.17  	shr $9, %eax			# EAX[0] == IRET_EFLAGS.IF
    1.18  	GET_VCPU_INFO
    1.19  	andb evtchn_upcall_mask(%esi),%al
    1.20  	andb $1,%al			# EAX[0] == IRET_EFLAGS.IF & event_mask
    1.21 +	CFI_REMEMBER_STATE
    1.22  	jnz restore_all_enable_events	#        != 0 => enable event delivery
    1.23  #endif
    1.24  	TRACE_IRQS_IRET
    1.25 @@ -455,8 +458,8 @@ iret_exc:
    1.26  	.long 1b,iret_exc
    1.27  .previous
    1.28  
    1.29 +	CFI_RESTORE_STATE
    1.30  #ifndef CONFIG_XEN
    1.31 -	CFI_RESTORE_STATE
    1.32  ldt_ss:
    1.33  	larl OLDSS(%esp), %eax
    1.34  	jnz restore_nocheck
    1.35 @@ -485,14 +488,36 @@ 1:	iret
    1.36  	.align 4
    1.37  	.long 1b,iret_exc
    1.38  .previous
    1.39 -	CFI_ENDPROC
    1.40  #else
    1.41 +        ALIGN
    1.42 +restore_all_enable_events:
    1.43 +	TRACE_IRQS_ON
    1.44 +	__ENABLE_INTERRUPTS
    1.45 +scrit:	/**** START OF CRITICAL REGION ****/
    1.46 +	__TEST_PENDING
    1.47 +	jnz  14f			# process more events if necessary...
    1.48 +	RESTORE_REGS
    1.49 +	addl $4, %esp
    1.50 +	CFI_ADJUST_CFA_OFFSET -4
    1.51 +1:	iret
    1.52 +.section __ex_table,"a"
    1.53 +	.align 4
    1.54 +	.long 1b,iret_exc
    1.55 +.previous
    1.56 +14:	__DISABLE_INTERRUPTS
    1.57 +	TRACE_IRQS_OFF
    1.58 +	jmp  11f
    1.59 +ecrit:  /**** END OF CRITICAL REGION ****/
    1.60 +
    1.61 +	CFI_RESTORE_STATE
    1.62  hypervisor_iret:
    1.63  	andl $~NMI_MASK, EFLAGS(%esp)
    1.64  	RESTORE_REGS
    1.65  	addl $4, %esp
    1.66 +	CFI_ADJUST_CFA_OFFSET -4
    1.67  	jmp  hypercall_page + (__HYPERVISOR_iret * 32)
    1.68  #endif
    1.69 +	CFI_ENDPROC
    1.70  
    1.71  	# perform work that needs to be done immediately before resumption
    1.72  	ALIGN
    1.73 @@ -736,7 +761,9 @@ error_code:
    1.74  # critical region we know that the entire frame is present and correct
    1.75  # so we can simply throw away the new one.
    1.76  ENTRY(hypervisor_callback)
    1.77 +	RING0_INT_FRAME
    1.78  	pushl %eax
    1.79 +	CFI_ADJUST_CFA_OFFSET 4
    1.80  	SAVE_ALL
    1.81  	movl EIP(%esp),%eax
    1.82  	cmpl $scrit,%eax
    1.83 @@ -749,26 +776,13 @@ ENTRY(hypervisor_callback)
    1.84  	ja   11f
    1.85  	addl $OLDESP,%esp		# Remove eflags...ebx from stack frame.
    1.86  11:	push %esp
    1.87 +	CFI_ADJUST_CFA_OFFSET 4
    1.88  	call evtchn_do_upcall
    1.89  	add  $4,%esp
    1.90 +	CFI_ADJUST_CFA_OFFSET -4
    1.91  	jmp  ret_from_intr
    1.92 +	CFI_ENDPROC
    1.93  
    1.94 -        ALIGN
    1.95 -restore_all_enable_events:
    1.96 -	__ENABLE_INTERRUPTS
    1.97 -scrit:	/**** START OF CRITICAL REGION ****/
    1.98 -	__TEST_PENDING
    1.99 -	jnz  14f			# process more events if necessary...
   1.100 -	RESTORE_REGS
   1.101 -	addl $4, %esp
   1.102 -1:	iret
   1.103 -.section __ex_table,"a"
   1.104 -	.align 4
   1.105 -	.long 1b,iret_exc
   1.106 -.previous
   1.107 -14:	__DISABLE_INTERRUPTS
   1.108 -	jmp  11b
   1.109 -ecrit:  /**** END OF CRITICAL REGION ****/
   1.110  # [How we do the fixup]. We want to merge the current stack frame with the
   1.111  # just-interrupted frame. How we do this depends on where in the critical
   1.112  # region the interrupted handler was executing, and so how many saved
   1.113 @@ -835,6 +849,7 @@ 4:	mov 16(%esp),%gs
   1.114  	addl $16,%esp		# EAX != 0 => Category 2 (Bad IRET)
   1.115  	jmp iret_exc
   1.116  5:	addl $16,%esp		# EAX == 0 => Category 1 (Bad segment)
   1.117 +	RING0_INT_FRAME
   1.118  	pushl $0
   1.119  	SAVE_ALL
   1.120  	jmp ret_from_exception
   1.121 @@ -860,6 +875,7 @@ 9:	xorl %eax,%eax;		\
   1.122  	.long 4b,9b;		\
   1.123  .previous
   1.124  #endif
   1.125 +	CFI_ENDPROC
   1.126  
   1.127  ENTRY(coprocessor_error)
   1.128  	RING0_INT_FRAME
   1.129 @@ -1187,8 +1203,11 @@ ENDPROC(arch_unwind_init_running)
   1.130  #endif
   1.131  
   1.132  ENTRY(fixup_4gb_segment)
   1.133 +	RING0_EC_FRAME
   1.134  	pushl $do_fixup_4gb_segment
   1.135 +	CFI_ADJUST_CFA_OFFSET 4
   1.136  	jmp error_code
   1.137 +	CFI_ENDPROC
   1.138  
   1.139  .section .rodata,"a"
   1.140  .align 4
     2.1 --- a/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Mon Mar 05 13:33:42 2007 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/i386/kernel/head-xen.S	Mon Mar 05 13:49:11 2007 +0000
     2.3 @@ -9,6 +9,7 @@
     2.4  #include <asm/cache.h>
     2.5  #include <asm/thread_info.h>
     2.6  #include <asm/asm-offsets.h>
     2.7 +#include <asm/dwarf2.h>
     2.8  #include <xen/interface/xen.h>
     2.9  #include <xen/interface/elfnote.h>
    2.10  
    2.11 @@ -70,7 +71,9 @@ L6:
    2.12  #define HYPERCALL_PAGE_OFFSET 0x1000
    2.13  .org HYPERCALL_PAGE_OFFSET
    2.14  ENTRY(hypercall_page)
    2.15 +	CFI_STARTPROC
    2.16  .skip 0x1000
    2.17 +	CFI_ENDPROC
    2.18  
    2.19  /*
    2.20   * Real beginning of normal "text" segment
     3.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Mon Mar 05 13:33:42 2007 +0000
     3.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/entry-xen.S	Mon Mar 05 13:49:11 2007 +0000
     3.3 @@ -116,19 +116,21 @@ NMI_MASK = 0x80000000
     3.4  	CFI_ADJUST_CFA_OFFSET	-(6*8)
     3.5  	.endm
     3.6  
     3.7 -	.macro	CFI_DEFAULT_STACK start=1
     3.8 +	.macro	CFI_DEFAULT_STACK start=1,adj=0
     3.9  	.if \start
    3.10  	CFI_STARTPROC	simple
    3.11 -	CFI_DEF_CFA	rsp,SS+8
    3.12 +	CFI_DEF_CFA	rsp,SS+8-(\adj*ARGOFFSET)
    3.13  	.else
    3.14 -	CFI_DEF_CFA_OFFSET SS+8
    3.15 +	CFI_DEF_CFA_OFFSET SS+8-(\adj*ARGOFFSET)
    3.16  	.endif
    3.17 +	.if \adj == 0
    3.18  	CFI_REL_OFFSET	r15,R15
    3.19  	CFI_REL_OFFSET	r14,R14
    3.20  	CFI_REL_OFFSET	r13,R13
    3.21  	CFI_REL_OFFSET	r12,R12
    3.22  	CFI_REL_OFFSET	rbp,RBP
    3.23  	CFI_REL_OFFSET	rbx,RBX
    3.24 +	.endif
    3.25  	CFI_REL_OFFSET	r11,R11
    3.26  	CFI_REL_OFFSET	r10,R10
    3.27  	CFI_REL_OFFSET	r9,R9
    3.28 @@ -363,8 +365,8 @@ ENTRY(int_ret_from_sys_call)
    3.29  	CFI_REL_OFFSET	r9,R9-ARGOFFSET
    3.30  	CFI_REL_OFFSET	r10,R10-ARGOFFSET
    3.31  	CFI_REL_OFFSET	r11,R11-ARGOFFSET
    3.32 +        XEN_BLOCK_EVENTS(%rsi)
    3.33  	TRACE_IRQS_OFF
    3.34 -        XEN_BLOCK_EVENTS(%rsi)
    3.35  	testb $3,CS-ARGOFFSET(%rsp)
    3.36          jnz 1f
    3.37          /* Need to set the proper %ss (not NULL) for ring 3 iretq */
    3.38 @@ -534,7 +536,7 @@ END(stub_rt_sigreturn)
    3.39   */ 
    3.40  
    3.41  retint_check:
    3.42 -	CFI_DEFAULT_STACK
    3.43 +	CFI_DEFAULT_STACK adj=1
    3.44  	movl threadinfo_flags(%rcx),%edx
    3.45  	andl %edi,%edx
    3.46  	CFI_REMEMBER_STATE
    3.47 @@ -838,6 +840,7 @@ ENTRY(error_entry)
    3.48  	CFI_REL_OFFSET	r15,R15
    3.49  #if 0        
    3.50  	cmpl $__KERNEL_CS,CS(%rsp)
    3.51 +	CFI_REMEMBER_STATE
    3.52  	je  error_kernelspace
    3.53  #endif        
    3.54  error_call_handler:
    3.55 @@ -864,7 +867,7 @@ error_exit:
    3.56  	TRACE_IRQS_IRETQ
    3.57  	jmp   retint_restore_args
    3.58  
    3.59 -error_kernelspace:
    3.60 +#if 0
    3.61           /*
    3.62           * We need to re-write the logic here because we don't do iretq to 
    3.63           * to return to user mode. It's still possible that we get trap/fault
    3.64 @@ -872,7 +875,8 @@ error_kernelspace:
    3.65           * for example).
    3.66           *
    3.67           */           
    3.68 -#if 0
    3.69 +	CFI_RESTORE_STATE
    3.70 +error_kernelspace:
    3.71  	incl %ebx
    3.72         /* There are two places in the kernel that can potentially fault with
    3.73            usergs. Handle them here. The exception handlers after
    3.74 @@ -888,11 +892,13 @@ error_kernelspace:
    3.75  	cmpq $gs_change,RIP(%rsp)
    3.76          je   error_swapgs
    3.77  	jmp  error_sti
    3.78 -#endif        
    3.79 +#endif
    3.80 +	CFI_ENDPROC
    3.81  END(error_entry)
    3.82  	
    3.83  ENTRY(hypervisor_callback)
    3.84  	zeroentry do_hypervisor_callback
    3.85 +END(hypervisor_callback)
    3.86          
    3.87  /*
    3.88   * Copied from arch/xen/i386/kernel/entry.S
    3.89 @@ -909,48 +915,66 @@ ENTRY(hypervisor_callback)
    3.90  # existing activation in its critical region -- if so, we pop the current
    3.91  # activation and restart the handler using the previous one.
    3.92  ENTRY(do_hypervisor_callback)   # do_hypervisor_callback(struct *pt_regs)
    3.93 +	CFI_STARTPROC
    3.94  # Since we don't modify %rdi, evtchn_do_upall(struct *pt_regs) will
    3.95  # see the correct pointer to the pt_regs
    3.96  	movq %rdi, %rsp            # we don't return, adjust the stack frame
    3.97 -11:	movq %gs:pda_irqstackptr,%rax
    3.98 -	incl %gs:pda_irqcount
    3.99 -	cmovzq %rax,%rsp
   3.100 -	pushq %rdi
   3.101 +	CFI_ENDPROC
   3.102 +	CFI_DEFAULT_STACK
   3.103 +11:	incl %gs:pda_irqcount
   3.104 +	movq %rsp,%rbp
   3.105 +	CFI_DEF_CFA_REGISTER rbp
   3.106 +	cmovzq %gs:pda_irqstackptr,%rsp
   3.107 +	pushq %rbp			# backlink for old unwinder
   3.108  	call evtchn_do_upcall
   3.109  	popq %rsp
   3.110 +	CFI_DEF_CFA_REGISTER rsp
   3.111  	decl %gs:pda_irqcount
   3.112  	jmp  error_exit
   3.113 +	CFI_ENDPROC
   3.114 +END(do_hypervisor_callback)
   3.115  
   3.116  #ifdef CONFIG_X86_LOCAL_APIC
   3.117  KPROBE_ENTRY(nmi)
   3.118  	zeroentry do_nmi_callback
   3.119  ENTRY(do_nmi_callback)
   3.120 +	CFI_STARTPROC
   3.121          addq $8, %rsp
   3.122 +	CFI_ENDPROC
   3.123 +	CFI_DEFAULT_STACK
   3.124          call do_nmi
   3.125          orl  $NMI_MASK,EFLAGS(%rsp)
   3.126          RESTORE_REST
   3.127          XEN_BLOCK_EVENTS(%rsi)
   3.128 +	TRACE_IRQS_OFF
   3.129          GET_THREAD_INFO(%rcx)
   3.130          jmp  retint_restore_args
   3.131 +	CFI_ENDPROC
   3.132  	.previous .text
   3.133 +END(nmi)
   3.134  #endif
   3.135  
   3.136          ALIGN
   3.137  restore_all_enable_events:  
   3.138 +	CFI_DEFAULT_STACK adj=1
   3.139 +	TRACE_IRQS_ON
   3.140  	XEN_UNBLOCK_EVENTS(%rsi)        # %rsi is already set up...
   3.141  
   3.142  scrit:	/**** START OF CRITICAL REGION ****/
   3.143  	XEN_TEST_PENDING(%rsi)
   3.144 +	CFI_REMEMBER_STATE
   3.145  	jnz  14f			# process more events if necessary...
   3.146  	XEN_PUT_VCPU_INFO(%rsi)
   3.147          RESTORE_ARGS 0,8,0
   3.148          HYPERVISOR_IRET 0
   3.149          
   3.150 +	CFI_RESTORE_STATE
   3.151  14:	XEN_LOCKED_BLOCK_EVENTS(%rsi)
   3.152  	XEN_PUT_VCPU_INFO(%rsi)
   3.153  	SAVE_REST
   3.154          movq %rsp,%rdi                  # set the argument again
   3.155  	jmp  11b
   3.156 +	CFI_ENDPROC
   3.157  ecrit:  /**** END OF CRITICAL REGION ****/
   3.158  # At this point, unlike on x86-32, we don't do the fixup to simplify the 
   3.159  # code and the stack frame is more complex on x86-64.
   3.160 @@ -970,8 +994,12 @@ ecrit:  /**** END OF CRITICAL REGION ***
   3.161  # We distinguish between categories by comparing each saved segment register
   3.162  # with its current contents: any discrepancy means we in category 1.
   3.163  ENTRY(failsafe_callback)
   3.164 +	_frame (RIP-0x30)
   3.165 +	CFI_REL_OFFSET rcx, 0
   3.166 +	CFI_REL_OFFSET r11, 8
   3.167  	movw %ds,%cx
   3.168  	cmpw %cx,0x10(%rsp)
   3.169 +	CFI_REMEMBER_STATE
   3.170  	jne 1f
   3.171  	movw %es,%cx
   3.172  	cmpw %cx,0x18(%rsp)
   3.173 @@ -984,17 +1012,26 @@ ENTRY(failsafe_callback)
   3.174  	jne 1f
   3.175  	/* All segments match their saved values => Category 2 (Bad IRET). */
   3.176  	movq (%rsp),%rcx
   3.177 +	CFI_RESTORE rcx
   3.178  	movq 8(%rsp),%r11
   3.179 +	CFI_RESTORE r11
   3.180  	addq $0x30,%rsp
   3.181 +	CFI_ADJUST_CFA_OFFSET -0x30
   3.182  	movq $11,%rdi	/* SIGSEGV */
   3.183  	jmp do_exit			
   3.184 +	CFI_RESTORE_STATE
   3.185  1:	/* Segment mismatch => Category 1 (Bad segment). Retry the IRET. */
   3.186  	movq (%rsp),%rcx
   3.187 +	CFI_RESTORE rcx
   3.188  	movq 8(%rsp),%r11
   3.189 +	CFI_RESTORE r11
   3.190  	addq $0x30,%rsp
   3.191 +	CFI_ADJUST_CFA_OFFSET -0x30
   3.192  	pushq $0
   3.193 +	CFI_ADJUST_CFA_OFFSET 8
   3.194  	SAVE_ALL
   3.195  	jmp error_exit
   3.196 +	CFI_ENDPROC
   3.197  #if 0	      
   3.198          .section __ex_table,"a"
   3.199          .align 8
   3.200 @@ -1117,12 +1154,12 @@ END(device_not_available)
   3.201  
   3.202  	/* runs on exception stack */
   3.203  KPROBE_ENTRY(debug)
   3.204 - 	INTR_FRAME
   3.205 -/*	pushq $0
   3.206 +/* 	INTR_FRAME
   3.207 +	pushq $0
   3.208  	CFI_ADJUST_CFA_OFFSET 8	*/
   3.209  	zeroentry do_debug
   3.210 -/*	paranoid_exit */
   3.211 -	CFI_ENDPROC
   3.212 +/*	paranoidexit
   3.213 +	CFI_ENDPROC */
   3.214  END(debug)
   3.215  	.previous .text
   3.216  
   3.217 @@ -1144,12 +1181,12 @@ END(nmi)
   3.218  #endif        
   3.219  
   3.220  KPROBE_ENTRY(int3)
   3.221 - 	INTR_FRAME
   3.222 -/* 	pushq $0
   3.223 +/* 	INTR_FRAME
   3.224 + 	pushq $0
   3.225   	CFI_ADJUST_CFA_OFFSET 8 */
   3.226   	zeroentry do_int3
   3.227 -/* 	jmp paranoid_exit1 */
   3.228 - 	CFI_ENDPROC
   3.229 +/* 	jmp paranoid_exit1
   3.230 + 	CFI_ENDPROC */
   3.231  END(int3)
   3.232  	.previous .text
   3.233  
   3.234 @@ -1193,9 +1230,11 @@ END(segment_not_present)
   3.235  
   3.236  	/* runs on exception stack */
   3.237  ENTRY(stack_segment)
   3.238 -	XCPT_FRAME
   3.239 +/*	XCPT_FRAME
   3.240 +	paranoidentry do_stack_segment */
   3.241  	errorentry do_stack_segment
   3.242 -	CFI_ENDPROC
   3.243 +/*	jmp paranoid_exit1
   3.244 +	CFI_ENDPROC */
   3.245  END(stack_segment)
   3.246  
   3.247  KPROBE_ENTRY(general_protection)
     4.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Mon Mar 05 13:33:42 2007 +0000
     4.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Mon Mar 05 13:49:11 2007 +0000
     4.3 @@ -22,7 +22,7 @@
     4.4  #include <asm/page.h>
     4.5  #include <asm/msr.h>
     4.6  #include <asm/cache.h>
     4.7 -
     4.8 +#include <asm/dwarf2.h>
     4.9  #include <xen/interface/elfnote.h>
    4.10  
    4.11  	.section .bootstrap.text, "ax", @progbits
    4.12 @@ -40,6 +40,7 @@ ENTRY(_start)
    4.13  	/* rsi is pointer to startup info structure.
    4.14  	   pass it to C */
    4.15  	movq %rsi,%rdi
    4.16 +	pushq $0		# fake return address
    4.17  	jmp x86_64_start_kernel
    4.18  
    4.19  ENTRY(stext)
    4.20 @@ -80,7 +81,25 @@ NEXT_PAGE(level2_kernel_pgt)
    4.21  	.fill	512,8,0
    4.22  
    4.23  NEXT_PAGE(hypercall_page)
    4.24 -	.fill	512,8,0
    4.25 +	CFI_STARTPROC
    4.26 +	.rept 0x1000 / 0x20
    4.27 +	.skip 1 /* push %rcx */
    4.28 +	CFI_ADJUST_CFA_OFFSET	8
    4.29 +	CFI_REL_OFFSET	rcx,0
    4.30 +	.skip 2 /* push %r11 */
    4.31 +	CFI_ADJUST_CFA_OFFSET	8
    4.32 +	CFI_REL_OFFSET	rcx,0
    4.33 +	.skip 5 /* mov $#,%eax */
    4.34 +	.skip 2 /* syscall */
    4.35 +	.skip 2 /* pop %r11 */
    4.36 +	CFI_ADJUST_CFA_OFFSET -8
    4.37 +	CFI_RESTORE r11
    4.38 +	.skip 1 /* pop %rcx */
    4.39 +	CFI_ADJUST_CFA_OFFSET -8
    4.40 +	CFI_RESTORE rcx
    4.41 +	.align 0x20,0 /* ret */
    4.42 +	.endr
    4.43 +	CFI_ENDPROC
    4.44  
    4.45  #undef NEXT_PAGE
    4.46