public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: "Andreas K. Huettel" <dilfridge@gentoo.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH v2] nptl: Unconditionally use a 32-byte rseq area
Date: Fri, 21 Jul 2023 16:01:51 +0200	[thread overview]
Message-ID: <874jlxtlbk.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <0207c3ef-9041-c57c-557f-52119b9461f4@efficios.com> (Mathieu Desnoyers's message of "Thu, 20 Jul 2023 08:44:02 -0400")

* Mathieu Desnoyers:

> On 7/20/23 07:46, Florian Weimer wrote:
>> 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.
>
> Yes, this change appears to be needed considering the way the upstream
> kernel uapi has evolved.

Andreas, is it okay to push this from an RM perspective?

Thanks,
Florian

>> Tested on x86_64-linux-gnu.  Built with build-many-glibcs.py.
>> This needs to be backported all the way to glibc 2.35.
>> ---
>> v2: Drop further struct rseq reference on ia64.  Remove #include <sys/rseq.h>.
>>   nptl/descr.h | 18 ++++++++++++++----
>>   1 file changed, 14 insertions(+), 4 deletions(-)
>> diff --git a/nptl/descr.h b/nptl/descr.h
>> index d06abd6ad9..0171576c23 100644
>> --- a/nptl/descr.h
>> +++ b/nptl/descr.h
>> @@ -34,7 +34,6 @@
>>   #include <bits/types/res_state.h>
>>   #include <kernel-features.h>
>>   #include <tls-internal-struct.h>
>> -#include <sys/rseq.h>
>>   #include <internal-sigset.h>
>>     #ifndef TCB_ALIGNMENT
>> @@ -405,14 +404,25 @@ 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.  */
>>   #define PTHREAD_STRUCT_END_PADDING \
>>     (sizeof (struct pthread) - offsetof (struct pthread, rseq_area) \
>> -   + sizeof (struct rseq))
>> +   + sizeof ((struct pthread) {}.rseq_area))
>>   } __attribute ((aligned (TCB_ALIGNMENT)));
>>     static inline bool
>> base-commit: 3edc4ff2ceff4a59587ebecb94148d3bcfa1df62
>> 


  reply	other threads:[~2023-07-21 14:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-20 11:46 Florian Weimer
2023-07-20 12:44 ` Mathieu Desnoyers
2023-07-21 14:01   ` Florian Weimer [this message]
2023-07-21 14:14     ` Andreas K. Huettel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874jlxtlbk.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=dilfridge@gentoo.org \
    --cc=libc-alpha@sourceware.org \
    --cc=mathieu.desnoyers@efficios.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).