From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id B4894941269 for ; Thu, 18 Apr 2024 07:33:25 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=j5Ncrtx5f5/rn7w3R9pT49DmwfzQfD6+JBJDUqFor/A=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20240206; t=1713425604; v=1; b=lh3BiMZsRfwiNsHOUiKntr9MAuQEqPCpHAKM6/WMMEZzOXmWJqUDVYKhDG/fWqfv9CwRIiOB gYBx9OK+m/NeEf/UcbIix922A9CBdTg3cEBwkfleQe3rVaPYelIyhJuY7mQALcQnxobtU+BCUGR 0N/9YCRQjopwozbSq2BAEEHf9buDTPkTQdnL3q3yaQ7li038vouOEgmP2pJMUq24eWcVyllHhCD AulacoAFkKVGu77h1FDqeMEJ6Dzvhv2V/2RaRvSoiLGytjU2UVn+fjKkBxmwB9OCrHsq7diHns8 ppfJeYJ3JHRBIrLSOsbjXTgGTcQF1+E0EVMKiZCkhnVSw== X-Received: by 127.0.0.2 with SMTP id 7pPEYY7687511x2e1m5YuQiO; Thu, 18 Apr 2024 00:33:24 -0700 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mx.groups.io with SMTP id smtpd.web11.7410.1713425602938825733 for ; Thu, 18 Apr 2024 00:33:23 -0700 X-CSE-ConnectionGUID: IUMI97ysS6mEuiXXumI+WA== X-CSE-MsgGUID: c8LJ8A8UTg60wGsreTlc8g== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="8815544" X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208,217";a="8815544" X-Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 00:33:22 -0700 X-CSE-ConnectionGUID: F2FGIUu8TzaAheBYLvKHdQ== X-CSE-MsgGUID: K5J05CBwQ0K7SRbnudJK0w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,211,1708416000"; d="scan'208,217";a="27314435" X-Received: from orsmsx602.amr.corp.intel.com ([10.22.229.15]) by fmviesa005.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 18 Apr 2024 00:33:20 -0700 X-Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX602.amr.corp.intel.com (10.22.229.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 18 Apr 2024 00:33:19 -0700 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 18 Apr 2024 00:33:19 -0700 X-Received: from ORSEDG602.ED.cps.intel.com (10.7.248.7) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 18 Apr 2024 00:33:19 -0700 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.40) by edgegateway.intel.com (134.134.137.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 18 Apr 2024 00:33:18 -0700 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com (2603:10b6:208:470::14) by DM4PR11MB7349.namprd11.prod.outlook.com (2603:10b6:8:106::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7472.28; Thu, 18 Apr 2024 07:33:17 +0000 X-Received: from MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::8774:81a7:c5b7:5c2c]) by MN6PR11MB8244.namprd11.prod.outlook.com ([fe80::8774:81a7:c5b7:5c2c%7]) with mapi id 15.20.7472.037; Thu, 18 Apr 2024 07:33:17 +0000 From: "Ni, Ray" To: "Wu, Jiaxin" , "devel@edk2.groups.io" CC: "Zeng, Star" , Gerd Hoffmann , "Kumar, Rahul R" Subject: Re: [edk2-devel] [PATCH v3 03/13] UefiCpuPkg/SmmRelocationLib: Rename global variables Thread-Topic: [PATCH v3 03/13] UefiCpuPkg/SmmRelocationLib: Rename global variables Thread-Index: AQHakV2H2Qr51cCEAUWhKAapGpVinLFtoouJ Date: Thu, 18 Apr 2024 07:33:17 +0000 Message-ID: References: <20240418065556.5696-1-jiaxin.wu@intel.com> <20240418065556.5696-4-jiaxin.wu@intel.com> In-Reply-To: <20240418065556.5696-4-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN6PR11MB8244:EE_|DM4PR11MB7349:EE_ x-ms-office365-filtering-correlation-id: eabefcce-7fd4-4590-5205-08dc5f79d06f x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: fYqlVApW3Z0eK9TtMmdDay+V2HpH2rEN/Bk+GWcM8yK1Wz42h8tIMBIDZIffrMlkj+j66KfBSjJ5HWI8H1+LNDOUKBPCsSXfWpUk3cQiV4EYOj5nv/xwi4ymbx01ESIVO1WCqVpO7XRWyae7DrIofOqp+BrxL3Kxb99c1kHe7Nf2WlmU8amAz7BnfC11jAkszkpWcWmSdlW2E2vtXFkcvXIN5XTek6hqkr4bT7mAFOzXL4S4PUhdZvgbhqIOy+baxWR2XHqar1HabujGtr1+MvAX1ukGz7Azbl/0sBoVf8eNuVXvjUeKLhdiTqqr55NA0ubDsy5vTlxfpUQkTVw5o2euyGJsHM5uXD68y8SmhCVm2vzVpOfjz3dXuXisHQSJDEDYFoBmU/1mZjd5/JRZjFnTnBVXKev4zl782cEksaNP48TlNUMvzwnMBBKRwrqO0N4k16F22cAFt5sIHsBoiPK9Hf6KXWG7K7TMAW0utlwxS1Gaq2FpuP7h4V4ZAvWknDQKfHFr1XhHNXWcEGwrLaRW/9Ic8fnbw1C/ZqFdXQospQfB9+x3Wy7uVszHkcndHsYSlr9ono30ERnV4RW9l+FhrYoIXXM23ilGHpFNCsQyXM5hfaP8fE1Fc9opJcoOgnmx6eBx1pMw92k65A1UMWIZfi24CUB9bZAv+ldOknHvzWVtH1B21FY8w8j/CboWPojKMW1sXOVhr5SxXDjiIKjSeLg5XKGZTPhT7GLpd5c= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?pQYijVWF1x5mu+iwJxcoPNeazSEM7NhFMwrBTuCLPos1/owqGZW55J/EVlRu?= =?us-ascii?Q?YwQ87YrsisYWRFgLfFNU4rE13UBhr/ldDwvQFjuiYKQFR0oT6gPNNm6/1oi9?= =?us-ascii?Q?qKqGWQ/p/kl97t+BWwY2mbncfGiWC6NAKjsaqpvin3WCB53TwEkmVj0bHi7l?= =?us-ascii?Q?4PVwOZSrcwkJOKWTwfn7HcYCQjtlFhrRyjjj+gLfhueBpoQ7I2gL4vSEvH5B?= =?us-ascii?Q?hwr9laF+mPAceiJjOU/KzTuTeOpyehgy4iGKqWNnW+6tG+IdkkFMoxvYMmXf?= =?us-ascii?Q?ma1Yy4OlIRX9vqXA9ndOMY+HN3mDXj+ECYXzHhkjRZEqSwoV+sSyZku8+KrV?= =?us-ascii?Q?VVOjvQ5SS6cqG+fmy12qAIEY3vo7nxBqSoAoKto8P1VUNc1Od5z/acOf1c/3?= =?us-ascii?Q?yvaISlff1dULCzs6Tfyzkq/bpmIdVpPxgSH5tYrfDOJic6ETIurI41CvGWEc?= =?us-ascii?Q?yd2EHcBpaBUMSpAInCphJwpTpMNPF8GwZBO+5k5wtODtGSEDuUhZmAbJ1J+c?= =?us-ascii?Q?VfNSbktV/6UqX1ZIP6Hmgegqu1nxvHfpoEAYOnRylgTqhjQVMsosFYDP+aEl?= =?us-ascii?Q?pBJO7Q1M2AJy+nLIdX2VRRG1wMYNR8IpvTcUODOnADrE3ZgaVMlIlQKZXreV?= =?us-ascii?Q?rtdvNC1nkr94caXC2d/cwIqUnajynux1UWUE+94n05HcxPAqrETCNJcEzlEz?= =?us-ascii?Q?Dhb1zaf6qDDbf0gCcfVOz9l9U0ctNG/0oRnnXC0+0rwFhTcDhAiCqudgqqQm?= =?us-ascii?Q?76q5RtnnZLRJSHCTb+Mhq0R2L4FSw7Yx9urGmvJ7Ovv/VKVHIYzFde5m6Owb?= =?us-ascii?Q?NxtXpYqUZ8XXaHmmrliLUIPQkZux1OQJfh91nrTMBI1YPCKVVqSbWEiGcaMu?= =?us-ascii?Q?oQThzyFEAjQf80vyOAy6ys4pj3hw593CVU6uhD94cr1/Bu8js3bEXgYKN+uL?= =?us-ascii?Q?DQXK+hOF6xixBlj8sTDd5jsYIMWXUGypZ11xJXQHbjthKBHF0BHUwL+nKXD5?= =?us-ascii?Q?xugm8gDUln4RM3/TKaKCknLXm03u/zqcOkffk/ko14cYTeWuOJ1IjT/hEuFb?= =?us-ascii?Q?i3TvE7kl6sbOIDVKzQfKCvLdI8pXDaRdHpw779ppBd6SlcSVoIu0TTZJjEtX?= =?us-ascii?Q?u9WlsHphaw55YPLFXRzZEXnipvuQVbq/xR8R8aQyKSw6t2slQeswTcVudPf0?= =?us-ascii?Q?FMw1THQQau8dnTUQh72VXUr9+7o+Ovtvzjzj8/nEWXb1IP1hXReRanL5ejOd?= =?us-ascii?Q?pz9O5dBdpoQIjFmGjfYF1g72MccIO38wNTkq5oUGR54pBeLDiYGJRzCuD/H2?= =?us-ascii?Q?8KsC71jcFcbZ8soc9Sv0hPg1iZuFoenjmw3kC5OWlfQmncBOS6fh+/lJm/tp?= =?us-ascii?Q?kRfSNJ/ZhjVGsmoqVt7WZz25BEca+oIATmJO/gmqwMs3LHCSNHIsJFJadT8O?= =?us-ascii?Q?sGj5hjeYg27JEy52+7aHqEbKVH602dBljMZ7MNcmtdJjKgvB1wvvf6geKvBZ?= =?us-ascii?Q?WfVMH7f4w4RkehYXyI8ShoHRr9x54ymZOpwMlsRadGeWCOjQy4rJnMBQslqg?= =?us-ascii?Q?GdKaSxvXCqNOP0APyu4=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: eabefcce-7fd4-4590-5205-08dc5f79d06f X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Apr 2024 07:33:17.2062 (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: mKiAbCWopqiW7UPYTtG0v8E42QPbpBLiVh28hXt+ccI6aNPtUD8ArU9Ri/9d77ncZpiKiniv2KQ2B6bcBfajrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR11MB7349 X-OriginatorOrg: intel.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Thu, 18 Apr 2024 00:33:23 -0700 Resent-From: ray.ni@intel.com Reply-To: devel@edk2.groups.io,ray.ni@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: utlAr6KDIPDHS6uG5ckUf0aIx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MN6PR11MB824463EC0258869D6EADDEAF8C0E2MN6PR11MB8244namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=lh3BiMZs; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io --_000_MN6PR11MB824463EC0258869D6EADDEAF8C0E2MN6PR11MB8244namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ray Ni Thanks, Ray ________________________________ From: Wu, Jiaxin Sent: Thursday, April 18, 2024 14:55 To: devel@edk2.groups.io Cc: Ni, Ray ; Zeng, Star ; Gerd Hoff= mann ; Kumar, Rahul R Subject: [PATCH v3 03/13] UefiCpuPkg/SmmRelocationLib: Rename global variab= les This patch aims to rename global variables for clearer association with Smm Init, ensuring their names are distinct from those used in the PiSmmCpuDxeSmm Driver. Cc: Ray Ni Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Signed-off-by: Jiaxin Wu --- .../Library/SmmRelocationLib/Ia32/SmmInit.nasm | 18 +++++++-------- .../SmmRelocationLib/InternalSmmRelocationLib.h | 8 +++---- .../Library/SmmRelocationLib/SmmRelocationLib.c | 26 +++++++++++-------= ---- .../Library/SmmRelocationLib/X64/SmmInit.nasm | 18 +++++++-------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm b/UefiCp= uPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm index 3d845e9e16..8916cb7d06 100644 --- a/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm +++ b/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm @@ -16,15 +16,15 @@ extern ASM_PFX(SmmInitHandler) extern ASM_PFX(mRebasedFlag) extern ASM_PFX(mSmmRelocationOriginalAddress) -global ASM_PFX(gPatchSmmCr3) -global ASM_PFX(gPatchSmmCr4) -global ASM_PFX(gPatchSmmCr0) +global ASM_PFX(gPatchSmmInitCr3) +global ASM_PFX(gPatchSmmInitCr4) +global ASM_PFX(gPatchSmmInitCr0) global ASM_PFX(gPatchSmmInitStack) -global ASM_PFX(gcSmiInitGdtr) +global ASM_PFX(gcSmmInitGdtr) global ASM_PFX(gcSmmInitSize) global ASM_PFX(gcSmmInitTemplate) %define PROTECT_MODE_CS 0x8 %define PROTECT_MODE_DS 0x20 @@ -81,11 +81,11 @@ CodeSeg64: DB 0x9b DB 0xaf ; LimitHigh DB 0 ; BaseHigh GDT_SIZE equ $ - NullSeg -ASM_PFX(gcSmiInitGdtr): +ASM_PFX(gcSmmInitGdtr): DW GDT_SIZE - 1 DD NullSeg SECTION .text @@ -98,22 +98,22 @@ ASM_PFX(SmmStartup): cpuid mov ebx, edx ; rdmsr will change edx. keep it i= n ebx. and ebx, BIT20 ; extract NX capability bit shr ebx, 9 ; shift bit to IA32_EFER.NXE[BIT11= ] position mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr3): +ASM_PFX(gPatchSmmInitCr3): mov cr3, eax -o32 lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] +o32 lgdt [cs:ebp + (ASM_PFX(gcSmmInitGdtr) - ASM_PFX(SmmStartup))] mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr4): +ASM_PFX(gPatchSmmInitCr4): mov cr4, eax mov ecx, 0xc0000080 ; IA32_EFER MSR rdmsr or eax, ebx ; set NXE bit if NX is available wrmsr mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr0): +ASM_PFX(gPatchSmmInitCr0): mov di, PROTECT_MODE_DS mov cr0, eax jmp PROTECT_MODE_CS : dword @32bit BITS 32 diff --git a/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h= b/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h index a9d3f271a9..ede61b956f 100644 --- a/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h +++ b/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h @@ -30,17 +30,17 @@ #include #include #include #include -extern IA32_DESCRIPTOR gcSmiInitGdtr; +extern IA32_DESCRIPTOR gcSmmInitGdtr; extern CONST UINT16 gcSmmInitSize; extern CONST UINT8 gcSmmInitTemplate[]; -X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr0; -X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr3; -X86_ASSEMBLY_PATCH_LABEL gPatchSmmCr4; +X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitCr0; +X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitCr3; +X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitCr4; X86_ASSEMBLY_PATCH_LABEL gPatchSmmInitStack; // // The size 0x20 must be bigger than // the size of template code of SmmInit. Currently, diff --git a/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c b/UefiC= puPkg/Library/SmmRelocationLib/SmmRelocationLib.c index 13e62b662d..ca98f06a05 100644 --- a/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c +++ b/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c @@ -22,11 +22,11 @@ UINTN mNumberOfCpus =3D 1; EFI_PROCESSOR_INFORMATION *mProcessorInfo =3D NULL; // // IDT used during SMM Init // -IA32_DESCRIPTOR gcSmiIdtr; +IA32_DESCRIPTOR gcSmmInitIdtr; // // Smbase for all CPUs // UINT64 *mSmBase =3D NULL; @@ -118,11 +118,11 @@ SmmInitHandler ( UINTN Index; // // Update SMM IDT entries' code segment and load IDT // - AsmWriteIdtr (&gcSmiIdtr); + AsmWriteIdtr (&gcSmmInitIdtr); ApicId =3D GetApicId (); for (Index =3D 0; Index < mNumberOfCpus; Index++) { if (ApicId =3D=3D (UINT32)mProcessorInfo[Index].ProcessorId) { // @@ -167,13 +167,13 @@ SmmRelocateBases ( ASSERT (sizeof (BakBuf) >=3D gcSmmInitSize); // // Patch ASM code template with current CR0, CR3, and CR4 values // - PatchInstructionX86 (gPatchSmmCr0, AsmReadCr0 (), 4); - PatchInstructionX86 (gPatchSmmCr3, AsmReadCr3 (), 4); - PatchInstructionX86 (gPatchSmmCr4, AsmReadCr4 () & (~CR4_CET_ENABLE), 4)= ; + PatchInstructionX86 (gPatchSmmInitCr0, AsmReadCr0 (), 4); + PatchInstructionX86 (gPatchSmmInitCr3, AsmReadCr3 (), 4); + PatchInstructionX86 (gPatchSmmInitCr4, AsmReadCr4 () & (~CR4_CET_ENABLE)= , 4); U8Ptr =3D (UINT8 *)(UINTN)(SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET= ); CpuStatePtr =3D (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SMBASE + SMR= AM_SAVE_STATE_MAP_OFFSET); // @@ -249,19 +249,19 @@ InitSmmIdt ( // // There are 32 (not 255) entries in it since only processor // generated exceptions will be handled. // - gcSmiIdtr.Limit =3D (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - 1; + gcSmmInitIdtr.Limit =3D (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - 1; // // Allocate for IDT. // sizeof (UINTN) is for the PEI Services Table pointer. // - gcSmiIdtr.Base =3D (UINTN)AllocateZeroPool (gcSmiIdtr.Limit + 1 + sizeof= (UINTN)); - ASSERT (gcSmiIdtr.Base !=3D 0); - gcSmiIdtr.Base +=3D sizeof (UINTN); + gcSmmInitIdtr.Base =3D (UINTN)AllocateZeroPool (gcSmmInitIdtr.Limit + 1 = + sizeof (UINTN)); + ASSERT (gcSmmInitIdtr.Base !=3D 0); + gcSmmInitIdtr.Base +=3D sizeof (UINTN); // // Disable Interrupt, save InterruptState and save PEI IDT table // InterruptState =3D SaveAndDisableInterrupts (); @@ -270,21 +270,21 @@ InitSmmIdt ( // // Save the PEI Services Table pointer // The PEI Services Table pointer will be stored in the sizeof (UINTN) b= ytes // immediately preceding the IDT in memory. // - PeiServices =3D (CONST EFI_PEI_SERVICE= S **)(*(UINTN *)(PeiIdtr.Base - sizeof (UINTN))); - (*(UINTN *)(gcSmiIdtr.Base - sizeof (UINTN))) =3D (UINTN)PeiServices; + PeiServices =3D (CONST EFI_PEI_SER= VICES **)(*(UINTN *)(PeiIdtr.Base - sizeof (UINTN))); + (*(UINTN *)(gcSmmInitIdtr.Base - sizeof (UINTN))) =3D (UINTN)PeiServices= ; // // Load SMM temporary IDT table // - AsmWriteIdtr (&gcSmiIdtr); + AsmWriteIdtr (&gcSmmInitIdtr); // // Setup SMM default exception handlers, SMM IDT table - // will be updated and saved in gcSmiIdtr + // will be updated and saved in gcSmmInitIdtr // Status =3D InitializeCpuExceptionHandlers (NULL); ASSERT_EFI_ERROR (Status); // diff --git a/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm b/UefiCpu= Pkg/Library/SmmRelocationLib/X64/SmmInit.nasm index c790ad7ad8..8288b723c4 100644 --- a/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm +++ b/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm @@ -16,15 +16,15 @@ extern ASM_PFX(SmmInitHandler) extern ASM_PFX(mRebasedFlag) extern ASM_PFX(mSmmRelocationOriginalAddress) -global ASM_PFX(gPatchSmmCr3) -global ASM_PFX(gPatchSmmCr4) -global ASM_PFX(gPatchSmmCr0) +global ASM_PFX(gPatchSmmInitCr3) +global ASM_PFX(gPatchSmmInitCr4) +global ASM_PFX(gPatchSmmInitCr0) global ASM_PFX(gPatchSmmInitStack) -global ASM_PFX(gcSmiInitGdtr) +global ASM_PFX(gcSmmInitGdtr) global ASM_PFX(gcSmmInitSize) global ASM_PFX(gcSmmInitTemplate) global ASM_PFX(gPatchRebasedFlagAddr32) global ASM_PFX(gPatchSmmRelocationOriginalAddressPtr32) @@ -82,11 +82,11 @@ CodeSeg64: DB 0x9b DB 0xaf ; LimitHigh DB 0 ; BaseHigh GDT_SIZE equ $ - NullSeg -ASM_PFX(gcSmiInitGdtr): +ASM_PFX(gcSmmInitGdtr): DW GDT_SIZE - 1 DQ NullSeg DEFAULT REL @@ -98,15 +98,15 @@ BITS 16 ASM_PFX(SmmStartup): mov eax, 0x80000001 ; read capability cpuid mov ebx, edx ; rdmsr will change edx. keep it i= n ebx. mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr3): +ASM_PFX(gPatchSmmInitCr3): mov cr3, eax -o32 lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(SmmStartup))] +o32 lgdt [cs:ebp + (ASM_PFX(gcSmmInitGdtr) - ASM_PFX(SmmStartup))] mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr4): +ASM_PFX(gPatchSmmInitCr4): or ah, 2 ; enable XMM registers access mov cr4, eax mov ecx, 0xc0000080 ; IA32_EFER MSR rdmsr or ah, BIT0 ; set LME bit @@ -114,11 +114,11 @@ ASM_PFX(gPatchSmmCr4): jz .1 or ah, BIT3 ; set NXE bit .1: wrmsr mov eax, strict dword 0 ; source operand will be patched -ASM_PFX(gPatchSmmCr0): +ASM_PFX(gPatchSmmInitCr0): mov cr0, eax ; enable protected mode & paging jmp LONG_MODE_CS : dword 0 ; offset will be patched to @LongM= ode @PatchLongModeOffset: BITS 64 -- 2.16.2.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#117960): https://edk2.groups.io/g/devel/message/117960 Mute This Topic: https://groups.io/mt/105593571/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- --_000_MN6PR11MB824463EC0258869D6EADDEAF8C0E2MN6PR11MB8244namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable
Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray

