mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
fix: L0Debug - allow access only for reported stopped threads
- read/write registers/memory only allowed for threads reported as stopped by events - threads newly stopped, accidentally, that are resumed immediately are not allowed register/memory access Related-To: NEO-7776 Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
93f32f96b1
commit
802848a43f
@@ -211,7 +211,7 @@ bool DebugSession::areRequestedThreadsStopped(ze_device_thread_t thread) {
|
||||
|
||||
for (auto &threadId : singleThreads) {
|
||||
|
||||
if (allThreads[threadId]->isStopped()) {
|
||||
if (allThreads[threadId]->isReportedAsStopped()) {
|
||||
continue;
|
||||
}
|
||||
return false;
|
||||
@@ -708,6 +708,7 @@ void DebugSessionImp::markPendingInterruptsOrAddToNewlyStoppedFromRaisedAttentio
|
||||
request.second = true;
|
||||
}
|
||||
threadWasInterrupted = true;
|
||||
allThreads[threadId]->reportAsStopped();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,6 +833,7 @@ void DebugSessionImp::generateEventsForStoppedThreads(const std::vector<EuThread
|
||||
zet_debug_event_t debugEvent = {};
|
||||
for (auto &threadID : threadIds) {
|
||||
ze_device_thread_t thread = convertToApi(threadID);
|
||||
allThreads[threadID]->reportAsStopped();
|
||||
|
||||
debugEvent.type = ZET_DEBUG_EVENT_TYPE_THREAD_STOPPED;
|
||||
debugEvent.info.thread.thread = thread;
|
||||
@@ -1181,7 +1183,7 @@ ze_result_t DebugSessionImp::readRegisters(ze_device_thread_t thread, uint32_t t
|
||||
}
|
||||
auto threadId = convertToThreadId(thread);
|
||||
|
||||
if (!allThreads[threadId]->isStopped()) {
|
||||
if (!allThreads[threadId]->isReportedAsStopped()) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1214,7 @@ ze_result_t DebugSessionImp::writeRegisters(ze_device_thread_t thread, uint32_t
|
||||
}
|
||||
auto threadId = convertToThreadId(thread);
|
||||
|
||||
if (!allThreads[threadId]->isStopped()) {
|
||||
if (!allThreads[threadId]->isReportedAsStopped()) {
|
||||
return ZE_RESULT_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -122,6 +122,7 @@ class EuThread {
|
||||
return false;
|
||||
}
|
||||
PRINT_DEBUGGER_THREAD_LOG("Resumed thread: %s", toString().c_str());
|
||||
reportedAsStopped = false;
|
||||
state = State::Running;
|
||||
memoryHandle = invalidHandle;
|
||||
return true;
|
||||
@@ -155,6 +156,13 @@ class EuThread {
|
||||
uint8_t getLastCounter() const {
|
||||
return systemRoutineCounter;
|
||||
}
|
||||
void reportAsStopped() {
|
||||
reportedAsStopped = true;
|
||||
}
|
||||
bool isReportedAsStopped() {
|
||||
DEBUG_BREAK_IF(reportedAsStopped && state != State::Stopped);
|
||||
return reportedAsStopped;
|
||||
}
|
||||
|
||||
public:
|
||||
static constexpr uint64_t invalidHandle = std::numeric_limits<uint64_t>::max();
|
||||
@@ -164,6 +172,7 @@ class EuThread {
|
||||
std::atomic<State> state = State::Unavailable;
|
||||
uint8_t systemRoutineCounter = 0;
|
||||
std::atomic<uint64_t> memoryHandle = invalidHandle;
|
||||
std::atomic<bool> reportedAsStopped = false;
|
||||
};
|
||||
|
||||
static_assert(sizeof(EuThread::ThreadId) == sizeof(uint64_t));
|
||||
|
||||
Reference in New Issue
Block a user