Re: [PATCH] LoongArch: Fix off-by-one in bt_address() exception vector check
From: Tiezhu Yang
Date: Tue Nov 24 2026 - 21:21:39 EST
On 11/22/26 2:13 AM, hanbings wrote:
Hi Tiezhu,
Thanks for looking at this. I can reproduce it deterministically on
QEMU with vanilla v7.2.9; the machine here runs 7.2.9, so I used the
same version for the test.
I tested this patch on physical machines with the following small
debug code:
diff --git a/arch/loongarch/kernel/traps.c b/arch/loongarch/kernel/traps.c
index 20ce2c8d77a1..1dfeb8ecfb76 100644
--- a/arch/loongarch/kernel/traps.c
+++ b/arch/loongarch/kernel/traps.c
@@ -1113,6 +1113,11 @@ asmlinkage void noinstr do_vint(struct pt_regs *regs, unsigned long sp)
register unsigned long stack;
irqentry_state_t state = irqentry_enter(regs);
+ if (regs->csr_estat & BIT(INT_AVEC)) {
+ pr_info_once("AVEC interrupt triggered!\n");
+ DO_ONCE_LITE(dump_stack);
+ }
+
cpu = smp_processor_id();
if (on_irq_stack(cpu, sp))
I could not reproduce this issue on a Loongson-3A6000 where AVEC is
not enabled by firmware, but I reproduced it on a Loongson-3C6000
with AVEC enabled.
With this patch applied, the issue completely disappears under the
exact same test.
Before:
$ dmesg -t | grep "AVEC interrupt triggered"
AVEC interrupt triggered!
$ dmesg -t | grep -A 4 "Call Trace"
Call Trace:
[<9000000000c97f48>] show_stack+0xf8/0x1c0
[<9000000000c90b2c>] dump_stack_lvl+0x6c/0x9c
[<900000000241b638>] do_vint+0xf8/0x120
cannot find unwind pc at 9000000100979d54
After:
$ dmesg -t | grep "AVEC interrupt triggered"
AVEC interrupt triggered!
$ dmesg -t | grep -A 11 "Call Trace"
Call Trace:
[<9000000000867f48>] show_stack+0xf8/0x1c0
[<9000000000860b2c>] dump_stack_lvl+0x6c/0x9c
[<9000000001feb638>] do_vint+0xf8/0x120
[<9000000000865914>] handle_vint+0x154/0x1f4
[<9000000001fee14c>] idle_exit+0x0/0x4
[<9000000001fee158>] arch_cpu_idle+0x8/0x30
[<9000000001fee218>] default_idle_call+0x18/0x60
[<90000000008fceb8>] do_idle+0xb8/0x180
[<90000000008fd1e4>] cpu_startup_entry+0x34/0x40
[<9000000000874e30>] start_secondary+0xd0/0xe0
[<9000000001fef1b4>] smpboot_entry+0x8c/0x98
Thanks for the fix! One small nit: please use your real name for
"From:" and "Signed-off-by:".
Other than that, feel free to add:
Reviewed-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
Tested-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
Thanks,
Tiezhu