From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.62]) by mx.groups.io with SMTP id smtpd.web11.3035.1666143103864004817 for ; Tue, 18 Oct 2022 18:31:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=vrRKsgQH; spf=permerror, err=parse error for token &{10 18 %{i}._ip.%{h}._ehlo.%{d}._spf.vali.email}: invalid domain name (domain: amd.com, ip: 40.107.237.62, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VpOSMP3xMjwQHOREYIsZQt0wY2OC0uR/7+ztw7HqCIN+xKntDZDuJEaBepe59nPHRf8Y1+/QjvJO/TlfXXFkeppZBZm4GPh4h4TYqF74yxHWaAhaonot5iQAYQBeRgCucW+kpfk59Cfk3p5vdzpmg290BPE42G7HSRUFO0OaaRS6HVfs2+K73OSvP6vS/PZw7ZcJ5vl8y8Oz2ULMHb+Sy7gXyq8E9iMtzAULN2VOaKIRWdyrMP37IPUDziN0EUlilKvNWLdxHlo/nN7wXojkNYEtN5Zkh8iM5KlgFqnIlwAIbfOAdpC1IEjb5cj2ceXxLvuBFVykOe28U1ie+5zVKw== 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=4xgR0EDx1lJPFMZgS5NEc4d0rt/0ft+gv1a60FfHIIA=; b=PDR2wrOvR5PpTnH9wez1UNOn6ASFsbmLwbfRyrbXFpmTMo2JGIWP3UVy6rnQyiH1GglVTy0RquvAx9g5yp73NcnilolnpVHr1KmDyYR6I5qW8whfIVKHW+1jMCf4qrHyF2SOVkqteRQ1VDF+dIeDJqJS36ckQtYvJtEcF6OGY1ac7Cr7Jyif7QdEITZyr87WaaHNDM2osn8sHNTY2qpg30A7cqKmDF1qxaaZfTXqVxhjgPnzMSSHGUdhNTMB9tLOodyehuVZ373oBbsLSUlvyhWGJOHbRkDHxzZ9m3uf8SujzPVc0yzXvuY0y4S550dq34JmE4Gyted3dZkvL0+fXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4xgR0EDx1lJPFMZgS5NEc4d0rt/0ft+gv1a60FfHIIA=; b=vrRKsgQHFGqFaVaJ4ALk9iuTF6G8hBuDXTOw+PRweV+DQzk2sqmnQA8XwQVFlenPR5RNXL2OpKwWT8d8y/0VvNb1aEFhU733Sw7Vlh3oqYHs7fo4yoQHV+mmoaDXjrROvLkvAq2BIgg2b2D+jaCAJ5e0aPsdw3fgQ4Bhlq3qjkw= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by MW4PR12MB7143.namprd12.prod.outlook.com (2603:10b6:303:222::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Wed, 19 Oct 2022 01:31:41 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::2eab:b851:827c:1d88]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::2eab:b851:827c:1d88%3]) with mapi id 15.20.5723.034; Wed, 19 Oct 2022 01:31:23 +0000 From: "Chang, Abner" To: "Ni, Ray" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Coding Standard: Updates 4.2 and 4.3 sections Thread-Topic: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Coding Standard: Updates 4.2 and 4.3 sections Thread-Index: AQHY4rcWPTSlQa6vmkKZa0/ySI3iUK4T5O5QgAEI6QA= Date: Wed, 19 Oct 2022 01:31:23 +0000 Message-ID: References: <20221015114757.383-1-abner.chang@amd.com> <20513.1666072896702226815@groups.io> In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-10-19T01:31:15Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=30ca959e-a6f8-4063-acd8-77a9e8d281b8; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN2PR12MB3966:EE_|MW4PR12MB7143:EE_ x-ms-office365-filtering-correlation-id: ad21c039-02f0-4151-d63f-08dab171a1ea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 7MuzAFNI61HBhJdbWVjepssPMeWTiWau/RmzgtwmWOw/B75YeD/Fs2zNq1r5Qz+buRZ78JLZXgHUINMgtbpZqKjk3wnMhc64jF2bdIJscOQyLAwR39QdLqcs0FtDQwfpID21P9Rm14n3eB1hLBvQXUC0DOgdvakeQ9zjgMSESAWiAUt3J1Y/kxBLKxFrkVVlycBLAowOAOWhPs12/cUJt1FoqnQzEdFST5qWgb4qV1jU1eStK52yXnqhkvN/kjxrgdQGmRzbB9s0O8n2qmYWUrm/Rh4yJqJgWGk+iKiX9vlkn7GANUefWuexF4faYqjz8/SHITxLDnWwN+cftApQRZxSfnN0LPnQFi88jpYFM5zll8r7JioMmxNKQL2bB5Tjsm1Kv9H2iGgc0S8Y3XJg0Im/lxaOrjKoRR0GFOE3e+QESSAtFIBjH4rdRxY3RVMQc+9WktkyKHI1TrNb91o0j7k9MtpKLafpru0B028xz1Ip2ZFh1U/UEwvIapbXUlYFffjVVwF7hZtuJnkWVvq1nfYzSAqojTiIGvNbtzRdwAcnRmYS+HkKkyUbLMkzj2ohr74tqbT//x5sAyc17cob50FStcNC6+e0jMkqIezEMg+l/FEGIPZHuikgPkLQ2e9I2HIxQxeg0HFeZqyE13S+Y+pM6sWmyUCI62z/4sfw4ORb3k/6iRCGv4n4GQfgiRYp6+YEtVNAs5T+xBYYOo9i477/c/G9WBhCDxZE7Z+Z3ws3sbkcVakEVIqgOcZiFo4m6IzpX0QEApE/ZOTgp1xgug== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN2PR12MB3966.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(366004)(39860400002)(346002)(136003)(396003)(376002)(451199015)(122000001)(99936003)(26005)(38100700002)(86362001)(38070700005)(66446008)(55016003)(64756008)(66556008)(66946007)(33656002)(66476007)(76116006)(8676002)(110136005)(316002)(15650500001)(2906002)(5660300002)(8936002)(41300700001)(186003)(83380400001)(478600001)(52536014)(53546011)(71200400001)(9686003)(7696005)(6506007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?KLHZx8IpG/rqxgG6YjKI0AEoC1UAzkAI8Vecqq5tseq1OAOJJebX4UqaPqnw?= =?us-ascii?Q?zfUGg3KNQ8071MRunTNs6AXaSycokgwWV3Z3bmNev1ogO+U2EQS/CZ5aQ14V?= =?us-ascii?Q?Lx6qTCAhjXIexi6Rw78LOP/DK5pITYnvlDiGoF40dFN9sU0L2cSpXNxjuGmB?= =?us-ascii?Q?dTTcZseW7EkEo9Ah77cayFro0qcxZrr55NGoZjDCd238+YXPUKR4krBWpMH5?= =?us-ascii?Q?0TvJV44Cr98nwdzIrateQMT/JU/narbRr2DBPTB78yQGlqIKNgw6TL6xzLj1?= =?us-ascii?Q?xCFfveqOtoMib30+YmVEmV2SLqvmC+QzZimVyT+q6TuKrD8xv18SAc3dp7s1?= =?us-ascii?Q?IdTUp7B0EXocilQHTstDaP0wyt0klln+A9p+En68UsdDWqj6soM5BizvAW3L?= =?us-ascii?Q?dx2vopsb8zfm+2IJj1h9at/+veLhoJ5e0Zg7CcaAyWZMP//ceQD6ZZK2AlV/?= =?us-ascii?Q?fdSV8QbbT/4VOY5IzU22nPq6UUfzKE2L+GwlNpd6PROMDC5WoVsd8Zom1N+8?= =?us-ascii?Q?rIw81nhVr1Z3OpcRIyfn+awk4qYp6U5Y4d5oRtVAyTr58r0LHyJfGvT8zb53?= =?us-ascii?Q?yYyBRI6tLrWbdfJfQdNB72zIxfT1+PHS427Oypn8bJHBPdTJad9sSRgOr5i6?= =?us-ascii?Q?cCxTHoq+me+PP5WtP2JftguiEJXl2oGF5zHjdE6rk+FLcsQOkbSEGbtfdYIk?= =?us-ascii?Q?6Gp1aR3Mh9wafXCnjqaTycaYix/b03TnMJ1JkPtyv4gc8W3tMqjqAieY1tFs?= =?us-ascii?Q?sRpiCM5GsEkTW2xNcZTHLX3pSJZ/pWZB7lTuse9cmdLLkoMKB0WPQhfijw4K?= =?us-ascii?Q?lm6L/0ihVuxdyS30daW2QVfJ6KWbSRC0tAyjJ5/5WrDEDUMrTptM4hshegJP?= =?us-ascii?Q?LKLAXhqxU6WzcppvbLyXCwnBGWI3HiFVp9vs1jtZuytHZeXztH9zIItUG+CB?= =?us-ascii?Q?A6jno0rHgUpyuQ96mQdya3fz78vDuzKcY2PFWbJwcHRv3OSy932njuHhat+K?= =?us-ascii?Q?kgvyFAn/B91MuRv/RKrdnWXjkoVD4w42QNNnHqVz/VNHg52Swp6VrwZET5M3?= =?us-ascii?Q?NGM2ttZrNI+5XYdewNnCy2Eba2UiWFE7x1jd09eD7hEskSp6HNe9ZFW4X6jx?= =?us-ascii?Q?LLOnutc/ZLbfBNpbihFENX552NzkakDcHmi9+eN4dUOMHm/CfyZXoK6xhjc1?= =?us-ascii?Q?20Uoh6OhwWXSReDHK0O4b+iXXTeaMpUi1XZpHMKaaxkDMVXOeA+VYUZywZp9?= =?us-ascii?Q?/ooOMfDjAaMY8GgeGiZHMXR4/hoMjCMXUjYG5Bon3H9R1TQEWpFHOzxyIRUw?= =?us-ascii?Q?U+E4j42L/ZuYE+B2k2aPGXUqqInkk0SMuvN7Bb/LS2X72Vu0dNrsF9Um3N08?= =?us-ascii?Q?m/xpkadz5oBuZrJn2QoBFvdR0b2HCnp4PQR1ArG5QiXVQ0JMkdqe3uwCrDwy?= =?us-ascii?Q?VSv1MhMZDmC37842azstT/1uHsTSHSXdUm8I6E7ij98h+Y0f4x2M3QyyBViI?= =?us-ascii?Q?iDw5fQJK/vxwjrdQ/leMM+Pi2W5pL2Fcu1d8HNGNNuIRkllpZtqKdQsjxhLZ?= =?us-ascii?Q?NRjBvKf+OdDqT9xRJPwq4lAIxuTrIFLZgp4QHvUF?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN2PR12MB3966.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad21c039-02f0-4151-d63f-08dab171a1ea X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Oct 2022 01:31:23.1664 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: raw5WgLx4i9y9LYhVJ1J+InJdaPaYdyoUVFtoOhSONf4h34hrOKaBmqptsJu5dGfLMosOw9ZPSTbUTeFlwpIew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7143 X-Groupsio-MsgNum: 95351 Content-Language: en-US Content-Type: multipart/mixed; boundary="_004_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_" --_004_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_ Content-Type: multipart/alternative; boundary="_000_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_" --_000_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] BTW Ray, you can see SmmCpuFeaturesLib is renamed to IntelSmmCpuFeaturesLi= b in the 1/2 of SmmCpuFeatureLib rearchitecture patch. AMD will upstream it= s own SmmCpuFeaturesLib named as AmdSmmCpuFeaturesLib later. The naming is = follow the above guidelines. Abner From: Chang, Abner Sent: Tuesday, October 18, 2022 5:50 PM To: Ni, Ray ; devel@edk2.groups.io Subject: RE: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Coding St= andard: Updates 4.2 and 4.3 sections [AMD Official Use Only - General] Hi Ray, ][].* The simple naming rule was already defined in the 4.3.1 to 4.3.= 4 sections. We are not intending for defining the file naming style. This s= ection is mainly for the format of attaching and to the = filename. For example, how do we add AMD to SmmCpuFeaturesLib? Is "Amd"SmmCpuFeatures= Lib or SmmCpuFeaturesLib"Amd"? This is what we would like to define for the= processor archs and vendors. My opinion is we can just leave the file format naming as it was defined in= this spec. Or how about if we say "Refer to 4.3.1 to 4.3.4 sections for the file namin= g format" for in below? [][].* OPTIONAL The is represented with a BNF, ::=3D'Ia32' | 'X64' | 'Arm' | 'AArch64' | = 'RiscV64' | 'LoongArch64' | 'Ebc' ::=3D []* Example: Ia32X64Arm or RiscV64LoongArch64 OPTIONAL * REQUIRED Refer to 4.3.1 to 4.3.4 sections for the file Naming format. Thanks Abner From: Ni, Ray > Sent: Tuesday, October 18, 2022 2:02 PM To: Chang; Chang, Abner >; = devel@edk2.groups.io Subject: Re: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Coding St= andard: Updates 4.2 and 4.3 sections Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. All look good to me. Thanks for addressing my comments regarding simplifyin= g the rules. Except for one minor comment: I still don't think we need to define rules f= or source file names (4.3.5.4 EDK II source files within a Library/Module i= nstance). And the rule "[][].*" doesn't specify what could be. That leads t= o allowing any style of the file name. --_000_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

