qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] target/riscv: raise an exception when CSRRS/CSRRC writes


From: Richard Henderson
Subject: Re: [PATCH v2] target/riscv: raise an exception when CSRRS/CSRRC writes a read-only CSR
Date: Sun, 10 Mar 2024 18:48:58 -1000
User-agent: Mozilla Thunderbird

On 3/10/24 17:08, Yu-Ming Chang via wrote:
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>
---
This incorporated the comments from Richard. Thank you.

  target/riscv/cpu.h       |  2 ++
  target/riscv/csr.c       | 17 ++++++++++++++---
  target/riscv/op_helper.c |  2 +-
  3 files changed, 17 insertions(+), 4 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]