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.web10.5883.1667191688385082297 for ; Sun, 30 Oct 2022 21:48:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Q1bnXR/j; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667191688; x=1698727688; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=iQP1j+CXkXjRL7uE4Q2v1NtgC880RrYPzvsD9rKVMgY=; b=Q1bnXR/jBEtnBYqVGYDIA+SPSsqZwEaRZ+h0HsfAA6/71ex0gopEM4W7 IowuEyqIM7HWmC3ZyE6/cda+dRp60RDoj5ZRFHLhA1LRrJC7ejNQNOrES m2FbTU1CNrzqC1cv3iH93g/qMxkFJA7lDUHRTSoffdlcANgGA6f3VpUdE yp+IIy/qyS9EILQfqNk/SBHB1zui7KAcmsKix9GXRhTW3t7kVKJDsDVU6 541Jr4WDAZwpYnOJqahnuvZ0J6VLKoOrnvOpuJrp6zdQucwfAp8nYG04K qVWZHNOKIa4ZgyxThrAx49NGrtpL8bS+bprV64A/o/QjTDXXKAII4nIbu A==; X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="309902907" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="309902907" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2022 21:48:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="776001210" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="776001210" Received: from fmsmsx603.amr.corp.intel.com ([10.18.126.83]) by fmsmga001.fm.intel.com with ESMTP; 30 Oct 2022 21:48:07 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx603.amr.corp.intel.com (10.18.126.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sun, 30 Oct 2022 21:48:07 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) 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.2375.31; Sun, 30 Oct 2022 21:48:06 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) 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.2375.31 via Frontend Transport; Sun, 30 Oct 2022 21:48:06 -0700 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (104.47.59.168) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2375.31; Sun, 30 Oct 2022 21:48:06 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CNE5HvGezTZlkD9ivbVYxLyNbHyN/gX/IO1azNJJlspMZK+d6O9J9yn/6uUttBLwogc+WNgw45SvbveXf/6VlRAN3Cvx++I3YidkoNbf3MJ9L9gjlStdQ2xbRDY3UP2sOhWpeXeaqXZJVknywyGdu1Xv0ch/WqkB0E8na5mMIvXbdTrAK6oxOQgqf96Z6oJ8Gd2tvU/X9Gt7pG4PFeMoRjiGrxy3RXxdDGQ43KDbRyBffwcEVBw8vVrZdduQiEza1H+91OvEPUxXrM/hk6I+W2U451FLGhHQUPzELzhB2qVpfbPIDAiTXdk/zgPdLIT4bXsJHSXsGO0O+rIZxa2igg== 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=j2y969qVkZGhnjMPBEsQgtCMPJzaD7vNvKZZ9FZzq6E=; b=kR6dSwCMmMgLoZB5Yvm4K8iMjJqKN7Fwh7bsHuoawfBHmSRtkD4ECU3qnwsYp4xJ+kqs8xEW9bQ0xyK/bk/h/7wudkUss+8Gecwvikfeol8aJ6UCbiC/6MbgvYXGVbW6WxlL37kKStLFoCaepDaR0tGSpBlRrlgA99SWy/d+hp1nfuZRi5beyozdgFqQVPoq8k+N274/uUXVWDJWqddz89SwOxgP2HaSohXOcFzRStILj3EYMynzubvf/15YeFVGBbAfH5QMNcTlSAUAkd77DxwTRVRW6mx2KilqJTUa41N60/SocI/QZFArsnSXt6It5Nq7Ot4nsciCLL9xyZ+f9Q== 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 Received: from MWHPR11MB1631.namprd11.prod.outlook.com (2603:10b6:301:10::10) by SJ0PR11MB4800.namprd11.prod.outlook.com (2603:10b6:a03:2af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5769.19; Mon, 31 Oct 2022 04:48:04 +0000 Received: from MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::5594:2220:fe1:50ad]) by MWHPR11MB1631.namprd11.prod.outlook.com ([fe80::5594:2220:fe1:50ad%11]) with mapi id 15.20.5769.019; Mon, 31 Oct 2022 04:48:04 +0000 From: "Ni, Ray" To: "abner.chang@amd.com" , "devel@edk2.groups.io" CC: Abdul Lateef Attar , Garrett Kirkendall , Paul Grimes , "Dong, Eric" , "Kumar, Rahul R" Subject: Re: [PATCH V3 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Thread-Topic: [PATCH V3 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Thread-Index: AQHY7NOuo5PQ26Aec0mopRXYxSl+Iq4n7mNA Date: Mon, 31 Oct 2022 04:48:04 +0000 Message-ID: References: <20221031024912.60-1-abner.chang@amd.com> <20221031024912.60-2-abner.chang@amd.com> In-Reply-To: <20221031024912.60-2-abner.chang@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MWHPR11MB1631:EE_|SJ0PR11MB4800:EE_ x-ms-office365-filtering-correlation-id: dd3405f1-a3e2-4320-7243-08dabafb1903 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: iOvC4s752E4g+imsfZKX7otA6IOQdIUBtm1NnuDvNMRB8xJ+TYo0dPfwmKyuFuz7G0ovGTRk6aCXD35sS9Vb6xHf7GaITf9cPSNCsm7B0oFVsnRVXQ6WwmqD7CiT0XUp1U940LKa1CRZcOO9iNgn73Dzzvaqu2CbWhsAbGjyZhWMxcqRoMRqlX+z4V70i5zIRu7SHPVJ9i/nB8/+9LhzWgy6I+ROadt57r26iTll8gEukZnQbbAfkukEZKiL8HlrJlOKunS178tLz01Y40nt/KCFprDkl8mLJYR+TZjVjPLaKdoEewQ6zM6Yqnffs6xyS+nxbuaKJEhkGpkgmCVrD8hLRI5STT7DcfLRocwGAKmNayarL77486hd7Mgo7qCnzip0aXyyzwt4+fSA+GLeRB3HiHxEY7spEjJojJbMtTnYQ0w4PtcCSAEszi5t/kH+/eNYs9fn73gpdlKjAFpDQiPdIDDoKjGjUWcQED07fstxZBQFtFcF923YxSCkga8YP4tExslEH/ssK8Gj5M4HGs9kn6PA3XZWYdIU+jrc0XBO0ILMFvyu4+Lfta+lc6ZVg697vKgYcWbLz+Ycg8JSsXF/ruXj/r+gjIIxm43ZsFiBgwqpY/qdljLijtdGcJ16ET7B6vhRrTJYmLMJSavYcApdlb8QW67k6FwRJE5O6ay2WAKcsKp157xGXUh8aGm3QxBd1e5oaECRJ4M8FH7yJ9Z90a+o2pHqjxe2SQJVphRch+6FW9ehnQkC8EKtITHrw3QIEyPgQgzpKRJ7w2Mrzg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MWHPR11MB1631.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(396003)(136003)(376002)(346002)(366004)(39860400002)(451199015)(33656002)(86362001)(122000001)(38070700005)(38100700002)(82960400001)(83380400001)(55016003)(30864003)(2906002)(26005)(6506007)(53546011)(7696005)(478600001)(186003)(9686003)(107886003)(316002)(19627235002)(71200400001)(110136005)(54906003)(8676002)(66946007)(66556008)(66476007)(66446008)(41300700001)(4326008)(76116006)(5660300002)(64756008)(8936002)(52536014)(45080400002)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?O/3A95zCcjwZO+IwF95VkkRx0WWWM3Bii1nRGvP8wC9ybP4N2UrAU1qRupP3?= =?us-ascii?Q?I/XYghzG/FL6W64SQsx9yGGERilbXVDeWkx7uqHZ8OsFJttwwduWhctvn+iU?= =?us-ascii?Q?eupECDOEHJDXB89IdEv4kXzaCkOQmN9f7ZuPWdrGV/ovvG/cP+WPwvl502De?= =?us-ascii?Q?8yKJjb7C4pDNTDH+Nv7itoHiaYO3m/UMHvbm4RRwBi5bsnNfXnuwyOerKgkG?= =?us-ascii?Q?pW2nFIadNCUdSxExac4ExoDG7htL67Xvv3KsxqR5mFh/Y6mZcLO0FXjN7IcG?= =?us-ascii?Q?87LWwUYMoG0Mf3nuR+3kurrm1eiXL65VZB/VVmi515agoEKE33FQsX/iuvYD?= =?us-ascii?Q?u+lO7WeH6S8ptItK//FfUBdUJlj0BJ83/YNb78EEAxrHgk/CsULQ8pCS7CeE?= =?us-ascii?Q?4Tx8/nLLD1lphVETsd9n2Qpxdvl9H8W2TrSKSaHP2NRoMd4HV6EPomR5ROOa?= =?us-ascii?Q?4XKSzLzVIgXV77Jlk74jNC82ckQQ9OreWgOWtf4ooOT3csURSoHSm9JsHEtk?= =?us-ascii?Q?d5K8nY9JjNbtBWjHawByJ3GTQB5Dele9PgPlHMMVac/idK4HPY0WE4CKh3sH?= =?us-ascii?Q?O312s2tquv655Hwy8hrmOArRWM+3ogiab4X68PYDzS907uqSgaZdLCOfOIa/?= =?us-ascii?Q?05cPHYC+EMD3qbLr7iEuxrr/Fwpx+/vRePf8GZ+zuWevJlBKOK39Z/Z7YG3t?= =?us-ascii?Q?u8NUyiSM0FxxsZUQhrOl/2/afI7IpCKvE3hvPSDefvdSmJDTcoxynsS1uS+q?= =?us-ascii?Q?6Fi5HBqyzPpWbkYqj5ilBaQshjxLRZAXfpZCZngXnb3bNNte9JkE7mi1yOnQ?= =?us-ascii?Q?2N7VFjSKqDEBHcDxyp8mluGpr24l7AbGDblbBD6e/4qTzKPV9XgLc394zlKc?= =?us-ascii?Q?c9szMSB3/M8vaUumrhvacnzajPEgjuwyhNI+tdeSBvkDdLsBngf5qbgGHpaa?= =?us-ascii?Q?Op+lSNuh9bO05LE9Zo5Y/tNy1uWAuZXMoZ2IMTRvF9iZNzgu7LcalYhrLrYU?= =?us-ascii?Q?saMppgHzMQT+IBqnpjVrMktPTR+vOdOfk1wcnGSxKPFOomUDhhr2WI8EP5BA?= =?us-ascii?Q?ImdwesuVu76g+RmTgwjoPpQ5NnlYJeS/foa3Y0Ealip1mH5+qxW348cPIg+C?= =?us-ascii?Q?86AC/hjljWEl532dHiEZXjxz7fIzNVVuaZeGCfH64NaP4uduNRFqTk1yjEZo?= =?us-ascii?Q?ZcjbBevkm40V5bJhdEiHvETCc2WgCUXVPcde/7jtp22n2R46t/EaI03qANb7?= =?us-ascii?Q?R6gNcI3HQZe6fIv2xpYdMpuzIKSclVlTHba5xAt7Y3M8hwlWXl5DkEDTkU3L?= =?us-ascii?Q?hY6pkO4szjahuLPZvW2vM4a1Yb4F+NwSjg5IU9Z33CibQhTnh62uaWRG/6Hl?= =?us-ascii?Q?s++cNAUDn84MfKV5Z7bujoYodtqnYNqJRbFj0p7nifYECiGT8Ww2oH9j/AEK?= =?us-ascii?Q?8aVZJtRhHUnyBwDkFd+3CzCEcEIGtyeMoXbWQHWWFs3l4ygeqVC1cGQb8Lcr?= =?us-ascii?Q?zx6vkDL14zBeZE6Oh1zOCgSuCmqIcyESMhpHSLYz9KVCXKIsHMk2QIwlVFni?= =?us-ascii?Q?rSVMJxWtHpY92rSzv3s=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MWHPR11MB1631.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd3405f1-a3e2-4320-7243-08dabafb1903 X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Oct 2022 04:48:04.5247 (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: p/6l4v2J43FGCoiZQEMwVhdBhlCeFA5TfKUxhp11XQof1YSVTwWEPi5QX3+1KMyBTZFPc/3n0p4yCt5A8qRC+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR11MB4800 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni > -----Original Message----- > From: abner.chang@amd.com > Sent: Monday, October 31, 2022 10:49 AM > To: devel@edk2.groups.io > Cc: Abdul Lateef Attar ; Garrett Kirkendall > ; Paul Grimes ; Dong, > Eric ; Ni, Ray ; Kumar, Rahul R > > Subject: [PATCH V3 2/3] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch > dependent code >=20 > From: Abner Chang >=20 > BZ# 4093: Abstract SmmCpuFeaturesLib for sharing common code >=20 > This change stripped away the code that can be > shared with other archs or vendors from Intel > implementation and put in to the common file, > leaves the Intel X86 implementation in the > IntelSmmCpuFeatureLib. Also updates the header > file and INF file. >=20 > Signed-off-by: Abner Chang > Cc: Abdul Lateef Attar > Cc: Garrett Kirkendall > Cc: Paul Grimes > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > --- > .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf | 1 + > .../SmmCpuFeaturesLibStm.inf | 1 + > .../StandaloneMmCpuFeaturesLib.inf | 1 + > .../SmmCpuFeaturesLib/CpuFeaturesLib.h | 6 + > .../IntelSmmCpuFeaturesLib.c | 206 +---------------- > .../SmmCpuFeaturesLibCommon.c | 216 ++++++++++++++++++ > 6 files changed, 227 insertions(+), 204 deletions(-) > create mode 100644 > UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c >=20 > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > index 6254a14698a..9ac7dde78f8 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf > @@ -20,6 +20,7 @@ > CpuFeaturesLib.h > IntelSmmCpuFeaturesLib.c > SmmCpuFeaturesLib.c > + SmmCpuFeaturesLibCommon.c > SmmCpuFeaturesLibNoStm.c > TraditionalMmCpuFeaturesLib.c >=20 > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > index d64d8e66b38..86d367e0a09 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf > @@ -20,6 +20,7 @@ > [Sources] > CpuFeaturesLib.h > IntelSmmCpuFeaturesLib.c > + SmmCpuFeaturesLibCommon.c > SmmStm.c > SmmStm.h > TraditionalMmCpuFeaturesLib.c > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.i > nf > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.i > nf > index 5935b3e1fd6..b1f60a55055 100644 > --- > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.i > nf > +++ > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.i > nf > @@ -21,6 +21,7 @@ > [Sources] > CpuFeaturesLib.h > IntelSmmCpuFeaturesLib.c > + SmmCpuFeaturesLibCommon.c > StandaloneMmCpuFeaturesLib.c > SmmCpuFeaturesLibNoStm.c >=20 > diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > index 8a1c2adc5c4..fd3e902547c 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h > @@ -9,6 +9,12 @@ > #ifndef CPU_FEATURES_LIB_H_ > #define CPU_FEATURES_LIB_H_ >=20 > +#include > +#include > +#include > +#include > +#include > + > /** > Performs library initialization. >=20 > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c > index 75a0ec8e948..cb4897b21e3 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c > @@ -7,16 +7,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ >=20 > -#include > -#include > -#include > +#include "CpuFeaturesLib.h" > + > #include > -#include > -#include > -#include > #include > #include > -#include "CpuFeaturesLib.h" >=20 > // > // Machine Specific Registers (MSRs) > @@ -287,64 +282,6 @@ SmmCpuFeaturesInitializeProcessor ( > FinishSmmCpuFeaturesInitializeProcessor (); > } >=20 > -/** > - This function updates the SMRAM save state on the currently executing > CPU > - to resume execution at a specific address after an RSM instruction. T= his > - function must evaluate the SMRAM save state to determine the execution > mode > - the RSM instruction resumes and update the resume execution address > with > - either NewInstructionPointer32 or NewInstructionPoint. The auto HALT > restart > - flag in the SMRAM save state must always be cleared. This function re= turns > - the value of the instruction pointer from the SMRAM save state that wa= s > - replaced. If this function returns 0, then the SMRAM save state was n= ot > - modified. > - > - This function is called during the very first SMI on each CPU after > - SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution > mode > - to signal that the SMBASE of each CPU has been updated before the > default > - SMBASE address is used for the first SMI to the next CPU. > - > - @param[in] CpuIndex The index of the CPU to hook. The= value > - must be between 0 and the NumberOf= Cpus > - field in the System Management Sys= tem Table > - (SMST). > - @param[in] CpuState Pointer to SMRAM Save State Map fo= r the > - currently executing CPU. > - @param[in] NewInstructionPointer32 Instruction pointer to use if > resuming to > - 32-bit execution mode from 64-bit = SMM. > - @param[in] NewInstructionPointer Instruction pointer to use if resu= ming > to > - same execution mode as SMM. > - > - @retval 0 This function did modify the SMRAM save state. > - @retval > 0 The original instruction pointer value from the SMRAM sav= e > state > - before it was replaced. > -**/ > -UINT64 > -EFIAPI > -SmmCpuFeaturesHookReturnFromSmm ( > - IN UINTN CpuIndex, > - IN SMRAM_SAVE_STATE_MAP *CpuState, > - IN UINT64 NewInstructionPointer32, > - IN UINT64 NewInstructionPointer > - ) > -{ > - return 0; > -} > - > -/** > - Hook point in normal execution mode that allows the one CPU that was > elected > - as monarch during System Management Mode initialization to perform > additional > - initialization actions immediately after all of the CPUs have processe= d their > - first SMI and called SmmCpuFeaturesInitializeProcessor() relocating > SMBASE > - into a buffer in SMRAM and called > SmmCpuFeaturesHookReturnFromSmm(). > -**/ > -VOID > -EFIAPI > -SmmCpuFeaturesSmmRelocationComplete ( > - VOID > - ) > -{ > -} > - > /** > Determines if MTRR registers must be configured to set SMRAM cache- > ability > when executing in System Management Mode. > @@ -414,48 +351,6 @@ SmmCpuFeaturesRendezvousEntry ( > } > } >=20 > -/** > - Processor specific hook point each time a CPU exits System Management > Mode. > - > - @param[in] CpuIndex The index of the CPU that is exiting SMM. The va= lue > must > - be between 0 and the NumberOfCpus field in the Sy= stem > - Management System Table (SMST). > -**/ > -VOID > -EFIAPI > -SmmCpuFeaturesRendezvousExit ( > - IN UINTN CpuIndex > - ) > -{ > -} > - > -/** > - Check to see if an SMM register is supported by a specified CPU. > - > - @param[in] CpuIndex The index of the CPU to check for SMM register > support. > - The value must be between 0 and the NumberOfCpus = field > - in the System Management System Table (SMST). > - @param[in] RegName Identifies the SMM register to check for support. > - > - @retval TRUE The SMM register specified by RegName is supported by > the CPU > - specified by CpuIndex. > - @retval FALSE The SMM register specified by RegName is not supported > by the > - CPU specified by CpuIndex. > -**/ > -BOOLEAN > -EFIAPI > -SmmCpuFeaturesIsSmmRegisterSupported ( > - IN UINTN CpuIndex, > - IN SMM_REG_NAME RegName > - ) > -{ > - if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D > SmmRegFeatureControl)) { > - return TRUE; > - } > - > - return FALSE; > -} > - > /** > Returns the current value of the SMM register for the specified CPU. > If the SMM register is not supported, then 0 is returned. > @@ -506,100 +401,3 @@ SmmCpuFeaturesSetSmmRegister ( > } > } >=20 > -/** > - Read an SMM Save State register on the target processor. If this func= tion > - returns EFI_UNSUPPORTED, then the caller is responsible for reading th= e > - SMM Save Sate register. > - > - @param[in] CpuIndex The index of the CPU to read the SMM Save State. > The > - value must be between 0 and the NumberOfCpus fie= ld in > - the System Management System Table (SMST). > - @param[in] Register The SMM Save State register to read. > - @param[in] Width The number of bytes to read from the CPU save st= ate. > - @param[out] Buffer Upon return, this holds the CPU register value r= ead > - from the save state. > - > - @retval EFI_SUCCESS The register was read from Save State. > - @retval EFI_INVALID_PARAMETER Buffer is NULL. > - @retval EFI_UNSUPPORTED This function does not support reading > Register. > - > -**/ > -EFI_STATUS > -EFIAPI > -SmmCpuFeaturesReadSaveStateRegister ( > - IN UINTN CpuIndex, > - IN EFI_SMM_SAVE_STATE_REGISTER Register, > - IN UINTN Width, > - OUT VOID *Buffer > - ) > -{ > - return EFI_UNSUPPORTED; > -} > - > -/** > - Writes an SMM Save State register on the target processor. If this fu= nction > - returns EFI_UNSUPPORTED, then the caller is responsible for writing th= e > - SMM Save Sate register. > - > - @param[in] CpuIndex The index of the CPU to write the SMM Save State. > The > - value must be between 0 and the NumberOfCpus fiel= d in > - the System Management System Table (SMST). > - @param[in] Register The SMM Save State register to write. > - @param[in] Width The number of bytes to write to the CPU save stat= e. > - @param[in] Buffer Upon entry, this holds the new CPU register value= . > - > - @retval EFI_SUCCESS The register was written to Save State. > - @retval EFI_INVALID_PARAMETER Buffer is NULL. > - @retval EFI_UNSUPPORTED This function does not support writing > Register. > -**/ > -EFI_STATUS > -EFIAPI > -SmmCpuFeaturesWriteSaveStateRegister ( > - IN UINTN CpuIndex, > - IN EFI_SMM_SAVE_STATE_REGISTER Register, > - IN UINTN Width, > - IN CONST VOID *Buffer > - ) > -{ > - return EFI_UNSUPPORTED; > -} > - > -/** > - This function is hook point called after the > gEfiSmmReadyToLockProtocolGuid > - notification is completely processed. > -**/ > -VOID > -EFIAPI > -SmmCpuFeaturesCompleteSmmReadyToLock ( > - VOID > - ) > -{ > -} > - > -/** > - This API provides a method for a CPU to allocate a specific region for= storing > page tables. > - > - This API can be called more once to allocate memory for page tables. > - > - Allocates the number of 4KB pages of type EfiRuntimeServicesData and > returns a pointer to the > - allocated buffer. The buffer returned is aligned on a 4KB boundary. = If > Pages is 0, then NULL > - is returned. If there is not enough memory remaining to satisfy the > request, then NULL is > - returned. > - > - This function can also return NULL if there is no preference on where = the > page tables are allocated in SMRAM. > - > - @param Pages The number of 4 KB pages to allocate. > - > - @return A pointer to the allocated buffer for page tables. > - @retval NULL Fail to allocate a specific region for storing page = tables, > - Or there is no preference on where the page tables a= re allocated > in SMRAM. > - > -**/ > -VOID * > -EFIAPI > -SmmCpuFeaturesAllocatePageTableMemory ( > - IN UINTN Pages > - ) > -{ > - return NULL; > -} > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > new file mode 100644 > index 00000000000..7777e52740e > --- /dev/null > +++ > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c > @@ -0,0 +1,216 @@ > +/** @file > +Implementation shared across all library instances. > + > +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
> +Copyright (c) Microsoft Corporation.
> +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "CpuFeaturesLib.h" > + > +/** > + This function updates the SMRAM save state on the currently executing > CPU > + to resume execution at a specific address after an RSM instruction. T= his > + function must evaluate the SMRAM save state to determine the execution > mode > + the RSM instruction resumes and update the resume execution address > with > + either NewInstructionPointer32 or NewInstructionPoint. The auto HALT > restart > + flag in the SMRAM save state must always be cleared. This function > returns > + the value of the instruction pointer from the SMRAM save state that wa= s > + replaced. If this function returns 0, then the SMRAM save state was n= ot > + modified. > + > + This function is called during the very first SMI on each CPU after > + SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution > mode > + to signal that the SMBASE of each CPU has been updated before the > default > + SMBASE address is used for the first SMI to the next CPU. > + > + @param[in] CpuIndex The index of the CPU to hook. The= value > + must be between 0 and the NumberOf= Cpus > + field in the System Management Sys= tem Table > + (SMST). > + @param[in] CpuState Pointer to SMRAM Save State Map fo= r the > + currently executing CPU. > + @param[in] NewInstructionPointer32 Instruction pointer to use if > resuming to > + 32-bit execution mode from 64-bit = SMM. > + @param[in] NewInstructionPointer Instruction pointer to use if resu= ming > to > + same execution mode as SMM. > + > + @retval 0 This function did modify the SMRAM save state. > + @retval > 0 The original instruction pointer value from the SMRAM sav= e > state > + before it was replaced. > +**/ > +UINT64 > +EFIAPI > +SmmCpuFeaturesHookReturnFromSmm ( > + IN UINTN CpuIndex, > + IN SMRAM_SAVE_STATE_MAP *CpuState, > + IN UINT64 NewInstructionPointer32, > + IN UINT64 NewInstructionPointer > + ) > +{ > + return 0; > +} > + > +/** > + Hook point in normal execution mode that allows the one CPU that was > elected > + as monarch during System Management Mode initialization to perform > additional > + initialization actions immediately after all of the CPUs have processe= d their > + first SMI and called SmmCpuFeaturesInitializeProcessor() relocating > SMBASE > + into a buffer in SMRAM and called > SmmCpuFeaturesHookReturnFromSmm(). > +**/ > +VOID > +EFIAPI > +SmmCpuFeaturesSmmRelocationComplete ( > + VOID > + ) > +{ > +} > + > +/** > + Processor specific hook point each time a CPU exits System Management > Mode. > + > + @param[in] CpuIndex The index of the CPU that is exiting SMM. The > value must > + be between 0 and the NumberOfCpus field in the Sy= stem > + Management System Table (SMST). > +**/ > +VOID > +EFIAPI > +SmmCpuFeaturesRendezvousExit ( > + IN UINTN CpuIndex > + ) > +{ > +} > + > +/** > + Check to see if an SMM register is supported by a specified CPU. > + > + @param[in] CpuIndex The index of the CPU to check for SMM register > support. > + The value must be between 0 and the NumberOfCpus = field > + in the System Management System Table (SMST). > + @param[in] RegName Identifies the SMM register to check for support. > + > + @retval TRUE The SMM register specified by RegName is supported by > the CPU > + specified by CpuIndex. > + @retval FALSE The SMM register specified by RegName is not supported > by the > + CPU specified by CpuIndex. > +**/ > +BOOLEAN > +EFIAPI > +SmmCpuFeaturesIsSmmRegisterSupported ( > + IN UINTN CpuIndex, > + IN SMM_REG_NAME RegName > + ) > +{ > + if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D > SmmRegFeatureControl)) { > + return TRUE; > + } > + > + return FALSE; > +} > + > +/** > + Read an SMM Save State register on the target processor. If this func= tion > + returns EFI_UNSUPPORTED, then the caller is responsible for reading th= e > + SMM Save Sate register. > + > + @param[in] CpuIndex The index of the CPU to read the SMM Save State. > The > + value must be between 0 and the NumberOfCpus fie= ld in > + the System Management System Table (SMST). > + @param[in] Register The SMM Save State register to read. > + @param[in] Width The number of bytes to read from the CPU save > state. > + @param[out] Buffer Upon return, this holds the CPU register value r= ead > + from the save state. > + > + @retval EFI_SUCCESS The register was read from Save State. > + @retval EFI_INVALID_PARAMETER Buffer is NULL. > + @retval EFI_UNSUPPORTED This function does not support reading > Register. > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmCpuFeaturesReadSaveStateRegister ( > + IN UINTN CpuIndex, > + IN EFI_SMM_SAVE_STATE_REGISTER Register, > + IN UINTN Width, > + OUT VOID *Buffer > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +/** > + Writes an SMM Save State register on the target processor. If this fu= nction > + returns EFI_UNSUPPORTED, then the caller is responsible for writing th= e > + SMM Save Sate register. > + > + @param[in] CpuIndex The index of the CPU to write the SMM Save State. > The > + value must be between 0 and the NumberOfCpus fiel= d in > + the System Management System Table (SMST). > + @param[in] Register The SMM Save State register to write. > + @param[in] Width The number of bytes to write to the CPU save stat= e. > + @param[in] Buffer Upon entry, this holds the new CPU register value= . > + > + @retval EFI_SUCCESS The register was written to Save State. > + @retval EFI_INVALID_PARAMETER Buffer is NULL. > + @retval EFI_UNSUPPORTED This function does not support writing > Register. > +**/ > +EFI_STATUS > +EFIAPI > +SmmCpuFeaturesWriteSaveStateRegister ( > + IN UINTN CpuIndex, > + IN EFI_SMM_SAVE_STATE_REGISTER Register, > + IN UINTN Width, > + IN CONST VOID *Buffer > + ) > +{ > + return EFI_UNSUPPORTED; > +} > + > +/** > + This function is hook point called after the > gEfiSmmReadyToLockProtocolGuid > + notification is completely processed. > +**/ > +VOID > +EFIAPI > +SmmCpuFeaturesCompleteSmmReadyToLock ( > + VOID > + ) > +{ > +} > + > +/** > + This API provides a method for a CPU to allocate a specific region for > storing page tables. > + > + This API can be called more once to allocate memory for page tables. > + > + Allocates the number of 4KB pages of type EfiRuntimeServicesData and > returns a pointer to the > + allocated buffer. The buffer returned is aligned on a 4KB boundary. = If > Pages is 0, then NULL > + is returned. If there is not enough memory remaining to satisfy the > request, then NULL is > + returned. > + > + This function can also return NULL if there is no preference on where = the > page tables are allocated in SMRAM. > + > + @param Pages The number of 4 KB pages to allocate. > + > + @return A pointer to the allocated buffer for page tables. > + @retval NULL Fail to allocate a specific region for storing page = tables, > + Or there is no preference on where the page tables a= re allocated > in SMRAM. > + > +**/ > +VOID * > +EFIAPI > +SmmCpuFeaturesAllocatePageTableMemory ( > + IN UINTN Pages > + ) > +{ > + return NULL; > +} > -- > 2.37.1.windows.1