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: 1516623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: 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: 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=YJ767MZZ; 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GmKtB4SlLz9sX3 for ; Fri, 13 Aug 2021 20:44:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4880A388C004 for ; Fri, 13 Aug 2021 10:43:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4880A388C004 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628851439; 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=YJ767MZZ/UE4ntcHF29RgKXY8/WUSeXL53PomTfzxZY/UesTdx1PYysgjNfdYfEp+ CV1fCGq06AwcMqxdp/SrxRgR7mfkWOBh+6wO4Ljumoa/jB/goKL7eagHV59zzzSZku N3kyM2r7UkZIlJbcXB6qIn6Ah/5OcLSYevQW/M2Q= 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+incoming=patchwork.ozlabs.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