mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 05:55:46 +08:00
spinlock: fix stxr instruction status register requirement
error: unpredictable STXR instruction, status is also a source
99 | "stxr %w0, %1, [%2] \n"
| ^
<inline asm>:5:10: note: instantiated into assembly here
5 | stxr w10, x10, [x9]
Using w0 to pass the result can cause the "status register is also a source" problem, resulting in unpredictable behavior.
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
This commit is contained in:
committed by
Xiang Xiao
parent
68a1774eae
commit
c6a528ef11
@@ -91,18 +91,19 @@ typedef uint64_t spinlock_t;
|
|||||||
static inline_function spinlock_t up_testset(volatile spinlock_t *lock)
|
static inline_function spinlock_t up_testset(volatile spinlock_t *lock)
|
||||||
{
|
{
|
||||||
spinlock_t ret = SP_LOCKED;
|
spinlock_t ret = SP_LOCKED;
|
||||||
|
spinlock_t tmp = 0;
|
||||||
|
|
||||||
__asm__ __volatile__
|
__asm__ __volatile__
|
||||||
(
|
(
|
||||||
"1: \n"
|
"1: \n"
|
||||||
"ldaxr %0, [%2] \n"
|
"ldaxr %0, [%3] \n"
|
||||||
"cmp %0, %1 \n"
|
"cmp %0, %2 \n"
|
||||||
"beq 2f \n"
|
"beq 2f \n"
|
||||||
"stxr %w0, %1, [%2] \n"
|
"stxr %w1, %2, [%3] \n"
|
||||||
"cbnz %w0, 1b \n"
|
"cbnz %w1, 1b \n"
|
||||||
"2: \n"
|
"2: \n"
|
||||||
: "+r" (ret)
|
: "=r" (ret)
|
||||||
: "r" (SP_LOCKED), "r" (lock)
|
: "r" (tmp), "r" (SP_LOCKED), "r" (lock)
|
||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user