* 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute
@ 2017-08-01 8:56 Tsimbalist, Igor V
2017-08-25 22:15 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Tsimbalist, Igor V @ 2017-08-01 8:56 UTC (permalink / raw)
To: 'gcc-patches@gcc.gnu.org'; +Cc: Tsimbalist, Igor V
[-- Attachment #1: Type: text/plain, Size: 74 bytes --]
Part#3. Add tests for -finstrument-control-flow and notrack attribute.
[-- Attachment #2: 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-n.patch --]
[-- Type: application/octet-stream, Size: 3198 bytes --]
From 7869de8a0c0ec55c4e9240c2483fefee97bf34c9 Mon Sep 17 00:00:00 2001
From: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Date: Mon, 3 Jul 2017 17:29:08 +0300
Subject: [PATCH 3/9] Part#3. Add tests for -finstrument-control-flow and
notrack attribute.
gcc/testsuite/
* c-c++-common/finstrument-control-flow.c: New test.
* c-c++-common/notrack-1.c: Likewise.
* c-c++-common/notrack-2.c: Likewise.
---
.../c-c++-common/finstrument-control-flow.c | 4 +++
gcc/testsuite/c-c++-common/notrack-1.c | 30 ++++++++++++++++++++++
gcc/testsuite/c-c++-common/notrack-2.c | 5 ++++
3 files changed, 39 insertions(+)
create mode 100644 gcc/testsuite/c-c++-common/finstrument-control-flow.c
create mode 100644 gcc/testsuite/c-c++-common/notrack-1.c
create mode 100644 gcc/testsuite/c-c++-common/notrack-2.c
---
.../c-c++-common/finstrument-control-flow.c | 4 +++
gcc/testsuite/c-c++-common/notrack-1.c | 30 ++++++++++++++++++++++
gcc/testsuite/c-c++-common/notrack-2.c | 5 ++++
3 files changed, 39 insertions(+)
create mode 100644 gcc/testsuite/c-c++-common/finstrument-control-flow.c
create mode 100644 gcc/testsuite/c-c++-common/notrack-1.c
create mode 100644 gcc/testsuite/c-c++-common/notrack-2.c
diff --git a/gcc/testsuite/c-c++-common/finstrument-control-flow.c b/gcc/testsuite/c-c++-common/finstrument-control-flow.c
new file mode 100644
index 0000000..fa6d763
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/finstrument-control-flow.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-finstrument-control-flow" } */
+/* { dg-error "'-finstrument-control-flow' requires CET support on this target. Use -mcet or one of -mibt, -mshstk options to enable CET." "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-error "'-finstrument-control-flow' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
diff --git a/gcc/testsuite/c-c++-common/notrack-1.c b/gcc/testsuite/c-c++-common/notrack-1.c
new file mode 100644
index 0000000..75075fb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/notrack-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+int func (int) __attribute__ ((notrack));
+int (*fptr) (int) __attribute__ ((notrack));
+typedef void (*notrack_t) (void) __attribute__ ((notrack));
+
+int
+foo1 (int arg)
+{
+ return func (arg) + fptr (arg);
+}
+
+void
+foo2 (void (*foo) (void))
+{
+ void (*func) (void) __attribute__((notrack)) = foo;
+ func ();
+}
+
+void
+foo3 (notrack_t foo)
+{
+ foo ();
+}
+
+void
+foo4 (void (*foo) (void) __attribute__((notrack)))
+{
+ foo ();
+}
diff --git a/gcc/testsuite/c-c++-common/notrack-2.c b/gcc/testsuite/c-c++-common/notrack-2.c
new file mode 100644
index 0000000..95ea4ed
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/notrack-2.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+int var1 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+int *var2 __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
+void (**var3) (void) __attribute__((notrack)); /* { dg-warning "'notrack' attribute only applies to function types" } */
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute
2017-08-01 8:56 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute Tsimbalist, Igor V
@ 2017-08-25 22:15 ` Jeff Law
2017-09-19 13:58 ` Tsimbalist, Igor V
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2017-08-25 22:15 UTC (permalink / raw)
To: Tsimbalist, Igor V, 'gcc-patches@gcc.gnu.org'
On 08/01/2017 02:56 AM, Tsimbalist, Igor V wrote:
> Part#3. Add tests for -finstrument-control-flow and notrack attribute.
>
>
> 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-n.patch
>
>
> From 7869de8a0c0ec55c4e9240c2483fefee97bf34c9 Mon Sep 17 00:00:00 2001
> From: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
> Date: Mon, 3 Jul 2017 17:29:08 +0300
> Subject: [PATCH 3/9] Part#3. Add tests for -finstrument-control-flow and
> notrack attribute.
>
> gcc/testsuite/
>
> * c-c++-common/finstrument-control-flow.c: New test.
> * c-c++-common/notrack-1.c: Likewise.
> * c-c++-common/notrack-2.c: Likewise.
No concerns with the existing tests.
We should consider an ICF test as I outlined in an earlier message.
We should also consider tests where we drop/add the notrack attribute as
ISTM we ought to be getting warnings in those cases.
Finally, you should consider tests in gcc.target/i386 that verify we
generate the proper instrumentation for a few tests.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute
2017-08-25 22:15 ` Jeff Law
@ 2017-09-19 13:58 ` Tsimbalist, Igor V
2017-09-28 23:08 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Tsimbalist, Igor V @ 2017-09-19 13:58 UTC (permalink / raw)
To: 'gcc-patches@gcc.gnu.org'; +Cc: Jeff Law, Tsimbalist, Igor V
[-- Attachment #1: Type: text/plain, Size: 2284 bytes --]
Here is an updated patch (version #2). Mainly attribute and option names were changed.
The test for ICF will be introduced in x86 specific tests (patch 0006-Part-6) as the implementation
checks if the CF instrumentation is on to adjust a hash based on 'nocf'_check' attribute presence.
In generic part CF instrumentation is off as no implementation exist.
The patch for x86 specific tests (patch 0006-Part-6) is being reviewed by Uros.
gcc/testsuite/
* c-c++-common/fcf-protection-1.c: New test.
* c-c++-common/fcf-protection-2.c: Likewise.
* c-c++-common/fcf-protection-3.c: Likewise.
* c-c++-common/fcf-protection-4.c: Likewise.
* c-c++-common/fcf-protection-5.c: Likewise.
* c-c++-common/attr-nocf-check-1.c: Likewise.
* c-c++-common/attr-nocf-check-2.c: Likewise.
* c-c++-common/attr-nocf-check-3.c: Likewise.
Is it ok for trunk?
Thanks,
Igor
> -----Original Message-----
> From: Jeff Law [mailto:law@redhat.com]
> Sent: Friday, August 25, 2017 11:01 PM
> To: Tsimbalist, Igor V <igor.v.tsimbalist@intel.com>; 'gcc-
> patches@gcc.gnu.org' <gcc-patches@gcc.gnu.org>
> Subject: Re: 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-
> notrack attribute
>
> On 08/01/2017 02:56 AM, Tsimbalist, Igor V wrote:
> > Part#3. Add tests for -finstrument-control-flow and notrack attribute.
> >
> >
> > 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-n.patch
> >
> >
> > From 7869de8a0c0ec55c4e9240c2483fefee97bf34c9 Mon Sep 17 00:00:00
> 2001
> > From: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
> > Date: Mon, 3 Jul 2017 17:29:08 +0300
> > Subject: [PATCH 3/9] Part#3. Add tests for -finstrument-control-flow
> > and notrack attribute.
> >
> > gcc/testsuite/
> >
> > * c-c++-common/finstrument-control-flow.c: New test.
> > * c-c++-common/notrack-1.c: Likewise.
> > * c-c++-common/notrack-2.c: Likewise.
> No concerns with the existing tests.
>
> We should consider an ICF test as I outlined in an earlier message.
>
> We should also consider tests where we drop/add the notrack attribute as
> ISTM we ought to be getting warnings in those cases.
>
> Finally, you should consider tests in gcc.target/i386 that verify we generate
> the proper instrumentation for a few tests.
>
> jeff
[-- Attachment #2: 0003-Add-tests-for-fcf-protection-and-nocf_check-attribut.patch --]
[-- Type: application/octet-stream, Size: 7978 bytes --]
From 700d44c245e68fb4ce61f842f1bd83c5f0954954 Mon Sep 17 00:00:00 2001
From: Igor Tsimbalist <igor.v.tsimbalist@intel.com>
Date: Sun, 17 Sep 2017 19:24:03 +0300
Subject: [PATCH 3/3] Add tests for -fcf-protection and nocf_check attribute.
gcc/testsuite/
* c-c++-common/fcf-protection-1.c: New test.
* c-c++-common/fcf-protection-2.c: Likewise.
* c-c++-common/fcf-protection-3.c: Likewise.
* c-c++-common/fcf-protection-4.c: Likewise.
* c-c++-common/fcf-protection-5.c: Likewise.
* c-c++-common/attr-nocf-check-1.c: Likewise.
* c-c++-common/attr-nocf-check-2.c: Likewise.
* c-c++-common/attr-nocf-check-3.c: Likewise.
---
gcc/testsuite/c-c++-common/attr-nocf-check-1.c | 30 ++++++++++++++++++++++++++
gcc/testsuite/c-c++-common/attr-nocf-check-2.c | 5 +++++
gcc/testsuite/c-c++-common/attr-nocf-check-3.c | 29 +++++++++++++++++++++++++
gcc/testsuite/c-c++-common/fcf-protection-1.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-2.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-3.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-4.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-5.c | 4 ++++
8 files changed, 84 insertions(+)
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-1.c
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-2.c
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-3.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-1.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-2.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-3.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-4.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-5.c
---
gcc/testsuite/c-c++-common/attr-nocf-check-1.c | 30 ++++++++++++++++++++++++++
gcc/testsuite/c-c++-common/attr-nocf-check-2.c | 5 +++++
gcc/testsuite/c-c++-common/attr-nocf-check-3.c | 29 +++++++++++++++++++++++++
gcc/testsuite/c-c++-common/fcf-protection-1.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-2.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-3.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-4.c | 4 ++++
gcc/testsuite/c-c++-common/fcf-protection-5.c | 4 ++++
8 files changed, 84 insertions(+)
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-1.c
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-2.c
create mode 100644 gcc/testsuite/c-c++-common/attr-nocf-check-3.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-1.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-2.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-3.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-4.c
create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-5.c
diff --git a/gcc/testsuite/c-c++-common/attr-nocf-check-1.c b/gcc/testsuite/c-c++-common/attr-nocf-check-1.c
new file mode 100644
index 0000000..dfccd78
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-nocf-check-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+int func (int) __attribute__ ((nocf_check));
+int (*fptr) (int) __attribute__ ((nocf_check));
+typedef void (*nocf_check_t) (void) __attribute__ ((nocf_check));
+
+int
+foo1 (int arg)
+{
+ return func (arg) + fptr (arg);
+}
+
+void
+foo2 (void (*foo) (void))
+{
+ void (*func) (void) __attribute__((nocf_check)) = foo; /* { dg-warning "nocf_check attribute mismatch for initialization" } */
+ func ();
+}
+
+void
+foo3 (nocf_check_t foo)
+{
+ foo ();
+}
+
+void
+foo4 (void (*foo) (void) __attribute__((nocf_check)))
+{
+ foo ();
+}
diff --git a/gcc/testsuite/c-c++-common/attr-nocf-check-2.c b/gcc/testsuite/c-c++-common/attr-nocf-check-2.c
new file mode 100644
index 0000000..9ab0180
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-nocf-check-2.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+
+int var1 __attribute__((nocf_check)); /* { dg-warning "'nocf_check' attribute only applies to function types" } */
+int *var2 __attribute__((nocf_check)); /* { dg-warning "'nocf_check' attribute only applies to function types" } */
+void (**var3) (void) __attribute__((nocf_check)); /* { dg-warning "'nocf_check' attribute only applies to function types" } */
diff --git a/gcc/testsuite/c-c++-common/attr-nocf-check-3.c b/gcc/testsuite/c-c++-common/attr-nocf-check-3.c
new file mode 100644
index 0000000..d8d4c82
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/attr-nocf-check-3.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+
+int foo (void) __attribute__ ((nocf_check));
+void (*foo1) (void) __attribute__((nocf_check));
+void (*foo2) (void);
+
+int
+foo (void) /* The function's address is not tracked. */
+{
+ /* This call site is not tracked for
+ control-flow instrumentation. */
+ (*foo1)();
+
+ foo1 = foo2; /* { dg-warning "nocf_check attribute mismatch for assignment" } */
+ /* This call site is still not tracked for
+ control-flow instrumentation. */
+ (*foo1)();
+
+ /* This call site is tracked for
+ control-flow instrumentation. */
+ (*foo2)();
+
+ foo2 = foo1; /* { dg-warning "nocf_check attribute mismatch for assignment" } */
+ /* This call site is still tracked for
+ control-flow instrumentation. */
+ (*foo2)();
+
+ return 0;
+}
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-1.c b/gcc/testsuite/c-c++-common/fcf-protection-1.c
new file mode 100644
index 0000000..6a27e19
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-1.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection=full" } */
+/* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-2.c b/gcc/testsuite/c-c++-common/fcf-protection-2.c
new file mode 100644
index 0000000..558f4c0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-2.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection=branch" } */
+/* { dg-error "'-fcf-protection=branch' is not supported for this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-error "'-fcf-protection=branch' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-3.c b/gcc/testsuite/c-c++-common/fcf-protection-3.c
new file mode 100644
index 0000000..ffc7346
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-3.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection=return" } */
+/* { dg-error "'-fcf-protection=return' is not supported for this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-error "'-fcf-protection=return' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-4.c b/gcc/testsuite/c-c++-common/fcf-protection-4.c
new file mode 100644
index 0000000..1a5b1b8
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-4.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection=none" } */
+/* { dg-bogus "'-fcf-protection=none' is not supported for this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-bogus "'-fcf-protection=none' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-5.c b/gcc/testsuite/c-c++-common/fcf-protection-5.c
new file mode 100644
index 0000000..2ea2ce0
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-5.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-fcf-protection" } */
+/* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { "i?86-*-* x86_64-*-*" } } 0 } */
+/* { dg-error "'-fcf-protection=full' is not supported for this target" "" { target { ! "i?86-*-* x86_64-*-*" } } 0 } */
--
1.8.3.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute
2017-09-19 13:58 ` Tsimbalist, Igor V
@ 2017-09-28 23:08 ` Jeff Law
0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2017-09-28 23:08 UTC (permalink / raw)
To: Tsimbalist, Igor V, 'gcc-patches@gcc.gnu.org'
On 09/19/2017 07:58 AM, Tsimbalist, Igor V wrote:
> Here is an updated patch (version #2). Mainly attribute and option names were changed.
> The test for ICF will be introduced in x86 specific tests (patch 0006-Part-6) as the implementation
> checks if the CF instrumentation is on to adjust a hash based on 'nocf'_check' attribute presence.
> In generic part CF instrumentation is off as no implementation exist.
>
> The patch for x86 specific tests (patch 0006-Part-6) is being reviewed by Uros.
>
> gcc/testsuite/
> * c-c++-common/fcf-protection-1.c: New test.
> * c-c++-common/fcf-protection-2.c: Likewise.
> * c-c++-common/fcf-protection-3.c: Likewise.
> * c-c++-common/fcf-protection-4.c: Likewise.
> * c-c++-common/fcf-protection-5.c: Likewise.
> * c-c++-common/attr-nocf-check-1.c: Likewise.
> * c-c++-common/attr-nocf-check-2.c: Likewise.
> * c-c++-common/attr-nocf-check-3.c: Likewise.
>
> Is it ok for trunk?
>
This is OK once the CET changes for the compiler are approved.
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-28 23:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-01 8:56 0003-Part-3.-Add-tests-for-finstrument-control-flow-and-notrack attribute Tsimbalist, Igor V
2017-08-25 22:15 ` Jeff Law
2017-09-19 13:58 ` Tsimbalist, Igor V
2017-09-28 23:08 ` Jeff Law
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).