From patchwork Thu Jan 6 18:57:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 49663 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A39983858030 for ; Thu, 6 Jan 2022 18:58:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A39983858030 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1641495498; bh=ewmZ68zd3WhUA6M73A0SYRS2/8wmGn+kBDJ1j6noRdg=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=kNxAIxDJtq4rCiNrUck9sHhwF2QvAYsyX7X+V9xtA6boWbjoAYH0PzhKKbvFq37kY jiYYcLmHkRwpteivlVWVekpKhgYvJvnKqo+ilaDZtWVkqfFADRoZmPr/jhOSvW19CG uuI2s6PRTikuo+NZTJGDKreN5hTxzmJDD4x9xZjI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 74F893858408 for ; Thu, 6 Jan 2022 18:57:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74F893858408 Received: by mail-pf1-x42b.google.com with SMTP id v13so3281037pfi.3 for ; Thu, 06 Jan 2022 10:57:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ewmZ68zd3WhUA6M73A0SYRS2/8wmGn+kBDJ1j6noRdg=; b=igjcI+JdpSGrx+3GoNsHH/iv1d16hiWGa2cTh3rixqU9HfIV7Tldx2wAOH+zB/mf5a W9My8EoDeTHAWCzyMho+uoqWjmqEANPuJTEqYmhjku3rcGg12PSOXidAddyDuhkqrR3L j+aUvaDI2eeGiOJ1uYyL2OHdGm3sbM80n4Pw2AwgOt6E5BSitSJuoM+wd6vjI5w7cuKa VEVM1Nt1V3kxL5HNVsSbszIUW9LTnenRPcRlDctZ2lJdY1x9WFSCsLNeG/l5ZuWt2Xzw zThoG5J9uyOoOj+4smVyjqJIVs/QstLJGB+NMBOQ1RoPpxa/Sv8PGj6PtYlGARuP1rU3 1gzA== X-Gm-Message-State: AOAM531c9P1u1hc6jtn1ePqwCWa62ebP+x8vl3xqoU0J7X4sd7eEKdmH /htVJgXx6Ei5Cpv0URjrgRPqdXDT7r4= X-Google-Smtp-Source: ABdhPJy+D6zeOfF/N2eznMw9CECmyDjeiXJmJAd/snmQcogi8rL+LP0c+V0ERVBDf3b8tYJl3+J6xg== X-Received: by 2002:a63:3341:: with SMTP id z62mr44912848pgz.99.1641495467203; Thu, 06 Jan 2022 10:57:47 -0800 (PST) Received: from gnu-tgl-3.localdomain ([172.58.35.133]) by smtp.gmail.com with ESMTPSA id x33sm3771905pfh.212.2022.01.06.10.57.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 10:57:46 -0800 (PST) Received: from gnu-tgl-2.localdomain (gnu-tgl-2 [192.168.1.42]) by gnu-tgl-3.localdomain (Postfix) with ESMTPS id D34DCC0284; Thu, 6 Jan 2022 10:57:45 -0800 (PST) Received: from gnu-tgl-2.. (localhost [IPv6:::1]) by gnu-tgl-2.localdomain (Postfix) with ESMTP id 9FDFA3003B1; Thu, 6 Jan 2022 10:57:44 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] x86: Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp Date: Thu, 6 Jan 2022 10:57:44 -0800 Message-Id: <20220106185744.1561567-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3028.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: "H.J. Lu via Gcc-patches" From: "H.J. Lu" Reply-To: "H.J. Lu" Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Indirect branch also includes indirect call instructions. Rename -harden-sls=indirect-branch to -harden-sls=indirect-jmp to match its intended behavior. PR target/102952 * config/i386/i386-opts.h (harden_sls): Replace harden_sls_indirect_branch with harden_sls_indirect_jmp. * config/i386/i386.c (ix86_output_jmp_thunk_or_indirect): Likewise. (ix86_output_indirect_jmp): Likewise. (ix86_output_call_insn): Likewise. * config/i386/i386.opt: Replace indirect-branch with indirect-jmp. Replace harden_sls_indirect_branch with harden_sls_indirect_jmp. * doc/invoke.texi (-harden-sls=): Replace indirect-branch with indirect-jmp. --- gcc/config/i386/i386-opts.h | 4 ++-- gcc/config/i386/i386.c | 6 +++--- gcc/config/i386/i386.opt | 2 +- gcc/doc/invoke.texi | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h index b31f9506c35..8f71e89fa9a 100644 --- a/gcc/config/i386/i386-opts.h +++ b/gcc/config/i386/i386-opts.h @@ -124,8 +124,8 @@ enum instrument_return { enum harden_sls { harden_sls_none = 0, harden_sls_return = 1 << 0, - harden_sls_indirect_branch = 1 << 1, - harden_sls_all = harden_sls_return | harden_sls_indirect_branch + harden_sls_indirect_jmp = 1 << 1, + harden_sls_all = harden_sls_return | harden_sls_indirect_jmp }; #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 1a964fe00f4..835ec2cafcb 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -16037,7 +16037,7 @@ ix86_output_jmp_thunk_or_indirect (const char *thunk_name, const int regno) fprintf (asm_out_file, "\tjmp\t"); assemble_name (asm_out_file, thunk_name); putc ('\n', asm_out_file); - if ((ix86_harden_sls & harden_sls_indirect_branch)) + if ((ix86_harden_sls & harden_sls_indirect_jmp)) fputs ("\tint3\n", asm_out_file); } else @@ -16263,7 +16263,7 @@ ix86_output_indirect_jmp (rtx call_op) } else output_asm_insn ("%!jmp\t%A0", &call_op); - return (ix86_harden_sls & harden_sls_indirect_branch) ? "int3" : ""; + return (ix86_harden_sls & harden_sls_indirect_jmp) ? "int3" : ""; } /* Output return instrumentation for current function if needed. */ @@ -16430,7 +16430,7 @@ ix86_output_call_insn (rtx_insn *insn, rtx call_op) { output_asm_insn (xasm, &call_op); if (!direct_p - && (ix86_harden_sls & harden_sls_indirect_branch)) + && (ix86_harden_sls & harden_sls_indirect_jmp)) return "int3"; } return ""; diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index e69955bd1a8..eb829d13d40 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -1144,7 +1144,7 @@ EnumValue Enum(harden_sls) String(return) Value(harden_sls_return) EnumValue -Enum(harden_sls) String(indirect-branch) Value(harden_sls_indirect_branch) +Enum(harden_sls) String(indirect-jmp) Value(harden_sls_indirect_jmp) EnumValue Enum(harden_sls) String(all) Value(harden_sls_all) diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 04820656ffa..6b84228f142 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -32507,8 +32507,8 @@ Force indirect call and jump via register. @opindex mharden-sls Generate code to mitigate against straight line speculation (SLS) with @var{choice}. The default is @samp{none} which disables all SLS -hardening. @samp{return} enables SLS hardening for function return. -@samp{indirect-branch} enables SLS hardening for indirect branch. +hardening. @samp{return} enables SLS hardening for function returns. +@samp{indirect-jmp} enables SLS hardening for indirect jumps. @samp{all} enables all SLS hardening. @item -mindirect-branch-cs-prefix