Skip to content

Commit b82fbd8

Browse files
committed
Merge tag 'riscv-for-linus-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: - A handful of build fixes - A fix to avoid mixing up user/kernel-mode breakpoints, which can manifest as a hang when mixing k/uprobes with other breakpoint sources - A fix to avoid double-allocting crash kernel memory - A fix for tracefs syscall name mangling, which was causing syscalls not to show up in tracefs - A fix to the perf driver to enable the hw events when selected, which can trigger a BUG on some userspace access patterns * tag 'riscv-for-linus-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: drivers: perf: Fix panic in riscv SBI mmap support riscv: Fix ftrace syscall handling which are now prefixed with __riscv_ RISC-V: Fix wrong use of CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK riscv: kdump: fix crashkernel reserving problem on RISC-V riscv: Remove duplicate objcopy flag riscv: signal: fix sigaltstack frame size checking riscv: errata: andes: Makefile: Fix randconfig build issue riscv: Only consider swbp/ss handlers for correct privileged mode riscv: kselftests: Fix mm build by removing testcases subdirectory
2 parents 17325a2 + 3fec323 commit b82fbd8

File tree

16 files changed

+84
-47
lines changed

16 files changed

+84
-47
lines changed

arch/riscv/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
# for more details.
77
#
88

9-
OBJCOPYFLAGS := -O binary
109
LDFLAGS_vmlinux := -z norelro
1110
ifeq ($(CONFIG_RELOCATABLE),y)
1211
LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs

arch/riscv/errata/andes/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
ifdef CONFIG_RISCV_ALTERNATIVE_EARLY
2+
CFLAGS_errata.o := -mcmodel=medany
3+
endif
4+
15
obj-y += errata.o

arch/riscv/include/asm/ftrace.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,27 @@ static inline unsigned long ftrace_call_adjust(unsigned long addr)
3131
return addr;
3232
}
3333

34+
/*
35+
* Let's do like x86/arm64 and ignore the compat syscalls.
36+
*/
37+
#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
38+
static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
39+
{
40+
return is_compat_task();
41+
}
42+
43+
#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
44+
static inline bool arch_syscall_match_sym_name(const char *sym,
45+
const char *name)
46+
{
47+
/*
48+
* Since all syscall functions have __riscv_ prefix, we must skip it.
49+
* However, as we described above, we decided to ignore compat
50+
* syscalls, so we don't care about __riscv_compat_ prefix here.
51+
*/
52+
return !strcmp(sym + 8, name);
53+
}
54+
3455
struct dyn_arch_ftrace {
3556
};
3657
#endif

arch/riscv/include/asm/kprobes.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ void arch_remove_kprobe(struct kprobe *p);
4040
int kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr);
4141
bool kprobe_breakpoint_handler(struct pt_regs *regs);
4242
bool kprobe_single_step_handler(struct pt_regs *regs);
43-
43+
#else
44+
static inline bool kprobe_breakpoint_handler(struct pt_regs *regs)
45+
{
46+
return false;
47+
}
48+
49+
static inline bool kprobe_single_step_handler(struct pt_regs *regs)
50+
{
51+
return false;
52+
}
4453
#endif /* CONFIG_KPROBES */
4554
#endif /* _ASM_RISCV_KPROBES_H */

arch/riscv/include/asm/uprobes.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ struct arch_uprobe {
3434
bool simulate;
3535
};
3636

37+
#ifdef CONFIG_UPROBES
3738
bool uprobe_breakpoint_handler(struct pt_regs *regs);
3839
bool uprobe_single_step_handler(struct pt_regs *regs);
39-
40+
#else
41+
static inline bool uprobe_breakpoint_handler(struct pt_regs *regs)
42+
{
43+
return false;
44+
}
45+
46+
static inline bool uprobe_single_step_handler(struct pt_regs *regs)
47+
{
48+
return false;
49+
}
50+
#endif /* CONFIG_UPROBES */
4051
#endif /* _ASM_RISCV_UPROBES_H */

