From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web12.218.1590185400220491033 for ; Fri, 22 May 2020 15:10:00 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) 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 BD9ACD6E; Fri, 22 May 2020 15:09:58 -0700 (PDT) Received: from [192.168.1.81] (unknown [10.37.8.117]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6C8313F68F; Fri, 22 May 2020 15:09:57 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH] MdePkg/Include: AARCH64: disable outline atomics on GCC 10.2+ To: devel@edk2.groups.io, lersek@redhat.com Cc: liming.gao@intel.com, leif@nuviainc.com, philmd@redhat.com, mliska@suse.cz References: <20200522101202.15016-1-ard.biesheuvel@arm.com> <36effdcd-91a7-da00-855d-570e64d650b8@redhat.com> From: "Ard Biesheuvel" Message-ID: <5587f0f0-9f30-62ce-9d07-5eed4ac6daa7@arm.com> Date: Sat, 23 May 2020 00:09:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 5/22/20 10:05 PM, Laszlo Ersek via groups.io wrote: > On 05/22/20 22:01, Laszlo Ersek wrote: >> On 05/22/20 12:12, Ard Biesheuvel wrote: >>> GCC 10 enabled a feature by default that was introduced in GCC 9, >>> which results in atomic operations to be emitted as function calls >>> to intrinsics provided by a runtime library. >>> >>> Atomics are hardly used in EDK2, which runs on a single CPU anyway, >>> and any benefit that would result from reusing library code that >>> implements these operations is defeated by the fact that every EDK2 >>> module will need to have its own copy anyway. >>> >>> So let's disable this feature on GCC versions that support the >>> pragma to do so (GCC 10.2 and up) >>> >>> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2723 >>> Signed-off-by: Ard Biesheuvel >>> --- >>> The GCC support for this pragma has already been pulled into the 10.2 >>> release branch. I think we should consider adding this to the stable >>> tag, so that the issue can easily be resolved by upgrading the compiler. >>> Whether we add the intrinsics too is a separate matter, but we can >>> revisit that later. >>> >>> MdePkg/Include/AArch64/ProcessorBind.h | 11 +++++++++++ >>> 1 file changed, 11 insertions(+) >>> >>> diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h >>> index 896bf273ac7a..a3ca8f09e51c 100644 >>> --- a/MdePkg/Include/AArch64/ProcessorBind.h >>> +++ b/MdePkg/Include/AArch64/ProcessorBind.h >>> @@ -24,6 +24,17 @@ >>> #pragma pack() >>> #endif >>> >>> +#if defined(__GNUC__) && !defined(__clang__) >>> + >>> +// >>> +// Disable GCC outline atomics >>> +// Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2723 >>> +// >>> +#if __GNUC__ > 10 || (__GNUC__ == 10 && __GNUC_MINOR__ >= 2) >>> +#pragma GCC target "no-outline-atomics" >>> +#endif >>> +#endif >>> + >>> #if defined(_MSC_EXTENSIONS) >>> >>> // >>> >> >> Reviewed-by: Laszlo Ersek >> >> But I think it should be merged later, after GCC 10.2 is out. >> >> (Obviously I don't "insist" that we follow this approach, I'm just OK >> with it.) > > Oh and I think both this patch and the assembly language implementation > for the atomics should be delayed after the stable tag. gcc-10 is a new > toolchain; so even if we don't introduce a new toolchain tag such as > GCC10 for it, whatever we do in order to make it work, that's feature > enablement in my book. > Works for me. By the time the next stable tag comes around, early adopters that are now on GCC 10.1 will likely have moved to 10.2 by that time, and so we may not need the assembly patch at all.