From: Wu, Jiaxin <jiaxin= .wu@intel.com>
Sent: Thursday, April 18, 2024 14:55
To: devel@edk2.groups.io <devel@edk2.groups.io>
Cc: Ni, Ray <ray.ni@intel.com>; Zeng, Star <star.zeng@intel= .com>; Gerd Hoffmann <kraxel@redhat.com>; Kumar, Rahul R <rahul= .r.kumar@intel.com>
Subject: [PATCH v3 03/13] UefiCpuPkg/SmmRelocationLib: Rename global= variables
 
This patch aims to rename global variables for cle= arer
association with Smm Init, ensuring their names are
distinct from those used in the PiSmmCpuDxeSmm Driver.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
---
 .../Library/SmmRelocationLib/Ia32/SmmInit.nasm    = ; | 18 +++++++--------
 .../SmmRelocationLib/InternalSmmRelocationLib.h    |&n= bsp; 8 +++----
 .../Library/SmmRelocationLib/SmmRelocationLib.c    | 2= 6 +++++++++++-----------
 .../Library/SmmRelocationLib/X64/SmmInit.nasm    =   | 18 +++++++--------
 4 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm b/UefiCp= uPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
index 3d845e9e16..8916cb7d06 100644
--- a/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
+++ b/UefiCpuPkg/Library/SmmRelocationLib/Ia32/SmmInit.nasm
@@ -16,15 +16,15 @@
 
 extern ASM_PFX(SmmInitHandler)
 extern ASM_PFX(mRebasedFlag)
 extern ASM_PFX(mSmmRelocationOriginalAddress)
 
