* [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
@ 2018-02-06 21:09 H.J. Lu
2018-02-06 21:20 ` Tsimbalist, Igor V
0 siblings, 1 reply; 3+ messages in thread
From: H.J. Lu @ 2018-02-06 21:09 UTC (permalink / raw)
To: gcc-patches; +Cc: Uros Bizjak, Igor Tsimbalist
Since ix86_option_override_internal sets the CF_SET bit in
flag_cf_protection and it can be called more than once via pragma,
we need to mask out the CF_SET bit when checking flag_cf_protection.
OK for trunk if there is no regression?
H.J.
---
PR target/84248
* config/i386/i386.c (ix86_option_override_internal): Mask out
the CF_SET bit when checking -fcf-protection.
---
gcc/config/i386/i386.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 6c612c77987..ef7ff89bcbb 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -4913,12 +4913,12 @@ ix86_option_override_internal (bool main_args_p,
= build_target_option_node (opts);
/* Do not support control flow instrumentation if CET is not enabled. */
- if (opts->x_flag_cf_protection != CF_NONE)
+ cf_protection_level cf_protection
+ = (cf_protection_level) (opts->x_flag_cf_protection & ~CF_SET);
+ if (cf_protection != CF_NONE)
{
- switch (flag_cf_protection)
+ switch (cf_protection)
{
- case CF_NONE:
- break;
case CF_BRANCH:
if (! TARGET_IBT_P (opts->x_ix86_isa_flags2))
{
@@ -4953,7 +4953,7 @@ ix86_option_override_internal (bool main_args_p,
}
opts->x_flag_cf_protection =
- (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
+ (cf_protection_level) (cf_protection | CF_SET);
}
if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
--
2.14.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
2018-02-06 21:09 [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check H.J. Lu
@ 2018-02-06 21:20 ` Tsimbalist, Igor V
2018-02-07 8:52 ` Uros Bizjak
0 siblings, 1 reply; 3+ messages in thread
From: Tsimbalist, Igor V @ 2018-02-06 21:20 UTC (permalink / raw)
To: H.J. Lu, gcc-patches; +Cc: Uros Bizjak, Tsimbalist, Igor V
> -----Original Message-----
> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
> owner@gcc.gnu.org] On Behalf Of H.J. Lu
> Sent: Tuesday, February 6, 2018 10:09 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Uros Bizjak <ubizjak@gmail.com>; Tsimbalist, Igor V
> <igor.v.tsimbalist@intel.com>
> Subject: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
>
> Since ix86_option_override_internal sets the CF_SET bit in
> flag_cf_protection and it can be called more than once via pragma,
> we need to mask out the CF_SET bit when checking flag_cf_protection.
>
> OK for trunk if there is no regression?
Ok from CET viewpoint.
Thanks,
Igor
> H.J.
> ---
> PR target/84248
> * config/i386/i386.c (ix86_option_override_internal): Mask out
> the CF_SET bit when checking -fcf-protection.
> ---
> gcc/config/i386/i386.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 6c612c77987..ef7ff89bcbb 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -4913,12 +4913,12 @@ ix86_option_override_internal (bool
> main_args_p,
> = build_target_option_node (opts);
>
> /* Do not support control flow instrumentation if CET is not enabled. */
> - if (opts->x_flag_cf_protection != CF_NONE)
> + cf_protection_level cf_protection
> + = (cf_protection_level) (opts->x_flag_cf_protection & ~CF_SET);
> + if (cf_protection != CF_NONE)
> {
> - switch (flag_cf_protection)
> + switch (cf_protection)
> {
> - case CF_NONE:
> - break;
> case CF_BRANCH:
> if (! TARGET_IBT_P (opts->x_ix86_isa_flags2))
> {
> @@ -4953,7 +4953,7 @@ ix86_option_override_internal (bool main_args_p,
> }
>
> opts->x_flag_cf_protection =
> - (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
> + (cf_protection_level) (cf_protection | CF_SET);
> }
>
> if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
> --
> 2.14.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
2018-02-06 21:20 ` Tsimbalist, Igor V
@ 2018-02-07 8:52 ` Uros Bizjak
0 siblings, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2018-02-07 8:52 UTC (permalink / raw)
To: Tsimbalist, Igor V; +Cc: H.J. Lu, gcc-patches
On Tue, Feb 6, 2018 at 10:20 PM, Tsimbalist, Igor V
<igor.v.tsimbalist@intel.com> wrote:
>> -----Original Message-----
>> From: gcc-patches-owner@gcc.gnu.org [mailto:gcc-patches-
>> owner@gcc.gnu.org] On Behalf Of H.J. Lu
>> Sent: Tuesday, February 6, 2018 10:09 PM
>> To: gcc-patches@gcc.gnu.org
>> Cc: Uros Bizjak <ubizjak@gmail.com>; Tsimbalist, Igor V
>> <igor.v.tsimbalist@intel.com>
>> Subject: [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check
>>
>> Since ix86_option_override_internal sets the CF_SET bit in
>> flag_cf_protection and it can be called more than once via pragma,
>> we need to mask out the CF_SET bit when checking flag_cf_protection.
>>
>> OK for trunk if there is no regression?
>
> Ok from CET viewpoint.
OK.
Thanks,
Uros.
> Thanks,
> Igor
>
>> H.J.
>> ---
>> PR target/84248
>> * config/i386/i386.c (ix86_option_override_internal): Mask out
>> the CF_SET bit when checking -fcf-protection.
>> ---
>> gcc/config/i386/i386.c | 10 +++++-----
>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> index 6c612c77987..ef7ff89bcbb 100644
>> --- a/gcc/config/i386/i386.c
>> +++ b/gcc/config/i386/i386.c
>> @@ -4913,12 +4913,12 @@ ix86_option_override_internal (bool
>> main_args_p,
>> = build_target_option_node (opts);
>>
>> /* Do not support control flow instrumentation if CET is not enabled. */
>> - if (opts->x_flag_cf_protection != CF_NONE)
>> + cf_protection_level cf_protection
>> + = (cf_protection_level) (opts->x_flag_cf_protection & ~CF_SET);
>> + if (cf_protection != CF_NONE)
>> {
>> - switch (flag_cf_protection)
>> + switch (cf_protection)
>> {
>> - case CF_NONE:
>> - break;
>> case CF_BRANCH:
>> if (! TARGET_IBT_P (opts->x_ix86_isa_flags2))
>> {
>> @@ -4953,7 +4953,7 @@ ix86_option_override_internal (bool main_args_p,
>> }
>>
>> opts->x_flag_cf_protection =
>> - (cf_protection_level) (opts->x_flag_cf_protection | CF_SET);
>> + (cf_protection_level) (cf_protection | CF_SET);
>> }
>>
>> if (ix86_tune_features [X86_TUNE_AVOID_128FMA_CHAINS])
>> --
>> 2.14.3
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-07 8:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-06 21:09 [PATCH] i386: Mask out the CF_SET bit for -fcf-protection check H.J. Lu
2018-02-06 21:20 ` Tsimbalist, Igor V
2018-02-07 8:52 ` Uros Bizjak
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).