Skip to contentSkip to conversation

drm/radeon: fix R600_PTE_GART handling

PATCH Applied Christian König 2 participants 2 messages Jul 22, 2014

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

PATCH 1/1 drm/radeon: fix R600_PTE_GART handling

From: Christian König <[email protected]>

That didn't worked correctly any more and opened up a security problem.

---
 drivers/gpu/drm/radeon/cik_sdma.c | 3 +--
 drivers/gpu/drm/radeon/radeon.h   | 6 +++---
 drivers/gpu/drm/radeon/si_dma.c   | 3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/cik_sdma.c +1 -2
index 8534068..28ca3cb 100644
@@ -775,8 +775,7 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev,
 
 	trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-	/* XXX: How to distinguish between GART and other system memory pages? */
-	if (flags & R600_PTE_SYSTEM) {
+	if ((flags & R600_PTE_GART_MASK) == R600_PTE_GART_MASK) {
 		uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
 		while (count) {
 			unsigned bytes = count * 8;
drivers/gpu/drm/radeon/radeon.h +3 -3
index 89b63b9..fd878c7 100644
@@ -864,9 +864,9 @@ struct radeon_mec {
 #define R600_PTE_FRAG_64KB	(4 << 7)
 #define R600_PTE_FRAG_256KB	(6 << 7)
 
-/* flags used for GART page table entries on R600+ */
-#define R600_PTE_GART	( R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED \
-			| R600_PTE_READABLE | R600_PTE_WRITEABLE)
+/* flags needed to be set so we can copy directly from the GART table */
+#define R600_PTE_GART_MASK	( R600_PTE_READABLE | R600_PTE_WRITEABLE | \
+				  R600_PTE_SYSTEM | R600_PTE_VALID )
 
 struct radeon_vm_pt {
 	struct radeon_bo		*bo;
drivers/gpu/drm/radeon/si_dma.c +1 -2
index c9da341..a26e842 100644
@@ -79,8 +79,7 @@ void si_dma_vm_set_page(struct radeon_device *rdev,
 
 	trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-	/* XXX: How to distinguish between GART and other system memory pages? */
-	if (flags & R600_PTE_SYSTEM) {
+	if ((flags & R600_PTE_GART_MASK) == R600_PTE_GART_MASK) {
 		uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
 		while (count) {
 			unsigned bytes = count * 8;
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied
#1 lore raw
Quoted 5 lines · Christian König

From: Christian König <[email protected]>

That didn't worked correctly any more and opened up a security problem.

Applied to my 3.17 tree.

Alex

Quoted 54 lines
---
 drivers/gpu/drm/radeon/cik_sdma.c | 3 +--
 drivers/gpu/drm/radeon/radeon.h   | 6 +++---
 drivers/gpu/drm/radeon/si_dma.c   | 3 +--
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/gpu/drm/radeon/cik_sdma.c +1 -2
index 8534068..28ca3cb 100644
@@ -775,8 +775,7 @@ void cik_sdma_vm_set_page(struct radeon_device *rdev,
 
        trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-       /* XXX: How to distinguish between GART and other system memory pages? */
-       if (flags & R600_PTE_SYSTEM) {
+       if ((flags & R600_PTE_GART_MASK) == R600_PTE_GART_MASK) {
                uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
                while (count) {
                        unsigned bytes = count * 8;
drivers/gpu/drm/radeon/radeon.h +3 -3
index 89b63b9..fd878c7 100644
@@ -864,9 +864,9 @@ struct radeon_mec {
 #define R600_PTE_FRAG_64KB     (4 << 7)
 #define R600_PTE_FRAG_256KB    (6 << 7)
 
-/* flags used for GART page table entries on R600+ */
-#define R600_PTE_GART  ( R600_PTE_VALID | R600_PTE_SYSTEM | R600_PTE_SNOOPED \
-                       | R600_PTE_READABLE | R600_PTE_WRITEABLE)
+/* flags needed to be set so we can copy directly from the GART table */
+#define R600_PTE_GART_MASK     ( R600_PTE_READABLE | R600_PTE_WRITEABLE | \
+                                 R600_PTE_SYSTEM | R600_PTE_VALID )
 
 struct radeon_vm_pt {
        struct radeon_bo                *bo;
drivers/gpu/drm/radeon/si_dma.c +1 -3
index c9da341..a26e842 100644
@@ -79,8 +79,7 @@ void si_dma_vm_set_page(struct radeon_device *rdev,
 
        trace_radeon_vm_set_page(pe, addr, count, incr, flags);
 
-       /* XXX: How to distinguish between GART and other system memory pages? */
-       if (flags & R600_PTE_SYSTEM) {
+       if ((flags & R600_PTE_GART_MASK) == R600_PTE_GART_MASK) {
                uint64_t src = rdev->gart.table_addr + (addr >> 12) * 8;
                while (count) {
                        unsigned bytes = count * 8;
--

1.9.1

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel