guix_mirror_bot pushed a commit to branch core-packages-team in repository guix.
commit f36fefe32e42a3d832a44c8339a0ed0f1d0dc7d8 Author: Yelninei <[email protected]> AuthorDate: Thu May 7 12:15:14 2026 +0000 gnu: glibc: Update to 2.43. * gnu/packages/base.scm (glibc): Update to 2.43. (%glibc-patches): Remove obsolete patches for the Hurd. Add glibc-2.43-hurd-unimplemented.patch. * gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch: Delete patch. * gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch: Delete patch. * gnu/packages/patches/glibc-hurd-2.41-symlink.patch: Delete patch. * gnu/packages/patches/glibc-hurd-signal-fpe-exception.patch: Delete patch. * gnu/packages/patches/glibc-hurd-xstate.patch: Delete patch. * gnu/local.mk (dist_patch_DATA): Remove deleted patches, add new patch. Change-Id: I0b2f5f821aac59e302b1d545eb3f2c7191dcc660 --- gnu/local.mk | 6 +- gnu/packages/base.scm | 10 +- .../glibc-2.43-hurd-unimplemented-ioctls.patch | 194 +++++ .../patches/glibc-hurd-2.41-pthread-once.patch | 185 ----- .../patches/glibc-hurd-2.41-pthread-sigmask.patch | 22 - gnu/packages/patches/glibc-hurd-2.41-symlink.patch | 32 - .../patches/glibc-hurd-signal-fpe-exception.patch | 67 -- gnu/packages/patches/glibc-hurd-xstate.patch | 813 --------------------- 8 files changed, 198 insertions(+), 1131 deletions(-) diff --git a/gnu/local.mk b/gnu/local.mk index 4f2863587ed..389925276b9 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -1502,6 +1502,7 @@ dist_patch_DATA = \ %D%/packages/patches/glibc-2.41-bootstrap-system.patch \ %D%/packages/patches/glibc-2.41-hurd-local-clock_gettime_MONOTONIC.patch \ %D%/packages/patches/glibc-2.41-ldd-x86_64.patch \ + %D%/packages/patches/glibc-2.43-hurd-unimplemented-ioctls.patch \ %D%/packages/patches/glibc-allow-kernel-2.6.32.patch \ %D%/packages/patches/glibc-boot-2.2.5.patch \ %D%/packages/patches/glibc-boot-2.16.0.patch \ @@ -1520,12 +1521,7 @@ dist_patch_DATA = \ %D%/packages/patches/glibc-hurd-gettyent.patch \ %D%/packages/patches/glibc-hurd-mach-print.patch \ %D%/packages/patches/glibc-hurd-pthread_setcancelstate.patch \ - %D%/packages/patches/glibc-hurd-signal-fpe-exception.patch \ %D%/packages/patches/glibc-hurd-signal-sa-siginfo.patch \ - %D%/packages/patches/glibc-hurd-2.41-pthread-once.patch \ - %D%/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch \ - %D%/packages/patches/glibc-hurd-2.41-symlink.patch \ - %D%/packages/patches/glibc-hurd-xstate.patch \ %D%/packages/patches/glibc-hurd64-gcc-14.2-tls-bug.patch \ %D%/packages/patches/glibc-ldd-powerpc.patch \ %D%/packages/patches/glibc-ldd-x86_64.patch \ diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 25b262e93f4..fa1bf634b36 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -919,15 +919,11 @@ the store.") "glibc-supported-locales.patch" "glibc-2.37-hurd-clock_t_centiseconds.patch" "glibc-2.41-hurd-local-clock_gettime_MONOTONIC.patch" + "glibc-2.43-hurd-unimplemented-ioctls.patch" "glibc-hurd-mach-print.patch" "glibc-hurd-gettyent.patch" "glibc-hurd-getauxval.patch" "glibc-hurd-pthread_setcancelstate.patch" - "glibc-hurd-signal-fpe-exception.patch" - "glibc-hurd-xstate.patch" - "glibc-hurd-2.41-pthread-once.patch" - "glibc-hurd-2.41-pthread-sigmask.patch" - "glibc-hurd-2.41-symlink.patch" "glibc-hurd64-gcc-14.2-tls-bug.patch")) (define-public glibc @@ -935,13 +931,13 @@ the store.") ;; version 2.28, GNU/Hurd used a different glibc branch. (package (name "glibc") - (version "2.41") + (version "2.43") (source (origin (method url-fetch) (uri (string-append "mirror://gnu/glibc/glibc-" version ".tar.xz")) (sha256 (base32 - "00g95047sshv0zxk9ja3mi7lzwi8wh8qx0nxngbvgmj5yli6p8m5")) + "0c9qzbaprh779ggvix9c8hcps5y59y2caw42w2il7nxxbmmnrj6r")) (patches (map search-patch %glibc-patches)))) (properties `((lint-hidden-cve . ("CVE-2024-2961" "CVE-2024-33601" "CVE-2024-33602" diff --git a/gnu/packages/patches/glibc-2.43-hurd-unimplemented-ioctls.patch b/gnu/packages/patches/glibc-2.43-hurd-unimplemented-ioctls.patch new file mode 100644 index 00000000000..33ad2240b53 --- /dev/null +++ b/gnu/packages/patches/glibc-2.43-hurd-unimplemented-ioctls.patch @@ -0,0 +1,194 @@ +Combination of these glibc commits + +b507b6d4c6 * Hurd: restore some SIOC ioctls +7073112263 * Hurd: comment ioctls which cannot currently compile +ec98b25af5 * Hurd: comment PF_ROUTE/AF_ROUTE defines +59a0de89ba * Hurd: comment PF_LINK/AF_LINK defines + +From 59a0de89ba28028f5ec3f32c1da648a0d6f1dfc5 Mon Sep 17 00:00:00 2001 +From: Pino Toscano <[email protected]> +Date: Tue, 26 May 2026 22:27:02 +0200 +Subject: [PATCH 1/4] Hurd: comment PF_LINK/AF_LINK defines + +Comment out the PF_LINK and AF_LINK defines, since they are usually associated +with struct sockaddr_dl, which is not available on Hurd. +--- + sysdeps/mach/hurd/bits/socket.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h +index 9b81d48816..4a5807e619 100644 +--- a/sysdeps/mach/hurd/bits/socket.h ++++ b/sysdeps/mach/hurd/bits/socket.h +@@ -96,7 +96,7 @@ enum __socket_type + #define PF_HYLINK 15 /* NSC Hyperchannel protocol. */ + #define PF_APPLETALK 16 /* Don't use this. */ + #define PF_ROUTE 17 /* Internal Routing Protocol. */ +-#define PF_LINK 18 /* Link layer interface. */ ++/* #define PF_LINK 18 Link layer interface. */ + #define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */ + #define PF_COIP 20 /* Connection-oriented IP, aka ST II. */ + #define PF_CNT 21 /* Computer Network Technology. */ +@@ -129,7 +129,7 @@ enum __socket_type + #define AF_HYLINK PF_HYLINK + #define AF_APPLETALK PF_APPLETALK + #define AF_ROUTE PF_ROUTE +-#define AF_LINK PF_LINK ++/* #define AF_LINK PF_LINK */ + #ifdef __USE_MISC + # define pseudo_AF_XTP PF_XTP + #endif +-- +2.54.0 + +From ec98b25af5ae4b6dff24388ce10d0e64a7671363 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault <[email protected]> +Date: Tue, 26 May 2026 22:28:49 +0200 +Subject: [PATCH 2/4] Hurd: comment PF_ROUTE/AF_ROUTE defines + +Comment out the PF_ROUTE and AF_ROUTE defines, since they would be used for +PF_ROUTE setsockopts, which are not available on Hurd. +--- + sysdeps/mach/hurd/bits/socket.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h +index 4a5807e619..fb73dea063 100644 +--- a/sysdeps/mach/hurd/bits/socket.h ++++ b/sysdeps/mach/hurd/bits/socket.h +@@ -95,7 +95,7 @@ enum __socket_type + #define PF_LAT 14 /* DEC Local Area Transport protocol. */ + #define PF_HYLINK 15 /* NSC Hyperchannel protocol. */ + #define PF_APPLETALK 16 /* Don't use this. */ +-#define PF_ROUTE 17 /* Internal Routing Protocol. */ ++/* #define PF_ROUTE 17 Internal Routing Protocol. */ + /* #define PF_LINK 18 Link layer interface. */ + #define PF_XTP 19 /* eXpress Transfer Protocol (no AF). */ + #define PF_COIP 20 /* Connection-oriented IP, aka ST II. */ +@@ -128,7 +128,7 @@ enum __socket_type + #define AF_LAT PF_LAT + #define AF_HYLINK PF_HYLINK + #define AF_APPLETALK PF_APPLETALK +-#define AF_ROUTE PF_ROUTE ++/* #define AF_ROUTE PF_ROUTE */ + /* #define AF_LINK PF_LINK */ + #ifdef __USE_MISC + # define pseudo_AF_XTP PF_XTP +-- +2.54.0 + +From 707311226345f87ce6a1536a7d7365ce34b236b3 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault <[email protected]> +Date: Tue, 26 May 2026 22:35:55 +0200 +Subject: [PATCH 3/4] Hurd: comment ioctls which cannot currently compile + +We don't currently have struct ifreq_short, ifreq_int and ifaliasreq, so +don't let applications even try to compile these. +--- + sysdeps/mach/hurd/bits/ioctls.h | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h +index 151761ef66..4588f813fb 100644 +--- a/sysdeps/mach/hurd/bits/ioctls.h ++++ b/sysdeps/mach/hurd/bits/ioctls.h +@@ -293,8 +293,8 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; + #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ + #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ + #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */ +-#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short)/* set ifnet flags */ +-#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short)/* get ifnet flags */ ++/* #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short) set ifnet flags */ ++/* #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short) get ifnet flags */ + #define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */ + #define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */ + #define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */ +@@ -303,21 +303,21 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; + #define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */ + #define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */ + #define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */ +-#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */ +-#define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */ ++/* #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) get IF metric */ ++/* #define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) set IF metric */ + #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */ +-#define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) /* add/chg IF alias */ ++/* #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) add/chg IF alias */ + + #define SIOCSARP _IOW('i', 30, struct arpreq) /* set arp entry */ + #define OSIOCGARP _IOWR('i',31, struct arpreq) /* get arp entry */ + #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */ + #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ + +-#define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */ +-#define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */ ++/* #define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int) get IF mtu */ ++/* #define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) set IF mtu */ + +-#define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int)/* get IF index */ +-#define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int)/* set IF name */ ++/* #define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int) get IF index */ ++/* #define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int) set IF name */ + + + /* Compatibility with 4.3 BSD terminal driver. +-- +2.54.0 + +From b507b6d4c6138bfa3d6ff04ff880dc626c1c3605 Mon Sep 17 00:00:00 2001 +From: Samuel Thibault <[email protected]> +Date: Tue, 26 May 2026 23:07:12 +0200 +Subject: [PATCH 4/4] Hurd: restore some SIOC ioctls + +We do not define struct ifreq_short and ifreq_int, but we do +define _IOT_ifreq_short and _IOT_ifreq_int, and need these for +sysdeps/gnu/ifaddrs.c and sysdeps/mach/hurd/if_index.c +--- + sysdeps/mach/hurd/bits/ioctls.h | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/sysdeps/mach/hurd/bits/ioctls.h b/sysdeps/mach/hurd/bits/ioctls.h +index 4588f813fb..162a815082 100644 +--- a/sysdeps/mach/hurd/bits/ioctls.h ++++ b/sysdeps/mach/hurd/bits/ioctls.h +@@ -293,8 +293,8 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; + #define SIOCSIFDSTADDR _IOW('i', 14, struct ifreq) /* set p-p address */ + #define OSIOCGIFDSTADDR _IOWR('i',15, struct ifreq) /* get p-p address */ + #define SIOCGIFDSTADDR _IOWR('i',34, struct ifreq) /* get p-p address */ +-/* #define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short) set ifnet flags */ +-/* #define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short) get ifnet flags */ ++#define SIOCSIFFLAGS _IOW('i', 16, struct ifreq_short)/* set ifnet flags */ ++#define SIOCGIFFLAGS _IOWR('i',17, struct ifreq_short)/* get ifnet flags */ + #define OSIOCGIFBRDADDR _IOWR('i',18, struct ifreq) /* get broadcast addr */ + #define SIOCGIFBRDADDR _IOWR('i',35, struct ifreq) /* get broadcast addr */ + #define SIOCSIFBRDADDR _IOW('i',19, struct ifreq) /* set broadcast addr */ +@@ -303,8 +303,8 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; + #define OSIOCGIFNETMASK _IOWR('i',21, struct ifreq) /* get net addr mask */ + #define SIOCGIFNETMASK _IOWR('i',37, struct ifreq) /* get net addr mask */ + #define SIOCSIFNETMASK _IOW('i',22, struct ifreq) /* set net addr mask */ +-/* #define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) get IF metric */ +-/* #define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) set IF metric */ ++#define SIOCGIFMETRIC _IOWR('i',23, struct ifreq_int) /* get IF metric */ ++#define SIOCSIFMETRIC _IOW('i',24, struct ifreq_int) /* set IF metric */ + #define SIOCDIFADDR _IOW('i',25, struct ifreq) /* delete IF addr */ + /* #define SIOCAIFADDR _IOW('i',26, struct ifaliasreq) add/chg IF alias */ + +@@ -313,11 +313,11 @@ enum __ioctl_datum { IOC_8, IOC_16, IOC_32, IOC_64 }; + #define SIOCGARP _IOWR('i',38, struct arpreq) /* get arp entry */ + #define SIOCDARP _IOW('i', 32, struct arpreq) /* delete arp entry */ + +-/* #define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int) get IF mtu */ +-/* #define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) set IF mtu */ ++#define SIOCGIFMTU _IOWR('i', 51, struct ifreq_int)/* get IF mtu */ ++#define SIOCSIFMTU _IOW('i', 52, struct ifreq_int) /* set IF mtu */ + +-/* #define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int) get IF index */ +-/* #define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int) set IF name */ ++#define SIOCGIFINDEX _IOWR('i', 90, struct ifreq_int)/* get IF index */ ++#define SIOCGIFNAME _IOWR('i', 91, struct ifreq_int)/* set IF name */ + + + /* Compatibility with 4.3 BSD terminal driver. +-- +2.54.0 + diff --git a/gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch b/gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch deleted file mode 100644 index ba345b361e5..00000000000 --- a/gnu/packages/patches/glibc-hurd-2.41-pthread-once.patch +++ /dev/null @@ -1,185 +0,0 @@ -Taken from: -https://salsa.debian.org/glibc-team/glibc/-/blob/22f0a9381fe844a5de92a57012833bec225a9686/debian/patches/hurd-i386/local-pthread_once.diff -This is glibc ccdb68e829a31e4cda8339ea0d2dc3e51fb81ba5 adapted for glibc 2.41 - -Note: compared to upstream, this was changed to exposing pthread_once as version -2.41. - -commit ccdb68e829a31e4cda8339ea0d2dc3e51fb81ba5 -Author: Samuel Thibault <[email protected]> -Date: Sun Mar 2 15:16:45 2025 +0100 - - htl: move pthread_once into libc - -diff --git a/htl/Makefile b/htl/Makefile -index 310097914f..603af24ce4 100644 ---- a/htl/Makefile -+++ b/htl/Makefile -@@ -31,7 +31,6 @@ libpthread-routines := \ - pt-key-delete \ - pt-getspecific \ - pt-setspecific \ -- pt-once \ - pt-alloc \ - pt-create \ - pt-getattr \ -@@ -186,6 +185,7 @@ routines := \ - pt-mutexattr-setrobust \ - pt-mutexattr-settype \ - pt-nthreads \ -+ pt-once \ - pt-pthread_self \ - pt-self pt-equal \ - pt-setschedparam \ -diff --git a/htl/Versions b/htl/Versions -index 3d2cb4e7a4..a07a3b3708 100644 ---- a/htl/Versions -+++ b/htl/Versions -@@ -63,6 +63,7 @@ libc { - pthread_mutexattr_setprotocol; - pthread_mutexattr_setpshared; - pthread_mutexattr_settype; -+ pthread_once; - pthread_sigmask; - } - -@@ -158,6 +159,7 @@ libc { - pthread_mutexattr_setpshared; - pthread_mutexattr_setrobust; pthread_mutexattr_setrobust_np; - pthread_mutexattr_settype; -+ pthread_once; - pthread_sigmask; - } - -@@ -211,6 +213,7 @@ libc { - __pthread_mutexattr_destroy; - __pthread_mutexattr_init; - __pthread_mutexattr_settype; -+ __pthread_once; - __pthread_sigstate; - __pthread_sigstate_destroy; - __pthread_sigmask; -@@ -264,8 +267,6 @@ libpthread { - pthread_mutex_timedlock; pthread_mutex_transfer_np; - pthread_mutex_trylock; pthread_mutex_unlock; - -- pthread_once; -- - pthread_rwlock_destroy; pthread_rwlock_init; pthread_rwlock_rdlock; - pthread_rwlock_timedrdlock; pthread_rwlock_timedwrlock; - pthread_rwlock_tryrdlock; pthread_rwlock_trywrlock; -diff --git a/sysdeps/htl/libc-lockP.h b/sysdeps/htl/libc-lockP.h -index 5085570baa..092eb35831 100644 ---- a/sysdeps/htl/libc-lockP.h -+++ b/sysdeps/htl/libc-lockP.h -@@ -114,6 +114,7 @@ libc_hidden_proto (__pthread_rwlock_unlock) - - extern int __pthread_once (pthread_once_t *__once_control, - void (*__init_routine) (void)); -+libc_hidden_proto (__pthread_once); - - extern int __pthread_atfork (void (*__prepare) (void), - void (*__parent) (void), -@@ -128,7 +129,6 @@ libc_hidden_proto (__pthread_setcancelstate) - weak_extern (__pthread_key_create) - weak_extern (__pthread_setspecific) - weak_extern (__pthread_getspecific) --weak_extern (__pthread_once) - weak_extern (__pthread_initialize) - weak_extern (__pthread_atfork) - weak_extern (__pthread_setcancelstate) -@@ -128,7 +129,6 @@ libc_hidden_proto (__pthread_setcancelstate) - # pragma weak __pthread_key_create - # pragma weak __pthread_setspecific - # pragma weak __pthread_getspecific --# pragma weak __pthread_once - # pragma weak __pthread_initialize - # pragma weak __pthread_atfork - # pragma weak __pthread_setcancelstate -diff --git a/sysdeps/htl/pt-once.c b/sysdeps/htl/pt-once.c -index 68fb2e1129..1f999ce492 100644 ---- a/sysdeps/htl/pt-once.c -+++ b/sysdeps/htl/pt-once.c -@@ -20,6 +20,7 @@ - #include <atomic.h> - - #include <pt-internal.h> -+#include <shlib-compat.h> - - static void - clear_once_control (void *arg) -@@ -53,4 +54,9 @@ __pthread_once (pthread_once_t *once_control, void (*init_routine) (void)) - - return 0; - } --weak_alias (__pthread_once, pthread_once); -+libc_hidden_def (__pthread_once) -+versioned_symbol (libc, __pthread_once, pthread_once, GLIBC_2_41); -+ -+#if OTHER_SHLIB_COMPAT (libpthread, GLIBC_2_12, GLIBC_2_41) -+compat_symbol (libpthread, __pthread_once, pthread_once, GLIBC_2_12); -+#endif -diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist -index bf62539c57..461df01ffb 100644 ---- a/sysdeps/mach/hurd/i386/libc.abilist -+++ b/sysdeps/mach/hurd/i386/libc.abilist -@@ -88,6 +88,7 @@ GLIBC_2.12 pthread_mutexattr_setprioceiling F - GLIBC_2.12 pthread_mutexattr_setprotocol F - GLIBC_2.12 pthread_mutexattr_setpshared F - GLIBC_2.12 pthread_mutexattr_settype F -+GLIBC_2.12 pthread_once F - GLIBC_2.12 pthread_self F - GLIBC_2.12 pthread_setschedparam F - GLIBC_2.12 pthread_sigmask F -@@ -2595,6 +2596,7 @@ GLIBC_2.42 pthread_mutex_consistent_np F - GLIBC_2.41 pthread_mutexattr_setrobust F - GLIBC_2.41 pthread_mutexattr_setrobust_np F - GLIBC_2.41 pthread_mutexattr_settype F -+GLIBC_2.41 pthread_once F - GLIBC_2.41 pthread_sigmask F - GLIBC_2.5 __readlinkat_chk F - GLIBC_2.5 inet6_opt_append F -diff --git a/sysdeps/mach/hurd/i386/libpthread.abilist b/sysdeps/mach/hurd/i386/libpthread.abilist -index d9c1a1790a..b067d377b3 100644 ---- a/sysdeps/mach/hurd/i386/libpthread.abilist -+++ b/sysdeps/mach/hurd/i386/libpthread.abilist -@@ -35,7 +35,6 @@ GLIBC_2.12 pthread_key_create F - GLIBC_2.12 pthread_mutex_transfer_np F - GLIBC_2.12 pthread_mutex_trylock F - GLIBC_2.12 pthread_mutex_unlock F --GLIBC_2.12 pthread_once F - GLIBC_2.12 pthread_rwlock_destroy F - GLIBC_2.12 pthread_rwlock_init F - GLIBC_2.12 pthread_rwlock_rdlock F -diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist -index fb068ab45e..6f235d20ba 100644 ---- a/sysdeps/mach/hurd/x86_64/libc.abilist -+++ b/sysdeps/mach/hurd/x86_64/libc.abilist -@@ -1579,6 +1579,7 @@ GLIBC_2.38 pthread_mutexattr_setpshared F - GLIBC_2.38 pthread_mutexattr_setrobust F - GLIBC_2.38 pthread_mutexattr_setrobust_np F - GLIBC_2.38 pthread_mutexattr_settype F -+GLIBC_2.38 pthread_once F - GLIBC_2.38 pthread_self F - GLIBC_2.38 pthread_setcancelstate F - GLIBC_2.38 pthread_setcanceltype F -@@ -2278,6 +2279,7 @@ GLIBC_2.42 pthread_mutex_consistent_np F - GLIBC_2.41 pthread_mutexattr_setrobust F - GLIBC_2.41 pthread_mutexattr_setrobust_np F - GLIBC_2.41 pthread_mutexattr_settype F -+GLIBC_2.41 pthread_once F - GLIBC_2.41 pthread_sigmask F - HURD_CTHREADS_0.3 __cthread_getspecific F - HURD_CTHREADS_0.3 __cthread_keycreate F -diff --git a/sysdeps/mach/hurd/x86_64/libpthread.abilist b/sysdeps/mach/hurd/x86_64/libpthread.abilist -index 71ce1d6288..6b8acec832 100644 ---- a/sysdeps/mach/hurd/x86_64/libpthread.abilist -+++ b/sysdeps/mach/hurd/x86_64/libpthread.abilist -@@ -55,7 +55,6 @@ GLIBC_2.38 pthread_key_create F - GLIBC_2.38 pthread_mutex_transfer_np F - GLIBC_2.38 pthread_mutex_trylock F - GLIBC_2.38 pthread_mutex_unlock F --GLIBC_2.38 pthread_once F - GLIBC_2.38 pthread_rwlock_clockrdlock F - GLIBC_2.38 pthread_rwlock_clockwrlock F - GLIBC_2.38 pthread_rwlock_destroy F diff --git a/gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch b/gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch deleted file mode 100644 index 4c65ddbd53b..00000000000 --- a/gnu/packages/patches/glibc-hurd-2.41-pthread-sigmask.patch +++ /dev/null @@ -1,22 +0,0 @@ -Taken from: -https://salsa.debian.org/glibc-team/glibc/-/blob/6c823b5862bd91ca757eeb9c6f5326875bc8af01/debian/patches/hurd-i386/git-pthread_sigmask_nothread.diff - -Upstream 2.42 has a much more involved cleanup fix which in the end -boils down to this. - -Index: glibc-upstream/sysdeps/mach/hurd/htl/pt-sigstate.c -=================================================================== ---- glibc-upstream.orig/sysdeps/mach/hurd/htl/pt-sigstate.c -+++ glibc-upstream/sysdeps/mach/hurd/htl/pt-sigstate.c -@@ -36,7 +36,10 @@ __pthread_sigstate (struct __pthread *th - if (set != NULL) - new = *set; - -- ss = _hurd_thread_sigstate (thread->kernel_thread); -+ if (thread == _pthread_self ()) -+ ss = _hurd_self_sigstate (); -+ else -+ ss = _hurd_thread_sigstate (thread->kernel_thread); - assert (ss); - - _hurd_sigstate_lock (ss); diff --git a/gnu/packages/patches/glibc-hurd-2.41-symlink.patch b/gnu/packages/patches/glibc-hurd-2.41-symlink.patch deleted file mode 100644 index 8b106ca0a45..00000000000 --- a/gnu/packages/patches/glibc-hurd-2.41-symlink.patch +++ /dev/null @@ -1,32 +0,0 @@ -Taken from: -https://sourceware.org/git/?p=glibc.git;a=patch;h=39183b953c68a489cc0b9aefb8974711c834fb38 - -From 39183b953c68a489cc0b9aefb8974711c834fb38 Mon Sep 17 00:00:00 2001 -From: Samuel Thibault <[email protected]> -Date: Mon, 21 Apr 2025 22:21:17 +0200 -Subject: [PATCH] hurd: Make symlink return EEXIST on existing target directory - -8ef17919509e ("hurd: Fix EINVAL error on linking to a slash-trailing path -[BZ #32569]) made symlink return ENOTDIR, but the gnulib testsuite does -not recognize it for such a situation, and EEXIST is indeed more -comprehensible to users. ---- - sysdeps/mach/hurd/symlinkat.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sysdeps/mach/hurd/symlinkat.c b/sysdeps/mach/hurd/symlinkat.c -index e7dfb673df..cb6250e6f0 100644 ---- a/sysdeps/mach/hurd/symlinkat.c -+++ b/sysdeps/mach/hurd/symlinkat.c -@@ -47,7 +47,7 @@ __symlinkat (const char *from, int fd, const char *to) - - if (! *name) - /* Can't link to the existing directory itself. */ -- err = ENOTDIR; -+ err = EEXIST; - else - /* Create a new, unlinked node in the target directory. */ - err = __dir_mkfile (dir, O_WRITE, 0777 & ~_hurd_umask, &node); --- -2.49.0 - diff --git a/gnu/packages/patches/glibc-hurd-signal-fpe-exception.patch b/gnu/packages/patches/glibc-hurd-signal-fpe-exception.patch deleted file mode 100644 index fefd9f693c0..00000000000 --- a/gnu/packages/patches/glibc-hurd-signal-fpe-exception.patch +++ /dev/null @@ -1,67 +0,0 @@ -Cherry picked from glibc-2.42 - -0d99714680 * hurd: Clear FP exceptions before calling signal handler - -From 0d9971468087c77e8727638123ae4aa60724e0ff Mon Sep 17 00:00:00 2001 -From: Samuel Thibault <[email protected]> -Date: Mon, 21 Apr 2025 19:58:04 +0200 -Subject: [PATCH] hurd: Clear FP exceptions before calling signal handler - -This avoids SIGFPE handlers (or code longjmp-ed to) getting disturbed by the -exception that generated it. - -Note: gcc's unwinding depends on the rpc_wait_trampoline/trampoline exact -code, so we here avoid breaking it. ---- - sysdeps/mach/hurd/x86/trampoline.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c -index 02510b178c..6f23c567da 100644 ---- a/sysdeps/mach/hurd/x86/trampoline.c -+++ b/sysdeps/mach/hurd/x86/trampoline.c -@@ -461,7 +461,10 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - - in gdb: gdb/i386-gnu-tdep.c gnu_sigtramp_code. */ - - #ifdef __x86_64__ --asm ("rpc_wait_trampoline:\n" -+asm ("trampoline:\n" -+ "fnclex\n" /* Clear any pending exception. */ -+ "jmp _trampoline\n" -+ "rpc_wait_trampoline:\n" - /* This is the entry point when we have an RPC reply message to receive - before running the handler. The MACH_MSG_SEND bit has already been - cleared in the OPTION argument in our %rsi. The interrupted user -@@ -480,7 +483,7 @@ asm ("rpc_wait_trampoline:\n" - /* Switch to the signal stack. */ - "movq %rbx, %rsp\n" - -- "trampoline:\n" -+ "_trampoline:\n" - /* Entry point for running the handler normally. The arguments to the - handler function are on the top of the stack, same as in the i386 - version: -@@ -506,7 +509,10 @@ asm ("rpc_wait_trampoline:\n" - "movq 16(%rsp), %rdi\n" - "ret"); - #else --asm ("rpc_wait_trampoline:\n"); -+asm ("trampoline:\n" -+ "fnclex\n" /* Clear any pending exception. */ -+ "jmp _trampoline\n" -+ "rpc_wait_trampoline:\n"); - /* This is the entry point when we have an RPC reply message to receive - before running the handler. The MACH_MSG_SEND bit has already been - cleared in the OPTION argument on our stack. The interrupted user -@@ -526,7 +532,7 @@ asm (/* Retry the interrupted mach_msg system call. */ - /* Switch to the signal stack. */ - "movl %ebx, %esp\n"); - -- asm ("trampoline:\n"); -+asm ("_trampoline:\n"); - /* Entry point for running the handler normally. The arguments to the - handler function are already on the top of the stack: - --- -2.51.0 - diff --git a/gnu/packages/patches/glibc-hurd-xstate.patch b/gnu/packages/patches/glibc-hurd-xstate.patch deleted file mode 100644 index f46a84adb21..00000000000 --- a/gnu/packages/patches/glibc-hurd-xstate.patch +++ /dev/null @@ -1,813 +0,0 @@ -Cherry picked from glibc 2.42 - -6d6a6e2dd2 * hurd: save xstate during signal handling -8d54b428cf * hurd: Do not restore xstate when it is not initialized -0f2df19d95 * hurd: Do not check for xstate level if it was not initialized - -From 6d6a6e2dd2133908e3f5cb8a2ed817ccb2a0bb06 Mon Sep 17 00:00:00 2001 -From: Luca Dariz <[email protected]> -Date: Wed, 19 Mar 2025 18:11:18 +0100 -Subject: [PATCH] hurd: save xstate during signal handling - -* hurd/Makefile: add new tests -* hurd/test-sig-rpc-interrupted.c: check xstate save and restore in - the case where a signal is delivered to a thread which is waiting - for an rpc. This test implements the rpc interruption protocol used - by the hurd servers. It was so far passing on Debian thanks to the - local-intr-msg-clobber.diff patch, which is now obsolete. -* hurd/test-sig-xstate.c: check xstate save and restore in the case - where a signal is delivered to a running thread, making sure that - the xstate is modified in the signal handler. -* hurd/test-xstate.h: add helpers to test xstate -* sysdeps/mach/hurd/i386/bits/sigcontext.h: add xstate to the - sigcontext structure. -+ sysdeps/mach/hurd/i386/sigreturn.c: restore xstate from the saved - context -* sysdeps/mach/hurd/x86/trampoline.c: save xstate if - supported. Otherwise we fall back to the previous behaviour of - ignoring xstate. -* sysdeps/mach/hurd/x86_64/bits/sigcontext.h: add xstate to the - sigcontext structure. -* sysdeps/mach/hurd/x86_64/sigreturn.c: restore xstate from the saved - context - -Signed-off-by: Luca Dariz <[email protected]> -Signed-off-by: Samuel Thibault <[email protected]> -Message-ID: <[email protected]> ---- - hurd/Makefile | 5 + - hurd/test-sig-rpc-interrupted.c | 185 +++++++++++++++++++++ - hurd/test-sig-xstate.c | 94 +++++++++++ - hurd/test-xstate.h | 40 +++++ - sysdeps/mach/hurd/i386/bits/sigcontext.h | 2 + - sysdeps/mach/hurd/i386/sigreturn.c | 32 +++- - sysdeps/mach/hurd/x86/trampoline.c | 91 ++++++++-- - sysdeps/mach/hurd/x86_64/bits/sigcontext.h | 2 + - sysdeps/mach/hurd/x86_64/sigreturn.c | 32 +++- - 9 files changed, 458 insertions(+), 25 deletions(-) - create mode 100644 hurd/test-sig-rpc-interrupted.c - create mode 100644 hurd/test-sig-xstate.c - create mode 100644 hurd/test-xstate.h - -diff --git a/hurd/Makefile b/hurd/Makefile -index cf70b8c65c..cbc3c23b1f 100644 ---- a/hurd/Makefile -+++ b/hurd/Makefile -@@ -19,6 +19,11 @@ subdir := hurd - - include ../Makeconfig - -+tests := test-sig-xstate \ -+ test-sig-rpc-interrupted -+$(objpfx)test-sig-xstate: $(shared-thread-library) -+$(objpfx)test-sig-rpc-interrupted: $(shared-thread-library) $(objdir)/hurd/libhurduser.so -+ - headers = \ - $(interface-headers) \ - hurd.h \ -diff --git a/hurd/test-sig-rpc-interrupted.c b/hurd/test-sig-rpc-interrupted.c -new file mode 100644 -index 0000000000..a89d70e5a4 ---- /dev/null -+++ b/hurd/test-sig-rpc-interrupted.c -@@ -0,0 +1,185 @@ -+/* Test the state save/restore procedures during signal handling when an -+ interruptible RPC is restarted. -+ -+ Copyright (C) 2024 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+ -+#include <assert.h> -+#include <pthread.h> -+#include <signal.h> -+#include <stdbool.h> -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+#include <unistd.h> -+ -+#include <mach/message.h> -+#include <mach/gnumach.h> -+#include <mach/mach_traps.h> -+#include <mach/mig_errors.h> -+#include <mach-shortcuts.h> -+#include <mach_init.h> -+#include <hurd/io.h> -+#include <hurd/io_reply.h> -+ -+#include <support/check.h> -+#include <support/xthread.h> -+ -+#include "test-xstate.h" -+ -+void handler (int signum, siginfo_t *info, void *context) -+{ -+ printf ("signal %d setting a different CPU state\n", signum); -+ char buf3[XSTATE_BUFFER_SIZE]; -+ memset (buf3, 0x77, XSTATE_BUFFER_SIZE); -+ SET_XSTATE (buf3); -+} -+ -+static const mach_msg_type_t RetCodeCheck = { -+ .msgt_name = (unsigned char) MACH_MSG_TYPE_INTEGER_32, -+ .msgt_size = 32, -+ .msgt_number = 1, -+ .msgt_inline = TRUE, -+ .msgt_longform = FALSE, -+ .msgt_deallocate = FALSE, -+ .msgt_unused = 0 -+}; -+ -+ -+/* Helper thread to simulate a proper RPC interruption during dignal handling */ -+void* fake_interruptor (void *arg) -+{ -+ int err; -+ sigset_t ss; -+ TEST_COMPARE (sigemptyset (&ss), 0); -+ TEST_COMPARE (sigaddset (&ss, SIGUSR1), 0); -+ TEST_COMPARE (sigprocmask (SIG_BLOCK, &ss, NULL), 0); -+ -+ struct { -+ mach_msg_header_t Head; -+ } request; -+ mach_port_t rxport = *((mach_port_t*)arg); -+ err = mach_msg (&request.Head, MACH_RCV_MSG, 0, sizeof (request), rxport, -+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ TEST_COMPARE (request.Head.msgh_bits, 0x1112); -+ TEST_COMPARE (request.Head.msgh_size, sizeof (request.Head)); -+ TEST_COMPARE (request.Head.msgh_id, 33000); -+ -+ mig_reply_header_t reply; -+ reply.Head = request.Head; -+ reply.Head.msgh_id += 100; -+ reply.RetCodeType = RetCodeCheck; -+ reply.RetCode = KERN_SUCCESS; -+ err = mach_msg (&reply.Head, MACH_SEND_MSG, sizeof (reply), 0, MACH_PORT_NULL, -+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ return NULL; -+} -+ -+ -+/* Helper thread to send a signal to the main thread in the middle of -+ * an interruptible rpc */ -+void* signal_sender (void *arg) -+{ -+ int err; -+ sigset_t ss; -+ TEST_COMPARE (sigemptyset (&ss), 0); -+ TEST_COMPARE (sigaddset (&ss, SIGUSR1), 0); -+ TEST_COMPARE (sigprocmask (SIG_BLOCK, &ss, NULL), 0); -+ -+ /* Receive the first request, we won't answer to this. */ -+ struct { -+ mach_msg_header_t head; -+ char data[64]; -+ } m1, m2; -+ mach_port_t rxport = *((mach_port_t*)arg); -+ memset (&m1, 0, sizeof (m1)); -+ memset (&m2, 0, sizeof (m2)); -+ err = mach_msg (&m1.head, MACH_RCV_MSG, 0, sizeof (m1), rxport, -+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ /* interrupt the ongoing rpc with a signal, using the -+ * interruptible rpc protocol */ -+ pthread_t thintr = xpthread_create (NULL, fake_interruptor, arg); -+ TEST_COMPARE (kill (getpid (), SIGUSR1), 0); -+ xpthread_join (thintr); -+ -+ /* Complete the interruption by sending EINTR */ -+ mig_reply_header_t reply; -+ reply.Head = m1.head; -+ reply.Head.msgh_id += 100; -+ reply.RetCodeType = RetCodeCheck; -+ reply.RetCode = EINTR; -+ err = mach_msg (&reply.Head, MACH_SEND_MSG, sizeof (reply), 0, MACH_PORT_NULL, -+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ /* Receive the retried rpc, and check that it has the same payload -+ * as the first one. Port names might still be different. */ -+ err = mach_msg (&m2.head, MACH_RCV_MSG, 0, sizeof (m2), rxport, -+ MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); -+ TEST_COMPARE (m1.head.msgh_bits, m2.head.msgh_bits); -+ TEST_COMPARE (m1.head.msgh_size, m2.head.msgh_size); -+ TEST_COMPARE (m1.head.msgh_id, m2.head.msgh_id); -+ TEST_COMPARE_BLOB (m1.data, sizeof (m1.data), m2.data, sizeof (m2.data)); -+ -+ /* And finally make the rpc succeed by sending a valid reply */ -+ err = io_read_reply (m2.head.msgh_remote_port, MACH_MSG_TYPE_MOVE_SEND_ONCE, -+ KERN_SUCCESS, NULL, 0); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ return NULL; -+} -+ -+ -+static int do_test (void) -+{ -+#if ! XSTATE_HELPERS_SUPPORTED -+ FAIL_UNSUPPORTED ("Test not supported on this arch."); -+#endif -+ -+ /* Setup signal handling; we need to handle the signal in the main -+ * thread, the other ones will explicitely block SIGUSR1. */ -+ struct sigaction act = { 0 }; -+ act.sa_flags = SA_RESTART; -+ act.sa_sigaction = &handler; -+ TEST_COMPARE (sigaction (SIGUSR1, &act, NULL), 0); -+ -+ mach_port_t fakeio; -+ int err; -+ err = mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, &fakeio); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ err = mach_port_insert_right (mach_task_self (), fakeio, fakeio, -+ MACH_MSG_TYPE_MAKE_SEND); -+ TEST_COMPARE (err, MACH_MSG_SUCCESS); -+ -+ pthread_t thsender = xpthread_create (NULL, signal_sender, &fakeio); -+ -+ char *buf; -+ mach_msg_type_number_t n; -+ TEST_COMPARE (io_read (fakeio, &buf, &n, 1, 2), 0); -+ -+ xpthread_join (thsender); -+ return EXIT_SUCCESS; -+} -+ -+#include <support/test-driver.c> -diff --git a/hurd/test-sig-xstate.c b/hurd/test-sig-xstate.c -new file mode 100644 -index 0000000000..0a68a44fd7 ---- /dev/null -+++ b/hurd/test-sig-xstate.c -@@ -0,0 +1,94 @@ -+/* Test the state save/restore procedures during signal handling. -+ -+ Copyright (C) 2025 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+ -+#include <assert.h> -+#include <pthread.h> -+#include <signal.h> -+#include <stdbool.h> -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+#include <unistd.h> -+ -+#include <mach/message.h> -+#include <mach/gnumach.h> -+#include <mach/mach_traps.h> -+#include <mach-shortcuts.h> -+#include <mach_init.h> -+#include <hurd/io.h> -+#include <hurd/io_reply.h> -+ -+#include <support/check.h> -+#include <support/xthread.h> -+ -+#include "test-xstate.h" -+ -+static volatile bool loopflag = true; -+ -+void handler (int signum, siginfo_t *info, void *context) -+{ -+ char buf3[XSTATE_BUFFER_SIZE]; -+ memset (buf3, 0x77, XSTATE_BUFFER_SIZE); -+ SET_XSTATE (buf3); -+ printf ("signal %d setting a different CPU state\n", signum); -+ loopflag = false; -+} -+ -+/* Helper thread to send a signal to the main thread */ -+void* signal_sender (void *arg) -+{ -+ sigset_t ss; -+ assert (! sigemptyset (&ss)); -+ assert (! sigaddset (&ss, SIGUSR1)); -+ assert (! sigprocmask (SIG_BLOCK, &ss, NULL)); -+ -+ TEST_COMPARE (kill (getpid (), SIGUSR1), 0); -+ -+ return NULL; -+} -+ -+static int do_test (void) -+{ -+#if ! XSTATE_HELPERS_SUPPORTED -+ FAIL_UNSUPPORTED ("Test not supported on this arch."); -+#endif -+ -+ struct sigaction act = { 0 }; -+ act.sa_sigaction = &handler; -+ TEST_COMPARE (sigaction (SIGUSR1, &act, NULL), 0); -+ -+ pthread_t thsender = xpthread_create (NULL, signal_sender, NULL); -+ -+ char buf1[XSTATE_BUFFER_SIZE], buf2[XSTATE_BUFFER_SIZE]; -+ memset (buf1, 0x33, XSTATE_BUFFER_SIZE); -+ -+ SET_XSTATE (buf1); -+ -+ while (loopflag) -+ ; -+ -+ GET_XSTATE (buf2); -+ TEST_COMPARE_BLOB (buf1, sizeof (buf1), buf2, sizeof (buf2)); -+ -+ xpthread_join (thsender); -+ return EXIT_SUCCESS; -+} -+ -+#include <support/test-driver.c> -diff --git a/hurd/test-xstate.h b/hurd/test-xstate.h -new file mode 100644 -index 0000000000..a8185dcb07 ---- /dev/null -+++ b/hurd/test-xstate.h -@@ -0,0 +1,40 @@ -+/* Helpers to test XSTATE during signal handling -+ -+ Copyright (C) 2025 Free Software Foundation, Inc. -+ This file is part of the GNU C Library. -+ -+ The GNU C Library is free software; you can redistribute it and/or -+ modify it under the terms of the GNU Lesser General Public -+ License as published by the Free Software Foundation; either -+ version 2.1 of the License, or (at your option) any later version. -+ -+ The GNU C Library is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -+ Lesser General Public License for more details. -+ -+ You should have received a copy of the GNU Lesser General Public -+ License along with the GNU C Library; if not, see -+ <https://www.gnu.org/licenses/>. */ -+ -+#ifndef _TEST_XSTATE_H -+#define _TEST_XSTATE_H -+ -+#if defined __x86_64__ || defined __i386__ -+#define XSTATE_HELPERS_SUPPORTED 1 -+#define XSTATE_BUFFER_SIZE 16 -+#define SET_XSTATE(b) do { \ -+ asm volatile ("movups (%0),%%xmm0" :: "r" (b)); \ -+ } while (0) -+ -+#define GET_XSTATE(b) do { \ -+ asm volatile ("movups %%xmm0,(%0)" :: "r" (b)); \ -+ } while (0) -+ -+#else -+#define XSTATE_HELPERS_SUPPORTED 0 -+#define XSTATE_BUFFER_SIZE 1 -+#define SET_XSTATE(b) -+#endif -+ -+#endif /* _TEST_XSTATE_H */ -diff --git a/sysdeps/mach/hurd/i386/bits/sigcontext.h b/sysdeps/mach/hurd/i386/bits/sigcontext.h -index 6e5e220e9d..c44e4deac6 100644 ---- a/sysdeps/mach/hurd/i386/bits/sigcontext.h -+++ b/sysdeps/mach/hurd/i386/bits/sigcontext.h -@@ -88,6 +88,8 @@ struct sigcontext - struct i386_fp_save sc_fpsave; - struct i386_fp_regs sc_fpregs; - int sc_fpexcsr; /* FPSR including exception bits. */ -+ -+ struct i386_xfloat_state *xstate; - }; - - /* Traditional BSD names for some members. */ -diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c -index ce8df8d02b..37fa984070 100644 ---- a/sysdeps/mach/hurd/i386/sigreturn.c -+++ b/sysdeps/mach/hurd/i386/sigreturn.c -@@ -21,6 +21,8 @@ - #include <stdlib.h> - #include <string.h> - -+#include <cpuid.h> -+ - /* This is run on the thread stack after restoring it, to be able to - unlock SS off sigstack. */ - static void -@@ -123,10 +125,32 @@ __sigreturn (struct sigcontext *scp) - if (scp->sc_onstack) - ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - -- if (scp->sc_fpused) -- /* Restore the FPU state. Mach conveniently stores the state -- in the format the i387 `frstor' instruction uses to restore it. */ -- asm volatile ("frstor %0" : : "m" (scp->sc_fpsave)); -+#ifdef i386_XFLOAT_STATE -+ if ((scp->xstate) && (scp->xstate->initialized)) -+ { -+ unsigned eax, ebx, ecx, edx; -+ __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -+ switch (scp->xstate->fp_save_kind) -+ { -+ case 0: // FNSAVE -+ asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -+ break; -+ case 1: // FXSAVE -+ asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -+ asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ } -+ } -+ else -+#endif -+ if (scp->sc_fpused) -+ /* Restore the FPU state. Mach conveniently stores the state -+ in the format the i387 `frstor' instruction uses to restore it. */ -+ asm volatile ("frstor %0" : : "m" (scp->sc_fpsave)); - - { - /* There are convenient instructions to pop state off the stack, so we -diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c -index 8e2890f8c5..db756e8a1f 100644 ---- a/sysdeps/mach/hurd/x86/trampoline.c -+++ b/sysdeps/mach/hurd/x86/trampoline.c -@@ -26,7 +26,11 @@ - #include "hurdfault.h" - #include <intr-msg.h> - #include <sys/ucontext.h> -- -+#ifdef __x86_64__ -+#include <mach/x86_64/mach_i386.h> -+#else -+#include <mach/i386/mach_i386.h> -+#endif - - /* Fill in a siginfo_t structure for SA_SIGINFO-enabled handlers. */ - static void fill_siginfo (siginfo_t *si, int signo, -@@ -106,6 +110,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - void firewall (void); - void *sigsp; - struct sigcontext *scp; -+ vm_size_t xstate_size; - struct - { - union -@@ -145,6 +150,14 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - struct hurd_userlink link; - ucontext_t ucontext; - siginfo_t siginfo; -+#ifdef __x86_64__ -+ char _pad2[56]; -+#else -+ char _pad2[20]; -+#endif -+ char xstate[]; -+ /* Don't add anything after xstate, as it's dynamically -+ sized. */ - } *stackframe; - - #ifdef __x86_64__ -@@ -170,6 +183,17 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - if (! machine_get_basic_state (ss->thread, state)) - return NULL; - -+ /* Initialize the size of the CPU extended state, to be saved during -+ * signal handling */ -+#ifdef i386_XFLOAT_STATE -+ _Static_assert ((sizeof(*stackframe) + sizeof(struct i386_xfloat_state)) % 64 == 0, -+ "stackframe size must be multiple of 64-byte minus " -+ "sizeof(struct i386_xfloat_state), please adjust _pad2"); -+ -+ if (__i386_get_xstate_size(__mach_host_self(), &xstate_size)) -+#endif -+ xstate_size = 0; -+ - /* Save the original SP in the gratuitous `esp' slot. - We may need to reset the SP (the `uesp' slot) to avoid clobbering an - interrupted RPC frame. */ -@@ -196,14 +220,21 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - #endif - } - -- /* Push the arguments to call `trampoline' on the stack. */ -- sigsp -= sizeof (*stackframe); --#ifdef __x86_64__ -- /* Align SP at 16 bytes. Coupled with the fact that sigreturn_addr is -- 16-byte aligned within the stackframe struct, this ensures that it ends -- up on a 16-byte aligned address, as required by the ABI. */ -- sigsp = (void *) ((uintptr_t) sigsp & ~15UL); --#endif -+ /* Push the arguments to call `trampoline' on the stack. -+ * The extended state might have a variable size depending on the platform, -+ * so we dynamically allocate it on the stack frame.*/ -+ sigsp -= sizeof (*stackframe) + xstate_size; -+ -+ /* Align SP at 64 bytes. This is needed for two reasons: -+ * - sigreturn_addr is 16-byte aligned within the stackframe -+ * struct, and this ensures that it ends up on a 16-byte aligned -+ * address, as required by the ABI. -+ * - the XSAVE state needs to be aligned at 64 bytes (on both i386 and -+ * x86_64), so we align the stackframe also at 64 bytes and add the -+ * required padding at the end, see the _pad2 field. -+ */ -+ sigsp = (void *) ((uintptr_t) sigsp & ~63UL); -+ - stackframe = sigsp; - - if (_hurdsig_catch_memory_fault (stackframe)) -@@ -248,14 +279,40 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - memcpy (&scp->sc_i386_thread_state, - &state->basic, sizeof (state->basic)); - -- /* struct sigcontext is laid out so that starting at sc_fpkind mimics -- a struct i386_float_state. */ -- _Static_assert (offsetof (struct sigcontext, sc_i386_float_state) -- % __alignof__ (struct i386_float_state) == 0, -- "sc_i386_float_state layout mismatch"); -- ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE, -- &state->fpu, &scp->sc_i386_float_state, -- sizeof (state->fpu)); -+ scp->xstate = NULL; -+#ifdef i386_XFLOAT_STATE -+ if (xstate_size > 0) -+ { -+ mach_msg_type_number_t got = (xstate_size / sizeof (int)); -+ -+ ok = (! __thread_get_state (ss->thread, i386_XFLOAT_STATE, -+ (thread_state_t) stackframe->xstate, &got) -+ && got == (xstate_size / sizeof (int))); -+ -+ if (((struct i386_xfloat_state*) stackframe->xstate)->fp_save_kind > 5) -+ /* We support up to XSAVES */ -+ ok = 0; -+ -+ if (ok) -+ { -+ scp->xstate = (struct i386_xfloat_state*) stackframe->xstate; -+ assert((uintptr_t)scp->xstate->hw_state % 64 == 0); -+ } -+ } -+ else -+#endif -+ ok = 0; -+ if (!ok) -+ { -+ /* struct sigcontext is laid out so that starting at sc_fpkind mimics -+ a struct i386_float_state. */ -+ _Static_assert (offsetof (struct sigcontext, sc_i386_float_state) -+ % __alignof__ (struct i386_float_state) == 0, -+ "sc_i386_float_state layout mismatch"); -+ ok = machine_get_state (ss->thread, state, i386_FLOAT_STATE, -+ &state->fpu, &scp->sc_i386_float_state, -+ sizeof (state->fpu)); -+ } - - /* Set up the arguments for the signal handler. */ - stackframe->signo = signo; -diff --git a/sysdeps/mach/hurd/x86_64/bits/sigcontext.h b/sysdeps/mach/hurd/x86_64/bits/sigcontext.h -index 7bac881176..d83795fcbc 100644 ---- a/sysdeps/mach/hurd/x86_64/bits/sigcontext.h -+++ b/sysdeps/mach/hurd/x86_64/bits/sigcontext.h -@@ -96,6 +96,8 @@ struct sigcontext - struct i386_fp_save sc_fpsave; - struct i386_fp_regs sc_fpregs; - int sc_fpexcsr; /* FPSR including exception bits. */ -+ -+ struct i386_xfloat_state *xstate; - }; - - /* Traditional BSD names for some members. */ -diff --git a/sysdeps/mach/hurd/x86_64/sigreturn.c b/sysdeps/mach/hurd/x86_64/sigreturn.c -index 81a2d3ba74..dff8e76dc8 100644 ---- a/sysdeps/mach/hurd/x86_64/sigreturn.c -+++ b/sysdeps/mach/hurd/x86_64/sigreturn.c -@@ -20,6 +20,8 @@ - #include <hurd/msg.h> - #include <stdlib.h> - -+#include <cpuid.h> -+ - /* This is run on the thread stack after restoring it, to be able to - unlock SS off sigstack. */ - void -@@ -116,10 +118,32 @@ __sigreturn (struct sigcontext *scp) - if (scp->sc_onstack) - ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - -- if (scp->sc_fpused) -- /* Restore the FPU state. Mach conveniently stores the state -- in the format the i387 `frstor' instruction uses to restore it. */ -- asm volatile ("frstor %0" : : "m" (scp->sc_fpsave)); -+#ifdef i386_XFLOAT_STATE -+ if ((scp->xstate) && (scp->xstate->initialized)) -+ { -+ unsigned eax, ebx, ecx, edx; -+ __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -+ switch (scp->xstate->fp_save_kind) -+ { -+ case 0: // FNSAVE -+ asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -+ break; -+ case 1: // FXSAVE -+ asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -+ asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ } -+ } -+ else -+#endif -+ if (scp->sc_fpused) -+ /* Restore the FPU state. Mach conveniently stores the state -+ in the format the i387 `frstor' instruction uses to restore it. */ -+ asm volatile ("frstor %0" : : "m" (scp->sc_fpsave)); - - /* Copy the registers onto the user's stack, to be able to release the - altstack (by unlocking sigstate). Note that unless an altstack is used, --- -2.51.0 - -From 8d54b428cfe98c21049f94c8af3bf302e44091e9 Mon Sep 17 00:00:00 2001 -From: Samuel Thibault <[email protected]> -Date: Mon, 21 Apr 2025 19:42:27 +0200 -Subject: [PATCH] hurd: Do not restore xstate when it is not initialized - -If the process has never used fp before getting a signal, xstate is set -(and thus the x87 state is not initialized) but xstate->initialized is still -0, and we should not restore anything. ---- - sysdeps/mach/hurd/i386/sigreturn.c | 37 +++++++++++++++------------- - sysdeps/mach/hurd/x86_64/sigreturn.c | 37 +++++++++++++++------------- - 2 files changed, 40 insertions(+), 34 deletions(-) - -diff --git a/sysdeps/mach/hurd/i386/sigreturn.c b/sysdeps/mach/hurd/i386/sigreturn.c -index 37fa984070..dc57d6122c 100644 ---- a/sysdeps/mach/hurd/i386/sigreturn.c -+++ b/sysdeps/mach/hurd/i386/sigreturn.c -@@ -126,24 +126,27 @@ __sigreturn (struct sigcontext *scp) - ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - - #ifdef i386_XFLOAT_STATE -- if ((scp->xstate) && (scp->xstate->initialized)) -+ if (scp->xstate) - { -- unsigned eax, ebx, ecx, edx; -- __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -- switch (scp->xstate->fp_save_kind) -- { -- case 0: // FNSAVE -- asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -- break; -- case 1: // FXSAVE -- asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -- "a" (eax), "d" (edx)); -- break; -- default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -- asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -- "a" (eax), "d" (edx)); -- break; -- } -+ if (scp->xstate->initialized) -+ { -+ unsigned eax, ebx, ecx, edx; -+ __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -+ switch (scp->xstate->fp_save_kind) -+ { -+ case 0: // FNSAVE -+ asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -+ break; -+ case 1: // FXSAVE -+ asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -+ asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ } -+ } - } - else - #endif -diff --git a/sysdeps/mach/hurd/x86_64/sigreturn.c b/sysdeps/mach/hurd/x86_64/sigreturn.c -index dff8e76dc8..773c00f86d 100644 ---- a/sysdeps/mach/hurd/x86_64/sigreturn.c -+++ b/sysdeps/mach/hurd/x86_64/sigreturn.c -@@ -119,24 +119,27 @@ __sigreturn (struct sigcontext *scp) - ss->sigaltstack.ss_flags &= ~SS_ONSTACK; - - #ifdef i386_XFLOAT_STATE -- if ((scp->xstate) && (scp->xstate->initialized)) -+ if (scp->xstate) - { -- unsigned eax, ebx, ecx, edx; -- __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -- switch (scp->xstate->fp_save_kind) -- { -- case 0: // FNSAVE -- asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -- break; -- case 1: // FXSAVE -- asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -- "a" (eax), "d" (edx)); -- break; -- default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -- asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -- "a" (eax), "d" (edx)); -- break; -- } -+ if (scp->xstate->initialized) -+ { -+ unsigned eax, ebx, ecx, edx; -+ __cpuid_count(0xd, 0, eax, ebx, ecx, edx); -+ switch (scp->xstate->fp_save_kind) -+ { -+ case 0: // FNSAVE -+ asm volatile("frstor %0" : : "m" (scp->xstate->hw_state)); -+ break; -+ case 1: // FXSAVE -+ asm volatile("fxrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ default: // XSAVE, XSAVEOPT, XSAVEC, XSAVES -+ asm volatile("xrstor %0" : : "m" (scp->xstate->hw_state), \ -+ "a" (eax), "d" (edx)); -+ break; -+ } -+ } - } - else - #endif --- -2.51.0 - -From 0f2df19d9535d234b31c65f84a6c67ac2e0bd027 Mon Sep 17 00:00:00 2001 -From: Samuel Thibault <[email protected]> -Date: Mon, 21 Apr 2025 19:45:02 +0200 -Subject: [PATCH] hurd: Do not check for xstate level if it was not - initialized - -If __thread_get_state failed, there is no xstate level to check. -ok is 0 already and the memory exists, but better not read uninitialized -memory. ---- - sysdeps/mach/hurd/x86/trampoline.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c -index db756e8a1f..02510b178c 100644 ---- a/sysdeps/mach/hurd/x86/trampoline.c -+++ b/sysdeps/mach/hurd/x86/trampoline.c -@@ -289,7 +289,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action - (thread_state_t) stackframe->xstate, &got) - && got == (xstate_size / sizeof (int))); - -- if (((struct i386_xfloat_state*) stackframe->xstate)->fp_save_kind > 5) -+ if (ok && ((struct i386_xfloat_state*) stackframe->xstate)->fp_save_kind > 5) - /* We support up to XSAVES */ - ok = 0; - --- -2.51.0 -
