[PATCH v2] x32: Implement prctl in assembly

H.J. Lu hjl.tools@gmail.com
Mon Dec 8 01:48:55 GMT 2025


On Sun, Dec 7, 2025 at 5:41 PM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > On Thu, Dec 4, 2025 at 10:06 PM Adhemerval Zanella Netto
> > <adhemerval.zanella@linaro.org> wrote:
> >>
> >> The x32 and or1k (which also uses similar implementation) does seems broken
> >> without checking the 'option' argument to see which arg we can va_arg.
> >>
> >> The problem is adding this logic on libc will add some forward-compatibility
> >> that we try to avoid (newer kernel prctl additions might now work correctly).
> >>
> >> I am not sure why we haven't switch x32 back to the assembly wrappers
> >> with 6a04404521ac4119ae36827eeb288ea84eee7cf6 fix (BZ#29770).  H.J, can
> >> use remove the x32 C version (and also or1k as well)?
> >
> > Since the variadic prctl function takes at most 5 integer arguments which
> > are passed in the same integer registers on x32 as the function with 5
> > integer arguments, we can safely use assembly syscall wrapper for prctl
> > for x32.
>
> The C implementation clears the upper 32 bits of registers.  Does the
> assembler wrapper do the same?
>

Here is the v2 patch to implement prctl in assembly for x32.

Since the variadic prctl function takes at most 5 integer arguments which
are passed in the same integer registers on x32 as the function with 5
integer arguments, we can use assembly for prctl.  Since upper 32-bits in
the last 4 arguments of prctl must be cleared to match the x32 prctl
syscall interface where the last 4 arguments are unsigned 64 bit longs,
implement prctl in assembly to clear upper 32-bits in the last 4 arguments
and add a test to verify it.


-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-x32-Implement-prctl-in-assembly.patch
Type: text/x-patch
Size: 5782 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20251208/fcaaec46/attachment-0001.bin>


More information about the Libc-alpha mailing list