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

mmu: check pte.pad during the ptw #157

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/isa/riscv64/system/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static inline bool check_permission(PTE *pte, bool ok, vaddr_t vaddr, int type)
#else
bool update_ad = false;
#endif
if (!(ok && pte->x) || update_ad) {
if (!(ok && pte->x && !pte->pad) || update_ad) {
assert(!cpu.amo);
INTR_TVAL_REG(EX_IPF) = vaddr;
longjmp_exception(EX_IPF);
Expand All @@ -113,7 +113,7 @@ static inline bool check_permission(PTE *pte, bool ok, vaddr_t vaddr, int type)
#else
bool update_ad = false;
#endif
if (!(ok && can_load) || update_ad) {
if (!(ok && can_load && !pte->pad) || update_ad) {
if (cpu.amo) Logtr("redirect to AMO page fault exception at pc = " FMT_WORD, cpu.pc);
int ex = (cpu.amo ? EX_SPF : EX_LPF);
INTR_TVAL_REG(ex) = vaddr;
Expand All @@ -130,7 +130,7 @@ static inline bool check_permission(PTE *pte, bool ok, vaddr_t vaddr, int type)
bool update_ad = false;
#endif
Logtr("Translate for memory writing");
if (!(ok && pte->w) || update_ad) {
if (!(ok && pte->w && !pte->pad) || update_ad) {
INTR_TVAL_REG(EX_SPF) = vaddr;
cpu.amo = false;
longjmp_exception(EX_SPF);
Expand Down Expand Up @@ -274,7 +274,7 @@ static paddr_t ptw(vaddr_t vaddr, int type) {
#endif
pg_base = PGBASE(pte.ppn);
if (!pte.v || (!pte.r && pte.w)) goto bad;
if (pte.r || pte.x) { break; }
if (pte.r || pte.x || pte.pad) { break; }
else {
level --;
if (level < 0) { goto bad; }
Expand Down
Loading