]> Git Repo - linux.git/blob - tools/testing/selftests/kvm/lib/arm64/spinlock.c
Linux 6.14-rc3
[linux.git] / tools / testing / selftests / kvm / lib / arm64 / spinlock.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3  * ARM64 Spinlock support
4  */
5 #include <stdint.h>
6
7 #include "spinlock.h"
8
9 void spin_lock(struct spinlock *lock)
10 {
11         int val, res;
12
13         asm volatile(
14         "1:     ldaxr   %w0, [%2]\n"
15         "       cbnz    %w0, 1b\n"
16         "       mov     %w0, #1\n"
17         "       stxr    %w1, %w0, [%2]\n"
18         "       cbnz    %w1, 1b\n"
19         : "=&r" (val), "=&r" (res)
20         : "r" (&lock->v)
21         : "memory");
22 }
23
24 void spin_unlock(struct spinlock *lock)
25 {
26         asm volatile("stlr wzr, [%0]\n" : : "r" (&lock->v) : "memory");
27 }
This page took 0.034597 seconds and 4 git commands to generate.