xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Stefano Stabellini <sstabellini@kernel.org>
To: Simon Leiner <simon@leiner.me>
Cc: xen-devel@lists.xenproject.org, sstabellini@kernel.org,
	jgross@suse.com,  julien@xen.org
Subject: Re: [PATCH 2/2] arm/xen: Add misuse warning to virt_to_gfn
Date: Tue, 25 Aug 2020 16:58:19 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.2.21.2008251658090.24407@sstabellini-ThinkPad-T480s> (raw)
In-Reply-To: <20200825093153.35500-2-simon@leiner.me>

On Tue, 25 Aug 2020, Simon Leiner wrote:
> As virt_to_gfn uses virt_to_phys, it will return invalid addresses when
> used with vmalloc'd addresses. This patch introduces a warning, when
> virt_to_gfn is used in this way.
> 
> Signed-off-by: Simon Leiner <simon@leiner.me>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  include/xen/arm/page.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/xen/arm/page.h b/include/xen/arm/page.h
> index d7f6af50e200..b0d303b633d0 100644
> --- a/include/xen/arm/page.h
> +++ b/include/xen/arm/page.h
> @@ -76,7 +76,11 @@ static inline unsigned long bfn_to_pfn(unsigned long bfn)
>  #define bfn_to_local_pfn(bfn)	bfn_to_pfn(bfn)
>  
>  /* VIRT <-> GUEST conversion */
> -#define virt_to_gfn(v)		(pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT))
> +#define virt_to_gfn(v)                                                         \
> +	({                                                                     \
> +		WARN_ON_ONCE(is_vmalloc_addr(v));                              \
> +		pfn_to_gfn(virt_to_phys(v) >> XEN_PAGE_SHIFT);                 \
> +	})
>  #define gfn_to_virt(m)		(__va(gfn_to_pfn(m) << XEN_PAGE_SHIFT))
>  
>  /* Only used in PV code. But ARM guests are always HVM. */
> -- 
> 2.24.3 (Apple Git-128)
> 


  parent reply	other threads:[~2020-08-25 23:58 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 ` [PATCH 1/2] xen/xenbus: Fix granting of vmalloc'd memory Simon Leiner
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 [this message]
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=alpine.DEB.2.21.2008251658090.24407@sstabellini-ThinkPad-T480s \
    --to=sstabellini@kernel.org \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=simon@leiner.me \
    --cc=xen-devel@lists.xenproject.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).