From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Mukesh Rathor <mukesh.rathor@oracle.com>, xen-devel@lists.xenproject.org
Cc: JBeulich@suse.com, George.Dunlap@eu.citrix.com, tim@xen.org,
eddie.dong@intel.com, keir.xen@gmail.com, jun.nakajima@intel.com
Subject: Re: [V11 PATCH 3/4] pvh dom0: Add and remove foreign pages
Date: Wed, 7 May 2014 17:36:22 +0200 [thread overview]
Message-ID: <536A52F6.2050206@citrix.com> (raw)
In-Reply-To: <1398995707-12657-4-git-send-email-mukesh.rathor@oracle.com>
On 02/05/14 03:55, Mukesh Rathor wrote:
> +int p2m_add_foreign(struct domain *tdom, unsigned long fgfn,
> + unsigned long gpfn, domid_t foreigndom)
> +{
> + p2m_type_t p2mt, p2mt_prev;
> + unsigned long prev_mfn, mfn;
> + struct page_info *page;
> + int rc = -EINVAL;
> + struct domain *fdom = NULL;
> +
> + ASSERT(tdom);
> + if ( foreigndom == DOMID_SELF || !is_pvh_domain(tdom) )
> + return -EINVAL;
> +
> + /*
> + * pvh fixme: until support is added to p2m teardown code to cleanup any
> + * foreign entries, limit this to hardware domain only.
> + */
> + if ( !is_hardware_domain(tdom) )
> + return -EPERM;
> +
> + fdom = get_pg_owner(foreigndom);
> + if ( fdom == NULL )
> + return -ESRCH;
> +
> + if ( tdom == fdom )
> + goto out;
> +
> + rc = xsm_map_gmfn_foreign(XSM_TARGET, tdom, fdom);
> + if ( rc )
> + goto out;
> +
> + /*
> + * Take a refcnt on the mfn. NB: following supported for foreign mapping:
> + * ram_rw | ram_logdirty | ram_ro | paging_out.
> + */
> + page = get_page_from_gfn(fdom, fgfn, &p2mt, P2M_ALLOC);
> + if ( !page ||
> + !p2m_is_ram(p2mt) || p2m_is_shared(p2mt) || p2m_is_hole(p2mt) )
> + {
> + if ( page )
> + put_page(page);
This is missing setting rc to an error value, something like the
following is needed:
rc = -EINVAL;
Roger.
> + goto out;
> + }
> + mfn = mfn_x(page_to_mfn(page));
> +
> + /* Remove previously mapped page if it is present. */
> + prev_mfn = mfn_x(get_gfn(tdom, gpfn, &p2mt_prev));
> + if ( mfn_valid(_mfn(prev_mfn)) )
> + {
> + if ( is_xen_heap_mfn(prev_mfn) )
> + /* Xen heap frames are simply unhooked from this phys slot */
> + guest_physmap_remove_page(tdom, gpfn, prev_mfn, 0);
> + else
> + /* Normal domain memory is freed, to avoid leaking memory. */
> + guest_remove_page(tdom, gpfn);
> + }
> + /*
> + * Create the new mapping. Can't use guest_physmap_add_page() because it
> + * will update the m2p table which will result in mfn -> gpfn of dom0
> + * and not fgfn of domU.
> + */
> + rc = set_foreign_p2m_entry(tdom, gpfn, _mfn(mfn));
> + if ( rc )
> + gdprintk(XENLOG_WARNING, "set_foreign_p2m_entry failed. "
> + "gpfn:%lx mfn:%lx fgfn:%lx td:%d fd:%d\n",
> + gpfn, mfn, fgfn, tdom->domain_id, fdom->domain_id);
> +
> + put_page(page);
> +
> + /*
> + * This put_gfn for the above get_gfn for prev_mfn. We must do this
> + * after set_foreign_p2m_entry so another cpu doesn't populate the gpfn
> + * before us.
> + */
> + put_gfn(tdom, gpfn);
> +
> +out:
> + if ( fdom )
> + put_pg_owner(fdom);
> + return rc;
> +}
next prev parent reply other threads:[~2014-05-07 15:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-02 1:55 [V11 PATCH 0/4] pvh dom0 patches Mukesh Rathor
2014-05-02 1:55 ` [V11 PATCH 1/4] pvh dom0: construct_dom0 changes Mukesh Rathor
2014-05-08 12:05 ` Tim Deegan
2014-05-02 1:55 ` [V11 PATCH 2/4] pvh dom0: Add checks and restrictions for p2m_is_foreign Mukesh Rathor
2014-05-02 1:55 ` [V11 PATCH 3/4] pvh dom0: Add and remove foreign pages Mukesh Rathor
2014-05-05 10:56 ` Jan Beulich
2014-05-06 1:21 ` Mukesh Rathor
2014-05-06 7:51 ` Jan Beulich
2014-05-07 1:12 ` Mukesh Rathor
2014-05-07 7:27 ` Jan Beulich
2014-05-07 15:36 ` Roger Pau Monné [this message]
2014-05-02 1:55 ` [V11 PATCH 4/4] dom0: add opt_dom0pvh to setup.c Mukesh Rathor
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=536A52F6.2050206@citrix.com \
--to=roger.pau@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=eddie.dong@intel.com \
--cc=jun.nakajima@intel.com \
--cc=keir.xen@gmail.com \
--cc=mukesh.rathor@oracle.com \
--cc=tim@xen.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
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).