arch/riscv/kernel/irq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static void init_irq_stacks(void)
6060
}
6161
#endif /* CONFIG_VMAP_STACK */
6262

63-
#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK
63+
#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
6464
void do_softirq_own_stack(void)
6565
{
6666
#ifdef CONFIG_IRQ_STACKS
@@ -92,7 +92,7 @@ void do_softirq_own_stack(void)
9292
#endif
9393
__do_softirq();
9494
}
95-
#endif /* CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK */
95+
#endif /* CONFIG_SOFTIRQ_ON_OWN_STACK */
9696

9797
#else
9898
static void init_irq_stacks(void) {}

arch/riscv/kernel/setup.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,6 @@ static void __init init_resources(void)
173173
if (ret < 0)
174174
goto error;
175175

176-
#ifdef CONFIG_KEXEC_CORE
177-
if (crashk_res.start != crashk_res.end) {
178-
ret = add_resource(&iomem_resource, &crashk_res);
179-
if (ret < 0)
180-
goto error;
181-
}
182-
if (crashk_low_res.start != crashk_low_res.end) {
183-
ret = add_resource(&iomem_resource, &crashk_low_res);
184-
if (ret < 0)
185-
goto error;
186-
}
187-
#endif
188-
189176
#ifdef CONFIG_CRASH_DUMP
190177
if (elfcorehdr_size > 0) {
191178
elfcorehdr_res.start = elfcorehdr_addr;

arch/riscv/kernel/signal.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ static inline void __user *get_sigframe(struct ksignal *ksig,
311311
/* Align the stack frame. */
312312
sp &= ~0xfUL;
313313

314-
/*
315-
* Fail if the size of the altstack is not large enough for the
316-
* sigframe construction.
317-
*/
318-
if (current->sas_ss_size && sp < current->sas_ss_sp)
319-
return (void __user __force *)-1UL;
320-
321314
return (void __user *)sp;
322315
}
323316

arch/riscv/kernel/traps.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/kdebug.h>
1414
#include <linux/uaccess.h>
1515
#include <linux/kprobes.h>
16+
#include <linux/uprobes.h>
17+
#include <asm/uprobes.h>
1618
#include <linux/mm.h>
1719
#include <linux/module.h>
1820
#include <linux/irq.h>
@@ -247,22 +249,28 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
247249
return GET_INSN_LENGTH(insn);
248250
}
249251

252+
static bool probe_single_step_handler(struct pt_regs *regs)
253+
{
254+
bool user = user_mode(regs);
255+
256+
return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs);
257+
}
258+
259+
static bool probe_breakpoint_handler(struct pt_regs *regs)
260+
{
261+
bool user = user_mode(regs);
262+
263+
return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs);
264+
}
265+
250266
void handle_break(struct pt_regs *regs)
251267
{
252-
#ifdef CONFIG_KPROBES
253-
if (kprobe_single_step_handler(regs))
268+
if (probe_single_step_handler(regs))
254269
return;
255270

256-
if (kprobe_breakpoint_handler(regs))
257-
return;
258-
#endif
259-
#ifdef CONFIG_UPROBES
260-
if (uprobe_single_step_handler(regs))
271+
if (probe_breakpoint_handler(regs))
261272
return;
262273

263-
if (uprobe_breakpoint_handler(regs))
264-
return;
265-
#endif
266274
current->thread.bad_cause = regs->cause;
267275

268276
if (user_mode(regs))

drivers/perf/riscv_pmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ static bool riscv_perf_user_access(struct perf_event *event)
2323
return ((event->attr.type == PERF_TYPE_HARDWARE) ||
2424
(event->attr.type == PERF_TYPE_HW_CACHE) ||
2525
(event->attr.type == PERF_TYPE_RAW)) &&
26-
!!(event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT);
26+
!!(event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT) &&
27+
(event->hw.idx != -1);
2728
}
2829

2930
void arch_perf_update_userpage(struct perf_event *event,

0 commit comments

Comments
 (0)