We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi experts:
In armv8 specification, I have found two types of exclusive access instructions: LDAXR/STLXR and LDREX/STREX. I have some questions about these instructions:
(1) What's the difference between these exclusive access instructions?
(2) Is LDREX/STREX only for non-cacheable memory?
(3) Is LDAXR/STLXR only for cacheable memory?
I have tried LDAXR/STLXR, When I perform a exclusive read to a shared cacheable memory location and then perform a exclusive write to this address, It seems fine and STLXR return status (w2) is 0, as expected. the part of code is below:
MOV x0, #0xd1000000 // this is a shareable cacheable address
LDAXR x1, [x0] // exclusive read
LDR w1, =0xabcd1234
STRXR w2, w1, [x0] // exclusive write
But When I perform a exclusive read to a shared non-cacheable address location i.e. DDR, this will response EXOAKY, and the perform a exclusive write to this address, it didn't response EXOKAY but OKAY ( w2 is 1), thus the exclusive write is failed. I don't know why.
MOV x0, #0x40000000 // this is a shareable non-cacheable address (DDR)
While LDAXR has an implicit synchronization, LDREX/STREX is just an exclusive access to an address. You will need a data barrier such as DMB to make sure all CPUs see the same value.