public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Lendacky, Thomas" <thomas.lendacky@amd.com>
To: devel@edk2.groups.io, lersek@redhat.com
Cc: Jordan Justen <jordan.l.justen@intel.com>,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>,
	Liming Gao <liming.gao@intel.com>,
	Eric Dong <eric.dong@intel.com>, Ray Ni <ray.ni@intel.com>,
	Anthony Perard <anthony.perard@citrix.com>,
	Julien Grall <julien@xen.org>,
	Brijesh Singh <brijesh.singh@amd.com>,
	Andrew Fish <afish@apple.com>
Subject: Re: [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific
Date: Wed, 6 May 2020 15:37:30 -0500	[thread overview]
Message-ID: <7086eef3-cf00-6254-65b4-bf982b0f4f9e@amd.com> (raw)
In-Reply-To: <5d973f64-22fa-6f83-7b1b-cb97a7efe400@redhat.com>

On 5/6/20 2:01 PM, Laszlo Ersek via groups.io wrote:
> On 05/06/20 18:33, Tom Lendacky wrote:
>> BZ: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340&amp;data=02%7C01%7Cthomas.lendacky%40amd.com%7C3c47ab80a1554f27afd608d7f1eff6e8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243885258646451&amp;sdata=Xh7E1EB%2B1oOCtc2jgtJ8lsjgcwxgswIbgpL4%2BUwpoOw%3D&amp;reserved=0
>>
>> Commit 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass
>> XCODE5 tool chain") introduced binary patching into the exception handling
>> support. CPU exception handling is allowed during SEC and this results in
>> binary patching of flash, which should not be done.
>>
>> Separate the changes from commit 2db0ccc2d7fe into an XCODE5 toolchain
>> specific file, Xcode5ExceptionHandlerAsm.nasm, and create a new SEC INF
>> file for the XCODE5 version of CpuExceptionHandlerLib.
>>
>> Since binary patching is allowed when running outside of flash, switch
>> the Dxe, Pei and Smm versions of the CpuExceptionHandlerLib over to use
>> the Xcode5ExceptionHandlerAsm.nasm file to retain current functionality.
>>
>> Cc: Eric Dong <eric.dong@intel.com>
>> Cc: Ray Ni <ray.ni@intel.com>
>> Cc: Laszlo Ersek <lersek@redhat.com>
>> Cc: Liming Gao <liming.gao@intel.com>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>> ---
>>   UefiCpuPkg/UefiCpuPkg.dsc                     |   5 +
>>   .../DxeCpuExceptionHandlerLib.inf             |   2 +-
>>   .../PeiCpuExceptionHandlerLib.inf             |   2 +-
>>   .../SmmCpuExceptionHandlerLib.inf             |   2 +-
>>   .../Xcode5SecPeiCpuExceptionHandlerLib.inf    |  54 +++
>>   .../X64/Xcode5ExceptionHandlerAsm.nasm        | 396 ++++++++++++++++++
>>   .../Xcode5SecPeiCpuExceptionHandlerLib.uni    |  17 +
>>   7 files changed, 475 insertions(+), 3 deletions(-)
>>   create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
>>   create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/Xcode5ExceptionHandlerAsm.nasm
>>   create mode 100644 UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
>>
>> diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
>> index d28cb5cccb52..264e5a787bce 100644
>> --- a/UefiCpuPkg/UefiCpuPkg.dsc
>> +++ b/UefiCpuPkg/UefiCpuPkg.dsc
>> @@ -59,7 +59,11 @@ [LibraryClasses]
>>   
>>   [LibraryClasses.common.SEC]
>>     PlatformSecLib|UefiCpuPkg/Library/PlatformSecLibNull/PlatformSecLibNull.inf
>> +!if $(TOOL_CHAIN_TAG) == "XCODE5"
>> +  CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
>> +!else
>>     CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
>> +!endif
>>     HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
>>     PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>>     MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
>> @@ -126,6 +130,7 @@ [Components.IA32, Components.X64]
>>     UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
> 
> (1) I think this lib instance ("SecPeiCpuExceptionHandlerLib.inf") may
> not build with XCODE5 at the end of the series, even in stand-alone
> mode. Thus I think it should be conditionalized with
> 
> !if $(TOOL_CHAIN_TAG) != "XCODE5"
> ...
> !endif
> 
> When using XCODE5, we should only build
> "Xcode5SecPeiCpuExceptionHandlerLib.inf"; otherwise, we should build
> *both* "SecPeiCpuExceptionHandlerLib.inf" and
> ".inf".
> 

This is the area that was resulting in the error when I used the pull
request to run the integration tests. I was using an if/else originally,
I'll try just the if != XCODE5 around SecPeiCpuExceptionHandlerLib.inf and
see if that goes through. If not, Brett Barkelew responded with a
suggestion to add the Xcode5SecPeiCpuExceptionHandlerLib.inf to the ignore
list in the CI yaml file.

For the next version, under [Components], it will look like:

@@ -123,9 +127,12 @@ [Components.IA32, Components.X64]
   UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   UefiCpuPkg/Library/CpuCommonFeaturesLib/CpuCommonFeaturesLib.inf
   UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+!if $(TOOL_CHAIN_TAG) != "XCODE5"
   UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+!endif
   UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
   UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
+  UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
   UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
   UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf

>>     UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
>>     UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
>> +  UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
>>     UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
>>     UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
>>     UefiCpuPkg/Library/MpInitLibUp/MpInitLibUp.inf
>> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
>> index e41383573043..61e2ec30b089 100644
>> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
>> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
>> @@ -28,7 +28,7 @@ [Sources.Ia32]
>>     Ia32/ArchInterruptDefs.h
>>   
>>   [Sources.X64]
>> -  X64/ExceptionHandlerAsm.nasm
>> +  X64/Xcode5ExceptionHandlerAsm.nasm
>>     X64/ArchExceptionHandler.c
>>     X64/ArchInterruptDefs.h
>>   
>> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
>> index f31423ac0f91..093374944df6 100644
>> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
>> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiCpuExceptionHandlerLib.inf
>> @@ -28,7 +28,7 @@ [Sources.Ia32]
>>     Ia32/ArchInterruptDefs.h
>>   
>>   [Sources.X64]
>> -  X64/ExceptionHandlerAsm.nasm
>> +  X64/Xcode5ExceptionHandlerAsm.nasm
>>     X64/ArchExceptionHandler.c
>>     X64/ArchInterruptDefs.h
>>   
>> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
>> index 66c7f59e3c91..2ffbbccc302f 100644
>> --- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
>> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
>> @@ -28,7 +28,7 @@ [Sources.Ia32]
>>     Ia32/ArchInterruptDefs.h
>>   
>>   [Sources.X64]
>> -  X64/ExceptionHandlerAsm.nasm
>> +  X64/Xcode5ExceptionHandlerAsm.nasm
>>     X64/ArchExceptionHandler.c
>>     X64/ArchInterruptDefs.h
>>   
>> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
>> new file mode 100644
>> index 000000000000..3ed1378d6fa6
>> --- /dev/null
>> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
>> @@ -0,0 +1,54 @@
>> +## @file
>> +#  CPU Exception Handler library instance for SEC/PEI modules.
>> +#
>> +#  Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.<BR>
>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> (2) This is a customized copy of "SecPeiCpuExceptionHandlerLib.inf"; I
> think you should prepend your (C) notice.

Ok.

> 
>> +#
>> +#  This is the XCODE5 variant of the SEC/PEI CpuExceptionHandlerLib. This
>> +#  variant performs binary patching to fix up addresses that allow the
>> +#  XCODE5 toolchain to be used.
>> +#
>> +##
>> +
>> +[Defines]
>> +  INF_VERSION                    = 0x00010005
>> +  BASE_NAME                      = Xcode5SecPeiCpuExceptionHandlerLib
>> +  MODULE_UNI_FILE                = Xcode5SecPeiCpuExceptionHandlerLib.uni
>> +  FILE_GUID                      = 49C481AF-1621-42F3-8FA1-27C64143E304
>> +  MODULE_TYPE                    = PEIM
>> +  VERSION_STRING                 = 1.1
>> +  LIBRARY_CLASS                  = CpuExceptionHandlerLib|SEC PEI_CORE PEIM
>> +

<... SNIP ...>

>> +global ASM_PFX(AsmVectorNumFixup)
>> +ASM_PFX(AsmVectorNumFixup):
>> +    mov     rax, rdx
>> +    mov     [rcx + (@VectorNum - HookAfterStubHeaderBegin)], al
>> +    ret
>> +
>> diff --git a/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
>> new file mode 100644
>> index 000000000000..be69992cef09
>> --- /dev/null
>> +++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.uni
>> @@ -0,0 +1,17 @@
>> +// /** @file
>> +// XCODE5 CPU Exception Handler library instance for SEC/PEI modules.
>> +//
>> +// CPU Exception Handler library instance for SEC/PEI modules when built
>> +// using the XCODE5 toolchain.
>> +//
>> +// Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
>> +//
>> +// SPDX-License-Identifier: BSD-2-Clause-Patent
>> +//
>> +// **/
>> +
>> +
>> +#string STR_MODULE_ABSTRACT             #language en-US "CPU Exception Handler library instance for SEC/PEI modules with the XCODE5 toolchain."
>> +
>> +#string STR_MODULE_DESCRIPTION          #language en-US "CPU Exception Handler library instance for SEC/PEI modules with the XCODE5 toolchain."
>> +
>>
> 
> (3) This is a brand new file; I think you should prepend your (C) notice.

Ok.

> 
> Meta-hint: with patches like this, it sometimes makes sense to format
> the series for posting with "--find-copies-harder".

Ah, I'll do that on the next version.

Thanks,
Tom

> 
> With (1) through (3) updated:
> 
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
> 
> Thanks,
> Laszlo
> 
> 
> 
> 

  reply	other threads:[~2020-05-06 20:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06 16:32 [PATCH v2 0/3] XCODE5 toolchain binary patching fix Lendacky, Thomas
2020-05-06 16:33 ` [PATCH v2 1/3] UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific Lendacky, Thomas
2020-05-06 19:01   ` Laszlo Ersek
2020-05-06 20:37     ` Lendacky, Thomas [this message]
2020-05-06 16:33 ` [PATCH v2 2/3] OvmfPkg: Use toolchain appropriate CpuExceptionHandlerLib Lendacky, Thomas
2020-05-06 19:04   ` Laszlo Ersek
2020-05-06 16:33 ` [PATCH v2 3/3] UefiCpuPkg/CpuExceptionHandler: Revert CpuExceptionHandler binary patching Lendacky, Thomas
2020-05-06 19:31   ` Laszlo Ersek
2020-05-06 19:53 ` [PATCH v2 0/3] XCODE5 toolchain binary patching fix Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7086eef3-cf00-6254-65b4-bf982b0f4f9e@amd.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox