summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrail5 <andrew@rail5.org>2026-03-06 15:33:37 +0800
committerMichael Tokarev <mjt@tls.msk.ru>2026-03-13 10:16:00 +0300
commit730e6cb5547b85a84f1c5585fb0f17920559b50f (patch)
tree2cfa161975ff4d2d57f0da5cf36dac4037bf941f
parent3a7b0cd6a6051c920f17c0798ba0be970c1e8869 (diff)
downloadqemu-730e6cb5547b85a84f1c5585fb0f17920559b50f.tar.gz
qemu-730e6cb5547b85a84f1c5585fb0f17920559b50f.zip
target/loongarch: Avoid recursive PNX exception on CSR_BADI fetch
loongarch_cpu_do_interrupt() updates CSR_BADI by fetching the faulting instruction with cpu_ldl_code_mmu(). For a PNX exception (instruction fetch prohibited by NX), fetching the instruction at env->pc will fault with PNX again. This can lead to an infinite exception loop. Treat PNX like other instruction-fetch exceptions (PIF/ADEF) and do not update CSR_BADI for it. -Fixes: 410dfbf620a ("target/loongarch: Move TCG specified functions to tcg_cpu.c") Fixes: d2cba6f7cea9 ("target/loongarch: Add other core instructions support") Cc: qemu-stable@nongnu.org Signed-off-by: rail5 (Andrew S. Rightenburg) <andrew@rail5.org> Reviewed-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Song Gao <gaosong@loongson.cn> Signed-off-by: Song Gao <gaosong@loongson.cn> (cherry picked from commit db2325f79481fab87211e5a287580d753f582cb8) (Mjt: back-port to 10.1.x across v10.1.0-1187-g410dfbf620 "target/loongarch: Move TCG specified functions to tcg_cpu.c") (fixing the Fixes: tag) Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r--target/loongarch/cpu.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 266b0b97d0..b62d720258 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -198,6 +198,7 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
}
QEMU_FALLTHROUGH;
case EXCCODE_PIF:
+ case EXCCODE_PNX:
case EXCCODE_ADEF:
cause = cs->exception_index;
update_badinstr = 0;
@@ -218,7 +219,6 @@ static void loongarch_cpu_do_interrupt(CPUState *cs)
case EXCCODE_PIS:
case EXCCODE_PME:
case EXCCODE_PNR:
- case EXCCODE_PNX:
case EXCCODE_PPI:
cause = cs->exception_index;
break;