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

execute(CJALR) #1

Open
fvogels opened this issue Jan 9, 2024 · 1 comment
Open

execute(CJALR) #1

fvogels opened this issue Jan 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@fvogels
Copy link

fvogels commented Jan 9, 2024

function clause execute(CJALR(cd, cs, imm)) = {
  // [...]
  let imm = sail_zero_extend(imm, integer_size);
  let c' = updatePCPerm({c with cap_cursor = c.cap_cursor + imm});
  // [...]
}

imm gets zero-extended, but shouldn't this be sign-extended?
From the corresponding CHERI RISC-V Sail code:

function clause execute(CJALR(imm, cs1, cd)) = {
  let cs1_val = C(cs1);
  let off : xlenbits = sign_extend(imm);    // <--
  let newPC = [cs1_val.address + off with 0 = bitzero]; /* clear bit zero as for RISCV JALR */
  // [...]

Also note that the lsb is set to 0.

@fvogels fvogels added the bug Something isn't working label Jan 9, 2024
@capt-hb
Copy link
Member

capt-hb commented Jan 9, 2024

Yes, it should indeed be sign-extended. These (and maybe other uncovered) bugs are remnants of the "bi-translation" of MinimalCaps (which was initially written directly in microSail). Note that these bugs are only part of the Sail spec of MinimalCaps. The microSail implementation doesn't use bitvectors yet (nor has it any kind of alignment restrictions).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants