BaseTools/Conf/tools_def.template | 2 +- OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - OvmfPkg/Microvm/MicrovmX64.dsc | 4 - OvmfPkg/OvmfPkgIa32.dsc | 4 - OvmfPkg/OvmfPkgIa32X64.dsc | 4 - OvmfPkg/OvmfPkgX64.dsc | 4 - OvmfPkg/OvmfXen.dsc | 4 - UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- UefiCpuPkg/UefiCpuPkg.dsc | 7 -- 18 files changed, 133 insertions(+), 232 deletions(-) rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
We have a special version of CpuExceptionHandlerLib for XCODE5, whose linker (LLD) does not permit absolute symbol references in read-only sections. Instead of fixing this up at runtime for all toolchains (which is done by writing the fixed up values to the .text section, which we'd prefer to avoid), tweak the SEC/PEI version so it does not need this, and update the remaining versions to only incorporate this logic when using the XCODE toolchain. Changes since v3: - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI version of the NASM source file - Improve commit logs Changes since v2: - As Marvin points out, using '-read_only_relocs suppress' with the X64 XCODE linker is a terrible idea, as it corrupts the resulting PE binaries, so instead, let's do the following: . tweak the SEC/PEI version of the library so the relocs are emitted into .data when using XCODE; . tweak the other versions so the runtime fixups are only done when using XCODE - add acks from Jiewen and Ray Changes since v1: - pass linker switches to permit absolute relocations in read-only regions, and keep all code in .text Cc: "Ni, Ray" <ray.ni@intel.com> Cc: Andrew Fish <afish@apple.com> Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> Cc: Rebecca Cran <rebecca@bsdio.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Marvin Häuser <mhaeuser@posteo.de> Ard Biesheuvel (6): BaseTools/tools_def CLANGDWARF: Permit text relocations UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm component UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only OvmfPkg: Drop special Xcode5 version of exception handler library UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version BaseTools/Conf/tools_def.template | 2 +- OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - OvmfPkg/Microvm/MicrovmX64.dsc | 4 - OvmfPkg/OvmfPkgIa32.dsc | 4 - OvmfPkg/OvmfPkgIa32X64.dsc | 4 - OvmfPkg/OvmfPkgX64.dsc | 4 - OvmfPkg/OvmfXen.dsc | 4 - UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- UefiCpuPkg/UefiCpuPkg.dsc | 7 -- 18 files changed, 133 insertions(+), 232 deletions(-) rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni -- 2.39.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102405): https://edk2.groups.io/g/devel/message/102405 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
FWIW, Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> > On 3. Apr 2023, at 16:29, Ard Biesheuvel <ardb@kernel.org> wrote: > > We have a special version of CpuExceptionHandlerLib for XCODE5, whose > linker (LLD) does not permit absolute symbol references in read-only > sections. > > Instead of fixing this up at runtime for all toolchains (which is done > by writing the fixed up values to the .text section, which we'd prefer > to avoid), tweak the SEC/PEI version so it does not need this, and > update the remaining versions to only incorporate this logic when using > the XCODE toolchain. > > Changes since v3: > - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI version > of the NASM source file > - Improve commit logs > > Changes since v2: > - As Marvin points out, using '-read_only_relocs suppress' with the X64 > XCODE linker is a terrible idea, as it corrupts the resulting PE > binaries, so instead, let's do the following: > . tweak the SEC/PEI version of the library so the relocs are emitted > into .data when using XCODE; > . tweak the other versions so the runtime fixups are only done when > using XCODE > - add acks from Jiewen and Ray > > Changes since v1: > - pass linker switches to permit absolute relocations in read-only > regions, and keep all code in .text > > Cc: "Ni, Ray" <ray.ni@intel.com> > Cc: Andrew Fish <afish@apple.com> > Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> > Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> > Cc: Rebecca Cran <rebecca@bsdio.com> > Cc: Tom Lendacky <thomas.lendacky@amd.com> > Cc: Marvin Häuser <mhaeuser@posteo.de> > > Ard Biesheuvel (6): > BaseTools/tools_def CLANGDWARF: Permit text relocations > UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version > UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm > component > UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only > OvmfPkg: Drop special Xcode5 version of exception handler library > UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version > > BaseTools/Conf/tools_def.template | 2 +- > OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - > OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - > OvmfPkg/Microvm/MicrovmX64.dsc | 4 - > OvmfPkg/OvmfPkgIa32.dsc | 4 - > OvmfPkg/OvmfPkgIa32X64.dsc | 4 - > OvmfPkg/OvmfPkgX64.dsc | 4 - > OvmfPkg/OvmfXen.dsc | 4 - > UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- > UefiCpuPkg/UefiCpuPkg.dsc | 7 -- > 18 files changed, 133 insertions(+), 232 deletions(-) > rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni > > -- > 2.39.2 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102471): https://edk2.groups.io/g/devel/message/102471 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Thanks all Ray, any comments on this version? Thanks. Liming, Rebecca, any comments on the BaseTools changes? On Tue, 4 Apr 2023 at 09:57, Marvin Häuser <mhaeuser@posteo.de> wrote: > > FWIW, Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> > > > On 3. Apr 2023, at 16:29, Ard Biesheuvel <ardb@kernel.org> wrote: > > > > We have a special version of CpuExceptionHandlerLib for XCODE5, whose > > linker (LLD) does not permit absolute symbol references in read-only > > sections. > > > > Instead of fixing this up at runtime for all toolchains (which is done > > by writing the fixed up values to the .text section, which we'd prefer > > to avoid), tweak the SEC/PEI version so it does not need this, and > > update the remaining versions to only incorporate this logic when using > > the XCODE toolchain. > > > > Changes since v3: > > - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI version > > of the NASM source file > > - Improve commit logs > > > > Changes since v2: > > - As Marvin points out, using '-read_only_relocs suppress' with the X64 > > XCODE linker is a terrible idea, as it corrupts the resulting PE > > binaries, so instead, let's do the following: > > . tweak the SEC/PEI version of the library so the relocs are emitted > > into .data when using XCODE; > > . tweak the other versions so the runtime fixups are only done when > > using XCODE > > - add acks from Jiewen and Ray > > > > Changes since v1: > > - pass linker switches to permit absolute relocations in read-only > > regions, and keep all code in .text > > > > Cc: "Ni, Ray" <ray.ni@intel.com> > > Cc: Andrew Fish <afish@apple.com> > > Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> > > Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> > > Cc: Rebecca Cran <rebecca@bsdio.com> > > Cc: Tom Lendacky <thomas.lendacky@amd.com> > > Cc: Marvin Häuser <mhaeuser@posteo.de> > > > > Ard Biesheuvel (6): > > BaseTools/tools_def CLANGDWARF: Permit text relocations > > UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version > > UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm > > component > > UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only > > OvmfPkg: Drop special Xcode5 version of exception handler library > > UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version > > > > BaseTools/Conf/tools_def.template | 2 +- > > OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - > > OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - > > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - > > OvmfPkg/Microvm/MicrovmX64.dsc | 4 - > > OvmfPkg/OvmfPkgIa32.dsc | 4 - > > OvmfPkg/OvmfPkgIa32X64.dsc | 4 - > > OvmfPkg/OvmfPkgX64.dsc | 4 - > > OvmfPkg/OvmfXen.dsc | 4 - > > UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- > > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- > > UefiCpuPkg/UefiCpuPkg.dsc | 7 -- > > 18 files changed, 133 insertions(+), 232 deletions(-) > > rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) > > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf > > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni > > > > -- > > 2.39.2 > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102472): https://edk2.groups.io/g/devel/message/102472 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Reviewed. Merged. Thank you Ard! > -----Original Message----- > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ard > Biesheuvel > Sent: Tuesday, April 4, 2023 5:46 PM > To: devel@edk2.groups.io; mhaeuser@posteo.de; Ni, Ray <ray.ni@intel.com> > Cc: Andrew Fish <afish@apple.com>; Kinney, Michael D > <michael.d.kinney@intel.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; > Rebecca Cran <rebecca@bsdio.com>; Tom Lendacky > <thomas.lendacky@amd.com>; Gao, Liming <gaoliming@byosoft.com.cn> > Subject: Re: [edk2-devel] [PATCH v4 0/6] UefiCpuPkg, OvmfPkg: Simplify > CpuExceptionHandlerLib > > Thanks all > > Ray, any comments on this version? Thanks. > > Liming, Rebecca, any comments on the BaseTools changes? > > > > On Tue, 4 Apr 2023 at 09:57, Marvin Häuser <mhaeuser@posteo.de> wrote: > > > > FWIW, Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> > > > > > On 3. Apr 2023, at 16:29, Ard Biesheuvel <ardb@kernel.org> wrote: > > > > > > We have a special version of CpuExceptionHandlerLib for XCODE5, whose > > > linker (LLD) does not permit absolute symbol references in read-only > > > sections. > > > > > > Instead of fixing this up at runtime for all toolchains (which is done > > > by writing the fixed up values to the .text section, which we'd prefer > > > to avoid), tweak the SEC/PEI version so it does not need this, and > > > update the remaining versions to only incorporate this logic when using > > > the XCODE toolchain. > > > > > > Changes since v3: > > > - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI > version > > > of the NASM source file > > > - Improve commit logs > > > > > > Changes since v2: > > > - As Marvin points out, using '-read_only_relocs suppress' with the X64 > > > XCODE linker is a terrible idea, as it corrupts the resulting PE > > > binaries, so instead, let's do the following: > > > . tweak the SEC/PEI version of the library so the relocs are emitted > > > into .data when using XCODE; > > > . tweak the other versions so the runtime fixups are only done when > > > using XCODE > > > - add acks from Jiewen and Ray > > > > > > Changes since v1: > > > - pass linker switches to permit absolute relocations in read-only > > > regions, and keep all code in .text > > > > > > Cc: "Ni, Ray" <ray.ni@intel.com> > > > Cc: Andrew Fish <afish@apple.com> > > > Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> > > > Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> > > > Cc: Rebecca Cran <rebecca@bsdio.com> > > > Cc: Tom Lendacky <thomas.lendacky@amd.com> > > > Cc: Marvin Häuser <mhaeuser@posteo.de> > > > > > > Ard Biesheuvel (6): > > > BaseTools/tools_def CLANGDWARF: Permit text relocations > > > UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version > > > UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm > > > component > > > UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only > > > OvmfPkg: Drop special Xcode5 version of exception handler library > > > UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version > > > > > > BaseTools/Conf/tools_def.template > | 2 +- > > > OvmfPkg/AmdSev/AmdSevX64.dsc > | 4 - > > > OvmfPkg/CloudHv/CloudHvX64.dsc > | 4 - > > > OvmfPkg/IntelTdx/IntelTdxX64.dsc > | 4 - > > > OvmfPkg/Microvm/MicrovmX64.dsc > | 4 - > > > OvmfPkg/OvmfPkgIa32.dsc | > 4 - > > > OvmfPkg/OvmfPkgIa32X64.dsc > | 4 - > > > OvmfPkg/OvmfPkgX64.dsc | > 4 - > > > OvmfPkg/OvmfXen.dsc | > 4 - > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.in > f | 5 +- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf > | 4 +- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib > .inf | 4 +- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.i > nf | 4 +- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nas > m | 116 +++++++++++++++++--- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandler > Asm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHa > ndlerLib.inf | 65 ----------- > > > > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHa > ndlerLib.uni | 18 --- > > > UefiCpuPkg/UefiCpuPkg.dsc | > 7 -- > > > 18 files changed, 133 insertions(+), 232 deletions(-) > > > rename > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandler > Asm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) > > > delete mode 100644 > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHa > ndlerLib.inf > > > delete mode 100644 > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHa > ndlerLib.uni > > > > > > -- > > > 2.39.2 > > > > > > > > > > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102601): https://edk2.groups.io/g/devel/message/102601 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/3901457/1787277/102458076/xyzzy [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Sorry for the delay. I've just sent my reviewed-by. On 4/4/23 3:46 AM, Ard Biesheuvel wrote: > Thanks all > > Ray, any comments on this version? Thanks. > > Liming, Rebecca, any comments on the BaseTools changes? > > > > On Tue, 4 Apr 2023 at 09:57, Marvin Häuser <mhaeuser@posteo.de> wrote: >> FWIW, Reviewed-by: Marvin Häuser <mhaeuser@posteo.de> >> >>> On 3. Apr 2023, at 16:29, Ard Biesheuvel <ardb@kernel.org> wrote: >>> >>> We have a special version of CpuExceptionHandlerLib for XCODE5, whose >>> linker (LLD) does not permit absolute symbol references in read-only >>> sections. >>> >>> Instead of fixing this up at runtime for all toolchains (which is done >>> by writing the fixed up values to the .text section, which we'd prefer >>> to avoid), tweak the SEC/PEI version so it does not need this, and >>> update the remaining versions to only incorporate this logic when using >>> the XCODE toolchain. >>> >>> Changes since v3: >>> - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI version >>> of the NASM source file >>> - Improve commit logs >>> >>> Changes since v2: >>> - As Marvin points out, using '-read_only_relocs suppress' with the X64 >>> XCODE linker is a terrible idea, as it corrupts the resulting PE >>> binaries, so instead, let's do the following: >>> . tweak the SEC/PEI version of the library so the relocs are emitted >>> into .data when using XCODE; >>> . tweak the other versions so the runtime fixups are only done when >>> using XCODE >>> - add acks from Jiewen and Ray >>> >>> Changes since v1: >>> - pass linker switches to permit absolute relocations in read-only >>> regions, and keep all code in .text >>> >>> Cc: "Ni, Ray" <ray.ni@intel.com> >>> Cc: Andrew Fish <afish@apple.com> >>> Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> >>> Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> >>> Cc: Rebecca Cran <rebecca@bsdio.com> >>> Cc: Tom Lendacky <thomas.lendacky@amd.com> >>> Cc: Marvin Häuser <mhaeuser@posteo.de> >>> >>> Ard Biesheuvel (6): >>> BaseTools/tools_def CLANGDWARF: Permit text relocations >>> UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version >>> UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm >>> component >>> UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only >>> OvmfPkg: Drop special Xcode5 version of exception handler library >>> UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version >>> >>> BaseTools/Conf/tools_def.template | 2 +- >>> OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - >>> OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - >>> OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - >>> OvmfPkg/Microvm/MicrovmX64.dsc | 4 - >>> OvmfPkg/OvmfPkgIa32.dsc | 4 - >>> OvmfPkg/OvmfPkgIa32X64.dsc | 4 - >>> OvmfPkg/OvmfPkgX64.dsc | 4 - >>> OvmfPkg/OvmfXen.dsc | 4 - >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- >>> UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- >>> UefiCpuPkg/UefiCpuPkg.dsc | 7 -- >>> 18 files changed, 133 insertions(+), 232 deletions(-) >>> rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) >>> delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf >>> delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni >>> >>> -- >>> 2.39.2 >>> >> >> >> >> >> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102560): https://edk2.groups.io/g/devel/message/102560 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
On 4/3/23 09:29, Ard Biesheuvel via groups.io wrote: > We have a special version of CpuExceptionHandlerLib for XCODE5, whose > linker (LLD) does not permit absolute symbol references in read-only > sections. > > Instead of fixing this up at runtime for all toolchains (which is done > by writing the fixed up values to the .text section, which we'd prefer > to avoid), tweak the SEC/PEI version so it does not need this, and > update the remaining versions to only incorporate this logic when using > the XCODE toolchain. > > Changes since v3: > - Add another patch to move PeiCpuExceptionHandlerLib to SEC/PEI version > of the NASM source file > - Improve commit logs > > Changes since v2: > - As Marvin points out, using '-read_only_relocs suppress' with the X64 > XCODE linker is a terrible idea, as it corrupts the resulting PE > binaries, so instead, let's do the following: > . tweak the SEC/PEI version of the library so the relocs are emitted > into .data when using XCODE; > . tweak the other versions so the runtime fixups are only done when > using XCODE > - add acks from Jiewen and Ray > > Changes since v1: > - pass linker switches to permit absolute relocations in read-only > regions, and keep all code in .text > > Cc: "Ni, Ray" <ray.ni@intel.com> > Cc: Andrew Fish <afish@apple.com> > Cc: "Kinney, Michael D" <michael.d.kinney@intel.com> > Cc: "Liu, Zhiguang" <zhiguang.liu@intel.com> > Cc: Rebecca Cran <rebecca@bsdio.com> > Cc: Tom Lendacky <thomas.lendacky@amd.com> > Cc: Marvin Häuser <mhaeuser@posteo.de> Validated against SEV-ES (which was part of the original reason for the split out) and SEV-SNP guests. Both guest types boot successfully. Tested-by: Tom Lendacky <thomas.lendacky@amd.com> > > Ard Biesheuvel (6): > BaseTools/tools_def CLANGDWARF: Permit text relocations > UefiCpuPkg/CpuExceptionHandlerLib: Use single SEC/PEI version > UefiCpuPkg/PeiCpuExceptionHandlerLib: Use SEC/PEI specific asm > component > UefiCpuPkg/CpuExceptionHandlerLib: Make runtime fixups XCODE-only > OvmfPkg: Drop special Xcode5 version of exception handler library > UefiCpuPkg/CpuExceptionHandlerLib: Drop special XCODE5 version > > BaseTools/Conf/tools_def.template | 2 +- > OvmfPkg/AmdSev/AmdSevX64.dsc | 4 - > OvmfPkg/CloudHv/CloudHvX64.dsc | 4 - > OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 - > OvmfPkg/Microvm/MicrovmX64.dsc | 4 - > OvmfPkg/OvmfPkgIa32.dsc | 4 - > OvmfPkg/OvmfPkgIa32X64.dsc | 4 - > OvmfPkg/OvmfPkgX64.dsc | 4 - > OvmfPkg/OvmfXen.dsc | 4 - > UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf | 5 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf | 4 +- > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm | 116 +++++++++++++++++--- > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} | 108 +++--------------- > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf | 65 ----------- > UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni | 18 --- > UefiCpuPkg/UefiCpuPkg.dsc | 7 -- > 18 files changed, 133 insertions(+), 232 deletions(-) > rename UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/{Xcode5ExceptionHandlerAsm.nasm => SecPeiExceptionHandlerAsm.nasm} (70%) > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf > delete mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#102442): https://edk2.groups.io/g/devel/message/102442 Mute This Topic: https://groups.io/mt/98036435/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.