Skip to content

Commit 1515011

Browse files
committed
Merge tag 'riscv-for-linus-5.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: "A handful of fixes: - a fix to properly select SPARSEMEM_STATIC on rv32 - a few fixes to kprobes I don't generally like sending stuff this late, but these all seem pretty safe" * tag 'riscv-for-linus-5.12-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: keep interrupts disabled for BREAKPOINT exception riscv: kprobes/ftrace: Add recursion protection to the ftrace callback riscv: add do_page_fault and do_trap_break into the kprobes blacklist riscv: Fix spelling mistake "SPARSEMEM" to "SPARSMEM"
2 parents 06c2aac + 7ae1163 commit 1515011

5 files changed

Lines changed: 16 additions & 2 deletions

File tree

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ config ARCH_FLATMEM_ENABLE
153153
config ARCH_SPARSEMEM_ENABLE
154154
def_bool y
155155
depends on MMU
156-
select SPARSEMEM_STATIC if 32BIT && SPARSMEM
156+
select SPARSEMEM_STATIC if 32BIT && SPARSEMEM
157157
select SPARSEMEM_VMEMMAP_ENABLE if 64BIT
158158

159159
config ARCH_SELECT_MEMORY_MODEL

arch/riscv/kernel/entry.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ skip_context_tracking:
130130
*/
131131
andi t0, s1, SR_PIE
132132
beqz t0, 1f
133+
/* kprobes, entered via ebreak, must have interrupts disabled. */
134+
li t0, EXC_BREAKPOINT
135+
beq s4, t0, 1f
133136
#ifdef CONFIG_TRACE_IRQFLAGS
134137
call trace_hardirqs_on
135138
#endif

arch/riscv/kernel/probes/ftrace.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
99
struct kprobe *p;
1010
struct pt_regs *regs;
1111
struct kprobe_ctlblk *kcb;
12+
int bit;
1213

14+
bit = ftrace_test_recursion_trylock(ip, parent_ip);
15+
if (bit < 0)
16+
return;
17+
18+
preempt_disable_notrace();
1319
p = get_kprobe((kprobe_opcode_t *)ip);
1420
if (unlikely(!p) || kprobe_disabled(p))
15-
return;
21+
goto out;
1622

1723
regs = ftrace_get_regs(fregs);
1824
kcb = get_kprobe_ctlblk();
@@ -45,6 +51,9 @@ void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
4551
*/
4652
__this_cpu_write(current_kprobe, NULL);
4753
}
54+
out:
55+
preempt_enable_notrace();
56+
ftrace_test_recursion_unlock(bit);
4857
}
4958
NOKPROBE_SYMBOL(kprobe_ftrace_handler);
5059

arch/riscv/kernel/traps.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ asmlinkage __visible void do_trap_break(struct pt_regs *regs)
178178
else
179179
die(regs, "Kernel BUG");
180180
}
181+
NOKPROBE_SYMBOL(do_trap_break);
181182

182183
#ifdef CONFIG_GENERIC_BUG
183184
int is_valid_bugaddr(unsigned long pc)

arch/riscv/mm/fault.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,4 @@ asmlinkage void do_page_fault(struct pt_regs *regs)
328328
}
329329
return;
330330
}
331+
NOKPROBE_SYMBOL(do_page_fault);

0 commit comments

Comments
 (0)