From: Ian Campbell Subject: Re: [PATCH ARM v3 7/7] mini-os: initial ARM support Date: Thu, 12 Jun 2014 08:53:44 +0100 Message-ID: <1402559624.31087.68.camel@dagon.hellion.org.uk> References: <1402482618-15269-1-git-send-email-talex5@gmail.com> <1402482618-15269-8-git-send-email-talex5@gmail.com> <20140611192453.GM6816@type.mobile.lan> <1402558914.31087.67.camel@dagon.hellion.org.uk> <20140612074411.GU5699@type.youpi.perso.aquilenet.fr> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wuzq2-00028S-MD for xen-devel@lists.xenproject.org; Thu, 12 Jun 2014 07:54:22 +0000 In-Reply-To: <20140612074411.GU5699@type.youpi.perso.aquilenet.fr> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Samuel Thibault Cc: xen-devel@lists.xenproject.org, Thomas Leonard , anil@recoil.org, Dave.Scott@eu.citrix.com, stefano.stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org On Thu, 2014-06-12 at 09:44 +0200, Samuel Thibault wrote: > Ian Campbell, le Thu 12 Jun 2014 08:41:54 +0100, a =E9crit : > > On Wed, 2014-06-11 at 21:24 +0200, Samuel Thibault wrote: > > > > +static inline unsigned long __xchg(unsigned long x, volatile void = * ptr, int size) > > > > +{ > > > > + //TODO > > > > + unsigned volatile long y, tmp =3D 0; > > > > + switch(size){ > > > > + case 1: > > > > +#if CPU_EXCLUSIVE_LDST > > > > + __asm__ __volatile__("1:ldrexb %0, [%1]\n" > > > > + "strexb %3, %2, [%1]\n" > > > > + "cmp %3, #1\n" > > > > + "beq 1b\n\n" > > > > + "dmb\n":"=3D&r"(y):"r"(ptr), "r"(x), "r"(tmp):"memory"= ); > > > > +#else > > > > + y =3D (*(char *)ptr) & 0x000000ff; > > > > + *((char *)ptr) =3D (char)x; > > > = > > > The second version is very fragile :) I'd rather put a strong #warning > > > here, to make sure nobody ever uses that code for anything close to > > > production level. > > = > > ldrexb is guaranteed to be available on any platform which can run Xen. > > For one thing xen uses them (unconditionally) itself. > = > I'd rather see minios us them unconditionally then, to avoid the risk of > running unsafe code :) Right, that's what I was trying to say but ended up not actually saying it outright ;-) Ian