[AMD Officia= l Use Only - General]

 

BTW Ray,  you can see SmmCpuFeaturesLib is rena= med to IntelSmmCpuFeaturesLib in the 1/2 of SmmCpuFeatureLib rearchitecture= patch. AMD will upstream its own SmmCpuFeaturesLib named as AmdSmmCpuFeatu= resLib later. The naming is follow the above guidelines.

 

Abner

 

 

From: Chang, Abner
Sent: Tuesday, October 18, 2022 5:50 PM
To: Ni, Ray <ray.ni@intel.com>; devel@edk2.groups.io
Subject: RE: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Co= ding Standard: Updates 4.2 and 4.3 sections

 

[AMD Officia= l Use Only - General]

 

Hi Ray,

 

<CpuArch>][<Vendor>]<FileName>.*

 

The simple <FileName> naming rule was already =  defined in the 4.3.1 to 4.3.4 sections. We are not intending for defi= ning the file naming style. This section is mainly for the format of attach= ing <CpuArch> and <Vendor> to the filename.

For example, how do we add AMD to SmmCpuFeaturesLib?= Is ”Amd”SmmCpuFeaturesLib or SmmCpuFeaturesLib”Amd”= ;? This is what we would like to define for the processor archs and vendors= .

My opinion is we can just leave the file format nami= ng as it was defined in this spec.

 

Or how about if we say &= #8220;Refer to 4.3.1 to 4.3.4 sectio= ns for the file naming format” for <FileNmae> in below?

 

[<CpuArch>][&l= t;Vendor>]<FileName>.*

 

   <Cpu= Arch>   OPTIONAL   The <CpuArch> is represente= d with a BNF,

   &n= bsp;            = ;          <arch> ::=3D'= Ia32' | 'X64' | 'Arm' | 'AArch64' | 'RiscV64' |

   &n= bsp;            = ;            &n= bsp;       'LoongArch64' | 'Ebc'

   &n= bsp;            = ;          <CpuArch> ::= =3D <arch>[<arch>]*

 

   &n= bsp;            = ;          Example: Ia32X64Arm= or RiscV64LoongArch64

   <Ven= dor>    OPTIONAL   *

   <Fil= eName>  REQUIRED   Refer to 4.3.1 to 4.3.4 sections for t= he file

   &n= bsp;            = ;          Naming format.

 

