From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web11.43836.1685339518364690582 for ; Sun, 28 May 2023 22:51:59 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=SfP6cV+f; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: yong.li@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1685339518; x=1716875518; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=FZeLSiGvmCkJttvEliQn5bWJIcm/eCn6/DwYYxtvRbY=; b=SfP6cV+fsU9UvIzVIvfoAWfaHXOHR/PMHT5rjvskqfRIlrzlYh1yo+qY MfQQZUShL3KNnn3kGqndSB1xEjtyHn2TwcpCip3Dq99AKY5ioAqf7QfDy UkA3ItmbGT3c9Z8q0m1gDEfGpah/foEFdrZ30nI+64yC7pgjmXuTIjcTc 6h/ZgFXRjVbulm4rBA/mJjwusY69mOxqXZjIOhVQic017kRYpk5mJ8MuA 8x3WEVM/pfs8N37bqmnsqmFoAysACTJN325DFiw0keq8Asg1xFkIL+YBy LxcizlKnbi93ySR4hTSkZxjEKhjVoH+bmnuoJxC6Lla8urVWDVI0To9Z/ g==; X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="357006668" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="357006668" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2023 22:51:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10724"; a="775806825" X-IronPort-AV: E=Sophos;i="6.00,200,1681196400"; d="scan'208";a="775806825" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by fmsmga004.fm.intel.com with ESMTP; 28 May 2023 22:51:57 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sun, 28 May 2023 22:51:56 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Sun, 28 May 2023 22:51:56 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.103) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Sun, 28 May 2023 22:51:56 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j8uTnBPuB9wv3reeo7GGN+sdUlehoP/N1wgw5VVi5FRXIsSmiDvt7CchyLsemjMD+wNCQXX2uqyIlxbsIYcp86N4nmKZMn2qtTEE6uQLQsvPE9JGTyb1JX/2RMgqMnndlVjI4xvdw5wkZp9j7Fz6j1zA/Ax1g0a1RpeG/E3hjFKpRg6pzrA4BoM4VdnVl7awTv1nEZ6t8Wa9ndizl7bO86A6/CCbmhoTgPuelMJ6AUQpbg2rZX1uLqbW7HWUJ8BXbQ6VCUsoRCeSgEKjDRD/46V9dtfOhOLBQTXup5Kp8DRL5x1+fPgxA/XThVkY8JosprNwa26zOxUGXd0bh6/Hbw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JSVdKcOHLOIsLj9gEekTgxKeXM67jACMVdgG89hjsw8=; b=ViA54mokUyC4HVQKLr2IEjsbrbUAzxfTjfO3W2Z6vWU4WfdTca1snv7ZJ/mJmsVuxns7NHanhIZcgzZyesO5njalGjePx/2Tq6s5a6t+uFBM87kE5i6DF4RKZX8EeNZSCdmDAYtPLnbLzIeQdga4lywC2GcY9SrcEu24Wh5+XqF0fHpTl0d92eowltR4WDBcSDKL0k6w5/43+T+zgIpTcfy1ZgXshHtT7NAcJVPf/spo6hw/fZLBv/lyS4doSPC1+THP1hECzBuRlUS63mV8DWb4m6rbhvkfLLwv+9I81KLF5663ww75wOwkfKFxkbMWTXGWgonT9XnSqUIj9ljrjw== 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 Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from BY5PR11MB3861.namprd11.prod.outlook.com (2603:10b6:a03:18d::13) by DM4PR11MB6429.namprd11.prod.outlook.com (2603:10b6:8:b5::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Mon, 29 May 2023 05:51:55 +0000 Received: from BY5PR11MB3861.namprd11.prod.outlook.com ([fe80::4bb9:4d9a:1c31:bbef]) by BY5PR11MB3861.namprd11.prod.outlook.com ([fe80::4bb9:4d9a:1c31:bbef%6]) with mapi id 15.20.6433.022; Mon, 29 May 2023 05:51:54 +0000 Message-ID: Date: Mon, 29 May 2023 13:51:46 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [edk2-devel] [PATCH 1/1] MdePkg/BaseLib: Add SpeculationBarrier implementation for RiscV64 To: CC: Andrei Warkentin , Evan Chai , Sunil V L , Tuan Phan References: <176385E31A3644FB.14832@groups.io> From: "Li, Yong" In-Reply-To: <176385E31A3644FB.14832@groups.io> X-ClientProxiedBy: SG2PR06CA0198.apcprd06.prod.outlook.com (2603:1096:4:1::30) To BY5PR11MB3861.namprd11.prod.outlook.com (2603:10b6:a03:18d::13) Return-Path: yong.li@intel.com MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR11MB3861:EE_|DM4PR11MB6429:EE_ X-MS-Office365-Filtering-Correlation-Id: 947c9c49-c6a3-4e7a-4043-08db6008ce5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: htB3DikJeyVk59o7V8OXdQ1LwG/Sj3cj7t9wig0Nk47Sr9pNNlXtrFyQsbF+ynu0FOxSLw879lLHVsNTg+nRITZ3SYgsAyxs+ktdmbxy2hVh/fo5nIEVTCAsyPc+5sbyDCJffq6BqXl7+Bd29x2D7KobN5X46vLQsrV5FjkouPpFRDjw8lsGeIrXQG+WFvdS03/YZU7lQd8k4VQWf9QNN3xgG4t/7dfGLiwJX8TtIr/Qguoc1iVXiO2srfid6nt+jMu4Qzttg5yAoKgWMN2aQDbA/LeQR3zeI7Ic4ALeBde39TRwNK5JBfFSjPQN+ROIKI3VX2lw6UdWD8tjB4TpXdtsjj1crcpaB+hPrhqjCZ66FvKMvIEPAaMAmv/ezHDoAZqZAgSJ2fwG9xhc6jIEOgFbGRp4FWghUqX1aGYCuBxdPr0VG5u2VZd4zF6OTR+TYLh/7EmRHl8him2CbVRiBcI4Cb11d3sNySUzAPYoUOAlDYefzTPkFCJ+/MkLlk6g/8k7mHYJa+htm6qEtB+F7DXAjgyklKF/fuD9wA9rpqtQDisC/wyn4BjhVpafn5HWtuv4/dTCKdZQ0sQyAC0QAtmNwjdQIOfuWbajmgJ344RHiSDXDtNdolOAqxSKTklYjDEtjLUqI4/wAm211MTd0pVbMnmy3XU6W6+Y7e6X9aefotohV5bw2s0QHp6UQVQZ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB3861.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(366004)(346002)(39860400002)(396003)(136003)(376002)(451199021)(38100700002)(31686004)(41300700001)(6512007)(82960400001)(316002)(6666004)(31696002)(6916009)(4326008)(86362001)(8676002)(8936002)(6486002)(2906002)(2616005)(66946007)(66476007)(66556008)(53546011)(36756003)(54906003)(6506007)(19627235002)(26005)(83380400001)(966005)(478600001)(5660300002)(186003)(43740500002)(45980500001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ZW84aFhENk1vK1ozaFppYlhOSzJjWjJhY2pqUUlycDE5a3FjelN1SllMWnA4?= =?utf-8?B?L1U4YW8rY1FFS1RoRkIxdEpCRytNOXFkTE9kcFR2R1VvY0N4K0dmcmg1OWdh?= =?utf-8?B?Y0R0NHp5b1dyRVVNeTJpeHN6OEVzUDZWK050NlNyUnlGdnJPSDlSaFhHNm5p?= =?utf-8?B?Z1pSOFhoYnhzNEduNlR0MzBueGhTT3p2SFZTd1Awak81UHZDdFVLdnk3NXBr?= =?utf-8?B?RVFoNTNYWjYzT2dJejIyNUlZUnFQb0JVemlOTFN1UWhMVHYycVFVelBqc1dS?= =?utf-8?B?TGtGSkxuTWlZQzJ1RzNOc3d1aVA0OStnb0x5cEk1bXkwT1pnYngrY250N1Fy?= =?utf-8?B?UklwcStjVDYvZlZYcWlrd3FYM3NvT3FtcUtaN2tZTUN3YlpqZExKcmhGc0Jz?= =?utf-8?B?OGVHUnpSZzNjYy8ydGlyRnIrUm1QMkcyQVdUaS9jTk1PV25NMzJEOTNNbm5U?= =?utf-8?B?M2VrajV4S3R1VytiL3AwUkVNUkJ0VFgwZ3hJOWUvMUdqNm5aMVFrUXd6cHFq?= =?utf-8?B?VHVBZ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IwRHlHUzBEbFZxMmwxaFJWd2FibXhDOXc3UUhneERKcEtLcEk5bVhvT3JH?= =?utf-8?B?bnF3bEhQcEhPUTZHMnB0QmdibnlwaFBoZ2g4L3BaRjV3emhscDBuMERuaUVK?= =?utf-8?B?V2FEK0RwN3JPdERQSkVQSElFM2pRZDBhK01pTmdvNkhXZFg3NXVkOHZCTi9R?= =?utf-8?B?K3d4WEsrUk1PdUt3NzVaY1BOREJPV2xodDJuOTNJVXN6ekkzcG9xek9paUgw?= =?utf-8?B?UDNnc0FlTExkV0ozNXB1OTFrNW9NSjYxNE4zUTlCNWxlczFEZkRvOENhcE1n?= =?utf-8?B?OGNYRzJtQm9xZjJNdEMwTU0zcHdvVnN3TVZxMTUybFBKZEg4VnpYcVM4ZDFl?= =?utf-8?B?U00zY1N3K2E2cEJxM0ZHUXkzYWk4UFV5UXFHTVRacjE5OHRBOTEwWlJ5aDRU?= =?utf-8?B?L2J5UldwNEJXSWVMRmQ0bTBOdlYwVWp3M3lZZC9ZY1NteEpXUlRnaUtRRVlI?= =?utf-8?B?U2x5a0MvVjh1S1lxazRBZHlFTXNIVk9SVmRyanhTWnRDSkdFeitmQWxlT2VZ?= =?utf-8?B?UTZiVk9qSVpJWi9obC9UbEtMdXQxc09lY0Zla1p3d2JiYkx5aWtNNlhET0c1?= =?utf-8?B?M1dqVVJuWXhQbnYvZmFFVHZGcGlCT2hBTTlnUUJqZXpvWGw4YWk4c0pydkwr?= =?utf-8?Q?4nSV+EmxDET7Yot0N4tFWbaWS?= X-MS-Exchange-CrossTenant-Network-Message-Id: 947c9c49-c6a3-4e7a-4043-08db6008ce5c X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB3861.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2023 05:51:54.4458 (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: wPCwFPrwWXkK0SpPtuEM6sWHb74nrf0kQHKf5yDPLvF1TgZCc+5NkHHpRz2Xhke8A2CXuF+VcDipDJbAwet2FA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB6429 X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Hi Sunil, Could you help review this my first patch to edk2 community for RiscV, this is the change to MdePkg/Library/BaseLib/RiscV64. Since it is for RiscV specific, I guess you are the only maintainer per the Maintainers.txt ? Please let me know if need additional reviewer. Thanks in advance for your time and kind helping for this first patch. On 2023/5/29 13:24, Li, Yong wrote: > Impelement the SpeculationBarrier with implementations consisting of > fence instruction which provides finer-grain memory orderings. > Perform Data Barrier in RiscV: fence rw,rw > Perform Instruction Barrier in RiscV: fence.i; fence r,r > More detail is in Chapter 17, RVWMO Memory Consistency Model > https://github.com/riscv/riscv-isa-manual > > This API is first introduced in the below commits for IA32 and x64 > https://github.com/tianocore/edk2/commit/d9f1cac51bd354507e880e614d11a1dc160d38a3 > https://github.com/tianocore/edk2/commit/e83d841fdc2878959185c4c6cc38a7a1e88377a4 > and below the commit for ARM and AArch64 implementation > https://github.com/tianocore/edk2/commit/c0959b4426b2da45cdb8146a5116bb4fd9b86534 > > This commit is to add the RiscV64 implementation which will be used by > variable service under Variable/RuntimeDxe > > Cc: Andrei Warkentin > Cc: Evan Chai > Cc: Sunil V L > Cc: Tuan Phan > Signed-off-by: Yong Li > --- > MdePkg/Library/BaseLib/BaseLib.inf | 1 + > .../BaseLib/RiscV64/SpeculationBarrier.S | 34 +++++++++++++++++++ > 2 files changed, 35 insertions(+) > create mode 100644 MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S > > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf b/MdePkg/Library/BaseLib/BaseLib.inf > index 3a48492b1a01..03c7b02e828b 100644 > --- a/MdePkg/Library/BaseLib/BaseLib.inf > +++ b/MdePkg/Library/BaseLib/BaseLib.inf > @@ -404,6 +404,7 @@ [Sources.RISCV64] > RiscV64/CpuScratch.S | GCC > RiscV64/ReadTimer.S | GCC > RiscV64/RiscVMmu.S | GCC > + RiscV64/SpeculationBarrier.S | GCC > > [Sources.LOONGARCH64] > Math64.c > diff --git a/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S b/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S > new file mode 100644 > index 000000000000..581a7653996f > --- /dev/null > +++ b/MdePkg/Library/BaseLib/RiscV64/SpeculationBarrier.S > @@ -0,0 +1,34 @@ > +##------------------------------------------------------------------------------ > +# > +# SpeculationBarrier() for RISCV64 > +# > +# Copyright (c) 2023, Intel Corporation. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +##------------------------------------------------------------------------------ > + > +.text > +.p2align 2 > + > +ASM_GLOBAL ASM_PFX(SpeculationBarrier) > + > + > +#/** > +# Uses as a barrier to stop speculative execution. > +# > +# Ensures that no later instruction will execute speculatively, until all prior > +# instructions have completed. > +# > +#**/ > +#VOID > +#EFIAPI > +#SpeculationBarrier ( > +# VOID > +# ); > +# > +ASM_PFX(SpeculationBarrier): > + fence rw,rw > + fence.i > + fence r,r > + ret