From patchwork Mon Jan 8 02:35:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 185792 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp798582dyq; Sun, 7 Jan 2024 18:36:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IHc6CMSFo5UOlwwquIhRGG71oIPGhgnzLmbUMttS2O4YPNCgnN0jiCUOssjsCq7fC+KWwCJ X-Received: by 2002:a05:622a:11c3:b0:429:89e6:30ef with SMTP id n3-20020a05622a11c300b0042989e630efmr4708104qtk.86.1704681376549; Sun, 07 Jan 2024 18:36:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704681376; cv=pass; d=google.com; s=arc-20160816; b=dPrY8d4DtstnwQLUWPbSh6pA4agfuj8Yw5Y72TUtafRBe0e4jPYI0MzOWcE63fhDYs lPrwHdFupsmO3R8kk9qKhbErXSFkCgQWS5QVhMEi2NqpZc5pXi3iw5sj0vnjQvFdlkp/ GppvP14G1T2/CW0RAqxaBwnXZps10DMFdyNSJ3tESq+HLPcyBTgvwTY1V2maBL6p8fU0 eZZ+SsbFL1WQvL9q/AJD76sefgAGKVt4Th/0H3HVPvDpHmSV9fUtp4OQU3GQ7HDufoQL +S5/d+O4TfKUseQ9mSyFouu+cWoOFR2vx3f/4xcPsaeIEl1szKXdm6Z8O3a0dykJlE/f V4Fw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding:cc:to :subject:from:content-language:user-agent:mime-version:date :message-id:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=MUwJ1vBCQh8Gavz6mPgSN+ZIEpyvcmUCHAz4hYIGvMI=; fh=MuqH6WRrVWe5EE7zw2R76JZJs0LkxFUH/OaAovuJwFA=; b=XNu8I3jbTcCj8Gm58zANlzBLZ9hcNXDVBS+wLKZb0/drjXtJC32ZlmoAzTlfSVwANC 3vbrt6mEbJ+RNTKsOxN7KzKRM1ibIX+XlIRl6aCXpkGu1SDrN/bCGa1u5sh3o8Y6+0za RN9UsEEUFO1bQn51/+Uh3cKpfQFgMrhfp5uQWCx/GlWpkh0The5406gP0OaV2Z0Y+Vbw 7Pd32ey2pGt88ycRRgVoSumg8DlONgL0h0dj23rx2K99ud3qaBbZHuhilCMVRCvN71E2 W8XIVtwLJrnQ42Nvzx7ZYJvvFGlUbVRjYsuApLF0UDdatQHQ44HEWgY2cyLdlMEKEkwS /OkQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=G8KG5Tzn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id cc10-20020a05622a410a00b0042552a493fcsi4046338qtb.42.2024.01.07.18.36.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 18:36:16 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=G8KG5Tzn; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 37B243858CDA for ; Mon, 8 Jan 2024 02:36:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id 6F1583858D35 for ; Mon, 8 Jan 2024 02:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6F1583858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6F1583858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704681329; cv=none; b=Z9DICJnSJe0err19/gqxAPuepfXf7TXzY3KCOWOE8w3Ulz5u5apI8u000E73XPGLU38eIdeMuJNY26CNm4Z4MAMEa4yK8rlBm3AWkFljqRKKnvVi/Kr1TGm8fS14igkFT+nTucMOhpCia9ZCtSAqOf3sNZRtAkVnGZnnESsoZL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704681329; c=relaxed/simple; bh=29hpQknreNvZoXDp/5ad7h8sNyPwGyU3/c8BaasBf+k=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=T9klQ6aMhaidfwkxUmTsvsJehlehU1zMLMop0RfIlxAtUCiVHn+d/E62QKx0UHSh4679ixQNTM4FAIy3Y5O042FHDhTzHGSlw+vtkVKKav7O+4OfydE0TrHpdFnnh/E9aD+lN10drpUzVGEie7fjInMOnEDXYYDOj//eI0zsQZY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353728.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 407KY7ks031174; Mon, 8 Jan 2024 02:35:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : from : subject : to : cc : content-type : content-transfer-encoding; s=pp1; bh=MUwJ1vBCQh8Gavz6mPgSN+ZIEpyvcmUCHAz4hYIGvMI=; b=G8KG5TznnZ2bt9EX4zzoJ/Ig76cxexpartN19UppA3TSebTyFgA0yBTUwYOkSJiIiNTe ugKPOYa9fVwc8NIAjOw57a3GTYvH3d+LYbq4oxdYKg78pB4LrgY5xgPoPjeIqiNXX1Ov Ravw2TCI+NOWQwIRCvDwZBk2eAYU3ulJpcMLy23xAqrEsXQoX7qILs9D0D7MLeN1p7Ac D3zyChE71RcxQKHG7IBpetJ6EmM8ZvJ7PNUXjAwl3bwyInhXTQNMAJUiCq9EFEBMesXx FZu1rlM2dzFHU6MEdq9NGtBU6WyTipHZvb7j6g0Oi+jvQnWjkRsbNJIaOCcVNfNkjnuW 4Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vf1qehx1u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:35:16 +0000 Received: from m0353728.ppops.net (m0353728.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 4081x6Fj013057; Mon, 8 Jan 2024 02:35:16 GMT Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vf1qehx1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:35:15 +0000 Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 4082BrCH004395; Mon, 8 Jan 2024 02:35:14 GMT Received: from smtprelay04.fra02v.mail.ibm.com ([9.218.2.228]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfjpkdc3d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Jan 2024 02:35:14 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay04.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4082ZCXL14942622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 8 Jan 2024 02:35:12 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2DF4F20040; Mon, 8 Jan 2024 02:35:12 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 53F9F20043; Mon, 8 Jan 2024 02:35:09 +0000 (GMT) Received: from [9.197.233.114] (unknown [9.197.233.114]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 8 Jan 2024 02:35:08 +0000 (GMT) Message-ID: <91d2c107-0168-791b-b5fa-de21c2345f84@linux.ibm.com> Date: Mon, 8 Jan 2024 10:35:07 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Content-Language: en-US From: "Kewen.Lin" Subject: [PATCH] strub: Only unbias stack point for SPARC_STACK_BOUNDARY_HACK [PR113100] To: GCC Patches Cc: Alexandre Oliva , Richard Biener , Jakub Jelinek , Peter Bergner , Segher Boessenkool , Jeff Law , Richard Sandiford X-TM-AS-GCONF: 00 X-Proofpoint-GUID: p4GLrG7PTCeAiKyNApyYevSyGayWwH18 X-Proofpoint-ORIG-GUID: CEufGd2XIXr13SWgMECN6m4Ftr7zyAxG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-07_15,2024-01-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 impostorscore=0 mlxlogscore=999 bulkscore=0 adultscore=0 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401080016 X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787487979060099838 X-GMAIL-MSGID: 1787487979060099838 Hi, As PR113100 shows, the unbiasing introduced by r14-6737 can cause the scrubbing to overrun and screw some critical data on stack like saved toc base consequently cause segfault on Power. By checking PR112917, IMHO we should keep this unbiasing guarded under SPARC_STACK_BOUNDARY_HACK (TARGET_ARCH64 && TARGET_STACK_BIAS), similar to some existing code special treating SPARC stack bias. Bootstrapped and regtested on x86_64-redhat-linux and powerpc64{,le}-linux-gnu. All reported failures in PR113100 are gone. I also expect the culprit commit can affect those ports with nonzero STACK_POINTER_OFFSET. Is it ok for trunk? BR, Kewen ----- PR middle-end/113100 gcc/ChangeLog: * builtins.cc (expand_builtin_stack_address): Guard stack point adjustment with SPARC_STACK_BOUNDARY_HACK. --- gcc/builtins.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.39.3 diff --git a/gcc/builtins.cc b/gcc/builtins.cc index 125ea158ebf..9bad1e962b4 100644 --- a/gcc/builtins.cc +++ b/gcc/builtins.cc @@ -5450,6 +5450,7 @@ expand_builtin_stack_address () rtx ret = convert_to_mode (ptr_mode, copy_to_reg (stack_pointer_rtx), STACK_UNSIGNED); +#ifdef SPARC_STACK_BOUNDARY_HACK /* Unbias the stack pointer, bringing it to the boundary between the stack area claimed by the active function calling this builtin, and stack ranges that could get clobbered if it called another @@ -5476,7 +5477,9 @@ expand_builtin_stack_address () (caller) function's active area as well, whereas those pushed or allocated temporarily for a call are regarded as part of the callee's stack range, rather than the caller's. */ - ret = plus_constant (ptr_mode, ret, STACK_POINTER_OFFSET); + if (SPARC_STACK_BOUNDARY_HACK) + ret = plus_constant (ptr_mode, ret, STACK_POINTER_OFFSET); +#endif return force_reg (ptr_mode, ret); }