From: Bill Schmidt <wschmidt@linux.ibm.com>
To: gcc-patches@gcc.gnu.org
Cc: segher@kernel.crashing.org, dje.gcc@gmail.com,
Bill Schmidt <wschmidt@linux.ibm.com>
Subject: [PATCH 4/4] rs6000: Add ROP tests
Date: Fri, 14 May 2021 09:18:48 -0500 [thread overview]
Message-ID: <cac348815f75a1a9bc734076e0c6909f225e1987.1620958221.git.wschmidt@linux.ibm.com> (raw)
Message-ID: <20210514141848.wFtd2Jbsxh9_ULO-HFtvud0ibU3qowl4Irer0VOw1NA@z> (raw)
In-Reply-To: <cover.1620958221.git.wschmidt@linux.ibm.com>
2021-05-13 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.
---
gcc/testsuite/gcc.target/powerpc/rop-1.c | 17 +++++++++++++++++
gcc/testsuite/gcc.target/powerpc/rop-2.c | 17 +++++++++++++++++
gcc/testsuite/gcc.target/powerpc/rop-3.c | 18 ++++++++++++++++++
gcc/testsuite/gcc.target/powerpc/rop-4.c | 15 +++++++++++++++
gcc/testsuite/gcc.target/powerpc/rop-5.c | 13 +++++++++++++
5 files changed, 80 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..8cedcb6668a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rop-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
+/* { dg-require-effective-target powerpc_elfv2 } */
+
+/* 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-times {\mhashst\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mhashchk\M} 1 } } */
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..c556952aec1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rop-2.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect -mprivileged" } */
+/* { dg-require-effective-target powerpc_elfv2 } */
+
+/* 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-times {\mhashstp\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mhashchkp\M} 1 } } */
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..8d03792e3e5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rop-3.c
@@ -0,0 +1,18 @@
+/* { dg-do run { target { power10_hw } } } */
+/* { 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__((noipa)) foo ()
+{
+ asm ("");
+}
+
+int main ()
+{
+ foo ();
+ return 0;
+}
+
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..dcf47c63fb7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rop-4.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
+/* { dg-require-effective-target powerpc_elfv2 } */
+
+/* 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} } } */
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..cf04ea90eeb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/rop-5.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10 -mrop-protect" } */
+
+/* Verify that __ROP_PROTECT__ is predefined for -mrop-protect. */
+
+int foo ()
+{
+#ifndef __ROP_PROTECT__
+ __ROP_PROTECT__ macro is not defined when it should be
+#endif
+ return 0;
+}
+
--
2.27.0
next prev parent reply other threads:[~2021-05-14 14:19 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-14 3:34 [PATCHv2 0/4] ROP support Bill Schmidt
2021-05-14 3:34 ` [PATCH 1/4] rs6000: Add -mrop-protect and -mprivileged flags Bill Schmidt
2021-05-14 14:18 ` Bill Schmidt
2021-05-14 15:55 ` Segher Boessenkool
2021-05-15 19:06 ` Bill Schmidt
2021-05-14 3:34 ` [PATCH 2/4] rs6000: Emit ROP-mitigation instructions in prologue and epilogue Bill Schmidt
2021-05-14 14:18 ` Bill Schmidt
2021-05-14 18:44 ` Segher Boessenkool
2021-05-14 19:10 ` Bill Schmidt
2021-05-14 3:34 ` [PATCH 3/4] rs6000: Conditionally define __ROP_PROTECT__ Bill Schmidt
2021-05-14 14:18 ` Bill Schmidt
2021-05-14 18:51 ` Segher Boessenkool
2021-05-14 3:34 ` Bill Schmidt [this message]
2021-05-14 14:18 ` [PATCH 4/4] rs6000: Add ROP tests Bill Schmidt
2021-05-14 19:36 ` Segher Boessenkool
2021-05-14 14:18 ` [PATCHv2 0/4] ROP support Bill Schmidt
-- strict thread matches above, loose matches on Subject: below --
2021-04-26 1:50 [PATCH 0/4] [rs6000] " Bill Schmidt
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
2021-05-12 23:25 ` Segher Boessenkool
2021-05-12 23:42 ` 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=cac348815f75a1a9bc734076e0c6909f225e1987.1620958221.git.wschmidt@linux.ibm.com \
--to=wschmidt@linux.ibm.com \
--cc=dje.gcc@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=segher@kernel.crashing.org \
/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).