aboutsummaryrefslogtreecommitdiff
path: root/riscv/decode.h
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2019-11-13 05:22:18 -0800
committerGitHub <noreply@github.com>2019-11-13 05:22:18 -0800
commit2704790df5d16868571bacf4c521df4bac87f452 (patch)
tree5b80d59e0eb989d491f2c7db46a1a960e8236e67 /riscv/decode.h
parentff81dea8593c6e51b45e7bed230a2cafd56e4caf (diff)
parent86857aa3511d0a3bb1d28f8a6213013382545f77 (diff)
downloadspike-2704790df5d16868571bacf4c521df4bac87f452.zip
spike-2704790df5d16868571bacf4c521df4bac87f452.tar.gz
spike-2704790df5d16868571bacf4c521df4bac87f452.tar.bz2
Merge pull request #356 from riscv/priv-flag
Add --priv command-line option to set which privilege modes are available
Diffstat (limited to 'riscv/decode.h')
-rw-r--r--riscv/decode.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/riscv/decode.h b/riscv/decode.h
index a756607..f8ac020 100644
--- a/riscv/decode.h
+++ b/riscv/decode.h
@@ -292,8 +292,9 @@ inline freg_t f128_negate(freg_t a)
if (!STATE.serialized) return PC_SERIALIZE_BEFORE; \
STATE.serialized = false; \
unsigned csr_priv = get_field((which), 0x300); \
+ bool mode_unsupported = csr_priv == PRV_S && !P.supports_extension('S'); \
unsigned csr_read_only = get_field((which), 0xC00) == 3; \
- if (((write) && csr_read_only) || STATE.prv < csr_priv) \
+ if (((write) && csr_read_only) || STATE.prv < csr_priv || mode_unsupported) \
throw trap_illegal_instruction(0); \
(which); })