diff --git a/src/mem/AbstractMemory.py b/src/mem/AbstractMemory.py index ea88fd879c..7ab24bc118 100644 --- a/src/mem/AbstractMemory.py +++ b/src/mem/AbstractMemory.py @@ -74,3 +74,5 @@ class AbstractMemory(ClockedObject): image_file = Param.String( "", "Image to load into memory as its initial contents" ) + + writeable = Param.Bool(True, "Allow writes to this memory") diff --git a/src/mem/abstract_mem.cc b/src/mem/abstract_mem.cc index 03f2557d63..9340f7e96f 100644 --- a/src/mem/abstract_mem.cc +++ b/src/mem/abstract_mem.cc @@ -59,10 +59,11 @@ namespace memory AbstractMemory::AbstractMemory(const Params &p) : ClockedObject(p), range(p.range), pmemAddr(NULL), backdoor(params().range, nullptr, - (MemBackdoor::Flags)(MemBackdoor::Readable | - MemBackdoor::Writeable)), + (MemBackdoor::Flags)(p.writeable ? + MemBackdoor::Readable | MemBackdoor::Writeable : + MemBackdoor::Readable)), confTableReported(p.conf_table_reported), inAddrMap(p.in_addr_map), - kvmMap(p.kvm_map), _system(NULL), + kvmMap(p.kvm_map), writeable(p.writeable), _system(NULL), stats(*this) { panic_if(!range.valid() || !range.size(), diff --git a/src/mem/abstract_mem.hh b/src/mem/abstract_mem.hh index 53b794012d..7f12487421 100644 --- a/src/mem/abstract_mem.hh +++ b/src/mem/abstract_mem.hh @@ -129,6 +129,9 @@ class AbstractMemory : public ClockedObject // Should KVM map this memory for the guest const bool kvmMap; + // Are writes allowed to this memory + const bool writeable; + std::list lockedAddrList; // helper function for checkLockedAddrs(): we really want to @@ -149,8 +152,12 @@ class AbstractMemory : public ClockedObject // requesting execution context), 'true' otherwise. Note that // this method must be called on *all* stores since even // non-conditional stores must clear any matching lock addresses. - bool writeOK(PacketPtr pkt) { + bool + writeOK(PacketPtr pkt) + { const RequestPtr &req = pkt->req; + if (!writeable) + return false; if (lockedAddrList.empty()) { // no locked addrs: nothing to check, store_conditional fails bool isLLSC = pkt->isLLSC();