From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH] gnttab: lock the left grant table earlier in __gnttab_unmap_common() Date: Mon, 11 Nov 2013 09:53:01 +0000 Message-ID: <5280A8FD.6050707@citrix.com> References: <1384135642-26301-1-git-send-email-msw@linux.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VfoB8-00089h-Bc for xen-devel@lists.xenproject.org; Mon, 11 Nov 2013 09:53:06 +0000 In-Reply-To: <1384135642-26301-1-git-send-email-msw@linux.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: Matt Wilson Cc: xen-devel@lists.xenproject.org, Keir Fraser , Jan Beulich , Matt Wilson , Anthony Liguori List-Id: xen-devel@lists.xenproject.org On 11/11/13 02:07, Matt Wilson wrote: > From: Matt Wilson > > Luckily today maptrack_limit never shrinks. But if at some point in > the future this were to change, checking maptrack_limit without > holding the grant table spinlock would no longer be safe. > > Cc: xen-devel@lists.xenproject.org > Cc: Keir Fraser > Cc: Jan Beulich Reviewed-by: Andrew Cooper > Cc: Anthony Liguori > Signed-off-by: Matt Wilson > --- > xen/common/grant_table.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c > index 21c6a14..ef10ff4 100644 > --- a/xen/common/grant_table.c > +++ b/xen/common/grant_table.c > @@ -842,15 +842,16 @@ __gnttab_unmap_common( > > op->frame = (unsigned long)(op->dev_bus_addr >> PAGE_SHIFT); > > + spin_lock(&lgt->lock); > if ( unlikely(op->handle >= lgt->maptrack_limit) ) > { > + spin_unlock(&lgt->lock); > gdprintk(XENLOG_INFO, "Bad handle (%d).\n", op->handle); > op->status = GNTST_bad_handle; > return; > } > > op->map = &maptrack_entry(lgt, op->handle); > - spin_lock(&lgt->lock); > > if ( unlikely(!op->map->flags) ) > {