Skip to content

riscv: detect Zicsr/Zifencei without leading underscore - #468

Draft
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-riscv-z-ext-underscore-less
Draft

riscv: detect Zicsr/Zifencei without leading underscore#468
rootkiller6788 wants to merge 1 commit into
google:mainfrom
rootkiller6788:fix-riscv-z-ext-underscore-less

Conversation

@rootkiller6788

Copy link
Copy Markdown

Fixes #301

The Linux devicetree riscv,isa binding (cpus.yaml) allows the first multi-letter extension to omit its leading underscore, so a valid isa string can look like rv64imafdczicsr_zifencei. The parser in src/impl_riscv_linux.c looked for _zicsr and _zifencei (with a leading underscore), so when the first multi-letter extension dropped the underscore, Zicsr and Zifencei were silently missed.

Changes:

  • Match Z extensions without the leading underscore (zicsr, zifencei), which still matches the canonical _zicsr/_zifencei spelling.
  • Update the comment to the current cpus.yaml regex (^rv(?:64|32)imaf?d?q?c?b?k?j?p?v?h?(?:[hsxz](?:[a-z])+)?(?:_[hsxz](?:[a-z])+)*$).
  • Add regression tests for rv64imafdczicsr_zifencei, rv64imafdczifencei, and the canonical rv64imafdc_zicsr_zifencei.

Verified: the two underscore-less tests fail on the old parser and pass with this change; all existing riscv tests still pass.

The kernel riscv,isa binding allows the first multi-letter extension to
omit its leading underscore (e.g. rv64imafdczicsr_zifencei). The parser
looked for "_zicsr" and "_zifencei" with the underscore, so those
extensions were missed when the first multi-letter extension dropped the
underscore. Match them without the underscore to catch both spellings.

Also update the comment to the current devicetree binding regex and add
regression tests for the underscore-less and canonical spellings.
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.

RISC-V devicetree "riscv,isa" comment is no longer accurate

1 participant