Skip to content

Commit cf0c948

Browse files
committed
sync to asan
1 parent 3f4d489 commit cf0c948

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

source/loader/layers/sanitizer/asan/asan_shadow.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ ur_result_t ShadowMemoryGPU::Setup() {
104104
// shadow memory for each contexts, this will cause out-of-resource error when user uses
105105
// multiple contexts. Therefore, we just create one shadow memory here.
106106
static ur_result_t Result = [this]() {
107-
size_t ShadowSize = GetShadowSize();
107+
const size_t ShadowSize = GetShadowSize();
108+
// To reserve very large amount of GPU virtual memroy, the pStart param should be beyond
109+
// the SVM range, so that GFX driver will automatically switch to reservation on the GPU
110+
// heap.
111+
const void *StartAddress = (void *)(0x100'0000'0000'0000ULL);
108112
// TODO: Protect Bad Zone
109113
auto Result = getContext()->urDdiTable.VirtualMem.pfnReserve(
110-
Context, nullptr, ShadowSize, (void **)&ShadowBegin);
114+
Context, StartAddress, ShadowSize, (void **)&ShadowBegin);
111115
if (Result != UR_RESULT_SUCCESS) {
112116
getContext()->logger.error(
113117
"Shadow memory reserved failed with size {}: {}",

source/loader/layers/sanitizer/msan/msan_shadow.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ ur_result_t MsanShadowMemoryGPU::Setup() {
143143
auto Result = getContext()->urDdiTable.VirtualMem.pfnReserve(
144144
Context, StartAddress, ShadowSize, (void **)&ShadowBegin);
145145
if (Result != UR_RESULT_SUCCESS) {
146+
getContext()->logger.error(
147+
"Shadow memory reserved failed with size {}: {}",
148+
(void *)ShadowSize, Result);
146149
return Result;
147150
}
148151
ShadowEnd = ShadowBegin + ShadowSize;

0 commit comments

Comments
 (0)