From: Samuel Thibault Subject: Re: [PATCH 03/11] mini-os/xenbus: Add missing locks to xb_write Date: Thu, 26 Jun 2014 14:04:07 +0200 Message-ID: <20140626120407.GS6046@type.bordeaux.inria.fr> References: <1403291090-8657-1-git-send-email-ian.jackson@eu.citrix.com> <1403291090-8657-4-git-send-email-ian.jackson@eu.citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1X08PR-00023J-6q for xen-devel@lists.xenproject.org; Thu, 26 Jun 2014 12:04:09 +0000 Content-Disposition: inline In-Reply-To: <1403291090-8657-4-git-send-email-ian.jackson@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: Ian Jackson Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Campbell List-Id: xen-devel@lists.xenproject.org Ian Jackson, le Fri 20 Jun 2014 20:04:42 +0100, a =E9crit : > xb_write was missing any locking against concurrent calls. Well, yes, in its current form mini-os was not really meant to run with multiple processors. There are probably quite other issues like that in there. > Signed-off-by: Ian Jackson Acked-by: Samuel Thibault > --- > xen/xenbus/xenbus.c | 6 ++++++ > 1 file changed, 6 insertions(+) > = > diff --git a/xen/xenbus/xenbus.c b/xen/xenbus/xenbus.c > index 0958604..a06dc30 100644 > --- a/xen/xenbus/xenbus.c > +++ b/xen/xenbus/xenbus.c > @@ -45,6 +45,7 @@ > = > static struct xenstore_domain_interface *xenstore_buf; > static DECLARE_WAIT_QUEUE_HEAD(xb_waitq); > +static spinlock_t xb_lock =3D SPIN_LOCK_UNLOCKED; /* protects xenbus req= ring */ > DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue); > = > xenbus_event_queue xenbus_events; > @@ -372,6 +373,8 @@ static void xb_write(int type, int req_id, xenbus_tra= nsaction_t trans_id, > cur_req =3D &header_req; > = > BUG_ON(len > XENSTORE_RING_SIZE); > + > + spin_lock(&xb_lock); > /* Wait for the ring to drain to the point where we can send the > message. */ > prod =3D xenstore_buf->req_prod; > @@ -380,9 +383,11 @@ static void xb_write(int type, int req_id, xenbus_tr= ansaction_t trans_id, > /* Wait for there to be space on the ring */ > DEBUG("prod %d, len %d, cons %d, size %d; waiting.\n", > prod, len, xenstore_buf->req_cons, XENSTORE_RING_SIZE); > + spin_unlock(&xb_lock); > wait_event(xb_waitq, > xenstore_buf->req_prod + len - xenstore_buf->req_cons <= =3D > XENSTORE_RING_SIZE); > + spin_lock(&xb_lock); > DEBUG("Back from wait.\n"); > prod =3D xenstore_buf->req_prod; > } > @@ -419,6 +424,7 @@ static void xb_write(int type, int req_id, xenbus_tra= nsaction_t trans_id, > wmb(); > = > xenstore_buf->req_prod +=3D len; > + spin_unlock(&xb_lock); > = > /* Send evtchn to notify remote */ > notify_remote_via_evtchn(start_info.store_evtchn); > -- = > 1.7.10.4 > = > = > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel > = -- = Samuel sl - display animations aimed to correct users who accidentally enter sl instead of ls.