-global ASM_PFX(gPatchSmmCr3)
-global ASM_PFX(gPatchSmmCr4)
-global ASM_PFX(gPatchSmmCr0)
+global ASM_PFX(gPatchSmmInitCr3)
+global ASM_PFX(gPatchSmmInitCr4)
+global ASM_PFX(gPatchSmmInitCr0)
 global ASM_PFX(gPatchSmmInitStack)
-global ASM_PFX(gcSmiInitGdtr)
+global ASM_PFX(gcSmmInitGdtr)
 global ASM_PFX(gcSmmInitSize)
 global ASM_PFX(gcSmmInitTemplate)
 
 %define PROTECT_MODE_CS 0x8
 %define PROTECT_MODE_DS 0x20
@@ -81,11 +81,11 @@ CodeSeg64:
             DB=       0x9b
             DB=       0xaf      &nbs= p;         ; LimitHigh
             DB=       0       &= nbsp;           ; BaseHig= h
 GDT_SIZE equ $ - NullSeg
 
-ASM_PFX(gcSmiInitGdtr):
+ASM_PFX(gcSmmInitGdtr):
     DW      GDT_SIZE - 1
     DD      NullSeg
 
 
     SECTION .text
@@ -98,22 +98,22 @@ ASM_PFX(SmmStartup):
     cpuid
     mov     ebx, edx  &n= bsp;            = ;     ; rdmsr will change edx. keep it in ebx.
     and     ebx, BIT20  =             &nb= sp;   ; extract NX capability bit
     shr     ebx, 9  &nbs= p;            &= nbsp;      ; shift bit to IA32_EFER.NXE[BIT11] pos= ition
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr3):
+ASM_PFX(gPatchSmmInitCr3):
     mov     cr3, eax
