Skip to content

Commit 1e3cd03

Browse files
committed
Merge tag 'loongarch-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
Pull LoongArch updates from Huacai Chen: - Add objtool support for LoongArch - Add ORC stack unwinder support for LoongArch - Add kernel livepatching support for LoongArch - Select ARCH_HAS_CURRENT_STACK_POINTER in Kconfig - Select HAVE_ARCH_USERFAULTFD_MINOR in Kconfig - Some bug fixes and other small changes * tag 'loongarch-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson: LoongArch/crypto: Clean up useless assignment operations LoongArch: Define the __io_aw() hook as mmiowb() LoongArch: Remove superfluous flush_dcache_page() definition LoongArch: Move {dmw,tlb}_virt_to_page() definition to page.h LoongArch: Change __my_cpu_offset definition to avoid mis-optimization LoongArch: Select HAVE_ARCH_USERFAULTFD_MINOR in Kconfig LoongArch: Select ARCH_HAS_CURRENT_STACK_POINTER in Kconfig LoongArch: Add kernel livepatching support LoongArch: Add ORC stack unwinder support objtool: Check local label in read_unwind_hints() objtool: Check local label in add_dead_ends() objtool/LoongArch: Enable orc to be built objtool/x86: Separate arch-specific and generic parts objtool/LoongArch: Implement instruction decoder objtool/LoongArch: Enable objtool to be built
2 parents 4f55aa8 + fea1c94 commit 1e3cd03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2040
-266
lines changed

arch/loongarch/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ config LOONGARCH
1515
select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE
1616
select ARCH_HAS_ACPI_TABLE_UPGRADE if ACPI
1717
select ARCH_HAS_CPU_FINALIZE_INIT
18+
select ARCH_HAS_CURRENT_STACK_POINTER
1819
select ARCH_HAS_FORTIFY_SOURCE
1920
select ARCH_HAS_KCOV
2021
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
@@ -104,6 +105,7 @@ config LOONGARCH
104105
select HAVE_ARCH_SECCOMP_FILTER
105106
select HAVE_ARCH_TRACEHOOK
106107
select HAVE_ARCH_TRANSPARENT_HUGEPAGE
108+
select HAVE_ARCH_USERFAULTFD_MINOR if USERFAULTFD
107109
select HAVE_ASM_MODVERSIONS
108110
select HAVE_CONTEXT_TRACKING_USER
109111
select HAVE_C_RECORDMCOUNT
@@ -133,20 +135,24 @@ config LOONGARCH
133135
select HAVE_KPROBES
134136
select HAVE_KPROBES_ON_FTRACE
135137
select HAVE_KRETPROBES
138+
select HAVE_LIVEPATCH
136139
select HAVE_MOD_ARCH_SPECIFIC
137140
select HAVE_NMI
141+
select HAVE_OBJTOOL if AS_HAS_EXPLICIT_RELOCS
138142
select HAVE_PCI
139143
select HAVE_PERF_EVENTS
140144
select HAVE_PERF_REGS
141145
select HAVE_PERF_USER_STACK_DUMP
142146
select HAVE_PREEMPT_DYNAMIC_KEY
143147
select HAVE_REGS_AND_STACK_ACCESS_API
148+
select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC
144149
select HAVE_RETHOOK
145150
select HAVE_RSEQ
146151
select HAVE_RUST
147152
select HAVE_SAMPLE_FTRACE_DIRECT
148153
select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
149154
select HAVE_SETUP_PER_CPU_AREA if NUMA
155+
select HAVE_STACK_VALIDATION if HAVE_OBJTOOL
150156
select HAVE_STACKPROTECTOR
151157
select HAVE_SYSCALL_TRACEPOINTS
152158
select HAVE_TIF_NOHZ
@@ -624,6 +630,8 @@ config RANDOMIZE_BASE_MAX_OFFSET
624630

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

633+
source "kernel/livepatch/Kconfig"
634+
627635
endmenu
628636

629637
config ARCH_SELECT_MEMORY_MODEL

arch/loongarch/Kconfig.debug

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ config UNWINDER_PROLOGUE
2626
Some of the addresses it reports may be incorrect (but better than the
2727
Guess unwinder).
2828

29+
config UNWINDER_ORC
30+
bool "ORC unwinder"
31+
select OBJTOOL
32+
help
33+
This option enables the ORC (Oops Rewind Capability) unwinder for
34+
unwinding kernel stack traces. It uses a custom data format which is
35+
a simplified version of the DWARF Call Frame Information standard.
36+
37+
Enabling this option will increase the kernel's runtime memory usage
38+
by roughly 2-4MB, depending on your kernel config.
39+
2940
endchoice

arch/loongarch/Makefile

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ endif
2626
32bit-emul = elf32loongarch
2727
64bit-emul = elf64loongarch
2828

