From patchwork Fri Aug 13 10:43:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 44658 X-Patchwork-Delegate: joseph@codesourcery.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D789388C030 for ; Fri, 13 Aug 2021 10:44:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D789388C030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628851446; bh=+C2K9pzSpzBoqMeM0ywCAC6ukzhNprMaGdgy+56+MRo=; h=Subject:To:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ifRefo/SxbGjxhn6l+V5azpKKaMtcYZ5EE7ya3hzE+3qS7BSHID7x1EXFBTgJwSSM S+xu/Wi1mixWQUntkpcpWozTHpg8Eg8axFhNf8R3W2M7eJ5IFNBEI0edBCdXYxXWP3 pk+xaXJpn8NlxgUsLH0DqB8RXvJvOwS1rljTnLxM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mengyan1223.wang (mengyan1223.wang [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 934E4385B837 for ; Fri, 13 Aug 2021 10:43:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 934E4385B837 Received: from [IPv6:240e:35a:10bb:ac00:dc73:854d:832e:2] (unknown [IPv6:240e:35a:10bb:ac00:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id D181365AAC; Fri, 13 Aug 2021 06:43:31 -0400 (EDT) Message-ID: Subject: [PATCH] mips: increase stack alignment in clone to match the ABI To: Joseph Myers Date: Fri, 13 Aug 2021 18:43:20 +0800 In-Reply-To: References: <07cf2ef7f47070979089f880d91a0369c4efa978.camel@mengyan1223.wang> <97d59c143b34c620f5883670a21ae6286414fff6.camel@mengyan1223.wang> User-Agent: Evolution 3.40.3 MIME-Version: 1.0 X-Spam-Status: No, score=-3039.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Cc: libc-alpha@sourceware.org Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Hi Joseph, Sorry for this, but I have to admit I've made an error in the previous patch. In MIPS documentations one "word" is defined 32-bit (4-byte), so a "doubleword" is 8-byte and a "quadword" is 16-byte. I misinterpreted "doubleword" as a "dword" we normally uses for 4-byte, so the alignment is actually insufficient. I'm not sure why "tst-misaligned-stack" passed with the previous problematic patch on my board. Maybe it was pure luck, or my CPU used to test the patch supports some non-standard unaligned access. The following patch should fix this: In "mips: align stack in clone [BZ #28223]" (commit 1f51cd9a860ee45eee8a56fb2ba925267a2a7bfe) I made a mistake: I misbelieved one "word" was 2-byte and "doubleword" should be 4-byte. But in MIPS ABI one "word" is defined 32-bit (4-byte), so "doubleword" is 8-byte [1], and "quadword" is 16-byte [2]. [1]: "System V Application Binary Interface: MIPS(R) RISC Processor Supplement, 3rd edition", page 3-31 [2]: "MIPSpro(TM) 64-Bit Porting and Transition Guide", page 23 --- sysdeps/unix/sysv/linux/mips/clone.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S index 43a5ad3a40..81d814ba4d 100644 --- a/sysdeps/unix/sysv/linux/mips/clone.S +++ b/sysdeps/unix/sysv/linux/mips/clone.S @@ -57,9 +57,9 @@ NESTED(__clone,4*SZREG,sp) /* Align stack to 4/8 bytes per the ABI. */ #if _MIPS_SIM == _ABIO32 - li t0,-4 -#else li t0,-8 +#else + li t0,-16 #endif and a1,a1,t0