Skip to content

Commit 082f6b4

Browse files
committed
Merge branch 'for-next/kselftest' into for-next/core
* for-next/kselftest: selftests: arm64: Factor out utility functions for assembly FP tests selftests: arm64: Add coverage of ptrace flags for SVE VL inheritance selftests: arm64: Verify that all possible vector lengths are handled selftests: arm64: Fix and enable test for setting current VL in vec-syscfg selftests: arm64: Remove bogus error check on writing to files selftests: arm64: Fix printf() format mismatch in vec-syscfg selftests: arm64: Move FPSIMD in SVE ptrace test into a function selftests: arm64: More comprehensively test the SVE ptrace interface selftests: arm64: Verify interoperation of SVE and FPSIMD register sets selftests: arm64: Clarify output when verifying SVE register set selftests: arm64: Document what the SVE ptrace test is doing selftests: arm64: Remove extraneous register setting code selftests: arm64: Don't log child creation as a test in SVE ptrace test selftests: arm64: Use a define for the number of SVE ptrace tests to be run
2 parents d8a2c0f + 260ea4b commit 082f6b4

File tree

9 files changed

+640
-524
lines changed

9 files changed

+640
-524
lines changed

tools/testing/selftests/arm64/fp/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ TEST_PROGS_EXTENDED := fpsimd-test fpsimd-stress \
99

1010
all: $(TEST_GEN_PROGS) $(TEST_PROGS_EXTENDED)
1111

12-
fpsimd-test: fpsimd-test.o
12+
fpsimd-test: fpsimd-test.o asm-utils.o
1313
$(CC) -nostdlib $^ -o $@
1414
rdvl-sve: rdvl-sve.o rdvl.o
15-
sve-ptrace: sve-ptrace.o sve-ptrace-asm.o
15+
sve-ptrace: sve-ptrace.o
1616
sve-probe-vls: sve-probe-vls.o rdvl.o
17-
sve-test: sve-test.o
17+
sve-test: sve-test.o asm-utils.o
1818
$(CC) -nostdlib $^ -o $@
1919
vec-syscfg: vec-syscfg.o rdvl.o
2020
vlset: vlset.o

