From: "Jan Beulich" Subject: Re: [PATCH v7 6/8] xen/arm: introduce GNTTABOP_cache_flush Date: Fri, 17 Oct 2014 17:16:25 +0100 Message-ID: <54415CF9020000780003FB87@mail.emea.novell.com> References: <1413559886-11516-6-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: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XfACZ-0003La-8n for xen-devel@lists.xenproject.org; Fri, 17 Oct 2014 16:16:27 +0000 In-Reply-To: <1413559886-11516-6-git-send-email-stefano.stabellini@eu.citrix.com> Content-Disposition: inline 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 Cc: julien.grall@citrix.com, xen-devel , Ian.Campbell@citrix.com List-Id: xen-devel@lists.xenproject.org >>> On 17.10.14 at 17:31, wrote: > +static int grant_map_exists(const struct domain *ld, > + struct grant_table *rgt, > + unsigned long mfn, > + grant_ref_t *ref_count) > +{ > + const struct active_grant_entry *act; > + grant_ref_t ref; > + > + ASSERT(spin_is_locked(&rgt->lock)); > + > + for ( ref = *ref_count; ref < nr_grant_entries(rgt); ref++ ) > + { > + if ( (ref % MAX_GRANT_ENTRIES_ITERATIONS) == 0 && ref != *ref_count ) > + { > + *ref_count = ref; > + return ref; > + } > + > + act = &active_entry(rgt, ref); > + > + if ( !act->pin ) > + continue; > + > + if ( act->domid != ld->domain_id ) > + continue; > + > + if ( act->frame != mfn ) > + continue; > + > + return 0; > + } > + > + return -1; Return values need to be adjusted throughout the function: The -1 here gets passed up all the way, and hence will be seen as -EPERM by the caller of the hypercall, which clearly isn't right. Also returning ref (effectively a uint32_t) above doesn't fit with the function returning (signed) int. The caller doesn't care about the actual count, so just returning 1 in that case would seem fine. > +#define OPAQUE_CONTINUATION_ARG_SHIFT 16 > +#define CMD_MASK ((1<