Fix exception type on PMP check during PTW (#908)

Fixes #906

According to the spec:
> If accessing pte violates a PMA or PMP check, raise an access-fault
> exception corresponding to the original access type.

Found by @Phantom1003 and @ProjectDimlight

Signed-off-by: Moritz Schneider <moritz.schneider@inf.ethz.ch>
This commit is contained in:
Moritz Schneider 2022-07-08 10:21:57 +02:00 committed by GitHub
parent 01c89b7606
commit 011edf49bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -397,8 +397,12 @@ module mmu import ariane_pkg::*; #(
if (ptw_access_exception) begin
// an error makes the translation valid
lsu_valid_o = 1'b1;
// the page table walker can only throw page faults
lsu_exception_o = {riscv::LD_ACCESS_FAULT, {{riscv::XLEN-riscv::PLEN{1'b0}}, ptw_bad_paddr}, 1'b1};
// Any fault of the page table walk should be based of the original access type
if (lsu_is_store_q) begin
lsu_exception_o = {riscv::ST_ACCESS_FAULT, {{riscv::XLEN-riscv::VLEN{1'b0}}, lsu_vaddr_n}, 1'b1};
end else begin
lsu_exception_o = {riscv::LD_ACCESS_FAULT, {{riscv::XLEN-riscv::VLEN{1'b0}}, lsu_vaddr_n}, 1'b1};
end
end
end
end