Thread (4 messages) flat view 4 messages, 2 authors, 2020-03-20

Re: [RFC PATCH glibc 4/8] glibc: Perform rseq(2) registration at C startup and thread creation (v15)

From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Date: 2020-03-20 14:47:15
Also in: lkml

----- On Mar 20, 2020, at 9:44 AM, Mathieu Desnoyers mathieu.desnoyers@efficios.com wrote:
[...]
Actually, here is an important clarification: the Linux kernel validates
the struct rseq alignment on registration:

       if (!IS_ALIGNED((unsigned long)rseq, __alignof__(*rseq)) ||
           rseq_len != sizeof(*rseq))
               return -EINVAL;

So removing the aligned attribute from struct rseq is actually an
ABI-breaking change, because it would be incompatible with older
kernels which perform the IS_ALIGNED check expecting at least at
32 bytes alignment.
So I plan to add the following to glibc's sys/rseq.h:

#include <sys/cdefs.h>

[...]

/* Ensure the compiler supports __attribute__ ((aligned)).  */
_Static_assert (__alignof__ (struct rseq_cs) >= 4 * sizeof(uint64_t),
                "alignment");
_Static_assert (__alignof__ (struct rseq) >= 4 * sizeof(uint64_t),
                "alignment");

/* Allocations of struct rseq and struct rseq_cs on the heap need to
   be aligned on 32 bytes. Therefore, use of malloc is discouraged
   because it does not guarantee alignment. posix_memalign should be
   used instead.  */

Does it help mitigating your concerns ?

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help