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:
@@ -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")
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user