Skip to content

Commit 68444b9

Browse files
Merge patch "drivers: perf: Do not broadcast to other cpus when starting a counter"
This is really just a single patch, but since the offending fix hasn't yet made it to my for-next I'm merging it here. Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents c6e316a + 61e3d99 commit 68444b9

File tree

16 files changed

+80
-45
lines changed

16 files changed

+80
-45
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
@@ -79,7 +79,7 @@ static void init_irq_stacks(void)
7979
}
8080
#endif /* CONFIG_VMAP_STACK */
8181

82-
#ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK
82+
#ifdef CONFIG_SOFTIRQ_ON_OWN_STACK
8383
static void ___do_softirq(struct pt_regs *regs)
8484
{
8585
__do_softirq();
@@ -92,7 +92,7 @@ void do_softirq_own_stack(void)
9292
else
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_scs(void) {}

arch/riscv/kernel/setup.c

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

177-
#ifdef CONFIG_KEXEC_CORE
178-
if (crashk_res.start != crashk_res.end) {
179-
ret = add_resource(&iomem_resource, &crashk_res);
180-
if (ret < 0)
181-
goto error;
182-
}
183-
if (crashk_low_res.start != crashk_low_res.end) {
184-
ret = add_resource(&iomem_resource, &crashk_low_res);
185-
if (ret < 0)
186-
goto error;
187-
}
188-
#endif
189-
190177
#ifdef CONFIG_CRASH_DUMP
191178
if (elfcorehdr_size > 0) {
192179
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>
@@ -253,22 +255,28 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
253255
return GET_INSN_LENGTH(insn);
254256
}
255257

258+
static bool probe_single_step_handler(struct pt_regs *regs)
259+
{
260+
bool user = user_mode(regs);
261+
262+
return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs);
263+
}
264+
265+
static bool probe_breakpoint_handler(struct pt_regs *regs)
266+
{
267+
bool user = user_mode(regs);
268+
269+
return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs);
270+
}
271+
256272
void handle_break(struct pt_regs *regs)
257273
{
258-
#ifdef CONFIG_KPROBES
259-
if (kprobe_single_step_handler(regs))
274+
if (probe_single_step_handler(regs))
260275
return;
261276

262-
if (kprobe_breakpoint_handler(regs))
263-
return;
264-
#endif
265-
#ifdef CONFIG_UPROBES
266-
if (uprobe_single_step_handler(regs))
277+
if (probe_breakpoint_handler(regs))
267278
return;
268279

269-
if (uprobe_breakpoint_handler(regs))
270-
return;
271-
#endif
272280
current->thread.bad_cause = regs->cause;
273281

274282
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)