From bc3703f21cec8a2ac6a64f6fb3686fbcb1ba1513 Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Mon, 20 Nov 2017 11:41:07 +0100 Subject: s390/kernel: emit CFI data in .debug_frame and discard .eh_frame sections Using perf probe and libdw on kernel modules failed to find CFI data for symbols. The CFI data is stored in the .eh_frame section. The elfutils libdw is not able to extract the CFI data correctly, because the .eh_frame section requires "non-simple" relocations for kernel modules. The suggestion is to avoid these "non-simple" relocations by emitting the CFI data in the .debug_frame section. Let gcc emit respective directives by specifying the -fno-asynchronous-unwind-tables option. Using the .debug_frame section for CFI data, the .eh_frame section becomes unused and, thus, discard it for kernel and modules builds The vDSO requires the .eh_frame section and, hence, emit the CFI data in both, the .eh_frame and .debug_frame sections. See also discussion on elfutils/libdw bugzilla: https://sourceware.org/bugzilla/show_bug.cgi?id=22452 Suggested-by: Mark Wielaard Signed-off-by: Hendrik Brueckner Reviewed-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/dwarf.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 arch/s390/include/asm/dwarf.h (limited to 'arch/s390/include/asm') diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h new file mode 100644 index 000000000000..dffdb81e534f --- /dev/null +++ b/arch/s390/include/asm/dwarf.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_DWARF_H +#define _ASM_S390_DWARF_H + +#ifdef __ASSEMBLY__ + +#ifndef BUILD_VDSO + /* + * Emit CFI data in .debug_frame sections and not in .eh_frame + * sections. The .eh_frame CFI is used for runtime unwind + * information that is not being used. Hence, vmlinux.lds.S + * can discard the .eh_frame sections. + */ + .cfi_sections .debug_frame +#else + /* + * For vDSO, emit CFI data in both, .eh_frame and .debug_frame + * sections. + */ + .cfi_sections .eh_frame, .debug_frame +#endif + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_S390_DWARF_H */ -- cgit v1.2.3 From 7bceec4e58ee23be653c0dd366479d6cb64ae686 Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Mon, 20 Nov 2017 11:46:13 +0100 Subject: s390/vdso: revise CFI annotations of vDSO functions Revise and add CFI CFA and register rule annotations to the vDSO functions for proper stack unwinding and debugging. Because glibc might call the vDSO in special ways, the vDSO code does not rely on a stack frame created by the caller. The TOD clock value can be therefore not stored in the pre-allocated stack area and additional stack space is required. To correctly annotate these situations with CFI, the .cfi_val_offset directive is required to create relative offsets on the value of the stack register %r15. Because the .cfi_val_offset directive is available with recent GNU assembler versions only, additional checks are necessary. Note that if the vDSO is assembled with an older assembler version, stack unwinding and debugging from within the vDSO code might not be possible. Signed-off-by: Hendrik Brueckner Reviewed-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/dwarf.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'arch/s390/include/asm') diff --git a/arch/s390/include/asm/dwarf.h b/arch/s390/include/asm/dwarf.h index dffdb81e534f..4f21ae561e4d 100644 --- a/arch/s390/include/asm/dwarf.h +++ b/arch/s390/include/asm/dwarf.h @@ -4,6 +4,18 @@ #ifdef __ASSEMBLY__ +#define CFI_STARTPROC .cfi_startproc +#define CFI_ENDPROC .cfi_endproc +#define CFI_DEF_CFA_OFFSET .cfi_def_cfa_offset +#define CFI_ADJUST_CFA_OFFSET .cfi_adjust_cfa_offset +#define CFI_RESTORE .cfi_restore + +#ifdef CONFIG_AS_CFI_VAL_OFFSET +#define CFI_VAL_OFFSET .cfi_val_offset +#else +#define CFI_VAL_OFFSET # +#endif + #ifndef BUILD_VDSO /* * Emit CFI data in .debug_frame sections and not in .eh_frame -- cgit v1.2.3 From 4381f9f12e79436f90b14f326817cb1ed978940d Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Mon, 11 Dec 2017 14:47:27 +0100 Subject: s390/syscalls: use generated syscall_table.h and unistd.h header files Update the uapi/asm/unistd.h to include the generated compat and 64-bit version of the unistd.h and, as well as, the unistd_nr.h header file. Also remove the arch/s390/kernel/syscalls.S file and use the generated system call table, syscall_table.h, instead. Signed-off-by: Hendrik Brueckner Acked-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/Kbuild | 3 +++ arch/s390/include/asm/unistd.h | 1 + 2 files changed, 4 insertions(+) (limited to 'arch/s390/include/asm') diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild index 048450869328..7b059510bed3 100644 --- a/arch/s390/include/asm/Kbuild +++ b/arch/s390/include/asm/Kbuild @@ -1,4 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 +generated-y += syscall_table.h +generated-y += unistd_nr.h + generic-y += asm-offsets.h generic-y += cacheflush.h generic-y += clkdev.h diff --git a/arch/s390/include/asm/unistd.h b/arch/s390/include/asm/unistd.h index 7807093b73be..fd79c0d35dc4 100644 --- a/arch/s390/include/asm/unistd.h +++ b/arch/s390/include/asm/unistd.h @@ -8,6 +8,7 @@ #define _ASM_S390_UNISTD_H_ #include +#include #define __IGNORE_time #define __IGNORE_pkey_mprotect -- cgit v1.2.3 From 7fbf8315fb7fc7321919e6c880d70077aded515e Mon Sep 17 00:00:00 2001 From: Hendrik Brueckner Date: Thu, 11 Jan 2018 12:13:18 +0100 Subject: s390/tools: generate header files in arch/s390/include/generated/ Previously, the generated dis.h and facilities.h header files have been stored in include/generated. Because they are s390 specific, store them in the arch/s390/include/generated/asm/ directory. Also update references to the header files respectively. To prevent name collisions with those header files in asm/ that include the generated ones, rename the generated headers files and add an -defs suffix. Also update the generators to create the ifdef guards respectively. Signed-off-by: Hendrik Brueckner Acked-by: Heiko Carstens Signed-off-by: Martin Schwidefsky --- arch/s390/include/asm/Kbuild | 2 ++ arch/s390/include/asm/dis.h | 2 +- arch/s390/include/asm/facility.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'arch/s390/include/asm') diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild index 7b059510bed3..c7afbac38761 100644 --- a/arch/s390/include/asm/Kbuild +++ b/arch/s390/include/asm/Kbuild @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 +generated-y += dis-defs.h +generated-y += facility-defs.h generated-y += syscall_table.h generated-y += unistd_nr.h diff --git a/arch/s390/include/asm/dis.h b/arch/s390/include/asm/dis.h index b0480c60a8e1..c18ed6091914 100644 --- a/arch/s390/include/asm/dis.h +++ b/arch/s390/include/asm/dis.h @@ -9,7 +9,7 @@ #ifndef __ASM_S390_DIS_H__ #define __ASM_S390_DIS_H__ -#include +#include static inline int insn_length(unsigned char code) { diff --git a/arch/s390/include/asm/facility.h b/arch/s390/include/asm/facility.h index f040644575b7..fbe0c4be3cd8 100644 --- a/arch/s390/include/asm/facility.h +++ b/arch/s390/include/asm/facility.h @@ -8,7 +8,7 @@ #ifndef __ASM_FACILITY_H #define __ASM_FACILITY_H -#include +#include #include #include #include -- cgit v1.2.3