From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.70]) by mx.groups.io with SMTP id smtpd.web10.36521.1681093974167227189 for ; Sun, 09 Apr 2023 19:32:54 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=Eoj1Ellb; 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.94.70, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bk5oFJznalDqmyUDQV3JQYojB/lzLNmd3sZ8HTua2+7rkEOqx0bXndFaxxeviS2FDIkFjBaJYW/l2+sdODRjGXo5VLf45lwVunq2w+svbkbJx2MW+8EW/FTBg+kdawIse3r3jdKg4iSSrDN+3CD4GN7GcpmlMorjveMa6f2TucG6dJgWMZ9FdAHb0X96knIUR2hRnIUl+Py42oOaUMgYcc32G89V98pZYYYUpudycrP2+vCuhljTFecHcX7BDAFcOuDlVSWlpXnla2EecWZsg5L1/YTd3S0MWHPVOLR8tyBTtc/GWBEsJyLTeCPyWEn+x0Euqw1XH2bJti7i9+gmCw== 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=xwCmAFmyPx5c4ODyAY+epgyMiI1QSqeF1Yb3p3iYXWU=; b=mSkNL6Xc0VQvr+QdFjX2S3V1gf8Ho/hoRrtRZT67bcXRFoh+T5n/d2dPwJd0cMOlMMS5eQk/cN25Ed8qNHFgjNEz+ufb4L4xo5cpup9UY2VoDYqACH1gMzcDc1l9/32pjT6L0GRod/ry1Weh/4nfMF9fGAknvX2OrqByBurrzNGi0nBIG3RSI0X/Xs2UWTmEVIKcC5YDD72lit/yj4piNUG96zeLdTKYUASdhZIRDYMDQfVEK2JMBCKPqpQ/87PiEj9cAKKYLtgj9FhKZzAvA7JhT846fajj93fPzLQ0XtiRzz2JS7lwDCma1DaWuWddSW0xJGm7Jn1xFss5vLRJAg== 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=xwCmAFmyPx5c4ODyAY+epgyMiI1QSqeF1Yb3p3iYXWU=; b=Eoj1Ellb2Oeu29CTcBneaKkgRQR/vSVNaCERvbC/Xr536YzjrKXu9jIlGTiwhXmmv55a+gXcRFLMFbdNlgoWAP1ik/e5vbCsHoKLKjz416tpzpviz8aKxRtOfQQk4I+qf81Db2vE0c7VIcKVJH/Ssz/GKOV4HBr/H408oRcJSd8= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by PH8PR12MB7351.namprd12.prod.outlook.com (2603:10b6:510:215::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Mon, 10 Apr 2023 02:32:51 +0000 Received: from MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::30f:bd83:40dd:8f1]) by MN2PR12MB3966.namprd12.prod.outlook.com ([fe80::30f:bd83:40dd:8f1%3]) with mapi id 15.20.6277.036; Mon, 10 Apr 2023 02:32:51 +0000 From: "Chang, Abner" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" , Ard Biesheuvel , Leif Lindholm , Michael D Kinney Subject: Re: [PATCH v4 2/3] Platform/AMD/MinBoardPkg: Adds SetCacheMtrrLib library Thread-Topic: [PATCH v4 2/3] Platform/AMD/MinBoardPkg: Adds SetCacheMtrrLib library Thread-Index: AQHZZh61NE+EQkQYGECPYs/B95U4FK8j3T0Q Date: Mon, 10 Apr 2023 02:32:51 +0000 Message-ID: References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-04-10T02:32:49Z; 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=d89173f0-7ce7-49b6-a5c8-fc5023fcd424; 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_|PH8PR12MB7351:EE_ x-ms-office365-filtering-correlation-id: 817458e1-1b75-4ad3-c9a8-08db396be1d5 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DpOd2077o1szED4+tvPJXLQ9M0tkTWKSzbnTQvZySOKykE/hWIoaVhDGxF5zhuX/WYbX6Ol0YIVYOcMYlwkWBLZOIA5dsAEv3IBcs+7HoKAtxcQnqut3gLXvs2zGMRxszCfBW6g2by6tyTUWaAQ0xfH83l/mhHCIShqXqeGCZlNci58zmKg2yTkjl5zSTVTZ/MuaPNIltq8DYiLpKvhnpLseFtjIJ2QO1aivlKaw3OTZHJtxE8yk5D7cNG7l4RXvHIMG+9HdoGLZ/aPwxaGM3eXgxSXv1VeIcdlHC+lHePCh9rf7/Fz5nRsko+gRxIalDurupHXwxxpkCHLdTx0zddIObJjIt9DkbfIY4MXYGtxHtN2klZcmxrjMdxB9RnaPKf/HzEeD1KOSjzGTxvBrgHrX8JXHEtngRuzqaxjU9FrkSlOyw9+FlR94SQ7je7t+dHPiw5MOFZYx7vwue0cHplBhnxXKL597i4QcT8izMI6oSKkeVPJaB5xN80UtcOKDiWXolc2eMlmW+98HffuycIc6XIyDfF/guJ0W9BHEFET3+RbmHaDUTrB2Lwp+HAH52al7VUuPQfumLZTjBGqI1M6hZvAtw8KDe2EPYmr4fdXR7/vb1On7mS8XYzhGsF5c 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:(13230028)(4636009)(366004)(136003)(396003)(346002)(39860400002)(376002)(451199021)(478600001)(7696005)(71200400001)(54906003)(110136005)(316002)(53546011)(9686003)(6506007)(26005)(186003)(2906002)(4326008)(76116006)(66946007)(66556008)(66476007)(66446008)(64756008)(8676002)(41300700001)(8936002)(5660300002)(52536014)(38070700005)(122000001)(38100700002)(86362001)(55016003)(33656002)(83380400001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?50K6A/qcnqK1Ux9m3kmLvIF57U3Zp7RR7nni1qQa+eCnLQcBU4nvCFyks1rX?= =?us-ascii?Q?glyneoAYj7Z0+IR3/ZfbMmpdzIgaFweFRMu6e5euTDFMk6ClnMcipbabVsOn?= =?us-ascii?Q?O21NMuCvXbSzH+yR98P4nobKu5yh3FtYzLpYCsVFBBs4+2UsNL9QtN6vfUuh?= =?us-ascii?Q?P25axzHDwjbOzhEfTaZ0ApY0nacYXvHNpIbhXjuAJNciaOBiZ2gqcOjnuK3G?= =?us-ascii?Q?laOhKtZwapHbWz9EnaLE4Xqqu2IVURkWXai1bwjXeToftTsQLmJk/icaNJ/i?= =?us-ascii?Q?r5t+otbf6h/UInbPE8Y246GVpbg/0okGjBf2s/zmm7zqtzPzT7aZDexFQGKO?= =?us-ascii?Q?U/mkxW6AIL9FI8KZt8EK143I8AWYSc2Uy0LJPLoS7NZJNGqFAfJUxK/q93a/?= =?us-ascii?Q?PYRD7wdZRru931HWu04OCx5e4VB93a8pjwBPq2B1vJP4Ikuu3pJ6SJVTvHUM?= =?us-ascii?Q?qVkVmz8aQ0RVu9nU0fFReeN1a9Ip7GuuRYFkE7ndOF8JebkJ+2er79JLzy21?= =?us-ascii?Q?ckghZYYx7NmNC7jLCl6P1zGAQeMqH1pAOUS6GAOdYCBlEVJqPutWWvZxDXt1?= =?us-ascii?Q?PobJPxErobNYn9qJjC8BA625mnPO00XQuAnlW+P/UDo4WgEKv5lzM0KpgdTE?= =?us-ascii?Q?7gM58CjOaKX0kkeqNvRfquYwKAU22SyeKKRdSat+DrxEilRgRixI6biUmMMd?= =?us-ascii?Q?2ILEA28Ij1O8dn8c7flG6QVbMt0ORQS38s3BXkL11Yp93oQdOjW+81xfjA2k?= =?us-ascii?Q?dAzLG7doMtrI3qk8WbcgU3wyVaGP89ib19czMqmkfmzphb4j5d7AGhCVuIEK?= =?us-ascii?Q?TbmryqBM64cbgtv//Lx29kSiQ48Ov1xAdTwvHnSvapqF/vZcmz423Y5VT4Gc?= =?us-ascii?Q?m7pRP3a4PmNqXvoBT+L1gTaQmY1b0qyzQXxzclxo6svqm5qmMunalGjO21XH?= =?us-ascii?Q?wPdGyAwjgVpX9re3A9AfLc+qK+x7whDkNrvp/u5NinLGTTWPyWTFoPIq9Wyf?= =?us-ascii?Q?2+w74AziASPZFm5ZxCERcguji3HAU2U2QFtKnchxMGDGgeKwrZKJ8Uq3hzIn?= =?us-ascii?Q?mTLUKwSNjxbFd2X1pSysoSCuDVfMr591mpMZLNe/AmEyKCaYcp99woSnuc78?= =?us-ascii?Q?vyP1LtUoQ+Id70cdnaf71veqoQUQNTBs++vJX2E3Zq1SS81cFVd0QzNvoOMs?= =?us-ascii?Q?LJ3/8MRxXMnSsEN46Y4NUZMU3li3HUbmFzpHKhqz3QGPNFIRfJGTF+u+dsA8?= =?us-ascii?Q?w3MIJ2w0J73a0iNr4HzhYi+uu1ocirPiISGIiFx8b14RwrShW+XVvzZ6hIhL?= =?us-ascii?Q?gz9eTfLWdDIRAUJ2MmYh8mlrYFJzalAjVSQO8+DwrhEUMpKo2a7p5wlIiY4B?= =?us-ascii?Q?dKgSR2TiDNueZM3EO7z2EnkxnHSAnSBepo5Kbj3H7DA3ITj8I/C0xCDeYQ/X?= =?us-ascii?Q?vWFDfexhcmuoEuACL20P41edRVAVBTyNbL/zq/cl3HnSZgVhqRsoQMWKurJf?= =?us-ascii?Q?y52nWw/MLyCIWvvyET+qRxZkVNDFZR6VN6zITIB+223haOSilAycL8XXIRse?= =?us-ascii?Q?6KNC3Cpf0Oe0cHsUc4E=3D?= 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: 817458e1-1b75-4ad3-c9a8-08db396be1d5 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2023 02:32:51.5639 (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: pg0ke0+DAO8o2hA7SAmG74i82dnVhStR1CXAFY52D0bVSYAX+WyFGd8WFERvvi8PsP4RWCW58+iCulTtfo52TA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7351 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Reviewed-by: Abner Chang > -----Original Message----- > From: Abdul Lateef Attar > Sent: Monday, April 3, 2023 7:23 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Ard > Biesheuvel ; Leif Lindholm > ; Chang, Abner ; > Michael D Kinney > Subject: [PATCH v4 2/3] Platform/AMD/MinBoardPkg: Adds SetCacheMtrrLib > library >=20 > Adds SetCacheMtrrLib library for AmdMinBoardPkg, which sets MTRR values > for PEI phase and also modifies the MTRR value at the end of PEI phase. >=20 > Signed-off-by: Abdul Lateef Attar > Cc: Ard Biesheuvel > Cc: Leif Lindholm > Cc: Abner Chang > Cc: Michael D Kinney > --- > .../AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc | 9 ++ > .../SetCacheMtrrLib/SetCacheMtrrLib.inf | 35 +++++ > .../Library/SetCacheMtrrLib/SetCacheMtrrLib.c | 133 ++++++++++++++++++ > 3 files changed, 177 insertions(+) > create mode 100644 > Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib > .inf > create mode 100644 > Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib > .c >=20 > diff --git a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > index 74992a9a6b8c..2f17db5df5fb 100644 > --- a/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > +++ b/Platform/AMD/AmdMinBoardPkg/AmdMinBoardPkg.dsc > @@ -18,4 +18,13 @@ [Defines] >=20 > [Packages] > AmdMinBoardPkg/AmdMinBoardPkg.dec > + MdePkg/MdePkg.dec > + MinPlatformPkg/MinPlatformPkg.dec > + UefiCpuPkg/UefiCpuPkg.dec > + > +[LibraryClasses.common.PEIM] > + > +SetCacheMtrrLib|AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtr > rLib. > +inf > + > +[Components.IA32] > + AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrrLib.inf >=20 > diff --git > a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Lib.inf > b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Lib.inf > new file mode 100644 > index 000000000000..b4c4b3e7de14 > --- /dev/null > +++ > b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Li > +++ b.inf > @@ -0,0 +1,35 @@ > +## @file > +# Component information file for Platform SetCacheMtrr Library. > +# This library implementation is for AMD processor based platforms. > +# > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # ## > + > +[Defines] > + INF_VERSION =3D 1.29 > + BASE_NAME =3D PeiSetCacheMtrrLib > + FILE_GUID =3D 1E8468E0-5EB4-4088-9B52-BFDC6E4DAE8= 7 > + MODULE_TYPE =3D PEIM > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D SetCacheMtrrLib > + > +[LibraryClasses] > + BaseLib > + DebugLib > + MtrrLib > + > +[Packages] > + MdePkg/MdePkg.dec > + MinPlatformPkg/MinPlatformPkg.dec > + UefiCpuPkg/UefiCpuPkg.dec > + > +[Sources] > + SetCacheMtrrLib.c > + > +[Pcd] > + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaBaseAddress > + gMinPlatformPkgTokenSpaceGuid.PcdFlashAreaSize > + > diff --git > a/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Lib.c > b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Lib.c > new file mode 100644 > index 000000000000..33b774fedbd3 > --- /dev/null > +++ > b/Platform/AMD/AmdMinBoardPkg/Library/SetCacheMtrrLib/SetCacheMtrr > Li > +++ b.c > @@ -0,0 +1,133 @@ > +/** @file > + > +SetCacheMtrr library functions. > +This library implementation is for AMD processor based platforms. > + > +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> + > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > + > +/** > + This function sets the cache MTRR values for PEI phase. > +**/ > +VOID > +EFIAPI > +SetCacheMtrr ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D MtrrSetMemoryAttribute ( > + 0, > + 0xA0000, > + CacheWriteBack > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheWriteBack for 0-0x9FFFF\n", > + Status > + )); > + } > + > + Status =3D MtrrSetMemoryAttribute ( > + 0xA0000, > + 0x20000, > + CacheUncacheable > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheUncacheable for 0xA0000-0xBFFFF\n", > + Status > + )); > + } > + > + Status =3D MtrrSetMemoryAttribute ( > + 0xC0000, > + 0x40000, > + CacheWriteProtected > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheWriteProtected for 0xC0000-0xFFFFF\n", > + Status > + )); > + } > + > + Status =3D MtrrSetMemoryAttribute ( > + 0x100000, > + 0xAFF00000, > + CacheWriteBack > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheWriteBack for 0x100000-0xAFFFFFFF\n", > + Status > + )); > + } > + > + Status =3D MtrrSetMemoryAttribute ( > + PcdGet32 (PcdFlashAreaBaseAddress), > + PcdGet32 (PcdFlashAreaSize), > + CacheWriteProtected > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheWriteProtected for 0x%X-0x%X\n", > + Status, > + PcdGet32 (PcdFlashAreaBaseAddress), > + PcdGet32 (PcdFlashAreaBaseAddress) + PcdGet32 (PcdFlashAreaSize) > + )); > + } > + > + MtrrDebugPrintAllMtrrs (); > + return; > +} > + > +/** > + Update MTRR setting in EndOfPei phase. > + This function will set the MTRR value as CacheUncacheable > + for Flash address. > + > + @retval EFI_SUCCESS The function completes successfully. > + @retval Others Some error occurs. > +**/ > +EFI_STATUS > +EFIAPI > +SetCacheMtrrAfterEndOfPei ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + > + Status =3D MtrrSetMemoryAttribute ( > + PcdGet32 (PcdFlashAreaBaseAddress), > + PcdGet32 (PcdFlashAreaSize), > + CacheUncacheable > + ); > + if (EFI_ERROR (Status)) { > + DEBUG (( > + DEBUG_ERROR, > + "Error(%r) in setting CacheUncacheable for 0x%X-0x%X\n", > + Status, > + PcdGet32 (PcdFlashAreaBaseAddress), > + PcdGet32 (PcdFlashAreaBaseAddress) + PcdGet32 (PcdFlashAreaSize) > + )); > + } > + > + MtrrDebugPrintAllMtrrs (); > + return EFI_SUCCESS; > +} > + > -- > 2.25.1