Skip to content

Commit

Permalink
sync to asan
Browse files Browse the repository at this point in the history
  • Loading branch information
AllanZyne committed Dec 25, 2024
1 parent 3f4d489 commit cf0c948
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/loader/layers/sanitizer/asan/asan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,14 @@ ur_result_t ShadowMemoryGPU::Setup() {
// shadow memory for each contexts, this will cause out-of-resource error when user uses
// multiple contexts. Therefore, we just create one shadow memory here.
static ur_result_t Result = [this]() {
size_t ShadowSize = GetShadowSize();
const size_t ShadowSize = GetShadowSize();
// To reserve very large amount of GPU virtual memroy, the pStart param should be beyond
// the SVM range, so that GFX driver will automatically switch to reservation on the GPU
// heap.
const void *StartAddress = (void *)(0x100'0000'0000'0000ULL);
// TODO: Protect Bad Zone
auto Result = getContext()->urDdiTable.VirtualMem.pfnReserve(
Context, nullptr, ShadowSize, (void **)&ShadowBegin);
Context, StartAddress, ShadowSize, (void **)&ShadowBegin);
if (Result != UR_RESULT_SUCCESS) {
getContext()->logger.error(
"Shadow memory reserved failed with size {}: {}",
Expand Down
3 changes: 3 additions & 0 deletions source/loader/layers/sanitizer/msan/msan_shadow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ ur_result_t MsanShadowMemoryGPU::Setup() {
auto Result = getContext()->urDdiTable.VirtualMem.pfnReserve(
Context, StartAddress, ShadowSize, (void **)&ShadowBegin);
if (Result != UR_RESULT_SUCCESS) {
getContext()->logger.error(
"Shadow memory reserved failed with size {}: {}",
(void *)ShadowSize, Result);
return Result;
}
ShadowEnd = ShadowBegin + ShadowSize;
Expand Down

0 comments on commit cf0c948

Please sign in to comment.