Skip to content

Commit

Permalink
Don't read 8 bytes for 4-byte PTEs
Browse files Browse the repository at this point in the history
For Sv32 Page Table Entries are only 4 bytes, but the old code was unconditionally reading 8 bytes.

Fixes #459
  • Loading branch information
Timmmm committed Apr 29, 2024
1 parent 16077e1 commit 986346e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion model/riscv_vmem.sail
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,17 @@ function pt_walk(sv_params,
let mem_result = mem_read_priv(Read(Data), // AccessType
Supervisor, // Privilege
pte_phys_addr,
8, // atom (8)
2 ^ sv_params.log_pte_size_bytes,
false, // aq
false, // rl
false); // res

match mem_result {
MemException(_) => PTW_Failure(PTW_Access(), ext_ptw),
MemValue(pte) => {
// Extend to 64 bits even on RV32 for simplicity.
let pte : bits(64) = zero_extend(pte);

let pte_flags = Mk_PTE_Flags(pte[7 .. 0]);
if pte_is_invalid(pte_flags) then
PTW_Failure(PTW_Invalid_PTE(), ext_ptw)
Expand Down

0 comments on commit 986346e

Please sign in to comment.