From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.8763.1681202134342033017 for ; Tue, 11 Apr 2023 01:35:34 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=L5DarFOl; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: ray.ni@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1681202134; x=1712738134; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CsZ2daA+/oSTGjuxMRU05HjJXyeDL0TX9WzWaZOqcrg=; b=L5DarFOldr9R/Py+UkFIOq0AyOubMNo5LGYkCGhlL3QwyjR4XvOPIV1p TBvZ9QUR2NzUAI9czNB7NOP69BmYd4RmzoYDzFo1AzXcPDCb6NgAhhKMU QYxZpEsrwdlOcYQxsumj0MjiUpZ3bRN+wTM6uZAg4nAyxssx8xr6rO+ZV UPchSAfnO6Ec2NXFUpTEf3Y6Z2LrL4tdA0Bkklmo4lLEq0mrGSOylBarm tBOrycuBUh+0UuDC6tGgJlPMtDCFyB9NssK2e5ZrQ3e23h/kSijx649BG JCsE/pMZEXICCTZVAgpuNKCoqOJ54NuzSvWOSMByQCFs9D639noDSExxs g==; X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="342321551" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="342321551" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2023 01:35:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10676"; a="688529229" X-IronPort-AV: E=Sophos;i="5.98,336,1673942400"; d="scan'208";a="688529229" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga002.jf.intel.com with ESMTP; 11 Apr 2023 01:35:30 -0700 Received: from orsmsx603.amr.corp.intel.com (10.22.229.16) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 11 Apr 2023 01:35:30 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23 via Frontend Transport; Tue, 11 Apr 2023 01:35:30 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.108) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.23; Tue, 11 Apr 2023 01:35:30 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kKCzDC1Xr+JImE5E42EexzlRll47/lYAEIvbtyWOzM6Fcl9AF+/PU2KJHp/pAm70AxUbokUea3dsVGqAx4dA/dmPxFIroZP1MGfSKaT7K82LJmMTjQyUsKvxN7wDtHVdwlq+SZjez8fx+uwsqjnM0e1+ZBXOo7LZrPSwTzQWlnDNQpdKXTJLKKZQtLtLvDsNLIMRzNmHjMjhj7K1qvUCeWijeABQ4ImV0vGn8rNXAwzw5TlVjfZzs1W1zH/ulivyJcDb2XEk99PVg3PecdK09bZXbfF9tsqIWRTDHTgykhlwDrsXMbz0HJMrHGck1IrmPfZruZQfAHtLxGlS8NW0Lg== 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=TQqNdMWk3XixPrBtxxE4PKxkD8wvU7NpmD+MJwBP5hA=; b=IehtyaWzusAjtaej3Wk8neZih9YYXf4q78qsoCzh5mjLS8p/SvZvAcieRoSM3+H/RdQGMLGGk5RScpF9IdPC4psSFvaXJILLN4syLp/YBdnIW4Aj2y/i/Yq0MPtToaKE37eMnQf5inY7yAAF//P2KRGPn2+By+IKZmgR7d9zPHBjmob6s/ohe939v8tRrQMxMK4HRxHVuK3bVO+xYqLqvaqWBEny3oR7/jFSwVZ2Bwh0CC6cRrbpoNc7O5xqVzH5S/D4AxlVGijZvqr1TXKlnAgtNE1dtHZW0G8U1PGwOPK2Y8scPn2jMK6RjXPSwT1WXak3KT7ZvukjJeNrK+ZmFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by MN0PR11MB6182.namprd11.prod.outlook.com (2603:10b6:208:3c6::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 08:35:28 +0000 Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::ae07:e96a:4a24:8a69%7]) with mapi id 15.20.6277.034; Tue, 11 Apr 2023 08:35:28 +0000 From: "Ni, Ray" To: "devel@edk2.groups.io" , "abdattar@amd.com" CC: Abdul Lateef Attar , Paul Grimes , Garrett Kirkendall , Abner Chang , "Dong, Eric" , "Kumar, Rahul R" Subject: Re: [edk2-devel] [PATCH v8 6/9] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family Thread-Topic: [edk2-devel] [PATCH v8 6/9] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family Thread-Index: AQHZa50jWQmYCsHabkajKuXiU6Re4q8lyexA Date: Tue, 11 Apr 2023 08:35:28 +0000 Message-ID: References: <66120dc1cddbfa0a67f98e1387ac6151bc9c78e4.1681121324.git.abdattar@amd.com> In-Reply-To: <66120dc1cddbfa0a67f98e1387ac6151bc9c78e4.1681121324.git.abdattar@amd.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|MN0PR11MB6182:EE_ x-ms-office365-filtering-correlation-id: 5b16572c-ee9f-4178-45b3-08db3a67b45a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pJceZKFBEF5coPS9lubByMrtyvq8tfcliGuddf8AV6z4H3tsPQ4HSLW2xQESRadxlFBdrqA8eCCgiqTTa2rZQB3hrj40tJw55Y01go+uBt8TphYDKu89OcYk7rnuIsowlMrW/GUoiW0Ww9T7JheKzqkQPUlOz51ql1vUc1pjUqFVr084bj4IVv7grk80cYixxqGDJQq2Qbty65MlWS69q5ojlvKe2es15Hfvz1a94vboVqGu0JDhWa6h0AzuuqA0E3uuAsCQaeV3fbfd+TyJ5jpD7PEmVky34uiGarpUV170ErEgSwsMYv07sM2NtWGySouP3ThgluQisC0BPz7JNA3+hbORt/jSDvoe8GuKQmGQ+PdYJYdu8AFoT/z5ysqh0E6DdlKDQl1tmwBmFk65T/ljg5a1SdUa9UKjMph/RKtEqSe/n6ZqDr8eOFJuYFHzGpT7ezy7sDbPywAR5drgMTL9EXJ3eaTOo8zwuSzJ5BL+pMTOyz/7gXHzsx7MwvK/3MTDQ+JeWF5IAGBCk5F2hprik9+roHceEHjGwpe2sEqmmsPf0CI7Qwl63Pv7S3t27eviq+sFTGTdZK/y1GLkaojzDDzpMFnpccATn3hSqQoPUMOPp8G9EUeq632I1upijjzj7olB0ufYyCEhPm1xFg== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN6PR11MB8244.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(66899021)(66446008)(8676002)(4326008)(71200400001)(54906003)(66556008)(7696005)(66946007)(66476007)(966005)(76116006)(64756008)(110136005)(316002)(41300700001)(478600001)(33656002)(86362001)(6506007)(9686003)(26005)(107886003)(53546011)(83380400001)(8936002)(5660300002)(52536014)(55016003)(2906002)(38070700005)(82960400001)(38100700002)(122000001)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wbbylAIUqZOfm0R0yKStPgQAfE355YFalOzsSdBpMhcOkWd0qn6GH7in7o7l?= =?us-ascii?Q?DdRQsAENEOmONnRSarMce8F7nC+GmFnLrK/evyLVjQRGuXbVpDbpDW35fffq?= =?us-ascii?Q?pUwJ9hllRga2P20WObakAnmolYMDYxMRxotE3NLZ62SDr/Xg3fP7hOTTE700?= =?us-ascii?Q?GHM99wBu/qn+12+ebb1nt7JSDsct5i+2WBNtjQZ8ygumcldn57IvmQICdiMW?= =?us-ascii?Q?P2qTS0oqiLRDAPi7cLFz37t3ak1qeVKhAm05KH4vCaxOZ7xy7PEwkczNtznK?= =?us-ascii?Q?xTLBauyqSf3lqSozkEplSrPBcW7r4NTNmO/Rcy82O0ghGk6GMZyNlzH200xh?= =?us-ascii?Q?FLptv1VvhUmO8n6ruggCXG+bC/nxdM979Ma5ayk9uyaA1/zfLAtdjJEjAVCX?= =?us-ascii?Q?JBhltJIM4PnNmXqf7BXNPUGXVXoCyS0PkKnxnTIbzFvNEQw+ArTQKMia3y71?= =?us-ascii?Q?WuxAJeC98YfiMiDSeIith9UnTSXk6mW9pk+tstDfGvMYBVUB58sEnruyUaGN?= =?us-ascii?Q?bbYt98gQgySGfLbMaI+W12Tpf3TbeI2PmS61YEu/2jTk2IqPDR1OLAbSFfbj?= =?us-ascii?Q?Srj0RUEqpfozv3GS8WUPC7Yg6Vu/hITdBk/M/rrZWQ1R9TWynid81rGPcbY+?= =?us-ascii?Q?kX0oRk+v3QTviQ3x+KJqacAirSiOisgI/J5+9odcAL4dU/n6JhYCsryv2DRZ?= =?us-ascii?Q?T8h1QEo6cfoPgSrdI7cIMAJf8VFSJh7ftK9cTvTlgQShRIu3VdSSSpX+kVkv?= =?us-ascii?Q?ADBHbxsvnjjPW0yDglvnaf2ovHZzpAzHI+lLDla8BHDtKGGDW8NmJ20r9BtS?= =?us-ascii?Q?ezcx17YTCM7UK+pwoBONcJMsxJdVei51o2geLbMMAmrzgb6FupMQeZikdoZu?= =?us-ascii?Q?/1P3aLRqksXXZ5GJ3Sgz+VbiJJvikVTkdCJlJKRlo6W3S/HAdRdccWB4HUHD?= =?us-ascii?Q?HueqBiOYVujyMgixZgsbJPfGeBKnoYZ8Pd3sGHDpGDJp98knKlp83/8cLmDe?= =?us-ascii?Q?oHbI5xJdlnlSC07t1NTunG7ljlQW2u/igQHGHvp4dv6H3htYmw1ewWHuC/M4?= =?us-ascii?Q?Vr2diQjXDegy7oh6cetiKQ9nXGUycaZrFE1vPsOYJTwEw/pTzltaTIiNGhS1?= =?us-ascii?Q?zt55Ha9psHVc8STmhngRf9HpfhnzVDSX+bhTBAZgNN9yzDmlJSL7yqjFYXHN?= =?us-ascii?Q?XxatCAek6C/EfiXIFciDheFYWGE4AB2rLFodBw2OnHPWw+eDW9TOmgXxIv1O?= =?us-ascii?Q?jbXelxsI0xqU2kgNZA7+jycQE09xyjqMh/iwzTR/We7K0IeEEmuapDA48w8j?= =?us-ascii?Q?QmrlFDF3Vp1usnVueKS89kNrBPAAXTdI4U1VIjdFkJuWXZxAc0apfVk1Xtlq?= =?us-ascii?Q?4HCcySvhjM0wySK4mxzFga3oFPal3YO6fVFbCgWlPCiJ6mfKRygz1Sx7WRMv?= =?us-ascii?Q?JFYyXkCOEK25CaRGVeLcmbhtkEp6OAA0hRe7AYgCK4bfbZHvQ8e07oCq7Rg2?= =?us-ascii?Q?G+YzbaoQZWPMkdx7rkQ2s1rPNLV5sM/U2zHjBeTtK92UDrgbpflxVreSphZW?= =?us-ascii?Q?+N2cAu6nGXsXApkttuo=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN6PR11MB8244.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b16572c-ee9f-4178-45b3-08db3a67b45a X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2023 08:35:28.4738 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: BeQvx+vGCBKyr0oBVLnGpll1ynuY5JTLdUimwaJVvZf77oku1m1JSUApZ00vZqb53QGbH0Q93HCWZm+sqT8jCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR11MB6182 Return-Path: ray.ni@intel.com X-OriginatorOrg: intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Acked-by: Ray Ni > -----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: Abdul Lateef Attar ; Paul Grimes > ; Garrett Kirkendall ; > Abner Chang ; Dong, Eric ; > Ni, Ray ; Kumar, Rahul R ; > Abdul Lateef Attar > Subject: [edk2-devel] [PATCH v8 6/9] UefiCpuPkg: Implements > SmmCpuFeaturesLib for AMD Family >=20 > From: Abdul Lateef Attar >=20 > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4182 >=20 > Implements interfaces to read and write save state > registers of AMD's processor family. > Initializes processor SMMADDR and MASK depends > on PcdSmrrEnable flag. > Program or corrects the IP once control returns from SMM. >=20 > Cc: Paul Grimes > Cc: Garrett Kirkendall > Cc: Abner Chang > Cc: Eric Dong > Cc: Ray Ni > Cc: Rahul Kumar > Signed-off-by: Abdul Lateef Attar > Reviewed-by: Abner Chang > --- > .../AmdSmmCpuFeaturesLib.inf | 5 + > .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c | 106 > +++++++++++++++++- > 2 files changed, 108 insertions(+), 3 deletions(-) >=20 > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf > index 4c77efc64462..6d6f879e2a43 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf > +++ > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf > @@ -31,3 +31,8 @@ [LibraryClasses] > PcdLib > MemoryAllocationLib > DebugLib > + SmmSmramSaveStateLib > + > +[FeaturePcd] > + gUefiCpuPkgTokenSpaceGuid.PcdSmrrEnable ## CONSUMES > + gUefiCpuPkgTokenSpaceGuid.PcdSmmFeatureControlEnable ## > CONSUMES > diff --git > a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c > b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c > index c74e1a0c0c5b..af45be3e265a 100644 > --- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c > +++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c > @@ -11,6 +11,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent >=20 > #include > #include > +#include > +#include > +#include > +#include > + > +// EFER register LMA bit > +#define LMA BIT10 > + > +// Machine Specific Registers (MSRs) > +#define SMMADDR_ADDRESS 0xC0010112ul > +#define SMMMASK_ADDRESS 0xC0010113ul > +#define EFER_ADDRESS 0XC0000080ul > + > +// The mode of the CPU at the time an SMI occurs > +STATIC UINT8 mSmmSaveStateRegisterLma; >=20 > /** > Read an SMM Save State register on the target processor. If this func= tion > @@ -39,7 +54,7 @@ SmmCpuFeaturesReadSaveStateRegister ( > OUT VOID *Buffer > ) > { > - return EFI_SUCCESS; > + return SmramSaveStateReadRegister (CpuIndex, Register, Width, Buffer); > } >=20 > /** > @@ -67,7 +82,7 @@ SmmCpuFeaturesWriteSaveStateRegister ( > IN CONST VOID *Buffer > ) > { > - return EFI_SUCCESS; > + return SmramSaveStateWriteRegister (CpuIndex, Register, Width, Buffer)= ; > } >=20 > /** > @@ -82,6 +97,13 @@ CpuFeaturesLibInitialization ( > VOID > ) > { > + UINT32 LMAValue; > + > + LMAValue =3D (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA= ; > + mSmmSaveStateRegisterLma =3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT; > + if (LMAValue) { > + mSmmSaveStateRegisterLma =3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; > + } > } >=20 > /** > @@ -117,6 +139,52 @@ SmmCpuFeaturesInitializeProcessor ( > IN CPU_HOT_PLUG_DATA *CpuHotPlugData > ) > { > + AMD_SMRAM_SAVE_STATE_MAP *CpuState; > + UINT32 LMAValue; > + > + // > + // Configure SMBASE. > + // > + CpuState =3D (AMD_SMRAM_SAVE_STATE_MAP > *)(UINTN)(SMM_DEFAULT_SMBASE + SMRAM_SAVE_STATE_MAP_OFFSET); > + CpuState->x64.SMBASE =3D (UINT32)CpuHotPlugData->SmBase[CpuIndex]; > + > + // Re-initialize the value of mSmmSaveStateRegisterLma flag which migh= t > have been changed in PiCpuSmmDxeSmm Driver > + // Entry point, to make sure correct value on AMD platform is assigned= to > be used by SmmCpuFeaturesLib. > + LMAValue =3D (UINT32)AsmReadMsr64 (EFER_ADDRESS) & LMA= ; > + mSmmSaveStateRegisterLma =3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT; > + if (LMAValue) { > + mSmmSaveStateRegisterLma =3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_64BIT; > + } > + > + // > + // If SMRR is supported, then program SMRR base/mask MSRs. > + // The EFI_MSR_SMRR_PHYS_MASK_VALID bit is not set until the first > normal 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- > >SmrrSize)) || > + ((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 requirement!\n")); > + CpuDeadLoop (); > + } > + } else { > + AsmWriteMsr64 (SMMADDR_ADDRESS, CpuHotPlugData->SmrrBase); > + AsmWriteMsr64 (SMMMASK_ADDRESS, ((~(UINT64)(CpuHotPlugData- > >SmrrSize - 1)) | 0x6600)); > + } > + } > } >=20 > /** > @@ -159,7 +227,39 @@ SmmCpuFeaturesHookReturnFromSmm ( > IN UINT64 NewInstructionPointer > ) > { > - return 0; > + UINT64 OriginalInstructionPointer; > + AMD_SMRAM_SAVE_STATE_MAP *AmdCpuState; > + > + AmdCpuState =3D (AMD_SMRAM_SAVE_STATE_MAP *)CpuState; > + > + if (mSmmSaveStateRegisterLma =3D=3D > EFI_SMM_SAVE_STATE_REGISTER_LMA_32BIT) { > + OriginalInstructionPointer =3D (UINT64)AmdCpuState->x86._EIP; > + AmdCpuState->x86._EIP =3D (UINT32)NewInstructionPointer; > + // > + // Clear the auto HALT restart flag so the RSM instruction returns > + // program control to the instruction following the HLT instruction. > + // > + if ((AmdCpuState->x86.AutoHALTRestart & BIT0) !=3D 0) { > + AmdCpuState->x86.AutoHALTRestart &=3D ~BIT0; > + } > + } else { > + OriginalInstructionPointer =3D AmdCpuState->x64._RIP; > + if ((AmdCpuState->x64.EFER & LMA) =3D=3D 0) { > + AmdCpuState->x64._RIP =3D (UINT32)NewInstructionPointer32; > + } else { > + AmdCpuState->x64._RIP =3D (UINT32)NewInstructionPointer; > + } > + > + // > + // Clear the auto HALT restart flag so the RSM instruction returns > + // program control to the instruction following the HLT instruction. > + // > + if ((AmdCpuState->x64.AutoHALTRestart & BIT0) !=3D 0) { > + AmdCpuState->x64.AutoHALTRestart &=3D ~BIT0; > + } > + } > + > + return OriginalInstructionPointer; > } >=20 > /** > -- > 2.25.1 >=20 >=20 >=20 >=20 >=20