From patchwork Sat Apr 21 12:26:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 902391 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-476698-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Q9V6FGd3"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40SsRL4CZZz9s1t for ; Sat, 21 Apr 2018 22:26:52 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=jljZ/EWYxdnu1l2bZnrE37bqgTDKzOV7TiOLkkhNHn9Gyj7uqR RSnJAHhyVQOmXF8RqMxIRKt47JZnTakEB5zvARr7ONMV43ZDD2l3Qfulm0I7qFC4 iFdF1vWQBl2cfgZwncAJcZep8wMpSQJ8M/4qWLKjd+RLklDwbhO2Ps4Qc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:mime-version:content-type; s= default; bh=LWBrmyOzrLtxFZZrgoDo0drayI8=; b=Q9V6FGd3y7+d/p+e47P5 KoT17jU4kZljgs5P7U0U3j83qOSkjuk4RBfBCNDE6WeGfkMtkyyVRZZc0sz2lXFC MyT006kTs00D/P5B7t7L445vc0pfioB/LzxCjVhMDN5K31SWIk9+vi0w049x1Si0 Be2CVKtkgwN9FrM62QOzLNo= Received: (qmail 40529 invoked by alias); 21 Apr 2018 12:26:44 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 39813 invoked by uid 89); 21 Apr 2018 12:26:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:sk:3-v6mr1 X-HELO: mail-pg0-f54.google.com Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 21 Apr 2018 12:26:41 +0000 Received: by mail-pg0-f54.google.com with SMTP id e9so5223398pgr.7 for ; Sat, 21 Apr 2018 05:26:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=x0BTaQpSQ0xfTo5hagfOgb6gnGjYRUuRqgqswqzJlmY=; b=Qgk5axi+At1KgxYtQGGE9cw+yHsUlllOlYsSGlDVq8KTlcWBGtaULZ/W3xLky7GHTm XlbtuOt+PmXc7T6h5oOTiUGbZ7cLQ6/UCaCE0mbLXr6Lk82dN3JYPZBqsBj7nW8qOx9A DrdR1HZmXAqxYa/czahRC1VqElBfPsBkYGf2bzs8ImBCMrFFijGvBAMW/AXfk4B3qRgS K90/39RMp5CdMBWBgUQKYxziLC8K/7pBU7ZKj1mejEJHVJyL/gG+FvQmQEUY5957LRGV QXdINR+/JtJ64u2+LyXGS1qhdUMnLOiCjulMCkNEFoYzfxrRR/9WhNtguX+hjokf/4pL AtNA== X-Gm-Message-State: ALQs6tD3sYizpZ4jOLJs8jH/Bjk0DDUPrQfpfcEInItnLPaQ0k2KH3re JoZA6hHjZ+cAfP9Sz6T8UaZjNQ== X-Google-Smtp-Source: AIpwx49hWbMatE7C90G+RdpYpJQvcuuTWyREMVAWTESx1lcpEYVaoDd2ANzb1umnJgb0eCHxyKZwaA== X-Received: by 2002:a17:902:f83:: with SMTP id 3-v6mr13533407plz.336.1524313599175; Sat, 21 Apr 2018 05:26:39 -0700 (PDT) Received: from gnu-tools-1.localdomain (c-73-93-86-59.hsd1.ca.comcast.net. [73.93.86.59]) by smtp.gmail.com with ESMTPSA id b4sm14548225pfa.64.2018.04.21.05.26.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 21 Apr 2018 05:26:38 -0700 (PDT) Received: by gnu-tools-1.localdomain (Postfix, from userid 1000) id 67A2620890; Sat, 21 Apr 2018 05:26:37 -0700 (PDT) Date: Sat, 21 Apr 2018 05:26:37 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, Uros Bizjak Cc: Igor Tsimbalist Subject: [PATCH] x86: Update __CET__ check Message-ID: <20180421122637.GA5188@gmail.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.2 (2017-12-15) X-IsSubscribed: yes __CET__ has been changed by revision 259522: commit d59cfa9a4064339cf2bd2da828c4c133f13e57f0 Author: hjl Date: Fri Apr 20 13:30:13 2018 +0000 Define __CET__ for -fcf-protection and remove -mibt to (__CET__ & 1) != 0: -fcf-protection=branch or -fcf-protection=full (__CET__ & 2) != 0: -fcf-protection=return or -fcf-protection=full We should check (__CET__ & 2) != 0 for shadow stack. OK for trunk? H.J. --- libgcc/ * config/i386/linux-unwind.h: Add (__CET__ & 2) != 0 check when including "config/i386/shadow-stack-unwind.h". libitm/ * config/x86/sjlj.S (_ITM_beginTransaction): Add (__CET__ & 2) != 0 check for shadow stack. (GTM_longjmp): Likewise. --- libgcc/config/i386/linux-unwind.h | 2 +- libitm/config/x86/sjlj.S | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libgcc/config/i386/linux-unwind.h b/libgcc/config/i386/linux-unwind.h index f1f52334d8d..ea838e4e47b 100644 --- a/libgcc/config/i386/linux-unwind.h +++ b/libgcc/config/i386/linux-unwind.h @@ -23,7 +23,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ /* Unwind shadow stack for -fcf-protection -mshstk. */ -#if defined __SHSTK__ && defined __CET__ +#if defined __SHSTK__ && defined __CET__ && (__CET__ & 2) != 0 # include "config/i386/shadow-stack-unwind.h" #endif diff --git a/libitm/config/x86/sjlj.S b/libitm/config/x86/sjlj.S index ee61451394a..3cac9099c9e 100644 --- a/libitm/config/x86/sjlj.S +++ b/libitm/config/x86/sjlj.S @@ -141,7 +141,7 @@ SYM(_ITM_beginTransaction): movq %r15, -24(%rax) xorq %rdx, %rdx /* Save zero or shadow stack pointer in the new field. */ -#if defined(__SHSTK__) && defined(__CET__) +#if defined __SHSTK__ && defined __CET__ && (__CET__ & 2) != 0 rdsspq %rdx #endif movq %rdx, -16(%rax) @@ -177,7 +177,7 @@ SYM(_ITM_beginTransaction): movl %ebp, 20(%esp) xorl %edx, %edx /* Save zero or shadow stack pointer in the new field. */ -#if defined(__SHSTK__) && defined(__CET__) +#if defined __SHSTK__ && defined __CET__ && (__CET__ & 2) != 0 rdsspd %edx #endif movl %edx, 24(%esp) @@ -221,7 +221,7 @@ SYM(GTM_longjmp): cfi_offset(%rip, 64) cfi_register(%rsp, %rcx) movq %rcx, %rsp -#if defined(__SHSTK__) && defined(__CET__) +#if defined __SHSTK__ && defined __CET__ && (__CET__ & 2) != 0 /* Check if Shadow Stack is enabled. */ xorq %rcx, %rcx rdsspq %rcx @@ -259,7 +259,7 @@ SYM(GTM_longjmp): cfi_offset(%eip, 24) cfi_register(%esp, %ecx) movl %ecx, %esp -#if defined(__SHSTK__) && defined(__CET__) +#if defined __SHSTK__ && defined __CET__ && (__CET__ & 2) != 0 /* Check if Shadow Stack is enabled. */ xorl %ecx, %ecx rdsspd %ecx