Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/asm: Re-add parts of the manual CFI infrastructure

Commit:

131484c8da97 ("x86/debug: Remove perpetually broken, unmaintainable dwarf annotations")

removed all the manual DWARF annotations outside the vDSO. It also removed
the macros we used for the manual annotations.

Re-add these macros so that we can clean up the vDSO annotations.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/4c70bb98a8b773c8ccfaabf6745e569ff43e7f65.1444091584.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Andy Lutomirski and committed by
Ingo Molnar
7b956f03 0a6d1fa0

+178 -2
+8 -2
arch/x86/Makefile
··· 159 159 sp-$(CONFIG_X86_32) := esp 160 160 sp-$(CONFIG_X86_64) := rsp 161 161 162 + # do binutils support CFI? 163 + cfi := $(call as-instr,.cfi_startproc\n.cfi_rel_offset $(sp-y)$(comma)0\n.cfi_endproc,-DCONFIG_AS_CFI=1) 164 + # is .cfi_signal_frame supported too? 165 + cfi-sigframe := $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1) 166 + cfi-sections := $(call as-instr,.cfi_sections .debug_frame,-DCONFIG_AS_CFI_SECTIONS=1) 167 + 162 168 # does binutils support specific instructions? 163 169 asinstr := $(call as-instr,fxsaveq (%rax),-DCONFIG_AS_FXSAVEQ=1) 164 170 asinstr += $(call as-instr,pshufb %xmm0$(comma)%xmm0,-DCONFIG_AS_SSSE3=1) ··· 172 166 avx_instr := $(call as-instr,vxorps %ymm0$(comma)%ymm1$(comma)%ymm2,-DCONFIG_AS_AVX=1) 173 167 avx2_instr :=$(call as-instr,vpbroadcastb %xmm0$(comma)%ymm1,-DCONFIG_AS_AVX2=1) 174 168 175 - KBUILD_AFLAGS += $(asinstr) $(avx_instr) $(avx2_instr) 176 - KBUILD_CFLAGS += $(asinstr) $(avx_instr) $(avx2_instr) 169 + KBUILD_AFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) 170 + KBUILD_CFLAGS += $(cfi) $(cfi-sigframe) $(cfi-sections) $(asinstr) $(avx_instr) $(avx2_instr) 177 171 178 172 LDFLAGS := -m elf_$(UTS_MACHINE) 179 173
+170
arch/x86/include/asm/dwarf2.h
··· 1 + #ifndef _ASM_X86_DWARF2_H 2 + #define _ASM_X86_DWARF2_H 3 + 4 + #ifndef __ASSEMBLY__ 5 + #warning "asm/dwarf2.h should be only included in pure assembly files" 6 + #endif 7 + 8 + /* 9 + * Macros for dwarf2 CFI unwind table entries. 10 + * See "as.info" for details on these pseudo ops. Unfortunately 11 + * they are only supported in very new binutils, so define them 12 + * away for older version. 13 + */ 14 + 15 + #ifdef CONFIG_AS_CFI 16 + 17 + #define CFI_STARTPROC .cfi_startproc 18 + #define CFI_ENDPROC .cfi_endproc 19 + #define CFI_DEF_CFA .cfi_def_cfa 20 + #define CFI_DEF_CFA_REGISTER .cfi_def_cfa_register 21 + #define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset 22 + #define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset 23 + #define CFI_OFFSET .cfi_offset 24 + #define CFI_REL_OFFSET .cfi_rel_offset 25 + #define CFI_REGISTER .cfi_register 26 + #define CFI_RESTORE .cfi_restore 27 + #define CFI_REMEMBER_STATE .cfi_remember_state 28 + #define CFI_RESTORE_STATE .cfi_restore_state 29 + #define CFI_UNDEFINED .cfi_undefined 30 + #define CFI_ESCAPE .cfi_escape 31 + 32 + #ifdef CONFIG_AS_CFI_SIGNAL_FRAME 33 + #define CFI_SIGNAL_FRAME .cfi_signal_frame 34 + #else 35 + #define CFI_SIGNAL_FRAME 36 + #endif 37 + 38 + #if defined(CONFIG_AS_CFI_SECTIONS) && defined(__ASSEMBLY__) 39 + /* 40 + * Emit CFI data in .debug_frame sections, not .eh_frame sections. 41 + * The latter we currently just discard since we don't do DWARF 42 + * unwinding at runtime. So only the offline DWARF information is 43 + * useful to anyone. Note we should not use this directive if this 44 + * file is used in the vDSO assembly, or if vmlinux.lds.S gets 45 + * changed so it doesn't discard .eh_frame. 46 + */ 47 + .cfi_sections .debug_frame 48 + #endif 49 + 50 + #else 51 + 52 + /* 53 + * Due to the structure of pre-exisiting code, don't use assembler line 54 + * comment character # to ignore the arguments. Instead, use a dummy macro. 55 + */ 56 + .macro cfi_ignore a=0, b=0, c=0, d=0 57 + .endm 58 + 59 + #define CFI_STARTPROC cfi_ignore 60 + #define CFI_ENDPROC cfi_ignore 61 + #define CFI_DEF_CFA cfi_ignore 62 + #define CFI_DEF_CFA_REGISTER cfi_ignore 63 + #define CFI_DEF_CFA_OFFSET cfi_ignore 64 + #define CFI_ADJUST_CFA_OFFSET cfi_ignore 65 + #define CFI_OFFSET cfi_ignore 66 + #define CFI_REL_OFFSET cfi_ignore 67 + #define CFI_REGISTER cfi_ignore 68 + #define CFI_RESTORE cfi_ignore 69 + #define CFI_REMEMBER_STATE cfi_ignore 70 + #define CFI_RESTORE_STATE cfi_ignore 71 + #define CFI_UNDEFINED cfi_ignore 72 + #define CFI_ESCAPE cfi_ignore 73 + #define CFI_SIGNAL_FRAME cfi_ignore 74 + 75 + #endif 76 + 77 + /* 78 + * An attempt to make CFI annotations more or less 79 + * correct and shorter. It is implied that you know 80 + * what you're doing if you use them. 81 + */ 82 + #ifdef __ASSEMBLY__ 83 + #ifdef CONFIG_X86_64 84 + .macro pushq_cfi reg 85 + pushq \reg 86 + CFI_ADJUST_CFA_OFFSET 8 87 + .endm 88 + 89 + .macro pushq_cfi_reg reg 90 + pushq %\reg 91 + CFI_ADJUST_CFA_OFFSET 8 92 + CFI_REL_OFFSET \reg, 0 93 + .endm 94 + 95 + .macro popq_cfi reg 96 + popq \reg 97 + CFI_ADJUST_CFA_OFFSET -8 98 + .endm 99 + 100 + .macro popq_cfi_reg reg 101 + popq %\reg 102 + CFI_ADJUST_CFA_OFFSET -8 103 + CFI_RESTORE \reg 104 + .endm 105 + 106 + .macro pushfq_cfi 107 + pushfq 108 + CFI_ADJUST_CFA_OFFSET 8 109 + .endm 110 + 111 + .macro popfq_cfi 112 + popfq 113 + CFI_ADJUST_CFA_OFFSET -8 114 + .endm 115 + 116 + .macro movq_cfi reg offset=0 117 + movq %\reg, \offset(%rsp) 118 + CFI_REL_OFFSET \reg, \offset 119 + .endm 120 + 121 + .macro movq_cfi_restore offset reg 122 + movq \offset(%rsp), %\reg 123 + CFI_RESTORE \reg 124 + .endm 125 + #else /*!CONFIG_X86_64*/ 126 + .macro pushl_cfi reg 127 + pushl \reg 128 + CFI_ADJUST_CFA_OFFSET 4 129 + .endm 130 + 131 + .macro pushl_cfi_reg reg 132 + pushl %\reg 133 + CFI_ADJUST_CFA_OFFSET 4 134 + CFI_REL_OFFSET \reg, 0 135 + .endm 136 + 137 + .macro popl_cfi reg 138 + popl \reg 139 + CFI_ADJUST_CFA_OFFSET -4 140 + .endm 141 + 142 + .macro popl_cfi_reg reg 143 + popl %\reg 144 + CFI_ADJUST_CFA_OFFSET -4 145 + CFI_RESTORE \reg 146 + .endm 147 + 148 + .macro pushfl_cfi 149 + pushfl 150 + CFI_ADJUST_CFA_OFFSET 4 151 + .endm 152 + 153 + .macro popfl_cfi 154 + popfl 155 + CFI_ADJUST_CFA_OFFSET -4 156 + .endm 157 + 158 + .macro movl_cfi reg offset=0 159 + movl %\reg, \offset(%esp) 160 + CFI_REL_OFFSET \reg, \offset 161 + .endm 162 + 163 + .macro movl_cfi_restore offset reg 164 + movl \offset(%esp), %\reg 165 + CFI_RESTORE \reg 166 + .endm 167 + #endif /*!CONFIG_X86_64*/ 168 + #endif /*__ASSEMBLY__*/ 169 + 170 + #endif /* _ASM_X86_DWARF2_H */