]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/riscv: Fix SSP CSR error handling in VU/VS mode
authorJim Shu <jim.shu@sifive.com>
Wed, 24 Sep 2025 07:48:17 +0000 (15:48 +0800)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 15 Oct 2025 20:27:03 +0000 (23:27 +0300)
In VU/VS mode, accessing $ssp CSR will trigger the virtual instruction
exception instead of illegal instruction exception if SSE is disabled
via xenvcfg CSRs.

This is from RISC-V CFI v1.0 spec ch2.2.4. Shadow Stack Pointer

Signed-off-by: Jim Shu <jim.shu@sifive.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20250924074818.230010-3-jim.shu@sifive.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit 84c1605b7606d810ded4c1c3a2717f158dc89e3f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
target/riscv/csr.c

index 76e2f7e1d5cc575c71d2cf83953e345074348d88..76e77ae2d19b8cd228a630e0a4033b7dbd32e17a 100644 (file)
@@ -202,6 +202,8 @@ static RISCVException cfi_ss(CPURISCVState *env, int csrno)
 #if !defined(CONFIG_USER_ONLY)
         if (env->debugger) {
             return RISCV_EXCP_NONE;
+        } else if (env->virt_enabled) {
+            return RISCV_EXCP_VIRT_INSTRUCTION_FAULT;
         }
 #endif
         return RISCV_EXCP_ILLEGAL_INST;