Skip to content

Commit 8ecfa36

Browse files
committed
Merge tag 'riscv-for-linus-5.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - A pair of XIP fixes: one to fix alternatives, and one to turn off the rest of the features that require code modification - A fix to a type that was causing some alternatives to break - A build fix for BUILTIN_DTB * tag 'riscv-for-linus-5.13-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Fix BUILTIN_DTB for sifive and microchip soc riscv: alternative: fix typo in macro name riscv: code patching only works on !XIP_KERNEL riscv: xip: support runtime trap patching
2 parents 2e30254 + 0ddd7ea commit 8ecfa36

File tree

6 files changed

+36
-16
lines changed

6 files changed

+36
-16
lines changed

arch/riscv/Kconfig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ config RISCV
6161
select GENERIC_TIME_VSYSCALL if MMU && 64BIT
6262
select HANDLE_DOMAIN_IRQ
6363
select HAVE_ARCH_AUDITSYSCALL
64-
select HAVE_ARCH_JUMP_LABEL
65-
select HAVE_ARCH_JUMP_LABEL_RELATIVE
64+
select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL
65+
select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL
6666
select HAVE_ARCH_KASAN if MMU && 64BIT
6767
select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT
68-
select HAVE_ARCH_KGDB
68+
select HAVE_ARCH_KGDB if !XIP_KERNEL
6969
select HAVE_ARCH_KGDB_QXFER_PKT
7070
select HAVE_ARCH_MMAP_RND_BITS if MMU
7171
select HAVE_ARCH_SECCOMP_FILTER
@@ -80,9 +80,9 @@ config RISCV
8080
select HAVE_GCC_PLUGINS
8181
select HAVE_GENERIC_VDSO if MMU && 64BIT
8282
select HAVE_IRQ_TIME_ACCOUNTING
83-
select HAVE_KPROBES
84-
select HAVE_KPROBES_ON_FTRACE
85-
select HAVE_KRETPROBES
83+
select HAVE_KPROBES if !XIP_KERNEL
84+
select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL
85+
select HAVE_KRETPROBES if !XIP_KERNEL
8686
select HAVE_PCI
8787
select HAVE_PERF_EVENTS
8888
select HAVE_PERF_REGS
@@ -231,11 +231,11 @@ config ARCH_RV64I
231231
bool "RV64I"
232232
select 64BIT
233233
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000
234-
select HAVE_DYNAMIC_FTRACE if MMU && $(cc-option,-fpatchable-function-entry=8)
234+
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8)
235235
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
236-
select HAVE_FTRACE_MCOUNT_RECORD
236+
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
237237
select HAVE_FUNCTION_GRAPH_TRACER
238-
select HAVE_FUNCTION_TRACER
238+
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
239239
select SWIOTLB if MMU
240240

241241
endchoice
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0
22
dtb-$(CONFIG_SOC_MICROCHIP_POLARFIRE) += microchip-mpfs-icicle-kit.dtb
3+
obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y))

arch/riscv/boot/dts/sifive/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# SPDX-License-Identifier: GPL-2.0
22
dtb-$(CONFIG_SOC_SIFIVE) += hifive-unleashed-a00.dtb \
33
hifive-unmatched-a00.dtb
4+
obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y))

arch/riscv/include/asm/alternative-macros.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
REG_ASM " " newlen "\n" \
5252
".word " errata_id "\n"
5353

54-
#define ALT_NEW_CONSTENT(vendor_id, errata_id, enable, new_c) \
54+
#define ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c) \
5555
".if " __stringify(enable) " == 1\n" \
5656
".pushsection .alternative, \"a\"\n" \
5757
ALT_ENTRY("886b", "888f", __stringify(vendor_id), __stringify(errata_id), "889f - 888f") \
@@ -69,7 +69,7 @@
6969
"886 :\n" \
7070
old_c "\n" \
7171
"887 :\n" \
72-
ALT_NEW_CONSTENT(vendor_id, errata_id, enable, new_c)
72+
ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c)
7373

7474
#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
7575
__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))

arch/riscv/kernel/traps.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,13 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code,
8686
}
8787
}
8888

89+
#if defined (CONFIG_XIP_KERNEL) && defined (CONFIG_RISCV_ERRATA_ALTERNATIVE)
90+
#define __trap_section __section(".xip.traps")
91+
#else
92+
#define __trap_section
93+
#endif
8994
#define DO_ERROR_INFO(name, signo, code, str) \
90-
asmlinkage __visible void name(struct pt_regs *regs) \
95+
asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
9196
{ \
9297
do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
9398
}
@@ -111,15 +116,15 @@ DO_ERROR_INFO(do_trap_store_misaligned,
111116
int handle_misaligned_load(struct pt_regs *regs);
112117
int handle_misaligned_store(struct pt_regs *regs);
113118

114-
asmlinkage void do_trap_load_misaligned(struct pt_regs *regs)
119+
asmlinkage void __trap_section do_trap_load_misaligned(struct pt_regs *regs)
115120
{
116121
if (!handle_misaligned_load(regs))
117122
return;
118123
do_trap_error(regs, SIGBUS, BUS_ADRALN, regs->epc,
119124
"Oops - load address misaligned");
120125
}
121126

122-
asmlinkage void do_trap_store_misaligned(struct pt_regs *regs)
127+
asmlinkage void __trap_section do_trap_store_misaligned(struct pt_regs *regs)
123128
{
124129
if (!handle_misaligned_store(regs))
125130
return;
@@ -146,7 +151,7 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
146151
return GET_INSN_LENGTH(insn);
147152
}
148153

149-
asmlinkage __visible void do_trap_break(struct pt_regs *regs)
154+
asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
150155
{
151156
#ifdef CONFIG_KPROBES
152157
if (kprobe_single_step_handler(regs))

arch/riscv/kernel/vmlinux-xip.lds.S

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,22 @@ SECTIONS
9999
}
100100
PERCPU_SECTION(L1_CACHE_BYTES)
101101

102-
. = ALIGN(PAGE_SIZE);
102+
. = ALIGN(8);
103+
.alternative : {
104+
__alt_start = .;
105+
*(.alternative)
106+
__alt_end = .;
107+
}
103108
__init_end = .;
104109

110+
. = ALIGN(16);
111+
.xip.traps : {
112+
__xip_traps_start = .;
113+
*(.xip.traps)
114+
__xip_traps_end = .;
115+
}
116+
117+
. = ALIGN(PAGE_SIZE);
105118
.sdata : {
106119
__global_pointer$ = . + 0x800;
107120
*(.sdata*)

0 commit comments

Comments
 (0)