From patchwork Mon May 15 08:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1781174 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=SV5Nygsx; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKXhc3ccnz20dX for ; Mon, 15 May 2023 18:33:52 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5B0323853D35 for ; Mon, 15 May 2023 08:33:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5B0323853D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684139630; bh=JX6S7gJdO09nvRGFcT9btqxQ/L+WQ/o5IdBXZfCXNIw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=SV5Nygsxouu48Lh6BXb99kexWAvxozMS5rYyqW0+vIVX2SHsZM7sm2FYsiz9PoEKV BqztwrzVZJdWak/fwSR7WqmfvcbyVK9i9D6K8d/4MKS6loLYuLOZ5x/O65/oxTeQTK 1EnBzkgFWh9tll5JB2//IAlNbkBVX3KxecGKlzuY= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 28D84385735A for ; Mon, 15 May 2023 08:33:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28D84385735A Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2ac8ee9cf7aso114432581fa.2 for ; Mon, 15 May 2023 01:33:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684139606; x=1686731606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JX6S7gJdO09nvRGFcT9btqxQ/L+WQ/o5IdBXZfCXNIw=; b=gA6POwE5mQEDgwBe57VmFcIbfEZ6q1f97+SrKY+dtGyFlskywp7lHd3UXIysl9V2PS PALsxPci63Z943u14Mxc0B3rJz8fYdOLvPm1RviFb0XekotbjcaKMDI9r8gdrYsO7sB3 P7AE3gWVo83k+BVvk2LYfIMfxF1jvodDZPofC5L2aFjLPBxbBIbjpBhaV9pO1xSJjL8F dyDGTzczcwW/Cd9H2tTqFYV3piYU3orzlB8Ez5JnbGbGDcDPsVcj2Xp/SIIHIC2YUzwC 7FWyE8bLOHP9eUlF3SmdwRAB+xDyTiwx7ADpSs77t7ajPSrOX3V7+kM+SuhMw5THStfK vchw== X-Gm-Message-State: AC+VfDx6mJKZteWAp9eynTA5vwgZVfjFZBhgqnfCjLwzBG0MGvfUn1KF 5w2H5g1v4gH/hig0HUqwYZ1VGp3qJkM= X-Google-Smtp-Source: ACHHUZ7O72GaWQjMYbw8la3spbZb63vrDRQfJ92bem7SZ2M+XzrqVgtQG6TBUu3liA3Is2mKduNJlA== X-Received: by 2002:a2e:87cc:0:b0:2a7:b168:9e87 with SMTP id v12-20020a2e87cc000000b002a7b1689e87mr6481681ljj.18.1684139606029; Mon, 15 May 2023 01:33:26 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id p3-20020a05651238c300b004f251e73fc5sm2510677lft.30.2023.05.15.01.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 01:33:25 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Cc: Bruno Haible Subject: [PATCH 1/4] hurd: Fix aligning signal stack pointer Date: Mon, 15 May 2023 11:33:20 +0300 Message-Id: <20230515083323.1358039-2-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515083323.1358039-1-bugaevc@gmail.com> References: <20230515083323.1358039-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fixes 60f9bf974694d50daf58d46347b06a5975ac5ddd "hurd: Port trampoline.c to x86_64" Checked on x86_64-gnu. Reported-by: Bruno Haible Signed-off-by: Sergey Bugaev --- 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 e13c5d85..19bddad8 100644 --- a/sysdeps/mach/hurd/x86/trampoline.c +++ b/sysdeps/mach/hurd/x86/trampoline.c @@ -200,7 +200,7 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action /* 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 & 16UL); + sigsp = (void *) ((uintptr_t) sigsp & ~15UL); #endif /* Push the arguments to call `trampoline' on the stack. */ From patchwork Mon May 15 08:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1781177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=cZKHcDcm; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKXht141zz20dX for ; Mon, 15 May 2023 18:34:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B691385735C for ; Mon, 15 May 2023 08:34:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B691385735C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684139644; bh=ElD5vij6z0NOC9LExmvj9x6QlpyxmJWP2tS6D2b6jqQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=cZKHcDcmAfExIsHfBFN96/1AwenLwzBkDAOvOZgSjVTyqjjWDQEFVOhKBjQ2gKMTc 9e1hU5nzrIiItNDdkJv08iOqopLtVMTiuIBNMoWLZrs+kMGQ8SPKB5dh5G0EpLy9AG myR0/1PHgQglfn3wJ66iA1I1Ec3FMIfnDGNahr0s= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id C917F385701E for ; Mon, 15 May 2023 08:33:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C917F385701E Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2ac7de2b72fso136039261fa.1 for ; Mon, 15 May 2023 01:33:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684139607; x=1686731607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ElD5vij6z0NOC9LExmvj9x6QlpyxmJWP2tS6D2b6jqQ=; b=U8OBhnzzx/DdBZ60K90yineilzq7Q0WpnmB+By9WAEfLiRwKwonxIocwAWDrF+6UoK LfJNYLouAE4gEaKOrcjCC+dejGAjMRMIqUbUcUJ+Y8vlHhrw62d4YA912HoQKacvBmKJ AkqGJ1QjparlwoVhiJ9W/l2PT0W2eTbkPplnaw9E3yI/ZTOSAuKDrT8B3pfLdXTy4LOV oRtgdJbLwOlHvavE/XqVD3+NmaSfclL0kp6VNpr+fHumdlUrPbL7UNXKWC4tlPDWUOVM Ids6FNxOm+nCz008KuAJKNXrtDqE2xkTSCpRTeEdIlD/oOkcltpRs/WAk9V4P1HVKgFW I9CA== X-Gm-Message-State: AC+VfDwS28jBfy7jlO2gTfMihb20V8Xi0mQXFrCtG5xckZiTwNkbHWyj OnTx5q8OY/Gp34U34B2o7Eaiq4Fuzmc= X-Google-Smtp-Source: ACHHUZ4M5y6wC0ngCfxkbEU+F0jiVLztJ3gXOdSJpQatH+16yRzm8PYl/8dRMaLXz2jggiXQO/eGsg== X-Received: by 2002:ac2:4825:0:b0:4f1:47be:8db6 with SMTP id 5-20020ac24825000000b004f147be8db6mr7055887lft.56.1684139606820; Mon, 15 May 2023 01:33:26 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id p3-20020a05651238c300b004f251e73fc5sm2510677lft.30.2023.05.15.01.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 01:33:26 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 2/4] hurd: Align signal stack pointer after allocating stackframe Date: Mon, 15 May 2023 11:33:21 +0300 Message-Id: <20230515083323.1358039-3-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515083323.1358039-1-bugaevc@gmail.com> References: <20230515083323.1358039-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" sizeof (*stackframe) appears to be divisible by 16, but we should not rely on that. So make sure to leave enough space for the stackframe first, and then align the final pointer at 16 bytes. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86/trampoline.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c index 19bddad8..1f92064e 100644 --- a/sysdeps/mach/hurd/x86/trampoline.c +++ b/sysdeps/mach/hurd/x86/trampoline.c @@ -196,15 +196,14 @@ _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. */ - sigsp -= sizeof (*stackframe); stackframe = sigsp; if (_hurdsig_catch_memory_fault (stackframe)) From patchwork Mon May 15 08:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1781181 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=G9hUqKEb; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKXjZ3jXYz20dX for ; Mon, 15 May 2023 18:34:42 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84D9A3854151 for ; Mon, 15 May 2023 08:34:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84D9A3854151 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684139680; bh=aqUWVNg9Zy+b/druiVQeLoQeC8F5TxGEIKbVAFo0Opw=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=G9hUqKEbIOJKAOsORM7J8gOPLZS5UGBevdtuz0vyaXJCrtv+cXAKXKaKHkDNVJaqC lnfltg3uwRydlvD+tr6gd7mMPwvzGrbUbSL0ncg0OaYk1pXwT+wZpNrlFmsQsGd79v ak4bcqll0S/F+rllvXtm6L0aHaolEzlBw2mPcAXA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id CF1813856DD5 for ; Mon, 15 May 2023 08:33:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF1813856DD5 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-4f383d6f2f8so567750e87.2 for ; Mon, 15 May 2023 01:33:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684139608; x=1686731608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aqUWVNg9Zy+b/druiVQeLoQeC8F5TxGEIKbVAFo0Opw=; b=Gp+jnRxRkkWog/ZcO7CwokHYmiG3yh93FgYcpkgY5AoPCwoKvQb+WDbZCxXioZ/zQ/ lPeuQcQQ9m9CLSVSmIJ+ZsTalCJUrwwalEmRhmtbvyWMOYC78WiH+o/rfqtT94SRPg5N 9CPKTRgcmGmMghTXhhfZ/YafsQc6w2wYRK+LWS0K452C8o8t1cjWmqDuTXrNHP+OL0co LCqB2az+m69fec+TSp1x45Ixn2TQSv907Dw6/4tAice/qvXA6EnsPlwzja4QkJQWGL15 iIa4c4WvM2u2bVVLf48/4Id5mspxRfj9d0sBD4I1gRfO8Au0ACMfpWrl/Gl/skgT7bxW hbiw== X-Gm-Message-State: AC+VfDwOqJHIf40zw4J/VEbLMroFSzuHDClwgGnqiz7aOWKsk/ssbV+E cv3flzrL7nLOZo/jqObLrIvTAYcvEdU= X-Google-Smtp-Source: ACHHUZ74AKYhbj7FL8QcLPVThf/FhF0e1CgttMFxTLhN+NqGFS3KSlELeLS/2sRLNyWwDptrKHfWRw== X-Received: by 2002:ac2:5293:0:b0:4eb:42b7:8c18 with SMTP id q19-20020ac25293000000b004eb42b78c18mr6177273lfm.53.1684139607734; Mon, 15 May 2023 01:33:27 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id p3-20020a05651238c300b004f251e73fc5sm2510677lft.30.2023.05.15.01.33.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 01:33:27 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 3/4] hurd: Fix sc_i386_thread_state layout Date: Mon, 15 May 2023 11:33:22 +0300 Message-Id: <20230515083323.1358039-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515083323.1358039-1-bugaevc@gmail.com> References: <20230515083323.1358039-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" The real i386_thread_state Mach structure has an alignment of 8 on x86_64. However, in struct sigcontext, the compiler was packing sc_gs (which is the first member of sc_i386_thread_state) into the same 8-byte slot as sc_error; this resulted in the rest of sc_i386_thread_state members having wrong offsets relative to each other, and the overall sc_i386_thread_state layout mismatching that of i386_thread_state. Fix this by explicitly adding the required padding members, and statically asserting that this results in the desired alignment. The same goes for sc_i386_float_state. Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86/trampoline.c | 6 ++++++ sysdeps/mach/hurd/x86_64/bits/sigcontext.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/sysdeps/mach/hurd/x86/trampoline.c b/sysdeps/mach/hurd/x86/trampoline.c index 1f92064e..6318c952 100644 --- a/sysdeps/mach/hurd/x86/trampoline.c +++ b/sysdeps/mach/hurd/x86/trampoline.c @@ -242,11 +242,17 @@ _hurd_setup_sighandler (struct hurd_sigstate *ss, const struct sigaction *action /* struct sigcontext is laid out so that starting at sc_gs mimics a struct i386_thread_state. */ + _Static_assert (offsetof (struct sigcontext, sc_i386_thread_state) + % __alignof__ (struct i386_thread_state) == 0, + "sc_i386_thread_state layout mismatch"); 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)); diff --git a/sysdeps/mach/hurd/x86_64/bits/sigcontext.h b/sysdeps/mach/hurd/x86_64/bits/sigcontext.h index 3a3b34bc..63960544 100644 --- a/sysdeps/mach/hurd/x86_64/bits/sigcontext.h +++ b/sysdeps/mach/hurd/x86_64/bits/sigcontext.h @@ -46,6 +46,11 @@ struct sigcontext /* Error code associated with this signal (interpreted as `error_t'). */ int sc_error; + /* Make sure the below members are properly aligned, and not packed + together with sc_error -- otherwise the layout won't match that of + i386_thread_state. */ + int sc_pad1; + /* All following members are machine-dependent. The rest of this structure is written to be laid out identically to: { @@ -86,6 +91,9 @@ struct sigcontext long sc_ursp; /* This stack pointer is used. */ int sc_ss; /* Stack segment register. */ + /* Make sure the below has the same layout as i386_float_state. */ + int sc_pad2; + /* Following mimics struct i386_float_state. Structures and symbolic values can be found in . */ #define sc_i386_float_state sc_fpkind From patchwork Mon May 15 08:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Bugaev X-Patchwork-Id: 1781182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=FoelAo9+; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QKXjf17HMz20dX for ; Mon, 15 May 2023 18:34:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 13D243852769 for ; Mon, 15 May 2023 08:34:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 13D243852769 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684139684; bh=A+hG7C0Fs480gLQnizDkZMUN18eXwIKlcGTYHF/uS7M=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FoelAo9+eVVjJNjCJ8LqSj1eNMWSIyXj46EjW34zvfrtHsMu+swNLEajt+y5zZHJ+ PudKfjsZ3T70psHegHV0WKZDPMs3VE2wyZiBLROiTTzTPKklb0G34excnFYdvI5UuH yL/XinWXEPwcjCg1TyFCbFB/tAqyflT+aXLktgU8= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by sourceware.org (Postfix) with ESMTPS id 87319385B508 for ; Mon, 15 May 2023 08:33:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 87319385B508 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4ec8eca56cfso14294474e87.0 for ; Mon, 15 May 2023 01:33:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684139609; x=1686731609; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=A+hG7C0Fs480gLQnizDkZMUN18eXwIKlcGTYHF/uS7M=; b=Rg1hkEPvAm4cnIppWAfEed0+GTpzysBKPoiXvspZNvbwRI4FeWT9dc/9s4KrmhDJ8D i6KYskCATlWNCBbNOvGoKnCZIVmFzsS5zzRkALAbeFoebbAAFKHD/lJdsgZHTjZireLX VHGgZQ7Q4ifb2AugekSK5g2H/reJxlNNibQu+Z5GPVQg21HN49hCMFkULL4LV9J9c3J1 ZmVhxnX0/nGBjwzREQyoq9aT0p+X84/ef1SHoGCe9HBVB9ldanJlux0cCYg0OT9aFWIl bZzK71r73sLofFjulgNTCXIf5k8iaEvET5PKgnV1ygA8RCG94x2j9EnyBEFAai78/Jna Sxiw== X-Gm-Message-State: AC+VfDz2Re8KgbLC38d91gznYaezWYD9MUKumBV4hIIDLI1bopBOLPJB m8sV9ImfRy1KNXUR9XVk7hMp9dyZsjI= X-Google-Smtp-Source: ACHHUZ4O7CBgp01JYQS431jBsx3gK6ji2rKE8yyWsDxp7j1eKhTdMZIp1ILwTzlxmOntZORIJX27pA== X-Received: by 2002:ac2:5d48:0:b0:4f1:2236:6d2a with SMTP id w8-20020ac25d48000000b004f122366d2amr5731484lfd.53.1684139608655; Mon, 15 May 2023 01:33:28 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id p3-20020a05651238c300b004f251e73fc5sm2510677lft.30.2023.05.15.01.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 01:33:28 -0700 (PDT) To: libc-alpha@sourceware.org, bug-hurd@gnu.org Subject: [PATCH 4/4] hurd: Fix computing user stack pointer Date: Mon, 15 May 2023 11:33:23 +0300 Message-Id: <20230515083323.1358039-5-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515083323.1358039-1-bugaevc@gmail.com> References: <20230515083323.1358039-1-bugaevc@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Sergey Bugaev via Libc-alpha From: Sergey Bugaev Reply-To: Sergey Bugaev Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fixes b574ae0a2876ee94e4fe617f878407bf818c2df0 "hurd: Implement sigreturn for x86_64" Checked on x86_64-gnu. Signed-off-by: Sergey Bugaev --- sysdeps/mach/hurd/x86_64/sigreturn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/mach/hurd/x86_64/sigreturn.c b/sysdeps/mach/hurd/x86_64/sigreturn.c index 82247e3c..5d3a4d31 100644 --- a/sysdeps/mach/hurd/x86_64/sigreturn.c +++ b/sysdeps/mach/hurd/x86_64/sigreturn.c @@ -126,7 +126,7 @@ __sigreturn (struct sigcontext *scp) copy the registers onto the user's stack, switch there, pop and return. */ - uintptr_t *usp = (uintptr_t *) scp->sc_ursp - 128; + uintptr_t *usp = (uintptr_t *) (scp->sc_ursp - 128); *--usp = scp->sc_rip; *--usp = scp->sc_rfl;