title: Raspberry Pi ldrex causes data abort
body: <p>I have a simple bare metal Raspberry Pi project in which I'm trying to implement spin locks. This is my code:</p>
  
  <pre><code>spinlock_lock:
      push {r4, r5, lr} 
  
      mov r5, #0x1
  1:
      ldrex r4, [r0]
      teq r4, #0
      strexeq r4, r5, [r0]
      teqeq r4, #0
      bne 1b
  
      pop {r4, r5, pc} 
  </code></pre>
  
  <p>The problem is that the <code>ldrex</code> causes a data abort. The pointer I'm passing is page aligned, and the ARM runs in system mode. The strange thing is, replacing this code with a version that uses non exclusive loads/stores, it works. Is there anything I need to keep in mind when using exclusive loads and stores?</p>