The pidfd_test fails on the ARM64 platform with the following error:
Bail out! pidfd_poll check for premature notification on child thread exec test: Failed
When exception-trace is enabled, the kernel logs the details:
#echo 1 > /proc/sys/debug/exception-trace #dmesg | tail -n 20 [48628.713023] pidfd_test[1082142]: unhandled exception: SP Alignment, ESR 0x000000009a000000, SP/PC alignment exception in pidfd_test[400000+4000] [48628.713049] CPU: 21 PID: 1082142 Comm: pidfd_test Kdump: loaded Tainted: G W E 6.6.71-3_rc1.al8.aarch64 #1 [48628.713051] Hardware name: AlibabaCloud AliServer-Xuanwu2.0AM-1UC1P-5B/AS1111MG1, BIOS 1.2.M1.AL.P.157.00 07/29/2023 [48628.713053] pstate: 60001800 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=-c) [48628.713055] pc : 0000000000402100 [48628.713056] lr : 0000ffff98288f9c [48628.713056] sp : 0000ffffde49daa8 [48628.713057] x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 [48628.713060] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [48628.713062] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400e80 [48628.713065] x20: 0000000000000000 x19: 0000000000402650 x18: 0000000000000000 [48628.713067] x17: 00000000004200d8 x16: 0000ffff98288f40 x15: 0000ffffde49b92c [48628.713070] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [48628.713072] x11: 0000000000001011 x10: 0000000000402100 x9 : 0000000000000010 [48628.713074] x8 : 00000000000000dc x7 : 3861616239346564 x6 : 000000000000000a [48628.713077] x5 : 0000ffffde49daa8 x4 : 000000000000000a x3 : 0000ffffde49daa8 [48628.713079] x2 : 0000ffffde49dadc x1 : 0000ffffde49daa8 x0 : 0000000000000000
According to ARM ARM D1.3.10.2 SP alignment checking:
When the SP is used as the base address of a calculation, regardless of any offset applied by the instruction, if bits [3:0] of the SP are not 0b0000, there is a misaligned SP.
To fix it, align the stack with 16 bytes.
Signed-off-by: Shuai Xue xueshuai@linux.alibaba.com --- tools/testing/selftests/pidfd/pidfd_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c index c081ae91313a..ec161a7c3ff9 100644 --- a/tools/testing/selftests/pidfd/pidfd_test.c +++ b/tools/testing/selftests/pidfd/pidfd_test.c @@ -33,7 +33,7 @@ static bool have_pidfd_send_signal; static pid_t pidfd_clone(int flags, int *pidfd, int (*fn)(void *)) { size_t stack_size = 1024; - char *stack[1024] = { 0 }; + char *stack[1024] __attribute__((aligned(16))) = {0};
#ifdef __ia64__ return __clone2(fn, stack, stack_size, flags | SIGCHLD, NULL, pidfd);
On 6/15/25 23:06, Shuai Xue wrote:
The pidfd_test fails on the ARM64 platform with the following error:
Bail out! pidfd_poll check for premature notification on child thread exec test: Failed
When exception-trace is enabled, the kernel logs the details:
#echo 1 > /proc/sys/debug/exception-trace #dmesg | tail -n 20 [48628.713023] pidfd_test[1082142]: unhandled exception: SP Alignment, ESR 0x000000009a000000, SP/PC alignment exception in pidfd_test[400000+4000] [48628.713049] CPU: 21 PID: 1082142 Comm: pidfd_test Kdump: loaded Tainted: G W E 6.6.71-3_rc1.al8.aarch64 #1 [48628.713051] Hardware name: AlibabaCloud AliServer-Xuanwu2.0AM-1UC1P-5B/AS1111MG1, BIOS 1.2.M1.AL.P.157.00 07/29/2023 [48628.713053] pstate: 60001800 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=-c) [48628.713055] pc : 0000000000402100 [48628.713056] lr : 0000ffff98288f9c [48628.713056] sp : 0000ffffde49daa8 [48628.713057] x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 [48628.713060] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [48628.713062] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400e80 [48628.713065] x20: 0000000000000000 x19: 0000000000402650 x18: 0000000000000000 [48628.713067] x17: 00000000004200d8 x16: 0000ffff98288f40 x15: 0000ffffde49b92c [48628.713070] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [48628.713072] x11: 0000000000001011 x10: 0000000000402100 x9 : 0000000000000010 [48628.713074] x8 : 00000000000000dc x7 : 3861616239346564 x6 : 000000000000000a [48628.713077] x5 : 0000ffffde49daa8 x4 : 000000000000000a x3 : 0000ffffde49daa8 [48628.713079] x2 : 0000ffffde49dadc x1 : 0000ffffde49daa8 x0 : 0000000000000000
According to ARM ARM D1.3.10.2 SP alignment checking:
When the SP is used as the base address of a calculation, regardless of any offset applied by the instruction, if bits [3:0] of the SP are not 0b0000, there is a misaligned SP.
To fix it, align the stack with 16 bytes.
Signed-off-by: Shuai Xue xueshuai@linux.alibaba.com
Assuming this is going through Christian's tree.
Acked-by: Shuah Khan skhan@linuxfoundation.org
Let me know if you would like me to pick it up.
thanks, -- Shuah
在 2025/6/19 05:36, Shuah Khan 写道:
On 6/15/25 23:06, Shuai Xue wrote:
The pidfd_test fails on the ARM64 platform with the following error:
Bail out! pidfd_poll check for premature notification on child thread exec test: Failed
When exception-trace is enabled, the kernel logs the details:
#echo 1 > /proc/sys/debug/exception-trace #dmesg | tail -n 20 [48628.713023] pidfd_test[1082142]: unhandled exception: SP Alignment, ESR 0x000000009a000000, SP/PC alignment exception in pidfd_test[400000+4000] [48628.713049] CPU: 21 PID: 1082142 Comm: pidfd_test Kdump: loaded Tainted: G W E 6.6.71-3_rc1.al8.aarch64 #1 [48628.713051] Hardware name: AlibabaCloud AliServer-Xuanwu2.0AM-1UC1P-5B/AS1111MG1, BIOS 1.2.M1.AL.P.157.00 07/29/2023 [48628.713053] pstate: 60001800 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=-c) [48628.713055] pc : 0000000000402100 [48628.713056] lr : 0000ffff98288f9c [48628.713056] sp : 0000ffffde49daa8 [48628.713057] x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 [48628.713060] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [48628.713062] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400e80 [48628.713065] x20: 0000000000000000 x19: 0000000000402650 x18: 0000000000000000 [48628.713067] x17: 00000000004200d8 x16: 0000ffff98288f40 x15: 0000ffffde49b92c [48628.713070] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [48628.713072] x11: 0000000000001011 x10: 0000000000402100 x9 : 0000000000000010 [48628.713074] x8 : 00000000000000dc x7 : 3861616239346564 x6 : 000000000000000a [48628.713077] x5 : 0000ffffde49daa8 x4 : 000000000000000a x3 : 0000ffffde49daa8 [48628.713079] x2 : 0000ffffde49dadc x1 : 0000ffffde49daa8 x0 : 0000000000000000
According to ARM ARM D1.3.10.2 SP alignment checking:
When the SP is used as the base address of a calculation, regardless of any offset applied by the instruction, if bits [3:0] of the SP are not 0b0000, there is a misaligned SP.
To fix it, align the stack with 16 bytes.
Signed-off-by: Shuai Xue xueshuai@linux.alibaba.com
Assuming this is going through Christian's tree.
Acked-by: Shuah Khan skhan@linuxfoundation.org
Let me know if you would like me to pick it up.
thanks, -- Shuah
Hi, Shuah
Thanks for your review.
I send this fix in Mar, but it missed last linux version. I think I need your help to pick it up.
Thanks. Shuai
在 2025/6/19 10:26, Shuai Xue 写道:
在 2025/6/19 05:36, Shuah Khan 写道:
On 6/15/25 23:06, Shuai Xue wrote:
The pidfd_test fails on the ARM64 platform with the following error:
Bail out! pidfd_poll check for premature notification on child thread exec test: Failed
When exception-trace is enabled, the kernel logs the details:
#echo 1 > /proc/sys/debug/exception-trace #dmesg | tail -n 20 [48628.713023] pidfd_test[1082142]: unhandled exception: SP Alignment, ESR 0x000000009a000000, SP/PC alignment exception in pidfd_test[400000+4000] [48628.713049] CPU: 21 PID: 1082142 Comm: pidfd_test Kdump: loaded Tainted: G W E 6.6.71-3_rc1.al8.aarch64 #1 [48628.713051] Hardware name: AlibabaCloud AliServer-Xuanwu2.0AM-1UC1P-5B/AS1111MG1, BIOS 1.2.M1.AL.P.157.00 07/29/2023 [48628.713053] pstate: 60001800 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=-c) [48628.713055] pc : 0000000000402100 [48628.713056] lr : 0000ffff98288f9c [48628.713056] sp : 0000ffffde49daa8 [48628.713057] x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 [48628.713060] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [48628.713062] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400e80 [48628.713065] x20: 0000000000000000 x19: 0000000000402650 x18: 0000000000000000 [48628.713067] x17: 00000000004200d8 x16: 0000ffff98288f40 x15: 0000ffffde49b92c [48628.713070] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [48628.713072] x11: 0000000000001011 x10: 0000000000402100 x9 : 0000000000000010 [48628.713074] x8 : 00000000000000dc x7 : 3861616239346564 x6 : 000000000000000a [48628.713077] x5 : 0000ffffde49daa8 x4 : 000000000000000a x3 : 0000ffffde49daa8 [48628.713079] x2 : 0000ffffde49dadc x1 : 0000ffffde49daa8 x0 : 0000000000000000
According to ARM ARM D1.3.10.2 SP alignment checking:
When the SP is used as the base address of a calculation, regardless of any offset applied by the instruction, if bits [3:0] of the SP are not 0b0000, there is a misaligned SP.
To fix it, align the stack with 16 bytes.
Signed-off-by: Shuai Xue xueshuai@linux.alibaba.com
Assuming this is going through Christian's tree.
Acked-by: Shuah Khan skhan@linuxfoundation.org
Let me know if you would like me to pick it up.
thanks, -- Shuah
Hi, Shuah
Thanks for your review.
I send this fix in Mar, but it missed last linux version. I think I need your help to pick it up.
Thanks. Shuai
Hi, Shuah,
Gentle ping,
Thanks. Shuai
On 7/16/25 01:00, Shuai Xue wrote:
在 2025/6/19 10:26, Shuai Xue 写道:
在 2025/6/19 05:36, Shuah Khan 写道:
On 6/15/25 23:06, Shuai Xue wrote:
The pidfd_test fails on the ARM64 platform with the following error:
Bail out! pidfd_poll check for premature notification on child thread exec test: Failed
When exception-trace is enabled, the kernel logs the details:
#echo 1 > /proc/sys/debug/exception-trace #dmesg | tail -n 20 [48628.713023] pidfd_test[1082142]: unhandled exception: SP Alignment, ESR 0x000000009a000000, SP/PC alignment exception in pidfd_test[400000+4000] [48628.713049] CPU: 21 PID: 1082142 Comm: pidfd_test Kdump: loaded Tainted: G W E 6.6.71-3_rc1.al8.aarch64 #1 [48628.713051] Hardware name: AlibabaCloud AliServer-Xuanwu2.0AM-1UC1P-5B/AS1111MG1, BIOS 1.2.M1.AL.P.157.00 07/29/2023 [48628.713053] pstate: 60001800 (nZCv daif -PAN -UAO -TCO -DIT +SSBS BTYPE=-c) [48628.713055] pc : 0000000000402100 [48628.713056] lr : 0000ffff98288f9c [48628.713056] sp : 0000ffffde49daa8 [48628.713057] x29: 0000000000000000 x28: 0000000000000000 x27: 0000000000000000 [48628.713060] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000 [48628.713062] x23: 0000000000000000 x22: 0000000000000000 x21: 0000000000400e80 [48628.713065] x20: 0000000000000000 x19: 0000000000402650 x18: 0000000000000000 [48628.713067] x17: 00000000004200d8 x16: 0000ffff98288f40 x15: 0000ffffde49b92c [48628.713070] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000 [48628.713072] x11: 0000000000001011 x10: 0000000000402100 x9 : 0000000000000010 [48628.713074] x8 : 00000000000000dc x7 : 3861616239346564 x6 : 000000000000000a [48628.713077] x5 : 0000ffffde49daa8 x4 : 000000000000000a x3 : 0000ffffde49daa8 [48628.713079] x2 : 0000ffffde49dadc x1 : 0000ffffde49daa8 x0 : 0000000000000000
According to ARM ARM D1.3.10.2 SP alignment checking:
When the SP is used as the base address of a calculation, regardless of any offset applied by the instruction, if bits [3:0] of the SP are not 0b0000, there is a misaligned SP.
To fix it, align the stack with 16 bytes.
Signed-off-by: Shuai Xue xueshuai@linux.alibaba.com
Assuming this is going through Christian's tree.
Acked-by: Shuah Khan skhan@linuxfoundation.org
Let me know if you would like me to pick it up.
thanks, -- Shuah
Hi, Shuah
Thanks for your review.
I send this fix in Mar, but it missed last linux version. I think I need your help to pick it up.
Thanks. Shuai
Hi, Shuah,
Gentle ping,
Thanks. Shuai
Will, Christian,
Can you take a look at this and let me know if this change looks good to you both.
I can take this through my tree after your reviews.
thanks, -- Shuah
On Fri, Jul 18, 2025 at 03:10:32PM -0600, Shuah Khan wrote:
Can you take a look at this and let me know if this change looks good to you both.
I can take this through my tree after your reviews.
I never got to the point of fully understanding how the test was supposed to work, but it is true that arm64 requires a 16-byte aligned stack pointer and this patch appears to achieve that.
Will
在 2025/7/21 22:24, Will Deacon 写道:
On Fri, Jul 18, 2025 at 03:10:32PM -0600, Shuah Khan wrote:
Can you take a look at this and let me know if this change looks good to you both.
I can take this through my tree after your reviews.
I never got to the point of fully understanding how the test was supposed to work, but it is true that arm64 requires a 16-byte aligned stack pointer and this patch appears to achieve that.
Will
Hi, Will,
In case you missed I reply in last version. I just paste the original reply, I hope it can help you understand the root cause.
From man page of clone():
The stack argument specifies the location of the stack used by the child process. Since the child and calling process may share memory, it is not possible for the child process to execute in the same stack as the calling process. *The calling process must therefore set up memory space for the child stack and pass a pointer to this space to clone()*. Stacks grow downward on all processors that run Linux (except the HP PA processors), so stack usually points to the topmost address of the memory space set up for the child stack. Note that clone() does not provide a means whereby the caller can inform the kernel of the size of the stack area.
The glibc will do the sanity check:
/* int clone(int (*fn)(void *arg), x0 void *child_stack, x1 int flags, x2 void *arg, x3 pid_t *ptid, x4 struct user_desc *tls, x5 pid_t *ctid); x6 */ .text ENTRY(__clone) PTR_ARG (0) PTR_ARG (1) PTR_ARG (3) PTR_ARG (4) PTR_ARG (5) PTR_ARG (6) /* Save args for the child. */ mov x10, x0 mov x11, x2 mov x12, x3
/* Sanity check args. */ mov x0, #-EINVAL cbz x10, .Lsyscall_error /* Align sp. */ and x1, x1, -16 cbz x1, .Lsyscall_error // this line
When the stack pointer is set to NULL, the aligned stack pointer remains zero, leading __clone to perform a syscall error, returning -EINVAL due to an invalid argument.
In summary, Whether or not CLONE_VM is used, an address-aligned child stack needs to be allocated.
Thanks. Shuai
linux-kselftest-mirror@lists.linaro.org