From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by mx.groups.io with SMTP id smtpd.web11.49521.1680250010610609584 for ; Fri, 31 Mar 2023 01:06:51 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@posteo.de header.s=2017 header.b=ehcazdMO; spf=pass (domain: posteo.de, ip: 185.67.36.66, mailfrom: mhaeuser@posteo.de) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 40155240117 for ; Fri, 31 Mar 2023 10:06:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1680250007; bh=n8PwPqzV3PO5uhs4OuboHXDGhkB0LaV4GtadDbIgXco=; h=From:Subject:Date:Cc:To:From; b=ehcazdMOrzjj5aujX1CQevoBv23Ux44em3xr83bEN9J6zZmgQzAvWrpkVlyxZqvBN QPlTSzvJrqlaYkf91V6daLrs2zbSVdVxbw3J7NR53FswlYhagW0gRzyoa4wxsTQaPQ 4dirZf8UNPR7nkUpRXaHj0rXPfvORaN4RSP5bO1ESnO7o5dzKVoXChcZYzgDnz0A/x RCloui7kNd3Bf9Bz8GCzxEUwXi++FXlwPnE2yPg1B6gOm6/M76ewdW+0hlOnHjw16q eMGzgHa4tkMBYvOqjHCogBrtkKI0VC5KDcLoNPPZKd7WOcrJkcptXV3d/Us/tkGlog kDzR1DDl+hvTA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4PntD53Ss0z9rxG; Fri, 31 Mar 2023 10:06:45 +0200 (CEST) From: =?UTF-8?B?TWFydmluIEjDpHVzZXI=?= Mime-Version: 1.0 (1.0) Subject: Re: [edk2-devel] [RFT PATCH v2 4/6] UefiCpuPkg/CpuExceptionHandlerLib: Remove needless runtime fixups Date: Fri, 31 Mar 2023 08:06:45 +0000 Message-Id: References: Cc: devel@edk2.groups.io, Ard Biesheuvel In-Reply-To: To: "Ni, Ray" Content-Type: multipart/alternative; boundary=Apple-Mail-A77A4F56-E909-4FEC-A953-3E90DB05E0A0 Content-Transfer-Encoding: 7bit --Apple-Mail-A77A4F56-E909-4FEC-A953-3E90DB05E0A0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ray, Definitely - this is just an optimisation =E2=80=9Cwhile we=E2=80=99re at it= =E2=80=9C, nothing urgent. Best regards, Marvin > On 31. Mar 2023, at 07:09, Ni, Ray wrote: >=20 > =EF=BB=BF >=20 > diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5Exception= H=3D > andlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHa= n=3D > dlerAsm.nasm > similarity index 92% > rename from UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionH= a=3D > ndlerAsm.nasm > rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAs= m=3D > .nasm > index 957478574253e619..10af4cfcdb6b1ea2 100644 > --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandler= A=3D > sm.nasm > +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.na= sm > @@ -59,7 +59,7 @@ AsmIdtVectorBegin: > %rep 256=3D0D > push strict dword %[Vector] ; This instruction pushes sign-extended=3D > 8-byte value on stack=3D0D > push rax=3D0D > - mov rax, strict qword 0 ; mov rax, ASM_PFX(CommonInterruptE=3D > ntry)=3D0D > + mov rax, ASM_PFX(CommonInterruptEntry)=3D0D > I'm fairly certain this can be a relative reference, as the code doesn't s= eem to be copied away (as opposed to HookAfterStubHeaderBegin). If true, thi= s would save 256 relocs, which sounds quite nice. Would you mind verifying? T= hanks! >=20 > Marvin, >=20 > You are right the mov can be replaced with =E2=80=9Clea=E2=80=9D. But, we n= eed to analyze if using lea, the size of each idt stub is fixed or variant (= today the size is fixed, so StubSize =3D TotalSize / 256). >=20 > Another thing we need to evaluate is the impact to =E2=80=9CHook after=E2=80= =9D feature because =E2=80=9Chook after=E2=80=9D stub is very like the idt s= tub. >=20 > I think we can firstly use Ard=E2=80=99s solution. Later to evaluate to el= iminate unnecessary absolute reference. >=20 > Thanks, >=20 > Ray --Apple-Mail-A77A4F56-E909-4FEC-A953-3E90DB05E0A0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Hi R= ay,

Definitely - this is ju= st an optimisation =E2=80=9Cwhile we=E2=80=99re at it=E2=80=9C, nothing urge= nt.

Best regards,
Marvin

On 3= 1. Mar 2023, at 07:09, Ni, Ray <ray.ni@intel.com> wrote:

=EF=BB=BF


diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionH=3D=
andlerAsm.nasm b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHan=3D=
dlerAsm.nasm
similarity index 92%
rename from UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHa=3D=
ndlerAsm.nasm
rename to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm=3D=
.nasm
index 957478574253e619..10af4cfcdb6b1ea2 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerA=3D=
sm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm=
@@ -59,7 +59,7 @@ AsmIdtVectorBegin:
%rep 256=3D0D
push strict dword %[Vector] ; This instruction pushes sign-extended=3D
8-byte value on stack=3D0D
push rax=3D0D
- mov rax, strict qword 0 ; mov rax, ASM_PFX(CommonInterruptE=3D
ntry)=3D0D
+ mov rax, ASM_PFX(CommonInterruptEntry)=3D0D

I'm fairly certain this can be a relative refe= rence, as the code doesn't seem to be copied away (as opposed to HookAf= terStubHeaderBegin). If true, this would save 256 relocs, which sounds quite= nice. Would you mind verifying? Thanks!

Marvin,

You are right the mov can be replaced with =E2=80=9Clea=E2=80=9D. But, we= need to analyze if using lea, the size of each idt stub is fixed or variant= (today the size is fixed, so StubSize =3D TotalSize / 256).

Another thing we need to evaluate is the impact to =E2=80=9CHook after=E2= =80=9D feature because =E2=80=9Chook after=E2=80=9D stub is very like the id= t stub.

I think we can firstly use Ard=E2=80=99s solution. Later to evaluate to e= liminate unnecessary absolute reference.

Thanks,

Ray

= --Apple-Mail-A77A4F56-E909-4FEC-A953-3E90DB05E0A0--