sst-linux/arch/riscv/kernel
Nam Cao c21df31fc2 riscv: Fix sleeping in invalid context in die()
commit 6a97f4118ac07cfdc316433f385dbdc12af5025e upstream.

die() can be called in exception handler, and therefore cannot sleep.
However, die() takes spinlock_t which can sleep with PREEMPT_RT enabled.
That causes the following warning:

BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 285, name: mutex
preempt_count: 110001, expected: 0
RCU nest depth: 0, expected: 0
CPU: 0 UID: 0 PID: 285 Comm: mutex Not tainted 6.12.0-rc7-00022-ge19049cf7d56-dirty #234
Hardware name: riscv-virtio,qemu (DT)
Call Trace:
    dump_backtrace+0x1c/0x24
    show_stack+0x2c/0x38
    dump_stack_lvl+0x5a/0x72
    dump_stack+0x14/0x1c
    __might_resched+0x130/0x13a
    rt_spin_lock+0x2a/0x5c
    die+0x24/0x112
    do_trap_insn_illegal+0xa0/0xea
    _new_vmalloc_restore_context_a0+0xcc/0xd8
Oops - illegal instruction [#1]

Switch to use raw_spinlock_t, which does not sleep even with PREEMPT_RT
enabled.

Fixes: 76d2a0493a ("RISC-V: Init and Halt Code")
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
Reviewed-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20241118091333.1185288-1-namcao@linutronix.de
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-17 13:34:42 +01:00
..
compat_vdso
probes
vdso riscv: vdso: Prevent the compiler from inserting calls to memset() 2024-11-08 16:26:45 +01:00
.gitignore
alternative.c
asm-offsets.c riscv: Remove unused GENERATING_ASM_OFFSETS 2024-11-08 16:26:45 +01:00
cacheinfo.c
compat_signal.c
compat_syscall_table.c
cpu_ops_sbi.c riscv: prevent pt_regs corruption for secondary idle threads 2024-06-12 11:03:59 +02:00
cpu_ops_spinwait.c riscv: prevent pt_regs corruption for secondary idle threads 2024-06-12 11:03:59 +02:00
cpu_ops.c
cpu-hotplug.c riscv: Use '%u' to format the output of 'cpu' 2024-11-08 16:26:45 +01:00
cpu.c
cpufeature.c
crash_dump.c
crash_save_regs.S
efi-header.S riscv: efi: Set NX compat flag in PE/COFF header 2024-11-08 16:26:45 +01:00
efi.c
elf_kexec.c riscv/kexec_file: Fix relocation type R_RISCV_ADD16 and R_RISCV_SUB16 unknown 2024-10-17 15:22:15 +02:00
entry.S
fpu.S
ftrace.c
head.h
head.S riscv: set trap vector earlier 2024-09-12 11:10:24 +02:00
image-vars.h
irq.c
jump_label.c
kexec_relocate.S
kgdb.c
machine_kexec_file.c
machine_kexec.c riscv: kexec: Avoid deadlock in kexec crash path 2024-07-11 12:47:12 +02:00
Makefile
mcount-dyn.S
mcount.S
module-sections.c
module.c
patch.c
perf_callchain.c riscv: Fix fp alignment bug in perf_callchain_user() 2024-10-17 15:21:07 +02:00
perf_regs.c
process.c
ptrace.c
reset.c
return_address.c
riscv_ksyms.c
sbi.c
setup.c
signal.c riscv: signal: handle syscall restart before get_signal 2024-06-16 13:41:31 +02:00
smp.c
smpboot.c
soc.c
stacktrace.c riscv: stacktrace: fix usage of ftrace_graph_ret_addr() 2024-07-25 09:49:19 +02:00
suspend_entry.S
suspend.c
sys_riscv.c
syscall_table.c
time.c
trace_irq.c
trace_irq.h
traps_misaligned.c riscv: Remove duplicated GET_RM 2024-11-08 16:26:46 +01:00
traps.c riscv: Fix sleeping in invalid context in die() 2025-01-17 13:34:42 +01:00
vdso.c
vmlinux-xip.lds.S
vmlinux.lds.S