Skip to content

Commit be45e63

Browse files
mrutland-armwilldeacon
authored andcommitted
kselftest/arm64: tpidr2: Adjust to new clone() behaviour
In order to fix an ABI problem, we recently changed the way that a clone() syscall manipulates TPIDR2 and PSTATE.ZA. Historically the child would inherit the parent's TPIDR2 value unless CLONE_SETTLS was set, and now the child will inherit the parent's TPIDR2 value unless CLONE_VM is set. Update the tpidr2 test for the new behaviour. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Daniel Kiss <daniel.kiss@arm.com> Cc: Marc Zyngier <maz@kernel.org> Cc: Mark Brown <broonie@kernel.org> Cc: Richard Sandiford <richard.sandiford@arm.com> Cc: Sander De Smalen <sander.desmalen@arm.com> Cc: Tamas Petz <tamas.petz@arm.com> Cc: Will Deacon <will@kernel.org> Cc: Yury Khrustalev <yury.khrustalev@arm.com> Link: https://lore.kernel.org/r/20250508132644.1395904-23-mark.rutland@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent 78b2387 commit be45e63

File tree

1 file changed

+12
-2
lines changed
  • tools/testing/selftests/arm64/abi

1 file changed

+12
-2
lines changed

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);

0 commit comments

Comments
 (0)