Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misaligned jump target exception handling #2508

Closed
wants to merge 1 commit into from

Conversation

teobiton
Copy link

@teobiton teobiton commented Sep 23, 2024

As per the specifications, instruction-address-misaligned exceptions should be reported for instructions that are not 16-bit aligned if the C extension is supported, and for instructions that are not 32-bit aligned if not.

core/branch_unit.sv Show resolved Hide resolved
core/branch_unit.sv Outdated Show resolved Hide resolved
core/branch_unit.sv Outdated Show resolved Hide resolved
core/branch_unit.sv Outdated Show resolved Hide resolved
Copy link
Contributor

❌ failed run, report available here.

1 similar comment
Copy link
Contributor

❌ failed run, report available here.

As per the specifications, instruction-address-misaligned exceptions
should be reported for instructions that are not 16-bit aligned if
the C extension is supported, and for instructions that are not
32-bit aligned if not.
@teobiton teobiton changed the title Fix misaligned jump target exception management Fix misaligned jump target exception handling Sep 24, 2024
Copy link
Contributor

❌ failed run, report available here.

@zarubaf
Copy link
Contributor

zarubaf commented Sep 26, 2024

You shouldn't be able to trigger this exception if RVC is enabled. Since the LSB is cleared:

2.5.1. Unconditional Jumps

The indirect jump instruction JALR (jump and link register) uses the I-type encoding. The target
address is obtained by adding the sign-extended 12-bit I-immediate to the register rs1, then setting the least-significant bit of the result to zero.

@teobiton
Copy link
Author

Yes, I realized this after opening the PR.
I feel like the specifications are not clear on this point, because it states that this exception should be raised in case of misalignment ... but because bit 0 is supposed to be zero it shouldn't happen.

@zarubaf
Copy link
Contributor

zarubaf commented Sep 26, 2024

Yes, I realized this after opening the PR. I feel like the specifications are not clear on this point, because it states that this exception should be raised in case of misalignment ... but because bit 0 is supposed to be zero it shouldn't happen.

Indeed, could be clearer about it. But I think it is exactly how you wrote it. It should trigger it, but you can't trigger it.

@teobiton teobiton closed this Oct 4, 2024
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.

2 participants