Skip to contentSkip to conversation

reliable stack trace support (i386 entry.S annotations)

PATCH Applied Jan Beulich 3 participants 9 messages May 22, 2006 – May 26, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 6/6 reliable stack trace support (i386 entry.S annotations)

To increase the usefulness of reliable stack unwinding, this adds CFI unwind annotations to many low-level i386 routines.

arch/i386/kernel/entry.S +169 -11
Index: unwind-2.6.17-rc4/arch/i386/kernel/entry.S
===================================================================
@@ -48,6 +48,7 @@
 #include <asm/smp.h>
 #include <asm/page.h>
 #include <asm/desc.h>
+#include <asm/dwarf2.h>
 #include "irq_vectors.h"
 
 #define nr_syscalls ((syscall_table_size)/4)
@@ -85,31 +86,67 @@ VM_MASK		= 0x00020000
 #define SAVE_ALL \
 	cld; \
 	pushl %es; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	/*CFI_REL_OFFSET es, 0;*/\
 	pushl %ds; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	/*CFI_REL_OFFSET ds, 0;*/\
 	pushl %eax; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET eax, 0;\
 	pushl %ebp; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET ebp, 0;\
 	pushl %edi; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET edi, 0;\
 	pushl %esi; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET esi, 0;\
 	pushl %edx; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET edx, 0;\
 	pushl %ecx; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET ecx, 0;\
 	pushl %ebx; \
+	CFI_ADJUST_CFA_OFFSET 4;\
+	CFI_REL_OFFSET ebx, 0;\
 	movl $(__USER_DS), %edx; \
 	movl %edx, %ds; \
 	movl %edx, %es;
 
 #define RESTORE_INT_REGS \
 	popl %ebx;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE ebx;\
 	popl %ecx;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE ecx;\
 	popl %edx;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE edx;\
 	popl %esi;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE esi;\
 	popl %edi;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE edi;\
 	popl %ebp;	\
-	popl %eax
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE ebp;\
+	popl %eax;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	CFI_RESTORE eax
 
 #define RESTORE_REGS	\
 	RESTORE_INT_REGS; \
 1:	popl %ds;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	/*CFI_RESTORE ds;*/\
 2:	popl %es;	\
+	CFI_ADJUST_CFA_OFFSET -4;\
+	/*CFI_RESTORE es;*/\
 .section .fixup,"ax";	\
 3:	movl $0,(%esp);	\
 	jmp 1b;		\
@@ -122,13 +159,43 @@ VM_MASK		= 0x00020000
 	.long 2b,4b;	\
 .previous
 
+#define RING0_INT_FRAME \
+	CFI_STARTPROC simple;\
+	CFI_DEF_CFA esp, 3*4;\
+	/*CFI_OFFSET cs, -2*4;*/\
+	CFI_OFFSET eip, -3*4
+
+#define RING0_EC_FRAME \
+	CFI_STARTPROC simple;\
+	CFI_DEF_CFA esp, 4*4;\
+	/*CFI_OFFSET cs, -2*4;*/\
+	CFI_OFFSET eip, -3*4
+
+#define RING0_PTREGS_FRAME \
+	CFI_STARTPROC simple;\
+	CFI_DEF_CFA esp, OLDESP-EBX;\
+	/*CFI_OFFSET cs, CS-OLDESP;*/\
+	CFI_OFFSET eip, EIP-OLDESP;\
+	/*CFI_OFFSET es, ES-OLDESP;*/\
+	/*CFI_OFFSET ds, DS-OLDESP;*/\
+	CFI_OFFSET eax, EAX-OLDESP;\
+	CFI_OFFSET ebp, EBP-OLDESP;\
+	CFI_OFFSET edi, EDI-OLDESP;\
+	CFI_OFFSET esi, ESI-OLDESP;\
+	CFI_OFFSET edx, EDX-OLDESP;\
+	CFI_OFFSET ecx, ECX-OLDESP;\
+	CFI_OFFSET ebx, EBX-OLDESP
 
 ENTRY(ret_from_fork)
