[PATCH v2] x32: Implement prctl in assembly
Florian Weimer
fweimer@redhat.com
Mon Dec 8 14:25:05 GMT 2025
* Adhemerval Zanella Netto:
> On 08/12/25 06:09, Florian Weimer wrote:
>> * H. J. Lu:
>>
>>> On Mon, Dec 8, 2025 at 4:11 PM Florian Weimer <fweimer@redhat.com> wrote:
>>>>
>>>> * H. J. Lu:
>>>>> 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.
>>>>
>>>> What's the advantage of the assembler implementation over the C
>>>> implementation? I'm missing the context for this change.
>>>>
>>>
>>> It is inspired by
>>>
>>> commit 6a04404521ac4119ae36827eeb288ea84eee7cf6
>>> Author: Florian Weimer <fweimer@redhat.com>
>>> Date: Sat Feb 17 09:17:04 2024 +0100
>>>
>>> Linux: Switch back to assembly syscall wrapper for prctl (bug 29770)
>>
>> The justification for that does not apply to x32, though, because prctl
>> doesn't take floating point arguments. I don't have a strong opinion,
>> the C and assembler versions are of similar complexity.
>
> The main justification is UB to va_args *all* the arguments without taking
> in the consideration which option is passed. If x32 requires additional
> argument handling to clear the upper 32-bits, there is no advantage of
> using the assembly wrapper.
I'm okay with making this change to avoid UB.
Patch looks okay to me.
Reviewed-by: Florian Weimer <fweimer@redhat.com>
Minor nit:
+weak_alias (__prctl, __prctl_time64)
+hidden_weak (__prctl_time64)
This isn't necessary because there is no __prctl_time64 on x32.
Thanks,
Florian
More information about the Libc-alpha
mailing list