Unverified Commit 19640fb0 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!13180 Add objtool, orc and livepatch support for LoongArch

Merge Pull Request from: @ci-robot 
 
PR sync from: Tiezhu Yang <yangtiezhu@loongson.cn>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/QOMNOQB5AFUZ6IMRNMWCUIYRVG7D2YTQ/ 
The patches come from the upstream mainline kernel, backport them to
OLK-6.6 to support objtool, orc and livepatch on LoongArch.

Huacai Chen (1):
  LoongArch: Update Loongson-3 default config file

Jinyang He (1):
  LoongArch: Add kernel livepatching support

Tiezhu Yang (13):
  objtool/LoongArch: Enable objtool to be built
  objtool/LoongArch: Implement instruction decoder
  objtool/x86: Separate arch-specific and generic parts
  objtool/LoongArch: Enable orc to be built
  objtool: Check local label in add_dead_ends()
  objtool: Check local label in read_unwind_hints()
  LoongArch: Add ORC stack unwinder support
  LoongArch: Fix definition of ftrace_regs_set_instruction_pointer()
  LoongArch: Add ifdefs to fix LSX and LASX related warnings
  objtool: Handle frame pointer related instructions
  LoongArch: Enable objtool for Clang
  LoongArch: Set AS_HAS_THIN_ADD_SUB as y if AS_IS_LLVM
  compiler.h: specify correct attribute for .rodata..c_jump_table

Xi Ruoyao (1):
  LoongArch: Only allow OBJTOOL & ORC unwinder if toolchain supports
    -mthin-add-sub


-- 
2.42.0
 
https://gitee.com/openeuler/kernel/issues/IB3IRE 
 
Link:https://gitee.com/openeuler/kernel/pulls/13180

 

Reviewed-by: default avatarHongchen Zhang <zhanghongchen@loongson.cn>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 7d4e3fc0 7903b402
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -135,18 +135,23 @@ config LOONGARCH
	select HAVE_KPROBES_ON_FTRACE
	select HAVE_KPROBES_ON_FTRACE
	select HAVE_KRETPROBES
	select HAVE_KRETPROBES
	select HAVE_KVM
	select HAVE_KVM
	select HAVE_LIVEPATCH
	select HAVE_LIVEPATCH_FTRACE
	select HAVE_MOD_ARCH_SPECIFIC
	select HAVE_MOD_ARCH_SPECIFIC
	select HAVE_NMI
	select HAVE_NMI
	select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS && AS_HAS_THIN_ADD_SUB
	select HAVE_PCI
	select HAVE_PCI
	select HAVE_PERF_EVENTS
	select HAVE_PERF_EVENTS
	select HAVE_PERF_REGS
	select HAVE_PERF_REGS
	select HAVE_PERF_USER_STACK_DUMP
	select HAVE_PERF_USER_STACK_DUMP
	select HAVE_REGS_AND_STACK_ACCESS_API
	select HAVE_REGS_AND_STACK_ACCESS_API
	select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC
	select HAVE_RETHOOK
	select HAVE_RETHOOK
	select HAVE_RSEQ
	select HAVE_RSEQ
	select HAVE_SAMPLE_FTRACE_DIRECT
	select HAVE_SAMPLE_FTRACE_DIRECT
	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
	select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
	select HAVE_SETUP_PER_CPU_AREA if NUMA
	select HAVE_SETUP_PER_CPU_AREA if NUMA
	select HAVE_STACK_VALIDATION if HAVE_OBJTOOL
	select HAVE_STACKPROTECTOR
	select HAVE_STACKPROTECTOR
	select ARCH_HAS_PHYS_TO_DMA
	select ARCH_HAS_PHYS_TO_DMA
	select HAVE_SYSCALL_TRACEPOINTS
	select HAVE_SYSCALL_TRACEPOINTS
@@ -261,6 +266,9 @@ config AS_HAS_EXPLICIT_RELOCS
config AS_HAS_FCSR_CLASS
config AS_HAS_FCSR_CLASS
	def_bool $(as-instr,movfcsr2gr \$t0$(comma)\$fcsr0)
	def_bool $(as-instr,movfcsr2gr \$t0$(comma)\$fcsr0)


config AS_HAS_THIN_ADD_SUB
	def_bool $(cc-option,-Wa$(comma)-mthin-add-sub) || AS_IS_LLVM

config AS_HAS_LSX_EXTENSION
config AS_HAS_LSX_EXTENSION
	def_bool $(as-instr,vld \$vr0$(comma)\$a0$(comma)0)
	def_bool $(as-instr,vld \$vr0$(comma)\$a0$(comma)0)


@@ -621,6 +629,8 @@ config RANDOMIZE_BASE_MAX_OFFSET


	  This is limited by the size of the lower address memory, 256MB.
	  This is limited by the size of the lower address memory, 256MB.


source "kernel/livepatch/Kconfig"

endmenu
endmenu


config ARCH_SELECT_MEMORY_MODEL
config ARCH_SELECT_MEMORY_MODEL
+12 −0
Original line number Original line Diff line number Diff line
@@ -26,4 +26,16 @@ config UNWINDER_PROLOGUE
	  Some of the addresses it reports may be incorrect (but better than the
	  Some of the addresses it reports may be incorrect (but better than the
	  Guess unwinder).
	  Guess unwinder).


