Skip to content

Commit c035007

Browse files
brooniectmarinas
authored andcommitted
kselftets/arm64: Use flag bits for features in fp-ptrace assembler code
The assembler portions of fp-ptrace are passed feature flags by the C code indicating which architectural features are supported. Currently these use an entire register for each flag which is wasteful and gets cumbersome as new flags are added. Switch to using flag bits in a single register to make things easier to maintain. No functional change. Signed-off-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20241112-arm64-fp-ptrace-fpmr-v2-1-250b57c61254@kernel.org Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent c297aa7 commit c035007

File tree

3 files changed

+41
-18
lines changed

3 files changed

+41
-18
lines changed

tools/testing/selftests/arm64/fp/fp-ptrace-asm.S

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515

1616
// Load and save register values with pauses for ptrace
1717
//
18-
// x0 - SVE in use
19-
// x1 - SME in use
20-
// x2 - SME2 in use
21-
// x3 - FA64 supported
18+
// x0 - HAVE_ flags indicating which features are in use
2219

2320
.globl load_and_save
2421
load_and_save:
@@ -44,7 +41,7 @@ load_and_save:
4441
ldp q30, q31, [x7, #16 * 30]
4542

4643
// SME?
47-
cbz x1, check_sve_in
44+
tbz x0, #HAVE_SME_SHIFT, check_sve_in
4845

4946
adrp x7, svcr_in
5047
ldr x7, [x7, :lo12:svcr_in]
@@ -64,20 +61,24 @@ load_and_save:
6461
bne 1b
6562

6663
// ZT?
67-
cbz x2, check_sm_in
64+
tbz x0, #HAVE_SME2_SHIFT, check_sm_in
6865
adrp x6, zt_in
6966
add x6, x6, :lo12:zt_in
7067
_ldr_zt 6
7168

7269
// In streaming mode?
7370
check_sm_in:
7471
tbz x7, #SVCR_SM_SHIFT, check_sve_in
75-
mov x4, x3 // Load FFR if we have FA64
72+
73+
// Load FFR if we have FA64
74+
mov x4, #0
75+
tbz x0, #HAVE_FA64_SHIFT, load_sve
76+
mov x4, #1
7677
b load_sve
7778

7879
// SVE?
7980
check_sve_in:
80-
cbz x0, wait_for_writes
81+
tbz x0, #HAVE_SVE_SHIFT, wait_for_writes
8182
mov x4, #1
8283

8384
load_sve:
@@ -165,8 +166,7 @@ wait_for_writes:
165166
stp q28, q29, [x7, #16 * 28]
166167
stp q30, q31, [x7, #16 * 30]
167168

168-
// SME?
169-
cbz x1, check_sve_out
169+
tbz x0, #HAVE_SME_SHIFT, check_sve_out
170170

171171
rdsvl 11, 1
172172
adrp x6, sme_vl_out
@@ -187,20 +187,24 @@ wait_for_writes:
187187
bne 1b
188188

189189
// ZT?
190-
cbz x2, check_sm_out
190+
tbz x0, #HAVE_SME2_SHIFT, check_sm_out
191191
adrp x6, zt_out
192192
add x6, x6, :lo12:zt_out
193193
_str_zt 6
194194

195195
// In streaming mode?
196196
check_sm_out:
197197
tbz x7, #SVCR_SM_SHIFT, check_sve_out
198-
mov x4, x3 // FFR?
198+
199+
// Do we have FA64 and FFR?
200+
mov x4, #0
201+
tbz x0, #HAVE_FA64_SHIFT, read_sve
202+
mov x4, #1
199203
b read_sve
200204

201205
// SVE?
202206
check_sve_out:
203-
cbz x0, wait_for_reads
207+
tbz x0, #HAVE_SVE_SHIFT, wait_for_reads
204208
mov x4, #1
205209

206210
rdvl x7, #1
@@ -271,7 +275,7 @@ wait_for_reads:
271275
brk #0
272276

273277
// Ensure we don't leave ourselves in streaming mode
274-
cbz x1, out
278+
tbz x0, #HAVE_SME_SHIFT, out
275279
msr S3_3_C4_C2_2, xzr
276280

277281
out:

tools/testing/selftests/arm64/fp/fp-ptrace.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ uint64_t sve_vl_out;
8282
uint64_t sme_vl_out;
8383
uint64_t svcr_in, svcr_expected, svcr_out;
8484

85-
void load_and_save(int sve, int sme, int sme2, int fa64);
85+
void load_and_save(int flags);
8686

8787
static bool got_alarm;
8888

@@ -198,7 +198,7 @@ static int vl_expected(struct test_config *config)
198198

199199
static void run_child(struct test_config *config)
200200
{
201-
int ret;
201+
int ret, flags;
202202

203203
/* Let the parent attach to us */
204204
ret = ptrace(PTRACE_TRACEME, 0, 0, 0);
@@ -224,8 +224,17 @@ static void run_child(struct test_config *config)
224224
}
225225

226226
/* Load values and wait for the parent */
227-
load_and_save(sve_supported(), sme_supported(),
228-
sme2_supported(), fa64_supported());
227+
flags = 0;
228+
if (sve_supported())
229+
flags |= HAVE_SVE;
230+
if (sme_supported())
231+
flags |= HAVE_SME;
232+
if (sme2_supported())
233+
flags |= HAVE_SME2;
234+
if (fa64_supported())
235+
flags |= HAVE_FA64;
236+
237+
load_and_save(flags);
229238

230239
exit(0);
231240
}

tools/testing/selftests/arm64/fp/fp-ptrace.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@
1010
#define SVCR_SM (1 << SVCR_SM_SHIFT)
1111
#define SVCR_ZA (1 << SVCR_ZA_SHIFT)
1212

13+
#define HAVE_SVE_SHIFT 0
14+
#define HAVE_SME_SHIFT 1
15+
#define HAVE_SME2_SHIFT 2
16+
#define HAVE_FA64_SHIFT 3
17+
18+
#define HAVE_SVE (1 << HAVE_SVE_SHIFT)
19+
#define HAVE_SME (1 << HAVE_SME_SHIFT)
20+
#define HAVE_SME2 (1 << HAVE_SME2_SHIFT)
21+
#define HAVE_FA64 (1 << HAVE_FA64_SHIFT)
22+
1323
#endif

0 commit comments

Comments
 (0)