Skip to contentSkip to conversation

xen/9pfs: Fix data ring granting

PATCH New Juergen Gross 1 participant 1 message Dec 18, 2025 9P file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/9pfs: Fix data ring granting

xen_9pfs_front_alloc_dataring() is granting the backend access to the data ring by using gnttab_grant_foreign_access() for each memory page of the ring.

Unfortunately the pages passed to gnttab_grant_foreign_access() are not referenced by the consecutive PFNs, but by GFNs, which might be not consecutive if the system is running as a PV guest.

Fix that by not using "virt_to_gfn(bytes) + i" as parameter, but "pfn_to_gfn(virt_to_pfn(bytes) + i)" instead.

Fixes 71ebd71921e4 ("xen/9pfs: connect to the backend")
---
 net/9p/trans_xen.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/9p/trans_xen.c +2 -1
index 12f752a92332..a2ab633e78be 100644
@@ -347,7 +347,8 @@ static int xen_9pfs_front_alloc_dataring(struct xenbus_device *dev,
 	}
 	for (; i < (1 << order); i++) {
 		ret = gnttab_grant_foreign_access(
-				dev->otherend_id, virt_to_gfn(bytes) + i, 0);
+				dev->otherend_id,
+				pfn_to_gfn(virt_to_pfn(bytes) + i), 0);
 		if (ret < 0)
 			goto out;
 		ring->intf->ref[i] = ret;
Signature · 1 line
2.51.0