Skip to content

Commit 414aaef

Browse files
committed
Merge tag 'riscv-for-linus-6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - Three fixes for unnecessary spew: an ACPI CPPC boot-time debug message, the link-time warnings for R_RISCV_NONE in binaries, and some compile-time warnings in __put_user_nocheck - A fix for a race during text patching - Interrupts are no longer disabled during exception handling - A fix for a missing sign extension in the misaligned load handler - A fix to avoid static ftrace being selected in Kconfig, as we have moved to dynamic ftrace * tag 'riscv-for-linus-6.16-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: uaccess: Fix -Wuninitialized and -Wshadow in __put_user_nocheck riscv: Stop supporting static ftrace riscv: traps_misaligned: properly sign extend value in misaligned load handler riscv: Enable interrupt during exception handling riscv: ftrace: Properly acquire text_mutex to fix a race condition ACPI: RISC-V: Remove unnecessary CPPC debug message riscv: Stop considering R_RISCV_NONE as bad relocations
2 parents c7de79e + b65ca21 commit 414aaef

File tree

7 files changed

+28
-15
lines changed

7 files changed

+28
-15
lines changed

arch/riscv/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ config RISCV
9898
select CLONE_BACKWARDS
9999
select COMMON_CLK
100100
select CPU_PM if CPU_IDLE || HIBERNATION || SUSPEND
101+
select DYNAMIC_FTRACE if FUNCTION_TRACER
101102
select EDAC_SUPPORT
102103
select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
103104
select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
@@ -162,7 +163,7 @@ config RISCV
162163
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
163164
select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS
164165
select HAVE_FUNCTION_GRAPH_FREGS
165-
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
166+
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && HAVE_DYNAMIC_FTRACE
166167
select HAVE_EBPF_JIT if MMU
167168
select HAVE_GUP_FAST if MMU
168169
select HAVE_FUNCTION_ARG_ACCESS_API

arch/riscv/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ do { \
311311
do { \
312312
if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && \
313313
!IS_ALIGNED((uintptr_t)__gu_ptr, sizeof(*__gu_ptr))) { \
314-
__inttype(x) val = (__inttype(x))x; \
315-
if (__asm_copy_to_user_sum_enabled(__gu_ptr, &(val), sizeof(*__gu_ptr))) \
314+
__inttype(x) ___val = (__inttype(x))x; \
315+
if (__asm_copy_to_user_sum_enabled(__gu_ptr, &(___val), sizeof(*__gu_ptr))) \
316316
goto label; \
317317
break; \
318318
} \

arch/riscv/kernel/ftrace.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
#include <asm/text-patching.h>
1515

1616
#ifdef CONFIG_DYNAMIC_FTRACE
17+
void ftrace_arch_code_modify_prepare(void)
18+
__acquires(&text_mutex)
19+
{
20+
mutex_lock(&text_mutex);
21+
}
22+
23+
void ftrace_arch_code_modify_post_process(void)
24+
__releases(&text_mutex)
25+
{
26+
mutex_unlock(&text_mutex);
27+
}
28+
1729
unsigned long ftrace_call_adjust(unsigned long addr)
1830
{
1931
if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_CALL_OPS))
@@ -29,10 +41,8 @@ unsigned long arch_ftrace_get_symaddr(unsigned long fentry_ip)
2941

3042
void arch_ftrace_update_code(int command)
3143
{
32-
mutex_lock(&text_mutex);
3344
command |= FTRACE_MAY_SLEEP;
3445
ftrace_modify_all_code(command);
35-
mutex_unlock(&text_mutex);
3646
flush_icache_all();
3747
}
3848

@@ -149,6 +159,8 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
149159
unsigned int nops[2], offset;
150160
int ret;
151161

