This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Issue with stxr in ARMv8

Hi,

I am writing a simple spinlock taking Juno arm trusted firmware spinlock code.

But for me stxr instruction is always failing giving w1 value as "1" always.

When I read ARMv8 spec it says (under section B2.10.5) "Unpredictable behavior when load-ex/store-ex access a different number of registers" - subsection stxr instruction always fails returning "1".

I am not sure how for Juno below code is working as the ldaxr and stxr instruction access different number of registers and also if I take same code it doesn't work and stxr instruction always fails.

I suspect may be I am setting memory attributes wrongly (for X0) ? Can some one explain the difference between ldxr vs ldaxr and stxr vs stlxr instruction as well ?

        mov     w2, #1

        sevl

l1:     wfe

l2:     ldaxr   w1, [x0]

        cbnz    w1, l1

        stxr    w1, w2, [x0]

        cbnz    w1, l2

        ret

Thanks,