mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH V3 0/2] LoongArch: KVM: fix "unreliable stack" issue
@ 2025-12-27  1:27 Xianglai Li
  2025-12-27  1:27 ` [PATCH V3 1/2] LoongArch: KVM: Compile the switch.S file directly into the kernel Xianglai Li
  2025-12-27  1:27 ` [PATCH V3 2/2] LoongArch: KVM: fix "unreliable stack" issue Xianglai Li
  0 siblings, 2 replies; 25+ messages in thread
From: Xianglai Li @ 2025-12-27  1:27 UTC (permalink / raw)
  To: loongarch, linux-kernel, kvm, lixianglai
  Cc: Huacai Chen, WANG Xuerui, Tianrui Zhao, Bibo Mao,
	Charlie Jenkins, Thomas Gleixner, stable, Tiezhu Yang

When starting multi-core loongarch virtualization on loongarch physical
machine, loading livepatch on the physical machine will cause an error
similar to the following:
[  411.686289] livepatch: klp_try_switch_task: CPU 31/KVM:3116 has an
unreliable stack

The specific test steps are as follows:
1.Start a multi-core virtual machine on a physical machine

2.Enter the following command on the physical machine to turn on the debug
switch:
  echo "file kernel/livepatch/transition.c +p"  > /sys/kernel/debug/\
dynamic_debug/control 


3.Load livepatch:
 modprobe  livepatch-sample 

Through the above steps, similar prints can be viewed in dmesg.

The reason for this issue is that the code of the kvm_exc_entry function
was copied in the function kvm_loongarch_env_init. When the cpu needs to
execute kvm_exc_entry, it will switch to the copied address for execution.
The new address of the kvm_exc_entry function cannot be recognized in ORC,
which eventually leads to the arch_stack_walk_reliable function returning
an error and printing an exception message.

To solve the above problems, we directly compile the switch.S file into
the kernel instead of the module. In this way, the function kvm_exc_entry
will no longer need to be copied.

changlog:
V3<-V2:
1.Replace the EXPORT_SYMBOL macro declaration symbol with the
EXPORT_SYMBOL_FOR_KVM macro

2.Add some comments in kvm_enter_guest

3.Place the correct pc address in era

4.Move .p2align after .text

V2<-V1:
1.Rollback the modification of function parameter types such as
kvm_save_fpu. In the asm-prototypes.h header file, only the parameter types
it depends on are included

Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Tianrui Zhao <zhaotianrui@loongson.cn>
Cc: Bibo Mao <maobibo@loongson.cn>
Cc: Charlie Jenkins <charlie@rivosinc.com>
Cc: Xianglai Li <lixianglai@loongson.cn>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: stable@vger.kernel.org
Cc: Tiezhu Yang <yangtiezhu@loongson.cn>

Xianglai Li (2):
  LoongArch: KVM: Compile the switch.S file directly into the kernel
  LoongArch: KVM: fix "unreliable stack" issue

 arch/loongarch/Kbuild                       |  2 +-
 arch/loongarch/include/asm/asm-prototypes.h | 21 +++++++++++++
 arch/loongarch/include/asm/kvm_host.h       |  3 --
 arch/loongarch/kvm/Makefile                 |  2 +-
 arch/loongarch/kvm/main.c                   | 35 ++-------------------
 arch/loongarch/kvm/switch.S                 | 32 ++++++++++++++++---
 6 files changed, 53 insertions(+), 42 deletions(-)


base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
-- 
2.39.1


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2026-04-13  3:59 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-27  1:27 [PATCH V3 0/2] LoongArch: KVM: fix "unreliable stack" issue Xianglai Li
2025-12-27  1:27 ` [PATCH V3 1/2] LoongArch: KVM: Compile the switch.S file directly into the kernel Xianglai Li
2025-12-27  1:27 ` [PATCH V3 2/2] LoongArch: KVM: fix "unreliable stack" issue Xianglai Li
2025-12-27 12:49   ` Huacai Chen
2025-12-29  1:53     ` lixianglai
2025-12-28 13:32   ` Jinyang He
2025-12-29  3:53     ` lixianglai
2025-12-29  7:10       ` Jinyang He
2025-12-29  8:50         ` Bibo Mao
2025-12-29 10:11         ` lixianglai
2025-12-29 10:41           ` Jinyang He
2025-12-30  1:18             ` Bibo Mao
2025-12-30  2:13               ` Huacai Chen
2025-12-30  2:24             ` Bibo Mao
2025-12-30  3:36               ` Jinyang He
2025-12-30  4:03                 ` Bibo Mao
2025-12-30  5:53                   ` Jinyang He
2025-12-30  6:18                     ` Bibo Mao
2026-04-08  1:23                     ` Bibo Mao
2026-04-11 14:24                       ` Huacai Chen
2026-04-13  0:58                         ` Bibo Mao
2026-04-13  3:11                           ` Huacai Chen
2026-04-13  3:56                             ` Bibo Mao
2025-12-30  7:22   ` Bibo Mao
2025-12-31  1:11     ` lixianglai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®