From: Julien Grall <julien.grall@linaro.org>
To: Mukesh Rathor <mukesh.rathor@oracle.com>, Xen-devel@lists.xensource.com
Cc: Ian Campbell <Ian.Campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
george.dunlap@eu.citrix.com, tim@xen.org, keir.xen@gmail.com,
JBeulich@suse.com
Subject: Re: [V4 PATCH 6/7] pvh dom0: Add and remove foreign pages
Date: Wed, 04 Dec 2013 00:00:54 +0000 [thread overview]
Message-ID: <529E70B6.7060002@linaro.org> (raw)
In-Reply-To: <1386037848-27891-7-git-send-email-mukesh.rathor@oracle.com>
On 12/03/2013 02:30 AM, Mukesh Rathor wrote:
> In this patch, a new function, xenmem_add_foreign_to_pmap(), is added
xenmem_add_foreign_to_p2m?
> to map pages from foreign guest into current dom0 for domU creation.
> Such pages are typed p2m_map_foreign. Also, support is added here to
> XENMEM_remove_from_physmap to remove such pages. Note, in the remove
> path, we must release the refcount that was taken during the map phase.
Your remove path is very interesting for the ARM port. For now we are
unable to unmap the foreign page because get_page() will always return
NULL (as dom0 is not the owner).
I will give a try on ARM to see if it could resolve our problem.
> Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
> ---
> xen/arch/x86/mm.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++----
> xen/common/memory.c | 38 +++++++++++++++++++---
> 2 files changed, 114 insertions(+), 12 deletions(-)
[..]
> diff --git a/xen/common/memory.c b/xen/common/memory.c
> index 50b740f..d81df18 100644
> --- a/xen/common/memory.c
> +++ b/xen/common/memory.c
> @@ -675,9 +675,11 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
>
> case XENMEM_remove_from_physmap:
> {
> + unsigned long mfn;
> struct xen_remove_from_physmap xrfp;
> struct page_info *page;
> - struct domain *d;
> + struct domain *d, *foreign_dom = NULL;
> + p2m_type_t p2mt, tp;
>
> if ( copy_from_guest(&xrfp, arg, 1) )
> return -EFAULT;
> @@ -693,11 +695,37 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
> return rc;
> }
>
> - page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
> - if ( page )
> + /*
> + * if PVH, the gfn could be mapped to a mfn from foreign domain by the
> + * user space tool during domain creation. We need to check for that,
> + * free it up from the p2m, and release refcnt on it. In such a case,
> + * page would be NULL and the following call would not have refcnt'd
> + * the page. See also xenmem_add_foreign_to_pmap().
s/xenmem_add_foreign_pmap/xenmem_add_foreign_p2m/
> + */
> + page = get_page_from_gfn(d, xrfp.gpfn, &p2mt, P2M_ALLOC);
> +
> + if ( page || p2m_is_foreign(p2mt) )
> {
p2m_is_foreign doesn't exist on ARM. I plan to introduce p2m type in the
future, so I think you can define p2m_is_foreign as 0 for now on ARM.
> - guest_physmap_remove_page(d, xrfp.gpfn, page_to_mfn(page), 0);
> - put_page(page);
> + if ( page )
> + mfn = page_to_mfn(page);
> + else
> + {
> + mfn = mfn_x(get_gfn_query(d, xrfp.gpfn, &tp));
get_gfn_query doesn't exist on ARM.
> + foreign_dom = page_get_owner(mfn_to_page(mfn));
> + ASSERT(is_pvh_domain(d));
On ARM, the assert will always be wrong.
> + ASSERT(d != foreign_dom);
> + ASSERT(p2m_is_foreign(tp));
> + }
> +
> + guest_physmap_remove_page(d, xrfp.gpfn, mfn, 0);
> + if (page)
> + put_page(page);
> +
> + if ( p2m_is_foreign(p2mt) )
> + {
> + put_page(mfn_to_page(mfn));
> + put_gfn(d, xrfp.gpfn);
> + }
> }
> else
> rc = -ENOENT;
>
--
Julien Grall
next prev parent reply other threads:[~2013-12-04 0:00 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 2:30 [V4 PATCH 0/7]: PVH dom0 Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 1/7] PVH dom0: move some pv specific code to static functions Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 2/7] dom0: construct_dom0 changes Mukesh Rathor
2013-12-04 15:28 ` Jan Beulich
2013-12-03 2:30 ` [V4 PATCH 3/7] PVH dom0: implement XENMEM_add_to_physmap_range for x86 Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 4/7] PVH dom0: Introduce p2m_map_foreign Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 5/7] pvh: change xsm_add_to_physmap Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 6/7] pvh dom0: Add and remove foreign pages Mukesh Rathor
2013-12-04 0:00 ` Julien Grall [this message]
2013-12-04 1:05 ` Mukesh Rathor
2013-12-04 9:44 ` Ian Campbell
2013-12-04 10:56 ` Stefano Stabellini
2013-12-04 17:00 ` Julien Grall
2013-12-05 1:40 ` Mukesh Rathor
2013-12-05 12:31 ` Julien Grall
2013-12-04 9:43 ` Ian Campbell
2013-12-05 2:09 ` Mukesh Rathor
2013-12-03 2:30 ` [V4 PATCH 7/7] pvh dom0: add opt_dom0pvh to setup.c Mukesh Rathor
2013-12-04 15:37 ` [V4 PATCH 0/7]: PVH dom0 Jan Beulich
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=529E70B6.7060002@linaro.org \
--to=julien.grall@linaro.org \
--cc=Ian.Campbell@citrix.com \
--cc=JBeulich@suse.com \
--cc=Xen-devel@lists.xensource.com \
--cc=george.dunlap@eu.citrix.com \
--cc=keir.xen@gmail.com \
--cc=mukesh.rathor@oracle.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=tim@xen.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).