+	CFI_STARTPROC
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET -4
 	call schedule_tail
 	GET_THREAD_INFO(%ebp)
 	popl %eax
+	CFI_ADJUST_CFA_OFFSET -4
 	jmp syscall_exit
+	CFI_ENDPROC
 
 /*
  * Return to user mode is not as complex as all this looks,
@@ -139,6 +206,7 @@ ENTRY(ret_from_fork)
 
 	# userspace resumption stub bypassing syscall exit tracing
 	ALIGN
+	RING0_PTREGS_FRAME
 ret_from_exception:
 	preempt_stop
 ret_from_intr:
@@ -171,20 +239,33 @@ need_resched:
 	call preempt_schedule_irq
 	jmp need_resched
 #endif
+	CFI_ENDPROC
 
 /* SYSENTER_RETURN points to after the "sysenter" instruction in
    the vsyscall page.  See vsyscall-sysentry.S, which defines the symbol.  */
 
 	# sysenter call handler stub
 ENTRY(sysenter_entry)
+	CFI_STARTPROC simple
+	CFI_DEF_CFA esp, 0
+	CFI_REGISTER esp, ebp
 	movl TSS_sysenter_esp0(%esp),%esp
 sysenter_past_esp:
 	sti
 	pushl $(__USER_DS)
+	CFI_ADJUST_CFA_OFFSET 4
+	/*CFI_REL_OFFSET ss, 0*/
 	pushl %ebp
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET esp, 0
 	pushfl
+	CFI_ADJUST_CFA_OFFSET 4
 	pushl $(__USER_CS)
+	CFI_ADJUST_CFA_OFFSET 4
+	/*CFI_REL_OFFSET cs, 0*/
 	pushl $SYSENTER_RETURN
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET eip, 0
 
 /*
  * Load the potential sixth argument from user stack.
@@ -199,6 +280,7 @@ sysenter_past_esp:
 .previous
 
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	GET_THREAD_INFO(%ebp)
 
@@ -219,11 +301,14 @@ sysenter_past_esp:
 	xorl %ebp,%ebp
 	sti
 	sysexit
+	CFI_ENDPROC
 
 
 	# system call handler stub
 ENTRY(system_call)
+	RING0_INT_FRAME			# can't unwind into user space anyway
 	pushl %eax			# save orig_eax
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	GET_THREAD_INFO(%ebp)
 	testl $TF_MASK,EFLAGS(%esp)
@@ -256,10 +341,12 @@ restore_all:
 	movb CS(%esp), %al
 	andl $(VM_MASK | (4 << 8) | 3), %eax
 	cmpl $((4 << 8) | 3), %eax
+	CFI_REMEMBER_STATE
 	je ldt_ss			# returning to user-space with LDT SS
 restore_nocheck:
 	RESTORE_REGS
 	addl $4, %esp
+	CFI_ADJUST_CFA_OFFSET -4
 1:	iret
 .section .fixup,"ax"
 iret_exc:
@@ -273,6 +360,7 @@ iret_exc:
 	.long 1b,iret_exc
 .previous
 
+	CFI_RESTORE_STATE
 ldt_ss:
 	larl OLDSS(%esp), %eax
 	jnz restore_nocheck
@@ -285,11 +373,13 @@ ldt_ss:
 	 * CPUs, which we can try to work around to make
 	 * dosemu and wine happy. */
 	subl $8, %esp		# reserve space for switch16 pointer
+	CFI_ADJUST_CFA_OFFSET 8
 	cli
 	movl %esp, %eax
 	/* Set up the 16bit stack frame with switch32 pointer on top,
 	 * and a switch16 pointer on top of the current frame. */
 	call setup_x86_bogus_stack
+	CFI_ADJUST_CFA_OFFSET -8	# frame has moved
 	RESTORE_REGS
 	lss 20+4(%esp), %esp	# switch to 16bit stack
 1:	iret
