From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH 1/3] x86/P2M: synchronize fast and slow paths of p2m_get_page_from_gfn()
Date: Mon, 10 Mar 2025 15:53:54 +0100 [thread overview]
Message-ID: <Z879Aq-UNj-Jz5S1@macbook.local> (raw)
In-Reply-To: <88d24595-50be-4f99-97d6-9126340b791e@suse.com>
On Wed, Feb 26, 2025 at 12:52:27PM +0100, Jan Beulich wrote:
> Handling of both grants and foreign pages was different between the two
> paths.
>
> While permitting access to grants would be desirable, doing so would
> require more involved handling; undo that for the time being. In
> particular the page reference obtained would prevent the owning domain
> from changing e.g. the page's type (after the grantee has released the
> last reference of the grant). Instead perhaps another reference on the
> grant would need obtaining. Which in turn would require determining
> which grant that was.
>
> Foreign pages in any event need permitting on both paths.
>
> Introduce a helper function to be used on both paths, such that
> respective checking differs in just the extra "to be unshared" condition
> on the fast path.
>
> While there adjust the sanity check for foreign pages: Don't leak the
> reference on release builds when on a debug build the assertion would
> have triggered. (Thanks to Roger for the suggestion.)
>
> Fixes: 80ea7af17269 ("x86/mm: Introduce get_page_from_gfn()")
> Fixes: 50fe6e737059 ("pvh dom0: add and remove foreign pages")
> Fixes: cbbca7be4aaa ("x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
Just a couple of nits below (with a reply to your RFC).
> ---
> RFC: While the helper could take const struct domain * as first
> parameter, for a P2M function it seemed more natural to have it
> take const struct p2m_domain *.
>
> --- a/xen/arch/x86/mm/p2m.c
> +++ b/xen/arch/x86/mm/p2m.c
> @@ -328,12 +328,45 @@ void p2m_put_gfn(struct p2m_domain *p2m,
> gfn_unlock(p2m, gfn_x(gfn), 0);
> }
>
> +static struct page_info *get_page_from_mfn_and_type(
> + const struct p2m_domain *p2m, mfn_t mfn, p2m_type_t t)
Re your RFC: since it's a static function, just used for
p2m_get_page_from_gfn(), I would consider passing a domain instead of
a p2m_domain, as the solely usage of p2m is to obtain the domain.
> +{
> + struct page_info *page;
> +
> + if ( !mfn_valid(mfn) )
> + return NULL;
> +
> + page = mfn_to_page(mfn);
> +
> + if ( p2m_is_ram(t) )
Should this be a likely() to speed up the common successful path?
Thanks, Roger.
next prev parent reply other threads:[~2025-03-10 14:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 11:51 [PATCH 0/3] x86/P2M: assorted corrections Jan Beulich
2025-02-26 11:52 ` [PATCH 1/3] x86/P2M: synchronize fast and slow paths of p2m_get_page_from_gfn() Jan Beulich
2025-03-10 14:53 ` Roger Pau Monné [this message]
2025-03-11 8:44 ` Jan Beulich
2025-03-11 9:01 ` Roger Pau Monné
2025-02-26 11:52 ` [PATCH 2/3] x86/P2M: correct old entry checking in p2m_remove_entry() Jan Beulich
2025-03-10 15:16 ` Roger Pau Monné
2025-03-10 15:21 ` Roger Pau Monné
2025-02-26 11:53 ` [PATCH 3/3] x86/P2M: don't include MMIO_DM in p2m_is_valid() Jan Beulich
2025-03-10 15:25 ` Roger Pau Monné
2025-03-11 22:16 ` [REGRESSION] Re: [PATCH 0/3] x86/P2M: assorted corrections Andrew Cooper
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=Z879Aq-UNj-Jz5S1@macbook.local \
--to=roger.pau@citrix.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--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 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.