mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
fix: add fallback for invalid handles in extension functions
handle context, commandlist, driver, device, event, image and kernel handles Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
066282e15b
commit
d45c16dfc2
@@ -20,6 +20,7 @@
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
|
||||
#include "level_zero/core/source/cmdlist/cmdlist_launch_params.h"
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
@@ -28,7 +29,9 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
struct _ze_command_list_handle_t {};
|
||||
struct _ze_command_list_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
};
|
||||
|
||||
namespace NEO {
|
||||
class ScratchSpaceController;
|
||||
|
||||
@@ -10,10 +10,12 @@
|
||||
#include "shared/source/memory_manager/allocation_type.h"
|
||||
#include "shared/source/unified_memory/unified_memory.h"
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
struct _ze_context_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
virtual ~_ze_context_handle_t() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "shared/source/os_interface/product_helper.h"
|
||||
#include "shared/source/utilities/tag_allocator.h"
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
@@ -19,7 +20,9 @@
|
||||
|
||||
static_assert(NEO::ProductHelper::uuidSize == ZE_MAX_DEVICE_UUID_SIZE);
|
||||
|
||||
struct _ze_device_handle_t {};
|
||||
struct _ze_device_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
};
|
||||
namespace NEO {
|
||||
class CommandStreamReceiver;
|
||||
class DebuggerL0;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zes_api.h>
|
||||
|
||||
@@ -15,6 +16,7 @@
|
||||
#include <vector>
|
||||
|
||||
struct _ze_driver_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
virtual ~_ze_driver_handle_t() = default;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
||||
#include "shared/source/os_interface/os_time.h"
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
#include <atomic>
|
||||
@@ -22,7 +23,9 @@
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
struct _ze_event_handle_t {};
|
||||
struct _ze_event_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
};
|
||||
|
||||
struct _ze_event_pool_handle_t {};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2022-2023 Intel Corporation
|
||||
# Copyright (C) 2022-2024 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@@ -7,6 +7,7 @@
|
||||
target_sources(${L0_STATIC_LIB_NAME}
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api_handle_helper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/api_specific_config_l0.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/error_code_helper_l0.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/error_code_helper_l0.h
|
||||
@@ -14,4 +15,4 @@ target_sources(${L0_STATIC_LIB_NAME}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/l0_gfx_core_helper_factory_init.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/l0_populate_factory.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/properties_parser.h
|
||||
)
|
||||
)
|
||||
|
||||
23
level_zero/core/source/helpers/api_handle_helper.h
Normal file
23
level_zero/core/source/helpers/api_handle_helper.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2024 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
constexpr uint64_t objMagicValue = 0x8D7E6A5D4B3E2E1FULL;
|
||||
|
||||
template <typename T>
|
||||
inline T toInternalType(T input) {
|
||||
if (!input || input->objMagic == objMagicValue) {
|
||||
return input;
|
||||
}
|
||||
input = *reinterpret_cast<T *>(input);
|
||||
if (input->objMagic == objMagicValue) {
|
||||
return input;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -7,9 +7,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
|
||||
struct _ze_image_handle_t {};
|
||||
struct _ze_image_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
};
|
||||
|
||||
namespace NEO {
|
||||
struct ImageInfo;
|
||||
|
||||
@@ -13,13 +13,16 @@
|
||||
#include "shared/source/memory_manager/unified_memory_manager.h"
|
||||
#include "shared/source/unified_memory/unified_memory.h"
|
||||
|
||||
#include "level_zero/core/source/helpers/api_handle_helper.h"
|
||||
#include <level_zero/ze_api.h>
|
||||
#include <level_zero/zet_api.h>
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct _ze_kernel_handle_t {};
|
||||
struct _ze_kernel_handle_t {
|
||||
const uint64_t objMagic = objMagicValue;
|
||||
};
|
||||
|
||||
namespace NEO {
|
||||
class Device;
|
||||
|
||||
Reference in New Issue
Block a user