Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+82 -45
-1
arch/riscv/Makefile
··· 6 6 # for more details. 7 7 # 8 8 9 - OBJCOPYFLAGS := -O binary 10 9 LDFLAGS_vmlinux := -z norelro 11 10 ifeq ($(CONFIG_RELOCATABLE),y) 12 11 LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
+4
arch/riscv/errata/andes/Makefile
··· 1 + ifdef CONFIG_RISCV_ALTERNATIVE_EARLY 2 + CFLAGS_errata.o := -mcmodel=medany 3 + endif 4 + 1 5 obj-y += errata.o
+21
arch/riscv/include/asm/ftrace.h
··· 31 31 return addr; 32 32 } 33 33 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 + 34 55 struct dyn_arch_ftrace { 35 56 }; 36 57 #endif
+9
arch/riscv/include/asm/kprobes.h
··· 40 40 int kprobe_fault_handler(struct pt_regs *regs, unsigned int trapnr); 41 41 bool kprobe_breakpoint_handler(struct pt_regs *regs); 42 42 bool kprobe_single_step_handler(struct pt_regs *regs); 43 + #else 44 + static inline bool kprobe_breakpoint_handler(struct pt_regs *regs) 45 + { 46 + return false; 47 + } 43 48 49 + static inline bool kprobe_single_step_handler(struct pt_regs *regs) 50 + { 51 + return false; 52 + } 44 53 #endif /* CONFIG_KPROBES */ 45 54 #endif /* _ASM_RISCV_KPROBES_H */
+11
arch/riscv/include/asm/uprobes.h
··· 34 34 bool simulate; 35 35 }; 36 36 37 + #ifdef CONFIG_UPROBES 37 38 bool uprobe_breakpoint_handler(struct pt_regs *regs); 38 39 bool uprobe_single_step_handler(struct pt_regs *regs); 40 + #else 41 + static inline bool uprobe_breakpoint_handler(struct pt_regs *regs) 42 + { 43 + return false; 44 + } 39 45 46 + static inline bool uprobe_single_step_handler(struct pt_regs *regs) 47 + { 48 + return false; 49 + } 50 + #endif /* CONFIG_UPROBES */ 40 51 #endif /* _ASM_RISCV_UPROBES_H */
+2 -2
arch/riscv/kernel/irq.c
··· 60 60 } 61 61 #endif /* CONFIG_VMAP_STACK */ 62 62 63 - #ifdef CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK 63 + #ifdef CONFIG_SOFTIRQ_ON_OWN_STACK 64 64 void do_softirq_own_stack(void) 65 65 { 66 66 #ifdef CONFIG_IRQ_STACKS ··· 92 92 #endif 93 93 __do_softirq(); 94 94 } 95 - #endif /* CONFIG_HAVE_SOFTIRQ_ON_OWN_STACK */ 95 + #endif /* CONFIG_SOFTIRQ_ON_OWN_STACK */ 96 96 97 97 #else 98 98 static void init_irq_stacks(void) {}
-13
arch/riscv/kernel/setup.c
··· 173 173 if (ret < 0) 174 174 goto error; 175 175 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 - 189 176 #ifdef CONFIG_CRASH_DUMP 190 177 if (elfcorehdr_size > 0) { 191 178 elfcorehdr_res.start = elfcorehdr_addr;
-7
arch/riscv/kernel/signal.c
··· 311 311 /* Align the stack frame. */ 312 312 sp &= ~0xfUL; 313 313 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 - 321 314 return (void __user *)sp; 322 315 } 323 316
+18 -10
arch/riscv/kernel/traps.c
··· 13 13 #include <linux/kdebug.h> 14 14 #include <linux/uaccess.h> 15 15 #include <linux/kprobes.h> 16 + #include <linux/uprobes.h> 17 + #include <asm/uprobes.h> 16 18 #include <linux/mm.h> 17 19 #include <linux/module.h> 18 20 #include <linux/irq.h> ··· 249 247 return GET_INSN_LENGTH(insn); 250 248 } 251 249 250 + static bool probe_single_step_handler(struct pt_regs *regs) 251 + { 252 + bool user = user_mode(regs); 253 + 254 + return user ? uprobe_single_step_handler(regs) : kprobe_single_step_handler(regs); 255 + } 256 + 257 + static bool probe_breakpoint_handler(struct pt_regs *regs) 258 + { 259 + bool user = user_mode(regs); 260 + 261 + return user ? uprobe_breakpoint_handler(regs) : kprobe_breakpoint_handler(regs); 262 + } 263 + 252 264 void handle_break(struct pt_regs *regs) 253 265 { 254 - #ifdef CONFIG_KPROBES 255 - if (kprobe_single_step_handler(regs)) 266 + if (probe_single_step_handler(regs)) 256 267 return; 257 268 258 - if (kprobe_breakpoint_handler(regs)) 259 - return; 260 - #endif 261 - #ifdef CONFIG_UPROBES 262 - if (uprobe_single_step_handler(regs)) 269 + if (probe_breakpoint_handler(regs)) 263 270 return; 264 271 265 - if (uprobe_breakpoint_handler(regs)) 266 - return; 267 - #endif 268 272 current->thread.bad_cause = regs->cause; 269 273 270 274 if (user_mode(regs))
+2 -1
drivers/perf/riscv_pmu.c
··· 23 23 return ((event->attr.type == PERF_TYPE_HARDWARE) || 24 24 (event->attr.type == PERF_TYPE_HW_CACHE) || 25 25 (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); 27 28 } 28 29 29 30 void arch_perf_update_userpage(struct perf_event *event,
+10 -6
drivers/perf/riscv_pmu_sbi.c
··· 510 510 { 511 511 struct perf_event *event = (struct perf_event *)arg; 512 512 513 - csr_write(CSR_SCOUNTEREN, 514 - csr_read(CSR_SCOUNTEREN) | (1 << pmu_sbi_csr_index(event))); 513 + if (event->hw.idx != -1) 514 + csr_write(CSR_SCOUNTEREN, 515 + csr_read(CSR_SCOUNTEREN) | (1 << pmu_sbi_csr_index(event))); 515 516 } 516 517 517 518 static void pmu_sbi_reset_scounteren(void *arg) 518 519 { 519 520 struct perf_event *event = (struct perf_event *)arg; 520 521 521 - csr_write(CSR_SCOUNTEREN, 522 - csr_read(CSR_SCOUNTEREN) & ~(1 << pmu_sbi_csr_index(event))); 522 + if (event->hw.idx != -1) 523 + csr_write(CSR_SCOUNTEREN, 524 + csr_read(CSR_SCOUNTEREN) & ~(1 << pmu_sbi_csr_index(event))); 523 525 } 524 526 525 527 static void pmu_sbi_ctr_start(struct perf_event *event, u64 ival) ··· 543 541 544 542 if ((hwc->flags & PERF_EVENT_FLAG_USER_ACCESS) && 545 543 (hwc->flags & PERF_EVENT_FLAG_USER_READ_CNT)) 546 - pmu_sbi_set_scounteren((void *)event); 544 + on_each_cpu_mask(mm_cpumask(event->owner->mm), 545 + pmu_sbi_set_scounteren, (void *)event, 1); 547 546 } 548 547 549 548 static void pmu_sbi_ctr_stop(struct perf_event *event, unsigned long flag) ··· 554 551 555 552 if ((hwc->flags & PERF_EVENT_FLAG_USER_ACCESS) && 556 553 (hwc->flags & PERF_EVENT_FLAG_USER_READ_CNT)) 557 - pmu_sbi_reset_scounteren((void *)event); 554 + on_each_cpu_mask(mm_cpumask(event->owner->mm), 555 + pmu_sbi_reset_scounteren, (void *)event, 1); 558 556 559 557 ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP, hwc->idx, 1, flag, 0, 0, 0); 560 558 if (ret.error && (ret.error != SBI_ERR_ALREADY_STOPPED) &&
+3 -3
tools/testing/selftests/riscv/mm/Makefile
··· 5 5 # Additional include paths needed by kselftest.h and local headers 6 6 CFLAGS += -D_GNU_SOURCE -std=gnu99 -I. 7 7 8 - TEST_GEN_FILES := testcases/mmap_default testcases/mmap_bottomup 8 + TEST_GEN_FILES := mmap_default mmap_bottomup 9 9 10 - TEST_PROGS := testcases/run_mmap.sh 10 + TEST_PROGS := run_mmap.sh 11 11 12 12 include ../../lib.mk 13 13 14 - $(OUTPUT)/mm: testcases/mmap_default.c testcases/mmap_bottomup.c testcases/mmap_tests.h 14 + $(OUTPUT)/mm: mmap_default.c mmap_bottomup.c mmap_tests.h 15 15 $(CC) -o$@ $(CFLAGS) $(LDFLAGS) $^
+1 -1
tools/testing/selftests/riscv/mm/testcases/mmap_bottomup.c tools/testing/selftests/riscv/mm/mmap_bottomup.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 #include <sys/mman.h> 3 - #include <testcases/mmap_test.h> 3 + #include <mmap_test.h> 4 4 5 5 #include "../../kselftest_harness.h" 6 6
+1 -1
tools/testing/selftests/riscv/mm/testcases/mmap_default.c tools/testing/selftests/riscv/mm/mmap_default.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-only 2 2 #include <sys/mman.h> 3 - #include <testcases/mmap_test.h> 3 + #include <mmap_test.h> 4 4 5 5 #include "../../kselftest_harness.h" 6 6
tools/testing/selftests/riscv/mm/testcases/mmap_test.h tools/testing/selftests/riscv/mm/mmap_test.h
tools/testing/selftests/riscv/mm/testcases/run_mmap.sh tools/testing/selftests/riscv/mm/run_mmap.sh