tools/testing/selftests/arm64/fp/TODO

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
- Test unsupported values in the ABIs.
2-
- More coverage for ptrace (eg, vector length conversions).
3-
- Coverage for signals.
4-
- Test PR_SVE_VL_INHERITY after a double fork.
2+
- More coverage for ptrace:
3+
- Get/set of FFR.
4+
- Ensure ptraced processes actually see the register state visible through
5+
the ptrace interface.
6+
- Big endian.
7+
- Test PR_SVE_VL_INHERIT after a double fork.
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
// Copyright (C) 2015-2021 ARM Limited.
3+
// Original author: Dave Martin <[email protected]>
4+
//
5+
// Utility functions for assembly code.
6+
7+
#include <asm/unistd.h>
8+
#include "assembler.h"
9+
10+
// Print a single character x0 to stdout
11+
// Clobbers x0-x2,x8
12+
function putc
13+
str x0, [sp, #-16]!
14+
15+
mov x0, #1 // STDOUT_FILENO
16+
mov x1, sp
17+
mov x2, #1
18+
mov x8, #__NR_write
19+
svc #0
20+
21+
add sp, sp, #16
22+
ret
23+
endfunction
24+
.globl putc
25+
26+
// Print a NUL-terminated string starting at address x0 to stdout
27+
// Clobbers x0-x3,x8
28+
function puts
29+
mov x1, x0
30+
31+
mov x2, #0
32+
0: ldrb w3, [x0], #1
33+
cbz w3, 1f
34+
add x2, x2, #1
35+
b 0b
36+
37+
1: mov w0, #1 // STDOUT_FILENO
38+
mov x8, #__NR_write
39+
svc #0
40+
41+
ret
42+
endfunction
43+
.globl puts
44+
45+
// Print an unsigned decimal number x0 to stdout
46+
// Clobbers x0-x4,x8
47+
function putdec
48+
mov x1, sp
49+
str x30, [sp, #-32]! // Result can't be > 20 digits
50+
51+
mov x2, #0
52+
strb w2, [x1, #-1]! // Write the NUL terminator
53+
54+
mov x2, #10
55+
0: udiv x3, x0, x2 // div-mod loop to generate the digits
56+
msub x0, x3, x2, x0
57+
add w0, w0, #'0'
58+
strb w0, [x1, #-1]!
59+
mov x0, x3
60+
cbnz x3, 0b
61+
62+
ldrb w0, [x1]
63+
cbnz w0, 1f
64+
mov w0, #'0' // Print "0" for 0, not ""
65+
strb w0, [x1, #-1]!
66+
67+
1: mov x0, x1
68+
bl puts
69+
70+
ldr x30, [sp], #32
71+
ret
72+
endfunction
73+
.globl putdec
74+
75+
// Print an unsigned decimal number x0 to stdout, followed by a newline
76+
// Clobbers x0-x5,x8
77+
function putdecn
78+
mov x5, x30
79+
80+
bl putdec
81+
mov x0, #'\n'
82+
bl putc
83+
84+
ret x5
85+
endfunction
86+
.globl putdecn
87+
88+
// Clobbers x0-x3,x8
89+
function puthexb
90+
str x30, [sp, #-0x10]!
91+
92+
mov w3, w0
93+
lsr w0, w0, #4
94+
bl puthexnibble
95+
mov w0, w3
96+
97+
ldr x30, [sp], #0x10
98+
// fall through to puthexnibble
99+
endfunction
100+
.globl puthexb
101+
102+
// Clobbers x0-x2,x8
103+
function puthexnibble
104+
and w0, w0, #0xf
105+
cmp w0, #10
106+
blo 1f
107+
add w0, w0, #'a' - ('9' + 1)
108+
1: add w0, w0, #'0'
109+
b putc
110+
endfunction
111+
.globl puthexnibble
112+
113+
// x0=data in, x1=size in, clobbers x0-x5,x8
114+
function dumphex
115+
str x30, [sp, #-0x10]!
116+
117+
mov x4, x0
118+
mov x5, x1
119+
120+
0: subs x5, x5, #1
121+
b.lo 1f
122+
ldrb w0, [x4], #1
123+
bl puthexb
124+
b 0b
125+
126+
1: ldr x30, [sp], #0x10
127+
ret
128+
endfunction
129+
.globl dumphex
130+
131+
// Trivial memory copy: copy x2 bytes, starting at address x1, to address x0.
132+
// Clobbers x0-x3
133+
function memcpy
134+
cmp x2, #0
135+
b.eq 1f
136+
0: ldrb w3, [x1], #1
137+
strb w3, [x0], #1
138+
subs x2, x2, #1
139+
b.ne 0b
140+
1: ret
141+
endfunction
142+
.globl memcpy
143+
144+
// Fill x1 bytes starting at x0 with 0xae (for canary purposes)
145+
// Clobbers x1, x2.
146+
function memfill_ae
147+
mov w2, #0xae
148+
b memfill
149+
endfunction
150+
.globl memfill_ae
151+
152+
// Fill x1 bytes starting at x0 with 0.
153+
// Clobbers x1, x2.
154+
function memclr
155+
mov w2, #0
156+
endfunction
157+
.globl memclr
158+
// fall through to memfill
159+
160+
// Trivial memory fill: fill x1 bytes starting at address x0 with byte w2
161+
// Clobbers x1
162+
function memfill
163+
cmp x1, #0
164+
b.eq 1f
165+
166+
0: strb w2, [x0], #1
167+
subs x1, x1, #1
168+
b.ne 0b
169+
170+
1: ret
171+
endfunction
172+
.globl memfill

tools/testing/selftests/arm64/fp/assembler.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,15 @@ endfunction
5454
.purgem \name\()_entry
5555
.endm
5656

57+
// Utility macro to print a literal string
58+
// Clobbers x0-x4,x8
59+
.macro puts string
60+
.pushsection .rodata.str1.1, "aMS", 1
61+
.L__puts_literal\@: .string "\string"
62+
.popsection
63+
64+
ldr x0, =.L__puts_literal\@
65+
bl puts
66+
.endm
67+
5768
#endif /* ! ASSEMBLER_H */

0 commit comments

Comments
 (0)