Skip to content

Commit d6fc5db

Browse files
committed
Merge branch 'for-next/kselftest' into for-next/core
* for-next/kselftest: (32 commits) : arm64 kselftest updates. kselftest/arm64: Explicitly build no BTI tests with BTI disabled kselftest/arm64: bti: force static linking selftests/arm64: Use switch statements in mte_common_util.c selftests/arm64: Remove casts to/from void in check_tags_inclusion selftests/arm64: Check failures to set tags in check_tags_inclusion selftests/arm64: Allow zero tags in mte_switch_mode() selftests/arm64: Log errors in verify_mte_pointer_validity() kselftest/arm64: Fix ABI header directory location selftests/arm64: Fix O= builds for the floating point tests selftests/arm64: Clean the fp helper libraries selftests/arm64: Define top_srcdir for the fp tests selftests/arm64: Use TEST_GEN_PROGS_EXTENDED in the FP Makefile kselftest/arm64: fix array_size.cocci warning selftests/arm64: Add a testcase for handling of ZA on clone() kselftest/arm64: Add SME support to syscall ABI test kselftest/arm64: Add coverage for the ZA ptrace interface kselftest/arm64: Add streaming SVE to SVE ptrace tests kselftest/arm64: signal: Add SME signal handling tests kselftest/arm64: Add stress test for SME ZA context switching kselftest/arm64: signal: Handle ZA signal context in core code ...
2 parents e003d53 + 9f93c2e commit d6fc5db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2761
-116
lines changed

tools/testing/selftests/arm64/Makefile

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,7 @@ top_srcdir = $(realpath ../../../../)
1717
# Additional include paths needed by kselftest.h and local headers
1818
CFLAGS += -I$(top_srcdir)/tools/testing/selftests/
1919

20-
# Guessing where the Kernel headers could have been installed
21-
# depending on ENV config
22-
ifeq ($(KBUILD_OUTPUT),)
23-
khdr_dir = $(top_srcdir)/usr/include
24-
else
25-
# the KSFT preferred location when KBUILD_OUTPUT is set
26-
khdr_dir = $(KBUILD_OUTPUT)/kselftest/usr/include
27-
endif
28-
29-
CFLAGS += -I$(khdr_dir)
20+
CFLAGS += $(KHDR_INCLUDES)
3021

3122
export CFLAGS
3223
export top_srcdir
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
syscall-abi
2+
tpidr2
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# SPDX-License-Identifier: GPL-2.0
22
# Copyright (C) 2021 ARM Limited
33

4-
TEST_GEN_PROGS := syscall-abi
4+
TEST_GEN_PROGS := syscall-abi tpidr2
55

66
include ../../lib.mk
77

88
$(OUTPUT)/syscall-abi: syscall-abi.c syscall-abi-asm.S
9+
10+
# Build with nolibc since TPIDR2 is intended to be actively managed by
11+
# libc and we're trying to test the functionality that it depends on here.
12+
$(OUTPUT)/tpidr2: tpidr2.c
13+
$(CC) -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
14+
-static -include ../../../../include/nolibc/nolibc.h \
15+
-ffreestanding -Wall $^ -o $@ -lgcc

tools/testing/selftests/arm64/abi/syscall-abi-asm.S

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,42 @@
99
// invoked is configured in x8 of the input GPR data.
1010
//
1111
// x0: SVE VL, 0 for FP only
12+
// x1: SME VL
1213
//
1314
// GPRs: gpr_in, gpr_out
1415
// FPRs: fpr_in, fpr_out
1516
// Zn: z_in, z_out
1617
// Pn: p_in, p_out
1718
// FFR: ffr_in, ffr_out
19+
// ZA: za_in, za_out
20+
// SVCR: svcr_in, svcr_out
21+
22+
#include "syscall-abi.h"
1823

1924
.arch_extension sve
2025

