From patchwork Sun Jan 11 01:04:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 127841 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 76DEE4BA2E1E for ; Sun, 11 Jan 2026 01:05:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 76DEE4BA2E1E X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from sonata.ens-lyon.org (sonata.ens-lyon.org [140.77.166.138]) by sourceware.org (Postfix) with ESMTPS id 1F6914BA2E06 for ; Sun, 11 Jan 2026 01:04:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F6914BA2E06 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ens-lyon.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bounce.ens-lyon.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 1F6914BA2E06 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=140.77.166.138 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768093486; cv=none; b=Jjlh6KsOqt7vvBlJmo5LcU9F0ej3Hl74iRMlDURrd1BRI70PEAgn6vEAMt2XUetE67FoF8v5T/XKmQ5MrHM0KJsmOUh9KXIxCTnuYaRwD9TPrP+CiOZ8YTpcszPP442He2IK3R1SDhtwlXdp/n4CErxYIEKW2Od5pYYAn+5WjnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1768093486; c=relaxed/simple; bh=COE8F8UKuwLrLjAUgTCN5uFnH9CwM7a8wU6Kkc0xshI=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=vwfKGpZL64/QTcpR8/VqQk81yfFz7wWkbf7mz9HvPMHapXUlzQHjmerxhPFy9P3YwE2276+zlussPuWdg4qEBBY0UJt6HRaZXQQZLnqHRRqiW7Xvey+9jVgt7jmIrctjlL9nJ3Pt0DAo1zZg2adZtFZ9PeLt6FoxDBh0xW0ERDs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1F6914BA2E06 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 13755A4A50; Sun, 11 Jan 2026 02:04:45 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nVmOUA9kuPHJ; Sun, 11 Jan 2026 02:04:45 +0100 (CET) Received: from end (aamiens-653-1-40-48.w83-192.abo.wanadoo.fr [83.192.199.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id E76AFA2183; Sun, 11 Jan 2026 02:04:44 +0100 (CET) Received: from samy by end with local (Exim 4.99.1) (envelope-from ) id 1vejsq-00000001tsc-1KGD; Sun, 11 Jan 2026 02:04:44 +0100 From: Samuel Thibault To: libc-alpha@sourceware.org Cc: Samuel Thibault , commit-hurd@gnu.org Subject: [hurd,commited] hurd: Fix sigreturn clobbering some xmm registers Date: Sun, 11 Jan 2026 02:04:44 +0100 Message-ID: <20260111010444.453123-1-samuel.thibault@ens-lyon.org> X-Mailer: git-send-email 2.51.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org __sigreturn2 uses _hurd_sigstate_unlock after restoring the interrupted xmm values, we thus need it not to touch xmm. It makes sense to inline sigstate_is_global_rcv _hurd_sigstate_lock/unlock anyway. unlock calls gsync_wake, so we need to avoid xmm there as well. --- hurd/hurdsig.c | 38 ++++-------------------------- sysdeps/hurd/include/hurd/signal.h | 34 ++++++++++++++++++++++++++ sysdeps/mach/hurd/x86/Makefile | 1 + 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/hurd/hurdsig.c b/hurd/hurdsig.c index 2b2b57ac0d..91e664d0f1 100644 --- a/hurd/hurdsig.c +++ b/hurd/hurdsig.c @@ -168,6 +168,7 @@ _hurd_sigstate_delete (thread_t thread) free (ss); } } +libc_hidden_def (_hurd_sigstate_delete) /* Make SS a global receiver, with pthread signal semantics. */ void @@ -178,42 +179,13 @@ _hurd_sigstate_set_global_rcv (struct hurd_sigstate *ss) } libc_hidden_def (_hurd_sigstate_set_global_rcv) -/* Check whether SS is a global receiver. */ -static int -sigstate_is_global_rcv (const struct hurd_sigstate *ss) -{ - return (_hurd_global_sigstate != NULL) - && (ss->actions[0].sa_handler == SIG_IGN); -} -libc_hidden_def (_hurd_sigstate_delete) - -/* Lock/unlock a hurd_sigstate structure. If the accessors below require - it, the global sigstate will be locked as well. */ -void -_hurd_sigstate_lock (struct hurd_sigstate *ss) -{ - if (sigstate_is_global_rcv (ss)) - __spin_lock (&_hurd_global_sigstate->lock); - __spin_lock (&ss->lock); -} -libc_hidden_def (_hurd_sigstate_lock) - -void -_hurd_sigstate_unlock (struct hurd_sigstate *ss) -{ - __spin_unlock (&ss->lock); - if (sigstate_is_global_rcv (ss)) - __spin_unlock (&_hurd_global_sigstate->lock); -} -libc_hidden_def (_hurd_sigstate_unlock) - /* Retrieve a thread's full set of pending signals, including the global ones if appropriate. SS must be locked. */ sigset_t _hurd_sigstate_pending (const struct hurd_sigstate *ss) { sigset_t pending = ss->pending; - if (sigstate_is_global_rcv (ss)) + if (_hurd_sigstate_is_global_rcv (ss)) __sigorset (&pending, &pending, &_hurd_global_sigstate->pending); return pending; } @@ -225,7 +197,7 @@ libc_hidden_def (_hurd_sigstate_pending) static struct hurd_signal_detail sigstate_clear_pending (struct hurd_sigstate *ss, int signo) { - if (sigstate_is_global_rcv (ss) + if (_hurd_sigstate_is_global_rcv (ss) && __sigismember (&_hurd_global_sigstate->pending, signo)) { __sigdelset (&_hurd_global_sigstate->pending, signo); @@ -241,7 +213,7 @@ sigstate_clear_pending (struct hurd_sigstate *ss, int signo) struct sigaction * _hurd_sigstate_actions (struct hurd_sigstate *ss) { - if (sigstate_is_global_rcv (ss)) + if (_hurd_sigstate_is_global_rcv (ss)) return _hurd_global_sigstate->actions; else return ss->actions; @@ -746,7 +718,7 @@ post_signal (struct hurd_sigstate *ss, __mutex_lock (&_hurd_siglock); for (rss = _hurd_sigstates; rss != NULL; rss = rss->next) { - if (! sigstate_is_global_rcv (rss)) + if (! _hurd_sigstate_is_global_rcv (rss)) continue; /* The global sigstate is already locked. */ diff --git a/sysdeps/hurd/include/hurd/signal.h b/sysdeps/hurd/include/hurd/signal.h index a7b157dd9c..4d94b5ab82 100644 --- a/sysdeps/hurd/include/hurd/signal.h +++ b/sysdeps/hurd/include/hurd/signal.h @@ -6,6 +6,8 @@ extern struct hurd_sigstate *_hurd_self_sigstate (void) __attribute__ ((__const_ libc_hidden_proto (_hurd_self_sigstate) #endif +extern int _hurd_sigstate_is_global_rcv (const struct hurd_sigstate *ss); + #include_next #ifndef _ISOMAC @@ -66,6 +68,16 @@ _hurd_critical_section_lock (void) return ss; } +/* Check whether SS is a global receiver. */ +_HURD_SIGNAL_H_EXTERN_INLINE int +_hurd_sigstate_is_global_rcv (const struct hurd_sigstate *ss) +{ + extern struct hurd_sigstate *_hurd_global_sigstate; + + return (_hurd_global_sigstate != NULL) + && (ss->actions[0].sa_handler == SIG_IGN); +} + _HURD_SIGNAL_H_EXTERN_INLINE void _hurd_critical_section_unlock (void *our_lock) { @@ -88,6 +100,24 @@ _hurd_critical_section_unlock (void *our_lock) __msg_sig_post (_hurd_msgport, 0, 0, __mach_task_self ()); } } + +/* Lock/unlock a hurd_sigstate structure. If the accessors below require + it, the global sigstate will be locked as well. */ +_HURD_SIGNAL_H_EXTERN_INLINE void +_hurd_sigstate_lock (struct hurd_sigstate *ss) +{ + if (_hurd_sigstate_is_global_rcv (ss)) + __spin_lock (&_hurd_global_sigstate->lock); + __spin_lock (&ss->lock); +} + +_HURD_SIGNAL_H_EXTERN_INLINE void +_hurd_sigstate_unlock (struct hurd_sigstate *ss) +{ + __spin_unlock (&ss->lock); + if (_hurd_sigstate_is_global_rcv (ss)) + __spin_unlock (&_hurd_global_sigstate->lock); +} #endif /* defined __USE_EXTERN_INLINES && IS_IN (libc) */ @@ -96,6 +126,7 @@ libc_hidden_proto (_hurd_intr_rpc_mach_msg) libc_hidden_proto (_hurd_thread_sigstate) libc_hidden_proto (_hurd_raise_signal) libc_hidden_proto (_hurd_sigstate_set_global_rcv) +libc_hidden_proto (_hurd_sigstate_is_global_rcv) libc_hidden_proto (_hurd_sigstate_lock) libc_hidden_proto (_hurd_sigstate_pending) libc_hidden_proto (_hurd_sigstate_unlock) @@ -103,5 +134,8 @@ libc_hidden_proto (_hurd_sigstate_delete) #endif #ifdef _HURD_SIGNAL_H_HIDDEN_DEF libc_hidden_def (_hurd_self_sigstate) +libc_hidden_def (_hurd_sigstate_is_global_rcv) +libc_hidden_def (_hurd_sigstate_lock) +libc_hidden_def (_hurd_sigstate_unlock) #endif #endif diff --git a/sysdeps/mach/hurd/x86/Makefile b/sysdeps/mach/hurd/x86/Makefile index 27c4b06590..97e3287c87 100644 --- a/sysdeps/mach/hurd/x86/Makefile +++ b/sysdeps/mach/hurd/x86/Makefile @@ -18,4 +18,5 @@ endif ifeq ($(subdir),mach) # Avoid SSE&MMX to avoid __sigreturn2 thrashing it CFLAGS-RPC_mach_port_mod_refs.c = -mno-sse -mno-mmx +CFLAGS-RPC_gsync_wake.c = -mno-sse -mno-mmx endif