]> www.infradead.org Git - users/dwmw2/linux.git/commit
LoongArch: Use polling play_dead() when resuming from hibernation
authorHuacai Chen <chenhuacai@loongson.cn>
Sat, 8 Mar 2025 05:51:32 +0000 (13:51 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 8 Mar 2025 05:51:32 +0000 (13:51 +0800)
commitc9117434c8f7523f0b77db4c5766f5011cc94677
treea219acf341a09626a293f79e2b5bd4fb28e50aaa
parenta0d3c8bcb9206ac207c7ad3182027c6b0a1319bb
LoongArch: Use polling play_dead() when resuming from hibernation

When CONFIG_RANDOM_KMALLOC_CACHES or other randomization infrastructrue
enabled, the idle_task's stack may different between the booting kernel
and target kernel. So when resuming from hibernation, an ACTION_BOOT_CPU
IPI wakeup the idle instruction in arch_cpu_idle_dead() and jump to the
interrupt handler. But since the stack pointer is changed, the interrupt
handler cannot restore correct context.

So rename the current arch_cpu_idle_dead() to idle_play_dead(), make it
as the default version of play_dead(), and the new arch_cpu_idle_dead()
call play_dead() directly. For hibernation, implement an arch-specific
hibernate_resume_nonboot_cpu_disable() to use the polling version (idle
instruction is replace by nop, and irq is disabled) of play_dead(), i.e.
poll_play_dead(), to avoid IPI handler corrupting the idle_task's stack
when resuming from hibernation.

This solution is a little similar to commit 406f992e4a372dafbe3c ("x86 /
hibernate: Use hlt_play_dead() when resuming from hibernation").

Cc: stable@vger.kernel.org
Tested-by: Erpeng Xu <xuerpeng@uniontech.com>
Tested-by: Yuli Wang <wangyuli@uniontech.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/kernel/smp.c