-o32 lgdt    [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(Smm= Startup))]
+o32 lgdt    [cs:ebp + (ASM_PFX(gcSmmInitGdtr) - ASM_PFX(Smm= Startup))]
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr4):
+ASM_PFX(gPatchSmmInitCr4):
     mov     cr4, eax
     mov     ecx, 0xc0000080 &= nbsp;           ; IA32_EF= ER MSR
     rdmsr
     or      eax, ebx &nb= sp;            =       ; set NXE bit if NX is available
     wrmsr
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr0):
+ASM_PFX(gPatchSmmInitCr0):
     mov     di, PROTECT_MODE_DS      mov     cr0, eax
     jmp     PROTECT_MODE_CS : dwor= d @32bit
 
 BITS 32
diff --git a/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h= b/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
index a9d3f271a9..ede61b956f 100644
--- a/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
+++ b/UefiCpuPkg/Library/SmmRelocationLib/InternalSmmRelocationLib.h
@@ -30,17 +30,17 @@
 #include <Guid/SmmBaseHob.h>
 #include <Register/Intel/Cpuid.h>
 #include <Register/Intel/SmramSaveStateMap.h>
 #include <Protocol/MmCpu.h>
 
-extern IA32_DESCRIPTOR  gcSmiInitGdtr;
+extern IA32_DESCRIPTOR  gcSmmInitGdtr;
 extern CONST UINT16     gcSmmInitSize;
 extern CONST UINT8      gcSmmInitTemplate[];=
 
