arm: use BASEPRI_MAX instead of BASEPRI to mask interrupts
When locking interrupt in a critical session, it is safer to do MSR BASEPRI_MAX instead of BASEPRI. The rationale is that when writing to BASEPRI_MAX, the writing is conditional, and is only applied if the change is to a higher priority level. This commit replaces BASEPRI with BASEPRI_MAX in operations that aim to lock some specific interrupts: - irq_lock() - masking out PendSV So, for example, it is not possible to actually unmask any interrupts by doing an irq_lock operation. The commit does not introduce behavioral changes. However, it makes irq_lock() more robust against future changes to the IRQ locking mechanism. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
7156183985
commit
03c4bcd920
3 changed files with 4 additions and 4 deletions
|
@ -56,7 +56,7 @@ static ALWAYS_INLINE unsigned int arch_irq_lock(void)
|
|||
__asm__ volatile(
|
||||
"mov %1, %2;"
|
||||
"mrs %0, BASEPRI;"
|
||||
"msr BASEPRI, %1;"
|
||||
"msr BASEPRI_MAX, %1;"
|
||||
"isb;"
|
||||
: "=r"(key), "=r"(tmp)
|
||||
: "i"(_EXC_IRQ_DEFAULT_PRIO)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue