diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-06-24 14:13:08 -0700 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2015-06-24 14:14:01 -0700 |
commit | 027ba300cbeaa425218fd472e1fcf45c785f645c (patch) | |
tree | 4b4e42b54abf1d7137e5aa099d44319673b7269d | |
parent | 621793b43ae825188af584e5789ade2e2527c9f8 (diff) | |
download | pk-027ba300cbeaa425218fd472e1fcf45c785f645c.zip pk-027ba300cbeaa425218fd472e1fcf45c785f645c.tar.gz pk-027ba300cbeaa425218fd472e1fcf45c785f645c.tar.bz2 |
Use sbadaddr (not sepc) to resolve instruction page faults
-rw-r--r-- | pk/entry.S | 6 | ||||
-rw-r--r-- | pk/handlers.c | 6 |
2 files changed, 6 insertions, 6 deletions
@@ -39,11 +39,13 @@ # get sr, epc, badvaddr, cause csrrw t0,sscratch,x0 csrr s0,sstatus - csrr t2,sepc + csrr t1,sepc + csrr t2,sbadaddr csrr t3,scause STORE t0,2*REGBYTES(x2) STORE s0,32*REGBYTES(x2) - STORE t2,33*REGBYTES(x2) + STORE t1,33*REGBYTES(x2) + STORE t2,34*REGBYTES(x2) STORE t3,35*REGBYTES(x2) # get faulting insn, if it wasn't a fetch-related trap diff --git a/pk/handlers.c b/pk/handlers.c index c1f7c2b..881cc17 100644 --- a/pk/handlers.c +++ b/pk/handlers.c @@ -53,20 +53,18 @@ static void segfault(trapframe_t* tf, uintptr_t addr, const char* type) static void handle_fault_fetch(trapframe_t* tf) { - if (handle_page_fault(tf->epc, PROT_EXEC) != 0) - segfault(tf, tf->epc, "fetch"); + if (handle_page_fault(tf->badvaddr, PROT_EXEC) != 0) + segfault(tf, tf->badvaddr, "fetch"); } void handle_fault_load(trapframe_t* tf) { - tf->badvaddr = read_csr(sbadaddr); if (handle_page_fault(tf->badvaddr, PROT_READ) != 0) segfault(tf, tf->badvaddr, "load"); } void handle_fault_store(trapframe_t* tf) { - tf->badvaddr = read_csr(sbadaddr); if (handle_page_fault(tf->badvaddr, PROT_WRITE) != 0) segfault(tf, tf->badvaddr, "store"); } |