Thanks

Abner

 

From: Ni, Ray <ray.ni@intel.com>
Sent: Tuesday, October 18, 2022 2:02 PM
To: Chang; Chang, Abner <A= bner.Chang@amd.com>; devel@edk2.groups.io
Subject: Re: [edk2-devel] [tianocore-docs][PATCH V2 2/2] edk II C Co= ding Standard: Updates 4.2 and 4.3 sections

 

Caution: This message originated from an External Source. Use proper caution= when opening attachments, clicking links, or responding.

 

All look good to me. Thanks for addressing my comments regarding simplif= ying the rules.

Except for one minor comment: I still don't think we need to define rule= s for source file names (4.3.5.4 EDK II source files within a Library/Modul= e instance). And the rule "[][].*" doesn't specify what could be.= That leads to allowing any style of the file name.

--_000_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_-- --_004_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_ Content-Type: message/rfc822 Content-Disposition: attachment; creation-date="Wed, 19 Oct 2022 01:31:18 GMT"; modification-date="Wed, 19 Oct 2022 01:31:22 GMT" Received: from SA0PR12MB4445.namprd12.prod.outlook.com (2603:10b6:806:95::15) by MN2PR12MB3966.namprd12.prod.outlook.com with HTTPS; Fri, 30 Sep 2022 09:53:02 +0000 Received: from MW4PR03CA0090.namprd03.prod.outlook.com (2603:10b6:303:b6::35) by SA0PR12MB4445.namprd12.prod.outlook.com (2603:10b6:806:95::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.23; Fri, 30 Sep 2022 09:52:59 +0000 Received: from CO1NAM11FT091.eop-nam11.prod.protection.outlook.com (2603:10b6:303:b6:cafe::f0) by MW4PR03CA0090.outlook.office365.com (2603:10b6:303:b6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.20 via Frontend Transport; Fri, 30 Sep 2022 09:52:59 +0000 Received: from mail02.groups.io (66.175.222.108) by CO1NAM11FT091.mail.protection.outlook.com (10.13.175.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Fri, 30 Sep 2022 09:52:59 +0000 From: "Chang, Abner via groups.io" To: "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" , "Kirkendall, Garrett" , "Grimes, Paul" , Eric Dong , Ray Ni , Rahul Kumar Subject: [edk2-devel] [PATCH 1/2] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Thread-Topic: [edk2-devel] [PATCH 1/2] UefiCpuPkg/SmmCpuFeaturesLib: Abstract arch dependent code Thread-Index: AQHY1LJu59HtVpnfdkqBhVBUjRRaTA== Sender: "devel@edk2.groups.io" Date: Fri, 30 Sep 2022 09:52:28 +0000 Message-ID: <17199AA59D1EDE0C.23184@groups.io> List-Help: List-Subscribe: List-Unsubscribe: Reply-To: "devel@edk2.groups.io" , "Chang, Abner" Content-Language: zh-CN X-MS-Exchange-Organization-AuthSource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-Exchange-Organization-Network-Message-Id: 35230bb7-98f0-4e2c-9f41-08daa2c98ebb X-MS-TNEF-Correlator: X-MS-Exchange-Organization-RecordReviewCfmType: 0 received-spf: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C x-ms-exchange-organization-originalclientipaddress: 66.175.222.108 x-ms-exchange-organization-originalserveripaddress: 10.13.175.146 x-ms-publictraffictype: Email x-originating-ip: [10.180.168.240] authentication-results: spf=pass (sender IP is 66.175.222.108) smtp.mailfrom=groups.io; dkim=pass (signature was verified) header.d=groups.io;dmarc=bestguesspass action=none header.from=groups.io;compauth=pass reason=109 delivered-to: mailing list devel@edk2.groups.io mailing-list: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io list-id: dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664531578; bh=OG0Nj+UiRrmYJHZ7IvXRKYxiRxbUMmseMdA60+jYDyk=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=ki0x+QlJ6Z5IywdZdxjSnDFOx2tyxc8n4ejOIPyCtnQWMSP2Sq24Km+OPeKVlTFmmNR Po2EHlUz4KUYkkZmVrbyCzDq/nyiXpMLodcKbfZSRC0b8b8bGYIeb3ajSRn7s48ul3btg Fps4t3pGuF2mHgyxJnWWAbnGSx030R59TRw= x-ms-office365-filtering-correlation-id: 35230bb7-98f0-4e2c-9f41-08daa2c98ebb x-ms-traffictypediagnostic: DM6NAM11FT046:EE_|CH0PR12MB5251:EE_|CO1NAM11FT091:EE_|SA0PR12MB4445:EE_ x-forefront-antispam-report: CIP:66.175.222.108;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail02.groups.io;PTR:mail02.groups.io;CAT:NONE;SFS:(13230022)(4636009)(451199015)(36756003)(36736006)(54906003)(19810500001)(33656002)(66899015)(30864003)(356005)(336012)(956004)(2616005)(83380400001)(7636003)(7596003)(5660300002)(76796012)(26005)(6666004)(107886003)(7846003)(6486002)(966005)(8676002)(4326008)(7696005)(6862004)(1096003)(34756004)(118246002)(9316004);DIR:INB; x-microsoft-antispam: BCL:0; x-ms-exchange-crosstenant-network-message-id: 35230bb7-98f0-4e2c-9f41-08daa2c98ebb x-ms-exchange-crosstenant-originalarrivaltime: 30 Sep 2022 09:52:59.2352 (UTC) x-ms-exchange-crosstenant-fromentityheader: Internet x-ms-exchange-crosstenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d x-ms-exchange-transport-crosstenantheadersstamped: SA0PR12MB4445 x-ms-exchange-transport-endtoendlatency: 00:00:02.9223221 x-ms-exchange-processed-by-bccfoldering: 15.20.5676.023 x-eopattributedmessage: 1 x-ms-exchange-crosstenant-authas: Anonymous x-ms-exchange-crosstenant-authsource: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com x-received: from TPE-L1-ABNCHANG.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Fri, 30 Sep 2022 04:52:45 -0500 arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d6mgHPb4P1A19uI9r8IFyJ2rJanVHHVKCkfd2ZSb8ExIj09dVzC9d7OyQCyuDSsCByC/HJ27Fl/sjzr8b9M41ui0otC76QXkxrUfc1BU6Jn+ygwitMm+34Ffr6ZcjNaxG/zgG1AHqqNmdoJA9REnRoXVQrxCqasjo3aLA5BBgSTLqSfguOmKzcxzBGsuLhR/EWIxsxS/o2kzPAvk/Oh0LXBjj9UmA3m5KBBgeypsdsZ1QklLJrpq5h/tmwKp218Y+BaW753iSmCLq1WNBoSbKUdv5rTN80nxNi1t/950BEOJEhzwhXoBYyFtrAxkR5/PY6Ans5VsBHj8cWNPWxp+fw== 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=DZOkNSogqT2wSOTTbQ6cu+EjyX1ZF8Whq+68UiScoO4=; b=QPqIWq51Z7r1Ngp5z1MxBYauO5eRVRJ+UNDQVV8K9Y0Y5/LQ9mBAAps/9vhLekOpo1vAdWKpuBzt348j4rMyPd5Y08qmXEOB7p6+ezyxQSO/PhgdncuGUzGDEK7Wh1p+2kyYXbaIuDR1yBOz0E6+kAnQpMPADG3Sa6D8NNsWJkKmAXp/pQaVW93WoPIm6zqbHsDPIyLbntKQlDTYcGBl9c++oc/CW5Yx8WlhJ+1/Q1ASalsUrkfRtBWhWA6WN+pnqz29qQU7o3JVDGaLOMmCj9BzFZoHQbPY4iKv06zgjVk07glb+4hXyZXkJRuh3FPYnRFLdBiIPONjnH5Jt0ce8Q== arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info-original: 7gm5V0Xob6C8mRsRUydnu0YbHAyDETDx3w8FQDvxzwJMyM+polpwmBP0tsfjitZwp4W+yauOlg68lJrcT8jaJs60hdj+oewyTEuK6h/nz933cM+IZuo0wb3D0zw+jYVXhQ65kDoxue9utw7sjidgwgLoEqr+LwKbRZNf/ACe2ghjdgnDDOx4H0ymaDlE/CjJlR3sQiT0uDuQCZdxi6KklJNdcM1lUCLau2dtZzJiQi1NJRye+dqHWOZL8pew1n/shiUUhrfWrbNEBOqU5x8CxKC3wP8ZvvXoD6Bdig5rvdbBE4LY8eNZ1DgqbiRH4UX8+xV4qiFjXdBgWV/I1YsALv7xs2cplAcMI0GvdhIF2mN+kD92gok18X1J82Dn7RypxHyx5YHP6uvfv03oF9v55KRyY1CGLnsXqFWxFeB6O+d/fD8YkEbLN3Q3jOcOiO4cgwNZgoADyhFBTYjQbDTysnLac4yxxiqkKL0C6y9S05Q5HTWSPFIRXxfhUZyAozvOV9QkgeK4nI891NKm61jbPOIwWDtqEBdvt+hnFLuRY1Oo4sDGcyyk9eYSBd3mC159Qe0TWREKLymdZRd5Oyuo9C0pyXiELXavoa55r1dGAnXLlkEpOX7oGQgv4PvzrpE0OOl4mTJuYr5IP10q7iKo53zw986c6KLK/x3u+5ZkTzVTvuVzYpV2CYdO+MqIMHW71CdZFlx4LPGKIZJA1E3NSxnBZlMck9qznmYF0ml0snHS50cNWok3zsx1yrEIvmXXaFZ/Wck7O21/vr/+urV/SdlptlFSO7OMWPe58gkChxZ1GeHPTeosXks4oIhqDyEz x-ms-exchange-transport-crosstenantheadersstripped: CO1NAM11FT091.eop-nam11.prod.protection.outlook.com x-ms-office365-filtering-correlation-id-prvs: efa44f6f-88bf-4577-aa1f-08daa2c988f6 x-ms-exchange-antispam-relay: 0 x-gm-message-state: Lp196KaZlOLmdMO4C41DXPaix7039027AA= x-clientproxiedby: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) x-ms-exchange-atpmessageproperties: SA|SL X-Microsoft-Antispam-Mailbox-Delivery: ucf:0;jmr:0;auth:0;dest:I;ENG:(910001)(944506478)(944626604)(920097)(930097); X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?CVt7H4phCoWTF59gFpBbwR6SzX1JwFm6RxY2V0sfEejfwOZsN0mly7dQ9D99?= =?us-ascii?Q?OYpvqg2I5cJ43O4PE24wlLe3DO7xqDOUb5wVAtX+OsvnuyUZJ3uBv8Mo6UQF?= =?us-ascii?Q?9Q5jGldulk3F7eu+QR06imzUczvafMb5yZ8XWfUmEuUW0hRONL1btWJgwt0y?= =?us-ascii?Q?NiDvDqI3pJngCicz4nweewoKpJgL+wXlC8XUtXDcUrPDIVLbG3ZVGjmGM5VO?= =?us-ascii?Q?e1NzyrDKA2txIRtooIUHXNmMagKVAgN6Ptk/G/FPTcXmDFQro71kUUpQgwFo?= =?us-ascii?Q?iCItOf1WEs+jkZzh9fMTRgOluhepk9vmoMKBevv0Kp67EI+B0lsoK4+ljgeZ?= =?us-ascii?Q?rjUGymijS51l7GThSP1DrkNJr+P+SonDSiaU1chMm5XkvkR+99qSxJA0uzV+?= =?us-ascii?Q?aQ6siOj0CiF2L6VaTWei0CH/rlG45GIuHnVpJoANvya8wHC5yYYEnlfCtBS/?= =?us-ascii?Q?MaoywZhWI5Y/ZPT6CeVxUnBxxBlHMHcjt3MEEZ5IR5UXmqElSkf5PWamJC6+?= =?us-ascii?Q?BojXiupAr1LxxbQqtzObKrYkyaxfkOOCzQZraR66CwF4N4tI7G0m8AOURzUF?= =?us-ascii?Q?uFwUmkvxWQaak6ecwRVXtLn8cSyUlnCyzUwp9NPYZPvvHU5Is3obm3AtBX+z?= =?us-ascii?Q?1B66XeoEUFAksRFC6L5DUmDEEEmN6PHxTqWUGbt+gCJwN7DOLoYgquhI7kOF?= =?us-ascii?Q?Aqpb/Kdhlm3+xh7WtOJZdSwMb/8OZDHMLafwB8RnFfR6N6kcEGr84jvcWnAO?= =?us-ascii?Q?2zppqESO7Rfk9u5NyFuMrx+zMSv8ECs7gEL4dMbdU5Seqay3HV8BPMdclF55?= =?us-ascii?Q?12fycqw5GcGJk1q7KyBtzIo4CCbnsKNXn5srP0wV2FzdnrYXFqW3A+938Vqs?= =?us-ascii?Q?32R6paH3aldQ9ZIxYbHM7Q/lQCSXEtyDqL3JlKzpV5+8dEzjbnkBuCwxAnHK?= =?us-ascii?Q?gg87bfKcxYgftMKmu8xLVqmL1NAkT7gCvfNbslqaalh5I53NPIp2FhijU2Iv?= =?us-ascii?Q?PrXTh3AUWWw967EWT8k415szNLWcES2df6ALyVMU1+NQVcxRSAY+irzjYrqQ?= =?us-ascii?Q?FuaFaslyCKk+fz/eNOYL+rV0vvG/8A0mTioWjybkiSiX96d8r9VxCvW6qQHc?= =?us-ascii?Q?CEv/ZrIPbNJlFIzfoIZYl95PsKDqr3Veftu6QtwHLp1wGyhqubr0TsVuRJpJ?= =?us-ascii?Q?GbAX1dbFcT5vcpsl4KS+IsM1UWzrzV3kwio7oD5lE+eB/eek8unNqp2gh8Jw?= =?us-ascii?Q?Q4PHX/SbRJPsv6hXeNEmrNgdkYBnLNJd3X9pMyzPj/GN7T4LFAmR/ZyRcT9t?= =?us-ascii?Q?y2j2CIrZE4qbWi0+3SDvrOxCvMmecJSn3wF7g7Q6UESjnolGvKxyqQ765A86?= =?us-ascii?Q?jghnFut6UIrXeZC6rcd+pq9AE0/deTOzA325VhGOH+Aju8632fdKdnm10XG6?= =?us-ascii?Q?1+PNDaqHdZB0yzKH7OYYDag2tJaivWGpRziaSLsZWX6G9Gsm6GAra1JnfM0j?= =?us-ascii?Q?pYhIH+vBbs0jQNx5ieC3uxu+rDYpEzzhP1fljviCg+gOdTShixFquSRMys8t?= =?us-ascii?Q?8/W2eDY0qxNVX5CMLVoA21HzX45xOo8/Z3CU+E3xO6+aGOuAHCVotjrSKii4?= =?us-ascii?Q?IcmW6qYZKMjoSvu0oMa88L8u5cx8Zh8Cvt3IOK2k2+SzZXQfqYFOM6JcUpFO?= =?us-ascii?Q?LBy/jDefiosmcRLU2sNUUVPkc/+b47j6btBJxMfj/RhsG/EskJtEsfb+AmLW?= =?us-ascii?Q?g546iooXdgIYKaDaCS7wsu+Oa42sx1YMH8+Zgu3GT6p/sf9EcnuDnRC/cX2y?= =?us-ascii?Q?mXsS8E845wHQQw=3D=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. From: Abner Chang This change strips away Intel X86 implementation and put it in the IntelSmmCpuFeatureLib 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 | 403 ++++++++++++++++++ .../SmmCpuFeaturesLibCommon.c | 391 +---------------- 6 files changed, 413 insertions(+), 390 deletions(-) create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeature= sLib.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf b/U= efiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf index 7b5cef97008..9ac7dde78f8 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf @@ -18,6 +18,7 @@ [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c SmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf = b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf index 85214ee31cd..86d367e0a09 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf @@ -19,6 +19,7 @@ [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmStm.c SmmStm.h diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLi= b.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf index 3eacab48db3..61890205e18 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf @@ -20,6 +20,7 @@ [Sources] CpuFeaturesLib.h + IntelSmmCpuFeaturesLib.c StandaloneMmCpuFeaturesLib.c SmmCpuFeaturesLibCommon.c SmmCpuFeaturesLibNoStm.c diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/CpuFeaturesLib.h b/UefiCp= uPkg/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_ +#include +#include +#include +#include +#include + /** Performs library initialization. diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c = b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c new file mode 100644 index 00000000000..cb4897b21e3 --- /dev/null +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c @@ -0,0 +1,403 @@ +/** @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 "CpuFeaturesLib.h" + +#include +#include +#include + +// +// Machine Specific Registers (MSRs) +// +#define SMM_FEATURES_LIB_IA32_MTRR_CAP 0x0FE +#define SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A +#define SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE 0x1F2 +#define SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK 0x1F3 +#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE 0x0A0 +#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK 0x0A1 +#define EFI_MSR_SMRR_MASK 0xFFFFF000 +#define EFI_MSR_SMRR_PHYS_MASK_VALID BIT11 +#define SMM_FEATURES_LIB_SMM_FEATURE_CONTROL 0x4E0 + +// +// MSRs required for configuration of SMM Code Access Check +// +#define SMM_FEATURES_LIB_IA32_MCA_CAP 0x17D +#define SMM_CODE_ACCESS_CHK_BIT BIT58 + +// +// Set default value to assume IA-32 Architectural MSRs are used +// +UINT32 mSmrrPhysBaseMsr =3D SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE; +UINT32 mSmrrPhysMaskMsr =3D SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK; + +// +// Set default value to assume MTRRs need to be configured on each SMI +// +BOOLEAN mNeedConfigureMtrrs =3D TRUE; + +// +// Array for state of SMRR enable on all CPUs +// +BOOLEAN *mSmrrEnabled; + +/** + Performs library initialization. + + This initialization function contains common functionality shared betwen= all + library instance constructors. + +**/ +VOID +CpuFeaturesLibInitialization ( + VOID + ) +{ + UINT32 RegEax; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + + // + // Retrieve CPU Family and Model + // + AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); + FamilyId =3D (RegEax >> 8) & 0xf; + ModelId =3D (RegEax >> 4) & 0xf; + if ((FamilyId =3D=3D 0x06) || (FamilyId =3D=3D 0x0f)) { + ModelId =3D ModelId | ((RegEax >> 12) & 0xf0); + } + + // + // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability + // + if ((RegEdx & BIT12) !=3D 0) { + // + // Check MTRR_CAP MSR bit 11 for SMRR support + // + if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) !=3D 0) { + ASSERT (FeaturePcdGet (PcdSmrrEnable)); + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Famil= y + // + // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then + // SMRR Physical Base and SMM Physical Mask MSRs are not available. + // + if (FamilyId =3D=3D 0x06) { + if ((ModelId =3D=3D 0x1C) || (ModelId =3D=3D 0x26) || (ModelId =3D=3D = 0x27) || (ModelId =3D=3D 0x35) || (ModelId =3D=3D 0x36)) { + ASSERT (!FeaturePcdGet (PcdSmrrEnable)); + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Fam= ily + // + // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2 + // Processor Family MSRs + // + if (FamilyId =3D=3D 0x06) { + if ((ModelId =3D=3D 0x17) || (ModelId =3D=3D 0x0f)) { + mSmrrPhysBaseMsr =3D SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE; + mSmrrPhysMaskMsr =3D SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK; + } + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 34.4.2 SMRAM Caching + // An IA-32 processor does not automatically write back and invalidate= its + // caches before entering SMM or before exiting SMM. Because of this b= ehavior, + // care must be taken in the placement of the SMRAM in system memory a= nd in + // the caching of the SMRAM to prevent cache incoherence when switchin= g back + // and forth between SMM and protected mode operation. + // + // An IA-32 processor is a processor that does not support the Intel 64 + // Architecture. Support for the Intel 64 Architecture can be detected = from + // CPUID(CPUID_EXTENDED_CPU_SIG).EDX[29] + // + // If an IA-32 processor is detected, then set mNeedConfigureMtrrs to TR= UE, + // so caches are flushed on SMI entry and SMI exit, the interrupted code + // MTRRs are saved/restored, and MTRRs for SMM are loaded. + // + AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); + if (RegEax >=3D CPUID_EXTENDED_CPU_SIG) { + AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); + if ((RegEdx & BIT29) !=3D 0) { + mNeedConfigureMtrrs =3D FALSE; + } + } + + // + // Allocate array for state of SMRR enable on all CPUs + // + mSmrrEnabled =3D (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLo= gicalProcessorNumber ()); + ASSERT (mSmrrEnabled !=3D NULL); +} + +/** + Called during the very first SMI into System Management Mode to initiali= ze + CPU features, including SMBASE, for the currently executing CPU. Since = this + is the first SMI, the SMRAM Save State Map is at the default address of + SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executi= ng + CPU is specified by CpuIndex and CpuIndex can be used to access informat= ion + about the currently executing CPU in the ProcessorInfo array and the + HotPlugCpuData data structure. + + @param[in] CpuIndex The index of the CPU to initialize. The valu= e + must be between 0 and the NumberOfCpus field = in + the System Management System Table (SMST). + @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU = that + was elected as monarch during System Manageme= nt + Mode initialization. + FALSE if the CpuIndex is not the index of the= CPU + that was elected as monarch during System + Management Mode initialization. + @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMAT= ION + structures. ProcessorInfo[CpuIndex] contains= the + information for the currently executing CPU. + @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure th= at + contains the ApidId and SmBase arrays. +**/ +VOID +EFIAPI +SmmCpuFeaturesInitializeProcessor ( + IN UINTN CpuIndex, + IN BOOLEAN IsMonarch, + IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, + IN CPU_HOT_PLUG_DATA *CpuHotPlugData + ) +{ + SMRAM_SAVE_STATE_MAP *CpuState; + UINT64 FeatureControl; + UINT32 RegEax; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + + // + // Configure SMBASE. + // + CpuState =3D (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMB= ASE + SMRAM_SAVE_STATE_MAP_OFFSET); + CpuState->x86.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Fam= ily + // + // If Intel(R) Core(TM) Core(TM) 2 Processor Family MSRs are being used,= then + // make sure SMRR Enable(BIT3) of MSR_FEATURE_CONTROL MSR(0x3A) is set b= efore + // accessing SMRR base/mask MSRs. If Lock(BIT0) of MSR_FEATURE_CONTROL = MSR(0x3A) + // is set, then the MSR is locked and can not be modified. + // + if ((FeaturePcdGet (PcdSmrrEnable)) && (mSmrrPhysBaseMsr =3D=3D SMM_FEAT= URES_LIB_IA32_CORE_SMRR_PHYSBASE)) { + FeatureControl =3D AsmReadMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL= ); + if ((FeatureControl & BIT3) =3D=3D 0) { + ASSERT ((FeatureControl & BIT0) =3D=3D 0); + if ((FeatureControl & BIT0) =3D=3D 0) { + AsmWriteMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL, FeatureContr= ol | BIT3); + } + } + } + + // + // If SMRR is supported, then program SMRR base/mask MSRs. + // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first norma= l SMI. + // The code that initializes SMM environment is running in normal mode + // from SMRAM region. If SMRR is enabled here, then the SMRAM region + // is protected and the normal mode code execution will fail. + // + if (FeaturePcdGet (PcdSmrrEnable)) { + // + // SMRR size cannot be less than 4-KBytes + // SMRR size must be of length 2^n + // SMRR base alignment cannot be less than SMRR length + // + if ((CpuHotPlugData->SmrrSize < SIZE_4KB) || + (CpuHotPlugData->SmrrSize !=3D GetPowerOfTwo32 (CpuHotPlugData->Sm= rrSize)) || + ((CpuHotPlugData->SmrrBase & ~(CpuHotPlugData->SmrrSize - 1)) !=3D= CpuHotPlugData->SmrrBase)) + { + // + // Print message and halt if CPU is Monarch + // + if (IsMonarch) { + DEBUG ((DEBUG_ERROR, "SMM Base/Size does not meet alignment/size r= equirement!\n")); + CpuDeadLoop (); + } + } else { + AsmWriteMsr64 (mSmrrPhysBaseMsr, CpuHotPlugData->SmrrBase | MTRR_CAC= HE_WRITE_BACK); + AsmWriteMsr64 (mSmrrPhysMaskMsr, (~(CpuHotPlugData->SmrrSize - 1) & = EFI_MSR_SMRR_MASK)); + mSmrrEnabled[CpuIndex] =3D FALSE; + } + } + + // + // Retrieve CPU Family and Model + // + AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); + FamilyId =3D (RegEax >> 8) & 0xf; + ModelId =3D (RegEax >> 4) & 0xf; + if ((FamilyId =3D=3D 0x06) || (FamilyId =3D=3D 0x0f)) { + ModelId =3D ModelId | ((RegEax >> 12) & 0xf0); + } + + // + // Intel(R) 64 and IA-32 Architectures Software Developer's Manual + // Volume 3C, Section 35.10.1 MSRs in 4th Generation Intel(R) Core(TM) + // Processor Family. + // + // If CPU Family/Model is 06_3C, 06_45, or 06_46 then use 4th Generation + // Intel(R) Core(TM) Processor Family MSRs. + // + if (FamilyId =3D=3D 0x06) { + if ((ModelId =3D=3D 0x3C) || (ModelId =3D=3D 0x45) || (ModelId =3D=3D = 0x46) || + (ModelId =3D=3D 0x3D) || (ModelId =3D=3D 0x47) || (ModelId =3D=3D = 0x4E) || (ModelId =3D=3D 0x4F) || + (ModelId =3D=3D 0x3F) || (ModelId =3D=3D 0x56) || (ModelId =3D=3D = 0x57) || (ModelId =3D=3D 0x5C) || + (ModelId =3D=3D 0x8C)) + { + // + // Check to see if the CPU supports the SMM Code Access Check featur= e + // Do not access this MSR unless the CPU supports the SmmRegFeatureC= ontrol + // + if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MCA_CAP) & SMM_CODE_ACCESS_= CHK_BIT) !=3D 0) { + ASSERT (FeaturePcdGet (PcdSmmFeatureControlEnable)); + } + } + } + + // + // Call internal worker function that completes the CPU initialization + // + FinishSmmCpuFeaturesInitializeProcessor (); +} + +/** + Determines if MTRR registers must be configured to set SMRAM cache-abili= ty + when executing in System Management Mode. + + @retval TRUE MTRR registers must be configured to set SMRAM cache-abil= ity. + @retval FALSE MTRR registers do not need to be configured to set SMRAM + cache-ability. +**/ +BOOLEAN +EFIAPI +SmmCpuFeaturesNeedConfigureMtrrs ( + VOID + ) +{ + return mNeedConfigureMtrrs; +} + +/** + Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigu= reMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesDisableSmrr ( + VOID + ) +{ + if (FeaturePcdGet (PcdSmrrEnable) && mNeedConfigureMtrrs) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) & ~EF= I_MSR_SMRR_PHYS_MASK_VALID); + } +} + +/** + Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigur= eMtrrs() + returns TRUE. +**/ +VOID +EFIAPI +SmmCpuFeaturesReenableSmrr ( + VOID + ) +{ + if (FeaturePcdGet (PcdSmrrEnable) && mNeedConfigureMtrrs) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI= _MSR_SMRR_PHYS_MASK_VALID); + } +} + +/** + Processor specific hook point each time a CPU enters System Management M= ode. + + @param[in] CpuIndex The index of the CPU that has entered SMM. The val= ue + must be between 0 and the NumberOfCpus field in the + System Management System Table (SMST). +**/ +VOID +EFIAPI +SmmCpuFeaturesRendezvousEntry ( + IN UINTN CpuIndex + ) +{ + // + // If SMRR is supported and this is the first normal SMI, then enable SM= RR + // + if (FeaturePcdGet (PcdSmrrEnable) && !mSmrrEnabled[CpuIndex]) { + AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI= _MSR_SMRR_PHYS_MASK_VALID); + mSmrrEnabled[CpuIndex] =3D TRUE; + } +} + +/** + Returns the current value of the SMM register for the specified CPU. + If the SMM register is not supported, then 0 is returned. + + @param[in] CpuIndex The index of the CPU to read the SMM register. 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 read. + + @return The value of the SMM register specified by RegName from the CPU + specified by CpuIndex. +**/ +UINT64 +EFIAPI +SmmCpuFeaturesGetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName + ) +{ + if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { + return AsmReadMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL); + } + + return 0; +} + +/** + Sets the value of an SMM register on a specified CPU. + If the SMM register is not supported, then no action is performed. + + @param[in] CpuIndex The index of the CPU to write the SMM register. Th= e + value must be between 0 and the NumberOfCpus field = in + the System Management System Table (SMST). + @param[in] RegName Identifies the SMM register to write. + registers are read-only. + @param[in] Value The value to write to the SMM register. +**/ +VOID +EFIAPI +SmmCpuFeaturesSetSmmRegister ( + IN UINTN CpuIndex, + IN SMM_REG_NAME RegName, + IN UINT64 Value + ) +{ + if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { + AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value); + } +} + diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c= b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c index 75a0ec8e948..7777e52740e 100644 --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c @@ -14,278 +14,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include -#include -#include "CpuFeaturesLib.h" - -// -// Machine Specific Registers (MSRs) -// -#define SMM_FEATURES_LIB_IA32_MTRR_CAP 0x0FE -#define SMM_FEATURES_LIB_IA32_FEATURE_CONTROL 0x03A -#define SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE 0x1F2 -#define SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK 0x1F3 -#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE 0x0A0 -#define SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK 0x0A1 -#define EFI_MSR_SMRR_MASK 0xFFFFF000 -#define EFI_MSR_SMRR_PHYS_MASK_VALID BIT11 -#define SMM_FEATURES_LIB_SMM_FEATURE_CONTROL 0x4E0 - -// -// MSRs required for configuration of SMM Code Access Check -// -#define SMM_FEATURES_LIB_IA32_MCA_CAP 0x17D -#define SMM_CODE_ACCESS_CHK_BIT BIT58 - -// -// Set default value to assume IA-32 Architectural MSRs are used -// -UINT32 mSmrrPhysBaseMsr =3D SMM_FEATURES_LIB_IA32_SMRR_PHYSBASE; -UINT32 mSmrrPhysMaskMsr =3D SMM_FEATURES_LIB_IA32_SMRR_PHYSMASK; - -// -// Set default value to assume MTRRs need to be configured on each SMI -// -BOOLEAN mNeedConfigureMtrrs =3D TRUE; - -// -// Array for state of SMRR enable on all CPUs -// -BOOLEAN *mSmrrEnabled; - -/** - Performs library initialization. - - This initialization function contains common functionality shared betwen= all - library instance constructors. - -**/ -VOID -CpuFeaturesLibInitialization ( - VOID - ) -{ - UINT32 RegEax; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - - // - // Retrieve CPU Family and Model - // - AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); - FamilyId =3D (RegEax >> 8) & 0xf; - ModelId =3D (RegEax >> 4) & 0xf; - if ((FamilyId =3D=3D 0x06) || (FamilyId =3D=3D 0x0f)) { - ModelId =3D ModelId | ((RegEax >> 12) & 0xf0); - } - - // - // Check CPUID(CPUID_VERSION_INFO).EDX[12] for MTRR capability - // - if ((RegEdx & BIT12) !=3D 0) { - // - // Check MTRR_CAP MSR bit 11 for SMRR support - // - if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MTRR_CAP) & BIT11) !=3D 0) { - ASSERT (FeaturePcdGet (PcdSmrrEnable)); - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.3 MSRs in the Intel(R) Atom(TM) Processor Famil= y - // - // If CPU Family/Model is 06_1CH, 06_26H, 06_27H, 06_35H or 06_36H, then - // SMRR Physical Base and SMM Physical Mask MSRs are not available. - // - if (FamilyId =3D=3D 0x06) { - if ((ModelId =3D=3D 0x1C) || (ModelId =3D=3D 0x26) || (ModelId =3D=3D = 0x27) || (ModelId =3D=3D 0x35) || (ModelId =3D=3D 0x36)) { - ASSERT (!FeaturePcdGet (PcdSmrrEnable)); - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Fam= ily - // - // If CPU Family/Model is 06_0F or 06_17, then use Intel(R) Core(TM) 2 - // Processor Family MSRs - // - if (FamilyId =3D=3D 0x06) { - if ((ModelId =3D=3D 0x17) || (ModelId =3D=3D 0x0f)) { - mSmrrPhysBaseMsr =3D SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSBASE; - mSmrrPhysMaskMsr =3D SMM_FEATURES_LIB_IA32_CORE_SMRR_PHYSMASK; - } - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 34.4.2 SMRAM Caching - // An IA-32 processor does not automatically write back and invalidate= its - // caches before entering SMM or before exiting SMM. Because of this b= ehavior, - // care must be taken in the placement of the SMRAM in system memory a= nd in - // the caching of the SMRAM to prevent cache incoherence when switchin= g back - // and forth between SMM and protected mode operation. - // - // An IA-32 processor is a processor that does not support the Intel 64 - // Architecture. Support for the Intel 64 Architecture can be detected = from - // CPUID(CPUID_EXTENDED_CPU_SIG).EDX[29] - // - // If an IA-32 processor is detected, then set mNeedConfigureMtrrs to TR= UE, - // so caches are flushed on SMI entry and SMI exit, the interrupted code - // MTRRs are saved/restored, and MTRRs for SMM are loaded. - // - AsmCpuid (CPUID_EXTENDED_FUNCTION, &RegEax, NULL, NULL, NULL); - if (RegEax >=3D CPUID_EXTENDED_CPU_SIG) { - AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &RegEdx); - if ((RegEdx & BIT29) !=3D 0) { - mNeedConfigureMtrrs =3D FALSE; - } - } - - // - // Allocate array for state of SMRR enable on all CPUs - // - mSmrrEnabled =3D (BOOLEAN *)AllocatePool (sizeof (BOOLEAN) * GetCpuMaxLo= gicalProcessorNumber ()); - ASSERT (mSmrrEnabled !=3D NULL); -} - -/** - Called during the very first SMI into System Management Mode to initiali= ze - CPU features, including SMBASE, for the currently executing CPU. Since = this - is the first SMI, the SMRAM Save State Map is at the default address of - SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET. The currently executi= ng - CPU is specified by CpuIndex and CpuIndex can be used to access informat= ion - about the currently executing CPU in the ProcessorInfo array and the - HotPlugCpuData data structure. - - @param[in] CpuIndex The index of the CPU to initialize. The valu= e - must be between 0 and the NumberOfCpus field = in - the System Management System Table (SMST). - @param[in] IsMonarch TRUE if the CpuIndex is the index of the CPU = that - was elected as monarch during System Manageme= nt - Mode initialization. - FALSE if the CpuIndex is not the index of the= CPU - that was elected as monarch during System - Management Mode initialization. - @param[in] ProcessorInfo Pointer to an array of EFI_PROCESSOR_INFORMAT= ION - structures. ProcessorInfo[CpuIndex] contains= the - information for the currently executing CPU. - @param[in] CpuHotPlugData Pointer to the CPU_HOT_PLUG_DATA structure th= at - contains the ApidId and SmBase arrays. -**/ -VOID -EFIAPI -SmmCpuFeaturesInitializeProcessor ( - IN UINTN CpuIndex, - IN BOOLEAN IsMonarch, - IN EFI_PROCESSOR_INFORMATION *ProcessorInfo, - IN CPU_HOT_PLUG_DATA *CpuHotPlugData - ) -{ - SMRAM_SAVE_STATE_MAP *CpuState; - UINT64 FeatureControl; - UINT32 RegEax; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - - // - // Configure SMBASE. - // - CpuState =3D (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMB= ASE + SMRAM_SAVE_STATE_MAP_OFFSET); - CpuState->x86.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.2 MSRs in the Intel(R) Core(TM) 2 Processor Fam= ily - // - // If Intel(R) Core(TM) Core(TM) 2 Processor Family MSRs are being used,= then - // make sure SMRR Enable(BIT3) of MSR_FEATURE_CONTROL MSR(0x3A) is set b= efore - // accessing SMRR base/mask MSRs. If Lock(BIT0) of MSR_FEATURE_CONTROL = MSR(0x3A) - // is set, then the MSR is locked and can not be modified. - // - if ((FeaturePcdGet (PcdSmrrEnable)) && (mSmrrPhysBaseMsr =3D=3D SMM_FEAT= URES_LIB_IA32_CORE_SMRR_PHYSBASE)) { - FeatureControl =3D AsmReadMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL= ); - if ((FeatureControl & BIT3) =3D=3D 0) { - ASSERT ((FeatureControl & BIT0) =3D=3D 0); - if ((FeatureControl & BIT0) =3D=3D 0) { - AsmWriteMsr64 (SMM_FEATURES_LIB_IA32_FEATURE_CONTROL, FeatureContr= ol | BIT3); - } - } - } - // - // If SMRR is supported, then program SMRR base/mask MSRs. - // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first norma= l SMI. - // The code that initializes SMM environment is running in normal mode - // from SMRAM region. If SMRR is enabled here, then the SMRAM region - // is protected and the normal mode code execution will fail. - // - if (FeaturePcdGet (PcdSmrrEnable)) { - // - // SMRR size cannot be less than 4-KBytes - // SMRR size must be of length 2^n - // SMRR base alignment cannot be less than SMRR length - // - if ((CpuHotPlugData->SmrrSize < SIZE_4KB) || - (CpuHotPlugData->SmrrSize !=3D GetPowerOfTwo32 (CpuHotPlugData->Sm= rrSize)) || - ((CpuHotPlugData->SmrrBase & ~(CpuHotPlugData->SmrrSize - 1)) !=3D= CpuHotPlugData->SmrrBase)) - { - // - // Print message and halt if CPU is Monarch - // - if (IsMonarch) { - DEBUG ((DEBUG_ERROR, "SMM Base/Size does not meet alignment/size r= equirement!\n")); - CpuDeadLoop (); - } - } else { - AsmWriteMsr64 (mSmrrPhysBaseMsr, CpuHotPlugData->SmrrBase | MTRR_CAC= HE_WRITE_BACK); - AsmWriteMsr64 (mSmrrPhysMaskMsr, (~(CpuHotPlugData->SmrrSize - 1) & = EFI_MSR_SMRR_MASK)); - mSmrrEnabled[CpuIndex] =3D FALSE; - } - } - - // - // Retrieve CPU Family and Model - // - AsmCpuid (CPUID_VERSION_INFO, &RegEax, NULL, NULL, &RegEdx); - FamilyId =3D (RegEax >> 8) & 0xf; - ModelId =3D (RegEax >> 4) & 0xf; - if ((FamilyId =3D=3D 0x06) || (FamilyId =3D=3D 0x0f)) { - ModelId =3D ModelId | ((RegEax >> 12) & 0xf0); - } - - // - // Intel(R) 64 and IA-32 Architectures Software Developer's Manual - // Volume 3C, Section 35.10.1 MSRs in 4th Generation Intel(R) Core(TM) - // Processor Family. - // - // If CPU Family/Model is 06_3C, 06_45, or 06_46 then use 4th Generation - // Intel(R) Core(TM) Processor Family MSRs. - // - if (FamilyId =3D=3D 0x06) { - if ((ModelId =3D=3D 0x3C) || (ModelId =3D=3D 0x45) || (ModelId =3D=3D = 0x46) || - (ModelId =3D=3D 0x3D) || (ModelId =3D=3D 0x47) || (ModelId =3D=3D = 0x4E) || (ModelId =3D=3D 0x4F) || - (ModelId =3D=3D 0x3F) || (ModelId =3D=3D 0x56) || (ModelId =3D=3D = 0x57) || (ModelId =3D=3D 0x5C) || - (ModelId =3D=3D 0x8C)) - { - // - // Check to see if the CPU supports the SMM Code Access Check featur= e - // Do not access this MSR unless the CPU supports the SmmRegFeatureC= ontrol - // - if ((AsmReadMsr64 (SMM_FEATURES_LIB_IA32_MCA_CAP) & SMM_CODE_ACCESS_= CHK_BIT) !=3D 0) { - ASSERT (FeaturePcdGet (PcdSmmFeatureControlEnable)); - } - } - } - - // - // Call internal worker function that completes the CPU initialization - // - FinishSmmCpuFeaturesInitializeProcessor (); -} +#include "CpuFeaturesLib.h" /** This function updates the SMRAM save state on the currently executing CP= U @@ -345,75 +75,6 @@ SmmCpuFeaturesSmmRelocationComplete ( { } -/** - Determines if MTRR registers must be configured to set SMRAM cache-abili= ty - when executing in System Management Mode. - - @retval TRUE MTRR registers must be configured to set SMRAM cache-abil= ity. - @retval FALSE MTRR registers do not need to be configured to set SMRAM - cache-ability. -**/ -BOOLEAN -EFIAPI -SmmCpuFeaturesNeedConfigureMtrrs ( - VOID - ) -{ - return mNeedConfigureMtrrs; -} - -/** - Disable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigu= reMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesDisableSmrr ( - VOID - ) -{ - if (FeaturePcdGet (PcdSmrrEnable) && mNeedConfigureMtrrs) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) & ~EF= I_MSR_SMRR_PHYS_MASK_VALID); - } -} - -/** - Enable SMRR register if SMRR is supported and SmmCpuFeaturesNeedConfigur= eMtrrs() - returns TRUE. -**/ -VOID -EFIAPI -SmmCpuFeaturesReenableSmrr ( - VOID - ) -{ - if (FeaturePcdGet (PcdSmrrEnable) && mNeedConfigureMtrrs) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI= _MSR_SMRR_PHYS_MASK_VALID); - } -} - -/** - Processor specific hook point each time a CPU enters System Management M= ode. - - @param[in] CpuIndex The index of the CPU that has entered SMM. The val= ue - must be between 0 and the NumberOfCpus field in the - System Management System Table (SMST). -**/ -VOID -EFIAPI -SmmCpuFeaturesRendezvousEntry ( - IN UINTN CpuIndex - ) -{ - // - // If SMRR is supported and this is the first normal SMI, then enable SM= RR - // - if (FeaturePcdGet (PcdSmrrEnable) && !mSmrrEnabled[CpuIndex]) { - AsmWriteMsr64 (mSmrrPhysMaskMsr, AsmReadMsr64 (mSmrrPhysMaskMsr) | EFI= _MSR_SMRR_PHYS_MASK_VALID); - mSmrrEnabled[CpuIndex] =3D TRUE; - } -} - /** Processor specific hook point each time a CPU exits System Management Mo= de. @@ -456,56 +117,6 @@ SmmCpuFeaturesIsSmmRegisterSupported ( 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. - - @param[in] CpuIndex The index of the CPU to read the SMM register. 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 read. - - @return The value of the SMM register specified by RegName from the CPU - specified by CpuIndex. -**/ -UINT64 -EFIAPI -SmmCpuFeaturesGetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName - ) -{ - if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { - return AsmReadMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL); - } - - return 0; -} - -/** - Sets the value of an SMM register on a specified CPU. - If the SMM register is not supported, then no action is performed. - - @param[in] CpuIndex The index of the CPU to write the SMM register. Th= e - value must be between 0 and the NumberOfCpus field = in - the System Management System Table (SMST). - @param[in] RegName Identifies the SMM register to write. - registers are read-only. - @param[in] Value The value to write to the SMM register. -**/ -VOID -EFIAPI -SmmCpuFeaturesSetSmmRegister ( - IN UINTN CpuIndex, - IN SMM_REG_NAME RegName, - IN UINT64 Value - ) -{ - if (FeaturePcdGet (PcdSmmFeatureControlEnable) && (RegName =3D=3D SmmReg= FeatureControl)) { - AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value); - } -} - /** Read an SMM Save State register on the target processor. If this functi= on returns EFI_UNSUPPORTED, then the caller is responsible for reading the -- 2.37.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#94568): https://nam11.safelinks.protection.outlook.com/= ?url=3Dhttps%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Fmessage%2F94568&data= =3D05%7C01%7Cabner.chang%40amd.com%7C35230bb798f04e2c9f4108daa2c98ebb%7C3dd= 8961fe4884e608e11a82d994e183d%7C0%7C0%7C638001283822981371%7CUnknown%7CTWFp= bGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%= 7C3000%7C%7C%7C&sdata=3DSavK8Hd8gcaNZb%2B936BKS1FrR9sFTBqUolnnPm3G5Nc%3= D&reserved=3D0 Mute This Topic: https://nam11.safelinks.protection.outlook.com/?url=3Dhttp= s%3A%2F%2Fgroups.io%2Fmt%2F94013090%2F7039027&data=3D05%7C01%7Cabner.ch= ang%40amd.com%7C35230bb798f04e2c9f4108daa2c98ebb%7C3dd8961fe4884e608e11a82d= 994e183d%7C0%7C0%7C638001283822981371%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wL= jAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&s= data=3DhZ8DVHRBl4F%2FWXxrUbBuRaLHUnmTOPGM8FnBJW1Mq0M%3D&reserved=3D0 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://nam11.safelinks.protection.outlook.com/?url=3Dhttps%3A= %2F%2Fedk2.groups.io%2Fg%2Fdevel%2Funsub&data=3D05%7C01%7Cabner.chang%4= 0amd.com%7C35230bb798f04e2c9f4108daa2c98ebb%7C3dd8961fe4884e608e11a82d994e1= 83d%7C0%7C0%7C638001283823137634%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMD= AiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata= =3DefUfZi%2BTunz9zd1%2BLMfOdze7N2ld00mfpaa0X%2BZWURQ%3D&reserved=3D0 [a= bner.chang@amd.com] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_004_MN2PR12MB3966CA8A6B9D37E44BA1912FEA2B9MN2PR12MB3966namp_--