Message ID | 1412347845-27755-2-git-send-email-stefano.stabellini@eu.citrix.com |
---|---|
State | New |
Headers | show |
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 <stefano.stabellini@eu.citrix.com> > > --- > > 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)
On Fri, 3 Oct 2014, Andrew Cooper wrote: > 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 <stefano.stabellini@eu.citrix.com> > > > > --- > > > > 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. Ooops, you are right. > ~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) >
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); + + 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)
Check whether an mfn has been granted to a given domain on a target grant table. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- Changes in v2: - make the function static; - remove the spin_lock. --- xen/common/grant_table.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)