mem: Add a parameter which will make a memory truly a ROM.

This piggy-backs on the writeOK method which already exists. It also
modifies the flags returned as part of the memory's backdoor
descriptor which doesn't enforce that the memory is read only, but will
let the other party know it's expected not to write to it.

Change-Id: Ib95e619c76c327d302e62a88515a92af11815981
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68557
Maintainer: Gabe Black <gabeblack@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Matthew Poremba <matthew.poremba@amd.com>
This commit is contained in:
Gabe Black
2023-03-02 09:25:17 -08:00
committed by Gabe Black
parent e6604bf109
commit 7500136392
3 changed files with 14 additions and 4 deletions

View File

@@ -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")

View File

@@ -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(),

View File

@@ -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<LockedAddr> 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();