Debian Codegraph @

vmtest/patches/s390-kernel-emit-CFI-data-in-.debug_frame-and-discar.patch

raw
1 From bc3703f21cec8a2ac6a64f6fb3686fbcb1ba1513 Mon Sep 17 00:00:00 2001
2 Message-ID: <bc3703f21cec8a2ac6a64f6fb3686fbcb1ba1513.1709927555.git.osandov@osandov.com>
3 From: Hendrik Brueckner <[email protected]>
4 Date: Mon, 20 Nov 2017 11:41:07 +0100
5 Subject: [PATCH] s390/kernel: emit CFI data in .debug_frame and discard
6 .eh_frame sections
7
8 Using perf probe and libdw on kernel modules failed to find CFI
9 data for symbols. The CFI data is stored in the .eh_frame section.
10 The elfutils libdw is not able to extract the CFI data correctly,
11 because the .eh_frame section requires "non-simple" relocations
12 for kernel modules.
13
14 The suggestion is to avoid these "non-simple" relocations by emitting
15 the CFI data in the .debug_frame section. Let gcc emit respective
16 directives by specifying the -fno-asynchronous-unwind-tables option.
17
18 Using the .debug_frame section for CFI data, the .eh_frame section
19 becomes unused and, thus, discard it for kernel and modules builds
20
21 The vDSO requires the .eh_frame section and, hence, emit the CFI data
22 in both, the .eh_frame and .debug_frame sections.
23
24 See also discussion on elfutils/libdw bugzilla:
25 https://sourceware.org/bugzilla/show_bug.cgi?id=22452
26
27 Suggested-by: Mark Wielaard <[email protected]>
28 Signed-off-by: Hendrik Brueckner <[email protected]>
29 Reviewed-by: Heiko Carstens <[email protected]>
30 Signed-off-by: Martin Schwidefsky <[email protected]>
31 ---
32 arch/s390/Makefile | 1 +
33 arch/s390/include/asm/dwarf.h | 25 +++++++++++++++++++++++++
34 arch/s390/kernel/vdso32/Makefile | 3 +++
35 arch/s390/kernel/vdso32/clock_getres.S | 1 +
36 arch/s390/kernel/vdso32/clock_gettime.S | 1 +
37 arch/s390/kernel/vdso32/getcpu.S | 1 +
38 arch/s390/kernel/vdso32/gettimeofday.S | 1 +
39 arch/s390/kernel/vdso64/Makefile | 3 +++
40 arch/s390/kernel/vdso64/clock_getres.S | 1 +
41 arch/s390/kernel/vdso64/clock_gettime.S | 1 +
42 arch/s390/kernel/vdso64/getcpu.S | 1 +
43 arch/s390/kernel/vdso64/gettimeofday.S | 1 +
44 arch/s390/kernel/vmlinux.lds.S | 3 +++
45 13 files changed, 43 insertions(+)
46 create mode 100644 arch/s390/include/asm/dwarf.h
47
48 diff --git a/arch/s390/Makefile b/arch/s390/Makefile
49 index de54cfc6109d..494bb9ad5edf 100644
50 --- a/arch/s390/Makefile
51 +++ b/arch/s390/Makefile
52 @@ -90,6 +90,7 @@ endif
53
54 KBUILD_CFLAGS += -mbackchain -msoft-float $(cflags-y)
55 KBUILD_CFLAGS += -pipe -fno-strength-reduce -Wno-sign-compare
56 +KBUILD_CFLAGS += -fno-asynchronous-unwind-tables
57 KBUILD_AFLAGS += $(aflags-y)
58
59 OBJCOPYFLAGS := -O binary
60 diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h
61 new file mode 100644
62 index 000000000000..dffdb81e534f
63 --- /dev/null
64 +++ b/arch/s390/include/asm/dwarf.h
65 @@ -0,0 +1,25 @@
66 +/* SPDX-License-Identifier: GPL-2.0 */
67 +#ifndef _ASM_S390_DWARF_H
68 +#define _ASM_S390_DWARF_H
69 +
70 +#ifdef __ASSEMBLY__
71 +
72 +#ifndef BUILD_VDSO
73 + /*
74 + * Emit CFI data in .debug_frame sections and not in .eh_frame
75 + * sections. The .eh_frame CFI is used for runtime unwind
76 + * information that is not being used. Hence, vmlinux.lds.S
77 + * can discard the .eh_frame sections.
78 + */
79 + .cfi_sections .debug_frame
80 +#else
81 + /*
82 + * For vDSO, emit CFI data in both, .eh_frame and .debug_frame
83 + * sections.
84 + */
85 + .cfi_sections .eh_frame, .debug_frame
86 +#endif
87 +
88 +#endif /* __ASSEMBLY__ */
89 +
90 +#endif /* _ASM_S390_DWARF_H */
91 diff --git a/arch/s390/kernel/vdso32/Makefile b/arch/s390/kernel/vdso32/Makefile
92 index 308564b9bf68..c5c856f320bc 100644
93 --- a/arch/s390/kernel/vdso32/Makefile
94 +++ b/arch/s390/kernel/vdso32/Makefile
95 @@ -10,6 +10,9 @@ obj-vdso32 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
96 targets := $(obj-vdso32) vdso32.so vdso32.so.dbg
97 obj-vdso32 := $(addprefix $(obj)/, $(obj-vdso32))
98
99 +KBUILD_AFLAGS += -DBUILD_VDSO
100 +KBUILD_CFLAGS += -DBUILD_VDSO
101 +
102 KBUILD_AFLAGS_31 := $(filter-out -m64,$(KBUILD_AFLAGS))
103 KBUILD_AFLAGS_31 += -m31 -s
104
105 diff --git a/arch/s390/kernel/vdso32/clock_getres.S b/arch/s390/kernel/vdso32/clock_getres.S
106 index f61df5253c23..6aeddf8e4bc7 100644
107 --- a/arch/s390/kernel/vdso32/clock_getres.S
108 +++ b/arch/s390/kernel/vdso32/clock_getres.S
109 @@ -9,6 +9,7 @@
110 #include <asm/vdso.h>
111 #include <asm/asm-offsets.h>
112 #include <asm/unistd.h>
113 +#include <asm/dwarf.h>
114
115 .text
116 .align 4
117 diff --git a/arch/s390/kernel/vdso32/clock_gettime.S b/arch/s390/kernel/vdso32/clock_gettime.S
118 index 2d6ec3abe095..d0ac32c413e2 100644
119 --- a/arch/s390/kernel/vdso32/clock_gettime.S
120 +++ b/arch/s390/kernel/vdso32/clock_gettime.S
121 @@ -9,6 +9,7 @@
122 #include <asm/vdso.h>
123 #include <asm/asm-offsets.h>
124 #include <asm/unistd.h>
125 +#include <asm/dwarf.h>
126
127 .text
128 .align 4
129 diff --git a/arch/s390/kernel/vdso32/getcpu.S b/arch/s390/kernel/vdso32/getcpu.S
130 index 5477a2c112fb..539d92a2c61b 100644
131 --- a/arch/s390/kernel/vdso32/getcpu.S
132 +++ b/arch/s390/kernel/vdso32/getcpu.S
133 @@ -8,6 +8,7 @@
134 */
135 #include <asm/vdso.h>
136 #include <asm/asm-offsets.h>
137 +#include <asm/dwarf.h>
138
139 .text
140 .align 4
141 diff --git a/arch/s390/kernel/vdso32/gettimeofday.S b/arch/s390/kernel/vdso32/gettimeofday.S
142 index aa8bf13a2edb..435f819c3e65 100644
143 --- a/arch/s390/kernel/vdso32/gettimeofday.S
144 +++ b/arch/s390/kernel/vdso32/gettimeofday.S
145 @@ -9,6 +9,7 @@
146 #include <asm/vdso.h>
147 #include <asm/asm-offsets.h>
148 #include <asm/unistd.h>
149 +#include <asm/dwarf.h>
150
151 .text
152 .align 4
153 diff --git a/arch/s390/kernel/vdso64/Makefile b/arch/s390/kernel/vdso64/Makefile
154 index f81ae7998883..15b1ceafc4c1 100644
155 --- a/arch/s390/kernel/vdso64/Makefile
156 +++ b/arch/s390/kernel/vdso64/Makefile
157 @@ -10,6 +10,9 @@ obj-vdso64 = gettimeofday.o clock_getres.o clock_gettime.o note.o getcpu.o
158 targets := $(obj-vdso64) vdso64.so vdso64.so.dbg
159 obj-vdso64 := $(addprefix $(obj)/, $(obj-vdso64))
160
161 +KBUILD_AFLAGS += -DBUILD_VDSO
162 +KBUILD_CFLAGS += -DBUILD_VDSO
163 +
164 KBUILD_AFLAGS_64 := $(filter-out -m64,$(KBUILD_AFLAGS))
165 KBUILD_AFLAGS_64 += -m64 -s
166
167 diff --git a/arch/s390/kernel/vdso64/clock_getres.S b/arch/s390/kernel/vdso64/clock_getres.S
168 index faf5213b15df..5b0d9c380de2 100644
169 --- a/arch/s390/kernel/vdso64/clock_getres.S
170 +++ b/arch/s390/kernel/vdso64/clock_getres.S
171 @@ -9,6 +9,7 @@
172 #include <asm/vdso.h>
173 #include <asm/asm-offsets.h>
174 #include <asm/unistd.h>
175 +#include <asm/dwarf.h>
176
177 .text
178 .align 4
179 diff --git a/arch/s390/kernel/vdso64/clock_gettime.S b/arch/s390/kernel/vdso64/clock_gettime.S
180 index 6046b3bfca46..deccd793b279 100644
181 --- a/arch/s390/kernel/vdso64/clock_gettime.S
182 +++ b/arch/s390/kernel/vdso64/clock_gettime.S
183 @@ -9,6 +9,7 @@
184 #include <asm/vdso.h>
185 #include <asm/asm-offsets.h>
186 #include <asm/unistd.h>
187 +#include <asm/dwarf.h>
188
189 .text
190 .align 4
191 diff --git a/arch/s390/kernel/vdso64/getcpu.S b/arch/s390/kernel/vdso64/getcpu.S
192 index e9c34364d97b..022acdecd5b9 100644
193 --- a/arch/s390/kernel/vdso64/getcpu.S
194 +++ b/arch/s390/kernel/vdso64/getcpu.S
195 @@ -8,6 +8,7 @@
196 */
197 #include <asm/vdso.h>
198 #include <asm/asm-offsets.h>
199 +#include <asm/dwarf.h>
200
201 .text
202 .align 4
203 diff --git a/arch/s390/kernel/vdso64/gettimeofday.S b/arch/s390/kernel/vdso64/gettimeofday.S
204 index cc9dbc27da6f..964afb1de06d 100644
205 --- a/arch/s390/kernel/vdso64/gettimeofday.S
206 +++ b/arch/s390/kernel/vdso64/gettimeofday.S
207 @@ -9,6 +9,7 @@
208 #include <asm/vdso.h>
209 #include <asm/asm-offsets.h>
210 #include <asm/unistd.h>
211 +#include <asm/dwarf.h>
212
213 .text
214 .align 4
215 diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S
216 index a049ff005f03..608cf2987d19 100644
217 --- a/arch/s390/kernel/vmlinux.lds.S
218 +++ b/arch/s390/kernel/vmlinux.lds.S
219 @@ -141,4 +141,7 @@ SECTIONS
220
221 /* Sections to be discarded */
222 DISCARDS
223 + /DISCARD/ : {
224 + *(.eh_frame)
225 + }
226 }
227 --
228 2.44.0
229