26+
/*
27+
* LDR (vector to ZA array):
28+
* LDR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL]
29+
*/
30+
.macro _ldr_za nw, nxbase, offset=0
31+
.inst 0xe1000000 \
32+
| (((\nw) & 3) << 13) \
33+
| ((\nxbase) << 5) \
34+
| ((\offset) & 7)
35+
.endm
36+
37+
/*
38+
* STR (vector from ZA array):
39+
* STR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL]
40+
*/
41+
.macro _str_za nw, nxbase, offset=0
42+
.inst 0xe1200000 \
43+
| (((\nw) & 3) << 13) \
44+
| ((\nxbase) << 5) \
45+
| ((\offset) & 7)
46+
.endm
47+
2148
.globl do_syscall
2249
do_syscall:
2350
// Store callee saved registers x19-x29 (80 bytes) plus x0 and x1
@@ -30,6 +57,24 @@ do_syscall:
3057
stp x25, x26, [sp, #80]
3158
stp x27, x28, [sp, #96]
3259

60+
// Set SVCR if we're doing SME
61+
cbz x1, 1f
62+
adrp x2, svcr_in
63+
ldr x2, [x2, :lo12:svcr_in]
64+
msr S3_3_C4_C2_2, x2
65+
1:
66+
67+
// Load ZA if it's enabled - uses x12 as scratch due to SME LDR
68+
tbz x2, #SVCR_ZA_SHIFT, 1f
69+
mov w12, #0
70+
ldr x2, =za_in
71+
2: _ldr_za 12, 2
72+
add x2, x2, x1
73+
add x12, x12, #1
74+
cmp x1, x12
75+
bne 2b
76+
1:
77+
3378
// Load GPRs x8-x28, and save our SP/FP for later comparison
3479
ldr x2, =gpr_in
3580
add x2, x2, #64
@@ -68,7 +113,7 @@ do_syscall:
68113
ldp q30, q31, [x2, #16 * 30]
69114
1:
70115

71-
// Load the SVE registers if we're doing SVE
116+
// Load the SVE registers if we're doing SVE/SME
72117
cbz x0, 1f
73118

74119
ldr x2, =z_in
@@ -105,9 +150,14 @@ do_syscall:
105150
ldr z30, [x2, #30, MUL VL]
106151
ldr z31, [x2, #31, MUL VL]
107152

153+
// Only set a non-zero FFR, test patterns must be zero since the
154+
// syscall should clear it - this lets us handle FA64.
108155
ldr x2, =ffr_in
109156
ldr p0, [x2, #0]
157+
ldr x2, [x2, #0]
158+
cbz x2, 2f
110159
wrffr p0.b
160+
2:
111161

112162
ldr x2, =p_in
113163
ldr p0, [x2, #0, MUL VL]
@@ -169,6 +219,24 @@ do_syscall:
169219
stp q28, q29, [x2, #16 * 28]
170220
stp q30, q31, [x2, #16 * 30]
171221

222+
// Save SVCR if we're doing SME
223+
cbz x1, 1f
224+
mrs x2, S3_3_C4_C2_2
225+
adrp x3, svcr_out
226+
str x2, [x3, :lo12:svcr_out]
227+
1:
228+
229+
// Save ZA if it's enabled - uses x12 as scratch due to SME STR
230+
tbz x2, #SVCR_ZA_SHIFT, 1f
231+
mov w12, #0
232+
ldr x2, =za_out
233+
2: _str_za 12, 2
234+
add x2, x2, x1
235+
add x12, x12, #1
236+
cmp x1, x12
237+
bne 2b
238+
1:
239+
172240
// Save the SVE state if we have some
173241
cbz x0, 1f
174242

@@ -224,6 +292,10 @@ do_syscall:
224292
str p14, [x2, #14, MUL VL]
225293
str p15, [x2, #15, MUL VL]
226294

295+
// Only save FFR if we wrote a value for SME
296+
ldr x2, =ffr_in
297+
ldr x2, [x2, #0]
298+
cbz x2, 1f
227299
ldr x2, =ffr_out
228300
rdffr p0.b
229301
str p0, [x2, #0]
@@ -237,4 +309,9 @@ do_syscall:
237309
ldp x27, x28, [sp, #96]
238310
ldp x29, x30, [sp], #112
239311

312+
// Clear SVCR if we were doing SME so future tests don't have ZA
313+
cbz x1, 1f
314+
msr S3_3_C4_C2_2, xzr
315+
1:
316+
240317
ret

0 commit comments

Comments
 (0)