From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=michael.d.kinney@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA6CF22364885 for ; Tue, 30 Jan 2018 12:25:44 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2018 12:31:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,436,1511856000"; d="scan'208";a="15644520" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by fmsmga002.fm.intel.com with ESMTP; 30 Jan 2018 12:31:19 -0800 Received: from orsmsx114.amr.corp.intel.com (10.22.240.10) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 30 Jan 2018 12:31:18 -0800 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.97]) by ORSMSX114.amr.corp.intel.com ([169.254.8.245]) with mapi id 14.03.0319.002; Tue, 30 Jan 2018 12:31:18 -0800 From: "Kinney, Michael D" To: Laszlo Ersek , edk2-devel-01 , "Kinney, Michael D" CC: "Ni, Ruiyu" , Paolo Bonzini , "Yao, Jiewen" , "Dong, Eric" Thread-Topic: [edk2] [PATCH 1/3] UefiCpuPkg/PiSmmCpuDxeSmm: update comments in IA32 SmmStartup() Thread-Index: AQHTmd/MCkuvve09PEGT8wX9DIo2RaOMqXnggACV9oD//33u0A== Date: Tue, 30 Jan 2018 20:31:18 +0000 Message-ID: References: <20180130153348.31992-1-lersek@redhat.com> <20180130153348.31992-2-lersek@redhat.com> <31138ce7-0637-a755-ec57-e36ab812f259@redhat.com> In-Reply-To: <31138ce7-0637-a755-ec57-e36ab812f259@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: Re: [PATCH 1/3] UefiCpuPkg/PiSmmCpuDxeSmm: update comments in IA32 SmmStartup() X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jan 2018 20:25:45 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Laszlo, We have already used this technique in other NASM files to remove DBs. Let us know if you have suggestions on how to make the C code that performs the patches easier to read and=20 maintain. Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] > On Behalf Of Laszlo Ersek > Sent: Tuesday, January 30, 2018 10:17 AM > To: Kinney, Michael D ; edk2- > devel-01 > Cc: Ni, Ruiyu ; Paolo Bonzini > ; Yao, Jiewen > ; Dong, Eric > Subject: Re: [edk2] [PATCH 1/3] > UefiCpuPkg/PiSmmCpuDxeSmm: update comments in IA32 > SmmStartup() >=20 > On 01/30/18 18:22, Kinney, Michael D wrote: > > Laszlo, > > > > The DBs can be removed if the label is moved after > > the instruction and the patch is done to the label > > minus the size of the patch value. >=20 > Indeed I haven't thought of this. >=20 > If I understand correctly, it means >=20 > extern UINT8 gSmmCr0; >=20 > *(UINT32*)(&gSmmCr0 - sizeof (UINT32)) =3D > (UINT32)AsmReadCr0 (); >=20 > TBH, the DB feels less ugly to me than this :) >=20 > Still, if you think it would be an acceptable price to > pay for removing > the remaining DBs, I can respin. >=20 > Thanks > Laszlo >=20 > >> -----Original Message----- > >> From: edk2-devel [mailto:edk2-devel- > bounces@lists.01.org] > >> On Behalf Of Laszlo Ersek > >> Sent: Tuesday, January 30, 2018 7:34 AM > >> To: edk2-devel-01 > >> Cc: Ni, Ruiyu ; Yao, Jiewen > >> ; Dong, Eric > ; > >> Paolo Bonzini > >> Subject: [edk2] [PATCH 1/3] UefiCpuPkg/PiSmmCpuDxeSmm: > >> update comments in IA32 SmmStartup() > >> > >> The gSmmCr3, gSmmCr4, gSmmCr0 and gSmmJmpAddr global > >> variables are used > >> for patching assembly instructions, thus we can never > >> remove the DB > >> encodings for those instructions. At least we should > add > >> the intended > >> meanings in comments. > >> > >> This patch only changes comments. > >> > >> Cc: Eric Dong > >> Cc: Jian J Wang > >> Cc: Jiewen Yao > >> Cc: Paolo Bonzini > >> Cc: Ruiyu Ni > >> Contributed-under: TianoCore Contribution Agreement > 1.1 > >> Signed-off-by: Laszlo Ersek > >> --- > >> UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm | 8 ++++- > --- > >> 1 file changed, 4 insertions(+), 4 deletions(-) > >> > >> diff --git > a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm > >> b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm > >> index e96dd8d2392a..08534dba64b7 100644 > >> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm > >> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/Ia32/SmmInit.nasm > >> @@ -44,34 +44,34 @@ global ASM_PFX(SmmStartup) > >> ASM_PFX(SmmStartup): > >> DB 0x66 > >> mov eax, 0x80000001 ; read > >> capability > >> cpuid > >> DB 0x66 > >> mov ebx, edx ; rdmsr will > >> change edx. keep it in ebx. > >> - DB 0x66, 0xb8 > >> + DB 0x66, 0xb8 ; mov eax, > imm32 > >> ASM_PFX(gSmmCr3): DD 0 > >> mov cr3, eax > >> DB 0x67, 0x66 > >> lgdt [cs:ebp + (ASM_PFX(gcSmiInitGdtr) - > >> ASM_PFX(SmmStartup))] > >> - DB 0x66, 0xb8 > >> + DB 0x66, 0xb8 ; mov eax, > imm32 > >> ASM_PFX(gSmmCr4): DD 0 > >> mov cr4, eax > >> DB 0x66 > >> mov ecx, 0xc0000080 ; IA32_EFER > MSR > >> rdmsr > >> DB 0x66 > >> test ebx, BIT20 ; check NXE > >> capability > >> jz .1 > >> or ah, BIT3 ; set NXE bit > >> wrmsr > >> .1: > >> - DB 0x66, 0xb8 > >> + DB 0x66, 0xb8 ; mov eax, > imm32 > >> ASM_PFX(gSmmCr0): DD 0 > >> DB 0xbf, PROTECT_MODE_DS, 0 ; mov di, > >> PROTECT_MODE_DS > >> mov cr0, eax > >> - DB 0x66, 0xea ; jmp far > >> [ptr48] > >> + DB 0x66, 0xea ; jmp far > >> [ptr48] > >> ASM_PFX(gSmmJmpAddr): > >> DD @32bit > >> DW PROTECT_MODE_CS > >> @32bit: > >> mov ds, edi > >> mov es, edi > >> -- > >> 2.14.1.3.gb7cf6e02401b > >> > >> > >> _______________________________________________ > >> edk2-devel mailing list > >> edk2-devel@lists.01.org > >> https://lists.01.org/mailman/listinfo/edk2-devel >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel