From: Ian Campbell <ian.campbell@citrix.com>
To: CORNELIU ZUZU <czuzu@bitdefender.com>,
xen-devel <xen-devel@lists.xen.org>
Subject: Re: [PATCH] arm: p2m.c bug-fix: hypervisor hang on __p2m_get_mem_access
Date: Wed, 27 Jan 2016 11:42:10 +0000 [thread overview]
Message-ID: <1453894930.26591.8.camel@citrix.com> (raw)
In-Reply-To: <56A89338.8040409@bitdefender.com>
(we went offlist by mistake without noticing, resending my last reply which
I think has sufficient context/quoting to make sense)
On Wed, 2016-01-27 at 11:51 +0200, CORNELIU ZUZU wrote:
> On 1/26/2016 6:14 PM, Ian Campbell wrote:
> > On Tue, 2016-01-26 at 13:46 +0200, Corneliu ZUZU wrote:
> > > When __p2m_get_mem_access gets called, the p2m lock is already taken
> > > by either get_page_from_gva or p2m_get_mem_access.
> > >
> > > Possible code paths:
> > > 1) -> get_page_from_gva
> > > -> p2m_mem_access_check_and_get_page
> > > -> __p2m_get_mem_access
> > > 2) -> p2m_get_mem_access
> > > -> __p2m_get_mem_access
> > What about:
> > -> p2m_mem_access_check
> > -> p2m_get_mem_access
> > I can't see the lock being taken in that paths.
>
> Yes, that's code path #2 I've previously mentioned, the lock is first
> taken in p2m_get_mem_access (i.e. the line 'spin_lock(&p2m->lock)'),
> before __p2m_get_mem_access is called.
Oh yes, not sure how I got myself confused there.
> I'm looking @ the master branch of git://xenbits.xenproject.org/xen.git
> (although we've hit this bug on the 4.6 stable repo).
>
> >
> > As well as fixing that I think it would be wise to add an assert that
> > the
> > lock is held before the call to p2m_lookup which you are changing into
> > the
> > unlocked variant.
>
> Good idea, didn't know one could do that.
> Concretely, I suppose this would be done by
>
> ASSERT(spin_is_locked(&p2m->lock));
>
> ?
Right.
>
> One question though. It seems that everytime __p2m_get_mem_access is
> called, the lock is taken *before the call*, not within the
> function itself.
Right. It's a common (but by no mean universal) convention within Xen that
a __foo function is a version of foo which expects the relevant lock(s) to
already be held.
> Since __p2m_get_mem_access also accesses other fields of the p2m pointer
> (e.g. 'p2m->mem_access_enabled'),
> including performing a radix tree lookup before calling p2m_lookup,
> doesn't this mean that
> the p2m lock is also needed for these accesses (especially for the radix
> tree lookup)? And if so,
> shouldn't I position the assertion line @ the *beginning* of
> __p2m_get_mem_access, e.g. just before 'if ( !p2m->mem_access_enabled )'?
Yes, since p2m_get_mem_access requires the lock to be taken on entry it
makes sense to put the assert as near the top of the function as possible.
This is true whether the initial bit of the function does anything which
requires the lock.
Ian.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-01-27 11:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-26 11:46 [PATCH] arm: p2m.c bug-fix: hypervisor hang on __p2m_get_mem_access Corneliu ZUZU
2016-01-26 16:14 ` Ian Campbell
[not found] ` <56A89338.8040409@bitdefender.com>
2016-01-27 11:42 ` Ian Campbell [this message]
2016-02-03 11:37 ` [PATCH v2] " Corneliu ZUZU
2016-02-03 11:52 ` Ian Campbell
2016-02-03 11:56 ` Corneliu ZUZU
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=1453894930.26591.8.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=czuzu@bitdefender.com \
--cc=xen-devel@lists.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).