Skip to content

Fix Zcmt table jump target LSB - #3501

Open
124107157-KV wants to merge 2 commits into
openhwgroup:masterfrom
124107157-KV:fix/3441-zcmt-target-lsb
Open

Fix Zcmt table jump target LSB#3501
124107157-KV wants to merge 2 commits into
openhwgroup:masterfrom
124107157-KV:fix/3441-zcmt-target-lsb

Conversation

@124107157-KV

Copy link
Copy Markdown
Contributor
  • I have searched for similar pull requests
  • I am a human engaging in an interpersonal interaction. During this interaction, my words are my own and are not generated. If relevant, I provide links to my sources.

Why this PR is needed

Zcmt table jumps currently use the JVT-loaded value directly when
calculating the jump target.

For cm.jt and cm.jalt, bit 0 of the value loaded from the JVT must
be cleared before it is used as the architectural target. Since CVA6
expands these table jumps to an internal JAL, they do not pass through
the existing JALR target-LSB clearing in the branch unit.

As a result, an odd address stored in a JVT entry can cause CVA6 to
jump to the odd address instead of the required address with bit 0
cleared.

Changes

  • Clear bit 0 of the JVT-loaded target in core/zcmt_decoder.sv
    before converting the target to the PC-relative offset used by the
    internal JAL expansion.
  • Add an RV32 directed regression for cm.jt with an odd JVT target.
  • Add an RV32 directed regression for cm.jalt with an odd JVT target.
  • Check that the cm.jalt target executes and returns through the
    expected link address.
  • Register both directed tests in verif/tests/testlist_issues.yaml.
  • Add both regressions to verif/regress/issue-tests.sh.

Validation

The permanent directed regressions were checked both before and after
the RTL change.

Before the fix:

  • zcmt-jt-target-lsb-rv32: FAIL
  • zcmt-jalt-target-lsb-rv32: FAIL

After the fix:

  • zcmt-jt-target-lsb-rv32: PASS
  • zcmt-jalt-target-lsb-rv32: PASS
  • Existing zcmt-jvt-index-rv32 regression: PASS

Additional checks:

  • verible-verilog-format --verify core/zcmt_decoder.sv: PASS
  • bash -n verif/regress/issue-tests.sh: PASS
  • git diff --check: clean
  • Rebasing against the current upstream/master required no changes.
  • Working tree is clean after the final regression runs.

Scope / limitations

This change is limited to Zcmt table-jump target handling.

It does not change the normal JAL, JALR, or branch-unit target
handling. Bit 0 is cleared specifically on the target loaded from the
JVT before that target is converted to the PC-relative offset used by
the Zcmt internal JAL expansion.

No known limitation is introduced by this change.

Fixes #3441

Clear bit 0 of the JVT-loaded target before converting it to the
PC-relative offset used by the internal JAL expansion.

Add RV32 directed regressions covering odd JVT targets for cm.jt
and cm.jalt.
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.

[BUG] Zcmt table jump (cm.jt/cm.jalt) does not clear bit 0 of the target

1 participant