arch-sparc: Fix an operator precedence bug in the iob device.

Like in the nomali library, this bug is in some code making a bitmask
where what bits are enabled depends on some conditions. It used ?: to
evaluate the conditions and | to aggregate the bits, but didn't use any
()s, so the | happened first, then the ?:s. This would generate an
incorrect bitmask.

Change-Id: Iabcc8a9fd38cde5de3c0627a3b143407247c0c0e
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40955
Maintainer: Gabe Black <gabe.black@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Boris Shingarov <shingarov@gmail.com>
This commit is contained in:
Gabe Black
2021-02-08 00:36:51 -08:00
parent 99d5579656
commit 36b57f9b4e

View File

@@ -101,8 +101,8 @@ Iob::readIob(PacketPtr pkt)
if (accessAddr >= IntCtlAddr && accessAddr < IntCtlAddr + IntCtlSize) {
int index = (accessAddr - IntCtlAddr) >> 3;
uint64_t data = intCtl[index].mask ? 1 << 2 : 0 |
intCtl[index].pend ? 1 << 0 : 0;
uint64_t data = (intCtl[index].mask ? (1 << 2) : 0) |
(intCtl[index].pend ? (1 << 0) : 0);
pkt->setBE(data);
return;
}