From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web12.8639.1617317751465671772 for ; Thu, 01 Apr 2021 15:55:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@intel.onmicrosoft.com header.s=selector2-intel-onmicrosoft-com header.b=ihTfIkJV; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: ray.ni@intel.com) IronPort-SDR: B8Y5UjrLy75roKzz6+SkUwv42QB1af4KSwim0tY10hX5JmPfBZefU0Hqc9wFV3VCsPvxTGOHsk AUjMa4102r6g== X-IronPort-AV: E=McAfee;i="6000,8403,9941"; a="256328210" X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208,217";a="256328210" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Apr 2021 15:55:50 -0700 IronPort-SDR: 93PDkkvB+SW4pigwKzHCvpksqm+YsVaHkO16D4Vbxv+BzAWIxVnF+Cig7+SDOukvf/HLqG/gWl S0UGZCagmJag== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,296,1610438400"; d="scan'208,217";a="517528336" Received: from fmsmsx606.amr.corp.intel.com ([10.18.126.86]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2021 15:55:50 -0700 Received: from fmsmsx609.amr.corp.intel.com (10.18.126.89) by fmsmsx606.amr.corp.intel.com (10.18.126.86) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 1 Apr 2021 15:55:50 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx609.amr.corp.intel.com (10.18.126.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Thu, 1 Apr 2021 15:55:49 -0700 Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Thu, 1 Apr 2021 15:55:49 -0700 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.172) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Thu, 1 Apr 2021 15:55:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=blRzHnlhwLVsv8L2xjD02tMaa1/Lp3OzGEDbvWv6V+F7lWIIRCbI0wwhIqJYRn5pfRNV4suAKg15fE6CuMbRpFRatLLAPi/g5p07ozDSdW+pJ0jnI1ERR5tFYzJH1DjFQsoomKa722DkuCvxjon6NJhVMC6DgxNy85GSi5wi7EN9AbCE9lW+WbvQaHb35lDSb5cXUH5bFMWDmt44u3YPCNC9GV0uJRAQu0uYm9sv5VEdssflax8xdWSlLSwUMnYkcSXQ4PB9WoEsMDDIiY9DWpW8+41EZ4e7ECbD/QcqYHDCqgwzGWNbb4zeeaSXpOnn+FX1MvZuqt4jJDFxJxaIYw== 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=Ylt2P/bMXaqigyPBD3rzl1KQ2aRRFNyYf7OUPbNIWtM=; b=bp8nWYvLVs5brw7ODziXdC5nQUb2OsfvVikd0onNekCAuNKa3JeidRyGpAHYPg0XKnSJ2xddjraGplyzLcIrIJOCdX9OEYIlcjtWj4Or/+k5b/FPDWPGlApp7hBTUspDkMynoMWQRxbJhp5mWVtFQJaz/mqJnDImnqSss7oX3eXD/kC1j8OBFeq+8yASDPL2zbh33wiwAHqVvBGPyKuZUVu0H4BvNRq6klHMaEf8f5D9H20utXDLQEq2e083Es6f/q/KpxXsWzGhrXDbFDSuGIWqaxH8J53MR5KUhRiU6IU9PtClHCtBtTHA/mu5ckBHESVJDD6Rv+NHFEbRqX+y0Q== 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=Ylt2P/bMXaqigyPBD3rzl1KQ2aRRFNyYf7OUPbNIWtM=; b=ihTfIkJVIkaIpZU9sVoLw/wker2+luiom0wE1fUWHnnnjSOR8hWpxJVF5kK1lk0XVOLED/xglAjGz7I/z2+vF3mSz9EaO9VXxHDgUoU2eZvIAO7n2m93u5cbgnphFz/KtLoMXHDuPcN0cS11Gc5fZVd5Rp13TplbQ6GNkspzp9c= Received: from CO1PR11MB4930.namprd11.prod.outlook.com (2603:10b6:303:9b::11) by CO1PR11MB4882.namprd11.prod.outlook.com (2603:10b6:303:97::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.27; Thu, 1 Apr 2021 22:55:44 +0000 Received: from CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::59d6:8b94:55bf:36e7]) by CO1PR11MB4930.namprd11.prod.outlook.com ([fe80::59d6:8b94:55bf:36e7%5]) with mapi id 15.20.3999.028; Thu, 1 Apr 2021 22:55:44 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "Wu, Jiaxin" CC: "Kinney, Michael D" , Liming Gao , "Liu, Zhiguang" , "Yao, Jiewen" , "Zhang, Hongbin1" Subject: Re: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the XSETBV instruction Thread-Topic: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the XSETBV instruction Thread-Index: AQHXJgMFFcTOhEfqzEiUYAhtE2R216qfr7GQgACYe4w= Date: Thu, 1 Apr 2021 22:55:44 +0000 Message-ID: References: <16715E20BB70A728.7099@groups.io>, In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=intel.com; x-originating-ip: [124.77.195.36] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8332f00e-51f9-43d6-17c9-08d8f5614828 x-ms-traffictypediagnostic: CO1PR11MB4882: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2449; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: eR55IR2hi4ExNRUvm6EW+kfoyuGvyB+pQszZPCvB3mGDJF4lXG8zlosih95+wSNqE4p6QAZa7uXmyhF5KLlL8IB78MJhSt+4hOS/O0I/o6gimR3ecmFQDIWei6wvWXtm4sQdX8LavKiYWTBQqDA96iHoUSVm51NiAhvnbDt2GD5pSt25ieSOneuEaQswDQp1hElz4o0Hkq4J/9daX2+P9Z4prRbCBkVDXYC4KafFsCdFwJC6oqJPGnBRrKQBCU9Gp/Id4KpYc+LrwLosD3b/SvNiDjc0CM+DTLzeD4po/jHJMjvNGpYWTbgdg18hx505pZpf++yq4Ozvz4N/I+obJTGs9034WeTBWwh+RmQA/8v/vQ2U4Tmr6ji1TrIGsDYSPbQs6cuG1+ghP2Yj3VOhcvYTGqrStvz9aNimngW+Ljv1pMIELX+Br3u4hsA9UYa55vryDUCMmW4SAsSjhlT82gaY0p2FaTr5uk+I+wa7J5Gp27nSCTEVaTJ/0SazboZuOp2OnKi91tcs77pDXvcEJiMmd5Y0/FeKCPjRGnRngRX1uNrwz+mZE4HULc0li6Hyq0Gw/9sAqvcdSS5nr6+aZqoe0YcmpQZC0PhDoZhHhIdeWHnabq/97rLVi53MnQ2ECsLhApA4EOkm2MZMCefLbD0HF/CJbogRlyzptzxcJFAfAM2G9bMbYBCTLKY8I4y1/wX6O2ocfGzcujo9FqJLiFYo6MoI2js/SHz162VYRuwSpaMF+PcySEFdmk8UjENV x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CO1PR11MB4930.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(376002)(396003)(346002)(136003)(39860400002)(366004)(19627235002)(52536014)(110136005)(316002)(5660300002)(166002)(54906003)(2906002)(86362001)(76116006)(478600001)(966005)(8936002)(8676002)(45080400002)(66946007)(91956017)(7696005)(66476007)(66556008)(64756008)(66446008)(6636002)(6506007)(53546011)(55016002)(71200400001)(9686003)(33656002)(186003)(83380400001)(4326008)(38100700001)(107886003)(26005);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?1ILe7CMGxe1vuhuzsI69JS+QGymVAw8vgFiN3plLaVUNfpBdN6w+/mpx+9Dj?= =?us-ascii?Q?LpVK4rJ7Kz+XqTq7T6+aEiZQkuHnEJXuLsqyYK/Aa6OmZWnNFPL6cgWCx7HG?= =?us-ascii?Q?O1jx0sq+kYLU+5w18H4QNUoXVNyPnuJGQs0xjgC0QMlJCAdGbvLPg5mKHs6s?= =?us-ascii?Q?2FPUeVJDHwS2xxR2FnzM0yzSYevoG3k9pO3YChebkxL6r+ED2N7mj1vBmPGi?= =?us-ascii?Q?V8eGSFarcDMppgYi5nMcvaPjaYH9Q7fRE3eeJc+CoKIAbLokq3++sbfqynT0?= =?us-ascii?Q?myka+ikgd6b1zotak7/91EkAjDPPlOPlktzBiJgEOrFJU54VP4gZOdXWbwII?= =?us-ascii?Q?90CbFZ+OVcuUJsBzaEZm3j5PAIoci4o+V7cQYdyafO0Mzdwj5qS3yzwFoJHo?= =?us-ascii?Q?4O7Sykf5/pBIQldPTB3H/HnDtUIBdu5mi0TcAKNGPuAzn5Js5aFtE1/Um5IN?= =?us-ascii?Q?L6OWAww47Y0s3F/1tTKOMLNJ0At2lxjHhcftFsrKKQdX9x05j0Jgugecad37?= =?us-ascii?Q?b91jeHIf0KEN6QSbCjXbR5GlG9kmYb/6TnnsscX85SdqqyBl9MhC4nmJZzlc?= =?us-ascii?Q?xbMbzMwv3fZeutJVWmZA0khBPFqDAYQuIarXJZSFJLpu+aokHtdhDFaj2qBz?= =?us-ascii?Q?+h0odQbsgyNG9maK/+h7iOsk4Ori/+YnBnJSdIlxV/l3fFgt0/fRD8Y8ibeZ?= =?us-ascii?Q?SpOaB6MNmP9QQvr+CtZDm4N2XdSVWpPwBBAe5q4wjP3Fb2b05yuGET7artBh?= =?us-ascii?Q?UxvIvIuR6utWsNwwaXzXCM1p3BbwHwR8rr6tkTzgqeZRUiRCvG3pRojoafxW?= =?us-ascii?Q?1HKdbK5T+VWoxA48NbJk3Ui95lgQjNmxKnhQMsrUDfWN3WDcngFs/UgjyRaR?= =?us-ascii?Q?95C0RGOGNMIY7lXWqVeu/m+lHQpD0dxhmEoZKuRu7p7Cz9ozNgZJraRPcJK1?= =?us-ascii?Q?NpE/xY3x45XHmNZdGyi0hZ+ybymVO9XMnq2cn8ng2gn53nVoU3lnX077jhYW?= =?us-ascii?Q?SiyHw0cDFCE8mRkZDQQLTbf3M2Cwjz6RH+92PyQnU5H3CzpUfc8MH31wbCMS?= =?us-ascii?Q?whbbFBqcgeY3lOacKg3oXUVPxT1UDhAetSmfmivepWYv/Qwy6p/6R3HQ+889?= =?us-ascii?Q?DOKh0axNEbfoznC5YLMYXGKR6GUQiyeFl/sXnJLzwzVEDr1/jIA6qJbP2CfM?= =?us-ascii?Q?kr2v0qX/IqSCDapSCkV5+Nx3UmZljyLt4QXaC2EjheRjaNcy+hIOaFhWcFUI?= =?us-ascii?Q?ut1RujGH6giLijJ/bNNyPK0+bm8B3S1Cmdd88Tb56ebQqDpDJKKqYTjt7jNg?= =?us-ascii?Q?BZUvXxsazhFUYOZSZSi865YzBsxkocjF6LPaM+4/YWVUEQ=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4930.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8332f00e-51f9-43d6-17c9-08d8f5614828 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Apr 2021 22:55:44.2840 (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: 8D++pE/wzzKMZYrgw7qLPT/UXY5Eqvrroz6EmLS2DmSIRTf5RUk4cgDXCEsjPacqbeMcahIf/+2we706zCScMw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4882 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CO1PR11MB493067965DDCDEF02FC3A66A8C7B9CO1PR11MB4930namp_" --_000_CO1PR11MB493067965DDCDEF02FC3A66A8C7B9CO1PR11MB4930namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please fix this: > \ No newline at end of file thanks, ray ________________________________ From: devel@edk2.groups.io on behalf of Wu, Jiaxin = Sent: Thursday, April 1, 2021 9:50:29 PM To: devel@edk2.groups.io ; Wu, Jiaxin Cc: Kinney, Michael D ; Liming Gao ; Liu, Zhiguang ; Yao, Jiewen ; Zhang, Hongbin1 Subject: Re: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the X= SETBV instruction Hi Liming and Jiewen, Could you help review the patch? Thanks, Jiaxin > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Wu, > Jiaxin > Sent: Wednesday, March 31, 2021 3:54 PM > To: devel@edk2.groups.io > Cc: Kinney, Michael D ; Liming Gao > ; Liu, Zhiguang ; Yao, > Jiewen ; Zhang, Hongbin1 > > Subject: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the > XSETBV instruction > > https://bugzilla.tianocore.org/show_bug.cgi?id=3D3284 > > This patch is to support XSETBV instruction so as to support > Extended Control Register(XCR) write. > > Extended Control Register(XCR) read has already been supported > by below commit to support XGETBV instruction: > 9b3ca509abd4e45439bbdfe2c2fa8780c950320a > > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Zhiguang Liu > Cc: Yao Jiewen > Signed-off-by: Jiaxin Wu > Signed-off-by: Zhang Hongbin1 > --- > MdePkg/Include/Library/BaseLib.h | 25 +++++++++++++++++++++++- > MdePkg/Library/BaseLib/BaseLib.inf | 4 +++- > MdePkg/Library/BaseLib/Ia32/XSetBv.nasm | 34 > +++++++++++++++++++++++++++++++++ > MdePkg/Library/BaseLib/X64/XSetBv.nasm | 34 > +++++++++++++++++++++++++++++++++ > 4 files changed, 95 insertions(+), 2 deletions(-) > create mode 100644 MdePkg/Library/BaseLib/Ia32/XSetBv.nasm > create mode 100644 MdePkg/Library/BaseLib/X64/XSetBv.nasm > > diff --git a/MdePkg/Include/Library/BaseLib.h > b/MdePkg/Include/Library/BaseLib.h > index 1171a0ffb5..035d6b655d 100644 > --- a/MdePkg/Include/Library/BaseLib.h > +++ b/MdePkg/Include/Library/BaseLib.h > @@ -1,10 +1,10 @@ > /** @file > Provides string functions, linked list functions, math functions, > synchronization > functions, file path functions, and CPU architecture-specific functio= ns. > > -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
> Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> Copyright (c) Microsoft Corporation.
> Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.= All > rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -7436,10 +7436,33 @@ UINT64 > EFIAPI > AsmXGetBv ( > IN UINT32 Index > ); > > +/** > + Executes a XSETBV instruction to write a 64-bit value to a Extended C= ontrol > Register(XCR), > + and returns the value. > + > + Writes the 64-bit value specified by Value to the XCR specified by In= dex. > The > + 64-bit value written to the XCR is returned. No parameter checking is > + performed on Index or Value, and some of these may cause CPU > exceptions. The > + caller must either guarantee that Index and Value are valid, or the c= aller > + must establish proper exception handlers. This function is only avail= able on > + IA-32 and x64. > + > + @param Index The 32-bit XCR index to write. > + @param Value The 64-bit value to write to the XCR. > + > + @return Value > + > +**/ > +UINT64 > +EFIAPI > +AsmXSetBv ( > + IN UINT32 Index, > + IN UINT64 Value > + ); > > /** > Executes a VMGEXIT instruction (VMMCALL with a REP prefix) > > Executes a VMGEXIT instruction. This function is only available on IA= -32 and > diff --git a/MdePkg/Library/BaseLib/BaseLib.inf > b/MdePkg/Library/BaseLib/BaseLib.inf > index 3b85c56c3c..fe8f68bbcf 100644 > --- a/MdePkg/Library/BaseLib/BaseLib.inf > +++ b/MdePkg/Library/BaseLib/BaseLib.inf > @@ -1,9 +1,9 @@ > ## @file > # Base Library implementation. > # > -# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved. > +# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved. > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<= BR> > # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved. > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All r= ights > reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent > @@ -182,10 +182,11 @@ > Ia32/LShiftU64.nasm| GCC > Ia32/EnableCache.nasm| GCC > Ia32/DisableCache.nasm| GCC > Ia32/RdRand.nasm > Ia32/XGetBv.nasm > + Ia32/XSetBv.nasm > Ia32/VmgExit.nasm > > Ia32/DivS64x64Remainder.c > Ia32/InternalSwitchStack.c | MSFT > Ia32/InternalSwitchStack.nasm | GCC > @@ -316,10 +317,11 @@ > X64/GccInlinePriv.c | GCC > X64/EnableDisableInterrupts.nasm > X64/DisablePaging64.nasm > X64/RdRand.nasm > X64/XGetBv.nasm > + X64/XSetBv.nasm > X64/VmgExit.nasm > ChkStkGcc.c | GCC > > [Sources.EBC] > Ebc/CpuBreakpoint.c > diff --git a/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm > b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm > new file mode 100644 > index 0000000000..9fa2f761cd > --- /dev/null > +++ b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm > @@ -0,0 +1,34 @@ > +;----------------------------------------------------------------------= -------- > +; > +; Copyright (c) 2021, Intel Corporation. All rights reserved.
> +; SPDX-License-Identifier: BSD-2-Clause-Patent > +; > +; Module Name: > +; > +; XSetBv.nasm > +; > +; Abstract: > +; > +; AsmXSetBv function > +; > +; Notes: > +; > +;----------------------------------------------------------------------= -------- > + > + SECTION .text > + > +;----------------------------------------------------------------------= -------- > +; UINT64 > +; EFIAPI > +; AsmXSetBv ( > +; IN UINT32 Index, > +; IN UINT64 Value > +; ); > +;----------------------------------------------------------------------= -------- > +global ASM_PFX(AsmXSetBv) > +ASM_PFX(AsmXSetBv): > + mov edx, [esp + 12] > + mov eax, [esp + 8] > + mov ecx, [esp + 4] > + xsetbv > + ret > \ No newline at end of file > diff --git a/MdePkg/Library/BaseLib/X64/XSetBv.nasm > b/MdePkg/Library/BaseLib/X64/XSetBv.nasm > new file mode 100644 > index 0000000000..aa72419e7f > --- /dev/null > +++ b/MdePkg/Library/BaseLib/X64/XSetBv.nasm > @@ -0,0 +1,34 @@ > +;----------------------------------------------------------------------= -------- > +; > +; Copyright (c) 2021, Intel Corporation. All rights reserved.
> +; SPDX-License-Identifier: BSD-2-Clause-Patent > +; > +; Module Name: > +; > +; XSetBv.nasm > +; > +; Abstract: > +; > +; AsmXSetBv function > +; > +; Notes: > +; > +;----------------------------------------------------------------------= -------- > + > + DEFAULT REL > + SECTION .text > + > +;----------------------------------------------------------------------= -------- > +; UINT64 > +; EFIAPI > +; AsmXSetBv ( > +; IN UINT32 Index, > +; IN UINT64 Value > +; ); > +;----------------------------------------------------------------------= -------- > +global ASM_PFX(AsmXSetBv) > +ASM_PFX(AsmXSetBv): > + mov rax, rdx ; meanwhile, rax <- return valu= e > + shr rdx, 0x20 ; edx:eax contains the value t= o write > + xsetbv > + ret > \ No newline at end of file > -- > 2.16.2.windows.1 > > > > > --_000_CO1PR11MB493067965DDCDEF02FC3A66A8C7B9CO1PR11MB4930namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Please fix this:
>= ; \ No newline at end of file

thanks,
ray

From: devel@edk2.groups.io= <devel@edk2.groups.io> on behalf of Wu, Jiaxin <jiaxin.wu@intel.c= om>
Sent: Thursday, April 1, 2021 9:50:29 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>; Wu, Jiaxin &= lt;jiaxin.wu@intel.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Ga= o <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.co= m>; Yao, Jiewen <jiewen.yao@intel.com>; Zhang, Hongbin1 <hongbi= n1.zhang@intel.com>
Subject: Re: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support fo= r the XSETBV instruction
 
Hi Liming and Jiewen,

Could you help review the patch?

Thanks,
Jiaxin



> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of = Wu,
> Jiaxin
> Sent: Wednesday, March 31, 2021 3:54 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Liming Gao<= br> > <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@inte= l.com>; Yao,
> Jiewen <jiewen.yao@intel.com>; Zhang, Hongbin1
> <hongbin1.zhang@intel.com>
> Subject: [edk2-devel] [PATCH v1] MdePkg/BaseLib: Add support for the<= br> > XSETBV instruction
>
> htt= ps://bugzilla.tianocore.org/show_bug.cgi?id=3D3284
>
> This patch is to support XSETBV instruction so as to support
> Extended Control Register(XCR) write.
>
> Extended Control Register(XCR) read has already been supported
> by below commit to support XGETBV instruction:
> 9b3ca509abd4e45439bbdfe2c2fa8780c950320a
>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Zhiguang Liu <zhiguang.liu@intel.com>
> Cc: Yao Jiewen <jiewen.yao@intel.com>
> Signed-off-by: Jiaxin Wu <Jiaxin.wu@intel.com>
> Signed-off-by: Zhang Hongbin1 <hongbin1.zhang@intel.com>
> ---
>  MdePkg/Include/Library/BaseLib.h     &= nbsp;  | 25 +++++++++++++++++++++++-
>  MdePkg/Library/BaseLib/BaseLib.inf     = ; |  4 +++-
>  MdePkg/Library/BaseLib/Ia32/XSetBv.nasm | 34
> +++++++++++++++++++++++++++++++++
>  MdePkg/Library/BaseLib/X64/XSetBv.nasm  | 34
> +++++++++++++++++++++++++++++++++
>  4 files changed, 95 insertions(+), 2 deletions(-)
>  create mode 100644 MdePkg/Library/BaseLib/Ia32/XSetBv.nasm
>  create mode 100644 MdePkg/Library/BaseLib/X64/XSetBv.nasm
>
> diff --git a/MdePkg/Include/Library/BaseLib.h
> b/MdePkg/Include/Library/BaseLib.h
> index 1171a0ffb5..035d6b655d 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -1,10 +1,10 @@
>  /** @file
>    Provides string functions, linked list functions, m= ath functions,
> synchronization
>    functions, file path functions, and CPU architectur= e-specific functions.
>
> -Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.&l= t;BR>
> +Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.&l= t;BR>
>  Portions copyright (c) 2008 - 2009, Apple Inc. All rights reser= ved.<BR>
>  Copyright (c) Microsoft Corporation.<BR>
>  Portions Copyright (c) 2020, Hewlett Packard Enterprise Develop= ment LP. All
> rights reserved.<BR>
>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -7436,10 +7436,33 @@ UINT64
>  EFIAPI
>  AsmXGetBv (
>    IN UINT32  Index
>    );
>
> +/**
> +  Executes a XSETBV instruction to write a 64-bit value to a Ex= tended Control
> Register(XCR),
> +  and returns the value.
> +
> +  Writes the 64-bit value specified by Value to the XCR specifi= ed by Index.
> The
> +  64-bit value written to the XCR is returned. No parameter che= cking is
> +  performed on Index or Value, and some of these may cause CPU<= br> > exceptions. The
> +  caller must either guarantee that Index and Value are valid, = or the caller
> +  must establish proper exception handlers. This function is on= ly available on
> +  IA-32 and x64.
> +
> +  @param  Index The 32-bit XCR index to write.
> +  @param  Value The 64-bit value to write to the XCR.
> +
> +  @return Value
> +
> +**/
> +UINT64
> +EFIAPI
> +AsmXSetBv (
> +  IN UINT32  Index,
> +  IN UINT64  Value
> +  );
>
>  /**
>    Executes a VMGEXIT instruction (VMMCALL with a REP = prefix)
>
>    Executes a VMGEXIT instruction. This function is on= ly available on IA-32 and
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index 3b85c56c3c..fe8f68bbcf 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -1,9 +1,9 @@
>  ## @file
>  #  Base Library implementation.
>  #
> -#  Copyright (c) 2007 - 2020, Intel Corporation. All rights res= erved.<BR>
> +#  Copyright (c) 2007 - 2021, Intel Corporation. All rights res= erved.<BR>
>  #  Portions copyright (c) 2008 - 2009, Apple Inc. All righ= ts reserved.<BR>
>  #  Portions copyright (c) 2011 - 2013, ARM Ltd. All rights= reserved.<BR>
>  #  Copyright (c) 2020, Hewlett Packard Enterprise Developm= ent LP. All rights
> reserved.<BR>
>  #
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
> @@ -182,10 +182,11 @@
>    Ia32/LShiftU64.nasm| GCC
>    Ia32/EnableCache.nasm| GCC
>    Ia32/DisableCache.nasm| GCC
>    Ia32/RdRand.nasm
>    Ia32/XGetBv.nasm
> +  Ia32/XSetBv.nasm
>    Ia32/VmgExit.nasm
>
>    Ia32/DivS64x64Remainder.c
>    Ia32/InternalSwitchStack.c | MSFT
>    Ia32/InternalSwitchStack.nasm | GCC
> @@ -316,10 +317,11 @@
>    X64/GccInlinePriv.c | GCC
>    X64/EnableDisableInterrupts.nasm
>    X64/DisablePaging64.nasm
>    X64/RdRand.nasm
>    X64/XGetBv.nasm
> +  X64/XSetBv.nasm
>    X64/VmgExit.nasm
>    ChkStkGcc.c  | GCC
>
>  [Sources.EBC]
>    Ebc/CpuBreakpoint.c
> diff --git a/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm
> b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm
> new file mode 100644
> index 0000000000..9fa2f761cd
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/Ia32/XSetBv.nasm
> @@ -0,0 +1,34 @@
> +;-------------------------------------------------------------------= -----------
> +;
> +; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR&= gt;
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> +;
> +; Module Name:
> +;
> +;   XSetBv.nasm
> +;
> +; Abstract:
> +;
> +;   AsmXSetBv function
> +;
> +; Notes:
> +;
> +;-------------------------------------------------------------------= -----------
> +
> +    SECTION .text
> +
> +;-------------------------------------------------------------------= -----------
> +; UINT64
> +; EFIAPI
> +; AsmXSetBv (
> +;   IN UINT32  Index,
> +;   IN UINT64  Value
> +;   );
> +;-------------------------------------------------------------------= -----------
> +global ASM_PFX(AsmXSetBv)
> +ASM_PFX(AsmXSetBv):
> +    mov     edx, [esp + 12]
> +    mov     eax, [esp + 8]
> +    mov     ecx, [esp + 4]
> +    xsetbv
> +    ret
> \ No newline at end of file
> diff --git a/MdePkg/Library/BaseLib/X64/XSetBv.nasm
> b/MdePkg/Library/BaseLib/X64/XSetBv.nasm
> new file mode 100644
> index 0000000000..aa72419e7f
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/X64/XSetBv.nasm
> @@ -0,0 +1,34 @@
> +;-------------------------------------------------------------------= -----------
> +;
> +; Copyright (c) 2021, Intel Corporation. All rights reserved.<BR&= gt;
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> +;
> +; Module Name:
> +;
> +;   XSetBv.nasm
> +;
> +; Abstract:
> +;
> +;   AsmXSetBv function
> +;
> +; Notes:
> +;
> +;-------------------------------------------------------------------= -----------
> +
> +    DEFAULT REL
> +    SECTION .text
> +
> +;-------------------------------------------------------------------= -----------
> +; UINT64
> +; EFIAPI
> +; AsmXSetBv (
> +;   IN UINT32  Index,
> +;   IN UINT64  Value
> +;   );
> +;-------------------------------------------------------------------= -----------
> +global ASM_PFX(AsmXSetBv)
> +ASM_PFX(AsmXSetBv):
> +    mov     rax, rdx  &= nbsp;           &nbs= p;     ; meanwhile, rax <- return value
> +    shr     rdx, 0x20  =             &nb= sp;     ; edx:eax contains the value to write
> +    xsetbv
> +    ret
> \ No newline at end of file
> --
> 2.16.2.windows.1
>
>
>
>
>






--_000_CO1PR11MB493067965DDCDEF02FC3A66A8C7B9CO1PR11MB4930namp_--