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().
This commit is contained in:
Mitch Hayenga 2014-09-03 07:42:27 -04:00
parent 87f6034462
commit 71769d2d7b

View file

@ -395,8 +395,25 @@ Pl390::writeDistributor(PacketPtr pkt)
assert(pkt->req->hasContextId()); assert(pkt->req->hasContextId());
int ctx_id = pkt->req->contextId(); int ctx_id = pkt->req->contextId();
uint32_t pkt_data M5_VAR_USED;
switch (pkt->getSize())
{
case 1:
pkt_data = pkt->get<uint8_t>();
break;
case 2:
pkt_data = pkt->get<uint16_t>();
break;
case 4:
pkt_data = pkt->get<uint32_t>();
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", DPRINTF(GIC, "gic distributor write register %#x size %#x value %#x \n",
daddr, pkt->getSize(), pkt->get<uint32_t>()); daddr, pkt->getSize(), pkt_data);
if (daddr >= ICDISER_ST && daddr < ICDISER_ED + 4) { if (daddr >= ICDISER_ST && daddr < ICDISER_ED + 4) {
assert((daddr-ICDISER_ST) >> 2 < 32); assert((daddr-ICDISER_ST) >> 2 < 32);