[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c0602aa-a8bc-25b9-7d7a-467e04dbc519@loongson.cn>
Date: Wed, 26 Nov 2025 14:28:56 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Jinyang He <hejinyang@...ngson.cn>
Cc: Huacai Chen <chenhuacai@...nel.org>, 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 2025/11/26 下午2:08, Tiezhu Yang wrote:
> On 2025/11/25 下午6:52, Jinyang He wrote:
>> On 2025-11-25 14:33, Tiezhu Yang 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.
>>
>> Hi, Tiezhu,
>>
>> Since kvm_loongarch_env_init copies kvm_exc_entry which similar to how
>> trap_init copies the exception handler. We should apply the same
>> offset-based adjustment to compute the shadow PC address:
>> shadow_pc = kvm_exc_entry + (cur_pc − copied_base_address)
>> This allows the ORC unwinder to correctly locate the corresponding
>> unwind info.
>
> Thank you. I did some tests, it can unwind from kvm_handle_exit()
> to its previous frame kvm_exc_entry() only when CONFIG_KVM=y,
> but it can not unwind from kvm_handle_exit() to its previous frame
> kvm_exc_entry() when CONFIG_KVM=m because we can not get the two
> kvm address (unsigned long)kvm_exc_entry and
> (unsigned long)kvm_loongarch_ops->exc_entry
> in arch/loongarch/kernel/unwind_orc.c.
Use function pointer can get get the two kvm address
(unsigned long)kvm_exc_entry and
(unsigned long)kvm_loongarch_ops->exc_entry
in arch/loongarch/kernel/unwind_orc.c.
I will do more test and send v2 later.
Thanks,
Tiezhu
Powered by blists - more mailing lists