162+
guard(mutex)(&text_mutex);
163+
152164
ret = ftrace_rec_set_nop_ops(rec);
153165
if (ret)
154166
return ret;
@@ -157,9 +169,7 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
157169
nops[0] = to_auipc_t0(offset);
158170
nops[1] = RISCV_INSN_NOP4;
159171

160-
mutex_lock(&text_mutex);
161172
ret = patch_insn_write((void *)pc, nops, 2 * MCOUNT_INSN_SIZE);
162-
mutex_unlock(&text_mutex);
163173

164174
return ret;
165175
}

arch/riscv/kernel/traps.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/cpu.h>
77
#include <linux/kernel.h>
88
#include <linux/init.h>
9+
#include <linux/irqflags.h>
910
#include <linux/randomize_kstack.h>
1011
#include <linux/sched.h>
1112
#include <linux/sched/debug.h>
@@ -151,7 +152,9 @@ asmlinkage __visible __trap_section void name(struct pt_regs *regs) \
151152
{ \
152153
if (user_mode(regs)) { \
153154
irqentry_enter_from_user_mode(regs); \
155+
local_irq_enable(); \
154156
do_trap_error(regs, signo, code, regs->epc, "Oops - " str); \
157+
local_irq_disable(); \
155158
irqentry_exit_to_user_mode(regs); \
156159
} else { \
157160
irqentry_state_t state = irqentry_nmi_enter(regs); \
@@ -173,17 +176,14 @@ asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *re
173176

174177
if (user_mode(regs)) {
175178
irqentry_enter_from_user_mode(regs);
176-
177179
local_irq_enable();
178180

179181
handled = riscv_v_first_use_handler(regs);
180-
181-
local_irq_disable();
182-
183182
if (!handled)
184183
do_trap_error(regs, SIGILL, ILL_ILLOPC, regs->epc,
185184
"Oops - illegal instruction");
186185

186+
local_irq_disable();
187187
irqentry_exit_to_user_mode(regs);
188188
} else {
189189
irqentry_state_t state = irqentry_nmi_enter(regs);
@@ -308,9 +308,11 @@ asmlinkage __visible __trap_section void do_trap_break(struct pt_regs *regs)
308308
{
309309
if (user_mode(regs)) {
310310
irqentry_enter_from_user_mode(regs);
311+
local_irq_enable();
311312

312313
handle_break(regs);
313314

315+
local_irq_disable();
314316
irqentry_exit_to_user_mode(regs);
315317
} else {
316318
irqentry_state_t state = irqentry_nmi_enter(regs);

arch/riscv/kernel/traps_misaligned.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ static int handle_scalar_misaligned_load(struct pt_regs *regs)
461461
}
462462

463463
if (!fp)
464-
SET_RD(insn, regs, val.data_ulong << shift >> shift);
464+
SET_RD(insn, regs, (long)(val.data_ulong << shift) >> shift);
465465
else if (len == 8)
466466
set_f64_rd(insn, regs, val.data_u64);
467467
else

arch/riscv/tools/relocs_check.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ bad_relocs=$(
1414
${srctree}/scripts/relocs_check.sh "$@" |
1515
# These relocations are okay
1616
# R_RISCV_RELATIVE
17-
grep -F -w -v 'R_RISCV_RELATIVE'
17+
# R_RISCV_NONE
18+
grep -F -w -v 'R_RISCV_RELATIVE
19+
R_RISCV_NONE'
1820
)
1921

2022
if [ -z "$bad_relocs" ]; then

drivers/acpi/riscv/cppc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ static int __init sbi_cppc_init(void)
3737
{
3838
if (sbi_spec_version >= sbi_mk_version(2, 0) &&
3939
sbi_probe_extension(SBI_EXT_CPPC) > 0) {
40-
pr_info("SBI CPPC extension detected\n");
4140
cppc_ext_present = true;
4241
} else {
43-
pr_info("SBI CPPC extension NOT detected!!\n");
4442
cppc_ext_present = false;
4543
}
4644

0 commit comments

Comments
 (0)