Skip to contentSkip to conversation

drm/amd/amdgpu: Return error if initiating read out of range on vram

PATCH In review Tom St Denis 3 participants 3 messages May 23, 2017 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/amdgpu: Return error if initiating read out of range on vram

If you initiate a read that is out of the VRAM address space return ENXIO instead of 0.

Reads that begin below that point will read upto the VRAM limit as before.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
index 522f773203c8..399209495265 100644
@@ -1468,6 +1468,9 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
 	if (size & 0x3 || *pos & 0x3)
 		return -EINVAL;
 
+	if (*pos >= adev->mc.mc_vram_size)
+		return -ENXIO;
+
 	while (size) {
 		unsigned long flags;
 		uint32_t value;
Signature · 6 lines
2.12.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by
#2 lore raw

Am 23.05.2017 um 17:59 schrieb Tom St Denis:

Quoted 7 lines

If you initiate a read that is out of the VRAM address space return ENXIO instead of 0.

Reads that begin below that point will read upto the VRAM limit as before.

Quoted 9 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 522f773203c8..399209495265 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf, · line 1476

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
@@ -1468,6 +1468,9 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
  	if (size & 0x3 || *pos & 0x3)
  		return -EINVAL;
 
+	if (*pos >= adev->mc.mc_vram_size)
+		return -ENXIO;
+
  	while (size) {
  		unsigned long flags;
  		uint32_t value;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by Alex Deucher
#3 lore raw
In reply to a message not in the archive
Quoted 9 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Tom St Denis
Sent: Tuesday, May 23, 2017 11:59 AM
To: [email protected]
Cc: StDenis, Tom
Subject: [PATCH] drm/amd/amdgpu: Return error if initiating read out of range on vram

Quoted 7 lines

If you initiate a read that is out of the VRAM address space return ENXIO instead of 0.

Reads that begin below that point will read upto the VRAM limit as before.

Quoted 23 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +3 -0
index 522f773203c8..399209495265 100644
@@ -1468,6 +1468,9 @@ static ssize_t amdgpu_ttm_vram_read(struct file
 *f, char __user *buf,
 	if (size & 0x3 || *pos & 0x3)
 		return -EINVAL;
 
+	if (*pos >= adev->mc.mc_vram_size)
+		return -ENXIO;
+
 	while (size) {
 		unsigned long flags;

uint32_t value;
--
2.12.0

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx