* [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode.
@ 2017-08-15 18:09 Steve Ellcey
2017-08-16 8:03 ` Andreas Schwab
0 siblings, 1 reply; 5+ messages in thread
From: Steve Ellcey @ 2017-08-15 18:09 UTC (permalink / raw)
To: libc-alpha
This is an additional patch for ILP32 aarch64 support, it fixes a failure
with the tst-makecontext3 test in ILP32 mode.  That ABI has not
been checked in yet but I wanted to submit this patch in order to share
it and see if there is any feedback.  The basic problem is that makecontext
was using 'long int *' as the sp pointer type and that is 32 bytes in
ILP32 mode instead of 64 bytes.  By using uint64_t instead we get 64
bytes for both ILP32 and LP64 modes and the makecontext test works in both
modes and there are no regressions.
Steve Ellcey
sellcey@cavium.com
2017-08-15  Steve Ellcey  <sellcey@cavium.com>
* sysdeps/unix/sysv/linux/aarch64/makecontext.c (__makecontext):
Use pointer to uint64_t instead of long int for sp.
diff --git a/sysdeps/unix/sysv/linux/aarch64/makecontext.c b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
index f510f48..8e52b5d 100644
--- a/sysdeps/unix/sysv/linux/aarch64/makecontext.c
+++ b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
@@ -42,18 +42,18 @@ void
 __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
 {
   extern void __startcontext (void);
-Â Â unsigned long int *sp;
+Â Â uint64_t *sp;
   va_list ap;
   int i;
Â
-Â Â sp = (unsigned long int *)
+Â Â sp = (uint64_t *)
     ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
Â
   /* Allocate stack arguments.  */
   sp -= argc < 8 ? 0 : argc - 8;
Â
   /* Keep the stack aligned.  */
-Â Â sp = (unsigned long int *) (((uintptr_t) sp) & -16L);
+Â Â sp = (uint64_t *) (((uintptr_t) sp) & -16L);
Â
   ucp->uc_mcontext.regs[19] = (uintptr_t) ucp->uc_link;
   ucp->uc_mcontext.sp = (uintptr_t) sp;
@@ -66,7 +66,7 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
     if (i < 8)
       ucp->uc_mcontext.regs[i] = va_arg (ap, unsigned long int);
     else
-Â Â Â Â Â Â sp[i - 8] = va_arg (ap, unsigned long int);
+Â Â Â Â Â Â sp[i - 8] = va_arg (ap, uint64_t);
Â
   va_end (ap);
 }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode.
2017-08-15 18:09 [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode Steve Ellcey
@ 2017-08-16 8:03 ` Andreas Schwab
2017-08-17 15:32 ` Steve Ellcey
0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schwab @ 2017-08-16 8:03 UTC (permalink / raw)
To: Steve Ellcey; +Cc: libc-alpha
On Aug 15 2017, Steve Ellcey <sellcey@cavium.com> wrote:
> diff --git a/sysdeps/unix/sysv/linux/aarch64/makecontext.c b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
> index f510f48..8e52b5d 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/makecontext.c
> +++ b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
> @@ -42,18 +42,18 @@ void
> Â __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
> Â {
> Â Â Â extern void __startcontext (void);
> -Â Â unsigned long int *sp;
> +Â Â uint64_t *sp;
> Â Â Â va_list ap;
> Â Â Â int i;
> Â
> -Â Â sp = (unsigned long int *)
> +Â Â sp = (uint64_t *)
> Â Â Â Â Â ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
> Â
>    /* Allocate stack arguments.  */
> Â Â Â sp -= argc < 8 ? 0 : argc - 8;
> Â
>    /* Keep the stack aligned.  */
> -Â Â sp = (unsigned long int *) (((uintptr_t) sp) & -16L);
> +Â Â sp = (uint64_t *) (((uintptr_t) sp) & -16L);
> Â
> Â Â Â ucp->uc_mcontext.regs[19] = (uintptr_t) ucp->uc_link;
> Â Â Â ucp->uc_mcontext.sp = (uintptr_t) sp;
> @@ -66,7 +66,7 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
> Â Â Â Â Â if (i < 8)
> Â Â Â Â Â Â Â ucp->uc_mcontext.regs[i] = va_arg (ap, unsigned long int);
I think you want to use uint64_t here as well.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode.
2017-08-16 8:03 ` Andreas Schwab
@ 2017-08-17 15:32 ` Steve Ellcey
2017-08-30 16:17 ` Steve Ellcey
0 siblings, 1 reply; 5+ messages in thread
From: Steve Ellcey @ 2017-08-17 15:32 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
On Wed, 2017-08-16 at 10:01 +0200, Andreas Schwab wrote:
> On Aug 15 2017, Steve Ellcey <sellcey@cavium.com> wrote:
>Â
> > @@ -66,7 +66,7 @@ __makecontext (ucontext_t *ucp, void (*func)
> > (void), int argc, ...)
> > Â Â Â Â Â if (i < 8)
> > Â Â Â Â Â Â Â ucp->uc_mcontext.regs[i] = va_arg (ap, unsigned long int);
> I think you want to use uint64_t here as well.
>
> Andreas.
I agree, I will make that change.
Steve Ellcey
sellcey@cavium.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode.
2017-08-17 15:32 ` Steve Ellcey
@ 2017-08-30 16:17 ` Steve Ellcey
2017-08-30 16:18 ` Szabolcs Nagy
0 siblings, 1 reply; 5+ messages in thread
From: Steve Ellcey @ 2017-08-30 16:17 UTC (permalink / raw)
To: Andreas Schwab; +Cc: libc-alpha
[-- Attachment #1: Type: text/plain, Size: 970 bytes --]
On Thu, 2017-08-17 at 08:32 -0700, Steve Ellcey wrote:
> On Wed, 2017-08-16 at 10:01 +0200, Andreas Schwab wrote:
> >
> > On Aug 15 2017, Steve Ellcey <sellcey@cavium.com> wrote:
> > Â
> > >
> > > @@ -66,7 +66,7 @@ __makecontext (ucontext_t *ucp, void (*func)
> > > (void), int argc, ...)
> > > Â Â Â Â Â if (i < 8)
> > > Â Â Â Â Â Â Â ucp->uc_mcontext.regs[i] = va_arg (ap, unsigned long int);
> > I think you want to use uint64_t here as well.
> >
> > Andreas.
> I agree, I will make that change.
>
> Steve Ellcey
> sellcey@cavium.com
Here is an updated patch. Â Is this OK to check in now? Â It is only
needed for ILP32 aarch64 but it is a correct standalone change and it
would be nice to have it in the mainline.
Steve Ellcey
sellcey@cavium.com
2017-08-30  Steve Ellcey  <sellcey@cavium.com>
* sysdeps/unix/sysv/linux/aarch64/makecontext.c (__makecontext):
Use pointer to uint64_t instead of long int for sp.
[-- Attachment #2: aarch64-ilp32-makecontext.patch --]
[-- Type: text/x-patch, Size: 1277 bytes --]
diff --git a/sysdeps/unix/sysv/linux/aarch64/makecontext.c b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
index f510f48..20057f8 100644
--- a/sysdeps/unix/sysv/linux/aarch64/makecontext.c
+++ b/sysdeps/unix/sysv/linux/aarch64/makecontext.c
@@ -42,18 +42,18 @@ void
__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
{
extern void __startcontext (void);
- unsigned long int *sp;
+ uint64_t *sp;
va_list ap;
int i;
- sp = (unsigned long int *)
+ sp = (uint64_t *)
((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
/* Allocate stack arguments. */
sp -= argc < 8 ? 0 : argc - 8;
/* Keep the stack aligned. */
- sp = (unsigned long int *) (((uintptr_t) sp) & -16L);
+ sp = (uint64_t *) (((uintptr_t) sp) & -16L);
ucp->uc_mcontext.regs[19] = (uintptr_t) ucp->uc_link;
ucp->uc_mcontext.sp = (uintptr_t) sp;
@@ -64,9 +64,9 @@ __makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...)
va_start (ap, argc);
for (i = 0; i < argc; ++i)
if (i < 8)
- ucp->uc_mcontext.regs[i] = va_arg (ap, unsigned long int);
+ ucp->uc_mcontext.regs[i] = va_arg (ap, uint64_t);
else
- sp[i - 8] = va_arg (ap, unsigned long int);
+ sp[i - 8] = va_arg (ap, uint64_t);
va_end (ap);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode.
2017-08-30 16:17 ` Steve Ellcey
@ 2017-08-30 16:18 ` Szabolcs Nagy
0 siblings, 0 replies; 5+ messages in thread
From: Szabolcs Nagy @ 2017-08-30 16:18 UTC (permalink / raw)
To: sellcey, Andreas Schwab; +Cc: nd, libc-alpha
On 30/08/17 17:16, Steve Ellcey wrote:
> Here is an updated patch. Is this OK to check in now? It is only
> needed for ILP32 aarch64 but it is a correct standalone change and it
> would be nice to have it in the mainline.
>
> Steve Ellcey
> sellcey@cavium.com
>
>
> 2017-08-30 Steve Ellcey <sellcey@cavium.com>
>
> * sysdeps/unix/sysv/linux/aarch64/makecontext.c (__makecontext):
> Use pointer to uint64_t instead of long int for sp.
>
OK.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-30 16:18 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-15 18:09 [Patch] aarch64: Fix tst-makecontext3 in ILP32 mode Steve Ellcey
2017-08-16 8:03 ` Andreas Schwab
2017-08-17 15:32 ` Steve Ellcey
2017-08-30 16:17 ` Steve Ellcey
2017-08-30 16:18 ` Szabolcs Nagy
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).