target/riscv: raise an exception when CSRRS/CSRRC writes a read-only CSR
authorYu-Ming Chang <yumin686@andestech.com>
Fri, 8 Mar 2024 07:48:03 +0000 (15:48 +0800)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 18 Jul 2024 02:08:45 +0000 (12:08 +1000)
commit38c83e8d3a333b8b377367756a2b6c700c7d0084
tree40db608999be38ef578f2960d94840017240bbcb
parent6f6592d62ebaffff353bdd27ec4480972695d24b
target/riscv: raise an exception when CSRRS/CSRRC writes a read-only CSR

Both CSRRS and CSRRC always read the addressed CSR and cause any read side
effects regardless of rs1 and rd fields. Note that if rs1 specifies a register
holding a zero value other than x0, the instruction will still attempt to write
the unmodified value back to the CSR and will cause any attendant side effects.

So if CSRRS or CSRRC tries to write a read-only CSR with rs1 which specifies
a register holding a zero value, an illegal instruction exception should be
raised.

Signed-off-by: Yu-Ming Chang <yumin686@andestech.com>
Signed-off-by: Alvin Chang <alvinga@andestech.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <172100444279.18077.6893072378718059541-0@git.sr.ht>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
target/riscv/cpu.h
target/riscv/csr.c
target/riscv/op_helper.c