From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 173EF3858C52 for ; Mon, 4 Jul 2022 10:55:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 173EF3858C52 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D50A523A; Mon, 4 Jul 2022 03:55:12 -0700 (PDT) Received: from [10.57.7.73] (unknown [10.57.7.73]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C418F3F66F; Mon, 4 Jul 2022 03:55:11 -0700 (PDT) Message-ID: <86ba1f52-6b1b-0808-22cd-ff1684692c25@foss.arm.com> Date: Mon, 4 Jul 2022 11:55:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 3/12 V2] arm: Add option -mbranch-protection Content-Language: en-GB To: Andrea Corallo Cc: Richard Earnshaw , nd , Andrea Corallo via Gcc-patches References: <7599346b-1015-7dae-88a6-f7c8a8d82c98@foss.arm.com> From: Richard Earnshaw In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3490.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: Mon, 04 Jul 2022 10:55:14 -0000 On 04/07/2022 10:27, Andrea Corallo via Gcc-patches wrote: > Richard Earnshaw writes: > > [...] > >> +@item >> +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] >> +@opindex mbranch-protection >> +Enable branch protection features (armv8.1-m.main only). >> +@samp{none} generate code without branch protection or return address >> +signing. >> +@samp{standard[+@var{leaf}]} generate code with all branch protection >> +features enabled at their standard level. >> +@samp{pac-ret[+@var{leaf}]} generate code with return address signing >> +set to its standard level, which is to sign all functions that save >> +the return address to memory. >> +@samp{leaf} When return address signing is enabled, also sign leaf >> +functions even if they do not write the return address to memory. >> ++@samp{bti} Add landing-pad instructions at the permitted targets of >> +indirect branch instructions. >> + >> +If the @samp{+pacbti} architecture extension is not enabled, then all >> +branch protection and return address signing operations are >> +constrained to use only the instructions defined in the >> +architectural-NOP space. The generated code will remain >> +backwards-compatible with earlier versions of the architecture, but >> +the additional security can be enabled at run time on processors that >> +support the @samp{PACBTI} extension. >> + >> +Branch target enforcement using BTI can only be enabled at runtime if >> +all code in the application has been compiled with at least >> +@samp{-mbranch-protection=bti}. >> + >> +The default is to generate code without branch protection or return >> +address signing. >> >> This needs to make it clear that -mbranch-protection != none is only >> supported on armv8-m.main or later. >> >> R. > > Hi Richard, > > thanks for reviewing, please find attached the respinned patch. > > Ok for trunk (when the rest of the series will be approved)? > > Best Regards > > Andrea > > gcc/ChangeLog: > > * config/arm/arm.c (arm_configure_build_target): Parse and validate > -mbranch-protection option and initialize appropriate data structures. > * config/arm/arm.opt (-mbranch-protection): New option. > * doc/invoke.texi (Arm Options): Document it. > > Co-Authored-By: Tejas Belagod > Co-Authored-By: Richard Earnshaw > OK. R.