[gem5-dev] [S] Change in gem5/gem5[develop]: mem: Add a parameter which will make a memory truly a ROM.

2023-03-02 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has submitted this change. (  
https://gem5-review.googlesource.com/c/public/gem5/+/68557?usp=email )


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

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 
Tested-by: kokoro 
Reviewed-by: Matthew Poremba 
---
M src/mem/AbstractMemory.py
M src/mem/abstract_mem.cc
M src/mem/abstract_mem.hh
3 files changed, 14 insertions(+), 4 deletions(-)

Approvals:
  Matthew Poremba: Looks good to me, approved
  Gabe Black: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/mem/AbstractMemory.py b/src/mem/AbstractMemory.py
index ea88fd8..7ab24bc 100644
--- a/src/mem/AbstractMemory.py
+++ b/src/mem/AbstractMemory.py
@@ -74,3 +74,5 @@
 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 03f2557..9340f7e 100644
--- a/src/mem/abstract_mem.cc
+++ b/src/mem/abstract_mem.cc
@@ -59,10 +59,11 @@
 AbstractMemory::AbstractMemory(const Params ) :
 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 53b7940..7f12487 100644
--- a/src/mem/abstract_mem.hh
+++ b/src/mem/abstract_mem.hh
@@ -129,6 +129,9 @@
 // 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 @@
 // 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  = pkt->req;
+if (!writeable)
+return false;
 if (lockedAddrList.empty()) {
 // no locked addrs: nothing to check, store_conditional fails
 bool isLLSC = pkt->isLLSC();

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/68557?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib95e619c76c327d302e62a88515a92af11815981
Gerrit-Change-Number: 68557
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Gabe Black 
Gerrit-Reviewer: Giacomo Travaglini 
Gerrit-Reviewer: Jui-min Lee 
Gerrit-Reviewer: Matthew Poremba 
Gerrit-Reviewer: Yu-hsin Wang 
Gerrit-Reviewer: kokoro 
Gerrit-MessageType: merged
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org


[gem5-dev] [S] Change in gem5/gem5[develop]: mem: Add a parameter which will make a memory truly a ROM.

2023-03-02 Thread Gabe Black (Gerrit) via gem5-dev
Gabe Black has uploaded this change for review. (  
https://gem5-review.googlesource.com/c/public/gem5/+/68557?usp=email )



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

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.

Bug: 254411221
Test: Used this flag with the GSA's boot ROM and saw that it no longer
Test: accepted a corrupting write which overwrote the reset vector.
Change-Id: Ib95e619c76c327d302e62a88515a92af11815981
---
M src/mem/AbstractMemory.py
M src/mem/abstract_mem.cc
M src/mem/abstract_mem.hh
3 files changed, 14 insertions(+), 4 deletions(-)



diff --git a/src/mem/AbstractMemory.py b/src/mem/AbstractMemory.py
index ea88fd8..7ab24bc 100644
--- a/src/mem/AbstractMemory.py
+++ b/src/mem/AbstractMemory.py
@@ -74,3 +74,5 @@
 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 03f2557..9340f7e 100644
--- a/src/mem/abstract_mem.cc
+++ b/src/mem/abstract_mem.cc
@@ -59,10 +59,11 @@
 AbstractMemory::AbstractMemory(const Params ) :
 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 53b7940..7f12487 100644
--- a/src/mem/abstract_mem.hh
+++ b/src/mem/abstract_mem.hh
@@ -129,6 +129,9 @@
 // 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 @@
 // 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  = pkt->req;
+if (!writeable)
+return false;
 if (lockedAddrList.empty()) {
 // no locked addrs: nothing to check, store_conditional fails
 bool isLLSC = pkt->isLLSC();

--
To view, visit  
https://gem5-review.googlesource.com/c/public/gem5/+/68557?usp=email
To unsubscribe, or for help writing mail filters, visit  
https://gem5-review.googlesource.com/settings


Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Ib95e619c76c327d302e62a88515a92af11815981
Gerrit-Change-Number: 68557
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black 
Gerrit-CC: Gabe Black 
Gerrit-MessageType: newchange
___
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org