From patchwork Thu Oct 17 05:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Monga X-Patchwork-Id: 99066 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 8C41D3858C2B for ; Thu, 17 Oct 2024 05:25:58 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id D201B3858D33 for ; Thu, 17 Oct 2024 05:25:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D201B3858D33 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 D201B3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729142734; cv=none; b=rrkZ38uA7uOR8jT1jS/nVZJ5t/EY1H0M1aaK7pooIIDU7orU+u5mQd89yH9/1HR252S0K1ehCkzkVTJSFS7u2qBmHvjP8TktIfCUp6ljZQWsziC48HOFmKbnSNMaJGZ4IpaAzBsCJ3KjkuTwbv9pMCZ3iiOJUvHzVHBlrfev77E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729142734; c=relaxed/simple; bh=KPpSWfXNSywLyt6C8kqxpxlunUiGvxcvtVljWb2aXus=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=cE4WkRomp+M0C6IeMnZXSEFXh+qUrXP2NNgvHNKJZUTt79lymK41JCG0i8cjkx3v0m0JsRt/vNrfCO3pre3aELvwguvCGxOUiDJ8aeO//9s942zoIwRsiHcGoTU2zdK/KCTYHQFFh6Z2ySAXEx6V7K+FaAG8PcrEkOsJIGq3CTU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49H1nLmB018434 for ; Thu, 17 Oct 2024 05:25:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=pp1; bh=ReOAOi2kRyWTxtFTG0FV827C41GVR55Iwq2aeEb+y iw=; b=olaNcnQ08/9MeWAH04jpOuHD54kcjzupodGGykKxTsQBADFChbwwLAGtk DGLeeimF71woQ38U9h8qCcWUJRfpATFuef+tWtTLWJXJ6kJE7Gpn+hjZc8CKBfra nW3Wro11Z5NuBtxBL2M/b5WS3SWJFWHeP3V7LI0oCNb0jkNlGrSqc7cHiI3tUb8S iZ8O112yb4SKCk3bzaNoeJGai++0DFbw6FgucLRagrnUrzM9BqK3ZLFUmMclqWTM QIYBHgi1WbcaanRfD4JdxFqHCCSYqBuHjrB7ZQgWpEfhi00IGj6fCwzj3bJuWbcB eIhReSINClUTx+kulfi2jhmNhgJ9A== Received: from ppma11.dal12v.mail.ibm.com (db.9e.1632.ip4.static.sl-reverse.com [50.22.158.219]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 42as8a0mf1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 Oct 2024 05:25:31 +0000 (GMT) Received: from pps.filterd (ppma11.dal12v.mail.ibm.com [127.0.0.1]) by ppma11.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 49H2vZ0g006338 for ; Thu, 17 Oct 2024 05:25:30 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma11.dal12v.mail.ibm.com (PPS) with ESMTPS id 4286514p6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 Oct 2024 05:25:30 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 49H5PRRY54985032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Oct 2024 05:25:27 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 201822004B; Thu, 17 Oct 2024 05:25:27 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CD0620043; Thu, 17 Oct 2024 05:25:26 +0000 (GMT) Received: from ltcden2-lp1.aus.stglabs.ibm.com (unknown [9.3.90.43]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 17 Oct 2024 05:25:26 +0000 (GMT) From: Sachin Monga To: libc-alpha@sourceware.org Cc: bergner@linux.ibm.com, murphyp@linux.ibm.com, Sachin Monga Subject: [PATCH v3] powerpc64: Obviate the need for ROP protection in clone/clone3 Date: Thu, 17 Oct 2024 00:25:18 -0500 Message-ID: <20241017052518.88062-1-smonga@linux.ibm.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: wyewkbOCL3--eBVdxF9uXDElteJNAuAj X-Proofpoint-ORIG-GUID: wyewkbOCL3--eBVdxF9uXDElteJNAuAj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 mlxscore=0 lowpriorityscore=0 suspectscore=0 mlxlogscore=442 phishscore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2409260000 definitions=main-2410170034 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Spilling lr in a non-volatile before scv in clone/clone3. For clone, the non-volatile was unused and already saved/restored. Removed the dead code from clone. Signed-off-by: Sachin Monga --- .../unix/sysv/linux/powerpc/powerpc64/clone.S | 7 ++-- .../sysv/linux/powerpc/powerpc64/clone3.S | 35 ++++++++++--------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S index 164311d2bd..e57cb6e82e 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S @@ -56,7 +56,6 @@ ENTRY (__clone) /* Save fn, args, stack across syscall. */ mr r30,r3 /* Function in r30. */ - mr r29,r5 /* Flags in r29. */ mr r31,r6 /* Argument in r31. */ /* 'flags' argument is first parameter to clone syscall. @@ -77,14 +76,12 @@ ENTRY (__clone) CHECK_SCV_SUPPORT r28 0f /* This is equivalent to DO_CALL_SCV, but we cannot use the macro here because it uses CFI directives and we just called cfi_endproc. */ - mflr r9 - std r9,FRAME_LR_SAVE(r1) + mflr r29 .machine "push" .machine "power9" scv 0 .machine "pop" - ld r9,FRAME_LR_SAVE(r1) - mtlr r9 + mtlr r29 /* Check for child process. */ /* When using scv, error is indicated by negative r3. */ diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S index 900c354c9c..913f341d7d 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone3.S @@ -39,14 +39,12 @@ because it uses CFI directives and we just called cfi_endproc. */ # define DO_CLONE3_SVC_CALL(jumpfalse) \ CHECK_SCV_SUPPORT r28 jumpfalse; \ - mflr r9; \ - std r9, FRAME_LR_SAVE(r1); \ + mflr r31; \ .machine "push"; \ .machine "power9"; \ scv 0; \ .machine "pop"; \ - ld r9, FRAME_LR_SAVE(r1); \ - mtlr r9; \ + mtlr r31; \ /* With scv an, an error is a value -4095 <= x < 0. */ \ cmpdi cr1, r3, 0; \ b 1f; @@ -66,13 +64,15 @@ ENTRY(__clone3) /* Save some regs in the "red zone". */ #ifdef USE_PPC_SCV - std r28, -24(r1) - cfi_offset (r28, -24) + std r28, -32(r1) + cfi_offset (r28, -32) #endif - std r29, -16(r1) - std r30, -8(r1) - cfi_offset (r29, -16) - cfi_offset (r30, -8) + std r29, -24(r1) + std r30, -16(r1) + std r31, -8(r1) + cfi_offset (r29, -24) + cfi_offset (r30, -16) + cfi_offset (r31, -8) /* Save func and arg across syscall. */ mr r30, r5 /* Function in r30. */ @@ -132,16 +132,19 @@ L(parent): /* Parent. Restore registers & return. */ #ifdef USE_PPC_SCV - cfi_offset (r28, -24) - ld r28, -24(r1) + cfi_offset (r28, -32) + ld r28, -32(r1) cfi_restore (r28) #endif - cfi_offset (r29,-16) - cfi_offset (r30,-8) - ld r29, -16(r1) - ld r30, -8(r1) + cfi_offset (r29,-24) + cfi_offset (r30,-16) + cfi_offset (r31,-8) + ld r29, -24(r1) + ld r30, -16(r1) + ld r31, -8(r1) cfi_restore (r29) cfi_restore (r30) + cfi_restore (r31) #ifdef USE_PPC_SCV beq cr1, 0f