All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mukesh Rathor <mukesh.rathor@oracle.com>
To: Tim Deegan <tim@xen.org>
Cc: Xen-devel@lists.xensource.com,
	Ian Campbell <Ian.Campbell@citrix.com>,
	george.dunlap@eu.citrix.com,
	Julien Grall <julien.grall@linaro.org>,
	keir.xen@gmail.com, JBeulich@suse.com
Subject: Re: [V6 PATCH 6.2/7] pvh dom0: Add and remove foreign pages
Date: Wed, 11 Dec 2013 18:46:06 -0800	[thread overview]
Message-ID: <20131211184606.4f0d9366@mantra.us.oracle.com> (raw)
In-Reply-To: <20131211142903.GB6450@deinos.phlegethon.org>

On Wed, 11 Dec 2013 15:29:03 +0100
Tim Deegan <tim@xen.org> wrote:

> At 17:47 -0800 on 10 Dec (1386694075), Mukesh Rathor wrote:
> > On Wed, 11 Dec 2013 01:35:08 +0000
> > Julien Grall <julien.grall@linaro.org> wrote:
> > 
> > > >       unsigned long mfn = gmfn_to_mfn(d, gfn);
> > > >
> > > > -    ASSERT(t == NULL);
> > > > +    ASSERT(*t == INT_MAX);
> > > 
> > > There is various place where get_page_from_gfn where t == NULL.
> > > With this solution it will segfault every time.
> > > 
> > > I would do something like that:
> > >    if (*t)
> > >      t = INT_MAX;
> > 
> > here's updated:
> > ------------
> > 
> > In this patch, a new function, p2m_add_foreign(), is added
> > to map pages from foreign guest into current dom0 for domU creation.
> > Such pages are typed p2m_map_foreign. Another function
> > p2m_remove_foreign() is added to remove such pages. Note, in
> > the remove path, we must release the refcount that was taken during
> > the map phase. This is done in p2m_remove_page, which also addresses
> > releasing of refcnt when the domain is destroyed.
> 
> Did you test that?  I don't think it can be true.

Yes. In this version, I had added code to p2m_remove_page() to do that.

> Maybe I wasn't clear last time: this refcount is effectively held by
> the presence of a foreign mapping in a p2m entry.  AFAICT the only
> properly safe way to make sure that broken guest/tools behaviour can't
> mess up Xen's internal refcounting is to have the ref be taken and
> dropped at the time that the entry itelf is written/replaced, e.g.
> ept_set_entry() (or maybe atomic_write_ept_entry()) on EPT and
> paging_write_p2m_entry() on NPT/shadow.

Ah, I was fixated on thinking only p2m_add_foreign was ever gonna
add p2m foreign. Hmm... a bit worried with all the p2m locking in p2m
path and me doing get_page* in ept_set_entry().... But, may be we'll be
ok. Looking at the code to refresh all the locking in my brain....

> Trying to find all the higher-level operations that might cause
> foreign mappings to be inserted/removed is going to be difficult and
> fragile.

Yeah, i found that out staring at the code.

> You'll also need to handle domain teardown, which right now just frees
> all the memory holding the p2m tables (see p2m_teardown()).  That will
> need somehow to check those tables for valid foreign mappings and DTRT
> about them.

Ok, I was thinking since this is dom0 if p2m is tearing down, nothing 
to worry about.  But, with control domains, and all that, we'd need to 
take care of the teardown path. So, I'll fix it.

I'll have another version out hopefully tomorrow, with
get_page* and put_page* in ept path, and p2m_teardown fixed up, and all
tested. I'm thinking something along the lines of:

ept_set_entry():
   ...
   if (p2mt == foreign)
   {
       page = mfn_to_page(mfn);
       fdom = page_get_owner(page);
       get_page(page, fdom);
   }
   table = map_domain_page(pagetable_get_pfn(p2m_get_pagetable(p2m)));
   .....


thanks a lot,
Mukesh

  reply	other threads:[~2013-12-12  2:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-06  2:38 [V6 PATCH 0/7]: PVH dom0 Mukesh Rathor
2013-12-06  2:38 ` [V6 PATCH 1/7] pvh dom0: move some pv specific code to static functions Mukesh Rathor
2013-12-06  2:38 ` [V6 PATCH 2/7] pvh dom0: construct_dom0 changes Mukesh Rathor
2013-12-06  2:38 ` [V6 PATCH 3/7] pvh dom0: implement XENMEM_add_to_physmap_range for x86 Mukesh Rathor
2013-12-06  2:38 ` [V6 PATCH 4/7] pvh dom0: Introduce p2m_map_foreign Mukesh Rathor
2013-12-09 12:02   ` Tim Deegan
2013-12-06  2:38 ` [V6 PATCH 5/7] pvh: change xsm_add_to_physmap Mukesh Rathor
2013-12-06  2:38 ` [V6 PATCH 6/7] pvh dom0: Add and remove foreign pages Mukesh Rathor
2013-12-06  2:54   ` Mukesh Rathor
2013-12-06 11:46     ` Jan Beulich
2013-12-07  2:09       ` Mukesh Rathor
2013-12-07  2:34   ` [V6 PATCH 6.1/7] " Mukesh Rathor
2013-12-07 16:06     ` Julien Grall
2013-12-09  9:50     ` Jan Beulich
2013-12-10  1:30       ` Mukesh Rathor
2013-12-09 10:31     ` Ian Campbell
2013-12-09 13:46       ` Julien Grall
2013-12-09 12:11     ` Tim Deegan
2013-12-10  2:16       ` Mukesh Rathor
2013-12-09  2:45   ` [V6 PATCH 6/7] " Julien Grall
2013-12-09  2:57     ` Julien Grall
2013-12-10  2:17     ` Mukesh Rathor
2013-12-11  0:27   ` [V6 PATCH 6.2/7] " Mukesh Rathor
2013-12-11  0:44     ` Mukesh Rathor
2013-12-11  1:35       ` Julien Grall
2013-12-11  1:47         ` Mukesh Rathor
2013-12-11  9:23           ` Jan Beulich
2013-12-11 14:29           ` Tim Deegan
2013-12-12  2:46             ` Mukesh Rathor [this message]
2013-12-13  2:44               ` Mukesh Rathor
2013-12-13 11:25                 ` Tim Deegan
2013-12-13 11:39                   ` Jan Beulich
2013-12-13 19:02                     ` George Dunlap
2013-12-16  7:47                       ` Jan Beulich
2013-12-14  2:48                   ` Mukesh Rathor
2013-12-16  8:40                     ` Jan Beulich
2013-12-16 23:27                       ` Mukesh Rathor
2013-12-16 23:44                         ` Julien Grall
2013-12-17  1:51                           ` Mukesh Rathor
2013-12-17  2:33                         ` Mukesh Rathor
2013-12-17 10:10                         ` Tim Deegan
2013-12-17 23:24                           ` Mukesh Rathor
2013-12-18  2:34                           ` Mukesh Rathor
2013-12-18  9:51                             ` Jan Beulich
2013-12-18  9:53                             ` Tim Deegan
2013-12-06  2:38 ` [V6 PATCH 7/7] pvh 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=20131211184606.4f0d9366@mantra.us.oracle.com \
    --to=mukesh.rathor@oracle.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=Xen-devel@lists.xensource.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=julien.grall@linaro.org \
    --cc=keir.xen@gmail.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 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.