aboutsummaryrefslogtreecommitdiff
path: root/riscv/mmu.h
diff options
context:
space:
mode:
authorYenHaoChen <howard25336284@gmail.com>2022-09-30 12:05:40 +0800
committerYenHaoChen <howard25336284@gmail.com>2022-09-30 12:18:39 +0800
commitd52858f3a80d3f87bfedffbff1fec34245a63082 (patch)
tree75f6e973bef46896f8eefd8fb0414ae9659f61bc /riscv/mmu.h
parent99cb603973b3f9575b411b80934035f3ee7fbcf3 (diff)
downloadspike-d52858f3a80d3f87bfedffbff1fec34245a63082.zip
spike-d52858f3a80d3f87bfedffbff1fec34245a63082.tar.gz
spike-d52858f3a80d3f87bfedffbff1fec34245a63082.tar.bz2
Fix priority of mcontrol trigger store address/data before
The spec defines that the mcontrol store address/data has a higher priority over page fault and address misalignment (Debug spec, Table 5.2). Thus, the trigger checking should be before the translation and alignment checking. The previous implementation checks the trigger after the translation and alignment, resulting in incorrect priority. For instance, when page fault and trigger occur on the same instruction, the previous implementation will choose to raise the page fault, which contradicts the priority requirement. This commit moves the trigger checking before the misaligned checking and translation. The trigger will fire on the instruction instead of the page fault in the above case.
Diffstat (limited to 'riscv/mmu.h')
-rw-r--r--riscv/mmu.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/riscv/mmu.h b/riscv/mmu.h
index 3a06c1e..40a435f 100644
--- a/riscv/mmu.h
+++ b/riscv/mmu.h
@@ -169,6 +169,13 @@ public:
#define store_func(type, prefix, xlate_flags) \
void ALWAYS_INLINE prefix##_##type(reg_t addr, type##_t val, bool actually_store=true, bool require_alignment=false) { \
if (unlikely(addr & (sizeof(type##_t)-1))) { \
+ if (actually_store) { \
+ if (!matched_trigger) { \
+ matched_trigger = trigger_exception(triggers::OPERATION_STORE, addr, true, val); \
+ if (matched_trigger) \
+ throw *matched_trigger; \
+ } \
+ } \
if (require_alignment) store_conditional_address_misaligned(addr); \
else return misaligned_store(addr, val, sizeof(type##_t), xlate_flags, actually_store); \
} \