@@ -297,9 +387,11 @@ ldt_ss:
 	.align 4
 	.long 1b,iret_exc
 .previous
+	CFI_ENDPROC
 
 	# perform work that needs to be done immediately before resumption
 	ALIGN
+	RING0_PTREGS_FRAME		# can't unwind into user space anyway
 work_pending:
 	testb $_TIF_NEED_RESCHED, %cl
 	jz work_notifysig
@@ -329,8 +421,10 @@ work_notifysig:				# deal with pending s
 work_notifysig_v86:
 #ifdef CONFIG_VM86
 	pushl %ecx			# save ti_flags for do_notify_resume
+	CFI_ADJUST_CFA_OFFSET 4
 	call save_v86_state		# %eax contains pt_regs pointer
 	popl %ecx
+	CFI_ADJUST_CFA_OFFSET -4
 	movl %eax, %esp
 	xorl %edx, %edx
 	call do_notify_resume
@@ -363,19 +457,21 @@ syscall_exit_work:
 	movl $1, %edx
 	call do_syscall_trace
 	jmp resume_userspace
+	CFI_ENDPROC
 
-	ALIGN
+	RING0_INT_FRAME			# can't unwind into user space anyway
 syscall_fault:
 	pushl %eax			# save orig_eax
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	GET_THREAD_INFO(%ebp)
 	movl $-EFAULT,EAX(%esp)
 	jmp resume_userspace
 
-	ALIGN
 syscall_badsys:
 	movl $-ENOSYS,EAX(%esp)
 	jmp resume_userspace
+	CFI_ENDPROC
 
 #define FIXUP_ESPFIX_STACK \
 	movl %esp, %eax; \
@@ -387,16 +483,21 @@ syscall_badsys:
 	movl %eax, %esp;
 #define UNWIND_ESPFIX_STACK \
 	pushl %eax; \
+	CFI_ADJUST_CFA_OFFSET 4; \
 	movl %ss, %eax; \
 	/* see if on 16bit stack */ \
 	cmpw $__ESPFIX_SS, %ax; \
-	jne 28f; \
-	movl $__KERNEL_DS, %edx; \
-	movl %edx, %ds; \
-	movl %edx, %es; \
+	je 28f; \
+27:	popl %eax; \
+	CFI_ADJUST_CFA_OFFSET -4; \
+.section .fixup,"ax"; \
+28:	movl $__KERNEL_DS, %eax; \
+	movl %eax, %ds; \
+	movl %eax, %es; \
 	/* switch to 32bit stack */ \
-	FIXUP_ESPFIX_STACK \
-28:	popl %eax;
+	FIXUP_ESPFIX_STACK; \
+	jmp 27b; \
+.previous
 
 /*
  * Build the entry stubs and pointer table with
@@ -408,9 +509,14 @@ ENTRY(interrupt)
 
 vector=0
 ENTRY(irq_entries_start)
+	RING0_INT_FRAME
 .rept NR_IRQS
 	ALIGN
+ .if vector
+	CFI_ADJUST_CFA_OFFSET -4
+ .endif
 1:	pushl $vector-256
+	CFI_ADJUST_CFA_OFFSET 4
 	jmp common_interrupt
 .data
 	.long 1b
@@ -424,60 +530,99 @@ common_interrupt:
 	movl %esp,%eax
 	call do_IRQ
 	jmp ret_from_intr
+	CFI_ENDPROC
 
 #define BUILD_INTERRUPT(name, nr)	\
 ENTRY(name)				\
+	RING0_INT_FRAME;		\
 	pushl $nr-256;			\
-	SAVE_ALL			\
+	CFI_ADJUST_CFA_OFFSET 4;	\
+	SAVE_ALL;			\
 	movl %esp,%eax;			\
 	call smp_/**/name;		\
