Skip to content

Commit f92f17a

Browse files
committed
Merge branch 'for-next/selftests' into for-next/core
* for-next/selftests: kselftest/arm64: Set default OUTPUT path when undefined kselftest/arm64: fp-ptrace: Adjust to new inactive mode behaviour kselftest/arm64: fp-ptrace: Adjust to new VL change behaviour kselftest/arm64: tpidr2: Adjust to new clone() behaviour kselftest/arm64: fp-ptrace: Fix expected FPMR value when PSTATE.SM is changed
2 parents 3b9552c + b225219 commit f92f17a

File tree

3 files changed

+40
-38
lines changed

3 files changed

+40
-38
lines changed

tools/testing/selftests/arm64/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ CFLAGS += $(KHDR_INCLUDES)
2121

2222
CFLAGS += -I$(top_srcdir)/tools/include
2323

24+
OUTPUT ?= $(CURDIR)
25+
2426
export CFLAGS
2527
export top_srcdir
2628

tools/testing/selftests/arm64/abi/tpidr2.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ static int sys_clone(unsigned long clone_flags, unsigned long newsp,
169169
child_tidptr);
170170
}
171171

172+
#define __STACK_SIZE (8 * 1024 * 1024)
173+
172174
/*
173-
* If we clone with CLONE_SETTLS then the value in the parent should
175+
* If we clone with CLONE_VM then the value in the parent should
174176
* be unchanged and the child should start with zero and be able to
175177
* set its own value.
176178
*/
@@ -179,11 +181,19 @@ static int write_clone_read(void)
179181
int parent_tid, child_tid;
180182
pid_t parent, waiting;
181183
int ret, status;
184+
void *stack;
182185

183186
parent = getpid();
184187
set_tpidr2(parent);
185188

186-
ret = sys_clone(CLONE_SETTLS, 0, &parent_tid, 0, &child_tid);
189+
stack = malloc(__STACK_SIZE);
190+
if (!stack) {
191+
putstr("# malloc() failed\n");
192+
return 0;
193+
}
194+
195+
ret = sys_clone(CLONE_VM, (unsigned long)stack + __STACK_SIZE,
196+
&parent_tid, 0, &child_tid);
187197
if (ret == -1) {
188198
putstr("# clone() failed\n");
189199
putnum(errno);

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

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,17 @@ static bool check_ptrace_values_sve(pid_t child, struct test_config *config)
439439
pass = false;
440440
}
441441

442-
if (sve->size != SVE_PT_SIZE(vq, sve->flags)) {
443-
ksft_print_msg("Mismatch in SVE header size: %d != %lu\n",
444-
sve->size, SVE_PT_SIZE(vq, sve->flags));
445-
pass = false;
442+
if (svcr_in & SVCR_SM) {
443+
if (sve->size != sizeof(sve)) {
444+
ksft_print_msg("NT_ARM_SVE reports data with PSTATE.SM\n");
445+
pass = false;
446+
}
447+
} else {
448+
if (sve->size != SVE_PT_SIZE(vq, sve->flags)) {
449+
ksft_print_msg("Mismatch in SVE header size: %d != %lu\n",
450+
sve->size, SVE_PT_SIZE(vq, sve->flags));
451+
pass = false;
452+
}
446453
}
447454

448455
/* The registers might be in completely different formats! */
@@ -515,10 +522,17 @@ static bool check_ptrace_values_ssve(pid_t child, struct test_config *config)
515522
pass = false;
516523
}
517524

518-
if (sve->size != SVE_PT_SIZE(vq, sve->flags)) {
519-
ksft_print_msg("Mismatch in SSVE header size: %d != %lu\n",
520-
sve->size, SVE_PT_SIZE(vq, sve->flags));
521-
pass = false;
525+
if (!(svcr_in & SVCR_SM)) {
526+
if (sve->size != sizeof(sve)) {
527+
ksft_print_msg("NT_ARM_SSVE reports data without PSTATE.SM\n");
528+
pass = false;
529+
}
530+
} else {
531+
if (sve->size != SVE_PT_SIZE(vq, sve->flags)) {
532+
ksft_print_msg("Mismatch in SSVE header size: %d != %lu\n",
533+
sve->size, SVE_PT_SIZE(vq, sve->flags));
534+
pass = false;
535+
}
522536
}
523537

524538
/* The registers might be in completely different formats! */
@@ -891,18 +905,11 @@ static void set_initial_values(struct test_config *config)
891905
{
892906
int vq = __sve_vq_from_vl(vl_in(config));
893907
int sme_vq = __sve_vq_from_vl(config->sme_vl_in);
894-
bool sm_change;
895908

896909
svcr_in = config->svcr_in;
897910
svcr_expected = config->svcr_expected;
898911
svcr_out = 0;
899912

900-
if (sme_supported() &&
901-
(svcr_in & SVCR_SM) != (svcr_expected & SVCR_SM))
902-
sm_change = true;
903-
else
904-
sm_change = false;
905-
906913
fill_random(&v_in, sizeof(v_in));
907914
memcpy(v_expected, v_in, sizeof(v_in));
908915
memset(v_out, 0, sizeof(v_out));
@@ -953,12 +960,7 @@ static void set_initial_values(struct test_config *config)
953960
if (fpmr_supported()) {
954961
fill_random(&fpmr_in, sizeof(fpmr_in));
955962
fpmr_in &= FPMR_SAFE_BITS;
956-
957-
/* Entering or exiting streaming mode clears FPMR */
958-
if (sm_change)
959-
fpmr_expected = 0;
960-
else
961-
fpmr_expected = fpmr_in;
963+
fpmr_expected = fpmr_in;
962964
} else {
963965
fpmr_in = 0;
964966
fpmr_expected = 0;
@@ -1195,18 +1197,8 @@ static void sve_write(pid_t child, struct test_config *config)
11951197

11961198
static bool za_write_supported(struct test_config *config)
11971199
{
1198-
if (config->sme_vl_in != config->sme_vl_expected) {
1199-
/* Changing the SME VL exits streaming mode. */
1200-
if (config->svcr_expected & SVCR_SM) {
1201-
return false;
1202-
}
1203-
} else {
1204-
/* Otherwise we can't change streaming mode */
1205-
if ((config->svcr_in & SVCR_SM) !=
1206-
(config->svcr_expected & SVCR_SM)) {
1207-
return false;
1208-
}
1209-
}
1200+
if ((config->svcr_in & SVCR_SM) != (config->svcr_expected & SVCR_SM))
1201+
return false;
12101202

12111203
return true;
12121204
}
@@ -1224,10 +1216,8 @@ static void za_write_expected(struct test_config *config)
12241216
memset(zt_expected, 0, sizeof(zt_expected));
12251217
}
12261218

1227-
/* Changing the SME VL flushes ZT, SVE state and exits SM */
1219+
/* Changing the SME VL flushes ZT, SVE state */
12281220
if (config->sme_vl_in != config->sme_vl_expected) {
1229-
svcr_expected &= ~SVCR_SM;
1230-
12311221
sve_vq = __sve_vq_from_vl(vl_expected(config));
12321222
memset(z_expected, 0, __SVE_ZREGS_SIZE(sve_vq));
12331223
memset(p_expected, 0, __SVE_PREGS_SIZE(sve_vq));

0 commit comments

Comments
 (0)