From: Simon Leiner <simon@leiner.me> To: xen-devel@lists.xenproject.org, sstabellini@kernel.org, jgross@suse.com Cc: julien@xen.org Subject: [PATCH 1/2] xen/xenbus: Fix granting of vmalloc'd memory Date: Tue, 25 Aug 2020 11:31:52 +0200 [thread overview] Message-ID: <20200825093153.35500-1-simon@leiner.me> (raw) In-Reply-To: <Aw: [Linux] [ARM] Granting memory obtained from the DMA API> 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 <simon@leiner.me> --- drivers/xen/xenbus/xenbus_client.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus_client.c index 786fbb7d8be0..907bcbb93afb 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -379,8 +379,14 @@ int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, int i, j; for (i = 0; i < nr_pages; i++) { - err = gnttab_grant_foreign_access(dev->otherend_id, - virt_to_gfn(vaddr), 0); + unsigned long gfn; + + 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) { xenbus_dev_fatal(dev, err, "granting access to ring page"); -- 2.24.3 (Apple Git-128)
next parent reply other threads:[~2020-08-25 9:32 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <Aw: [Linux] [ARM] Granting memory obtained from the DMA API> 2020-08-25 9:31 ` Simon Leiner [this message] 2020-08-25 9:31 ` [PATCH 2/2] arm/xen: Add misuse warning to virt_to_gfn Simon Leiner 2020-08-25 12:16 ` Jan Beulich 2020-08-25 23:48 ` Stefano Stabellini 2020-08-26 6:20 ` Jan Beulich 2020-08-26 7:50 ` Simon Leiner 2020-08-26 7:59 ` Jürgen Groß 2020-08-26 8:14 ` Simon Leiner 2020-08-26 8:27 ` Jürgen Groß 2020-08-26 8:30 ` Simon Leiner 2020-08-25 23:58 ` Stefano Stabellini 2020-08-26 18:37 ` Julien Grall 2020-08-27 5:21 ` Jürgen Groß 2020-08-27 8:24 ` Julien Grall 2020-08-27 8:35 ` Jürgen Groß 2020-08-27 16:04 ` Stefano Stabellini 2020-08-25 23:55 ` [PATCH 1/2] xen/xenbus: Fix granting of vmalloc'd memory Stefano Stabellini
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200825093153.35500-1-simon@leiner.me \ --to=simon@leiner.me \ --cc=jgross@suse.com \ --cc=julien@xen.org \ --cc=sstabellini@kernel.org \ --cc=xen-devel@lists.xenproject.org \ --subject='Re: [PATCH 1/2] xen/xenbus: Fix granting of vmalloc'\''d memory' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.