xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: julien.grall@citrix.com,
	xen-devel <xen-devel@lists.xenproject.org>,
	tim@xen.org, Ian.Campbell@citrix.com
Subject: Re: [PATCH 2/4] xen: introduce grant_map_exists
Date: Thu, 02 Oct 2014 12:42:39 +0100	[thread overview]
Message-ID: <542D564F020000780003BEFE@mail.emea.novell.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1410021232590.17038@kaball.uk.xensource.com>

>>> On 02.10.14 at 13:34, <stefano.stabellini@eu.citrix.com> wrote:
> On Thu, 2 Oct 2014, Jan Beulich wrote:
>> >>> On 02.10.14 at 12:02, <stefano.stabellini@eu.citrix.com> wrote:
>> > --- a/xen/common/grant_table.c
>> > +++ b/xen/common/grant_table.c
>> > @@ -484,6 +484,38 @@ static int _set_status(unsigned gt_version,
>> >          return _set_status_v2(domid, readonly, mapflag, shah, act, 
> status);
>> >  }
>> >  
>> > +bool_t grant_map_exists(struct domain *ld,
>> > +                        struct grant_table *rgt,
>> > +                        unsigned long mfn)
>> > +{
>> > +    struct active_grant_entry *act;
>> > +    grant_ref_t ref;
>> > +    bool_t ret = 0;
>> > +
>> > +    spin_lock(&rgt->lock);
>> > +
>> > +    for ( ref = 0; ref != nr_grant_entries(rgt); ref++ )
>> > +    {
>> > +        act = &active_entry(rgt, ref);
>> > +
>> > +        if ( !act->pin )
>> > +            continue;
>> > +
>> > +        if ( act->domid != ld->domain_id )
>> > +            continue;
>> > +
>> > +        if ( act->frame != mfn )
>> > +            continue;
>> > +        
>> > +        ret = 1;
>> > +        break;
>> > +    }
>> > +
>> > +    spin_unlock(&rgt->lock);
>> > +
>> > +    return ret;
>> 
>> By the time you get here the information you return is stale. Is that
>> not a problem for the caller? And if it's not, why would it check in the
>> first place?
> 
> This is just a security check to make sure that the caller is allowed to
> cache flush the memory range. Even if it is a bit stale I think is OK:
> it is not possible for the memory to have already been reused somewhere
> else.

Why not? Especially when Xen itself runs virtualized, the time
window is arbitrarily large.

Jan

  reply	other threads:[~2014-10-02 11:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-02 10:01 [PATCH 0/4] xen/arm: introduce XENMEM_cache_flush Stefano Stabellini
2014-10-02 10:02 ` [PATCH 1/4] xen/arm: introduce invalidate_xen_dcache_va_range Stefano Stabellini
2014-10-02 11:57   ` Julien Grall
2014-10-03 14:00     ` Ian Campbell
2014-10-03 13:39   ` Ian Campbell
2014-10-02 10:02 ` [PATCH 2/4] xen: introduce grant_map_exists Stefano Stabellini
2014-10-02 10:17   ` Tim Deegan
2014-10-02 10:42     ` Stefano Stabellini
2014-10-02 11:30       ` Jan Beulich
2014-10-02 11:37         ` Stefano Stabellini
2014-10-02 11:45           ` Jan Beulich
2014-10-02 11:41       ` Tim Deegan
2014-10-02 11:59         ` Jan Beulich
2014-10-02 14:01           ` Tim Deegan
2014-10-03 13:47           ` Stefano Stabellini
2014-10-03 14:05             ` Stefano Stabellini
2014-10-03 15:41             ` Jan Beulich
2014-10-02 10:45   ` Jan Beulich
2014-10-02 11:34     ` Stefano Stabellini
2014-10-02 11:42       ` Jan Beulich [this message]
2014-10-02 10:02 ` [PATCH 3/4] xen/arm: introduce XENMEM_cache_flush Stefano Stabellini
2014-10-02 11:00   ` Jan Beulich
2014-10-02 11:34   ` Jan Beulich
2014-10-02 11:41     ` Stefano Stabellini
2014-10-02 11:49       ` Jan Beulich
2014-10-02 11:57         ` Stefano Stabellini
2014-10-02 12:11           ` Jan Beulich
2014-10-02 12:59             ` Stefano Stabellini
2014-10-02 12:17   ` Julien Grall
2014-10-03 13:41   ` Ian Campbell
2014-10-02 10:02 ` [PATCH 4/4] Revert "xen/arm: introduce XENFEAT_grant_map_identity" Stefano Stabellini
2014-10-02 11:02   ` Jan Beulich
2014-10-03 13:42     ` Ian Campbell

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=542D564F020000780003BEFE@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=Ian.Campbell@citrix.com \
    --cc=julien.grall@citrix.com \
    --cc=stefano.stabellini@eu.citrix.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).