From c58cb8c9dbeef377da180f1fdaaa1c0eadf85550 Mon Sep 17 00:00:00 2001 From: Giacomo Gabrielli Date: Fri, 7 Jul 2017 14:13:11 +0100 Subject: cpu,mem: Add support for partial loads/stores and wide mem. accesses This changeset adds support for partial (or masked) loads/stores, i.e. loads/stores that can disable accesses to individual bytes within the target address range. In addition, this changeset extends the code to crack memory accesses across most CPU models (TimingSimpleCPU still TBD), so that arbitrarily wide memory accesses are supported. These changes are required for supporting ISAs with wide vectors. Additional authors: - Gabor Dozsa - Tiago Muck Change-Id: Ibad33541c258ad72925c0b1d5abc3e5e8bf92d92 Signed-off-by: Giacomo Gabrielli Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/13518 Tested-by: kokoro Reviewed-by: Nikos Nikoleris Maintainer: Nikos Nikoleris --- src/mem/packet.hh | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/mem/packet.hh') diff --git a/src/mem/packet.hh b/src/mem/packet.hh index 93b3ad5de..130cc41ad 100644 --- a/src/mem/packet.hh +++ b/src/mem/packet.hh @@ -1092,6 +1092,7 @@ class Packet : public Printable getPtr() { assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)); + assert(!isMaskedWrite()); return (T*)data; } @@ -1180,10 +1181,11 @@ class Packet : public Printable // same pointer from source to destination and back assert(p != getPtr() || flags.isSet(STATIC_DATA)); - if (p != getPtr()) + if (p != getPtr()) { // for packet with allocated dynamic data, we copy data from // one to the other, e.g. a forwarded response to a response std::memcpy(getPtr(), p, getSize()); + } } /** @@ -1203,7 +1205,19 @@ class Packet : public Printable void writeData(uint8_t *p) const { - std::memcpy(p, getConstPtr(), getSize()); + if (!isMaskedWrite()) { + std::memcpy(p, getConstPtr(), getSize()); + } else { + assert(req->getByteEnable().size() == getSize()); + // Write only the enabled bytes + const uint8_t *base = getConstPtr(); + for (int i = 0; i < getSize(); i++) { + if (req->getByteEnable()[i]) { + p[i] = *(base + i); + } + // Disabled bytes stay untouched + } + } } /** @@ -1268,6 +1282,17 @@ class Packet : public Printable bool trySatisfyFunctional(PacketPtr other) { + if (other->isMaskedWrite()) { + // Do not forward data if overlapping with a masked write + if (_isSecure == other->isSecure() && + getAddr() <= (other->getAddr() + other->getSize() - 1) && + other->getAddr() <= (getAddr() + getSize() - 1)) { + warn("Trying to check against a masked write, skipping." + " (addr: 0x%x, other addr: 0x%x)", getAddr(), + other->getAddr()); + } + return false; + } // all packets that are carrying a payload should have a valid // data pointer return trySatisfyFunctional(other, other->getAddr(), other->isSecure(), @@ -1296,6 +1321,12 @@ class Packet : public Printable return cmd == MemCmd::CleanEvict || cmd == MemCmd::WritebackClean; } + bool + isMaskedWrite() const + { + return (cmd == MemCmd::WriteReq && !req->getByteEnable().empty()); + } + /** * Check a functional request against a memory value represented * by a base/size pair and an associated data array. If the -- cgit v1.2.3