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
acpi.c
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
cfi.c bpf, riscv64/cfi: Support kCFI + BPF on riscv64 2024-03-06 15:18:16 -08:00
compat_signal.c
compat_syscall_table.c
copy-unaligned.h
copy-unaligned.S
cpu-hotplug.c
cpu.c riscv: cpufeature: Fix thead vector hwcap removal 2024-05-22 09:41:02 -07:00
cpu_ops.c
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
cpufeature.c riscv: cpufeature: Fix extension subset checking 2024-05-22 09:41:03 -07:00
crash_dump.c
crash_save_regs.S
efi-header.S
efi.c
elf_kexec.c fix missing vmalloc.h includes 2024-04-25 20:55:49 -07:00
entry.S
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
head.S
hibernate-asm.S
hibernate.c
image-vars.h
irq.c
jump_label.c
kernel_mode_fpu.c riscv: add support for kernel-mode FPU 2024-05-19 14:36:19 -07:00
kernel_mode_vector.c
kexec_relocate.S
kgdb.c
machine_kexec.c
machine_kexec_file.c
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
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
perf_regs.c
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
return_address.c riscv: add CALLER_ADDRx support 2024-02-22 12:17:47 -08:00
riscv_ksyms.c
sbi-ipi.c riscv: Use IPIs for remote cache/TLB flushes by default 2024-04-29 10:49:26 -07:00
sbi.c
setup.c
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
stacktrace.c riscv: stacktrace: fixed walk_stackframe() 2024-05-22 16:12:49 -07:00
suspend.c riscv: Do not save the scratch CSR during suspend 2024-04-28 14:50:36 -07:00
suspend_entry.S
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
time.c
traps.c riscv: use KERN_INFO in do_trap 2024-04-04 12:12:14 -07:00
traps_misaligned.c riscv: misaligned: remove CONFIG_RISCV_M_MODE specific code 2024-04-28 14:50:37 -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
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
vmlinux.lds.S