From patchwork Thu Nov 11 22:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Bergner X-Patchwork-Id: 1554101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=e6Ll8gBe; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hqwvc0Nhxz9s1l for ; Fri, 12 Nov 2021 09:12:58 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C51113858014 for ; Thu, 11 Nov 2021 22:12:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C51113858014 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636668775; bh=bVFMBRx5sEaOdSiqmQQqaGIhQJWs7pl/BulYnuAv+Vg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=e6Ll8gBeZfXl8+sWZc+sADpXo+m29xH2D6lNqGHrui6ynkYu+9XumvkBhbMOO6Nyl YamC1FoLCZ1nXsodIkKUFytcxyz1J+FboPsFJ7qcQpFvQfrxoAwhiTrtguUO/2806Y nGEaYTl2va50tqrd8TFSmlcOPHlwqQ3c8NFi0xrw= 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 41C0E385840E for ; Thu, 11 Nov 2021 22:12:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 41C0E385840E Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1ABLFdIk012279; Thu, 11 Nov 2021 22:12:12 GMT Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c9axc8ung-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Nov 2021 22:12:12 +0000 Received: from m0098394.ppops.net (m0098394.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 1ABMAXZB017471; Thu, 11 Nov 2021 22:12:11 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3c9axc8un4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Nov 2021 22:12:11 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 1ABLqwaI015530; Thu, 11 Nov 2021 22:12:10 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma04wdc.us.ibm.com with ESMTP id 3c9854c6qq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Nov 2021 22:12:10 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 1ABMC95G19268154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Nov 2021 22:12:09 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6042F11207B; Thu, 11 Nov 2021 22:12:09 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAB6D112063; Thu, 11 Nov 2021 22:12:08 +0000 (GMT) Received: from [9.65.75.193] (unknown [9.65.75.193]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Thu, 11 Nov 2021 22:12:08 +0000 (GMT) Message-ID: Date: Thu, 11 Nov 2021 16:12:08 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Content-Language: en-US To: Segher Boessenkool , David Edelsohn Subject: [PATCH] rs6000: testsuite: Add rop_ok effective-target function X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gTh1XTah5OXNEeA-bwNXnDBxLii1n52R X-Proofpoint-GUID: pnj2RM0TkXMN1I-MFJ_3DbnEIM9o3J0e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-11-11_07,2021-11-11_01,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 phishscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 suspectscore=0 impostorscore=0 adultscore=0 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2110150000 definitions=main-2111110113 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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: 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: Peter Bergner via Gcc-patches From: Peter Bergner Reply-To: Peter Bergner Cc: Bill Schmidt , GCC Patches Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This patch adds a new effective-target function that tests whether it is safe to emit the ROP-protect instructions and updates the ROP test cases to use it. Segher, as we discussed offline, this uses the double [] which you said isn't needed in general regex's, but for some reason is needed in the gcc testsuite regex. Tested on powerpc64le*-linux with no regressions. Ok for mainline? Peter gcc/testsuite/ * lib/target-supports.exp (check_effective_target_rop_ok): New function. * gcc.target/powerpc/rop-1.c: Use it. * gcc.target/powerpc/rop-2.c: Likewise. * gcc.target/powerpc/rop-3.c: Likewise. * gcc.target/powerpc/rop-4.c: Likewise. * gcc.target/powerpc/rop-5.c: Likewise. diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 1c8b1ebb86e..0d9a3ba67ce 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -6625,6 +6625,13 @@ proc check_effective_target_powerpc_elfv2 { } { } } +# Return 1 if this is a PowerPC target supporting -mrop-protect + +proc check_effective_target_rop_ok { } { + return [check_effective_target_power10_ok] + && [check_effective_target_powerpc_elfv2] +} + # The VxWorks SPARC simulator accepts only EM_SPARC executables and # chokes on EM_SPARC32PLUS or EM_SPARCV9 executables. Return 1 if the # test environment appears to run executables on such a simulator. diff --git a/gcc/testsuite/gcc.target/powerpc/rop-1.c b/gcc/testsuite/gcc.target/powerpc/rop-1.c index 8cedcb6668a..12893dec027 100644 --- a/gcc/testsuite/gcc.target/powerpc/rop-1.c +++ b/gcc/testsuite/gcc.target/powerpc/rop-1.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */ -/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-require-effective-target rop_ok } */ /* Verify that ROP-protect instructions are inserted when a call is present. */ diff --git a/gcc/testsuite/gcc.target/powerpc/rop-2.c b/gcc/testsuite/gcc.target/powerpc/rop-2.c index c556952aec1..5f1d7c39bfc 100644 --- a/gcc/testsuite/gcc.target/powerpc/rop-2.c +++ b/gcc/testsuite/gcc.target/powerpc/rop-2.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mprivileged" } */ -/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-require-effective-target rop_ok } */ /* Verify that privileged ROP-protect instructions are inserted when a call is present. */ diff --git a/gcc/testsuite/gcc.target/powerpc/rop-3.c b/gcc/testsuite/gcc.target/powerpc/rop-3.c index 8d03792e3e5..d2ef3bf4bad 100644 --- a/gcc/testsuite/gcc.target/powerpc/rop-3.c +++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c @@ -1,5 +1,5 @@ /* { dg-do run { target { power10_hw } } } */ -/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-require-effective-target rop_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */ /* Verify that ROP-protect instructions execute correctly when a diff --git a/gcc/testsuite/gcc.target/powerpc/rop-4.c b/gcc/testsuite/gcc.target/powerpc/rop-4.c index dcf47c63fb7..80faa9b3f7b 100644 --- a/gcc/testsuite/gcc.target/powerpc/rop-4.c +++ b/gcc/testsuite/gcc.target/powerpc/rop-4.c @@ -1,6 +1,6 @@ /* { dg-do compile } */ /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */ -/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-require-effective-target rop_ok } */ /* Verify that no ROP-protect instructions are inserted when no call is present. */ diff --git a/gcc/testsuite/gcc.target/powerpc/rop-5.c b/gcc/testsuite/gcc.target/powerpc/rop-5.c index f2594df8a44..f7970f1fe25 100644 --- a/gcc/testsuite/gcc.target/powerpc/rop-5.c +++ b/gcc/testsuite/gcc.target/powerpc/rop-5.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-require-effective-target powerpc_elfv2 } */ +/* { dg-require-effective-target rop_ok } */ /* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */ /* Verify that __ROP_PROTECT__ is predefined for -mrop-protect. */