Xen-Devel Archive on lore.kernel.org
 help / color / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Simon Leiner <simon@leiner.me>,
	xen-devel@lists.xenproject.org, jgross@suse.com, julien@xen.org
Subject: Re: [PATCH 2/2] arm/xen: Add misuse warning to virt_to_gfn
Date: Wed, 26 Aug 2020 08:20:30 +0200
Message-ID: <00bdd0ee-8f18-4580-01c7-01c95f3a6184@suse.com> (raw)
In-Reply-To: <alpine.DEB.2.21.2008251647100.24407@sstabellini-ThinkPad-T480s>

On 26.08.2020 01:48, Stefano Stabellini wrote:
> On Tue, 25 Aug 2020, Jan Beulich wrote:
>> On 25.08.2020 11:31, Simon Leiner wrote:
>>> --- 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);                 \
>>> +	})
>>
>> Shouldn't such a check cover more than just the vmalloc range,
>> i.e. everything outside of what __va() can validly return?
> 
> Keep in mind that this patch is meant as sister patch to
> https://marc.info/?l=xen-devel&m=159834800203817
> so it makes sense to check for vmalloc addresses specifically.

I had seen that patch before writing the reply, and I had assumed
precisely what you say. It was for this reason that I did point
out the limitation: While there's a specific issue for the vmalloc
range, any other addresses outside the direct mapping area are as
problematic (aiui).

> That said, I am not aware of a good way to implement the __va test you
> are suggesting.

Hmm, to me __phys_to_virt() and __virt_to_phys_nodebug() give
the impression that they're just linear transformations of the
address, which would seem to suggest there's a pre-determined
address range used for the direct map.

Jan


  reply index

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 [this message]
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=00bdd0ee-8f18-4580-01c7-01c95f3a6184@suse.com \
    --to=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=simon@leiner.me \
    --cc=sstabellini@kernel.org \
    --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

Xen-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/xen-devel/0 xen-devel/git/0.git
	git clone --mirror https://lore.kernel.org/xen-devel/1 xen-devel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 xen-devel xen-devel/ https://lore.kernel.org/xen-devel \
		xen-devel@lists.xenproject.org xen-devel@lists.xen.org
	public-inbox-index xen-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.xenproject.lists.xen-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git