Skip to content

Commit d742db7

Browse files
sleinerjgross1
authored andcommitted
xen/xenbus: Fix granting of vmalloc'd memory
On some architectures (like ARM), virt_to_gfn cannot be used for vmalloc'd memory because of its reliance on virt_to_phys. This patch introduces a check for vmalloc'd addresses and obtains the PFN using vmalloc_to_pfn in that case. Signed-off-by: Simon Leiner <[email protected]> Reviewed-by: Stefano Stabellini <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Juergen Gross <[email protected]>
1 parent c330fb1 commit d742db7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/xen/xenbus/xenbus_client.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
379379
int i, j;
380380

381381
for (i = 0; i < nr_pages; i++) {
382-
err = gnttab_grant_foreign_access(dev->otherend_id,
383-
virt_to_gfn(vaddr), 0);
382+
unsigned long gfn;
383+
384+
if (is_vmalloc_addr(vaddr))
385+
gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr));
386+
else
387+
gfn = virt_to_gfn(vaddr);
388+
389+
err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0);
384390
if (err < 0) {
385391
xenbus_dev_fatal(dev, err,
386392
"granting access to ring page");

0 commit comments

Comments
 (0)