[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v5 02/17] Add cmpxchg16b support for x86-64
On Wed, Aug 12, 2015 at 10:35:23AM +0800, Feng Wu wrote: > This patch adds cmpxchg16b support for x86-64, so software > can perform 128-bit atomic write/read. > > CC: Keir Fraser <keir@xxxxxxx> > CC: Jan Beulich <jbeulich@xxxxxxxx> > CC: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> > Signed-off-by: Feng Wu <feng.wu@xxxxxxxxx> > --- > v5: > - Change back the parameters of __cmpxchg16b() to __uint128_t * > - Remove pointless cast for 'ptr' > - Remove pointless parentheses > - Use A constraint for the output > > v4: > - Use pointer as the parameter of __cmpxchg16b(). > - Use gcc's __uint128_t built-in type > - Make the parameters of __cmpxchg16b() void * > > v3: > - Newly added. > > xen/include/asm-x86/x86_64/system.h | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/xen/include/asm-x86/x86_64/system.h > b/xen/include/asm-x86/x86_64/system.h > index 662813a..ebbe4b5 100644 > --- a/xen/include/asm-x86/x86_64/system.h > +++ b/xen/include/asm-x86/x86_64/system.h > @@ -6,6 +6,34 @@ > (unsigned long)(n),sizeof(*(ptr)))) > > /* > + * Atomic 16 bytes compare and exchange. Compare OLD with MEM, if > + * identical, store NEW in MEM. Return the initial value in MEM. > + * Success is indicated by comparing RETURN with OLD. > + * > + * This function can only be called when cpu_has_cx16 is ture. s/ture/true/ > + */ > + > +static always_inline __uint128_t __cmpxchg16b( > + volatile void *ptr, __uint128_t *old, __uint128_t *new) > +{ > + __uint128_t prev; > + uint64_t new_high = *new >> 64; > + uint64_t new_low = (uint64_t)*new; > + > + ASSERT(cpu_has_cx16); > + > + asm volatile ( "lock; cmpxchg16b %3" > + : "=A" (prev) > + : "c" (new_high), "b" (new_low), "m" (*__xg(ptr)), "0" > (*old) > + : "memory" ); > + > + return prev; > +} > + > +#define cmpxchg16b(ptr,o,n) \ > + __cmpxchg16b((ptr), (__uint128_t *)(o), (__uint128_t *)(n)) > + > +/* > * This function causes value _o to be changed to _n at location _p. > * If this access causes a fault then we return 1, otherwise we return 0. > * If no fault occurs then _o is updated to the value we saw at _p. If this > -- > 2.1.0 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@xxxxxxxxxxxxx > http://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |