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

Re: [PATCH v7 08/19] xen/riscv: introduce cmpxchg.h



On Thu, 2024-04-04 at 17:01 +0200, Jan Beulich wrote:
> On 03.04.2024 12:20, Oleksii Kurochko wrote:
> > +#define emulate_cmpxchg_1_2(ptr, old, new, lr_sfx, sc_sfx) \
> > +({ \
> > +    uint32_t *aligned_ptr; \
> > +    unsigned long alignment_mask = sizeof(*aligned_ptr) -
> > sizeof(*(ptr)); \
> > +    uint8_t new_val_bit = \
> > +        ((unsigned long)(ptr) & alignment_mask) * BITS_PER_BYTE; \
> > +    unsigned long mask = \
> > +        GENMASK(((sizeof(*(ptr))) * BITS_PER_BYTE) - 1, 0) <<
> > new_val_bit; \
> > +    unsigned int old_ = (old) << new_val_bit; \
> > +    unsigned int new_ = (new) << new_val_bit; \
> > +    unsigned int old_val; \
> > +    unsigned int scratch; \
> > +    \
> > +    aligned_ptr = (uint32_t *)((unsigned long)ptr &
> > ~alignment_mask); \
> > +    \
> > +    asm volatile ( \
> > +        "0: lr.w" lr_sfx " %[scratch], %[ptr_]\n" \
> > +        "   and  %[old_val], %[scratch], %[mask]\n" \
> > +        "   bne  %[old_val], %z[old_], 1f\n" \
> > +        /* the following line is an equivalent to:
> > +         *     scratch = old_val & ~mask;
> > +         * And to elimanate one ( likely register ) input it was
> > decided
> > +         * to use:
> > +         *     scratch = old_val ^ scratch
> > +         */ \
> 
> I'm surprised this compiles without \-es inside the comment as well.
> Line
> splicing happens ahead of comment recognition as per the spec.
I'll add \-es inside the comment.

> 
> Everything else okay-ish to me now, but I can't very well given an
> ack for
> a patch depending on things that haven't been committed yet and may
> never be.
Except 3 dependency ( which should be dropped as nothing anymore is
used now from this headers ):
   #include <asm/fence.h>
   #include <asm/io.h>
   #include <asm/system.h>

It seems everything else doesn't depending on other things, does it?

~ Oleksii




 


Rackspace

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