From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 2/4] xen: introduce grant_map_exists Date: Fri, 3 Oct 2014 16:02:24 +0100 Message-ID: <542EBA80.1040901@citrix.com> References: <1412347845-27755-2-git-send-email-stefano.stabellini@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1412347845-27755-2-git-send-email-stefano.stabellini@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Stefano Stabellini , xen-devel@lists.xensource.com Cc: julien.grall@citrix.com, Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On 03/10/14 15:50, Stefano Stabellini wrote: > Check whether an mfn has been granted to a given domain on a target > grant table. > > Signed-off-by: Stefano Stabellini > > --- > > Changes in v2: > - make the function static; > - remove the spin_lock. > --- > xen/common/grant_table.c | 30 ++++++++++++++++++++++++++++++ > 1 file changed, 30 insertions(+) > > diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c > index 23266c3..7a6399b 100644 > --- a/xen/common/grant_table.c > +++ b/xen/common/grant_table.c > @@ -484,6 +484,36 @@ static int _set_status(unsigned gt_version, > return _set_status_v2(domid, readonly, mapflag, shah, act, status); > } > > +static 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; > + > + ASSERT(&rgt->lock); I presume you mean spin_is_locked()? This assertion is currently a tautology. ~Andrew > + > + 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; > + } > + > + return ret; > +} > + > static void mapcount( > struct grant_table *lgt, struct domain *rd, unsigned long mfn, > unsigned int *wrc, unsigned int *rdc)