public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ARC: align child stack in clone
@ 2022-12-21 16:19 Pavel.Kozlov
  2023-01-16 14:08 ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel.Kozlov @ 2022-12-21 16:19 UTC (permalink / raw)
  To: libc-alpha; +Cc: linux-snps-arc, Pavel Kozlov

From: Pavel Kozlov <pavel.kozlov@synopsys.com>

The ARCv2 ABI requires 4 byte stack pointer alignment. Don't allow to
use unaligned child stack in clone. As the stack grows down,
align it down.

This was pointed by misc/tst-misalign-clone-internal and
misc/tst-misalign-clone tests. Stack alignmet fixes these tests
fails.
---
 sysdeps/unix/sysv/linux/arc/clone.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sysdeps/unix/sysv/linux/arc/clone.S b/sysdeps/unix/sysv/linux/arc/clone.S
index bd924890844a..f32c83f17a65 100644
--- a/sysdeps/unix/sysv/linux/arc/clone.S
+++ b/sysdeps/unix/sysv/linux/arc/clone.S
@@ -41,6 +41,7 @@
 
 ENTRY (__clone)
 	cmp	r0, 0		/* @fn can't be NULL.  */
+	and	r1,r1,-4	/* @child_stack be 4 bytes aligned per ABI.  */
 	cmp.ne	r1, 0		/* @child_stack can't be NULL.  */
 	bz	L (__sys_err)
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARC: align child stack in clone
  2022-12-21 16:19 [PATCH] ARC: align child stack in clone Pavel.Kozlov
@ 2023-01-16 14:08 ` Adhemerval Zanella Netto
  2023-01-25 15:53   ` Pavel Kozlov
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella Netto @ 2023-01-16 14:08 UTC (permalink / raw)
  To: Pavel.Kozlov, libc-alpha; +Cc: linux-snps-arc



On 21/12/22 13:19, Pavel.Kozlov--- via Libc-alpha wrote:
> From: Pavel Kozlov <pavel.kozlov@synopsys.com>
> 
> The ARCv2 ABI requires 4 byte stack pointer alignment. Don't allow to
> use unaligned child stack in clone. As the stack grows down,
> align it down.
> 
> This was pointed by misc/tst-misalign-clone-internal and
> misc/tst-misalign-clone tests. Stack alignmet fixes these tests
> fails.

LGTM, although I can't really test it since the Synopsys qemu tree does not
have qemu-user support [1].

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

[1] https://github.com/foss-for-synopsys-dwc-arc-processors/qemu

> ---
>  sysdeps/unix/sysv/linux/arc/clone.S | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S b/sysdeps/unix/sysv/linux/arc/clone.S
> index bd924890844a..f32c83f17a65 100644
> --- a/sysdeps/unix/sysv/linux/arc/clone.S
> +++ b/sysdeps/unix/sysv/linux/arc/clone.S
> @@ -41,6 +41,7 @@
>  
>  ENTRY (__clone)
>  	cmp	r0, 0		/* @fn can't be NULL.  */
> +	and	r1,r1,-4	/* @child_stack be 4 bytes aligned per ABI.  */
>  	cmp.ne	r1, 0		/* @child_stack can't be NULL.  */
>  	bz	L (__sys_err)
>  

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARC: align child stack in clone
  2023-01-16 14:08 ` Adhemerval Zanella Netto
@ 2023-01-25 15:53   ` Pavel Kozlov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Kozlov @ 2023-01-25 15:53 UTC (permalink / raw)
  To: Adhemerval Zanella Netto, libc-alpha; +Cc: linux-snps-arc

> LGTM, although I can't really test it since the Synopsys qemu tree does not
> have qemu-user support [1].

Thank you for the review. I've checked this patch on QEMU with Linux system
and on the ARC HSDK board.
Also, I can say that it is possible to run ARC binaries on QEMU [1] in
user mode. Currently not all instructions are supported in ARC QEMU and it
is recommended to build binaries with extra -mcpu=archs compiler option,
to reduce instruction set. Maybe this [2] will be also useful.
It will be great to have this patch in coming 2.37.

[1]
https://github.com/foss-for-synopsys-dwc-arc-processors/qemu
[2]
https://github.com/foss-for-synopsys-dwc-arc-processors/glibc/wiki/Glibc-test-suite-for-a-target-without-native-GNU-toolchain#glibc-test-suite-execution-with-qemu-user-mode-emulation

--
Pavel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-25 15:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-21 16:19 [PATCH] ARC: align child stack in clone Pavel.Kozlov
2023-01-16 14:08 ` Adhemerval Zanella Netto
2023-01-25 15:53   ` Pavel Kozlov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).