diff options
| author | Jesse Zhang <Jesse.Zhang@amd.com> | 2026-10-20 10:15:22 +0800 |
|---|---|---|
| committer | Alex Deucher <alexander.deucher@amd.com> | 2026-11-04 12:10:07 -0500 |
| commit | 37cfaaa6b5e9448ef786342d470d0e0b8eb89fa6 (patch) | |
| tree | e2e812d2299eed5538587eb5eb46912f7d41b45f | |
| parent | 9b115ca0e5ceba08da9b9ca09e6ba65d1a2544c0 (diff) | |
drm/amdgpu: sign extend the addresses GEM_OP(GET_MAPPING_INFO) returns
GEM_VA takes the GPU virtual addresses above the VA hole sign extended,
like the rest of the UAPI, but GET_MAPPING_INFO reports them without the
upper bits, so they land in the hole. Mappings in the upper half of the
address space can't be recreated or removed with what it returns. On
navi31:
MAP at 0xffff800100000000 -> 0
GET_MAPPING_INFO -> addr 0x800100000000
UNMAP at 0x800100000000 -> -EINVAL
Sign extend the addresses before handing them out.
Fixes: 4d82724f7f2b ("drm/amdgpu: Add mapping info option for GEM_OP ioctl")
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 9d5524a339390da9145b19bfb40da45640332fb3)
Cc: stable@vger.kernel.org
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c index 3962b9f08dd6..3b8b089c258e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c @@ -1064,6 +1064,7 @@ error_put_gobj: int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) { + struct amdgpu_device *adev = drm_to_adev(dev); struct drm_amdgpu_gem_op *args = data; struct drm_gem_object *gobj; struct amdgpu_vm_bo_base *base; @@ -1170,7 +1171,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, amdgpu_vm_bo_va_for_each_valid_mapping(bo_va, mapping) { if (num_mappings < args->num_entries) { - vm_entries[num_mappings].addr = mapping->start * AMDGPU_GPU_PAGE_SIZE; + vm_entries[num_mappings].addr = + amdgpu_gmc_sign_extend(mapping->start * AMDGPU_GPU_PAGE_SIZE); vm_entries[num_mappings].size = (mapping->last - mapping->start + 1) * AMDGPU_GPU_PAGE_SIZE; vm_entries[num_mappings].offset = mapping->offset; vm_entries[num_mappings].flags = mapping->flags; @@ -1180,7 +1182,8 @@ int amdgpu_gem_op_ioctl(struct drm_device *dev, void *data, amdgpu_vm_bo_va_for_each_invalid_mapping(bo_va, mapping) { if (num_mappings < args->num_entries) { - vm_entries[num_mappings].addr = mapping->start * AMDGPU_GPU_PAGE_SIZE; + vm_entries[num_mappings].addr = + amdgpu_gmc_sign_extend(mapping->start * AMDGPU_GPU_PAGE_SIZE); vm_entries[num_mappings].size = (mapping->last - mapping->start + 1) * AMDGPU_GPU_PAGE_SIZE; vm_entries[num_mappings].offset = mapping->offset; vm_entries[num_mappings].flags = mapping->flags; |
