public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] nptl: Unconditionally use a 32-byte rseq area
@ 2023-07-20 10:39 Florian Weimer
  2023-07-20 10:40 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2023-07-20 10:39 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mathieu Desnoyers

If the kernel headers provide a larger struct rseq, we used that
size as the argument to the rseq system call.  As a result,
rseq registration would fail on older kernels which only accept
size 32.

Tested on x86_64-linux-gnu.  Built with build-many-glibcs.py.
This needs to be backported all the way to glibc 2.35.

---
 nptl/descr.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/nptl/descr.h b/nptl/descr.h
index d06abd6ad9..abc9282ef7 100644
--- a/nptl/descr.h
+++ b/nptl/descr.h
@@ -405,8 +405,19 @@ struct pthread
   /* Used on strsignal.  */
   struct tls_internal_t tls_state;
 
-  /* rseq area registered with the kernel.  */
-  struct rseq rseq_area;
+  /* rseq area registered with the kernel.  Use a custom definition
+     here to isolate from kernel struct rseq changes.  The
+     implementation of sched_getcpu needs acccess to the cpu_id field;
+     the other fields are unused and not included here.  */
+  union
+  {
+    struct
+    {
+      uint32_t cpu_id_start;
+      uint32_t cpu_id;
+    };
+    char pad[32];		/* Original rseq area size.  */
+  } rseq_area __attribute__ ((aligned (32)));
 
   /* Amount of end padding, if any, in this structure.
      This definition relies on rseq_area being last.  */

base-commit: 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62


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

* Re: [PATCH] nptl: Unconditionally use a 32-byte rseq area
  2023-07-20 10:39 [PATCH] nptl: Unconditionally use a 32-byte rseq area Florian Weimer
@ 2023-07-20 10:40 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2023-07-20 10:40 UTC (permalink / raw)
  To: libc-alpha; +Cc: Mathieu Desnoyers

* Florian Weimer:

> If the kernel headers provide a larger struct rseq, we used that
> size as the argument to the rseq system call.  As a result,
> rseq registration would fail on older kernels which only accept
> size 32.
>
> Tested on x86_64-linux-gnu.  Built with build-many-glibcs.py.
> This needs to be backported all the way to glibc 2.35.
>
> ---
>  nptl/descr.h | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/nptl/descr.h b/nptl/descr.h
> index d06abd6ad9..abc9282ef7 100644
> --- a/nptl/descr.h
> +++ b/nptl/descr.h
> @@ -405,8 +405,19 @@ struct pthread
>    /* Used on strsignal.  */
>    struct tls_internal_t tls_state;
>  
> -  /* rseq area registered with the kernel.  */
> -  struct rseq rseq_area;
> +  /* rseq area registered with the kernel.  Use a custom definition
> +     here to isolate from kernel struct rseq changes.  The
> +     implementation of sched_getcpu needs acccess to the cpu_id field;
> +     the other fields are unused and not included here.  */
> +  union
> +  {
> +    struct
> +    {
> +      uint32_t cpu_id_start;
> +      uint32_t cpu_id;
> +    };
> +    char pad[32];		/* Original rseq area size.  */
> +  } rseq_area __attribute__ ((aligned (32)));
>  
>    /* Amount of end padding, if any, in this structure.
>       This definition relies on rseq_area being last.  */
>
> base-commit: 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62

Meh, disregard that, the patch is buggy.

Thanks,
Florian


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

end of thread, other threads:[~2023-07-20 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-20 10:39 [PATCH] nptl: Unconditionally use a 32-byte rseq area Florian Weimer
2023-07-20 10:40 ` Florian Weimer

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