Skip to contentSkip to conversation

accel/amdxdna: Preserve user address when PASID is disabled

PATCH In review Lizhi Hou 2 participants 3 messages Jun 2

Subsystems (2)
lore
Share & tools
lore

Lizhi Hou

author maintainer
#0 lore raw

PATCH 1/1 accel/amdxdna: Preserve user address when PASID is disabled

When PASID is not used, the buffer user address is set to AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation fails even though the original userspace address is available.

Preserve the userspace address regardless of PASID usage so heap buffer address validation works correctly.

Fixes dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap support")
---
 drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +4 -1
index 77e5fad08ae5..33cf5af98ceb 100644
@@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
 	u32 nr_pages;
 	int ret;
 
-	if (!amdxdna_pasid_on(abo->client))
+	if (!amdxdna_pasid_on(abo->client)) {
+		/* Need to set uva for heap uva validation */
+		abo->mem.uva = addr;
 		return 0;
+	}
 
 	mapp = kzalloc_obj(*mapp);
 	if (!mapp)
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Lizhi Hou

When PASID is not used, the buffer user address is set to AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation fails even though the original userspace address is available.

Preserve the userspace address regardless of PASID usage so heap buffer address validation works correctly.

Fixes dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap support")
Quoted 21 lines
---
  drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +4 -1
index 77e5fad08ae5..33cf5af98ceb 100644
@@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct amdxdna_gem_obj *abo,
  	u32 nr_pages;
  	int ret;
 
-	if (!amdxdna_pasid_on(abo->client))
+	if (!amdxdna_pasid_on(abo->client)) {
+		/* Need to set uva for heap uva validation */
+		abo->mem.uva = addr;
  		return 0;
+	}
 
  	mapp = kzalloc_obj(*mapp);
  	if (!mapp)
author maintainer Applied
#2 lore raw

Applied to drm-misc-next-fixes

Quoted 34 lines · Mario Limonciello
Quoted 9 lines · Lizhi Hou

When PASID is not used, the buffer user address is set to AMDXDNA_INVALID_ADDR. As a result, heap buffer user address validation fails even though the original userspace address is available.

Preserve the userspace address regardless of PASID usage so heap buffer address validation works correctly.

Fixes dbc8fd7a03cb ("accel/amdxdna: Add expandable device heap support")
Quoted 20 lines

---
  drivers/accel/amdxdna/amdxdna_gem.c | 5 ++++-

  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/amdxdna_gem.c +4 -0
index 77e5fad08ae5..33cf5af98ceb 100644
@@ -349,8 +349,11 @@ static int amdxdna_hmm_register(struct 
 amdxdna_gem_obj *abo,
       u32 nr_pages;
       int ret;
   -    if (!amdxdna_pasid_on(abo->client))
+    if (!amdxdna_pasid_on(abo->client)) {
+        /* Need to set uva for heap uva validation */
+        abo->mem.uva = addr;
           return 0;
+    }
         mapp = kzalloc_obj(*mapp);
       if (!mapp)