File tree Expand file tree Collapse file tree 3 files changed +41
-1
lines changed
tools/testing/selftests/kvm Expand file tree Collapse file tree 3 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 35
35
36
36
LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/rbtree.c lib/sparsebit.c lib/test_util.c lib/guest_modes.c lib/perf_test_util.c
37
37
LIBKVM_x86_64 = lib/x86_64/apic.c lib/x86_64/processor.c lib/x86_64/vmx.c lib/x86_64/svm.c lib/x86_64/ucall.c lib/x86_64/handlers.S
38
- LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c lib/aarch64/handlers.S
38
+ LIBKVM_aarch64 = lib/aarch64/processor.c lib/aarch64/ucall.c lib/aarch64/handlers.S lib/aarch64/spinlock.c
39
39
LIBKVM_s390x = lib/s390x/processor.c lib/s390x/ucall.c lib/s390x/diag318_test_handler.c
40
40
41
41
TEST_GEN_PROGS_x86_64 = x86_64/cr4_cpuid_sync_test
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0 */
2
+
3
+ #ifndef SELFTEST_KVM_ARM64_SPINLOCK_H
4
+ #define SELFTEST_KVM_ARM64_SPINLOCK_H
5
+
6
+ struct spinlock {
7
+ int v ;
8
+ };
9
+
10
+ extern void spin_lock (struct spinlock * lock );
11
+ extern void spin_unlock (struct spinlock * lock );
12
+
13
+ #endif /* SELFTEST_KVM_ARM64_SPINLOCK_H */
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments