From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.84]) by mx.groups.io with SMTP id smtpd.web10.42805.1681127339812938796 for ; Mon, 10 Apr 2023 04:49:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@amd.com header.s=selector1 header.b=gk46SVn8; 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.243.84, mailfrom: abner.chang@amd.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cVaEGhYH6xTYmnT/JkfSdhjWBTi/lcTnEXbdKN+KtAbnfowTdKr93o4a3orDHNE3InTayeFAjgQKQWee45MbzsIn69zE/mBJYVyPI2j0YszSVbl+dNcJ4NGlcbKNUk8bvN+LLKgK/D6wj7+xTXDM3j2+x0dpaWPl0OF47kzDizilobCGOC2xNDpmYnB8ohp6GXxdP6aT3EJUsJDcUNeNXbNd3MpMNmKMf9z7N9wsks4hLXDE086WkVpCJWukWX9fxWbxpyC8LO6sFB8JGZKJUplqJFld3AaZuV1Cfhd/Cpoha9UZogEzZqjX8S97Yfs/W3gDOC1L+cmAGZLX7nF9zA== 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=OxLbO44TLRAqTMq2MyPvWAbjy3a/Hr5CgbtnFwshvTw=; b=bcqKkRPtfiQ9e2dqmry4vIln6yJ8xGvkiFdyIpMsKiZLfoBofnDspHfea/Kv3f0ZBl3gSlH4TpnSfog66SNCuLhTdNOXqUsfusu2oHh+/hLMoXonDmYYjJC0Sr7aNuEG4l/fhNP7lEorDOpWzhnvGAAOdDeIi5hhXchPLDM+3NOzHD5meYBLg18nvYGE3skL3zbvsoQNxPKwVq03QawYljDt+a/WFTklPlfepyy/FgdRYh8NVnd6e+/uLptBUIGFw4fOItWbaGdgT2IUm5c7mgpwNXvRi4Afdws7QrRbqlh67l5+Gst6GEnxi7o/jpJXJir1PGz7lgGmk0vHbJmBAw== 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=OxLbO44TLRAqTMq2MyPvWAbjy3a/Hr5CgbtnFwshvTw=; b=gk46SVn89uj9zc5Hyh0ycoU5Clgw6TqhOp22Vume5lTXvfidsS5zU4Rt4uZuIB20Ee9ecOjoWrvozp8y1nuJwd2U6/AszBACEx/xqsuBhLfHNy5MhVX0vjtaiX0XT+TOyDPCOVDxp0NrPPatl2a8fB8zE+VhDqEej+XoB/qNevk= Received: from MN2PR12MB3966.namprd12.prod.outlook.com (2603:10b6:208:165::18) by BN9PR12MB5367.namprd12.prod.outlook.com (2603:10b6:408:104::11) 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 11:48:55 +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 11:48:55 +0000 From: "Chang, Abner" To: "devel@edk2.groups.io" , "Attar, AbdulLateef (Abdul Lateef)" CC: "Grimes, Paul" , "Kirkendall, Garrett" , Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Ard Biesheuvel , Jiewen Yao , Jordan Justen Subject: Re: [edk2-devel] [PATCH v8 8/9] UefiCpuPkg: Uses SmmSmramSaveStateLib library Thread-Topic: [edk2-devel] [PATCH v8 8/9] UefiCpuPkg: Uses SmmSmramSaveStateLib library Thread-Index: AQHZa50pyh/A9xhPCk+DJ5c3BGLodK8kbZEQ Date: Mon, 10 Apr 2023 11:48:54 +0000 Message-ID: References: <0bc7e47da753c14dd68fcc1b564e66a44c272aaa.1681121324.git.abdattar@amd.com> In-Reply-To: <0bc7e47da753c14dd68fcc1b564e66a44c272aaa.1681121324.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-10T11:48:52Z; 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=6a63f01e-4859-4b82-88d6-a3d4c8c0935e; 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_|BN9PR12MB5367:EE_ x-ms-office365-filtering-correlation-id: 71f70345-c339-45c4-35bd-08db39b98fdf x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: DJoMh3pxuxDjrLvtBv4HdRpbvm63y/n92xGEFJRQriVK+bVPlYLr1lXfi4/4gU1PAfdv6O46YFavZguAHwaqydaoQxl/mLFQypF/NRtRrWAUtHWsx7xUYtuoL0AJ3vXVPDGAIEWJKm0BdyfkjsX3T4soL76rxoUpQE9qQkFhwbf2OM7oAacjvM8Z6rI7mlVndCgzmDdU8K5bNVUfyaUE5SmVnL9F8imq1uhYyOF1CwDIcwmyS1mvMT/9sNftL1C5GsN7vU2d4/3t0C8zJpdsRquTcejil+X3WUM7i1zSzLcTwt87VCBgkPfrp8FpFZ0A5OUbHIdVrgyp99LJD710AbP7uWLhv7ebGTomuHwM6ta13cLvAApC/VnKx07i/eETNpTSWhnhAFD6uibz6WZeKR1b4ZQPINXfUprU4dy0Smco45PAGOOMBBhi+I2xK1d85+Ft0ufOHTPP/I57SnEmP3Xg9u1y9fPf9puxB84hAvYZGHmiZSeyYgQPHOO9bzjsnZXv5LbOmerVB1uKlesVmcbyoBvPC78hkslbD1sOWino/WdpX6XyqxZvHr6oPL+VMmziL5mU+BYMeI0G+ztaviGqqTLOdfIy7MzdZqcH6UvNsH9CiQhCCSpQ+mVJsTWv 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)(396003)(346002)(366004)(136003)(376002)(39860400002)(451199021)(478600001)(7696005)(71200400001)(19627235002)(316002)(54906003)(6636002)(110136005)(53546011)(9686003)(6506007)(26005)(186003)(966005)(2906002)(30864003)(66556008)(4326008)(76116006)(66946007)(41300700001)(64756008)(8936002)(5660300002)(52536014)(66446008)(66476007)(8676002)(122000001)(38100700002)(38070700005)(86362001)(55016003)(33656002)(83380400001)(66899021)(213903007)(579004)(559001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?OqUFtkiEbr98XtEYoHcb77XCRnw/lGaGT3bahUN7LDUeBIGUbemGxpNw1UPT?= =?us-ascii?Q?B0L3Ox3NvxrF3U/RYgaa0KhC72agxwdXWddvYTt44J2jOCwvNW4kfJQtWiaN?= =?us-ascii?Q?tcYRSzOnaYvUx4/5+IG8rky+c5ypNrOMP0dG3d5G3wTOluJYpsWZebKbmz4h?= =?us-ascii?Q?uSCIn47aphVABfNJ4O8Y0RyZAnZJMLILSi2b2w0tE4N+nGlm5j1i9fvBK6YS?= =?us-ascii?Q?3eUX/eeR/CPcba2GzbuHz0wKkJUdgWZzqXWQlsJEk27j3TOj+pLzdF2WQ/5J?= =?us-ascii?Q?ap7MiVN6TwcLKy1LCoLaILU8YzfYH46WoWAQUZnODdf4WWhijYD703MQ3vGV?= =?us-ascii?Q?7NcHC4CHxvHGAwEFljVV1Fvh8WRvvOf/UsoSK4iYZAcMK+ysME0ZZ2LrosUa?= =?us-ascii?Q?EmzYNpWOoyJs/G7lKF2WBGhvED5CUgj7Pncm6cII44Xym4rJmgThlHn57IwT?= =?us-ascii?Q?wgLgBJcKpplOfsUSPH38cKp4i+JVLPwisB/jKF7PsSBO3O5lM5m9tldd7qLC?= =?us-ascii?Q?8sq6ZL28UVHSfeMK0TGGdunLE0A53bWu3A0dk9GWconCKxNPp1JsqOilBctF?= =?us-ascii?Q?kzmzdoNoRK8VteoyRKMU8MW4+xUgDf9oyM0izRsVLqP6YmUDhwoyUbUUjFz0?= =?us-ascii?Q?8No2qJZu5UxMeWGvRrB4JF4mZGSc5n5FY/jocT/6ayoxf/Za3VSqPtFliWIT?= =?us-ascii?Q?VihOAv5PTm2MhctxZGQW/apVl/gVYbRnl/ZvfxrVfKniLoUTNEq5Uv3Vf6t5?= =?us-ascii?Q?UNYWGnxKyrRnIjn7foNzXSRsf3sOhPidP04jctwdYNxyx5Xl1NX1zZJ5i2sO?= =?us-ascii?Q?1n9yqCb265UtzDSoeOGWUQ3OORXRFW+/SZRllN1Yau1c0qH+3cdy8FdxSLf9?= =?us-ascii?Q?tvT2EyOC632m6wTepLpwhRpuyRSyCm8ma21L22rUMY3Q3MuNOX4iWT3tfvrk?= =?us-ascii?Q?Ulh4Smci0hGbfO/dxkpn6ozquqCmb5thzkkiNiaCXGpiLdZbrYmhmfM65b0Z?= =?us-ascii?Q?cWWRc/1vnYQ3jhThAChQHPUPprFBDa0A5/LDZkiX/6WhBeTs/y30VN+1dZW5?= =?us-ascii?Q?sXcOpiyA8NWOW2yU2EESdK8HiTxI+PaJqQR43sfO81NOQSJ+0Uf7l1yW4dno?= =?us-ascii?Q?ZvmhHrnz8G7Ru8asahyDrOHzVlGLtiu59+jHwFu33AvmGBW/oeibJAmoYnNA?= =?us-ascii?Q?QbPxUO2gmEluwnBVTEF9BxaNN8f1z+q6lkpv2U6kmNPCvCTC9W+NiD4Gr6j/?= =?us-ascii?Q?LVfZEcvJ3kB9IhdwI4YjSU8v/jbk0e01B+HuIcgteXywqSRFo6Yewa2CBHJ3?= =?us-ascii?Q?e+dsApo5GcHb24FaBfWUUlwnhc2O+wBSGvhr9hboEmUs89AZuNbBvS6APlEl?= =?us-ascii?Q?WcfAE/8saAdkxJB1eUu07b0G9VVfobTOiVXxTK5beLFm18VqcGvc7ZChyklE?= =?us-ascii?Q?AssEgkFVeN1lG6ZKfjSKV8fTz2qTTnpHo1pS803TdoPraAdgSTmNxmpKlEMO?= =?us-ascii?Q?uo/g+SOvcpRX1tQDeXlca+C9E/8jjZpUAGr/dHuJFpWh6psx86K/FwtRsvlk?= =?us-ascii?Q?WUVquK7rzFL+viXBaug=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: 71f70345-c339-45c4-35bd-08db39b98fdf X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Apr 2023 11:48:54.8020 (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: MfHoLGz2gL3j1lPnFogk8o+ZlTrp43szxpcJSfujVvt3XU9IksOva2TFpjpfFxbDpYXU6LnUDEyw47SHXbC7hA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5367 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: devel@edk2.groups.io On Behalf Of Abdul > Lateef Attar via groups.io > Sent: Monday, April 10, 2023 7:10 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: [edk2-devel] [PATCH v8 8/9] UefiCpuPkg: Uses > SmmSmramSaveStateLib library >=20 > Caution: This message originated from an External Source. Use proper > caution when opening attachments, clicking links, or responding. >=20 >=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 > --- > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 2 + > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 2 + > UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 5 +- > UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c | 500 +------------------ > 4 files changed, 9 insertions(+), 500 deletions(-) >=20 > 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 >=20 >=20 >=20 >=20 >=20