-	jmp ret_from_intr;
+	jmp ret_from_intr;	\
+	CFI_ENDPROC
 
 /* The include is where all of the SMP etc. interrupts come from */
 #include "entry_arch.h"
 
 ENTRY(divide_error)
+	RING0_INT_FRAME
 	pushl $0			# no error code
+	CFI_ADJUST_CFA_OFFSET 4
 	pushl $do_divide_error
+	CFI_ADJUST_CFA_OFFSET 4
 	ALIGN
 error_code:
 	pushl %ds
+	CFI_ADJUST_CFA_OFFSET 4
+	/*CFI_REL_OFFSET ds, 0*/
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET eax, 0
 	xorl %eax, %eax
 	pushl %ebp
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET ebp, 0
 	pushl %edi
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET edi, 0
 	pushl %esi
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET esi, 0
 	pushl %edx
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET edx, 0
 	decl %eax			# eax = -1
 	pushl %ecx
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET ecx, 0
 	pushl %ebx
+	CFI_ADJUST_CFA_OFFSET 4
+	CFI_REL_OFFSET ebx, 0
 	cld
 	pushl %es
+	CFI_ADJUST_CFA_OFFSET 4
+	/*CFI_REL_OFFSET es, 0*/
 	UNWIND_ESPFIX_STACK
 	popl %ecx
+	CFI_ADJUST_CFA_OFFSET -4
+	/*CFI_REGISTER es, ecx*/
 	movl ES(%esp), %edi		# get the function address
 	movl ORIG_EAX(%esp), %edx	# get the error code
 	movl %eax, ORIG_EAX(%esp)
 	movl %ecx, ES(%esp)
+	/*CFI_REL_OFFSET es, ES*/
 	movl $(__USER_DS), %ecx
 	movl %ecx, %ds
 	movl %ecx, %es
 	movl %esp,%eax			# pt_regs pointer
 	call *%edi
 	jmp ret_from_exception
+	CFI_ENDPROC
 
 ENTRY(coprocessor_error)
+	RING0_INT_FRAME
 	pushl $0
+	CFI_ADJUST_CFA_OFFSET 4
 	pushl $do_coprocessor_error
+	CFI_ADJUST_CFA_OFFSET 4
 	jmp error_code
+	CFI_ENDPROC
 
 ENTRY(simd_coprocessor_error)
+	RING0_INT_FRAME
 	pushl $0
+	CFI_ADJUST_CFA_OFFSET 4
 	pushl $do_simd_coprocessor_error
+	CFI_ADJUST_CFA_OFFSET 4
 	jmp error_code
+	CFI_ENDPROC
 
 ENTRY(device_not_available)
+	RING0_INT_FRAME
 	pushl $-1			# mark this as an int
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	movl %cr0, %eax
 	testl $0x4, %eax		# EM (math emulation bit)
@@ -487,9 +632,12 @@ ENTRY(device_not_available)
 	jmp ret_from_exception
 device_not_available_emulate:
 	pushl $0			# temporary storage for ORIG_EIP
+	CFI_ADJUST_CFA_OFFSET 4
 	call math_emulate
 	addl $4, %esp
+	CFI_ADJUST_CFA_OFFSET -4
 	jmp ret_from_exception
+	CFI_ENDPROC
 
 /*
  * Debug traps and NMI can happen at the one SYSENTER instruction
@@ -514,16 +662,19 @@ label:						\
 	pushl $sysenter_past_esp
 
 KPROBE_ENTRY(debug)
+	RING0_INT_FRAME
 	cmpl $sysenter_entry,(%esp)
 	jne debug_stack_correct
 	FIX_STACK(12, debug_stack_correct, debug_esp_fix_insn)
 debug_stack_correct:
 	pushl $-1			# mark this as an int
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	xorl %edx,%edx			# error code 0
 	movl %esp,%eax			# pt_regs pointer
 	call do_debug
 	jmp ret_from_exception
+	CFI_ENDPROC
 	.previous .text
 /*
  * NMI is doubly nasty. It can happen _while_ we're handling
@@ -534,14 +685,18 @@ debug_stack_correct:
  * fault happened on the sysenter path.
  */
 ENTRY(nmi)
