-
Notifications
You must be signed in to change notification settings - Fork 102
[linux-6.6.y] loongarch64: Re-apply livepatching/objtool changes and backport a fix #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
340a61c
7e91a21
ff04b57
cc7e808
ef96fa3
90dc281
aa6dffe
6b09ebc
f6cf462
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,18 @@ endif | |
| 32bit-emul = elf32loongarch | ||
| 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 $@ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: trailing whitespace |
||
| cmd_orc_hash = mkdir -p $(dir $@); \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: patch seems to be corrupt (line wrapped?) |
||
| $(CONFIG_SHELL) $(orc_hash_sh) < $< > $@ | ||
| $(orc_hash_h): $(srctree)/arch/loongarch/include/asm/orc_types.h $(orc_hash_sh) FORCE | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: trailing whitespace |
||
| $(call if_changed,orc_hash) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: trailing whitespace |
||
| archprepare: $(orc_hash_h) | ||
| endif | ||
|
|
||
| ifdef CONFIG_DYNAMIC_FTRACE | ||
| KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR: Avoid using diff content in the commit message - patch(1) might not work |
||
| CC_FLAGS_FTRACE := -fpatchable-function-entry=2 | ||
|
|
@@ -68,8 +80,6 @@ LDFLAGS_vmlinux += -static -n -nostdlib | |
| ifdef CONFIG_AS_HAS_EXPLICIT_RELOCS | ||
| cflags-y += $(call cc-option,-mexplicit-relocs) | ||
| 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 | ||
| cflags-y += $(call cc-option,-mno-explicit-relocs) | ||
| 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 | ||
| 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) | ||
| KBUILD_CFLAGS_KERNEL += -fPIE | ||
| LDFLAGS_vmlinux += -static -pie --no-dynamic-linker -z notext $(call ld-option, --apply-dynamic-relocs) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
|
||
| #ifndef _ORC_HEADER_H | ||
| #define _ORC_HEADER_H | ||
|
|
||
| #include <linux/types.h> | ||
| #include <linux/compiler.h> | ||
| #include <asm/orc_hash.h> | ||
|
|
||
| /* | ||
| * The header is currently a 20-byte hash of the ORC entry definition; see | ||
| * scripts/orc_hash.sh. | ||
| */ | ||
| #define ORC_HEADER \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) |
||
| __used __section(".orc_header") __aligned(4) \ | ||
| static const u8 orc_header[] = { ORC_HASH } | ||
|
|
||
| #endif /* _ORC_HEADER_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
| #ifndef _ORC_LOOKUP_H | ||
| #define _ORC_LOOKUP_H | ||
|
|
||
| /* | ||
| * This is a lookup table for speeding up access to the .orc_unwind table. | ||
| * Given an input address offset, the corresponding lookup table entry | ||
| * specifies a subset of the .orc_unwind table to search. | ||
| * | ||
| * Each block represents the end of the previous range and the start of the | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) |
||
| * next range. An extra block is added to give the last range an end. | ||
| * | ||
| * The block size should be a power of 2 to avoid a costly 'div' instruction. | ||
| * | ||
| * A block size of 256 was chosen because it roughly doubles unwinder | ||
| * performance while only adding ~5% to the ORC data footprint. | ||
| */ | ||
| #define LOOKUP_BLOCK_ORDER 8 | ||
| #define LOOKUP_BLOCK_SIZE (1 << LOOKUP_BLOCK_ORDER) | ||
|
|
||
| #ifndef LINKER_SCRIPT | ||
|
|
||
| extern unsigned int orc_lookup[]; | ||
| extern unsigned int orc_lookup_end[]; | ||
|
|
||
| #define LOOKUP_START_IP (unsigned long)_stext | ||
| #define LOOKUP_STOP_IP (unsigned long)_etext | ||
|
|
||
| #endif /* LINKER_SCRIPT */ | ||
|
|
||
| #endif /* _ORC_LOOKUP_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
| #ifndef _ORC_TYPES_H | ||
| #define _ORC_TYPES_H | ||
|
|
||
| #include <linux/types.h> | ||
|
|
||
| /* | ||
| * The ORC_REG_* registers are base registers which are used to find other | ||
| * registers on the stack. | ||
| * | ||
| * ORC_REG_PREV_SP, also known as DWARF Call Frame Address (CFA), is the | ||
| * address of the previous frame: the caller's SP before it called the current | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) |
||
| * function. | ||
| * | ||
| * ORC_REG_UNDEFINED means the corresponding register's value didn't change in | ||
| * the current frame. | ||
| * | ||
| * The most commonly used base registers are SP and FP -- which the previous SP | ||
| * is usually based on -- and PREV_SP and UNDEFINED -- which the previous FP is | ||
| * usually based on. | ||
| * | ||
| * The rest of the base registers are needed for special cases like entry code | ||
| * and GCC realigned stacks. | ||
| */ | ||
| #define ORC_REG_UNDEFINED 0 | ||
| #define ORC_REG_PREV_SP 1 | ||
| #define ORC_REG_SP 2 | ||
| #define ORC_REG_FP 3 | ||
| #define ORC_REG_MAX 4 | ||
|
|
||
| #define ORC_TYPE_UNDEFINED 0 | ||
| #define ORC_TYPE_END_OF_STACK 1 | ||
| #define ORC_TYPE_CALL 2 | ||
| #define ORC_TYPE_REGS 3 | ||
| #define ORC_TYPE_REGS_PARTIAL 4 | ||
|
|
||
| #ifndef __ASSEMBLY__ | ||
| /* | ||
| * This struct is more or less a vastly simplified version of the DWARF Call | ||
| * Frame Information standard. It contains only the necessary parts of DWARF | ||
| * CFI, simplified for ease of access by the in-kernel unwinder. It tells the | ||
| * unwinder how to find the previous SP and FP (and sometimes entry regs) on | ||
| * the stack for a given code address. Each instance of the struct corresponds | ||
| * to one or more code locations. | ||
| */ | ||
| struct orc_entry { | ||
| s16 sp_offset; | ||
| s16 fp_offset; | ||
| s16 ra_offset; | ||
| unsigned int sp_reg:4; | ||
| unsigned int fp_reg:4; | ||
| unsigned int ra_reg:4; | ||
| unsigned int type:3; | ||
| unsigned int signal:1; | ||
| }; | ||
| #endif /* __ASSEMBLY__ */ | ||
|
|
||
| #endif /* _ORC_TYPES_H */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0 */ | ||
| #ifndef _ASM_LOONGARCH_UNWIND_HINTS_H | ||
| #define _ASM_LOONGARCH_UNWIND_HINTS_H | ||
|
|
||
| #include <linux/objtool.h> | ||
| #include <asm/orc_types.h> | ||
|
|
||
| #ifdef __ASSEMBLY__ | ||
|
|
||
| .macro UNWIND_HINT_UNDEFINED | ||
| UNWIND_HINT type=UNWIND_HINT_TYPE_UNDEFINED | ||
| .endm | ||
|
|
||
| .macro UNWIND_HINT_END_OF_STACK | ||
| UNWIND_HINT type=UNWIND_HINT_TYPE_END_OF_STACK | ||
| .endm | ||
|
|
||
| .macro UNWIND_HINT_REGS | ||
| UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_REGS | ||
| .endm | ||
|
|
||
| .macro UNWIND_HINT_FUNC | ||
| UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL | ||
| .endm | ||
|
|
||
| #endif /* __ASSEMBLY__ */ | ||
|
|
||
| #endif /* _ASM_LOONGARCH_UNWIND_HINTS_H */ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| # Makefile for the Linux/LoongArch kernel. | ||
| # | ||
|
|
||
| OBJECT_FILES_NON_STANDARD_head.o := y | ||
|
|
||
| extra-y := vmlinux.lds | ||
|
|
||
| obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WARNING: Prefer a maximum 75 chars per line (possible unwrapped commit description?) |
||
|
|
@@ -22,6 +24,7 @@ obj-$(CONFIG_ARCH_STRICT_ALIGN) += unaligned.o | |
|
|
||
| CFLAGS_module.o += $(call cc-option,-Wno-override-init,) | ||
| CFLAGS_syscall.o += $(call cc-option,-Wno-override-init,) | ||
| CFLAGS_traps.o += $(call cc-option,-Wno-override-init,) | ||
| CFLAGS_perf_event.o += $(call cc-option,-Wno-override-init,) | ||
|
|
||
| ifdef CONFIG_FUNCTION_TRACER | ||
|
|
@@ -64,6 +67,7 @@ obj-$(CONFIG_CRASH_DUMP) += crash_dump.o | |
|
|
||
| obj-$(CONFIG_UNWINDER_GUESS) += unwind_guess.o | ||
| obj-$(CONFIG_UNWINDER_PROLOGUE) += unwind_prologue.o | ||
| obj-$(CONFIG_UNWINDER_ORC) += unwind_orc.o | ||
|
|
||
| obj-$(CONFIG_PERF_EVENTS) += perf_event.o perf_regs.o | ||
| obj-$(CONFIG_HAVE_HW_BREAKPOINT) += hw_breakpoint.o | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ERROR: trailing whitespace