aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Johnson <scott.johnson@arilinc.com>2022-04-22 12:52:46 -0500
committerGitHub <noreply@github.com>2022-04-22 12:52:46 -0500
commit1dbcee7d97c8b05cda8f6fa009afc4c0a5d251b1 (patch)
treee2bdfb718e31c60d81c93fd6ec52a3356714e26b
parentb9fc8e4e9087a6064dfcc627efabbe3fd4bdc309 (diff)
parent01b88b06693d91ee3d2e5b80020e0b934828d47d (diff)
downloadriscv-isa-sim-1dbcee7d97c8b05cda8f6fa009afc4c0a5d251b1.zip
riscv-isa-sim-1dbcee7d97c8b05cda8f6fa009afc4c0a5d251b1.tar.gz
riscv-isa-sim-1dbcee7d97c8b05cda8f6fa009afc4c0a5d251b1.tar.bz2
Merge pull request #978 from rbuchner-aril/amo-order-change-patch
Bug Fix for bug introduced in PR #976
-rw-r--r--riscv/mmu.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/riscv/mmu.h b/riscv/mmu.h
index dcf338f..8964e29 100644
--- a/riscv/mmu.h
+++ b/riscv/mmu.h
@@ -65,11 +65,11 @@ public:
#endif
}
- inline void misaligned_store(reg_t addr, reg_t data, size_t size, uint32_t xlate_flags)
+ inline void misaligned_store(reg_t addr, reg_t data, size_t size, uint32_t xlate_flags, bool actually_store=true)
{
#ifdef RISCV_ENABLE_MISALIGNED
for (size_t i = 0; i < size; i++)
- store_uint8(addr + (target_big_endian? size-1-i : i), data >> (i * 8));
+ store_uint8(addr + (target_big_endian? size-1-i : i), data >> (i * 8), actually_store);
#else
bool gva = ((proc) ? proc->state.v : false) || (RISCV_XLATE_VIRT & xlate_flags);
throw trap_store_address_misaligned(gva, addr, 0, 0);
@@ -147,9 +147,11 @@ public:
// template for functions that store an aligned value to memory
#define store_func(type, prefix, xlate_flags) \
- void prefix##_##type(reg_t addr, type##_t val, bool actually_store=true) { \
- if (unlikely(addr & (sizeof(type##_t)-1))) \
- return misaligned_store(addr, val, sizeof(type##_t), xlate_flags); \
+ void prefix##_##type(reg_t addr, type##_t val, bool actually_store=true, bool require_alignment=false) { \
+ if (unlikely(addr & (sizeof(type##_t)-1))) { \
+ if (require_alignment) store_conditional_address_misaligned(addr); \
+ else return misaligned_store(addr, val, sizeof(type##_t), xlate_flags, actually_store); \
+ } \
reg_t vpn = addr >> PGSHIFT; \
size_t size = sizeof(type##_t); \
if ((xlate_flags) == 0 && likely(tlb_store_tag[vpn % TLB_ENTRIES] == vpn)) { \
@@ -196,7 +198,7 @@ public:
template<typename op> \
type##_t amo_##type(reg_t addr, op f) { \
convert_load_traps_to_store_traps({ \
- store_##type(addr, 0, false); \
+ store_##type(addr, 0, false, true); \
auto lhs = load_##type(addr, true); \
store_##type(addr, f(lhs)); \
return lhs; \