+	RING0_INT_FRAME
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
 	movl %ss, %eax
 	cmpw $__ESPFIX_SS, %ax
 	popl %eax
+	CFI_ADJUST_CFA_OFFSET -4
 	je nmi_16bit_stack
 	cmpl $sysenter_entry,(%esp)
 	je nmi_stack_fixup
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
 	movl %esp,%eax
 	/* Do not access memory above the end of our stack page,
 	 * it might not exist.
@@ -549,16 +704,19 @@ ENTRY(nmi)
 	andl $(THREAD_SIZE-1),%eax
 	cmpl $(THREAD_SIZE-20),%eax
 	popl %eax
+	CFI_ADJUST_CFA_OFFSET -4
 	jae nmi_stack_correct
 	cmpl $sysenter_entry,12(%esp)
 	je nmi_debug_stack_check
 nmi_stack_correct:
 	pushl %eax
+	CFI_ADJUST_CFA_OFFSET 4
 	SAVE_ALL
 	xorl %edx,%edx		# zero error code
 	movl %esp,%eax		# pt_regs pointer
 	call do_nmi
 	jmp restore_all
+	CFI_ENDPROC
 
 nmi_stack_fixup:
 	FIX_STACK(12,nmi_stack_correct, 1)
include/asm-i386/dwarf2.h new file +54 -0

54 lines not on this page · raw message

#1 lore raw
Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

bix:/usr/src/25> as --version
GNU assembler 2.14.90.0.6 20030820

#2 lore raw
Quoted 19 lines · Andrew Morton
Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

Quoted 5 lines

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

btw, this cfi annotation code:

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17-rc4/2.6.17-rc4-mm3/broken-out/kgdb-cfi_annotations.patch

compiles happily with that toolchain.

#3 lore raw

Sure - it doesn't use the assembler's .cfi_* directives, but encodes things manually. I'll still have to check why you're getting these errors, as you should see entirely different ones if the assembler didn't support the directives at all. Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

Andrew Morton <[email protected]> 25.05.06 07:41 >>>

Quoted 19 lines · Andrew Morton
Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

Quoted 5 lines

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

btw, this cfi annotation code:

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.17-rc4/2.6.17-rc4-mm3/broken-out/kgdb-cfi_annotations.patch

compiles happily with that toolchain.

#4 lore raw
In reply to Andrew Morton
Quoted 18 lines · Andrew Morton
Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

Quoted 4 lines

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

It works for me with
GNU assembler 2.16.91.0.2 20050720 (SuSE Linux)
(from SUSE 1.1)

You probably need newer binutils.

If it's a common problem we might need to somehow hack a binutils version check into Kconfig or the Makefiles.

-andi

#5 lore raw
Quoted 2 lines · Andi Kleen

You probably need newer binutils.

Don't think so.

With this:

arch/i386/kernel/entry.S renamed from arch/i386/kernel/entry.S~a +1 -0
diff -puN arch/i386/kernel/entry.S~a arch/i386/kernel/entry.S
@@ -733,6 +733,7 @@ nmi_debug_stack_check:
 
 nmi_16bit_stack:
 	/* create the pointer to lss back */
+	CFI_STARTPROC simple
 	pushl %ss
 	pushl %esp
 	movzwl %sp, %esp

That great stream of assembler errors comes down to:

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:858: Error: open CFI at the end of file; missing .cfi_endproc directive make[1]: *** [arch/i386/kernel/entry.o] Error 1

So there seems to be a missing startproc in there.

With this:

arch/i386/kernel/entry.S renamed from arch/i386/kernel/entry.S~a +3 -0
@@ -733,6 +733,7 @@ nmi_debug_stack_check:
 
 nmi_16bit_stack:
 	/* create the pointer to lss back */
