summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Norton2016-06-28 14:23:11 +0100
committerRobert Norton2016-06-28 14:25:28 +0100
commit28874bde2f7ad58e76ebe8d779d3920d74ca1db6 (patch)
tree5abc4c1c32e16e71029ca9e3367235f99bc627fd
parent90c7ab7d28d68d943ebae7be6b687550d57a357c (diff)
Munge exception destination PC so we hit the correct address even when kcc.base is non-zero.
-rw-r--r--cheri/cheri_prelude.sail2
-rw-r--r--mips/mips_prelude.sail6
-rw-r--r--mips/mips_wrappers.sail2
3 files changed, 6 insertions, 4 deletions
diff --git a/cheri/cheri_prelude.sail b/cheri/cheri_prelude.sail
index c8483548..9f39496f 100644
--- a/cheri/cheri_prelude.sail
+++ b/cheri/cheri_prelude.sail
@@ -349,7 +349,7 @@ function unit SignalException ((Exception) ex) =
nextPCC := C29; (* KCC *)
delayedPCC := C29; (* always write delayedPCC together whether PCC so
that non-capability branches don't override PCC *)
- SignalExceptionMIPS(ex);
+ SignalExceptionMIPS(ex, C29.base);
}
function unit ERETHook() =
diff --git a/mips/mips_prelude.sail b/mips/mips_prelude.sail
index 5cccee3f..5be1a3cc 100644
--- a/mips/mips_prelude.sail
+++ b/mips/mips_prelude.sail
@@ -279,7 +279,7 @@ function (bit[5]) ExceptionCode ((Exception) ex) =
val Exception -> unit effect {rreg, wreg} SignalException
-function unit SignalExceptionMIPS ((Exception) ex) =
+function unit SignalExceptionMIPS ((Exception) ex, (bit[64]) kccBase) =
{
(* Only update EPC and BD if not already in EXL mode *)
if (~ (CP0Status.EXL)) then
@@ -311,7 +311,9 @@ function unit SignalExceptionMIPS ((Exception) ex) =
0xFFFFFFFFBFC00200
else
0xFFFFFFFF80000000;
- nextPC := vectorBase + EXTS(vectorOffset);
+ (* On CHERI we have to subtract KCC.base so that we end up at the
+ right absolute vector address after indirecting via new PCC *)
+ nextPC := ((bit[64])(vectorBase + EXTS(vectorOffset))) - kccBase;
CP0Cause.ExcCode := ExceptionCode(ex);
CP0Status.EXL := 1;
}
diff --git a/mips/mips_wrappers.sail b/mips/mips_wrappers.sail
index 36cbe0d4..e8b17a29 100644
--- a/mips/mips_wrappers.sail
+++ b/mips/mips_wrappers.sail
@@ -52,6 +52,6 @@ function (bit[64]) TranslateAddress ((bit[64]) vAddr, (MemAccessType) accessType
let have_cp2 = false
-function unit SignalException ((Exception) ex) = SignalExceptionMIPS(ex)
+function unit SignalException ((Exception) ex) = SignalExceptionMIPS(ex, 0x0000000000000000)
function unit ERETHook() = ()