From nobody Tue Feb 10 09:11:06 2026 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A25B481231 for ; Wed, 21 Jan 2026 09:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768989564; cv=none; b=nEvXFv+m/W1pLXnHxJehwRZ01vdFxAn26J/kgJDGPKa1Z9wdYAeC70KWiuiRlR/9srztqigBPju9mKIDZRaC5lo+9L/pkBTu9L8JeHxzFa0eE88sEpcIsmupzARuXyHyRnV1sKIOqOZw0mnWaH2TDlaaQ2ct3XHY0Cfz2n1XyRg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768989564; c=relaxed/simple; bh=hpI05w5/xOh4Q+x+QJnh0Cb4K2FhT68HYMbjL9ism30=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D7AlzxMPdnQvjrMZv1Ufq1mZyz7+/6SwA1M8XhCmphwgAp28kbwikKKC9OxT710FgNiN1MOYPHXUpDDSEOsZy8IBkDPPbrhq6hwVJXCLWke1s7/hk2vIlClV/0zp67lShclaLtV2PggcrckbXz8aCr0MkjPT+eBFiLml1nzcafk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn; spf=pass smtp.mailfrom=loongson.cn; arc=none smtp.client-ip=114.242.206.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxmsJxo3BpCBELAA--.36005S3; Wed, 21 Jan 2026 17:59:13 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by front1 (Coremail) with SMTP id qMiowJCxvsJvo3BpdUMpAA--.17586S4; Wed, 21 Jan 2026 17:59:13 +0800 (CST) From: Tiezhu Yang To: Huacai Chen Cc: loongarch@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/4] LoongArch: Handle percpu handler address for ORC unwinder Date: Wed, 21 Jan 2026 17:59:09 +0800 Message-ID: <20260121095911.20868-3-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20260121095911.20868-1-yangtiezhu@loongson.cn> References: <20260121095911.20868-1-yangtiezhu@loongson.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowJCxvsJvo3BpdUMpAA--.17586S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBj93XoW7Cw4kWr4DKw13WF1DtrW7WrX_yoW8KFWrpF 9Fkrs8JrW0g34vva4DAFyDurn8Arn7Gw12qFsIq34ruF17Xa4fCrs7twnruFyDt3ykXF18 Xas5Ga4Y9F4YyagCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv 67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1Y6r17MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUco7KUUUUU Content-Type: text/plain; charset="utf-8" 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". The kernel boots normally with the defconfig, so no problem found out at the first time. Here is one way to reproduce: cd linux make mrproper defconfig -j"$(nproc)" scripts/config -e KASAN make olddefconfig all -j"$(nproc)" sudo make modules_install sudo make install sudo reboot The address that can not unwind is not a valid kernel address which is between "pcpu_handlers[cpu]" and "pcpu_handlers[cpu] + vec_sz" due to the code of eentry was copied to the new area of pcpu_handlers[cpu] in setup_tlb_handler(), handle this special case to get the valid address to unwind normally. Signed-off-by: Tiezhu Yang --- arch/loongarch/include/asm/setup.h | 2 ++ arch/loongarch/kernel/unwind_orc.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/arch/loongarch/include/asm/setup.h b/arch/loongarch/include/as= m/setup.h index 3c2fb16b11b6..79eb63e749f9 100644 --- a/arch/loongarch/include/asm/setup.h +++ b/arch/loongarch/include/asm/setup.h @@ -14,6 +14,8 @@ =20 extern unsigned long eentry; extern unsigned long tlbrentry; +extern unsigned long pcpu_handlers[NR_CPUS]; +extern long exception_handlers[VECSIZE * 128 / sizeof(long)]; extern char init_command_line[COMMAND_LINE_SIZE]; extern void tlb_init(int cpu); extern void cpu_cache_init(void); diff --git a/arch/loongarch/kernel/unwind_orc.c b/arch/loongarch/kernel/unw= ind_orc.c index d6b3688a1ce9..e0c0dc22eb08 100644 --- a/arch/loongarch/kernel/unwind_orc.c +++ b/arch/loongarch/kernel/unwind_orc.c @@ -351,6 +351,21 @@ EXPORT_SYMBOL_GPL(unwind_start); static inline unsigned long bt_address(unsigned long ra) { extern unsigned long eentry; +#if defined(CONFIG_NUMA) && !defined(CONFIG_PREEMPT_RT) + int cpu; + int vec_sz =3D sizeof(exception_handlers); + + for_each_possible_cpu(cpu) { + if (!pcpu_handlers[cpu]) + continue; + + if (ra >=3D pcpu_handlers[cpu] && + ra < pcpu_handlers[cpu] + vec_sz) { + ra =3D eentry + (ra - pcpu_handlers[cpu]); + break; + } + } +#endif =20 if (ra >=3D eentry && ra < eentry + EXCCODE_INT_END * VECSIZE) { unsigned long func; --=20 2.42.0