lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0059c5f2-afe3-3100-4f9e-023ddf5c1fe9@loongson.cn>
Date: Wed, 21 Jan 2026 09:46:59 +0800
From: Tiezhu Yang <yangtiezhu@...ngson.cn>
To: Huacai Chen <chenhuacai@...nel.org>
Cc: loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/4] LoongArch: Handle percpu handler address in
 bt_address()

On 2026/1/20 下午9:08, Tiezhu Yang wrote:
> On 2026/1/20 下午9:01, Huacai Chen wrote:
>> On Tue, Jan 20, 2026 at 8:57 PM Tiezhu Yang <yangtiezhu@...ngson.cn> 
>> wrote:
>>>
>>> On 2026/1/20 下午8:04, Huacai Chen wrote:
>>>> Hi, Tiezhu,
>>>>
>>>> On Tue, Jan 20, 2026 at 5:23 PM Tiezhu Yang <yangtiezhu@...ngson.cn> 
>>>> wrote:
>>>>>
>>>>> After commit 4cd641a79e69 ("LoongArch: Remove unnecessary checks for
>>>>> ORC unwinder"), the system can not boot normally under some configs,
>>>>> there are many error messages "cannot find unwind pc at".
>>>
>>> ...
>>>
>>>>> +#if defined(CONFIG_NUMA) && !defined(CONFIG_PREEMPT_RT)
>>>>> +       for (int cpu = 1; cpu < num_possible_cpus(); cpu++) {
>>>> Use nr_cpu_ids instead of num_possible_cpus() can improve 
>>>> performance a little.
>>>>
>>>>> +               int vec_sz = sizeof(exception_handlers);
>>>>> +
>>>> It is better to add "if (!pcpu_handlers[cpu]) continue" here.
>>>
>>> If so, it can use for_each_possible_cpu(cpu) directly?
>> It can, but I remember you want to skip CPU 0?
> 
> Yes, that is the intention to use the for loop, but if checking
> !pcpu_handlers[cpu], I think no need to use for loop to skip cpu
> 0, just use for_each_possible_cpu(cpu) is more simple and direct.

Handle this special case only if bt_address() returns 0 to avoid
affecting performance for the normal address.

Here is the draft change:

----->8-----
diff --git a/arch/loongarch/kernel/unwind_orc.c 
b/arch/loongarch/kernel/unwind_orc.c
index d6b3688a1ce9..1ce10701f3c3 100644
--- a/arch/loongarch/kernel/unwind_orc.c
+++ b/arch/loongarch/kernel/unwind_orc.c
@@ -378,6 +378,28 @@ static inline unsigned long bt_address(unsigned 
long ra)
         return 0;
  }

+static inline unsigned long handle_pcpu_handlers(unsigned long ra)
+{
+#if defined(CONFIG_NUMA) && !defined(CONFIG_PREEMPT_RT)
+       int cpu;
+       int vec_sz __maybe_unused;
+
+       for_each_possible_cpu(cpu) {
+               if (!pcpu_handlers[cpu])
+                       continue;
+
+               vec_sz = sizeof(exception_handlers);
+
+               if (ra >= pcpu_handlers[cpu] &&
+                   ra < pcpu_handlers[cpu] + vec_sz) {
+                       ra = eentry + (ra - pcpu_handlers[cpu]);
+                       break;
+               }
+       }
+#endif
+       return ra;
+}
+
  bool unwind_next_frame(struct unwind_state *state)
  {
         unsigned long *p, pc;
@@ -494,8 +516,11 @@ bool unwind_next_frame(struct unwind_state *state)

         state->pc = bt_address(pc);
         if (!state->pc) {
-               pr_err("cannot find unwind pc at %px\n", (void *)pc);
-               goto err;
+               state->pc = bt_address(handle_pcpu_handlers(pc));
+               if (!state->pc) {
+                       pr_err("cannot find unwind pc at %px\n", (void 
*)pc);
+                       goto err;
+               }
         }

         return true;

I will test it, if it works well I will wait for more comments and
submit v2 later.

Thanks,
Tiezhu


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