Skip to content

Commit

Permalink
[L0] Fixes potential overwrite in ZeEventPoolDesc.pNext
Browse files Browse the repository at this point in the history
When both counterbased and interruptbased events are enabled there is a
ZeEventPoolDesc.pNext will get overwritten in
getFreeSlotInExistingOrNewPool. This fixes that.

Signed-off-by: Zhang, Winston <winston.zhang@intel.com>
  • Loading branch information
winstonzhang-intel committed Dec 20, 2024
1 parent 76a9623 commit 6f7cfcb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions source/adapters/level_zero/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,13 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
if (*ZePool == nullptr) {
ze_event_pool_counter_based_exp_desc_t counterBasedExt = {
ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC, nullptr, 0};

ze_intel_event_sync_mode_exp_desc_t eventSyncMode = {
ZE_INTEL_STRUCTURE_TYPE_EVENT_SYNC_MODE_EXP_DESC, nullptr, 0};
eventSyncMode.syncModeFlags =
ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_LOW_POWER_WAIT |
ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_SIGNAL_INTERRUPT;

ZeStruct<ze_event_pool_desc_t> ZeEventPoolDesc;
ZeEventPoolDesc.count = MaxNumEventsPerPool;
ZeEventPoolDesc.flags = 0;
Expand All @@ -552,14 +559,11 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool(
}
logger::debug("ze_event_pool_desc_t counter based flags set to: {}",
counterBasedExt.flags);
if (InterruptBasedEventEnabled) {
counterBasedExt.pNext = &eventSyncMode;
}
ZeEventPoolDesc.pNext = &counterBasedExt;
}
if (InterruptBasedEventEnabled) {
ze_intel_event_sync_mode_exp_desc_t eventSyncMode = {
ZE_INTEL_STRUCTURE_TYPE_EVENT_SYNC_MODE_EXP_DESC, nullptr, 0};
eventSyncMode.syncModeFlags =
ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_LOW_POWER_WAIT |
ZE_INTEL_EVENT_SYNC_MODE_EXP_FLAG_SIGNAL_INTERRUPT;
} else if (InterruptBasedEventEnabled) {
ZeEventPoolDesc.pNext = &eventSyncMode;
}

Expand Down

0 comments on commit 6f7cfcb

Please sign in to comment.