-X86_ASSEMBLY_PATCH_LABEL  gPatchSmmCr0;
-X86_ASSEMBLY_PATCH_LABEL  gPatchSmmCr3;
-X86_ASSEMBLY_PATCH_LABEL  gPatchSmmCr4;
+X86_ASSEMBLY_PATCH_LABEL  gPatchSmmInitCr0;
+X86_ASSEMBLY_PATCH_LABEL  gPatchSmmInitCr3;
+X86_ASSEMBLY_PATCH_LABEL  gPatchSmmInitCr4;
 X86_ASSEMBLY_PATCH_LABEL  gPatchSmmInitStack;
 
 //
 // The size 0x20 must be bigger than
 // the size of template code of SmmInit. Currently,
diff --git a/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c b/UefiC= puPkg/Library/SmmRelocationLib/SmmRelocationLib.c
index 13e62b662d..ca98f06a05 100644
--- a/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c
+++ b/UefiCpuPkg/Library/SmmRelocationLib/SmmRelocationLib.c
@@ -22,11 +22,11 @@ UINTN  mNumberOfCpus    =3D 1;
 EFI_PROCESSOR_INFORMATION  *mProcessorInfo =3D NULL;
 
 //
 // IDT used during SMM Init
 //
-IA32_DESCRIPTOR  gcSmiIdtr;
+IA32_DESCRIPTOR  gcSmmInitIdtr;
 
 //
 // Smbase for all CPUs
 //
 UINT64  *mSmBase =3D NULL;
