From: Ian Campbell Subject: Re: [PATCH] xen: arm: clear the exclusive monitor on exception return Date: Fri, 19 Jul 2013 15:17:53 +0100 Message-ID: <1374243473.13645.88.camel@kazak.uk.xensource.com> References: <1374059931-7508-1-git-send-email-ian.campbell@citrix.com> <20130717194821.GC80836@ocelot.phlegethon.org> <1374136284.26728.39.camel@kazak.uk.xensource.com> <20130718164825.GB94768@ocelot.phlegethon.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130718164825.GB94768@ocelot.phlegethon.org> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tim Deegan Cc: julien.grall@citrix.com, xen-devel@lists.xen.org, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Thu, 2013-07-18 at 17:48 +0100, Tim Deegan wrote: > At 09:31 +0100 on 18 Jul (1374139884), Ian Campbell wrote: > > On Wed, 2013-07-17 at 20:48 +0100, Tim Deegan wrote: > > > At 12:18 +0100 on 17 Jul (1374063531), Ian Campbell wrote: > > > > Otherwise context switching between two vcpus which are contending the same > > > > lock can result in a spurious success. > > > > > > Shouldn't this go in ctxt_swicth_to(), then? I think any use that Xen > > > itself makes of the monitor should end with it cleared. > > > > Our atomic read/set which we stole^Winherited from Linux relies on this > > behaviour (interlocking with atomic_add_and_blah stuff). > > /* > > * On ARM, ordinary assignment (str instruction) doesn't clear the local > > * strex/ldrex monitor on some implementations. The reason we can use it for > > * atomic_set() is the clrex or dummy strex done on every exception return. > > */ > > Ah, OK. So, Ack, but if it's not already committed can you edit the > commit message to refer to this? Applied, thanks. Commit message is now: xen: arm: clear the exclusive monitor on exception return Otherwise context switching between two vcpus which are contending the same lock can result in a spurious success. Our spinlock and atomics code (which we get from Linux) rely on this behaviour because they use non-exclusive stores for single instruction operations (e.g. spin_unlock or atomic_set). This is not required on ARMv8 since eret implicitly clears the monitor. Signed-off-by: Ian Campbell Acked-by: Stefano Stabellini Acked-by: Tim Deegan