i#3544 RV64: Fix patch_stub for unaligned stub_pc #6711
Merged
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.
To simplify codegen, we require the exit stub pc to be aligned to 4 bytes. If it is not aligned, we place a 2-byte
c.nop
at the beginning of the exit stub. Therefore, all functions that modify the exit stub should skip the possiblec.nop
.The wrongly implemented
patch_stub()
makesunlink_branch()
not affect the exit stub, which makes the async signal handling error-prone.Before the fix, it hits the following assertion ~1/5 times when running
linux.signal0001
on a RISC-V machine, which indicates that the second signal comes from a different fragment after the unlinking, and the real reason is that the unlinking is not successful.It would be great if we could enable the signal tests in CI, but these tests do not work in QEMU for unknown reasons.
Issue: #3544
Related: #2328