Skip to content

csr: validate CSRRS/CSRRC writes by register index - #299

Open
carlosqwqqwq wants to merge 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/csr-readonly-rs1-index
Open

csr: validate CSRRS/CSRRC writes by register index#299
carlosqwqqwq wants to merge 1 commit into
LekKit:stagingfrom
carlosqwqqwq:fix/csr-readonly-rs1-index

Conversation

@carlosqwqqwq

Copy link
Copy Markdown

csr: validate CSRRS/CSRRC writes by register index

Fixes #293

Commit message

csr: validate CSRRS/CSRRC writes by register index

Description

The CSR helper decides whether CSRRS/CSRRC writes from the runtime value loaded from rs1. A nonzero rs1 register containing zero is therefore mistakenly treated as a read, allowing writes to read-only time. Carry the architectural write-intent bit from the decoder into the helper: only rs1=x0/zimm=0 forms are read-only accesses.

Validation

  • Native RISC-V hardware and QEMU trap csrrs/csrrc with rs1 = t0 (value zero) against read-only time and accept only the canonical rs1 = x0 read form; the patched build matches both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CSRRS/CSRRC to read-only time accepted when rs1 != x0 holds zero

1 participant