[PATCH v5 0/6] Add support for LoongArch32

mengqinggang mengqinggang@loongson.cn
Mon Mar 2 09:36:47 GMT 2026


在 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?

> FAIL: nptl/test-mutexattr-printers
> FAIL: nptl/tst-pthread-gdb-attach
> FAIL: nptl/tst-pthread-gdb-attach-static
>                  === Summary of results ===
>        4 FAIL
>     6658 PASS
>       31 UNSUPPORTED
>       13 XFAIL
>        5 XPASS
>
> LA32R ilp32s abi:
> FAIL: iconv/tst-iconv_prog
> FAIL: math/test-fenv
> FAIL: misc/tst-pidfd
> FAIL: nptl/tst-cancel31
> FAIL: nptl/tst-pthread-gdb-attach
> FAIL: nptl/tst-pthread-gdb-attach-static
>                  === Summary of results ===
>        6 FAIL
>     6649 PASS
>       38 UNSUPPORTED
>       13 XFAIL
>        5 XPASS
>
> These patches are based on Jiajie Chen's previous work[1].
> A Chinese LA32R instruction set manual is here[2].
> There is currently no separate LA32 instruction set manual.
> The LA64 instruction set manual[3] specifies the instructions available in LA32.
> A LA32 linux system based on qemu user is here[4].
> A LA32 linux system based on qemu system is here[5].
>
> [1] https://github.com/jiegec/glibc/tree/loongarch32
> [2] https://www.loongson.cn/uploads/images/2025032109211238668.%E9%BE%99%E6%9E%B6%E6%9E%8432%E4%BD%8D%E7%B2%BE%E7%AE%80%E7%89%88%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C_r1p04.pdf
> [3] https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-Vol1-EN/basic-integer-instructions/overview-of-basic-integer-instructions.adoc
> [4] https://github.com/sunhaiyong1978/CLFS-for-LoongArch32/blob/main/Qemu_For_LoongArch32-Simple.md
> [5] https://github.com/sunhaiyong1978/CLFS-for-LoongArch32/blob/main/Qemu_System_For_LoongArch32-Simple.md
> [6] https://lore.kernel.org/loongarch/176559874944.2388135.2320307195215147125.pr-tracker-bot@kernel.org/T/#t
>
> v4 -> v5:
> - Set arch_minimum_kernel to 6.19.
> - Preprocessor indentation with one space.
> - Fix defined but not used for cbaud_to_speed.
> - Define the minimum arch for loongarch64.
>
> v3 -> v4:
> - Add sysdeps/loongarch/lp64/fpu Implies subfolder for LoongArch64 implementation.
> - Set ABI baseline GLIBC_2.43 only for LoongArch32.
> - Regenerate abilist files to GLIBC_2.43.
>
> v2 -> v3:
> - Delete extra configure checks in configure.ac.
> - Change GLIBC_2.36 to GLIBC_2.43 shlib-versions.
>
> v1 -> v2:
> - Update syscall list and update abi list.
> - Delete libm-test-ulps and libm-test-ulps-name.
> - Fix tst-gnu2-tls2: change 24 to 3 * SZREG, change uint64_t to int or long.
>    Do not check static float registers. Static float registers save and restore
>    follow the procedure call standard and dot not require tls desc resolver
>    function processing.
> - Change __NR_mmap2 to the previous __NR_mmap on lp64.
> - Change SZREG to 8 to m
>
>
> mengqinggang (6):
>    LoongArch: Add support for LA32 in sysdeps/loongarch
>    LoongArch: Add support for LA32 in sysdeps/loongarch/fpu
>    LoongArch: Add new file for LA32 in sysdeps/loongarch/ilp32
>    LoongArch: Add support for LA32 in sysdeps/unix/sysv/linux/loongarch
>    LoongArch: Add new files for LA32 in
>      sysdeps/unix/sysv/linux/loongarch/ilp32
>    Fix 'cbaud_to_speed' defined but not used on LA32
>
>   scripts/build-many-glibcs.py                  |   13 +-
>   sysdeps/loongarch/configure                   |   29 +-
>   sysdeps/loongarch/configure.ac                |   21 +-
>   sysdeps/loongarch/dl-machine.h                |   16 +-
>   sysdeps/loongarch/dl-tlsdesc-dynamic.h        |   37 +-
>   sysdeps/loongarch/dl-tlsdesc.S                |    6 +-
>   sysdeps/loongarch/dl-trampoline.h             |    4 +-
>   .../loongarch/fpu/math-use-builtins-llrint.h  |    2 +-
>   .../loongarch/fpu/math-use-builtins-logb.h    |    2 +-
>   .../loongarch/fpu/math-use-builtins-lrint.h   |    2 +-
>   .../loongarch/fpu/math-use-builtins-rint.h    |    2 +-
>   .../loongarch/fpu/math-use-builtins-sqrt.h    |   10 +-
>   sysdeps/loongarch/hp-timing.h                 |    9 +
>   sysdeps/loongarch/ilp32/Implies-after         |    1 +
>   sysdeps/loongarch/lp64/fpu/Implies            |    1 +
>   sysdeps/loongarch/{ => lp64}/fpu/e_scalb.c    |    0
>   sysdeps/loongarch/{ => lp64}/fpu/e_scalbf.c   |    0
>   sysdeps/loongarch/{ => lp64}/fpu/s_scalbn.c   |    0
>   sysdeps/loongarch/{ => lp64}/fpu/s_scalbnf.c  |    0
>   .../loongarch/{ => lp64}/fpu/w_ilogb-impl.h   |    0
>   .../loongarch/{ => lp64}/fpu/w_ilogbf-impl.h  |    0
>   sysdeps/loongarch/preconfigure                |    3 +-
>   sysdeps/loongarch/preconfigure.ac             |    3 +-
>   sysdeps/loongarch/sfp-machine.h               |   33 +
>   sysdeps/loongarch/start.S                     |   32 +-
>   sysdeps/loongarch/sys/asm.h                   |   93 +-
>   sysdeps/loongarch/tst-gnu2-tls2.h             |   50 +-
>   sysdeps/unix/sysv/linux/loongarch/Makefile    |    4 +-
>   sysdeps/unix/sysv/linux/loongarch/clone.S     |   10 +-
>   sysdeps/unix/sysv/linux/loongarch/clone3.S    |    8 +-
>   sysdeps/unix/sysv/linux/loongarch/configure   |   44 +
>   .../unix/sysv/linux/loongarch/configure.ac    |   12 +
>   .../unix/sysv/linux/loongarch/getcontext.S    |   12 +-
>   .../unix/sysv/linux/loongarch/gettimeofday.c  |    9 +-
>   .../unix/sysv/linux/loongarch/ilp32/Implies   |    2 +
>   .../sysv/linux/loongarch/ilp32/arch-syscall.h |  314 +++
>   .../sysv/linux/loongarch/ilp32/c++-types.data |   67 +
>   .../sysv/linux/loongarch/ilp32/ld.abilist     |    8 +
>   .../loongarch/ilp32/libBrokenLocale.abilist   |    1 +
>   .../sysv/linux/loongarch/ilp32/libc.abilist   | 2289 +++++++++++++++++
>   .../loongarch/ilp32/libc_malloc_debug.abilist |   28 +
>   .../sysv/linux/loongarch/ilp32/libm.abilist   | 1166 +++++++++
>   .../linux/loongarch/ilp32/libpthread.abilist  |    0
>   .../linux/loongarch/ilp32/libresolv.abilist   |   55 +
>   .../sysv/linux/loongarch/ilp32/librt.abilist  |    0
>   .../loongarch/ilp32/libthread_db.abilist      |   40 +
>   .../unix/sysv/linux/loongarch/ldd-rewrite.sed |    2 +-
>   .../linux/loongarch/{ => lp64}/arch-syscall.h |    0
>   .../unix/sysv/linux/loongarch/pointer_guard.h |   18 +-
>   .../unix/sysv/linux/loongarch/readelflib.c    |   33 +-
>   .../unix/sysv/linux/loongarch/setcontext.S    |   24 +-
>   .../unix/sysv/linux/loongarch/shlib-versions  |   10 +-
>   .../unix/sysv/linux/loongarch/swapcontext.S   |   28 +-
>   .../sysv/linux/loongarch/syscall_cancel.S     |    2 +-
>   sysdeps/unix/sysv/linux/loongarch/sysdep.S    |    8 +-
>   sysdeps/unix/sysv/linux/loongarch/sysdep.h    |   30 +-
>   .../sysv/linux/loongarch/ucontext-macros.h    |    6 +-
>   sysdeps/unix/sysv/linux/loongarch/vfork.S     |    6 +-
>   sysdeps/unix/sysv/linux/tst-termios-linux.c   |   24 +-
>   59 files changed, 4423 insertions(+), 206 deletions(-)
>   create mode 100644 sysdeps/loongarch/ilp32/Implies-after
>   create mode 100644 sysdeps/loongarch/lp64/fpu/Implies
>   rename sysdeps/loongarch/{ => lp64}/fpu/e_scalb.c (100%)
>   rename sysdeps/loongarch/{ => lp64}/fpu/e_scalbf.c (100%)
>   rename sysdeps/loongarch/{ => lp64}/fpu/s_scalbn.c (100%)
>   rename sysdeps/loongarch/{ => lp64}/fpu/s_scalbnf.c (100%)
>   rename sysdeps/loongarch/{ => lp64}/fpu/w_ilogb-impl.h (100%)
>   rename sysdeps/loongarch/{ => lp64}/fpu/w_ilogbf-impl.h (100%)
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/Implies
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/arch-syscall.h
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/c++-types.data
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/ld.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libBrokenLocale.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libc.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libc_malloc_debug.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libm.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libpthread.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libresolv.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/librt.abilist
>   create mode 100644 sysdeps/unix/sysv/linux/loongarch/ilp32/libthread_db.abilist
>   rename sysdeps/unix/sysv/linux/loongarch/{ => lp64}/arch-syscall.h (100%)
>



More information about the Libc-alpha mailing list