From patchwork Mon Mar 6 09:27:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 64528 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1741800wrd; Mon, 6 Mar 2023 01:28:04 -0800 (PST) X-Google-Smtp-Source: AK7set/NLVHWsAUlH+bz6TmVlhywTPEabcILUn8MxyPE2aB7E04HFCh0HTcK1bv+7wY+eagVtdHg X-Received: by 2002:aa7:df93:0:b0:4ab:5ce9:9f83 with SMTP id b19-20020aa7df93000000b004ab5ce99f83mr9972918edy.23.1678094884348; Mon, 06 Mar 2023 01:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678094884; cv=none; d=google.com; s=arc-20160816; b=N9Zr/DbHWcJG6j89FwvUAISI0CR6OR4oUmuCVmwCzJDqbmg6QrJEI4MqExikpGPKPU fG0dP/LjBTJadUVsDnKHS+Vuw48OaS/2UcATgEl2RonhCpmNhh1B4HY+sDw0ifu/q3W+ 9B03Bk1q7XgeKqDjRjsqvadxbmRudvNMMfSiGak8bSg33EmgiRJ0n9TA9vApiRNbjiUq aLG3FmCoQ8nAp40jsa+wiqAPsDbYS0s+5EaYewyAi1utxXgQ0w2uOkmEXsVytVkSZphL YlR0p3NHpAkJqRDuJg9CqcUh11SBsjrerAKccvRVjmr9MSQZdXzKIf5MGpHFK3RK/N3N d6qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:subject:cc:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=7bNEBZMLINQiWKo1wQTIyr/bQ3Z4xdGdqn7gD/JoEPI=; b=lGetNaSTO5Hw3ImeaDspLrHkS5nQhNLnT3gew6GQokgomSz8uWzVdRGJZvNS3KPyk3 /CYyq2sDc9mgENKvUAT8dVsPFv5GgEkuhcrkqpOkWTodbJchx1FgyESp5BcwRWw7/T/D K7qMagyN0skuV3inGBJ2UqO/eADzJjkkh+YeiYIMugtv8S18UUMc6pctsS+5w+p0DmKV ZAKzuv12Uyhy+SVVBm7IjV9LycOFslpjqv9WR1wge4QFBUqRY0s7h/Am1heHdSET1eXX RTOvZ+v4LPrRl5lQX5Gjwf2CetRKEtGAPXWMXW9+UHqYWg9iLWLOa845z7jlmzEeC85k WhpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=NH0B9WYb; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i2-20020aa7c702000000b004acbde7ddd9si3253714edq.378.2023.03.06.01.28.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 01:28:04 -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=@gcc.gnu.org header.s=default header.b=NH0B9WYb; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 31408385B51E for ; Mon, 6 Mar 2023 09:28:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31408385B51E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678094883; bh=7bNEBZMLINQiWKo1wQTIyr/bQ3Z4xdGdqn7gD/JoEPI=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NH0B9WYbecvcCcjCViET/5w7LoCFOSWYJpTEHc0qNvX1sN+0JcZpZU4LRxdlN4ivB vO8xVy6HM7ZZy4s9aoS+FEoVutEvwNtkbACIDs6HkKbxRwX0OODrqpPBoX0v9THXs4 Uobza4VrhLeR0jzTTYJWgjqSsjJX2tYLK47VVHsQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id BE7D53858D39 for ; Mon, 6 Mar 2023 09:27:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE7D53858D39 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3268ZSiq032062; Mon, 6 Mar 2023 09:27:18 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p4x1hgwp1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 09:27:18 +0000 Received: from m0098416.ppops.net (m0098416.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3269M215023535; Mon, 6 Mar 2023 09:27:17 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3p4x1hgwne-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 09:27:17 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 325JulJp005927; Mon, 6 Mar 2023 09:27:15 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3p418ctfx7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Mar 2023 09:27:15 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3269RDDj29819342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Mar 2023 09:27:13 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EBE4E2004F; Mon, 6 Mar 2023 09:27:12 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D9A1820043; Mon, 6 Mar 2023 09:27:10 +0000 (GMT) Received: from [9.197.230.12] (unknown [9.197.230.12]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Mar 2023 09:27:10 +0000 (GMT) Message-ID: Date: Mon, 6 Mar 2023 17:27:09 +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 To: GCC Patches Cc: Segher Boessenkool , David Edelsohn , AlanM , Peter Bergner Subject: [PATCH] rs6000, libgcc: Fix bump size for powerpc64 elfv1 ABI [PR108727] X-TM-AS-GCONF: 00 X-Proofpoint-GUID: kVmpWHPOj1SXMY3NDgFD5gz6-VhwxAs- X-Proofpoint-ORIG-GUID: Ih8fsOGI2teReLbq5y8yxcx2_ldLDyQD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-06_02,2023-03-03_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxlogscore=932 spamscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 impostorscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303060078 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "Kewen.Lin via Gcc-patches" From: "Kewen.Lin" Reply-To: "Kewen.Lin" Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759610021354037055?= X-GMAIL-MSGID: =?utf-8?q?1759610021354037055?= Hi, As PR108727 shows, when cleanup code called by the stack unwinder calls function _Unwind_Resume, it goes via plt stub like: function 00000000.plt_call._Unwind_Resume: => 0x0000000010003580 <+0>: std r2,40(r1) 0x0000000010003584 <+4>: ld r12,-31760(r2) 0x0000000010003588 <+8>: mtctr r12 0x000000001000358c <+12>: ld r2,-31752(r2) 0x0000000010003590 <+16>: cmpldi r2,0 0x0000000010003594 <+20>: bnectr+ 0x0000000010003598 <+24>: b 0x100031a4 <_Unwind_Resume@plt> It wants to save TOC base (r2) to r1 + 40, but we only bump the stack segment by 32 bytes as follows: stdu %r29,-32(%r3) It means the access is out of the stack segment allocated by __generic_morestack, once the touch area isn't writable like this failure shows, it would cause segment fault. So fix the bump size with one reasonable value PARAMS. Bootstrapped and regtested on powerpc64-linux-gnu P{8,9} and powerpc64le-linux-gnu P{8,9,10}. Alan ack'ed this in that PR, I'm going to push this soon. BR, Kewen ----- PR libgcc/108727 libgcc/ChangeLog: * config/rs6000/morestack.S (__morestack): Use PARAMS for new stack bump size. --- libgcc/config/rs6000/morestack.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.39.2 diff --git a/libgcc/config/rs6000/morestack.S b/libgcc/config/rs6000/morestack.S index 5e7ad133303..f2fea6abb10 100644 --- a/libgcc/config/rs6000/morestack.S +++ b/libgcc/config/rs6000/morestack.S @@ -205,12 +205,12 @@ ENTRY0(__morestack) bl JUMP_TARGET(__generic_morestack) # Start using new stack - stdu %r29,-32(%r3) # back-chain + stdu %r29,-PARAMS(%r3) # back-chain mr %r1,%r3 # Set __private_ss stack guard for the new stack. ld %r12,NEWSTACKSIZE_SAVE(%r29) # modified size - addi %r3,%r3,BACKOFF-32 + addi %r3,%r3,BACKOFF-PARAMS sub %r3,%r3,%r12 # Note that a signal frame has $pc pointing at the instruction # where the signal occurred. For something like a timer