From patchwork Thu Dec 3 17:15:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Castanho X-Patchwork-Id: 41290 X-Patchwork-Delegate: tuliom@linux.vnet.ibm.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 AFE25397202F; Thu, 3 Dec 2020 17:15:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFE25397202F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607015742; bh=rbUb/6V9vuemsLpuNuqCmoQZG53dmdwbv4f7qmGkuyQ=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=J4RmIvJ7pK0svQ+gln5/e+x+TEQokWzbCDsMEyZYqPc3zyqZ4hBjAlWZZTZg52nws Pj2wmvDPfgTIXiB4VsASVzlpfIqn+1vDBGHGdaizDe0l4KtFW7Y1Hh9qwxuvleryTm jwv7AgpoTw47/WD24OQG40saLiX0kXXSQP4fmjEE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by sourceware.org (Postfix) with ESMTPS id E5458397202F for ; Thu, 3 Dec 2020 17:15:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E5458397202F Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0B3HAlEa092587 for ; Thu, 3 Dec 2020 12:15:37 -0500 Received: from ppma03wdc.us.ibm.com (ba.79.3fa9.ip4.static.sl-reverse.com [169.63.121.186]) by mx0a-001b2d01.pphosted.com with ESMTP id 3573yh8ehy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 03 Dec 2020 12:15:37 -0500 Received: from pps.filterd (ppma03wdc.us.ibm.com [127.0.0.1]) by ppma03wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0B3HFUQ6018369 for ; Thu, 3 Dec 2020 17:15:35 GMT Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by ppma03wdc.us.ibm.com with ESMTP id 356q6qn9w7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 03 Dec 2020 17:15:35 +0000 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0B3HFZR58192352 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 3 Dec 2020 17:15:35 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4601EAE062 for ; Thu, 3 Dec 2020 17:15:35 +0000 (GMT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BFA29AE063 for ; Thu, 3 Dec 2020 17:15:34 +0000 (GMT) Received: from localhost (unknown [9.160.113.167]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP for ; Thu, 3 Dec 2020 17:15:34 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH v2 2/2] powerpc: Use scv instruction on clone when available Date: Thu, 3 Dec 2020 14:15:28 -0300 Message-Id: <20201203171528.83180-3-msc@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201203171528.83180-1-msc@linux.ibm.com> References: <20201203171528.83180-1-msc@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-12-03_09:2020-12-03, 2020-12-03 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 suspectscore=1 adultscore=0 impostorscore=0 clxscore=1015 phishscore=0 spamscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 mlxlogscore=722 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012030100 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Matheus Castanho via Libc-alpha From: Matheus Castanho Reply-To: Matheus Castanho Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" clone already uses r31 to temporarily save input arguments before doing the syscall, so we use a different register to read from the TCB. We can also avoid allocating another stack frame, which is not needed since we can simply extend the usage of the red zone. --- .../unix/sysv/linux/powerpc/powerpc64/clone.S | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S index fc496fa671..247e0de68c 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/clone.S @@ -38,9 +38,11 @@ ENTRY (__clone) beq- cr0,L(badargs) /* Save some regs in the "red zone". */ + std r28,-32(r1) std r29,-24(r1) std r30,-16(r1) std r31,-8(r1) + cfi_offset(r28,-32) cfi_offset(r29,-24) cfi_offset(r30,-16) cfi_offset(r31,-8) @@ -69,11 +71,26 @@ ENTRY (__clone) /* Do the call. */ li r0,SYS_ify(clone) - DO_CALL_SC + 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) + scv 0 + ld r9,FRAME_LR_SAVE(r1) + mtlr r9 + + /* Check for child process. */ + /* When using scv, error is indicated by negative r3. */ + cmpdi cr1,r3,0 + b 1f +0: DO_CALL_SC /* Check for child process. */ + /* With sc, error is indicated by cr0.SO. */ cmpdi cr1,r3,0 crandc cr1*4+eq,cr1*4+eq,cr0*4+so +1: bne- cr1,L(parent) /* The '-' is to minimise the race. */ std r2,FRAME_TOC_SAVE(r1) @@ -95,19 +112,29 @@ L(badargs): TAIL_CALL_SYSCALL_ERROR L(parent): + /* Check if scv is available. */ + cmpdi cr1,r28,0 + /* Parent. Restore registers & return. */ + cfi_offset(r28,-32) cfi_offset(r29,-24) cfi_offset(r30,-16) cfi_offset(r31,-8) + ld r28,-32(r1) ld r29,-24(r1) ld r30,-16(r1) ld r31,-8(r1) + cfi_restore(r28) cfi_restore(r29) cfi_restore(r30) cfi_restore(r31) - RET_SC - TAIL_CALL_SYSCALL_ERROR + beq cr1,0f + RET_SCV + b 1f +0: RET_SC +1: TAIL_CALL_SYSCALL_ERROR + END (__clone)