public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bill Schmidt <wschmidt@linux.ibm.com>
To: will schmidt <will_schmidt@vnet.ibm.com>, gcc-patches@gcc.gnu.org
Cc: dje.gcc@gmail.com, segher@kernel.crashing.org
Subject: Re: [PATCH 4/4] rs6000: Add ROP tests
Date: Mon, 26 Apr 2021 14:27:45 -0500	[thread overview]
Message-ID: <32475e36-6494-10ec-3ebb-4c43d7f9cea8@linux.ibm.com> (raw)
In-Reply-To: <7118acced8c2c6a60d86cceff306ac55dfcdb115.camel@vnet.ibm.com>

On 4/26/21 11:04 AM, will schmidt wrote:
> On Sun, 2021-04-25 at 20:50 -0500, Bill Schmidt via Gcc-patches wrote:
>> 2021-03-25  Bill Schmidt  <wschmidt@linux.ibm.com>
>>
>> gcc/testsuite/
>> 	* gcc.target/powerpc/rop-1.c: New.
>> 	* gcc.target/powerpc/rop-2.c: New.
>> 	* gcc.target/powerpc/rop-3.c: New.
>> 	* gcc.target/powerpc/rop-4.c: New.
>> 	* gcc.target/powerpc/rop-5.c: New.
> ok
>
>> ---
>>   gcc/testsuite/gcc.target/powerpc/rop-1.c | 16 ++++++++++++++++
>>   gcc/testsuite/gcc.target/powerpc/rop-2.c | 16 ++++++++++++++++
>>   gcc/testsuite/gcc.target/powerpc/rop-3.c | 19 +++++++++++++++++++
>>   gcc/testsuite/gcc.target/powerpc/rop-4.c | 14 ++++++++++++++
>>   gcc/testsuite/gcc.target/powerpc/rop-5.c | 17 +++++++++++++++++
>>   5 files changed, 82 insertions(+)
>>   create mode 100644 gcc/testsuite/gcc.target/powerpc/rop-1.c
>>   create mode 100644 gcc/testsuite/gcc.target/powerpc/rop-2.c
>>   create mode 100644 gcc/testsuite/gcc.target/powerpc/rop-3.c
>>   create mode 100644 gcc/testsuite/gcc.target/powerpc/rop-4.c
>>   create mode 100644 gcc/testsuite/gcc.target/powerpc/rop-5.c
>>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-1.c b/gcc/testsuite/gcc.target/powerpc/rop-1.c
>> new file mode 100644
>> index 00000000000..cf8e2b01dda
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/rop-1.c
>> @@ -0,0 +1,16 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
>> +
>> +/* Verify that ROP-protect instructions are inserted when a
>> +   call is present.  */
>> +
>> +extern void foo (void);
>> +
>> +int bar ()
>> +{
>> +  foo ();
>> +  return 5;
>> +}
>> +
>> +/* { dg-final { scan-assembler {\mhashst\M} } } */
>> +/* { dg-final { scan-assembler {\mhashchk\M} } } */
> ok
>
>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-2.c b/gcc/testsuite/gcc.target/powerpc/rop-2.c
>> new file mode 100644
>> index 00000000000..dde403b0ef5
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/rop-2.c
>> @@ -0,0 +1,16 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mprivileged" } */
>> +
>> +/* Verify that privileged ROP-protect instructions are inserted when a
>> +   call is present.  */
>> +
>> +extern void foo (void);
>> +
>> +int bar ()
>> +{
>> +  foo ();
>> +  return 5;
>> +}
>> +
>> +/* { dg-final { scan-assembler {\mhashstp\M} } } */
>> +/* { dg-final { scan-assembler {\mhashchkp\M} } } */
> ok
>
>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-3.c b/gcc/testsuite/gcc.target/powerpc/rop-3.c
>> new file mode 100644
>> index 00000000000..054f94fda99
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
>> @@ -0,0 +1,19 @@
>> +/* { dg-do run { target { power10_hw } } } */
>> +/* { dg-require-effective-target power10_ok } */
>> +/* { dg-require-effective-target powerpc_elfv2 } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
>> +
>> +/* Verify that ROP-protect instructions execute correctly when a
>> +   call is present.  */
>> +
>> +void __attribute__((noinline)) foo ()
>> +{
>> +  asm ("");
>> +}
>> +
>> +int main ()
>> +{
>> +  foo ();
>> +  return 0;
>> +}
>> +
> ok
>
>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-4.c b/gcc/testsuite/gcc.target/powerpc/rop-4.c
>> new file mode 100644
>> index 00000000000..e2be8b2c035
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/rop-4.c
>> @@ -0,0 +1,14 @@
>> +/* { dg-do compile } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
>> +
>> +/* Verify that no ROP-protect instructions are inserted when no
>> +   call is present.  */
>> +
>> +
>> +int bar ()
>> +{
>> +  return 5;
>> +}
>> +
>> +/* { dg-final { scan-assembler-not {\mhashst\M} } } */
>> +/* { dg-final { scan-assembler-not {\mhashchk\M} } } */
>
> ok
>
>> diff --git a/gcc/testsuite/gcc.target/powerpc/rop-5.c b/gcc/testsuite/gcc.target/powerpc/rop-5.c
>> new file mode 100644
>> index 00000000000..b759fa59979
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/rop-5.c
>> @@ -0,0 +1,17 @@
>> +/* { dg-do run { target { power10_hw } } } */
>> +/* { dg-require-effective-target power10_ok } */
>> +/* { dg-require-effective-target powerpc_elfv2 } */
>> +/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
>> +
>> +/* Verify that __ROP_PROTECT__ is predefined for -mrop-protect.  */
>> +
>> +extern void abort (void);
>> +
>> +int main ()
>> +{
>> +#ifndef __ROP_PROTECT__
>> +  abort ();
>> +#endif
>> +  return 0;
>> +}
>> +
> ok.
>
>
> Does there need to be another test to verify if -mrop-protect is on by
> default without specifying -mrop-protect?   (or is it?)  Question on
> 0/4.