config UNWINDER_ORC
	bool "ORC unwinder"
	depends on HAVE_OBJTOOL
	select OBJTOOL
	help
	  This option enables the ORC (Oops Rewind Capability) unwinder for
	  unwinding kernel stack traces.  It uses a custom data format which is
	  a simplified version of the DWARF Call Frame Information standard.

	  Enabling this option will increase the kernel's runtime memory usage
	  by roughly 2-4MB, depending on your kernel config.

endchoice
endchoice
+21 −2
Original line number Original line Diff line number Diff line
@@ -25,6 +25,18 @@ endif
32bit-emul		= elf32loongarch
32bit-emul		= elf32loongarch
64bit-emul		= elf64loongarch
64bit-emul		= elf64loongarch


ifdef CONFIG_UNWINDER_ORC
orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h
orc_hash_sh := $(srctree)/scripts/orc_hash.sh
targets += $(orc_hash_h)
quiet_cmd_orc_hash = GEN     $@
      cmd_orc_hash = mkdir -p $(dir $@); \
		     $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@
$(orc_hash_h): $(srctree)/arch/loongarch/include/asm/orc_types.h $(orc_hash_sh) FORCE
	$(call if_changed,orc_hash)
archprepare: $(orc_hash_h)
endif

ifdef CONFIG_DYNAMIC_FTRACE
ifdef CONFIG_DYNAMIC_FTRACE
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
CC_FLAGS_FTRACE := -fpatchable-function-entry=2
CC_FLAGS_FTRACE := -fpatchable-function-entry=2
@@ -68,8 +80,6 @@ LDFLAGS_vmlinux += -static -n -nostdlib
ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS
cflags-y			+= $(call cc-option,-mexplicit-relocs)
cflags-y			+= $(call cc-option,-mexplicit-relocs)
KBUILD_CFLAGS_KERNEL		+= $(call cc-option,-mdirect-extern-access)
KBUILD_CFLAGS_KERNEL		+= $(call cc-option,-mdirect-extern-access)
KBUILD_AFLAGS_MODULE		+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
KBUILD_CFLAGS_MODULE		+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
else
else
cflags-y			+= $(call cc-option,-mno-explicit-relocs)
cflags-y			+= $(call cc-option,-mno-explicit-relocs)
KBUILD_AFLAGS_KERNEL		+= -Wa,-mla-global-with-pcrel
KBUILD_AFLAGS_KERNEL		+= -Wa,-mla-global-with-pcrel
@@ -78,6 +88,15 @@ KBUILD_AFLAGS_MODULE += -Wa,-mla-global-with-abs
KBUILD_CFLAGS_MODULE		+= -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
KBUILD_CFLAGS_MODULE		+= -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
endif
endif


KBUILD_AFLAGS			+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
KBUILD_CFLAGS			+= $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
KBUILD_AFLAGS			+= $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
KBUILD_CFLAGS			+= $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)

ifdef CONFIG_OBJTOOL
KBUILD_CFLAGS			+= -fno-jump-tables
endif

ifeq ($(CONFIG_RELOCATABLE),y)
ifeq ($(CONFIG_RELOCATABLE),y)
KBUILD_CFLAGS_KERNEL		+= -fPIE
KBUILD_CFLAGS_KERNEL		+= -fPIE
LDFLAGS_vmlinux			+= -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs)
LDFLAGS_vmlinux			+= -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs)
+3 −0
Original line number Original line Diff line number Diff line
@@ -43,6 +43,7 @@ CONFIG_NR_CPUS=256
CONFIG_NUMA=y
CONFIG_NUMA=y
CONFIG_CPU_HAS_LSX=y
CONFIG_CPU_HAS_LSX=y
CONFIG_CPU_HAS_LASX=y
CONFIG_CPU_HAS_LASX=y
CONFIG_LIVEPATCH=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
@@ -2195,5 +2196,7 @@ CONFIG_SCHEDSTATS=y
CONFIG_DEBUG_LIST=y
CONFIG_DEBUG_LIST=y
CONFIG_RCU_CPU_STALL_TIMEOUT=60
CONFIG_RCU_CPU_STALL_TIMEOUT=60
# CONFIG_RCU_TRACE is not set
# CONFIG_RCU_TRACE is not set
CONFIG_FUNCTION_TRACER=y
# CONFIG_STRICT_DEVMEM is not set
# CONFIG_STRICT_DEVMEM is not set
CONFIG_UNWINDER_ORC=y
# CONFIG_RUNTIME_TESTING_MENU is not set
# CONFIG_RUNTIME_TESTING_MENU is not set
+2 −0
Original line number Original line Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0
# SPDX-License-Identifier: GPL-2.0
generated-y += orc_hash.h

generic-y += dma-contiguous.h
generic-y += dma-contiguous.h
generic-y += mcs_spinlock.h
generic-y += mcs_spinlock.h
generic-y += parport.h
generic-y += parport.h
Loading