From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 97654383642E for ; Wed, 11 May 2022 20:52:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 97654383642E Received: by mail-pf1-x42b.google.com with SMTP id 204so3000513pfx.3 for ; Wed, 11 May 2022 13:52:54 -0700 (PDT) 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=VzpXSTeM24tEJNGFSFtKYke960MJc8/yLLBrepEJZuQ=; b=GAY+nC0Wc0ZXISot0vWo92ZzUHZraXK3bDveNeGByG1UQp+t+BDj91zgV+CIfV/86p 2bluTY0hPJHY0Q5Hr7AuSIwZeEyeLZifploshvlbUMiU5+XLBymGOWAvQEUdJOEXv37g 8/82XjwQRKbyUvUPg/WgbXzDjQQXWoWsOgnF69wlI83h5Ejd9EwElZ/4lYWLJcwVHr0o J1X+HXupx86qXrV/D/64SejWFbCRSOQQt9cKxKdysQQXIfrDCJJ4HIZW9Xj8QBJnlhTW lrLeNC8v6ki5f3zo4Rn1dTW2+z9B4HhJlbvLKILniTwrQ28309Cfss4gNdlKaze2oz2c GlCQ== X-Gm-Message-State: AOAM532plZhw/4DlTnsMQsHwbEROTd4JGHLk5CcYb7yni6UkYc/5yn85 j6KX9jI0lk4dEHMhf5WuNgnJ7hsYVNo= X-Google-Smtp-Source: ABdhPJzFKIk3ApavKppOGIjTAHQHqkQHXphTm5lmcicGKM5rMSSqmHPFvwPLPut1AiL04PvmexNaoA== X-Received: by 2002:a05:6a00:150d:b0:510:3a9c:3eed with SMTP id q13-20020a056a00150d00b005103a9c3eedmr26911811pfu.86.1652302373333; Wed, 11 May 2022 13:52:53 -0700 (PDT) Received: from gnu-tgl-3.localdomain ([172.58.88.122]) by smtp.gmail.com with ESMTPSA id 68-20020a621647000000b0050dc76281ebsm2155592pfw.197.2022.05.11.13.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 13:52:52 -0700 (PDT) Received: from gnu-tgl-3.. (localhost [IPv6:::1]) by gnu-tgl-3.localdomain (Postfix) with ESMTP id AAB44C021F; Wed, 11 May 2022 13:52:51 -0700 (PDT) From: "H.J. Lu" To: gcc-patches@gcc.gnu.org Cc: Uros Bizjak , Florian Weimer Subject: [PATCH v2] x86: Document -mcet-switch Date: Wed, 11 May 2022 13:52:51 -0700 Message-Id: <20220511205251.2947362-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3028.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Wed, 11 May 2022 20:52:56 -0000 When -fcf-protection=branch is used, the compiler will generate jump tables for switch statements where the indirect jump is prefixed with the NOTRACK prefix, so it can jump to non-ENDBR targets. Since the indirect jump targets are generated by the compiler, they are always valid. Document -mcet-switch to generate jump tables for switch statements with ENDBR and skip the NOTRACK prefix for indirect jump. This option should be used when the NOTRACK prefix is disabled. PR target/104816 * config/i386/i386.opt: Remove Undocumented. * doc/invoke.texi: Document -mcet-switch. --- gcc/config/i386/i386.opt | 2 +- gcc/doc/invoke.texi | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index a6b0e28f238..0dbaacb57ed 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -1047,7 +1047,7 @@ Enable shadow stack built-in functions from Control-flow Enforcement Technology (CET). mcet-switch -Target Undocumented Var(flag_cet_switch) Init(0) +Target Var(flag_cet_switch) Init(0) Turn on CET instrumentation for switch statements that use a jump table and an indirect jump. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 7a35d9613a4..968853690f9 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1420,7 +1420,8 @@ See RS/6000 and PowerPC Options. -msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop @gol -madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mhle -mlwp @gol -mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes -mwaitpkg @gol --mshstk -mmanual-endbr -mforce-indirect-call -mavx512vbmi2 -mavx512bf16 -menqcmd @gol +-mshstk -mmanual-endbr -mcet-switch -mforce-indirect-call @gol +-mavx512vbmi2 -mavx512bf16 -menqcmd @gol -mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq @gol -mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid @gol -mrdseed -msgx -mavx512vp2intersect -mserialize -mtsxldtrk@gol @@ -32641,6 +32642,11 @@ function attribute. This is useful when used with the option @option{-fcf-protection=branch} to control ENDBR insertion at the function entry. +@item -mcet-switch +@opindex mcet-switch +Turn on CET instrumentation for switch statements that use a jump table +and an indirect jump. + @item -mcall-ms2sysv-xlogues @opindex mcall-ms2sysv-xlogues @opindex mno-call-ms2sysv-xlogues -- 2.35.1