From 4594dffc7f6e7d8329d94767d850e0a1294a1581 Mon Sep 17 00:00:00 2001
From: David Harris <david_harris@hmc.edu>
Date: Tue, 28 Mar 2023 06:46:11 -0700
Subject: [PATCH] Set PMP to allow all user/supervisor accesses in
 WALLY-init-lib

---
 tests/coverage/WALLY-init-lib.h | 4 ++++
 tests/coverage/priv.S           | 1 +
 2 files changed, 5 insertions(+)

diff --git a/tests/coverage/WALLY-init-lib.h b/tests/coverage/WALLY-init-lib.h
index 4de5e7688..f95ef285c 100644
--- a/tests/coverage/WALLY-init-lib.h
+++ b/tests/coverage/WALLY-init-lib.h
@@ -40,6 +40,10 @@ rvtest_entry_point:
     la t0, topoftrapstack 
     csrw mscratch, t0   # MSCRATCH holds trap stack pointer
     csrsi mstatus, 0x8  # Turn on mstatus.MIE global interrupt enable
+    # set up PMP so user and supervisor mode can access full address space
+    csrw pmpcfg0, 0xF   # configure PMP0 to TOR RWX
+    li t0, 0xFFFFFFFF   
+    csrw pmpaddr0, t0   # configure PMP0 top of range to 0xFFFFFFFF to allow all 32-bit addresses
     j main              # Call main function in user test program
 
 done:
diff --git a/tests/coverage/priv.S b/tests/coverage/priv.S
index 81ec31df9..3aa3aea5c 100644
--- a/tests/coverage/priv.S
+++ b/tests/coverage/priv.S
@@ -33,6 +33,7 @@ main:
     ecall
 
     # Test read to stimecmp fails when MCOUNTEREN_TM is not set
+    addi t0, zero, 0
     csrr t0, stimecmp 
 
     j done