Browse Source

Fix the access exception during page-table walks to match the original access type, as specified in the manual. (#185)

pull/187/head
Prashanth Mundkur 8 years ago
committed by Andrew Waterman
parent
commit
ec79312862
  1. 10
      riscv/mmu.cc

10
riscv/mmu.cc

@ -182,7 +182,7 @@ reg_t mmu_t::walk(reg_t addr, access_type type, reg_t mode)
// check that physical address of PTE is legal
auto ppte = sim->addr_to_mem(base + idx * vm.ptesize);
if (!ppte)
throw trap_load_access_fault(addr);
goto fail_access;
reg_t pte = vm.ptesize == 4 ? *(uint32_t*)ppte : *(uint64_t*)ppte;
reg_t ppn = pte >> PTE_PPN_SHIFT;
@ -223,6 +223,14 @@ fail:
case STORE: throw trap_store_page_fault(addr);
default: abort();
}
fail_access:
switch (type) {
case FETCH: throw trap_instruction_access_fault(addr);
case LOAD: throw trap_load_access_fault(addr);
case STORE: throw trap_store_access_fault(addr);
default: abort();
}
}
void mmu_t::register_memtracer(memtracer_t* t)

Loading…
Cancel
Save