libhsakmt: Add check for the runntime debuuger

Avoiding the segfault, runtime debugger enable is not supported
if the firmware of gpu doesn't support debug exceptions.

Signed-off-by: jie1zhan <jesse.zhang@amd.com>
Change-Id: Ifad57a6e78cb1c92b1f8927355ece8c64e89c51b
Tento commit je obsažen v:
jie1zhan
2022-09-01 17:06:23 +08:00
odevzdal Jesse Zhang
rodič 57a1c6f3ff
revize d98c729ff9
+19
Zobrazit soubor
@@ -302,6 +302,25 @@ hsaKmtGetKernelDebugTrapVersionInfo(
static HSAKMT_STATUS checkRuntimeDebugSupport(void) {
HSAuint32 kMajor, kMinor;
HsaNodeProperties node = {0};
HsaSystemProperties props = {0};
memset(&node, 0x00, sizeof(node));
memset(&props, 0x00, sizeof(props));
if (hsaKmtAcquireSystemProperties(&props))
return HSAKMT_STATUS_ERROR;
//the firmware of gpu node doesn't support the debugger, disable it.
for (uint32_t i = 0; i < props.NumNodes; i++) {
if (hsaKmtGetNodeProperties(i, &node))
return HSAKMT_STATUS_ERROR;
//ignore cpu node
if (node.NumCPUCores)
continue;
if (!node.Capability.ui32.DebugSupportedFirmware)
return HSAKMT_STATUS_NOT_SUPPORTED;
}
if (hsaKmtGetKernelDebugTrapVersionInfo(&kMajor, &kMinor))
return HSAKMT_STATUS_NOT_SUPPORTED;