+	CFI_STARTPROC simple
 	pushl %ss
 	pushl %esp
 	movzwl %sp, %esp
@@ -850,6 +851,8 @@ ENTRY(arch_unwind_init_running)
 ENDPROC(arch_unwind_init_running)
 #endif
 
+	CFI_ENDPROC
+
 .section .rodata,"a"
 #include "syscall_table.S"
 

I get

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:860: Error: invalid sections for operation on L0' and L0'

Which is a bit mysterious.

Still, I expect that with a bit of fiddling this patch can be made to work with older binutils. I also suspect there's actually something wrong with it.

#6 lore raw
Quoted 6 lines · Andrew Morton
Quoted 2 lines · Andi Kleen

You probably need newer binutils.

Don't think so.

<fiddles a bit more>

This makes it build.

arch/i386/kernel/entry.S renamed from arch/i386/kernel/entry.S~a +4 -0
diff -puN arch/i386/kernel/entry.S~a arch/i386/kernel/entry.S
@@ -733,6 +733,7 @@ nmi_debug_stack_check:
 
 nmi_16bit_stack:
 	/* create the pointer to lss back */
+	CFI_STARTPROC simple
 	pushl %ss
 	pushl %esp
 	movzwl %sp, %esp
@@ -747,6 +748,7 @@ nmi_16bit_stack:
 	xorl %edx,%edx			# zero error code
 	call do_nmi
 	RESTORE_REGS
+	CFI_ENDPROC
 	lss 12+4(%esp), %esp		# back to 16bit stack
 1:	iret
 .section __ex_table,"a"
@@ -756,11 +758,13 @@ nmi_16bit_stack:
 
 KPROBE_ENTRY(int3)
 	pushl $-1			# mark this as an int
+	CFI_STARTPROC simple
 	SAVE_ALL
 	xorl %edx,%edx		# zero error code
 	movl %esp,%eax		# pt_regs pointer
 	call do_int3
 	jmp ret_from_exception
+	CFI_ENDPROC
 	.previous .text
 
 ENTRY(overflow)

_

#7 lore raw
In reply to Andrew Morton
Quoted 19 lines
Quoted 1 line
Quoted 1 line

Andrew Morton <[email protected]> 25.05.06 07:23 >>>

Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

Quoted 8 lines

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

bix:/usr/src/25> as --version
GNU assembler 2.14.90.0.6 20030820

Still doesn't make sense to me, assuming the merge didn't corrupt anything. The oldest assembler I'm using is 2.15.90.0.1.1, but as said before your assembler clearly also supports .cfi_*. Any chance I could see the offending entry.S?

Jan

#8 lore raw
Quoted 26 lines · Jan Beulich
Quoted 26 lines
Quoted 2 lines
Quoted 2 lines

Andrew Morton <[email protected]> 25.05.06 07:23 >>>

Quoted 7 lines · Jan Beulich

#define SAVE_ALL \
cld; \
pushl %es; \
+ CFI_ADJUST_CFA_OFFSET 4;\
+ /*CFI_REL_OFFSET es, 0;*/\
pushl %ds; \

arch/i386/kernel/entry.S: Assembler messages:
arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is 4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc arch/i386/kernel/entry.S:757: Warning: rest of line ignored; first ignored character is `4' arch/i386/kernel/entry.S:757: Error: CFI instruction used without previous .cfi_startproc

etcetera. And

arch/i386/kernel/entry.S:757: Error: no such instruction: eax,0' arch/i386/kernel/entry.S:757: Error: no such instruction: ebp,0'

Quoted 7 lines
Quoted 2 lines

bix:/usr/src/25> as --version
GNU assembler 2.14.90.0.6 20030820

Still doesn't make sense to me, assuming the merge didn't corrupt anything. The oldest assembler I'm using is 2.15.90.0.1.1, but as said before your assembler clearly also supports .cfi_*. Any chance I could see the offending entry.S?

http://www.zip.com.au/~akpm/linux/patches/stuff/entry.S