[riot-notifications] [RIOT-OS/RIOT] cpu/arm7_common: Make irq_*() compiler barriers (#11440)

Marian Buschsieweke notifications at github.com
Wed Apr 24 17:58:57 CEST 2019


maribu commented on this pull request.



>      return retval;
 }
 
 int irq_is_in(void)
 {
     int retval;
-    __asm__ volatile(" mrs  %0, cpsr" : "=r"(retval) : /* no inputs */);
+    __asm__ volatile(" mrs  %0, cpsr" : "=r"(retval) : /* no inputs */ : "memory");

I was thinking about control dependencies and speculative stores.

E.g.

```C
if (irq_is_in()) {
    /* no lock required */
    x = 3;
} 
else {
    lock();
    x = 7;
    unlock();
}
```

could be transformed into:

```C
x = 3;
if (!irq_is_in()) {
    lock();
    x = 7;
    unlock();
}
```

That unprotected `x = 3` outside of an ISR could bring a share data structure into an corrupted state...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11440#discussion_r278200124
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190424/f25de7f2/attachment.html>


More information about the notifications mailing list