Skip to content

Commit

Permalink
Fix intercept layer access to array of handles and return of logs
Browse files Browse the repository at this point in the history
Related-To: VLCLJ-2021

Signed-off-by: Spruit, Neil R <[email protected]>
  • Loading branch information
nrspruit committed Aug 30, 2023
1 parent 39e42df commit c2cb388
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
13 changes: 13 additions & 0 deletions scripts/templates/ldrddi.cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ namespace loader
%for i, item in enumerate(th.get_loader_prologue(n, tags, obj, meta)):
%if 0 == i:
// extract driver's function pointer table
%if 'range' in item:
auto dditable = reinterpret_cast<${item['obj']}*>( ${item['name']}[ 0 ] )->dditable;
%else:
auto dditable = reinterpret_cast<${item['obj']}*>( ${item['name']} )->dditable;
%endif
auto ${th.make_pfn_name(n, tags, obj)} = dditable->${n}.${th.get_table_name(n, tags, obj)}.${th.make_pfn_name(n, tags, obj)};
if( nullptr == ${th.make_pfn_name(n, tags, obj)} )
return ${X}_RESULT_ERROR_UNINITIALIZED;
Expand Down Expand Up @@ -181,9 +185,11 @@ namespace loader
del add_local%>
%for i, item in enumerate(th.get_loader_epilogue(n, tags, obj, meta)):
%if 0 == i:
%if not re.match(r"\w+ModuleDynamicLink$", th.make_func_name(n, tags, obj)) and not re.match(r"\w+ModuleCreate$", th.make_func_name(n, tags, obj)):
if( ${X}_RESULT_SUCCESS != result )
return result;

%endif
%endif
%if item['release']:
// release loader handle
Expand Down Expand Up @@ -225,6 +231,13 @@ namespace loader
}
%endif

%if 0 == i:
%if re.match(r"\w+ModuleDynamicLink$", th.make_func_name(n, tags, obj)) or re.match(r"\w+ModuleCreate$", th.make_func_name(n, tags, obj)):
if( ${X}_RESULT_SUCCESS != result )
return result;

%endif
%endif
%endfor
%endif
return result;
Expand Down
16 changes: 8 additions & 8 deletions source/loader/ze_ldrddi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3071,9 +3071,6 @@ namespace loader
// forward to device-driver
result = pfnCreate( hContext, hDevice, desc, phModule, phBuildLog );

if( ZE_RESULT_SUCCESS != result )
return result;

try
{
// convert driver handle to loader handle
Expand All @@ -3085,6 +3082,9 @@ namespace loader
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}

if( ZE_RESULT_SUCCESS != result )
return result;

try
{
// convert driver handle to loader handle
Expand Down Expand Up @@ -3143,7 +3143,7 @@ namespace loader
ze_result_t result = ZE_RESULT_SUCCESS;

// extract driver's function pointer table
auto dditable = reinterpret_cast<ze_module_object_t*>( phModules )->dditable;
auto dditable = reinterpret_cast<ze_module_object_t*>( phModules[ 0 ] )->dditable;
auto pfnDynamicLink = dditable->ze.Module.pfnDynamicLink;
if( nullptr == pfnDynamicLink )
return ZE_RESULT_ERROR_UNINITIALIZED;
Expand All @@ -3157,9 +3157,6 @@ namespace loader
result = pfnDynamicLink( numModules, phModulesLocal, phLinkLog );
delete []phModulesLocal;

if( ZE_RESULT_SUCCESS != result )
return result;

try
{
// convert driver handle to loader handle
Expand All @@ -3172,6 +3169,9 @@ namespace loader
result = ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY;
}

if( ZE_RESULT_SUCCESS != result )
return result;

return result;
}

Expand Down Expand Up @@ -4818,7 +4818,7 @@ namespace loader
ze_result_t result = ZE_RESULT_SUCCESS;

// extract driver's function pointer table
auto dditable = reinterpret_cast<ze_module_object_t*>( phModules )->dditable;
auto dditable = reinterpret_cast<ze_module_object_t*>( phModules[ 0 ] )->dditable;
auto pfnInspectLinkageExt = dditable->ze.Module.pfnInspectLinkageExt;
if( nullptr == pfnInspectLinkageExt )
return ZE_RESULT_ERROR_UNINITIALIZED;
Expand Down

0 comments on commit c2cb388

Please sign in to comment.