[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH ARM v3 7/7] mini-os: initial ARM support



On Thu, 2014-06-12 at 09:44 +0200, Samuel Thibault wrote:
> Ian Campbell, le Thu 12 Jun 2014 08:41:54 +0100, a écrit :
> > 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'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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.