From nobody Mon Jun 15 18:06:51 2026 Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B07131D61A3; Mon, 13 Apr 2026 02:23:43 +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=1776047025; cv=none; b=NFTPP6CKnptcSV95JYwb9iLDCbDKoxyHqxUMLuSj04n8Rl5XEpuzp8mXXFgwF5tL1SySSU3JeSwL20ziJaup0wq0ywk0xPqsEKKp2/vd1pZM+Vyi8QCPtKVV+jrYGFicfJfD9/LpZARJ8cRIY7p0sEFvtfiogDg9iSG1N35impM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776047025; c=relaxed/simple; bh=UrKUJXyIqt6CRvnr9X9PcME9ZRoWnWqRGGaz1dPycco=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=DQunPbdWWiFkFFyv3TdvgyQZV8biKPNNdZRYNwuJIj1+zmI1oFdBpQ0JHYoukFqTLdrB4Ofg4+RFbFiMnE2+TlutEIStnsMni0PJarKB+10SfR0Jh9zbBeieOfs9+RZEdkEuSKx/rPnQPdzeiYYcIjyer+1lJuzyGE/+qOjP9xg= 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 [223.64.68.8]) by gateway (Coremail) with SMTP id _____8BxWcKtU9xpWZskAA--.35983S3; Mon, 13 Apr 2026 10:23:41 +0800 (CST) Received: from kernelserver (unknown [223.64.68.8]) by front1 (Coremail) with SMTP id qMiowJCxmuCpU9xpU9BrAA--.48154S2; Mon, 13 Apr 2026 10:23:41 +0800 (CST) From: Huacai Chen To: Greg Kroah-Hartman , Sasha Levin , Huacai Chen Cc: Xuerui Wang , stable@vger.kernel.org, linux-kernel@vger.kernel.org, loongarch@lists.linux.dev, Tiezhu Yang , Huacai Chen Subject: [PATCH for 6.12] LoongArch: Handle percpu handler address for ORC unwinder Date: Mon, 13 Apr 2026 10:23:30 +0800 Message-ID: <20260413022330.1238394-1-chenhuacai@loongson.cn> X-Mailer: git-send-email 2.52.0 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: qMiowJCxmuCpU9xpU9BrAA--.48154S2 X-CM-SenderInfo: hfkh0x5xdftxo6or00hjvr0hdfq/ X-Coremail-Antispam: 1Uk129KBj93XoWxZr13Kw1rXw43uFWkWryrKrX_yoW5XF13pF ZFkr4DKrWrWryvvas8AFyj9r98Awn7Gw12qFWag34rCF12qa4fCrs2vrnFgFyDJ3y8XF18 Xas5G34Y9F45A3gCm3ZEXasCq-sJn29KB7ZKAUJUUUUr529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUU9Fb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2kKe7AKxVWUXVWUAwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07 AIYIkI8VC2zVCFFI0UMc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWU tVWrXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7V AKI48JMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMxCIbckI1I0E14v2 6r1Y6r17MI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17 CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF 0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIx AIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2 KfnxnUUI43ZEXa7IU89qXPUUUUU== Content-Type: text/plain; charset="utf-8" From: Tiezhu Yang After commit 4cd641a79e69 ("LoongArch: Remove unnecessary checks for ORC unwinder"), the system can not boot normally under some configs (such as enable KASAN), 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. Cc: stable@vger.kernel.org Signed-off-by: Tiezhu Yang Signed-off-by: Huacai Chen --- arch/loongarch/include/asm/setup.h | 3 +++ arch/loongarch/kernel/unwind_orc.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/loongarch/include/asm/setup.h b/arch/loongarch/include/as= m/setup.h index 3c2fb16b11b6..f81375e5e89c 100644 --- a/arch/loongarch/include/asm/setup.h +++ b/arch/loongarch/include/asm/setup.h @@ -7,6 +7,7 @@ #define _LOONGARCH_SETUP_H =20 #include +#include #include #include =20 @@ -14,6 +15,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 5f256d75ab1e..7a9bc4754474 100644 --- a/arch/loongarch/kernel/unwind_orc.c +++ b/arch/loongarch/kernel/unwind_orc.c @@ -351,6 +351,22 @@ static inline unsigned long bt_address(unsigned long r= a) { extern unsigned long eentry; =20 +#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 ra + eentry - pcpu_handlers[cpu]; + break; + } + } +#endif + if (ra >=3D eentry && ra < eentry + EXCCODE_INT_END * VECSIZE) { unsigned long func; unsigned long type =3D (ra - eentry) / VECSIZE; --=20 2.52.0