Skip to content

Commit 8e65aa4

Browse files
Alexander Antonovrdementi
authored andcommitted
Add checking first valid BUS ID to get_cpu_bus() function
It's possible to have not enabled first stack
1 parent 11cc543 commit 8e65aa4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/utils.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,13 @@ bool get_cpu_bus(uint32 msmDomain, uint32 msmBus, uint32 msmDev, uint32 msmFunc,
12101210
//std::cout << std::hex << "get_cpu_bus: busNo=0x" << busNo << std::dec << "\n";
12111211
}
12121212

1213-
cpuBusNo0 = cpuBusNo[0] & 0xff;
1213+
/*
1214+
* It's possible to have not enabled first stack that's why
1215+
* need to find the first valid bus to read CSR
1216+
*/
1217+
int firstValidBusId = 0;
1218+
while (!((cpuBusValid >> firstValidBusId) & 0x1)) firstValidBusId++;
1219+
int cpuBusNo0 = (cpuBusNo[(int)(firstValidBusId / 4)] >> ((firstValidBusId % 4) * 8)) & 0xff;
12141220
PciHandleType sad_cfg_handler(msmDomain, cpuBusNo0, 0, 0);
12151221

12161222
sad_cfg_handler.read32(SPR_SAD_REG_CTL_CFG_OFFSET, &sadControlCfg);

0 commit comments

Comments
 (0)