It's off by default (see the Init(0) in patch 1/4).

Bill

> with that noted,
> lgtm,
> thanks,
> -will
>
>
>

  reply	other threads:[~2021-04-26 19:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26  1:50 [PATCH 0/4] [rs6000] ROP support Bill Schmidt
2021-04-26  1:50 ` [PATCH 1/4] rs6000: Add -mrop-protect and -mprivileged flags Bill Schmidt
2021-04-26 16:02   ` will schmidt
2021-05-12 20:40     ` Segher Boessenkool
2021-05-12 20:26   ` Segher Boessenkool
2021-04-26  1:50 ` [PATCH 2/4] rs6000: Emit ROP-protect instructions in prologue and epilogue Bill Schmidt
2021-04-26 16:03   ` will schmidt
2021-05-12 23:09   ` Segher Boessenkool
2021-04-26  1:50 ` [PATCH 3/4] rs6000: Conditionally define __ROP_PROTECT__ Bill Schmidt
2021-04-26 16:03   ` will schmidt
2021-05-12 23:19     ` Segher Boessenkool
2021-05-12 23:20   ` Segher Boessenkool
2021-04-26  1:50 ` [PATCH 4/4] rs6000: Add ROP tests Bill Schmidt
2021-04-26 16:04   ` will schmidt
2021-04-26 19:27     ` Bill Schmidt [this message]
2021-05-12 23:25       ` Segher Boessenkool
2021-05-12 23:42   ` Segher Boessenkool
2021-04-26 16:01 ` [PATCH 0/4] [rs6000] ROP support will schmidt
2021-04-26 16:33   ` Bill Schmidt
2021-05-11 15:56 ` Bill Schmidt
2021-05-14  3:34 [PATCHv2 0/4] " Bill Schmidt
2021-05-14  3:34 ` [PATCH 4/4] rs6000: Add ROP tests Bill Schmidt
2021-05-14 14:18   ` Bill Schmidt
2021-05-14 19:36   ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=32475e36-6494-10ec-3ebb-4c43d7f9cea8@linux.ibm.com \
    --to=wschmidt@linux.ibm.com \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=segher@kernel.crashing.org \
    --cc=will_schmidt@vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).