[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAAhV-H77duX-WiYsJzkJChmGHdGh5y_k6YEvLQdpDys5iLctgw@mail.gmail.com>
Date: Tue, 25 Nov 2025 17:05:04 +0800
From: Huacai Chen <chenhuacai@...nel.org>
To: Tiezhu Yang <yangtiezhu@...ngson.cn>
Cc: Xi Zhang <zhangxi@...inos.cn>, Xianglai Li <lixianglai@...ngson.cn>,
loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] LoongArch: Handle special PC in unwind_next_frame()
On Tue, Nov 25, 2025 at 4:54 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
>
> On 2025/11/25 下午4:08, Huacai Chen wrote:
> > Hi, Tiezhu,
> >
> > On Tue, Nov 25, 2025 at 2:34 PM Tiezhu Yang <yangtiezhu@...ngson.cn> wrote:
> >>
> >> When running virtual machine before testing the kernel live patching with
> >> "modprobe livepatch-sample", there is a timeout over 15 seconds, the dmesg
> >> command shows "unreliable stack" for user tasks in debug mode.
> >>
> >> The "unreliable stack" is because it can not unwind from kvm_handle_exit()
> >> to its previous frame kvm_exc_entry() due to the PC is not a valid kernel
> >> address, the root cause is that the code of kvm_exc_entry() was copied to
> >> the DMW area in kvm_loongarch_env_init(), so it should check the PC range
> >> and then finish unwinding for this special case.
> >>
> >> How to test:
> >>
> >> (1) Update kernel with LIVEPATCH
> >>
> >> git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> >> cd linux && make mrproper defconfig
> >> scripts/config -e FTRACE -e FUNCTION_TRACER \
> >> -e LIVEPATCH -e SAMPLES -m SAMPLE_LIVEPATCH
> >> make olddefconfig all -j"$(nproc)"
> >> sudo make modules_install
> >> sudo make install
> >> sudo reboot
> >>
> >> (2) Set up a VM with "-accel kvm", no need to specify kernel and initrd
> >>
> >> sudo yum -y install edk2-loongarch64 qemu
> >> qemu-system-loongarch64 -serial stdio \
> >> -machine virt -cpu la464 -smp 8 -m 4G \
> >> -bios /usr/share/edk2/loongarch64/QEMU_EFI.fd \
> >> -nodefaults -no-reboot -nographic -accel kvm
> >>
> >> (3) Test the kernel live patching
> >>
> >> cat /proc/cmdline
> >> sudo modprobe livepatch-sample
> >> cat /proc/cmdline
> >> sudo sh -c "echo 0 > /sys/kernel/livepatch/livepatch_sample/enabled"
> >> sudo rmmod livepatch_sample
> >> cat /proc/cmdline
> >> dmesg -T
> >>
> >> Cc: stable@...r.kernel.org # v6.9+
> >> Fixes: cb8a2ef0848c ("LoongArch: Add ORC stack unwinder support")
> >> Reported-by: Xi Zhang <zhangxi@...inos.cn>
> >> Reported-by: Xianglai Li <lixianglai@...ngson.cn>
> >> Signed-off-by: Tiezhu Yang <yangtiezhu@...ngson.cn>
> >> ---
> >> arch/loongarch/kernel/unwind_orc.c | 3 +++
> >> 1 file changed, 3 insertions(+)
> >>
> >> diff --git a/arch/loongarch/kernel/unwind_orc.c b/arch/loongarch/kernel/unwind_orc.c
> >> index 0d5fa64a2225..1d60a593479a 100644
> >> --- a/arch/loongarch/kernel/unwind_orc.c
> >> +++ b/arch/loongarch/kernel/unwind_orc.c
> >> @@ -506,6 +506,9 @@ bool unwind_next_frame(struct unwind_state *state)
> >> goto err;
> >> }
> >>
> >> + if (pc >= (unsigned long)_end && pc < (unsigned long)XKVRANGE)
> >> + goto end;
> > The __kernel_text_address() judgement after bt_address() do the same
> > thing exactly, so why do we need this?
>
> They are different code paths, the current path is "goto err", it will
> set state->error as true, then arch_stack_walk_reliable() will return
> -EINVAL.
>
> With this patch, the code path is "goto end" for this case, it will
> not set state->error as true, then arch_stack_walk_reliable() will
> return 0.
Then can we replace "goto err" with "goto end" at __kernel_text_address()?
Huacai
>
> Thanks,
> Tiezhu
>
Powered by blists - more mailing lists