29+
ifdef CONFIG_UNWINDER_ORC
30+
orc_hash_h := arch/$(SRCARCH)/include/generated/asm/orc_hash.h
31+
orc_hash_sh := $(srctree)/scripts/orc_hash.sh
32+
targets += $(orc_hash_h)
33+
quiet_cmd_orc_hash = GEN $@
34+
cmd_orc_hash = mkdir -p $(dir $@); \
35+
$(CONFIG_SHELL) $(orc_hash_sh) < $< > $@
36+
$(orc_hash_h): $(srctree)/arch/loongarch/include/asm/orc_types.h $(orc_hash_sh) FORCE
37+
$(call if_changed,orc_hash)
38+
archprepare: $(orc_hash_h)
39+
endif
40+
2941
ifdef CONFIG_DYNAMIC_FTRACE
3042
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
3143
CC_FLAGS_FTRACE := -fpatchable-function-entry=2
@@ -72,8 +84,6 @@ KBUILD_CFLAGS_KERNEL += $(call cc-option,-mdirect-extern-access)
7284
KBUILD_CFLAGS_KERNEL += $(call cc-option,-fdirect-access-external-data)
7385
KBUILD_AFLAGS_MODULE += $(call cc-option,-fno-direct-access-external-data)
7486
KBUILD_CFLAGS_MODULE += $(call cc-option,-fno-direct-access-external-data)
75-
KBUILD_AFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
76-
KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
7787
else
7888
cflags-y += $(call cc-option,-mno-explicit-relocs)
7989
KBUILD_AFLAGS_KERNEL += -Wa,-mla-global-with-pcrel
@@ -82,6 +92,15 @@ KBUILD_AFLAGS_MODULE += -Wa,-mla-global-with-abs
8292
KBUILD_CFLAGS_MODULE += -fplt -Wa,-mla-global-with-abs,-mla-local-with-abs
8393
endif
8494

95+
KBUILD_AFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
96+
KBUILD_CFLAGS += $(call cc-option,-mno-relax) $(call cc-option,-Wa$(comma)-mno-relax)
97+
KBUILD_AFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
98+
KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
99+
100+
ifdef CONFIG_OBJTOOL
101+
KBUILD_CFLAGS += -fno-jump-tables
102+
endif
103+
85104
KBUILD_RUSTFLAGS += --target=$(objtree)/scripts/target.json
86105
KBUILD_RUSTFLAGS_MODULE += -Crelocation-model=pic
87106

arch/loongarch/crypto/crc32-loongarch.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ static u32 crc32_loongarch_hw(u32 crc_, const u8 *p, unsigned int len)
4444

4545
CRC32(crc, value, w);
4646
p += sizeof(u32);
47-
len -= sizeof(u32);
4847
}
4948

5049
if (len & sizeof(u16)) {
@@ -80,7 +79,6 @@ static u32 crc32c_loongarch_hw(u32 crc_, const u8 *p, unsigned int len)
8079

8180
CRC32C(crc, value, w);
8281
p += sizeof(u32);
83-
len -= sizeof(u32);
8482
}
8583

8684
if (len & sizeof(u16)) {

arch/loongarch/include/asm/Kbuild

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# SPDX-License-Identifier: GPL-2.0
2+
generated-y += orc_hash.h
3+
24
generic-y += dma-contiguous.h
35
generic-y += mcs_spinlock.h
46
generic-y += parport.h
57
generic-y += early_ioremap.h
68
generic-y += qrwlock.h
9+
generic-y += qspinlock.h
710
generic-y += rwsem.h
811
generic-y += segment.h
912
generic-y += user.h

arch/loongarch/include/asm/bug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
do { \
4545
instrumentation_begin(); \
4646
__BUG_FLAGS(BUGFLAG_WARNING|(flags)); \
47+
annotate_reachable(); \
4748
instrumentation_end(); \
4849
} while (0)
4950

arch/loongarch/include/asm/cacheflush.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ void local_flush_icache_range(unsigned long start, unsigned long end);
3737
#define flush_icache_range local_flush_icache_range
3838
#define flush_icache_user_range local_flush_icache_range
3939

40-
#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
41-
4240
#define flush_cache_all() do { } while (0)
4341
#define flush_cache_mm(mm) do { } while (0)
4442
#define flush_cache_dup_mm(mm) do { } while (0)
@@ -47,7 +45,6 @@ void local_flush_icache_range(unsigned long start, unsigned long end);
4745
#define flush_cache_vmap(start, end) do { } while (0)
4846
#define flush_cache_vunmap(start, end) do { } while (0)
4947
#define flush_icache_user_page(vma, page, addr, len) do { } while (0)
50-
#define flush_dcache_page(page) do { } while (0)
5148
#define flush_dcache_mmap_lock(mapping) do { } while (0)
5249
#define flush_dcache_mmap_unlock(mapping) do { } while (0)
5350

arch/loongarch/include/asm/exception.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <asm/ptrace.h>
77
#include <linux/kprobes.h>
88

9+
extern void *exception_table[];
10+
911
void show_registers(struct pt_regs *regs);
1012

1113
asmlinkage void cache_parity_error(void);

arch/loongarch/include/asm/io.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ extern void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t
7171
#define memcpy_fromio(a, c, l) __memcpy_fromio((a), (c), (l))
7272
#define memcpy_toio(c, a, l) __memcpy_toio((c), (a), (l))
7373

74+
#define __io_aw() mmiowb()
75+
7476
#include <asm-generic/io.h>
7577

7678
#define ARCH_HAS_VALID_PHYS_ADDR_RANGE

arch/loongarch/include/asm/module.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#define _ASM_MODULE_H
77

88
#include <asm/inst.h>
9+
#include <asm/orc_types.h>
910
#include <asm-generic/module.h>
1011

1112
#define RELA_STACK_DEPTH 16
@@ -21,6 +22,12 @@ struct mod_arch_specific {
2122
struct mod_section plt;
2223
struct mod_section plt_idx;
2324

25+
#ifdef CONFIG_UNWINDER_ORC
26+
unsigned int num_orcs;
27+
int *orc_unwind_ip;
28+
struct orc_entry *orc_unwind;
29+
#endif
30+
2431
/* For CONFIG_DYNAMIC_FTRACE */
2532
struct plt_entry *ftrace_trampolines;
2633
};

0 commit comments

Comments
 (0)