From 71769d2d7b094580b7a4437bf8d8e1401c418c4d Mon Sep 17 00:00:00 2001 From: Mitch Hayenga Date: Wed, 3 Sep 2014 07:42:27 -0400 Subject: [PATCH] dev: Avoid invalid sized reads in PL390 with DPRINTF enabled The first DPRINTF() in PL390::writeDistributor always read a uint32_t, though a packet may have only been 1 or 2 bytes. This caused an assertion in packet->get(). --- src/dev/arm/gic_pl390.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/dev/arm/gic_pl390.cc b/src/dev/arm/gic_pl390.cc index 7fc65b2b7..b93cdd028 100644 --- a/src/dev/arm/gic_pl390.cc +++ b/src/dev/arm/gic_pl390.cc @@ -395,8 +395,25 @@ Pl390::writeDistributor(PacketPtr pkt) assert(pkt->req->hasContextId()); int ctx_id = pkt->req->contextId(); + uint32_t pkt_data M5_VAR_USED; + switch (pkt->getSize()) + { + case 1: + pkt_data = pkt->get(); + break; + case 2: + pkt_data = pkt->get(); + break; + case 4: + pkt_data = pkt->get(); + break; + default: + panic("Invalid size when writing to priority regs in Gic: %d\n", + pkt->getSize()); + } + DPRINTF(GIC, "gic distributor write register %#x size %#x value %#x \n", - daddr, pkt->getSize(), pkt->get()); + daddr, pkt->getSize(), pkt_data); if (daddr >= ICDISER_ST && daddr < ICDISER_ED + 4) { assert((daddr-ICDISER_ST) >> 2 < 32); -- 2.30.2