Skip to content
Snippets Groups Projects
Commit 4fd62a05 authored by Simon Leiner's avatar Simon Leiner Committed by Laibin Qiu
Browse files

xen/xenbus: Fix granting of vmalloc'd memory


stable inclusion
from linux-4.19.144
commit 47eb291ba65bfade197e73ee13610d97809cb087

--------------------------------

[ Upstream commit d742db70 ]

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: default avatarSimon Leiner <simon@leiner.me>
Reviewed-by: default avatarStefano Stabellini <sstabellini@kernel.org>
Link: https://lore.kernel.org/r/20200825093153.35500-1-simon@leiner.me


Signed-off-by: default avatarJuergen Gross <jgross@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarYongqiang Liu <liuyongqiang13@huawei.com>
Reviewed-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
Reviewed-by: default avatarJason Yan <yanaijie@huawei.com>
Signed-off-by: default avatarLaibin Qiu <qiulaibin@huawei.com>
parent a88267d5
No related branches found
No related tags found
No related merge requests found
...@@ -371,8 +371,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, ...@@ -371,8 +371,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr,
int i, j; int i, j;
for (i = 0; i < nr_pages; i++) { for (i = 0; i < nr_pages; i++) {
err = gnttab_grant_foreign_access(dev->otherend_id, unsigned long gfn;
virt_to_gfn(vaddr), 0);
if (is_vmalloc_addr(vaddr))
gfn = pfn_to_gfn(vmalloc_to_pfn(vaddr));
else
gfn = virt_to_gfn(vaddr);
err = gnttab_grant_foreign_access(dev->otherend_id, gfn, 0);
if (err < 0) { if (err < 0) {
xenbus_dev_fatal(dev, err, xenbus_dev_fatal(dev, err,
"granting access to ring page"); "granting access to ring page");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment