Skip to content

Commit

Permalink
Added exception handling in utils.cpp:get_cpu_bus()
Browse files Browse the repository at this point in the history
Avoid early termination without any message if a PCI handle fails to open.
  • Loading branch information
spersvold authored and rdementi committed Oct 5, 2023
1 parent 6a0f81b commit 3674dbc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ bool get_cpu_bus(uint32 msmDomain, uint32 msmBus, uint32 msmDev, uint32 msmFunc,
uint32 busNo = 0x0;

//std::cout << "get_cpu_bus: d=" << std::hex << msmDomain << ",b=" << msmBus << ",d=" << msmDev << ",f=" << msmFunc << std::dec << " \n";
try {
PciHandleType h(msmDomain, msmBus, msmDev, msmFunc);

h.read32(SPR_MSM_REG_CPUBUSNO_VALID_OFFSET, &cpuBusValid);
Expand Down Expand Up @@ -1138,6 +1139,11 @@ bool get_cpu_bus(uint32 msmDomain, uint32 msmBus, uint32 msmDev, uint32 msmFunc,
cpuPackageId = sadControlCfg & 0xf;

return true;
} catch (...)
{
std::cerr << "Warning: unable to enumerate CPU Buses" << std::endl;
return false;
}
}

#ifdef __linux__
Expand Down

0 comments on commit 3674dbc

Please sign in to comment.