@@ -118,11 +118,11 @@ SmmInitHandler (
   UINTN   Index;
 
   //
   // Update SMM IDT entries' code segment and load IDT
   //
-  AsmWriteIdtr (&gcSmiIdtr);
+  AsmWriteIdtr (&gcSmmInitIdtr);
   ApicId =3D GetApicId ();
 
   for (Index =3D 0; Index < mNumberOfCpus; Index++) {
     if (ApicId =3D=3D (UINT32)mProcessorInfo[Index].Pr= ocessorId) {
       //
@@ -167,13 +167,13 @@ SmmRelocateBases (
   ASSERT (sizeof (BakBuf) >=3D gcSmmInitSize);
 
   //
   // Patch ASM code template with current CR0, CR3, and CR4 valu= es
   //
-  PatchInstructionX86 (gPatchSmmCr0, AsmReadCr0 (), 4);
-  PatchInstructionX86 (gPatchSmmCr3, AsmReadCr3 (), 4);
-  PatchInstructionX86 (gPatchSmmCr4, AsmReadCr4 () & (~CR4_CET_EN= ABLE), 4);
+  PatchInstructionX86 (gPatchSmmInitCr0, AsmReadCr0 (), 4);
+  PatchInstructionX86 (gPatchSmmInitCr3, AsmReadCr3 (), 4);
+  PatchInstructionX86 (gPatchSmmInitCr4, AsmReadCr4 () & (~CR4_CE= T_ENABLE), 4);
 
   U8Ptr       =3D (UINT8 *)(UINTN)= (SMM_DEFAULT_SMBASE + SMM_HANDLER_OFFSET);
   CpuStatePtr =3D (SMRAM_SAVE_STATE_MAP *)(UINTN)(SMM_DEFAULT_SM= BASE + SMRAM_SAVE_STATE_MAP_OFFSET);
 
   //
@@ -249,19 +249,19 @@ InitSmmIdt (
 
   //
   // There are 32 (not 255) entries in it since only processor    // generated exceptions will be handled.
   //
-  gcSmiIdtr.Limit =3D (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - 1; +  gcSmmInitIdtr.Limit =3D (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 32) - = 1;
 
   //
   // Allocate for IDT.
   // sizeof (UINTN) is for the PEI Services Table pointer.
   //
-  gcSmiIdtr.Base =3D (UINTN)AllocateZeroPool (gcSmiIdtr.Limit + 1 + s= izeof (UINTN));
-  ASSERT (gcSmiIdtr.Base !=3D 0);
-  gcSmiIdtr.Base +=3D sizeof (UINTN);
+  gcSmmInitIdtr.Base =3D (UINTN)AllocateZeroPool (gcSmmInitIdtr.Limit= + 1 + sizeof (UINTN));
+  ASSERT (gcSmmInitIdtr.Base !=3D 0);
+  gcSmmInitIdtr.Base +=3D sizeof (UINTN);
 
   //
   // Disable Interrupt, save InterruptState and save PEI IDT tab= le
   //
   InterruptState =3D SaveAndDisableInterrupts ();
@@ -270,21 +270,21 @@ InitSmmIdt (
   //
   // Save the PEI Services Table pointer
   // The PEI Services Table pointer will be stored in the sizeof= (UINTN) bytes
   // immediately preceding the IDT in memory.
   //
-  PeiServices         &n= bsp;            = ;             = =3D (CONST EFI_PEI_SERVICES **)(*(UINTN *)(PeiIdtr.Base - sizeof (UINTN)));=
-  (*(UINTN *)(gcSmiIdtr.Base - sizeof (UINTN))) =3D (UINTN)PeiService= s;
+  PeiServices         &n= bsp;            = ;            &n= bsp;    =3D (CONST EFI_PEI_SERVICES **)(*(UINTN *)(PeiIdtr.B= ase - sizeof (UINTN)));
+  (*(UINTN *)(gcSmmInitIdtr.Base - sizeof (UINTN))) =3D (UINTN)PeiSer= vices;
 
   //
   // Load SMM temporary IDT table
   //
-  AsmWriteIdtr (&gcSmiIdtr);
+  AsmWriteIdtr (&gcSmmInitIdtr);
 
   //
   // Setup SMM default exception handlers, SMM IDT table
-  // will be updated and saved in gcSmiIdtr
+  // will be updated and saved in gcSmmInitIdtr
   //
   Status =3D InitializeCpuExceptionHandlers (NULL);
   ASSERT_EFI_ERROR (Status);
 
   //
diff --git a/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm b/UefiCpu= Pkg/Library/SmmRelocationLib/X64/SmmInit.nasm
index c790ad7ad8..8288b723c4 100644
--- a/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm
+++ b/UefiCpuPkg/Library/SmmRelocationLib/X64/SmmInit.nasm
@@ -16,15 +16,15 @@
 
 extern ASM_PFX(SmmInitHandler)
 extern ASM_PFX(mRebasedFlag)
 extern ASM_PFX(mSmmRelocationOriginalAddress)
 
-global ASM_PFX(gPatchSmmCr3)
-global ASM_PFX(gPatchSmmCr4)
-global ASM_PFX(gPatchSmmCr0)
+global ASM_PFX(gPatchSmmInitCr3)
+global ASM_PFX(gPatchSmmInitCr4)
+global ASM_PFX(gPatchSmmInitCr0)
 global ASM_PFX(gPatchSmmInitStack)
-global ASM_PFX(gcSmiInitGdtr)
+global ASM_PFX(gcSmmInitGdtr)
 global ASM_PFX(gcSmmInitSize)
 global ASM_PFX(gcSmmInitTemplate)
 global ASM_PFX(gPatchRebasedFlagAddr32)
 global ASM_PFX(gPatchSmmRelocationOriginalAddressPtr32)
 
@@ -82,11 +82,11 @@ CodeSeg64:
             DB=       0x9b
             DB=       0xaf      &nbs= p;         ; LimitHigh
             DB=       0       &= nbsp;           ; BaseHig= h
 GDT_SIZE equ $ -   NullSeg
 
-ASM_PFX(gcSmiInitGdtr):
+ASM_PFX(gcSmmInitGdtr):
     DW      GDT_SIZE - 1
     DQ      NullSeg
 
 
     DEFAULT REL
@@ -98,15 +98,15 @@ BITS 16
 ASM_PFX(SmmStartup):
     mov     eax, 0x80000001 &= nbsp;           ; read ca= pability
     cpuid
     mov     ebx, edx  &n= bsp;            = ;     ; rdmsr will change edx. keep it in ebx.
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr3):
+ASM_PFX(gPatchSmmInitCr3):
     mov     cr3, eax
-o32 lgdt    [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - ASM_PFX(Smm= Startup))]
+o32 lgdt    [cs:ebp + (ASM_PFX(gcSmmInitGdtr) - ASM_PFX(Smm= Startup))]
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr4):
+ASM_PFX(gPatchSmmInitCr4):
     or      ah,  2 =             &nb= sp;        ; enable XMM registers access=
     mov     cr4, eax
     mov     ecx, 0xc0000080 &= nbsp;           ; IA32_EF= ER MSR
     rdmsr
     or      ah, BIT0 &nb= sp;            =       ; set LME bit
@@ -114,11 +114,11 @@ ASM_PFX(gPatchSmmCr4):
     jz      .1
     or      ah, BIT3 &nb= sp;            =       ; set NXE bit
 .1:
     wrmsr
     mov     eax, strict dword 0&nb= sp;        ; source operand will be patc= hed
-ASM_PFX(gPatchSmmCr0):
+ASM_PFX(gPatchSmmInitCr0):
     mov     cr0, eax  &n= bsp;            = ;     ; enable protected mode & paging
     jmp     LONG_MODE_CS : dword 0=       ; offset will be patched to @LongMode
 @PatchLongModeOffset:
 
 BITS 64
--
2.16.2.windows.1

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#117960) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_MN6PR11MB824463EC0258869D6EADDEAF8C0E2MN6PR11MB8244namp_--