linux/arch/riscv/kernel
Sergey Matyukevich a638b0461b
riscv: prevent pt_regs corruption for secondary idle threads
Top of the kernel thread stack should be reserved for pt_regs. However
this is not the case for the idle threads of the secondary boot harts.
Their stacks overlap with their pt_regs, so both may get corrupted.

Similar issue has been fixed for the primary hart, see c7cdd96eca
("riscv: prevent stack corruption by reserving task_pt_regs(p) early").
However that fix was not propagated to the secondary harts. The problem
has been noticed in some CPU hotplug tests with V enabled. The function
smp_callin stored several registers on stack, corrupting top of pt_regs
structure including status field. As a result, kernel attempted to save
or restore inexistent V context.

Fixes: 9a2451f186 ("RISC-V: Avoid using per cpu array for ordered booting")
Fixes: 2875fe0561 ("RISC-V: Add cpu_ops and modify default booting method")
Signed-off-by: Sergey Matyukevich <sergey.matyukevich@syntacore.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20240523084327.2013211-1-geomatsi@gmail.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2024-05-30 09:42:51 -07:00
..
compat_vdso Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
pi Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
probes The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
tests treewide: replace or remove redundant def_bool in Kconfig files 2024-02-20 20:47:45 +09:00
vdso Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
acpi.c RISC-V: ACPI: Enhance acpi_os_ioremap with MMIO remapping 2023-10-26 09:40:31 -07:00
alternative.c riscv: errata: Rename defines for Andes 2024-03-12 07:13:12 -07:00
asm-offsets.c ftrace: riscv: move from REGS to ARGS 2024-05-22 16:12:48 -07:00
cacheinfo.c RISC-V Patches for the 6.4 Merge Window, Part 1 2023-04-28 16:55:39 -07:00
cfi.c bpf, riscv64/cfi: Support kCFI + BPF on riscv64 2024-03-06 15:18:16 -08:00
compat_signal.c riscv: compat: signal: Add rt_frame implementation 2022-05-17 16:37:21 -07:00
compat_syscall_table.c riscv: Implement syscall wrappers 2023-08-23 14:16:36 -07:00
copy-unaligned.h RISC-V: Probe for unaligned access speed 2023-09-01 09:06:25 -07:00
copy-unaligned.S riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
cpu_ops_sbi.c riscv: prevent pt_regs corruption for secondary idle threads 2024-05-30 09:42:51 -07:00
cpu_ops_spinwait.c riscv: prevent pt_regs corruption for secondary idle threads 2024-05-30 09:42:51 -07:00
cpu_ops.c riscv: Use the same CPU operations for all CPUs 2024-01-04 15:03:07 -08:00
cpu-hotplug.c riscv: Use the same CPU operations for all CPUs 2024-01-04 15:03:07 -08:00
cpu.c riscv: cpufeature: Fix thead vector hwcap removal 2024-05-22 09:41:02 -07:00
cpufeature.c riscv: cpufeature: Fix extension subset checking 2024-05-22 09:41:03 -07:00
crash_dump.c vmcore: convert copy_oldmem_page() to take an iov_iter 2022-04-29 14:37:59 -07:00
crash_save_regs.S RISC-V: Fixup get incorrect user mode PC for kernel mode regs 2022-08-11 08:54:40 -07:00
efi-header.S riscv: Prepare EFI header for relocatable kernels 2023-04-19 07:46:28 -07:00
efi.c riscv: Use accessors to page table entries instead of direct dereference 2023-12-20 10:48:15 -08:00
elf_kexec.c fix missing vmalloc.h includes 2024-04-25 20:55:49 -07:00
entry.S riscv: blacklist assembly symbols for kprobe 2024-01-24 15:59:42 -08:00
fpu.S riscv: typo in comment for get_f64_reg 2024-05-22 16:12:53 -07:00
ftrace.c riscv: Fix early ftrace nop patching 2024-05-23 08:22:17 -07:00
head.h riscv: entry: Convert to generic entry 2023-03-23 08:47:00 -07:00
head.S Merge patch series "Fix XIP boot and make XIP testable in QEMU" 2024-01-09 20:10:39 -08:00
hibernate-asm.S riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
hibernate.c riscv: hibernate: remove WARN_ON in save_processor_state 2023-06-23 10:06:22 -07:00
image-vars.h efi: move screen_info into efi init code 2023-10-17 16:33:39 +02:00
irq.c Merge patch "drivers: perf: Do not broadcast to other cpus when starting a counter" 2023-11-09 06:44:13 -08:00
jump_label.c jump_label: make initial NOP patching the special case 2022-06-24 09:48:55 +02:00
kernel_mode_fpu.c riscv: add support for kernel-mode FPU 2024-05-19 14:36:19 -07:00
kernel_mode_vector.c riscv: vector: allow kernel-mode Vector with preemption 2024-01-16 07:14:02 -08:00
kexec_relocate.S riscv: kexec: Cleanup riscv_kexec_relocate 2023-09-20 02:53:29 -07:00
kgdb.c RISC-V: rename parse_asm.h to insn.h 2022-12-29 06:59:47 -08:00
machine_kexec_file.c RISC-V: Add kexec_file support 2022-05-19 12:14:18 -07:00
machine_kexec.c kexec_file, riscv: print out debugging message if required 2023-12-20 15:02:57 -08:00
Makefile riscv: add support for kernel-mode FPU 2024-05-19 14:36:19 -07:00
mcount-dyn.S ftrace: riscv: move from REGS to ARGS 2024-05-22 16:12:48 -07:00
mcount.S riscv: remove MCOUNT_NAME workaround 2024-02-22 15:38:54 -08:00
module-sections.c riscv: add missing header file includes 2019-10-28 00:46:01 -07:00
module.c arch: make execmem setup available regardless of CONFIG_MODULES 2024-05-14 00:31:44 -07:00
paravirt.c RISC-V: KVM: Rename the SBI_STA_SHMEM_DISABLE to a generic name 2024-04-22 11:13:52 +05:30
patch.c RISC-V Patches for the 6.10 Merge Window, Part 1 2024-05-22 09:56:00 -07:00
perf_callchain.c riscv: Fix fill_callchain return value 2022-03-30 23:01:42 -07:00
perf_regs.c perf/arch: Remove perf_sample_data::regs_user_copy 2020-11-09 18:12:34 +01:00
process.c riscv: process: Fix kernel gp leakage 2024-04-04 12:35:05 -07:00
ptrace.c Merge patch series "riscv: Introduce compat-mode helpers & improve arch_get_mmap_end()" 2024-03-20 08:56:05 -07:00
reset.c riscv: Use do_kernel_power_off() 2022-05-19 19:30:30 +02:00
return_address.c riscv: add CALLER_ADDRx support 2024-02-22 12:17:47 -08:00
riscv_ksyms.c RISC-V: add infrastructure to allow different str* implementations 2023-01-31 11:43:23 -08:00
sbi-ipi.c riscv: Use IPIs for remote cache/TLB flushes by default 2024-04-29 10:49:26 -07:00
sbi.c RISC-V: Add SBI debug console helper routines 2024-01-10 07:04:03 -08:00
setup.c Driver core changes for 6.8-rc1 2024-01-18 09:48:40 -08:00
signal.c riscv: Fix vector state restore in rt_sigreturn() 2024-04-03 16:10:25 -07:00
smp.c riscv: Use IPIs for remote cache/TLB flushes by default 2024-04-29 10:49:26 -07:00
smpboot.c Use bool value in set_cpu_online() 2024-05-22 16:12:52 -07:00
soc.c riscv: Fix builtin DTB handling 2021-01-07 19:00:50 -08:00
stacktrace.c riscv: stacktrace: fixed walk_stackframe() 2024-05-22 16:12:49 -07:00
suspend_entry.S riscv: Use SYM_*() assembly macros instead of deprecated ones 2023-11-06 09:42:47 -08:00
suspend.c riscv: Do not save the scratch CSR during suspend 2024-04-28 14:50:36 -07:00
sys_hwprobe.c riscv: hwprobe: export Zihintpause ISA extension 2024-04-28 14:50:38 -07:00
sys_riscv.c riscv: remove unused header 2024-03-27 07:23:23 -07:00
syscall_table.c riscv: Implement syscall wrappers 2023-08-23 14:16:36 -07:00
time.c RISC-V: paravirt: Add skeleton for pv-time support 2023-12-30 11:25:03 +05:30
traps_misaligned.c riscv: misaligned: remove CONFIG_RISCV_M_MODE specific code 2024-04-28 14:50:37 -07:00
traps.c riscv: use KERN_INFO in do_trap 2024-04-04 12:12:14 -07:00
unaligned_access_speed.c riscv: Use kcalloc() instead of kzalloc() 2024-03-20 08:56:07 -07:00
vdso.c riscv: vdso: Use generic union vdso_data_store 2024-02-20 20:56:00 +01:00
vector.c riscv: vector: allow kernel-mode Vector with preemption 2024-01-16 07:14:02 -08:00
vmcore_info.c crash: split vmcoreinfo exporting code out from crash_core.c 2024-02-23 17:48:22 -08:00
vmlinux-xip.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-09 10:58:59 -08:00
vmlinux.lds.S riscv: Check if the code to patch lies in the exit section 2024-01-09 10:58:59 -08:00