From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.40]) by mx.groups.io with SMTP id smtpd.web10.37894.1681101509802715622 for ; Sun, 09 Apr 2023 21:38:30 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=b2Dq4GPE; 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.236.40, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V/zRh4j6RihT/A70NlWeWJuUAzGFWMktq7AqqD+xPZt7uP+ws4OMwUJLzChOgBOQPOAgsGDSIf2HKLZrh4bk6GuX+WT5gfpyv3Hn/w6YcjnFSZwQnBzPxUer2pR8EVt/MMQXUbEWv9lMDlgW2tw0XQCKA+GU416trDQlRsmQkLl5Sm+YLtsQUmBwj0FJtxlLFHbznwBEuHMKnI8bKDa5gwtvTpvhrQfuUn7hUrlN8jXU8OCIVhWmRGTOqSkp6je2mu7JNNkRXTXDqcu5mlvFUFB8ckM0mdR2OzH7P53fYW9GO7SKZ17JYCtxBCxIdAe34qZA4AtnkU1/GDkLBPE/0Q== 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=DxiDbzUk+06cpssC+cOIseGX9jpC1MFyw90eT4A4Rdc=; b=YcdiG+xq6SIjWD1F9OrqN1rpwSoHe353oDEsnYp64Eadcq2aMhXwyy7noF6Qj8t9AVyIlEhH6T6yh9qUV3peC+LNOc2hgmFjdl9ezlYQ4tndsJadv7CJd9wKF83LrjniJK5rJATWLUrA4nuqQcTUCb5b4khjgJkU8MGyXDaDoYvouvyaK2YOVmgiL1DUe0YpjZm0EiHJV2XIvYgL0AtbAeJsIPO1+FSB8UkXAu9emwUxU3Su9wuyEVoXzXDbKsPLViJZUwVhmWNG1Y3TTvW8Z9unEG+pNZMaI2NmVe4d7vK+SzfdDfIyemzHhy1vBLLGikFGtXUYGiCnqP5rqURMTg== 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=DxiDbzUk+06cpssC+cOIseGX9jpC1MFyw90eT4A4Rdc=; b=b2Dq4GPER0xYnipbIuxkI2soWPlBY2b5g+blw9Q6ViPSQBIJ1Tmn2QhbOZjCryYlmo0QcfrnSbJ7MfjxE4G7NsolDEyNbsYd511ykPRELIg6xCtxtLbAz8mOq+SBk1/Kt6rYnpXofaovQTA2N/B/muQFUl27cHOUf3Z9N6DuUMc= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by MW4PR12MB7468.namprd12.prod.outlook.com (2603:10b6:303:212::15) 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 04:38:23 +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 04:38:23 +0000 From: "Chang, Abner" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" , "Grimes, Paul" , "Kirkendall, Garrett" , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Ard Biesheuvel , Jiewen Yao , Jordan Justen Subject: Re: [PATCH v7 8/8] UefiCpuPkg: Uses SmmSmramSaveStateLib library Thread-Topic: [PATCH v7 8/8] UefiCpuPkg: Uses SmmSmramSaveStateLib library Thread-Index: AQHZaR5vyi0ycy+3JE6THJF4nCcBsa8j+dWw Date: Mon, 10 Apr 2023 04:38:22 +0000 Message-ID: References: <6ec51c656b9b935263a8438ca144649488ffac95.1680847286.git.abdattar@amd.com> In-Reply-To: <6ec51c656b9b935263a8438ca144649488ffac95.1680847286.git.abdattar@amd.com> 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-10T04:38:21Z; 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=11f05ebe-ce7f-4ee0-8140-d42e8e014842; 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_|MW4PR12MB7468:EE_ x-ms-office365-filtering-correlation-id: c809fb35-f2b3-4549-d028-08db397d6ad4 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: sEoAYPnLPbOtXo5PTyprhwbToDUKIoy88Z9DqJIArHz12ip3ZLeHNJlGAdoZmnu6GdQJrDADIwbx1TeaeEhhZJlMHKadjEP0obdSPmoXAsHGzM4WI4uE0mMBEbJZvLRML1b3+mXio7fQRc4t7ebXBUw9UAytn3ZA3Fb96bVQfRjJLWQ5egZsxjqiyxFoSfmkH9jkwZ+GxcSVLJyq6J4GprwI5X0bJRPuVWCu96RPZrK1I/LpQRvEFmQf6qz8iNeWz8GSEsOjPnsEbTMHtr6c5xfgDSmJe5z9PtxXl0Dy3ErzcgdyQ0EB3DmmTR+7o4voWyxE50M81MNuRGykXsKEl/s3NTYoz9BDfry1UXt4EByxyYaRsW+nBHFjX1r8shIUH3/voP3pwRnVa1VoFUDAVGna40jiQSxjdvvRUsYbnhyM7Kca0uthdB49QJ/Z3wD3F+WMYzynD27/gt2GSdEhxP7CFHQ4TsNpyXfizIn9WrjwI9jjxoduOCJ7oBMSiCfRcxLcfjBc3l51iv/w48VtygsK+n8KCF45o45G/Y6xhGR5uEaLQHqhbZOoEz7MeyZFmFrmmxk1I1hclM3PvwrRst57yWNuD21UrUstxhDBGql8dzHkZzZ7Cn+3SNEhyOXq 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)(39860400002)(376002)(396003)(136003)(366004)(346002)(451199021)(7696005)(71200400001)(45080400002)(478600001)(86362001)(33656002)(55016003)(83380400001)(38070700005)(122000001)(38100700002)(966005)(19627235002)(30864003)(2906002)(54906003)(110136005)(316002)(186003)(53546011)(9686003)(26005)(6506007)(66476007)(8676002)(41300700001)(66446008)(8936002)(66556008)(52536014)(64756008)(5660300002)(4326008)(76116006)(66946007)(213903007)(559001)(579004);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?nInwH4PFUkQwKQijWSrdgQUZSHjjlPR9l6FXYGtkbofQYBWGl6mXWxmLaBr8?= =?us-ascii?Q?wte4vZavrwp0wzluNhVCGF8L5Ix7NVbhAPA/o2kidwbXnEwpGVG6SBcEg20k?= =?us-ascii?Q?SakQcudO4y7csqpSdvqXhMnPr0ZStsgNwOk1dSBNYsDbxxH4ZMSlTALi5Fw+?= =?us-ascii?Q?SerrqRXAHOU2CFCIZYpIS7EAMD11Z0I2lTOKME1J7jvLpFlghLSnpQ86IKhQ?= =?us-ascii?Q?A9gcAHn63UmtGFRAaJHWB5cBidPSAQyRJPX6BaWiCX8gSUt2AAQrC5ktkdcn?= =?us-ascii?Q?4QpK4vtZOjZ+upVBcMc0CpD4BrkvJjd5NHdkGpVBPgGRPPaDVs0ZWFHwOUUn?= =?us-ascii?Q?fbx+0Zm7e2d03Zf6Mc5uQbZ1Pd3dRDLt2CzBTw7rIQH5RuwwADTcokzPnfY/?= =?us-ascii?Q?n1PYOGtnrV93Dmu0XT+apW5VfGXTmCnQAEqYYI43xtgYKaf5IOWtYIKFOemV?= =?us-ascii?Q?HeMjeevssTa+Jvn7NplQWoqyHJE3f7nxmwHdV4qvQuKyTJAqOV9PWypyyGSD?= =?us-ascii?Q?FsJVRBg95lCBBFuJZO5r1CiTJwm87PsE49FGVpZQtv7rqgWIszCkE4GX/b+I?= =?us-ascii?Q?u2ybcJuNqaD9UfDRn/1ZtSosAGDaPVOwnwhvNk2esOKP6DR0AE5fnIjDY711?= =?us-ascii?Q?URU7i3J6yxMpW1cVXxECbB0AwHdhcpmTl4/xY/YnKcf/LtEpa1Ub7IrG/eTL?= =?us-ascii?Q?kaN4Q1qQQxcOizUdHxz0lZtGySxpGwah54PJ2lcKjB1+9BEpG3+pbs2GozPn?= =?us-ascii?Q?/yHRKUg78Niapi3361Mea1BQxo+603HqjH4iaz5dXRrto2u8ljVy/rVuFsNP?= =?us-ascii?Q?MRZsmIdqqv0y1toiMFa1uqJp+LHDYQPbnuYV7arP8wUP0gym2QX/vLV+I/aC?= =?us-ascii?Q?CzxKLW7ETaFhH1NbD8J8+eZ0zEWLf2CbyQRNV0/C4QkEQv2tUTEVDbt+8vKz?= =?us-ascii?Q?daV1YBPUAkoX2BpLzMG0iOO0dHCKUq/CLiZMTrDzPH1r1dteQNs3wuhOX2qM?= =?us-ascii?Q?xbE4lyh9f8QitmkpHtBcAThhq4Q1T4tHUi1uSFOBnBgU6czLwqCzErF5if0j?= =?us-ascii?Q?DlQ+BKbGufo5od+zQ+u+tVig3nD+/enlgft5ru1eTvmtElLTv02mIa4OIc1z?= =?us-ascii?Q?UKgjJ3KMXLiBPIVqn3v2zUN+S3ZzW3K8PxoshW1nfjoYs5gAfsgNeSIK9Jmr?= =?us-ascii?Q?KYfE5Hwk/5LeFQK4ZoKrkpqvaQRV9e3AlAkUnm8TFPGqqPk34auZ2PmLFdBe?= =?us-ascii?Q?7VO5fg3Tw5UhRh2Tmb/OXVgyj+Moesa2u6a/Xmo8/WhHL76w/CUMglXGHqi5?= =?us-ascii?Q?gOt3l5zgkaVLAHdZqji+Of5oLv0IaZtZVAZGfUSFiNCOWqOVghmXwd7SA8B5?= =?us-ascii?Q?2JSWR1dHAXSH8sbCUhbQOFIxD10DvXwrh7RJKspHs2NcChW/yNpnZT2SNgsT?= =?us-ascii?Q?pFQWS6CRqk2WnrsxdyvkAri9KJkR8/xFOs+Ud6YwPjm++9LpSPLUmZ4/MA0/?= =?us-ascii?Q?pqLilF/Qo3rRgOcjLq32ceRen/8Dh2NL/rFwaTZeC4AqNW3LhgoUv4BGrl92?= =?us-ascii?Q?Ryvt5pnGXOsoNLjryP8=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: c809fb35-f2b3-4549-d028-08db397d6ad4 X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2023 04:38:22.8640 (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: rT3u8fuHn/LEIbc73OPp4ecy/jVFkGv+YtkNBS+G5nm3GahhCiJV7NP/uUJ3nuoO8hEO/X9h4eDeWsXpt0sUvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7468 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Abdul, Comments inline. > -----Original Message----- > From: Abdul Lateef Attar > Sent: Friday, April 7, 2023 2:58 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; > Grimes, Paul ; Kirkendall, Garrett > ; Chang, Abner ; > Eric Dong ; Ray Ni ; Rahul Kumar > ; Gerd Hoffmann ; Ard > Biesheuvel ; Jiewen Yao > ; Jordan Justen > Subject: [PATCH v7 8/8] UefiCpuPkg: Uses SmmSmramSaveStateLib library >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4182 >=20 > Uses new SmmSmramSaveStateLib library. > Removes old code. >=20 > Cc: Paul Grimes > Cc: Garrett Kirkendall > Cc: Abner Chang > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Cc: Gerd Hoffmann > Cc: Ard Biesheuvel > Cc: Jiewen Yao > Cc: Jordan Justen > Signed-off-by: Abdul Lateef Attar > --- > OvmfPkg/OvmfPkgIa32X64.dsc | 2 + > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 2 + > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 2 + > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 5 +- > UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 500 +------------------ > 5 files changed, 11 insertions(+), 500 deletions(-) >=20 > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc We should have Ovmf changes in a separate patch. All others look good. Thanks Abner > index 065b54450647..39465fa23739 100644 > --- a/OvmfPkg/OvmfPkgIa32X64.dsc > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc > @@ -4,6 +4,7 @@ > # Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved. # (C) > Copyright 2016 Hewlett Packard Enterprise Development LP
# > Copyright (c) Microsoft Corporation. > +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -451,6 +452,7 @@ > [LibraryClasses.common.DXE_SMM_DRIVER] > BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf > PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf >=20 > SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/Smm > CpuRendezvousLib.inf > + > + > SmmSmramSaveStateLib|UefiCpuPkg/Library/SmmSmramSaveStateLib/Intel > SmmS > + mramSaveStateLib.inf >=20 > [LibraryClasses.common.SMM_CORE] > PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > index 158e05e2646c..c57b6eea0e14 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf > @@ -6,6 +6,7 @@ > # > # Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
= # > Copyright (c) 2017, AMD Incorporated. All rights reserved.
> +# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> # > # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -97,6 +98,7 @@ > [LibraryClasses] > ReportStatusCodeLib > SmmCpuFeaturesLib > PeCoffGetEntryPointLib > + SmmSmramSaveStateLib >=20 > [Protocols] > gEfiSmmAccess2ProtocolGuid ## CONSUMES > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > index a5c2bdd971ca..10df1e908ba8 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h > @@ -3,6 +3,7 @@ Agent Module to load other modules to deploy SMM > Entry Vector for X86 CPU. >=20 > Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
> Copyright (c) 2017, AMD Incorporated. All rights reserved.
> +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -50,6 +51,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include > #include > > #include > +#include >=20 > #include > #include > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > index c0e368ea9475..64643aec54d0 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c > @@ -3,6 +3,7 @@ Agent Module to load other modules to deploy SMM > Entry Vector for X86 CPU. >=20 > Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
> Copyright (c) 2017, AMD Incorporated. All rights reserved.
> +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
>=20 > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > @@ -278,7 +279,7 @@ SmmReadSaveState ( >=20 > Status =3D SmmCpuFeaturesReadSaveStateRegister (CpuIndex, Register, > Width, Buffer); > if (Status =3D=3D EFI_UNSUPPORTED) { > - Status =3D ReadSaveStateRegister (CpuIndex, Register, Width, Buffer)= ; > + Status =3D SmramSaveStateReadRegister (CpuIndex, Register, Width, > + Buffer); > } >=20 > return Status; > @@ -330,7 +331,7 @@ SmmWriteSaveState ( >=20 > Status =3D SmmCpuFeaturesWriteSaveStateRegister (CpuIndex, Register, > Width, Buffer); > if (Status =3D=3D EFI_UNSUPPORTED) { > - Status =3D WriteSaveStateRegister (CpuIndex, Register, Width, Buffer= ); > + Status =3D SmramSaveStateWriteRegister (CpuIndex, Register, Width, > + Buffer); > } >=20 > return Status; > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > index c8ddc6083df6..1e316ee0acdb 100644 > --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c > @@ -2,6 +2,8 @@ > Provides services to access SMRAM Save State Map >=20 > Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
> +Copyright (C) 2023 Advanced Micro Devices, Inc. All rights > +reserved.
> + > SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > **/ > @@ -48,52 +50,6 @@ extern CONST PROCESSOR_SMM_DESCRIPTOR gcPsd; > // #define LMA BIT10 >=20 > -/// > -/// Macro used to simplify the lookup table entries of type > CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -#define > SMM_CPU_OFFSET(Field) OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field) > - > -/// > -/// Macro used to simplify the lookup table entries of type > CPU_SMM_SAVE_STATE_REGISTER_RANGE -/// -#define > SMM_REGISTER_RANGE(Start, End) { Start, End, End - Start + 1 } > - > -/// > -/// Structure used to describe a range of registers -/// -typedef struct= { > - EFI_SMM_SAVE_STATE_REGISTER Start; > - EFI_SMM_SAVE_STATE_REGISTER End; > - UINTN Length; > -} CPU_SMM_SAVE_STATE_REGISTER_RANGE; > - > -/// > -/// Structure used to build a lookup table to retrieve the widths and of= fsets - > /// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value > -/// > - > -#define SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX 1 > -#define SMM_SAVE_STATE_REGISTER_IOMISC_INDEX 2 > -#define SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX 3 > -#define SMM_SAVE_STATE_REGISTER_MAX_INDEX 4 > - > -typedef struct { > - UINT8 Width32; > - UINT8 Width64; > - UINT16 Offset32; > - UINT16 Offset64Lo; > - UINT16 Offset64Hi; > - BOOLEAN Writeable; > -} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY; > - > -/// > -/// Structure used to build a lookup table for the IOMisc width informat= ion - > /// -typedef struct { > - UINT8 Width; > - EFI_SMM_SAVE_STATE_IO_WIDTH IoWidth; > -} CPU_SMM_SAVE_STATE_IO_WIDTH; > - > /// > /// Variables from SMI Handler > /// > @@ -108,463 +64,11 @@ extern CONST UINT16 gcSmiHandlerSize; > // > IA32_DESCRIPTOR gSmiHandlerIdtr; >=20 > -/// > -/// Table used by GetRegisterIndex() to convert an > EFI_SMM_SAVE_STATE_REGISTER -/// value to an index into a table of type > CPU_SMM_SAVE_STATE_LOOKUP_ENTRY -/// -CONST > CPU_SMM_SAVE_STATE_REGISTER_RANGE mSmmCpuRegisterRanges[] =3D { > - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_GDTBASE, > EFI_SMM_SAVE_STATE_REGISTER_LDTINFO), > - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_ES, > EFI_SMM_SAVE_STATE_REGISTER_RIP), > - SMM_REGISTER_RANGE (EFI_SMM_SAVE_STATE_REGISTER_RFLAGS, > EFI_SMM_SAVE_STATE_REGISTER_CR4), > - { (EFI_SMM_SAVE_STATE_REGISTER)0, > (EFI_SMM_SAVE_STATE_REGISTER)0, 0} > -}; > - > -/// > -/// Lookup table used to retrieve the widths and offsets associated with > each -/// supported EFI_SMM_SAVE_STATE_REGISTER value -/// -CONST > CPU_SMM_SAVE_STATE_LOOKUP_ENTRY mSmmCpuWidthOffset[] =3D { > - { 0, 0, 0, 0, = 0, FALSE }, // > Reserved > - > - // > - // Internally defined CPU Save State Registers. Not defined in PI SMM = CPU > Protocol. > - // > - { 4, 4, SMM_CPU_OFFSET (x86.SMMRevId), SMM_CPU_OFFSET > (x64.SMMRevId), 0, FALSE }, // > SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX =3D 1 > - { 4, 4, SMM_CPU_OFFSET (x86.IOMisc), SMM_CPU_OFFSET (x64.IOMisc), > 0, FALSE }, // SMM_SAVE_STATE_REGISTER_= IOMISC_INDEX > =3D 2 > - { 4, 8, SMM_CPU_OFFSET (x86.IOMemAddr), SMM_CPU_OFFSET > (x64.IOMemAddr), SMM_CPU_OFFSET (x64.IOMemAddr) + 4, FALSE }, // > SMM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX =3D 3 > - > - // > - // CPU Save State registers defined in PI SMM CPU Protocol. > - // > - { 0, 8, 0, SMM_CPU_OFFSET (x64.GdtBaseLoD= word), > SMM_CPU_OFFSET (x64.GdtBaseHiDword), FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_GDTBASE =3D 4 > - { 0, 8, 0, SMM_CPU_OFFSET (x64.IdtBaseLoD= word), > SMM_CPU_OFFSET (x64.IdtBaseHiDword), FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_IDTBASE =3D 5 > - { 0, 8, 0, SMM_CPU_OFFSET (x64.LdtBaseLoD= word), > SMM_CPU_OFFSET (x64.LdtBaseHiDword), FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_LDTBASE =3D 6 > - { 0, 0, 0, 0, = 0, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_GDTLIMIT =3D 7 > - { 0, 0, 0, 0, = 0, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_IDTLIMIT =3D 8 > - { 0, 0, 0, 0, = 0, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_LDTLIMIT =3D 9 > - { 0, 0, 0, 0, = 0, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_LDTINFO =3D 10 > - > - { 4, 4, SMM_CPU_OFFSET (x86._ES), SMM_CPU_OFFSET (x64._ES), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_ES =3D 20 > - { 4, 4, SMM_CPU_OFFSET (x86._CS), SMM_CPU_OFFSET (x64._CS), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_CS =3D 21 > - { 4, 4, SMM_CPU_OFFSET (x86._SS), SMM_CPU_OFFSET (x64._SS), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_SS =3D 22 > - { 4, 4, SMM_CPU_OFFSET (x86._DS), SMM_CPU_OFFSET (x64._DS), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_DS =3D 23 > - { 4, 4, SMM_CPU_OFFSET (x86._FS), SMM_CPU_OFFSET (x64._FS), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_FS =3D 24 > - { 4, 4, SMM_CPU_OFFSET (x86._GS), SMM_CPU_OFFSET (x64._GS), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_GS =3D 25 > - { 0, 4, 0, SMM_CPU_OFFSET (x64._LDTR), = 0, > FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_LDTR_SEL =3D 26 > - { 4, 4, SMM_CPU_OFFSET (x86._TR), SMM_CPU_OFFSET (x64._TR), > 0, FALSE }, // EFI_SMM_SAVE_STATE_REGI= STER_TR_SEL =3D > 27 > - { 4, 8, SMM_CPU_OFFSET (x86._DR7), SMM_CPU_OFFSET (x64._DR7), > SMM_CPU_OFFSET (x64._DR7) + 4, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_DR7 =3D 28 > - { 4, 8, SMM_CPU_OFFSET (x86._DR6), SMM_CPU_OFFSET (x64._DR6), > SMM_CPU_OFFSET (x64._DR6) + 4, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_DR6 =3D 29 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R8), > SMM_CPU_OFFSET (x64._R8) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R8 =3D 30 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R9), > SMM_CPU_OFFSET (x64._R9) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R9 =3D 31 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R10), > SMM_CPU_OFFSET (x64._R10) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R10 =3D 32 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R11), > SMM_CPU_OFFSET (x64._R11) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R11 =3D 33 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R12), > SMM_CPU_OFFSET (x64._R12) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R12 =3D 34 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R13), > SMM_CPU_OFFSET (x64._R13) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R13 =3D 35 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R14), > SMM_CPU_OFFSET (x64._R14) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R14 =3D 36 > - { 0, 8, 0, SMM_CPU_OFFSET (x64._R15), > SMM_CPU_OFFSET (x64._R15) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_R15 =3D 37 > - { 4, 8, SMM_CPU_OFFSET (x86._EAX), SMM_CPU_OFFSET (x64._RAX), > SMM_CPU_OFFSET (x64._RAX) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RAX =3D 38 > - { 4, 8, SMM_CPU_OFFSET (x86._EBX), SMM_CPU_OFFSET (x64._RBX), > SMM_CPU_OFFSET (x64._RBX) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RBX =3D 39 > - { 4, 8, SMM_CPU_OFFSET (x86._ECX), SMM_CPU_OFFSET (x64._RCX), > SMM_CPU_OFFSET (x64._RCX) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RCX =3D 40 > - { 4, 8, SMM_CPU_OFFSET (x86._EDX), SMM_CPU_OFFSET (x64._RDX), > SMM_CPU_OFFSET (x64._RDX) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RDX =3D 41 > - { 4, 8, SMM_CPU_OFFSET (x86._ESP), SMM_CPU_OFFSET (x64._RSP), > SMM_CPU_OFFSET (x64._RSP) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RSP =3D 42 > - { 4, 8, SMM_CPU_OFFSET (x86._EBP), SMM_CPU_OFFSET (x64._RBP), > SMM_CPU_OFFSET (x64._RBP) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RBP =3D 43 > - { 4, 8, SMM_CPU_OFFSET (x86._ESI), SMM_CPU_OFFSET (x64._RSI), > SMM_CPU_OFFSET (x64._RSI) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RSI =3D 44 > - { 4, 8, SMM_CPU_OFFSET (x86._EDI), SMM_CPU_OFFSET (x64._RDI), > SMM_CPU_OFFSET (x64._RDI) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RDI =3D 45 > - { 4, 8, SMM_CPU_OFFSET (x86._EIP), SMM_CPU_OFFSET (x64._RIP), > SMM_CPU_OFFSET (x64._RIP) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RIP =3D 46 > - > - { 4, 8, SMM_CPU_OFFSET (x86._EFLAGS), SMM_CPU_OFFSET > (x64._RFLAGS), SMM_CPU_OFFSET (x64._RFLAGS) + 4, TRUE }, // > EFI_SMM_SAVE_STATE_REGISTER_RFLAGS =3D 51 > - { 4, 8, SMM_CPU_OFFSET (x86._CR0), SMM_CPU_OFFSET (x64._CR0), > SMM_CPU_OFFSET (x64._CR0) + 4, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_CR0 =3D 52 > - { 4, 8, SMM_CPU_OFFSET (x86._CR3), SMM_CPU_OFFSET (x64._CR3), > SMM_CPU_OFFSET (x64._CR3) + 4, FALSE }, // > EFI_SMM_SAVE_STATE_REGISTER_CR3 =3D 53 > - { 0, 4, 0, SMM_CPU_OFFSET (x64._CR4), = 0, > FALSE }, // EFI_SMM_SAVE_STATE_REGISTER_CR4 =3D 54 > -}; > - > -/// > -/// Lookup table for the IOMisc width information -/// -CONST > CPU_SMM_SAVE_STATE_IO_WIDTH mSmmCpuIoWidth[] =3D { > - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined =3D= 0 > - { 1, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // > SMM_IO_LENGTH_BYTE =3D 1 > - { 2, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT16 }, // > SMM_IO_LENGTH_WORD =3D 2 > - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined =3D= 3 > - { 4, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT32 }, // > SMM_IO_LENGTH_DWORD =3D 4 > - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined =3D= 5 > - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 }, // Undefined =3D= 6 > - { 0, EFI_SMM_SAVE_STATE_IO_WIDTH_UINT8 } // Undefined =3D= 7 > -}; > - > -/// > -/// Lookup table for the IOMisc type information -/// -CONST > EFI_SMM_SAVE_STATE_IO_TYPE mSmmCpuIoType[] =3D { > - EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // SMM_IO_TYPE_OUT_DX > =3D 0 > - EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // SMM_IO_TYPE_IN_DX > =3D 1 > - EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_OUTS > =3D 2 > - EFI_SMM_SAVE_STATE_IO_TYPE_STRING, // SMM_IO_TYPE_INS = =3D > 3 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 4 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 5 > - EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // > SMM_IO_TYPE_REP_OUTS =3D 6 > - EFI_SMM_SAVE_STATE_IO_TYPE_REP_PREFIX, // SMM_IO_TYPE_REP_INS > =3D 7 > - EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT, // > SMM_IO_TYPE_OUT_IMMEDIATE =3D 8 > - EFI_SMM_SAVE_STATE_IO_TYPE_INPUT, // > SMM_IO_TYPE_OUT_IMMEDIATE =3D 9 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 10 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 11 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 12 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 13 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0, // Undefined = =3D 14 > - (EFI_SMM_SAVE_STATE_IO_TYPE)0 // Undefined = =3D 15 > -}; > - > /// > /// The mode of the CPU at the time an SMI occurs /// > UINT8 mSmmSaveStateRegisterLma; >=20 > -/** > - Read information from the CPU save state. > - > - @param Register Specifies the CPU register to read form the save sta= te. > - > - @retval 0 Register is not valid > - @retval >0 Index into mSmmCpuWidthOffset[] associated with Register > - > -**/ > -UINTN > -GetRegisterIndex ( > - IN EFI_SMM_SAVE_STATE_REGISTER Register > - ) > -{ > - UINTN Index; > - UINTN Offset; > - > - for (Index =3D 0, Offset =3D SMM_SAVE_STATE_REGISTER_MAX_INDEX; > mSmmCpuRegisterRanges[Index].Length !=3D 0; Index++) { > - if ((Register >=3D mSmmCpuRegisterRanges[Index].Start) && (Register = <=3D > mSmmCpuRegisterRanges[Index].End)) { > - return Register - mSmmCpuRegisterRanges[Index].Start + Offset; > - } > - > - Offset +=3D mSmmCpuRegisterRanges[Index].Length; > - } > - > - return 0; > -} > - > -/** > - Read a CPU Save State register on the target processor. > - > - This function abstracts the differences that whether the CPU Save Stat= e > register is in the > - IA32 CPU Save State Map or X64 CPU Save State Map. > - > - This function supports reading a CPU Save State register in SMBase > relocation handler. > - > - @param[in] CpuIndex Specifies the zero-based index of the CPU s= ave > state. > - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up > table. > - @param[in] Width The number of bytes to read from the CPU sa= ve > state. > - @param[out] Buffer Upon return, this holds the CPU register va= lue > read from the save state. > - > - @retval EFI_SUCCESS The register was read from Save State. > - @retval EFI_NOT_FOUND The register is not defined for the Save= State > of Processor. > - @retval EFI_INVALID_PARAMETER This or Buffer is NULL. > - > -**/ > -EFI_STATUS > -ReadSaveStateRegisterByIndex ( > - IN UINTN CpuIndex, > - IN UINTN RegisterIndex, > - IN UINTN Width, > - OUT VOID *Buffer > - ) > -{ > - SMRAM_SAVE_STATE_MAP *CpuSaveState; > - > - if (RegisterIndex =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - CpuSaveState =3D gSmst->CpuSaveState[CpuIndex]; > - > - if (mSmmSaveStateRegisterLma =3D=3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { > - // > - // If 32-bit mode width is zero, then the specified register can not= be > accessed > - // > - if (mSmmCpuWidthOffset[RegisterIndex].Width32 =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - // > - // If Width is bigger than the 32-bit mode width, then the specified > register can not be accessed > - // > - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Write return buffer > - // > - ASSERT (CpuSaveState !=3D NULL); > - CopyMem (Buffer, (UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset32, Width); > - } else { > - // > - // If 64-bit mode width is zero, then the specified register can not= be > accessed > - // > - if (mSmmCpuWidthOffset[RegisterIndex].Width64 =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - // > - // If Width is bigger than the 64-bit mode width, then the specified > register can not be accessed > - // > - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Write at most 4 of the lower bytes of the return buffer > - // > - CopyMem (Buffer, (UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, MIN (4, Width)); > - if (Width > 4) { > - // > - // Write at most 4 of the upper bytes of the return buffer > - // > - CopyMem ((UINT8 *)Buffer + 4, (UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, Width - 4); > - } > - } > - > - return EFI_SUCCESS; > -} > - > -/** > - Read a CPU Save State register on the target processor. > - > - This function abstracts the differences that whether the CPU Save Stat= e > register is in the > - IA32 CPU Save State Map or X64 CPU Save State Map. > - > - This function supports reading a CPU Save State register in SMBase > relocation handler. > - > - @param[in] CpuIndex Specifies the zero-based index of the CPU s= ave > state. > - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up > table. > - @param[in] Width The number of bytes to read from the CPU sa= ve > state. > - @param[out] Buffer Upon return, this holds the CPU register va= lue > read from the save state. > - > - @retval EFI_SUCCESS The register was read from Save State. > - @retval EFI_NOT_FOUND The register is not defined for the Save= State > of Processor. > - @retval EFI_INVALID_PARAMETER Buffer is NULL, or Width does not meet > requirement per Register type. > - > -**/ > -EFI_STATUS > -EFIAPI > -ReadSaveStateRegister ( > - IN UINTN CpuIndex, > - IN EFI_SMM_SAVE_STATE_REGISTER Register, > - IN UINTN Width, > - OUT VOID *Buffer > - ) > -{ > - UINT32 SmmRevId; > - SMRAM_SAVE_STATE_IOMISC IoMisc; > - EFI_SMM_SAVE_STATE_IO_INFO *IoInfo; > - > - // > - // Check for special EFI_SMM_SAVE_STATE_REGISTER_LMA > - // > - if (Register =3D=3D EFI_SMM_SAVE_STATE_REGISTER_LMA) { > - // > - // Only byte access is supported for this register > - // > - if (Width !=3D 1) { > - return EFI_INVALID_PARAMETER; > - } > - > - *(UINT8 *)Buffer =3D mSmmSaveStateRegisterLma; > - > - return EFI_SUCCESS; > - } > - > - // > - // Check for special EFI_SMM_SAVE_STATE_REGISTER_IO > - // > - if (Register =3D=3D EFI_SMM_SAVE_STATE_REGISTER_IO) { > - // > - // Get SMM Revision ID > - // > - ReadSaveStateRegisterByIndex (CpuIndex, > SMM_SAVE_STATE_REGISTER_SMMREVID_INDEX, sizeof (SmmRevId), > &SmmRevId); > - > - // > - // See if the CPU supports the IOMisc register in the save state > - // > - if (SmmRevId < SMRAM_SAVE_STATE_MIN_REV_ID_IOMISC) { > - return EFI_NOT_FOUND; > - } > - > - // > - // Get the IOMisc register value > - // > - ReadSaveStateRegisterByIndex (CpuIndex, > SMM_SAVE_STATE_REGISTER_IOMISC_INDEX, sizeof (IoMisc.Uint32), > &IoMisc.Uint32); > - > - // > - // Check for the SMI_FLAG in IOMisc > - // > - if (IoMisc.Bits.SmiFlag =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - // > - // Only support IN/OUT, but not INS/OUTS/REP INS/REP OUTS. > - // > - if ((mSmmCpuIoType[IoMisc.Bits.Type] !=3D > EFI_SMM_SAVE_STATE_IO_TYPE_INPUT) && > - (mSmmCpuIoType[IoMisc.Bits.Type] !=3D > EFI_SMM_SAVE_STATE_IO_TYPE_OUTPUT)) > - { > - return EFI_NOT_FOUND; > - } > - > - // > - // Compute index for the I/O Length and I/O Type lookup tables > - // > - if ((mSmmCpuIoWidth[IoMisc.Bits.Length].Width =3D=3D 0) || > (mSmmCpuIoType[IoMisc.Bits.Type] =3D=3D 0)) { > - return EFI_NOT_FOUND; > - } > - > - // > - // Make sure the incoming buffer is large enough to hold IoInfo befo= re > accessing > - // > - if (Width < sizeof (EFI_SMM_SAVE_STATE_IO_INFO)) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Zero the IoInfo structure that will be returned in Buffer > - // > - IoInfo =3D (EFI_SMM_SAVE_STATE_IO_INFO *)Buffer; > - ZeroMem (IoInfo, sizeof (EFI_SMM_SAVE_STATE_IO_INFO)); > - > - // > - // Use lookup tables to help fill in all the fields of the IoInfo st= ructure > - // > - IoInfo->IoPort =3D (UINT16)IoMisc.Bits.Port; > - IoInfo->IoWidth =3D mSmmCpuIoWidth[IoMisc.Bits.Length].IoWidth; > - IoInfo->IoType =3D mSmmCpuIoType[IoMisc.Bits.Type]; > - ReadSaveStateRegister (CpuIndex, > EFI_SMM_SAVE_STATE_REGISTER_RAX, > mSmmCpuIoWidth[IoMisc.Bits.Length].Width, &IoInfo->IoData); > - return EFI_SUCCESS; > - } > - > - // > - // Convert Register to a register lookup table index > - // > - return ReadSaveStateRegisterByIndex (CpuIndex, GetRegisterIndex > (Register), Width, Buffer); -} > - > -/** > - Write value to a CPU Save State register on the target processor. > - > - This function abstracts the differences that whether the CPU Save Stat= e > register is in the > - IA32 CPU Save State Map or X64 CPU Save State Map. > - > - This function supports writing a CPU Save State register in SMBase > relocation handler. > - > - @param[in] CpuIndex Specifies the zero-based index of the CPU sa= ve > state. > - @param[in] RegisterIndex Index into mSmmCpuWidthOffset[] look up > table. > - @param[in] Width The number of bytes to read from the CPU sav= e > state. > - @param[in] Buffer Upon entry, this holds the new CPU register = value. > - > - @retval EFI_SUCCESS The register was written to Save State. > - @retval EFI_NOT_FOUND The register is not defined for the Save= State > of Processor. > - @retval EFI_INVALID_PARAMETER ProcessorIndex or Width is not correct. > - > -**/ > -EFI_STATUS > -EFIAPI > -WriteSaveStateRegister ( > - IN UINTN CpuIndex, > - IN EFI_SMM_SAVE_STATE_REGISTER Register, > - IN UINTN Width, > - IN CONST VOID *Buffer > - ) > -{ > - UINTN RegisterIndex; > - SMRAM_SAVE_STATE_MAP *CpuSaveState; > - > - // > - // Writes to EFI_SMM_SAVE_STATE_REGISTER_LMA are ignored > - // > - if (Register =3D=3D EFI_SMM_SAVE_STATE_REGISTER_LMA) { > - return EFI_SUCCESS; > - } > - > - // > - // Writes to EFI_SMM_SAVE_STATE_REGISTER_IO are not supported > - // > - if (Register =3D=3D EFI_SMM_SAVE_STATE_REGISTER_IO) { > - return EFI_NOT_FOUND; > - } > - > - // > - // Convert Register to a register lookup table index > - // > - RegisterIndex =3D GetRegisterIndex (Register); > - if (RegisterIndex =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - CpuSaveState =3D gSmst->CpuSaveState[CpuIndex]; > - > - // > - // Do not write non-writable SaveState, because it will cause exceptio= n. > - // > - if (!mSmmCpuWidthOffset[RegisterIndex].Writeable) { > - return EFI_UNSUPPORTED; > - } > - > - // > - // Check CPU mode > - // > - if (mSmmSaveStateRegisterLma =3D=3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { > - // > - // If 32-bit mode width is zero, then the specified register can not= be > accessed > - // > - if (mSmmCpuWidthOffset[RegisterIndex].Width32 =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - // > - // If Width is bigger than the 32-bit mode width, then the specified > register can not be accessed > - // > - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width32) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Write SMM State register > - // > - ASSERT (CpuSaveState !=3D NULL); > - CopyMem ((UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset32, Buffer, Width); > - } else { > - // > - // If 64-bit mode width is zero, then the specified register can not= be > accessed > - // > - if (mSmmCpuWidthOffset[RegisterIndex].Width64 =3D=3D 0) { > - return EFI_NOT_FOUND; > - } > - > - // > - // If Width is bigger than the 64-bit mode width, then the specified > register can not be accessed > - // > - if (Width > mSmmCpuWidthOffset[RegisterIndex].Width64) { > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Write at most 4 of the lower bytes of SMM State register > - // > - CopyMem ((UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset64Lo, Buffer, MIN (4, Width)); > - if (Width > 4) { > - // > - // Write at most 4 of the upper bytes of SMM State register > - // > - CopyMem ((UINT8 *)CpuSaveState + > mSmmCpuWidthOffset[RegisterIndex].Offset64Hi, (UINT8 *)Buffer + 4, > Width - 4); > - } > - } > - > - return EFI_SUCCESS; > -} > - > /** > Hook the code executed immediately after an RSM instruction on the > currently > executing CPU. The mode of code executed immediately after RSM must > be > -- > 2.25.1