Skip to contentSkip to conversation

drm/amd/amdgpu: Fix iova debugfs for non-iommu case

PATCH In review Tom St Denis 3 participants 13 messages Sep 19, 2017 – Sep 20, 2017 12 messages not in the archive

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

PATCH 1/1 drm/amd/amdgpu: Fix iova debugfs for non-iommu case

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -6
index 0e5f78f3a97e..1ee51a15a56c 100644
@@ -1791,13 +1791,14 @@ static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
 	struct iommu_domain *dom;
 
 	dom = iommu_get_domain_for_dev(adev->dev);
-	if (!dom)
-		return -EFAULT;
 
 	result = 0;
 	while (size) {
 		// get physical address and map
-		phys = iommu_iova_to_phys(dom, *pos);
+		if (dom)
+			phys = iommu_iova_to_phys(dom, *pos);
+		else
+			phys = *pos;
 
 		// copy upto one page
 		if (size > PAGE_SIZE)
@@ -1837,13 +1838,14 @@ static ssize_t amdgpu_iova_to_phys_write(struct file *f, const char __user *buf,
 	struct iommu_domain *dom;
 
 	dom = iommu_get_domain_for_dev(adev->dev);
-	if (!dom)
-		return -EFAULT;
 
 	result = 0;
 	while (size) {
 		// get physical address and map
-		phys = iommu_iova_to_phys(dom, *pos);
+		if (dom)
+			phys = iommu_iova_to_phys(dom, *pos);
+		else
+			phys = *pos;
 
 		// copy upto one page
 		if (size > PAGE_SIZE)
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]

#2 lore raw

Do we need to put #ifdefs of IOMMU_SUPPORT around this too?

The cavium driver doesn't seem to have any depends on IOMMU_* anywhere... (for instance)

Tom

Quoted 36 lines · Tom St Denis
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -5
index 0e5f78f3a97e..1ee51a15a56c 100644
@@ -1791,13 +1791,14 @@ static ssize_t amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
  	struct iommu_domain *dom;
 
  	dom = iommu_get_domain_for_dev(adev->dev);
-	if (!dom)
-		return -EFAULT;
 
  	result = 0;
  	while (size) {
  		// get physical address and map
-		phys = iommu_iova_to_phys(dom, *pos);
+		if (dom)
+			phys = iommu_iova_to_phys(dom, *pos);
+		else
+			phys = *pos;
 
  		// copy upto one page
  		if (size > PAGE_SIZE)
@@ -1837,13 +1838,14 @@ static ssize_t amdgpu_iova_to_phys_write(struct file *f, const char __user *buf,
  	struct iommu_domain *dom;
 
  	dom = iommu_get_domain_for_dev(adev->dev);
-	if (!dom)
-		return -EFAULT;
 
  	result = 0;

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

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +4 -1
  	while (size) {
  		// get physical address and map
-		phys = iommu_iova_to_phys(dom, *pos);
+		if (dom)
+			phys = iommu_iova_to_phys(dom, *pos);
+		else
+			phys = *pos;
 
  		// copy upto one page
  		if (size > PAGE_SIZE)

_______________________________________________
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): e9302f12-3f26-5176-79d1-5d837e44ebd5-5C7GfCeVMHo@public.gmane.org

#4 lore raw

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

Regards,
Christian.

Am 19.09.2017 um 17:36 schrieb Tom St Denis:

Quoted 47 lines

Do we need to put #ifdefs of IOMMU_SUPPORT around this too?

The cavium driver doesn't seem to have any depends on IOMMU_* anywhere... (for instance)

Tom

Quoted 39 lines · Tom St Denis
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 14 ++++++++------
  1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +8 -6
index 0e5f78f3a97e..1ee51a15a56c 100644
@@ -1791,13 +1791,14 @@ static ssize_t 
 amdgpu_iova_to_phys_read(struct file *f, char __user *buf,
      struct iommu_domain *dom;
        dom = iommu_get_domain_for_dev(adev->dev);
-    if (!dom)
-        return -EFAULT;
        result = 0;
      while (size) {
          // get physical address and map
-        phys = iommu_iova_to_phys(dom, *pos);
+        if (dom)
+            phys = iommu_iova_to_phys(dom, *pos);
+        else
+            phys = *pos;
            // copy upto one page
          if (size > PAGE_SIZE)
@@ -1837,13 +1838,14 @@ static ssize_t 
 amdgpu_iova_to_phys_write(struct file *f, const char __user *buf,
      struct iommu_domain *dom;
        dom = iommu_get_domain_for_dev(adev->dev);
-    if (!dom)
-        return -EFAULT;
        result = 0;
      while (size) {
          // get physical address and map
-        phys = iommu_iova_to_phys(dom, *pos);
+        if (dom)
+            phys = iommu_iova_to_phys(dom, *pos);
+        else
+            phys = *pos;
Quoted 8 lines

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

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
            // copy upto one page
          if (size > PAGE_SIZE)
 

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): 1e817718-572a-6d77-f948-ef3ed5eeef0c-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#6 lore raw
Quoted 3 lines · Christian König

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

I'm open to suggestions.

Tom
_______________________________________________
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): 5fbdcf5d-3be9-5af9-2321-8c59ebac4bb3-5C7GfCeVMHo@public.gmane.org

#8 lore raw

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 10 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

Christian.

Quoted 2 lines

Tom

_______________________________________________
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): 73bfce43-eeb2-f30a-21be-f59e1a9eb509-5C7GfCeVMHo@public.gmane.org

#10 lore raw
Quoted 6 lines · Christian König

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 5 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

Quoted 7 lines
Quoted 5 lines

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

On devices where there's no translation (e.g. Carrizo) does the iommu layer track mappings? I'm wondering if on those I could seek outside of boundaries and read system memory anyways.

Quoted 3 lines

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

I could easily do this (basically check if the domain is not null at debugfs init time).

Tom
_______________________________________________
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): d6fb88bd-0742-29c4-f091-091ea466d599-5C7GfCeVMHo@public.gmane.org

#12 lore raw

Am 19.09.2017 um 19:20 schrieb Tom St Denis:

Quoted 9 lines · Christian König
Quoted 8 lines

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 7 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

On devices where there's no translation (e.g. Carrizo) does the iommu layer track mappings? I'm wondering if on those I could seek outside of boundaries and read system memory anyways.

Why do you think there isn't any translation on CZ? I mean the whole ATC thing uses the IOMMU (v2 in this case) on APUs.

Quoted 5 lines
Quoted 3 lines

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

I could easily do this (basically check if the domain is not null at debugfs init time).

Yeah, please do this for now.

I mean it would be great to have this interface even with IOMMU disabled, but of hand I can't think of a way to allow this.

Christian.

Quoted 2 lines

Tom

_______________________________________________
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): cffc4608-454c-7ef5-c231-77e6b31d660c-5C7GfCeVMHo@public.gmane.org

#14 lore raw
Quoted 12 lines · Christian König

Am 19.09.2017 um 19:20 schrieb Tom St Denis:

Quoted 11 lines · Christian König
Quoted 10 lines

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 9 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

On devices where there's no translation (e.g. Carrizo) does the iommu layer track mappings?  I'm wondering if on those I could seek outside of boundaries and read system memory anyways.

Why do you think there isn't any translation on CZ? I mean the whole ATC thing uses the IOMMU (v2 in this case) on APUs.

On my Carrizo devel system (A12-9800) the GPU dma addresses are physical addresses. I only first saw iommu with APUs enabled on Raven.

I'll see if I can read non-mapped pages via the iova file on my Carrizo.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

I could easily do this (basically check if the domain is not null at debugfs init time).

Yeah, please do this for now.

I mean it would be great to have this interface even with IOMMU disabled, but of hand I can't think of a way to allow this.

Sent to the list already. Tested with enabled/disabled. Seems to work for me.

Tom
_______________________________________________
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): a0abde86-0700-3155-9410-a14332836b95-5C7GfCeVMHo@public.gmane.org

#16 lore raw

As I predicted ...

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova

000c0000: 55aa 74e9 a902 0000 0000 0000 0000 0000  U.t.............
000c0010: 0000 0000 0000 0000 4c02 0000 0000 4942  ........L.....IB
000c0020: 4daa 2e93 0000 0000 0000 0000 0000 0004  M...............
000c0030: 2037 3631 3239 3535 3230 0000 0000 0000   761295520......
000c0040: a102 0000 0000 0000 2802 0000 0000 0000  ........(.......
000c0050: 3037 2f32 372f 3136 2030 343a 3036 0000  07/27/16 04:06..
000c0060: 3600 0000 e9b4 0300 e9c3 0300 0000 f400  6...............
000c0070: 0013 0000 00d0 0100 1a16 20e1 0280 7e00  .......... ...~.
000c0080: a200 4402 1200 0000 0000 003c 400e 0207  ..D........<@...
000c0090: 3c01 1a00 0400 0000 eea0 ff06 0008 3040  <.............0@
000c00a0: 0e01 0000 0000 0000 1403 0000 0000 0000  ................
000c00b0: be7e 1100 b907 1ad6 502c 0000 0000 0000  .~......P,......
000c00c0: 0000 0000 1440 4143 0000 0000 1000 0000  .....@AC........
000c00d0: 4200 0000 407c 0600 2000 2000 1200 0e00  B...@|.. . .....
000c00e0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
000c00f0: 0000 0000 3131 332d 4339 3534 3031 3031  ....113-C9540101
000c0100: 2d30 3036 0046 474c 2045 4c4c 4553 4d45  -006.FGL ELLESME
000c0110: 5245 0050 4349 5f45 5850 5245 5353 0047  RE.PCI_EXPRESS.G
000c0120: 4444 5235 000d 0a43 3935 3420 506f 6c61  DDR5...C954 Pola
000c0130: 7269 7331 3020 474c 2041 3120 4744 4452  ris10 GL A1 GDDR
000c0140: 3520 3235 364d 7833 3220 3847 4220 3330  5 256Mx32 8GB 30
000c0150: 3065 2f33 3030 6d20 2020 2020 2020 2020  0e/300m
000c0160: 2020 2020 2020 2020 2020 2020 2020 2020
000c0170: 2020 200d 0a00 0d0a 200d 0a00 2843 2920     ..... ...(C)
000c0180: 3139 3838 2d32 3031 302c 2041 6476 616e  1988-2010, Advan
000c0190: 6365 6420 4d69 6372 6f20 4465 7669 6365  ced Micro Device
000c01a0: 732c 2049 6e63 2e00 4154 4f4d 4249 4f53  s, Inc..ATOMBIOS
000c01b0: 424b 2d41 4d44 2056 4552 3031 352e 3035  BK-AMD VER015.05
000c01c0: 302e 3030 302e 3030 302e 3030 3730 3036  0.000.000.007006
000c01d0: 0043 3935 3430 3130 312e 3030 3600 3132  .C9540101.006.12
000c01e0: 3935 3838 3720 0033 3534 3731 3220 2000  95887 .354712  .
000c01f0: 2020 2020 2020 2020 0041 4d44 5f45 4c4c          .AMD_ELL
000c0200: 4553 4d45 5245 5f43 3935 3430 315f 5854  ESMERE_C95401_XT
000c0210: 5f41 315f 4744 355f 3847 425c 636f 6e66  _A1_GD5_8GB\conf
000c0220: 6967 2e68 0000 0090 2400 0101 4154 4f4d  ig.h....$...ATOM

I can dump arbitrary system memory with the iommu enabled in the bios via my carrizo "dev" in the debugfs entry.

So if the issue is arbitrary access is a no no (and I don't get why) then the entire patch is a NAK because clearly I can "abuse" it.

Tom

Quoted 35 lines · Tom St Denis
Quoted 12 lines · Christian König

Am 19.09.2017 um 19:20 schrieb Tom St Denis:

Quoted 11 lines · Christian König
Quoted 10 lines

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 9 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

On devices where there's no translation (e.g. Carrizo) does the iommu layer track mappings?  I'm wondering if on those I could seek outside of boundaries and read system memory anyways.

Why do you think there isn't any translation on CZ? I mean the whole ATC thing uses the IOMMU (v2 in this case) on APUs.

On my Carrizo devel system (A12-9800) the GPU dma addresses are physical addresses.  I only first saw iommu with APUs enabled on Raven.

I'll see if I can read non-mapped pages via the iova file on my Carrizo.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

I could easily do this (basically check if the domain is not null at debugfs init time).

Yeah, please do this for now.

I mean it would be great to have this interface even with IOMMU disabled, but of hand I can't think of a way to allow this.

Quoted 7 lines

Sent to the list already.  Tested with enabled/disabled.  Seems to work for me.

Tom
_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): bb94f775-ecd9-7752-9fc7-41a1a7a1c11d-5C7GfCeVMHo@public.gmane.org

#18 lore raw
Quoted 1 line

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova

Actually 0xC0000 is a special address, e.g. video BIOS if I'm not completely mistaken.

Take a look at /proc/iomem and try reading something which is marked as "System RAM".

If that still works we are lost and need to get back to square one.

On the other hand give me a day to check if we can't figure out through reverse mapping if a page is TTM allocated or not.

Christian.

Am 19.09.2017 um 19:37 schrieb Tom St Denis:

Quoted 39 lines

As I predicted ...

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova 000c0000: 55aa 74e9 a902 0000 0000 0000 0000 0000 U.t............. 000c0010: 0000 0000 0000 0000 4c02 0000 0000 4942 ........L.....IB 000c0020: 4daa 2e93 0000 0000 0000 0000 0000 0004 M............... 000c0030: 2037 3631 3239 3535 3230 0000 0000 0000 761295520...... 000c0040: a102 0000 0000 0000 2802 0000 0000 0000 ........(....... 000c0050: 3037 2f32 372f 3136 2030 343a 3036 0000 07/27/16 04:06.. 000c0060: 3600 0000 e9b4 0300 e9c3 0300 0000 f400 6............... 000c0070: 0013 0000 00d0 0100 1a16 20e1 0280 7e00 .......... ...~. 000c0080: a200 4402 1200 0000 0000 003c 400e 0207 ..D........<@... 000c0090: 3c01 1a00 0400 0000 eea0 ff06 0008 3040 <.............0@ 000c00a0: 0e01 0000 0000 0000 1403 0000 0000 0000 ................ 000c00b0: be7e 1100 b907 1ad6 502c 0000 0000 0000 .~......P,...... 000c00c0: 0000 0000 1440 4143 0000 0000 1000 0000 .....@AC........ 000c00d0: 4200 0000 407c 0600 2000 2000 1200 0e00 B...@|.. . ..... 000c00e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................ 000c00f0: 0000 0000 3131 332d 4339 3534 3031 3031 ....113-C9540101 000c0100: 2d30 3036 0046 474c 2045 4c4c 4553 4d45 -006.FGL ELLESME 000c0110: 5245 0050 4349 5f45 5850 5245 5353 0047 RE.PCI_EXPRESS.G

000c0120: 4444 5235 000d 0a43 3935 3420 506f 6c61  DDR5...C954 Pola
000c0130: 7269 7331 3020 474c 2041 3120 4744 4452  ris10 GL A1 GDDR
000c0140: 3520 3235 364d 7833 3220 3847 4220 3330  5 256Mx32 8GB 30
000c0150: 3065 2f33 3030 6d20 2020 2020 2020 2020  0e/300m
000c0160: 2020 2020 2020 2020 2020 2020 2020 2020
000c0170: 2020 200d 0a00 0d0a 200d 0a00 2843 2920     ..... ...(C)
000c0180: 3139 3838 2d32 3031 302c 2041 6476 616e  1988-2010, Advan
000c0190: 6365 6420 4d69 6372 6f20 4465 7669 6365  ced Micro Device
000c01a0: 732c 2049 6e63 2e00 4154 4f4d 4249 4f53  s, Inc..ATOMBIOS
000c01b0: 424b 2d41 4d44 2056 4552 3031 352e 3035  BK-AMD VER015.05

000c01c0: 302e 3030 302e 3030 302e 3030 3730 3036 0.000.000.007006 000c01d0: 0043 3935 3430 3130 312e 3030 3600 3132 .C9540101.006.12 000c01e0: 3935 3838 3720 0033 3534 3731 3220 2000 95887 .354712 . 000c01f0: 2020 2020 2020 2020 0041 4d44 5f45 4c4c .AMD_ELL 000c0200: 4553 4d45 5245 5f43 3935 3430 315f 5854 ESMERE_C95401_XT 000c0210: 5f41 315f 4744 355f 3847 425c 636f 6e66 _A1_GD5_8GB\conf 000c0220: 6967 2e68 0000 0090 2400 0101 4154 4f4d ig.h....$...ATOM

Quoted 50 lines

I can dump arbitrary system memory with the iommu enabled in the bios via my carrizo "dev" in the debugfs entry.

So if the issue is arbitrary access is a no no (and I don't get why) then the entire patch is a NAK because clearly I can "abuse" it.

Tom

Quoted 42 lines · Tom St Denis
Quoted 12 lines · Christian König

Am 19.09.2017 um 19:20 schrieb Tom St Denis:

Quoted 11 lines · Christian König
Quoted 10 lines

Am 19.09.2017 um 19:14 schrieb Tom St Denis:

Quoted 9 lines · Christian König
Quoted 3 lines

As far as I know we don't need #ifdefs cause there are dummy functions when IOMMU is not compiled in.

But this patch is a NAK since it circumvents the /dev/mem restriction when IOMMU is disabled and that is not something we can easily allow.

I raised this objection 24 hours ago and was told to go ahead with the read/write methods anyways.

Short of making a list of mappings/allocations in the ttm layer I have no idea how we would track this in the non-iommu case which means the entire iova debugfs entry should have been NAK'ed in the first place.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

I'm open to suggestions.

As long as IOMMU is enabled the entry is perfectly fine, cause only memory mapped to the IOMMU is accessible to the GPU and so accessible using the debugfs entry as well.

On devices where there's no translation (e.g. Carrizo) does the iommu layer track mappings? I'm wondering if on those I could seek outside of boundaries and read system memory anyways.

Why do you think there isn't any translation on CZ? I mean the whole ATC thing uses the IOMMU (v2 in this case) on APUs.

On my Carrizo devel system (A12-9800) the GPU dma addresses are physical addresses. I only first saw iommu with APUs enabled on Raven.

I'll see if I can read non-mapped pages via the iova file on my Carrizo.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

Only when IOMMU is disabled we can't go this way cause we can't know which memory is mapped to the driver and which isn't (or could we somehow track this?).

I suggest to not create the file in the first place if IOMMU is disabled.

I could easily do this (basically check if the domain is not null at debugfs init time).

Yeah, please do this for now.

I mean it would be great to have this interface even with IOMMU disabled, but of hand I can't think of a way to allow this.

Sent to the list already. Tested with enabled/disabled. Seems to work for me.

Tom
_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): eb89afe7-469a-c298-fba1-eb1d2c4c725d-5C7GfCeVMHo@public.gmane.org

#20 lore raw
Quoted 3 lines · Christian König
Quoted 1 line

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova

Actually 0xC0000 is a special address, e.g. video BIOS if I'm not completely mistaken.

Not sure why that would be mapped by the driver but I can also read the kernel's bss section with this...

$ xxd -l 1048576 -s 0x01e4c000  /sys/kernel/debug/dri/0/amdgpu_iova

...<snip>...

01e6a430: 4c69 6e75 7820 7665 7273 696f 6e20 342e  Linux version 4.
01e6a440: 3133 2e30 2d72 6335 2b20 2872 6f6f 7440  13.0-rc5+ (root@
01e6a450: 6361 7272 697a 6f29 2028 6763 6320 7665  carrizo) (gcc ve
01e6a460: 7273 696f 6e20 362e 332e 3120 3230 3136  rsion 6.3.1 2016
01e6a470: 3132 3231 2028 5265 6420 4861 7420 362e  1221 (Red Hat 6.
01e6a480: 332e 312d 3129 2028 4743 4329 2920 2333  3.1-1) (GCC)) #3
01e6a490: 3120 534d 5020 5475 6520 5365 7020 3139  1 SMP Tue Sep 19

01e6a4a0: 2030 373a 3138 3a33 3120 4544 5420 3230 07:18:31 EDT 20
<snip>

That's part of the dmesg buffer apparently.

I pointed it at all sorts of address (bios/system ram/etc) it pretty much will read anything.

Tom
_______________________________________________
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): df37f22f-ee32-977a-0d44-2dd35fcac95b-5C7GfCeVMHo@public.gmane.org

#22 lore raw

Am 19.09.2017 um 23:38 schrieb Tom St Denis:

Quoted 17 lines · Christian König
Quoted 3 lines
Quoted 1 line

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova

Actually 0xC0000 is a special address, e.g. video BIOS if I'm not completely mistaken.

Not sure why that would be mapped by the driver but I can also read the kernel's bss section with this...

$ xxd -l 1048576 -s 0x01e4c000 /sys/kernel/debug/dri/0/amdgpu_iova

...<snip>...

01e6a430: 4c69 6e75 7820 7665 7273 696f 6e20 342e  Linux version 4.
01e6a440: 3133 2e30 2d72 6335 2b20 2872 6f6f 7440  13.0-rc5+ (root@
01e6a450: 6361 7272 697a 6f29 2028 6763 6320 7665  carrizo) (gcc ve
01e6a460: 7273 696f 6e20 362e 332e 3120 3230 3136  rsion 6.3.1 2016
01e6a470: 3132 3231 2028 5265 6420 4861 7420 362e  1221 (Red Hat 6.
01e6a480: 332e 312d 3129 2028 4743 4329 2920 2333  3.1-1) (GCC)) #3
01e6a490: 3120 534d 5020 5475 6520 5365 7020 3139  1 SMP Tue Sep 19
Quoted 6 lines

01e6a4a0: 2030 373a 3138 3a33 3120 4544 5420 3230 07:18:31 EDT 20
<snip>

That's part of the dmesg buffer apparently.

I pointed it at all sorts of address (bios/system ram/etc) it pretty much will read anything.

Yeah, feared that this would be the case. OK in this case your original concern was completely correct and we can't allow this in general.

Christian.

Quoted 6 lines

Tom
_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): 9f37eed5-44b9-e175-284a-aa1bfd3223c7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#24 lore raw
Quoted 21 lines · Christian König

Am 19.09.2017 um 23:38 schrieb Tom St Denis:

Quoted 20 lines · Christian König
Quoted 3 lines
Quoted 1 line

[root@carrizo ~]# xxd -l 1024 -s 0xC0000 /sys/kernel/debug/dri/0/amdgpu_iova

Actually 0xC0000 is a special address, e.g. video BIOS if I'm not completely mistaken.

Not sure  why that would be mapped by the driver but I can also read the kernel's bss section with this...

$ xxd -l 1048576 -s 0x01e4c000 /sys/kernel/debug/dri/0/amdgpu_iova

...<snip>...
01e6a430: 4c69 6e75 7820 7665 7273 696f 6e20 342e  Linux version 4. 01e6a440: 3133 2e30 2d72 6335 2b20 2872 6f6f 7440  13.0-rc5+ (root@ 01e6a450: 6361 7272 697a 6f29 2028 6763 6320 7665  carrizo) (gcc ve 01e6a460: 7273 696f 6e20 362e 332e 3120 3230 3136  rsion 6.3.1 2016 01e6a470: 3132 3231 2028 5265 6420 4861 7420 362e  1221 (Red Hat 6. 01e6a480: 332e 312d 3129 2028 4743 4329 2920 2333  3.1-1) (GCC)) #3 01e6a490: 3120 534d 5020 5475 6520 5365 7020 3139  1 SMP Tue Sep 19 01e6a4a0: 2030 373a 3138 3a33 3120 4544 5420 3230   07:18:31 EDT 20 <snip>

Quoted 5 lines
Quoted 3 lines

That's part of the dmesg buffer apparently.

I pointed it at all sorts of address (bios/system ram/etc) it pretty much will read anything.

Yeah, feared that this would be the case. OK in this case your original concern was completely correct and we can't allow this in general.

Which means we want to go to a different v2 of this patch

https://lists.freedesktop.org/archives/amd-gfx/2017-September/013329.html

Where I check if domain==NULL and return the input or use the iova_to_phys to translate.

Then in umr I have to revert the last commit on master and apply the original patch I had sent to the list:

https://lists.freedesktop.org/archives/amd-gfx/2017-September/013332.html

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