From: Ian Campbell Subject: Re: [PATCH ARM v3 7/7] mini-os: initial ARM support Date: Thu, 12 Jun 2014 08:41:54 +0100 Message-ID: <1402558914.31087.67.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> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wuze2-0001Uf-MJ for xen-devel@lists.xenproject.org; Thu, 12 Jun 2014 07:41:58 +0000 In-Reply-To: <20140611192453.GM6816@type.mobile.lan> 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 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 = 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":"=&r"(y):"r"(ptr), "r"(x), "r"(tmp):"memory"); > > +#else > > + y = (*(char *)ptr) & 0x000000ff; > > + *((char *)ptr) = (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 can't remember if it is the virt extensions themselves or the LPAE extension (which is in turn required by the virt extensions) which add this architectural requirement. Ian.