From: Mukul Joshi <[email protected]>

Update the address mask to support 52-bits addresses when validating the
PDE addresses for GFX 12.1. Currently the address mask was incorrect and
only permitted 48-bits addresses. Additionally, drop the BUG_ON() and
replace it with code to reset the invalid address and valid bit if the
address verification fails. This should help generate a page fault instead
of crashing the kernel.

Signed-off-by: Mukul Joshi <[email protected]>
Reviewed-by: Philip Yang <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
---
 drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c 
b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
index 0d89cae582a8a..e8e35d1b22765 100644
--- a/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v12_1.c
@@ -575,7 +575,12 @@ static void gmc_v12_1_get_vm_pde(struct amdgpu_device 
*adev, int level,
        if (!(*flags & AMDGPU_PDE_PTE_GFX12) && !(*flags & AMDGPU_PTE_SYSTEM))
                *addr = adev->vm_manager.vram_base_offset + *addr -
                        adev->gmc.vram_start;
-       BUG_ON(*addr & 0xFFFF00000000003FULL);
+
+       if (*addr & ~adev->gmc.pte_addr_mask) {
+               dev_err(adev->dev, "Invalid PDE address: %llx\n", *addr);
+               *addr = 0;
+               *flags &= ~AMDGPU_PTE_VALID;
+       }
 
        *flags |= AMDGPU_PTE_SNOOPED;
 
-- 
2.55.0

Reply via email to