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 2771A385828E for ; Tue, 5 Jul 2022 10:05:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2771A385828E 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 0214223A; Tue, 5 Jul 2022 03:05:39 -0700 (PDT) Received: from [10.2.78.70] (unknown [10.2.78.70]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E24B33F792; Tue, 5 Jul 2022 03:05:37 -0700 (PDT) Message-ID: Date: Tue, 5 Jul 2022 11:05:36 +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 4/12] arm: Add testsuite library support for PACBTI target Content-Language: en-GB To: Andrea Corallo Cc: Andrea Corallo via Gcc-patches , Richard Earnshaw , nd References: <37b6b3d9-bd69-e34a-e762-5312638338f9@foss.arm.com> From: Richard Earnshaw In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3489.4 required=5.0 tests=BAYES_00, BODY_8BITS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, 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: Tue, 05 Jul 2022 10:05:40 -0000 On 04/07/2022 15:47, Andrea Corallo wrote: > Richard Earnshaw writes: > >> On 01/07/2022 14:03, Richard Earnshaw via Gcc-patches wrote: >>> On 28/04/2022 10:40, Andrea Corallo via Gcc-patches wrote: >>>> Add targeting-checking entities for PACBTI in testsuite >>>> framework. >>>> >>>> Pre-approved with the requested changes here >>>> >. >>>> >>>> gcc/testsuite/ChangeLog: >>>> >>>>     * testsuite/lib/target-supports.exp: >>>>     (check_effective_target_arm_pacbti_hw): New. >>>>     * doc/sourcebuild.texi: Document arm_pacbti_hw. >>>> >>>> Co-Authored-By: Tejas Belagod  >>>> >>> +proc check_effective_target_arm_pacbti_hw {} { >>> +    return [check_runtime arm_pacbti_hw_available { >>> +    __attribute__ ((naked)) int >>> +    main (void) >>> +    { >>> +      asm ("pac r12, lr, sp"); >>> So the armv8-m Arm ARM says that this instruction is in the NOP >>> space and that it is undefined if we aren't armv8-m.main or higher. >>> +      asm ("mov r0, #0"); >>> +      asm ("autg r12, lr, sp"); >>> This isn't in the nop space, but the Arm ARM says it is >>> unpredictable if the extension isn't present.  Unfortunately, that >>> means this isn't a particularly reliable way of detecting that the >>> PACBTI feature is present. >>> However, I can't think off hand of more reliable way of testing this >>> since reading the feature register ID_ISAR5 is not possible when in >>> unprivileged mode. >>> So I think we'll have to live with this. >>> +      asm ("bx lr"); >>> +    } >>> +    } ""] >>> OK. >>> >> >> Or perhaps not. The test does not try to add the right options to >> enable PAC/BTI if those aren't in the default selection for the >> current testsuite run. >> >> Perhaps we also need some additional tests to work out what >> architecture options to add (if any) to ensure the test will at least >> assemble. > > Hi Richard, > thanks for reviewing. > > Wouldn't be sufficient for that to have this test compiled with > -march=armv8-m.main? Take a look at how, for example, check_effective_target_arm_mve_hw (and add_options_for_v8_1_m_mve_fp) is implemented. R. > > BR > >   Andrea