Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR corrects RISC-V JALR target address alignment in the sim/simx emulator by clearing bit 0 of the computed target address, and adds a focused regression test to prevent the issue from reappearing.
Changes:
- Fix
sim/simxJALR next-PC computation to enforce(rs1 + imm) & ~1. - Add a new
tests/regression/jalrtest (host + kernel + startup) that fails deterministically when JALR doesn’t clear bit 0. - Wire the new regression into the top-level
tests/regression/Makefiletargets (build/run/clean).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
sim/simx/execute.cpp |
Masks off bit 0 when computing JALR target PC to match the ISA requirement. |
tests/regression/Makefile |
Adds the new jalr regression to aggregate build/run/clean targets. |
tests/regression/jalr/Makefile |
Build/run glue for the new regression test. |
tests/regression/jalr/start.S |
Minimal startup that calls main, dumps perf, and terminates. |
tests/regression/jalr/main.cpp |
Host-side test runner that launches the kernel and validates per-core pass signatures. |
tests/regression/jalr/kernel.cpp |
Kernel that uses an intentionally odd JALR target to distinguish correct vs incorrect alignment behavior. |
tests/regression/jalr/common.h |
Kernel argument struct for passing the destination buffer address. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes JALR target address alignment in sim/simx by clearing bit 0 of the computed target, as required by the RISC-V ISA.
It also adds a regression test under tests/regression/jalr.