Skip to content

Commit 2ca3e4c

Browse files
Ensure that allocations in 4GB heap have non 0 GPU address to patch.
- That address is used later to deduce that allocation is non null - If we have address 0 it is incorrectly detected as null ptr on the GPU. Change-Id: I45e1bb31f1788528327da35bfdcc13f3fa6beec2
1 parent bb7f8d9 commit 2ca3e4c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

runtime/os_interface/windows/wddm/wddm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ bool Wddm::mapGpuVirtualAddressImpl(Gmm *gmm, D3DKMT_HANDLE handle, void *cpuPtr
349349
}
350350

351351
if (allocation32bit) {
352-
MapGPUVA.MinimumAddress = gfxPartition.Heap32[3].Base;
352+
MapGPUVA.MinimumAddress = gfxPartition.Heap32[3].Base + MemoryConstants::pageSize;
353353
MapGPUVA.MaximumAddress = gfxPartition.Heap32[3].Limit;
354354
MapGPUVA.BaseAddress = 0;
355355
}

unit_tests/os_interface/windows/wddm_memory_manager_tests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,14 @@ TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithNullptr) {
706706
memoryManager->freeGraphicsMemory(gpuAllocation);
707707
}
708708

709+
TEST_F(WddmMemoryManagerTest, given32BitAllocationWhenItIsCreatedThenItHasNonZeroGpuAddressToPatch) {
710+
auto *gpuAllocation = memoryManager->allocate32BitGraphicsMemory(3 * MemoryConstants::pageSize, nullptr, AllocationOrigin::EXTERNAL_ALLOCATION);
711+
712+
ASSERT_NE(nullptr, gpuAllocation);
713+
EXPECT_NE(0llu, gpuAllocation->getGpuAddressToPatch());
714+
memoryManager->freeGraphicsMemory(gpuAllocation);
715+
}
716+
709717
TEST_F(WddmMemoryManagerTest, Allocate32BitMemoryWithMisalignedHostPtrDoesNotDoTripleAlloc) {
710718
size_t misalignedSize = 0x2500;
711719
void *misalignedPtr = reinterpret_cast<void *>(0x12500);

0 commit comments

Comments
 (0)