@@ -1016,7 +1016,9 @@ config HAVE_STACK_VALIDATION
bool
help
Architecture supports the 'objtool check' host tool command, which
- performs compile-time stack metadata validation.
+ performs compile-time stack metadata validation. Or, on architectures
+ that use DWARF validated frame pointers, it supports the
+ 'objtool dwarf generate' host tool command.
config HAVE_RELIABLE_STACKTRACE
bool
@@ -220,6 +220,8 @@ config ARM64
select SWIOTLB
select SYSCTL_EXCEPTION_TRACE
select THREAD_INFO_IN_TASK
+ select HAVE_STACK_VALIDATION if DWARF_FP
+ select STACK_VALIDATION if HAVE_STACK_VALIDATION
select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD
select TRACE_IRQFLAGS_SUPPORT
help
@@ -20,4 +20,9 @@ config ARM64_RELOC_TEST
depends on m
tristate "Relocation testing module"
+config DWARF_FP
+ def_bool y
+ depends on FRAME_POINTER
+ depends on DEBUG_INFO_DWARF4
+
source "drivers/hwtracing/coresight/Kconfig"
@@ -1233,3 +1233,4 @@ CONFIG_DEBUG_KERNEL=y
# CONFIG_DEBUG_PREEMPT is not set
# CONFIG_FTRACE is not set
CONFIG_MEMTEST=y
+CONFIG_DEBUG_INFO_DWARF4=y
@@ -122,6 +122,25 @@ jiffies = jiffies_64;
#define TRAMP_TEXT
#endif
+#ifdef CONFIG_DWARF_FP
+#define DWARF_RULES \
+ . = ALIGN(8); \
+ .dwarf_rules : { \
+ __dwarf_rules_start = .; \
+ KEEP(*(.dwarf_rules)) \
+ __dwarf_rules_end = .; \
+ }
+
+#define DWARF_PCS \
+ . = ALIGN(8); \
+ __dwarf_pcs_start = .; \
+ KEEP(*(.dwarf_pcs)) \
+ __dwarf_pcs_end = .;
+#else
+#define DWARF_RULES
+#define DWARF_PCS
+#endif
+
/*
* The size of the PE/COFF section that covers the kernel image, which
* runs from _stext to _edata, must be a round multiple of the PE/COFF
@@ -239,6 +258,7 @@ SECTIONS
CON_INITCALL
INIT_RAM_FS
*(.init.altinstructions .init.bss) /* from the EFI stub */
+ DWARF_PCS
}
.exit.data : {
EXIT_DATA
@@ -291,6 +311,8 @@ SECTIONS
__mmuoff_data_end = .;
}
+ DWARF_RULES
+
PECOFF_EDATA_PADDING
__pecoff_data_rawsize = ABSOLUTE(. - __initdata_begin);
_edata = .;
@@ -227,6 +227,9 @@ ifdef CONFIG_STACK_VALIDATION
objtool := $(objtree)/tools/objtool/objtool
+ifdef CONFIG_DWARF_FP
+objtool_args = dwarf generate
+else
objtool_args = \
$(if $(CONFIG_UNWINDER_ORC),orc generate,check) \
$(if $(part-of-module), --module) \
@@ -235,6 +238,7 @@ objtool_args = \
$(if $(CONFIG_RETPOLINE), --retpoline) \
$(if $(CONFIG_X86_SMAP), --uaccess) \
$(if $(CONFIG_FTRACE_MCOUNT_USE_OBJTOOL), --mcount)
+endif
cmd_objtool = $(if $(objtool-enabled), ; $(objtool) $(objtool_args) $@)
cmd_gen_objtooldep = $(if $(objtool-enabled), { echo ; echo '$@: $$(wildcard $(objtool))' ; } >> $(dot-target).cmd)
@@ -104,6 +104,12 @@ objtool_link()
local objtoolcmd;
local objtoolopt;
+ if [ "${CONFIG_LTO_CLANG} ${CONFIG_DWARF_FP}" = "y y" ]
+ then
+ tools/objtool/objtool dwarf generate ${1}
+ return
+ fi
+
if [ "${CONFIG_LTO_CLANG} ${CONFIG_STACK_VALIDATION}" = "y y" ]; then
# Don't perform vmlinux validation unless explicitly requested,
# but run objtool on vmlinux.o now that we have an object file.