aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <[email protected]>2025-05-08 13:26:42 +0000
committerWill Deacon <[email protected]>2025-05-08 14:45:24 +0000
commitbe45e63f79ecfea8373f18f50330838d77553a6b (patch)
treefa53bb834ce304ff2f6f47e981b19e974f006f0c
parentkselftest/arm64: fp-ptrace: Fix expected FPMR value when PSTATE.SM is changed (diff)
downloadkernel-be45e63f79ecfea8373f18f50330838d77553a6b.tar.gz
kernel-be45e63f79ecfea8373f18f50330838d77553a6b.zip
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 <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Daniel Kiss <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Mark Brown <[email protected]> Cc: Richard Sandiford <[email protected]> Cc: Sander De Smalen <[email protected]> Cc: Tamas Petz <[email protected]> Cc: Will Deacon <[email protected]> Cc: Yury Khrustalev <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
-rw-r--r--tools/testing/selftests/arm64/abi/tpidr2.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/testing/selftests/arm64/abi/tpidr2.c b/tools/testing/selftests/arm64/abi/tpidr2.c
index 285c47dd42f6..eb19dcc37a75 100644
--- a/tools/testing/selftests/arm64/abi/tpidr2.c
+++ b/tools/testing/selftests/arm64/abi/tpidr2.c
@@ -169,8 +169,10 @@ static int sys_clone(unsigned long clone_flags, unsigned long newsp,
child_tidptr);
}
+#define __STACK_SIZE (8 * 1024 * 1024)
+
/*
- * If we clone with CLONE_SETTLS then the value in the parent should
+ * If we clone with CLONE_VM then the value in the parent should
* be unchanged and the child should start with zero and be able to
* set its own value.
*/
@@ -179,11 +181,19 @@ static int write_clone_read(void)
int parent_tid, child_tid;
pid_t parent, waiting;
int ret, status;
+ void *stack;
parent = getpid();
set_tpidr2(parent);
- ret = sys_clone(CLONE_SETTLS, 0, &parent_tid, 0, &child_tid);
+ stack = malloc(__STACK_SIZE);
+ if (!stack) {
+ putstr("# malloc() failed\n");
+ return 0;
+ }
+
+ ret = sys_clone(CLONE_VM, (unsigned long)stack + __STACK_SIZE,
+ &parent_tid, 0, &child_tid);
if (ret == -1) {
putstr("# clone() failed\n");
putnum(errno);