From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web10.15116.1590680890323996850 for ; Thu, 28 May 2020 08:48:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=s/jLY/xQ; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: liming.gao@intel.com) IronPort-SDR: 5YoOapT3eUg92oHVz5FjunHxsEDezGxyIzRuRR78TEVPgbmBYWRB2XwCObJg26iBYgGcODQoyu 6dBashcIHxuQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 08:48:08 -0700 IronPort-SDR: KZQLcHtvI30htS9ucohg7kgfWP/NhrbsMNNFHRhxfWsg5lvm50EoDPBto7YBfBNtc+AQDEy6m1 tcr7F2HUK+2A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,445,1583222400"; d="scan'208";a="257093322" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga008.fm.intel.com with ESMTP; 28 May 2020 08:48:08 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 28 May 2020 08:48:08 -0700 Received: from fmsmsx607.amr.corp.intel.com (10.18.126.87) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 28 May 2020 08:48:08 -0700 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by fmsmsx607.amr.corp.intel.com (10.18.126.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.1713.5 via Frontend Transport; Thu, 28 May 2020 08:48:08 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.171) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 28 May 2020 08:48:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QJ70PrMiBOwcWxcOMRNVBxTncAQMG9NC4iEQnK51Sc7eXbansCYJEbV717wMgIlqvydjtrw5KIzyWwiFWz7bHghDFBhPUJadvstOdxkC//At/bYzdR87urDNw58tDjsaySXz8g2oV4JI8iym88CXIhRZvfKfzPEqva1+y+u2srKvjDg8s13St07sXHKZ7Os9LPPL7cLFiFxv9ZsV3tq8sIQtINranrl28SiA5ze+ieneFL9ybr4+BrwTpuD+pjhl/WusMpZNLi5kEz2c8C6eBIaXgYw/gSgbXS8+VUnu7ib3CTN1/+Nyki16GXC2Jgczew7ggcHork7E8cw49U4IKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q9irMO3WCDgN0UTEyUXFMzL2Tx/D1TN85qf90aQBa28=; b=NyaWWFCxfD5avJUqE8uAzoqfHWZT1bSXiYgoL6xd51Q67Qlwc3N2cNOlvjXU+X7gy6+awlidOtL+yDDlXlO9n67OzZ8R1lLkh+4rnMxZZP7If+7aB+1+YUWwjRRhlclU+zqGta84ceA+i7UbGvo+YzlXf6AG3Q619paQ750pgMVbeQFNC7Nfqlz22VArNot2k/6pusJxXj8WskKsa/gt1wVkUrBxtXk+w5k85MVShDSAlssPZzhH5Soo6xia4za8Xkk6FIOHTRHKTVNFdXO3SSkKdQtZW7LD8IZvlu7dpN3K6xkX0XQVG5aW91OjBvrr9qyfGz0H/aPCHcQtryuVIg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=q9irMO3WCDgN0UTEyUXFMzL2Tx/D1TN85qf90aQBa28=; b=s/jLY/xQyv+i1Qf9jtBb1MhQCidfgLrazDzoLuJtyfBArT6pp/lLzXME78JYKCICJ2b/qC/zNA6VX1oRRIHv7LibDqNcUALO2oSz8SHarDZo/fp+sVCIhpyyNCXbWnLIj/+M+BtKQc7PruvXKKfzjqShvWphp/oO9VdAqbDF4Tg= Received: from BYAPR11MB3191.namprd11.prod.outlook.com (2603:10b6:a03:79::25) by BYAPR11MB3829.namprd11.prod.outlook.com (2603:10b6:a03:fa::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3021.27; Thu, 28 May 2020 15:48:06 +0000 Received: from BYAPR11MB3191.namprd11.prod.outlook.com ([fe80::b869:6ea9:634e:82c8]) by BYAPR11MB3191.namprd11.prod.outlook.com ([fe80::b869:6ea9:634e:82c8%5]) with mapi id 15.20.3045.018; Thu, 28 May 2020 15:48:06 +0000 From: "Liming Gao" To: Leif Lindholm , Gary Lin , "afish@apple.com" , "Kinney, Michael D" CC: "devel@edk2.groups.io" , "ard.biesheuvel@arm.com" , "lersek@redhat.com" , "Gao, Liming" Subject: Re: [edk2-devel] [PATCH v2] ArmPkg/CompilerIntrinsicsLib: provide atomics intrinsics Thread-Topic: [edk2-devel] [PATCH v2] ArmPkg/CompilerIntrinsicsLib: provide atomics intrinsics Thread-Index: AQHWLpwsjn/uVTdvX0qkys69nPSvV6i8w52AgACJlwCAAGEp0A== Date: Thu, 28 May 2020 15:48:05 +0000 Message-ID: References: <20200520114448.26104-1-ard.biesheuvel@arm.com> <20200528013633.GF24379@GaryWorkstation> <20200528094900.GB1923@vanye> In-Reply-To: <20200528094900.GB1923@vanye> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action authentication-results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [192.55.52.207] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8fb580c1-3637-4332-869a-08d8031e8353 x-ms-traffictypediagnostic: BYAPR11MB3829: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 0417A3FFD2 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: cGGD1SuZWKaLqVd5VWzEvXiA6LpUqVPlAZR7jF52y9424VJWJXHTCLHsGNQR9c39v50aL/+9Wq+wLId5e4ZCIOdGVJjTl16UDuBcTpa9OdCy3WsZnxjZEjHazztxVks7CqZacVlJq5ClXlt7eHSJXa7nSaDbFizhg8qgwptpGpe2NXNXXugXihsWfXNCCElcCewX0SRX9IjgjfQGwkgso3cpp2YJ3gD2kNY4s34EXbGOixahtI0br4vlXVPAR9pMqX6knKbYjgRhCwWTkA9SpPoiwu0h/ae7vKHioQjj03KGeyX2ZPmY04l4Rtnl2mC9dGOvPH9YiX+vbtaHnPE4K9AMWyOjB6HLD4JHVHyR26OBCe46hL4/KzBgMtj3ufgxprdX86V280rfTYJJ7vQ2cpap7Wl3zSL70s4KO1H13nGCY2F6ieFb0pO0dhKepgLriWgxp0hScl/I/7IRaMAkcw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR11MB3191.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFTY:;SFS:(39860400002)(346002)(376002)(136003)(396003)(366004)(55016002)(7696005)(5660300002)(107886003)(86362001)(186003)(66946007)(8936002)(76116006)(64756008)(66476007)(66556008)(83380400001)(66446008)(54906003)(2906002)(110136005)(71200400001)(52536014)(8676002)(53546011)(9686003)(6506007)(316002)(6636002)(478600001)(26005)(4326008)(33656002)(966005)(357404004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: DlICt6yTi0N5oz5YJUhX0H8qVqQd373o7lqqfiBJGxghdYeEEObq0FJ8ckXsWEbhxEw+Nd2/3Kg821WAcIMHFzkM2UiIzCncxM+IiCGGbSV8mI4qM3RNTqPmcwiUf5p6ybFEUzLUR0YNu2jZT2t+4Wpo0kM/PoTGIHMfsFYTq6bMUOaq0yFQ3XjqsZgq4/6oE8fQUH1yQcp8NhqTtpSISx94mwMhCvvd/EBlgAS5aWWLSpR58NZL/0KW66U7CAlFVax63QvzaR1BSbc0VnAiVuYrOxwKWiGonbEt/ZtKg9lwyqVXoSAuC4MlgmaoNo9FKdpyRPRFL9nWeDA5OqscOBJf/rNoNTCFfa8G6td7Z4Lwk4EW1uoUMhemvg9e3bj6wn840PyY5OcvkVcpcj2jrTIMZMcNHZxyxPIXZFBTDfM0ow2WAnqWMUPiE7hmFau6DuA4YCq7BiEDj1xO31BKPzxtfJwZKyY1wT0SwLQPxR/hP1rpMS7HoOqgBoWza+Bv MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 8fb580c1-3637-4332-869a-08d8031e8353 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 May 2020 15:48:05.5439 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Nyq5TeDqjnREMqWOfCxoj+8N6pbHbE+sU6+b9y1ym6AUS+/0Pv7mD/z4d/YA2i6YyFyRBITJL+sCgbX8eX4AOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB3829 Return-Path: liming.gao@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Leif: BZ 2723 is a tiano feature request. This patch adds support for new GCC1= 0. I agree with Laszlo that this change is like the enhancement instead of = the critical bug fix. So, I suggest to delay it after this stable tag.=20 Thanks Liming > -----Original Message----- > From: Leif Lindholm > Sent: Thursday, May 28, 2020 5:49 PM > To: Gary Lin > Cc: devel@edk2.groups.io; ard.biesheuvel@arm.com; lersek@redhat.com; Gao= , Liming > Subject: Re: [edk2-devel] [PATCH v2] ArmPkg/CompilerIntrinsicsLib: provi= de atomics intrinsics >=20 > On Thu, May 28, 2020 at 09:36:33 +0800, Gary Lin wrote: > > On Wed, May 20, 2020 at 01:44:48PM +0200, Ard Biesheuvel wrote: > > > Gary reports the GCC 10 will emit calls to atomics intrinsics routin= es > > > unless -mno-outline-atomics is specified. This means GCC-10 introduc= es > > > new intrinsics, and even though it would be possible to work around = this > > > by specifying the command line option, this would require a new GCC1= 0 > > > toolchain profile to be created, which we prefer to avoid. > > > > > > So instead, add the new intrinsics to our library so they are provid= ed > > > when necessary. > > > > > > Signed-off-by: Ard Biesheuvel > > After applying this patch, gcc 10 can build ArmVirtPkg without the > > linking error. > > > > Tested-by: Gary Lin >=20 > Thanks Gary. >=20 > Liming, can we consider this patch for stable tag please? >=20 > With an added link to > https://bugzilla.tianocore.org/show_bug.cgi?id=3D2723 in the commit mess= age: > Reviewed-by: Leif Lindholm >=20 > / > Leif >=20 > > > --- > > > v2: > > > - add missing .globl to export the functions from the object file > > > - add function end markers so the size of each is visible in the ELF= metadata > > > - add some comments to describe what is going on > > > > > > ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf | = 3 + > > > ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S | 14= 2 ++++++++++++++++++++ > > > 2 files changed, 145 insertions(+) > > > > > > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsics= Lib.inf > b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf > > > index d5bad9467758..fcf48c678119 100644 > > > --- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf > > > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf > > > @@ -79,6 +79,9 @@ [Sources.ARM] > > > Arm/ldivmod.asm | MSFT > > > Arm/llsr.asm | MSFT > > > > > > +[Sources.AARCH64] > > > + AArch64/Atomics.S | GCC > > > + > > > [Packages] > > > MdePkg/MdePkg.dec > > > ArmPkg/ArmPkg.dec > > > diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S = b/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S > > > new file mode 100644 > > > index 000000000000..dc61d6bb8e52 > > > --- /dev/null > > > +++ b/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S > > > @@ -0,0 +1,142 @@ > > > +#------------------------------------------------------------------= ------------ > > > +# > > > +# Copyright (c) 2020, Arm, Limited. All rights reserved.
> > > +# > > > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > > +# > > > +#------------------------------------------------------------------= ------------ > > > + > > > + /* > > > + * Provide the GCC intrinsics that are required when using GCC 9 o= r > > > + * later with the -moutline-atomics options (which became the defa= ult > > > + * in GCC 10) > > > + */ > > > + .arch armv8-a > > > + > > > + .macro =09reg_alias, pfx, sz > > > + r0_\sz =09.req \pfx\()0 > > > + r1_\sz =09.req \pfx\()1 > > > + tmp0_\sz .req \pfx\()16 > > > + tmp1_\sz .req \pfx\()17 > > > + .endm > > > + > > > + /* > > > + * Define register aliases of the right type for each size > > > + * (xN for 8 bytes, wN for everything smaller) > > > + */ > > > + reg_alias w, 1 > > > + reg_alias w, 2 > > > + reg_alias w, 4 > > > + reg_alias x, 8 > > > + > > > + .macro =09fn_start, name:req > > > + .section .text.\name > > > + .globl =09\name > > > + .type =09\name, %function > > > +\name\(): > > > + .endm > > > + > > > + .macro =09fn_end, name:req > > > + .size =09\name, . - \name > > > + .endm > > > + > > > + /* > > > + * Emit an atomic helper for \model with operands of size \sz, usi= ng > > > + * the operation specified by \insn (which is the LSE name), and w= hich > > > + * can be implemented using the generic load-locked/store-conditio= nal > > > + * (LL/SC) sequence below, using the arithmetic operation given by > > > + * \opc. > > > + */ > > > + .macro =09 emit_ld_sz, sz:req, insn:req, opc:req, model:req, s, a,= l > > > + fn_start __aarch64_\insn\()\sz\()\model > > > + mov =09tmp0_\sz, r0_\sz > > > +0: ld\a\()xr\s r0_\sz, [x1] > > > + .ifnc =09\insn, swp > > > + \opc =09tmp1_\sz, r0_\sz, tmp0_\sz > > > + .else > > > + \opc =09tmp1_\sz, tmp0_\sz > > > + .endif > > > + st\l\()xr\s w15, tmp1_\sz, [x1] > > > + cbnz =09w15, 0b > > > + ret > > > + fn_end =09__aarch64_\insn\()\sz\()\model > > > + .endm > > > + > > > + /* > > > + * Emit atomic helpers for \model for operand sizes in the > > > + * set {1, 2, 4, 8}, for the instruction pattern given by > > > + * \insn. (This is the LSE name, but this implementation uses > > > + * the generic LL/SC sequence using \opc as the arithmetic > > > + * operation on the target.) > > > + */ > > > + .macro =09emit_ld, insn:req, opc:req, model:req, a, l > > > + emit_ld_sz 1, \insn, \opc, \model, b, \a, \l > > > + emit_ld_sz 2, \insn, \opc, \model, h, \a, \l > > > + emit_ld_sz 4, \insn, \opc, \model, , \a, \l > > > + emit_ld_sz 8, \insn, \opc, \model, , \a, \l > > > + .endm > > > + > > > + /* > > > + * Emit the compare and swap helper for \model and size \sz > > > + * using LL/SC instructions. > > > + */ > > > + .macro =09 emit_cas_sz, sz:req, model:req, uxt:req, s, a, l > > > + fn_start __aarch64_cas\sz\()\model > > > + \uxt =09tmp0_\sz, r0_\sz > > > +0: ld\a\()xr\s r0_\sz, [x2] > > > + cmp =09r0_\sz, tmp0_\sz > > > + bne =091f > > > + st\l\()xr\s w15, r1_\sz, [x2] > > > + cbnz =09w15, 0b > > > +1: ret > > > + fn_end =09__aarch64_cas\sz\()\model > > > + .endm > > > + > > > + /* > > > + * Emit compare-and-swap helpers for \model for operand sizes in t= he > > > + * set {1, 2, 4, 8, 16}. > > > + */ > > > + .macro =09emit_cas, model:req, a, l > > > + emit_cas_sz 1, \model, uxtb, b, \a, \l > > > + emit_cas_sz 2, \model, uxth, h, \a, \l > > > + emit_cas_sz 4, \model, mov , , \a, \l > > > + emit_cas_sz 8, \model, mov , , \a, \l > > > + > > > + /* > > > + * We cannot use the parameterized sequence for 16 byte CAS, so we > > > + * need to define it explicitly. > > > + */ > > > + fn_start __aarch64_cas16\model > > > + mov =09x16, x0 > > > + mov =09x17, x1 > > > +0: ld\a\()xp x0, x1, [x4] > > > + cmp =09x0, x16 > > > + ccmp =09x1, x17, #0, eq > > > + bne =091f > > > + st\l\()xp w15, x16, x17, [x4] > > > + cbnz =09w15, 0b > > > +1: ret > > > + fn_end =09__aarch64_cas16\model > > > + .endm > > > + > > > + /* > > > + * Emit the set of GCC outline atomic helper functions for > > > + * the memory ordering model given by \model: > > > + * - relax unordered loads and stores > > > + * - acq load-acquire, unordered store > > > + * - rel unordered load, store-release > > > + * - acq_rel load-acquire, store-release > > > + */ > > > + .macro =09emit_model, model:req, a, l > > > + emit_ld =09ldadd, add, \model, \a, \l > > > + emit_ld =09ldclr, bic, \model, \a, \l > > > + emit_ld =09ldeor, eor, \model, \a, \l > > > + emit_ld =09ldset, orr, \model, \a, \l > > > + emit_ld =09swp, mov, \model, \a, \l > > > + emit_cas \model, \a, \l > > > + .endm > > > + > > > + emit_model _relax > > > + emit_model _acq, a > > > + emit_model _rel,, l > > > + emit_model _acq_rel, a, l > > > -- > > > 2.17.1 > > > > > > > > >=20 > > >