[PATCH v5 0/6] Add support for LoongArch32

mengqinggang mengqinggang@loongson.cn
Tue Mar 3 03:44:30 GMT 2026


在 2026/3/2 22:27, Adhemerval Zanella Netto 写道:
>
> On 02/03/26 06:36, mengqinggang wrote:
>> 在 2026/3/2 16:05, mengqinggang 写道:
>>> Add support for LoongArch32(LA32) with ilp32d abi and
>>> LoongArch32 Reduced(LA32R) with ilp32s abi.
>>>
>>> The gcc and binutils master branch have added LA32 support.
>>>
>>> The kernel has added basic LA32 support[6]. But build infrastructures
>>> of LoongArch32 are not enabled yet, because we need to adjust
>>> irqchip drivers and wait for GNU toolchain be upstream first.
>>>
>>> You can build toolchains by script/build-many-glibcs.py:
>>> LA32 ilp32d abi:
>>> build-many-glibcs.py -j128 --keep all . compilers loongarch32-linux-gnu
>>> LA32R ilp32s abi:
>>> build-many-glibcs.py -j128 --keep all . compilers loongarch32-linux-gnusf
>>>
>>> LA32 tested by qemu-user and qemu-system.
>>> Most testcases passed on LA32.
>>> Tested on LA64 with no regression.
>>>
>>> LA32 ilp32d abi:
>>> FAIL: misc/tst-pidfd
>>
>> misc/tst-pidfd fail because pidfd_send_signal return -1 with errno E2BIG.
>> It may be cause by Linux kernel post_copy_siginfo_from_user funcion.
>>
>> 3508 static int post_copy_siginfo_from_user(kernel_siginfo_t *info,
>> 3509                                        const siginfo_t __user *from)
>> 3510 {
>> 3511         if (unlikely(!known_siginfo_layout(info->si_signo, info->si_code))) {
>> 3512                 char __user *expansion = si_expansion(from);
>> 3513                 char buf[SI_EXPANSION_SIZE];
>> 3514                 int i;
>> 3515                 /*
>> 3516                  * An unknown si_code might need more than
>> 3517                  * sizeof(struct kernel_siginfo) bytes.  Verify all of the
>> 3518                  * extra bytes are 0.  This guarantees copy_siginfo_to_user
>> 3519                  * will return this data to userspace exactly.
>> 3520                  */
>> 3521                 if (copy_from_user(&buf, expansion, SI_EXPANSION_SIZE))
>> 3522                         return -EFAULT;
>> 3523                 for (i = 0; i < SI_EXPANSION_SIZE; i++) {
>> 3524                         if (buf[i] != 0)
>> 3525                                 return -E2BIG;
>> 3526                 }
>> 3527         }
>> 3528         return 0;
>> 3529 }
>>
>> If init siginfo_t to 0, the test can pass.
>>
>> --- a/sysdeps/unix/sysv/linux/tst-pidfd.c
>> +++ b/sysdeps/unix/sysv/linux/tst-pidfd.c
>> @@ -210,13 +210,13 @@ do_test (void)
>>     /* Wait for second sigtimedwait.  */
>>     support_process_state_wait (pid, support_process_state_sleeping);
>>     {
>> -    siginfo_t info =
>> +    siginfo_t info = {0};
>>         {
>> -       .si_signo = SIGUSR2,
>> -       .si_errno = EAGAIN,
>> -       .si_code = -10,
>> -       .si_pid = ppid,
>> -       .si_uid = puid
>> +       info.si_signo = SIGUSR2;
>> +       info.si_errno = EAGAIN;
>> +       info.si_code = -10;
>> +       info.si_pid = ppid;
>> +       info.si_uid = puid;
>>         };
>>       TEST_COMPARE (pidfd_send_signal (pidfd, SIGUSR2, &info, 0), 0);
>>     }
>>
>> Should it be modified in this way?
> I have sent a similar patch during 2.43 release [1], and we did not have consensus
> if this the correct approach.
>
> [1] https://patchwork.sourceware.org/project/glibc/patch/20260120131337.2574254-1-adhemerval.zanella@linaro.org/


It is a simple method to pass the test when the compiler can't fully 
zero-filling the struct.
As Florian mentioned, this patch can show a exemplary usage of interfaces.




More information about the Libc-alpha mailing list