Re: [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific

2020-05-06 Thread Laszlo Ersek
On 05/06/20 18:33, Tom Lendacky wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340
> 
> 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 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Liming Gao 
> Signed-off-by: Tom Lendacky 
> ---
>  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
"Xcode5SecPeiCpuExceptionHandlerLib.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
> --- 

Re: [EXTERNAL] Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard CpuExceptionHandlerLib

2020-05-06 Thread Lendacky, Thomas

On 5/6/20 1:07 PM, Bret Barkelew via groups.io wrote:



 > Should that
 > section not use the !if check and just list both .inf files
 > (SecPeiCpuExceptionHandlerLib.inf and
 > Xcode5SecPeiCpuExceptionHandlerLib.inf)?

Hmmm, this is a very good point; after all, the updated (=reverted)
"SecPeiCpuExceptionHandlerLib.inf" instance will not build with XCODE5.
Therefore we should list both lib instance INF files under [Components],
but make "SecPeiCpuExceptionHandlerLib.inf" conditional on non-XCODE5.



Xcode5SecPeiCpuExceptionHandlerLib.inf could be added to the ignore list 
in the CI yaml file. PR gating CI currently only uses GCC and VS2017/19 
and shouldn’t have a problem with the reverted lib. This makes 
Xcode5SecPeiCpuExceptionHandlerLib the exception which can be documented 
in the ignore list (why it’s being ignored).


Thoughts?


I'll give those suggestions a try and see how they work. Thanks!

Tom



- Bret

*From: *Laszlo Ersek via groups.io 
*Sent: *Wednesday, May 6, 2020 9:33 AM
*To: *Tom Lendacky ; devel@edk2.groups.io 

*Cc: *Jordan Justen ; Ard Biesheuvel 
; Liming Gao 
; Eric Dong ; Ray 
Ni ; Brijesh Singh 
; Anthony Perard 
; Benjamin You 
; Guo Dong ; 
Julien Grall ; Maurice Ma 
; Andrew Fish 
*Subject: *[EXTERNAL] Re: [edk2-devel] [PATCH 4/4] 
UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard 
CpuExceptionHandlerLib


On 05/06/20 16:35, Tom Lendacky wrote:
 > On 5/5/20 5:15 PM, Laszlo Ersek via groups.io wrote:
 >> On 05/01/20 22:17, Lendacky, Thomas wrote:
 >>> BZ:
 >>> 
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340data=02%7C01%7CBret.Barkelew%40microsoft.com%7Ca9365fbefc53477c9e3308d7f1db4560%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637243796372782584sdata=R%2B5IgncDzx7viv3yIwX3MloX1QlzuUJ4bZlKnc%2B0xoI%3Dreserved=0 


 >>>
 >>>
 >>> Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
 >>> revert the changes made to the ExceptionHandlerAsm.nasm in commit
 >>> 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5
 >>> tool
 >>> chain") so that binary patching of flash code is not performed.
 >>>
 >>> Cc: Eric Dong 
 >>> Cc: Ray Ni 
 >>> Cc: Laszlo Ersek 
 >>> Cc: Liming Gao 
 >>> Signed-off-by: Tom Lendacky 
 >>> ---
 >>>   .../X64/ExceptionHandlerAsm.nasm  | 25 +--
 >>>   1 file changed, 6 insertions(+), 19 deletions(-)
 >>>
 >>> diff --git
 >>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
 >>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
 >>> index 19198f273137..3814f9de3703 100644
 >>> ---
 >>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
 >>> +++
 >>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
 >>> @@ -34,7 +34,7 @@ AsmIdtVectorBegin:
 >>>   db  0x6a    ; push  #VectorNum
 >>>   db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd -
 >>> AsmIdtVectorBegin) / 32) ; VectorNum
 >>>   push    rax
 >>> -    mov rax, strict qword 0 ;    mov rax,
 >>> ASM_PFX(CommonInterruptEntry)
 >>> +    mov rax, ASM_PFX(CommonInterruptEntry)
 >>>   jmp rax
 >>>   %endrep
 >>>   AsmIdtVectorEnd:
 >>> @@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
 >>>   @VectorNum:
 >>>   db  0  ; 0 will be fixed
 >>>   push    rax
 >>> -    mov rax, strict qword 0 ; mov rax,
 >>> HookAfterStubHeaderEnd
 >>> -JmpAbsoluteAddress:
 >>> +    mov rax, HookAfterStubHeaderEnd
 >>>   jmp rax
 >>>   HookAfterStubHeaderEnd:
 >>>   mov rax, rsp
 >>> @@ -257,7 +256,8 @@ HasErrorCode:
 >>>   ; and make sure RSP is 16-byte aligned
 >>>   ;
 >>>   sub rsp, 4 * 8 + 8
 >>> -    call    ASM_PFX(CommonExceptionHandler)
 >>> +    mov rax, ASM_PFX(CommonExceptionHandler)
 >>> +    call    rax
 >>>   add rsp, 4 * 8 + 8
 >>>
 >>>   cli
 >>> @@ -365,24 +365,11 @@ DoIret:
 >>>   ; comments here for definition of address map
 >>>   global ASM_PFX(AsmGetTemplateAddressMap)
 >>>   ASM_PFX(AsmGetTemplateAddressMap):
 >>> -    lea rax, [AsmIdtVectorBegin]
 >>> +    mov rax, AsmIdtVectorBegin
 >>>   mov qword [rcx], 

Re: [edk2-devel] [edk2-platforms:PATCH v5 2/7] KabylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 2/7] KabylakeOpenBoardPkg/TbtDxe: Removes 
redundant InitializeAslUpdateLib

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call as DxeAslUpdateLib 
itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index 13a687576c..d101f4bb75 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDx
+++ e.c
@@ -1,6 +1,6 @@
 /** @file
 
-Copyright (c) 2018, Intel Corporation. All rights reserved.
+Copyright (c) 2018 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
--
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58748): https://edk2.groups.io/g/devel/message/58748
Mute This Topic: https://groups.io/mt/74013806/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms:PATCH v5 3/7] CometlakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 3/7] CometlakeOpenBoardPkg/TbtDxe: Removes 
redundant InitializeAslUpdateLib

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib calls as DxeAslUpdateLib 
itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git 
a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index ef6201de94..e43c5c2fa1 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtD
+++ xe.c
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
--
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58749): https://edk2.groups.io/g/devel/message/58749
Mute This Topic: https://groups.io/mt/74013807/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms:PATCH v5 4/7] MinPlatformPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 4/7] MinPlatformPkg/DxeAslUpdateLib: Cleans 
up APIs

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib() but the 
library itself runs it internally. This commit makes it an internal call. 
LocateAcpiTableByOemTableId() is unreferenced externally so this commit makes 
it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced so they are 
removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c | 
215 
+++
 Platform/Intel/MinPlatformPkg/Include/Library/AslUpdateLib.h | 
135 
++-
 2 files changed, 165 insertions(+), 185 deletions(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index e6ab43db6d..57df18d664 100644
--- 
a/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslU
+++ pdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -29,7 +29,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -50,17 +50,76 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  - The signature of Operation Region that we 
want to update.
   @param[in] Buffer- source of data to be written over original aml
   @param[in] Length- length of data to be overwritten
 
   @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.

Re: [edk2-devel] [edk2-platforms:PATCH v5 1/7] WhiskeylakeOpenBoardPkg/TbtDxe: Removes redundant InitializeAslUpdateLib

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 1/7] WhiskeylakeOpenBoardPkg/TbtDxe: Removes 
redundant InitializeAslUpdateLib

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit removes redundant InitializeAslUpdateLib call as DxeAslUpdateLib 
itself calls it internally.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c | 5 
+
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git 
a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c 
b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
index c670f23320..991edfc2c6 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/TbtDxe.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/Features/Tbt/TbtInit/Dxe/Tb
+++ tDxe.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2019, Intel Corporation. All rights reserved.
+  Copyright (c) 2019 - 2020, Intel Corporation. All rights 
+ reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent  **/
 
@@ -125,9 +125,6 @@ TbtAcpiEndOfDxeCallback (
   UINT16Length;
   UINT32Signature;
 
-  Status = InitializeAslUpdateLib ();
-  ASSERT_EFI_ERROR (Status);
-
   Address = (UINT32) (UINTN) mTbtNvsAreaProtocol.Area;
   Length  = (UINT16) sizeof (TBT_NVS_AREA);
   DEBUG ((DEBUG_INFO, "Patch TBT NvsAreaAddress: TBT NVS Address %x Length 
%x\n", Address, Length));
--
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58747): https://edk2.groups.io/g/devel/message/58747
Mute This Topic: https://groups.io/mt/74013805/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific

2020-05-06 Thread Lendacky, Thomas
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%3D2340data=02%7C01%7Cthomas.lendacky%40amd.com%7C3c47ab80a1554f27afd608d7f1eff6e8%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243885258646451sdata=Xh7E1EB%2B1oOCtc2jgtJ8lsjgcwxgswIbgpL4%2BUwpoOw%3Dreserved=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 
>> Cc: Ray Ni 
>> Cc: Laszlo Ersek 
>> Cc: Liming Gao 
>> Signed-off-by: Tom Lendacky 
>> ---
>>   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
>> +  
>> 

Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Lendacky, Thomas
Hi Eric,

On 5/6/20 10:06 AM, Dong, Eric wrote:
> Hi Tom,
> 
>> -Original Message-
>> From: devel@edk2.groups.io  On Behalf Of
>> Lendacky, Thomas
>> Sent: Wednesday, May 6, 2020 9:20 PM
>> To: Dong, Eric ; devel@edk2.groups.io;
>> ler...@redhat.com
>> Cc: Justen, Jordan L ; Ard Biesheuvel
>> ; Kinney, Michael D
>> ; Gao, Liming ; Ni, Ray
>> ; Brijesh Singh ; Wang, Jian J
>> ; Wu, Hao A 
>> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
>> be used in support of SEV-ES
>>
>> On 5/5/20 8:53 PM, Dong, Eric wrote:
>>>
>>>
 -Original Message-
 From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
 Laszlo Ersek
 Sent: Tuesday, May 5, 2020 11:30 PM
 To: Tom Lendacky ; Dong, Eric
 ; devel@edk2.groups.io
 Cc: Justen, Jordan L ; Ard Biesheuvel
 ; Kinney, Michael D
 ; Gao, Liming ; Ni,
 Ray ; Brijesh Singh ; Wang,
 Jian J ; Wu, Hao A 
 Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs
 to be used in support of SEV-ES

 On 05/04/20 18:41, Tom Lendacky wrote:

> Is there an easy way to run everything that this link points, too?
> Is it just creating a pull request that does this? I don't want to
> take up a lot of your time, so if there's some documentation on how
> to run an integration test to find and fix issues like this, just point 
> me to it.

 Just create a pull request; it will set off CI, and you can review VS
 build errors there (if any).

 Your PR will automatically be closed (rejected) regardless of whether
 CI succeeds or not. PRs are merged -- in fact, *auto*-merged, by the
 "mergify bot" -- if and only if (a) the CI run succeeds, and (b) the PR has
>> the "push"
 label set.

 And only edk2 maintainers have permission to set the "push" label.
 Any PR without the "push" label qualifies as a "personal test build".
 So you can freely experiment with PRs, because you can't (even
 unwittingly) satisfy condition (b).


>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
 hub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-
>> Development
 -
>> data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a9
>> 57285

>> 08d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63724
>> 326821

>> 7382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYB
>> c%3D&
 amp;reserved=0
 Process

>>>
>>> Thanks Laszlo for your explanation.
>>>
>>> I found this patch serial is incompatible for the existed platforms.
>>> Can you help to fix the build failure for these platforms in
>>>
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
>>> ub.com%2Ftianocore%2Fedk2-
>> platformsdata=02%7C01%7Cthomas.lendacky
>>> %40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e6
>> 08e11a8
>>>
>> 2d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6Z
>> vFmPzjcx
>>> Go9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0
>>>
>>
>> I have fixed all of the build issues associated with the VS compiler using 
>> the
>> pull request method that Laszlo mentioned. I then successfully built the RPi4
>> platform under GCC (build -n 32 -a AARCH64 -t GCC5 -p
>> Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.
>>
>> Is there a particular platform that experiences an issue or are the failures
>> related to the VS compiler errors that my next series will have fixed?
> 
> I used the KabylakeRvp3 platform with your changes in Edk2 and met failures.
> KabylakeRvp3 code at Edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\
> 
>   I used below command to build the code.
> C:\Code\OpenSource\edk2-platforms\Platform\Intel>build_bios.py --platform 
> KabylakeRvp3
> 
> You need clone below repositories to build the code.
> Edk2: g...@github.com:tianocore/edk2.git
> Edk2-Platform g...@github.com:tianocore/edk2-platforms.git
> edk2-non-osi :  g...@github.com:tianocore/edk2-non-osi.git
> FSP: g...@github.com:IntelFsp/FSP.git

On my Linux system, I cloned all the libraries and set the WORKSPACE and
PACKAGES_PATH env variables, sourced edksetup.sh and issued:

python3 edk2-platforms/Platform/Intel/build_bios.py --platform KabylakeRvp3

and got the following errors:

Traceback (most recent call last):
  File "edk2-platforms/Platform/Intel/build_bios.py", line 1097, in 
main()
  File "edk2-platforms/Platform/Intel/build_bios.py", line 1067, in main
platform_config = get_platform_config(arguments.platform, build_config)
  File "edk2-platforms/Platform/Intel/build_bios.py", line 904, in 
get_platform_config
path = platform_data.get(platform_name)
AttributeError: 'NoneType' object has no attribute 'get'

I don't know what I'm missing as to why this error pops up. How is this
done on a Linux system?

Did your build fail because of the VmgExitLib library not being specified?
If the platform includes the CpuExceptionHandlerLib or MpInitLib 

Re: [edk2-devel] [PATCH v2 1/1] ShellPkg: smbiosview - print field values as unsigned integers

2020-05-06 Thread Philippe Mathieu-Daudé

On 5/6/20 6:52 PM, Rebecca Cran wrote:

This prevents overflow when printing DWORD fields such as the type 17
tables's extended DIMM size.

Signed-off-by: Rebecca Cran 
Cc: Ray Ni 
Cc: Zhichao Gao 
Cc: Philippe Mathieu-Daude 
---
  .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c   | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index a75caff3de34..1ea7b84bd0fa 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -49,7 +49,7 @@
  #define PRINT_STRUCT_VALUE(pStruct, type, element) \
do { \
  ShellPrintEx(-1,-1,L"%a",#element); \
-ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \
+ShellPrintEx(-1,-1,L": %u\n", (pStruct->type->element)); \
} while (0);
  
  #define PRINT_STRUCT_VALUE_H(pStruct, type, element) \

@@ -634,8 +634,8 @@ SmbiosPrintStructure (
NumOfItem = (Struct->Type14->Hdr.Length - 5) / 3;
PRINT_PENDING_STRING (Struct, Type14, GroupName);
for (Index = 0; Index < NumOfItem; Index++) {
-ShellPrintEx(-1,-1,L"ItemType %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemType);
-ShellPrintEx(-1,-1,L"ItemHandle %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemHandle);
+ShellPrintEx(-1,-1,L"ItemType %u: %u\n", Index + 1, 
Struct->Type14->Group[Index].ItemType);
+ShellPrintEx(-1,-1,L"ItemHandle %u: %u\n", Index + 1, 
Struct->Type14->Group[Index].ItemHandle);
}
  }
  break;



Reviewed-by: Philippe Mathieu-Daude 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58738): https://edk2.groups.io/g/devel/message/58738
Mute This Topic: https://groups.io/mt/74032727/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [EXTERNAL] [edk2-devel] [PATCH 1/4] MdePkg: Add new CPER Notification types

2020-05-06 Thread Oleksiy Yakovlev
Hi Bret.

Sorry for late reply. I was waiting for more comments from others.

Yes all previous notification types are defined in Include/Guid/Cper.h

You are right about the typos. But this were just copy/paste from previous 
notification types definitions from Cper.h - I am not a native English speaker 
and did not mentioned this.
Actually all of notification types defined with TYEP instead of TYPE.
I can fix TYEP in 3 definitions added by me, but what should I do with all the 
rest?

Regards, Oleksiy.


From: Bret Barkelew [mailto:bret.barke...@microsoft.com]
Sent: Friday, April 10, 2020 7:54 PM
To: devel@edk2.groups.io; Oleksiy Yakovlev
Cc: liming@intel.com; Kinney, Michael D; Felix Polyudov; Oleksiy Yakovlev
Subject: RE: [EXTERNAL] [edk2-devel] [PATCH 1/4] MdePkg: Add new CPER 
Notification types

> +#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_SEA \
Multiple typos in these lines.

> +  ## Include/Guid/Cper.h
Are all of these actually in the Cper.h file?

- Bret

From: Oleksiy Yakovlev via groups.io
Sent: Friday, April 10, 2020 12:59 PM
To: devel@edk2.groups.io
Cc: liming@intel.com; Kinney, Michael 
D; fel...@ami.com; 
oleks...@ami.com
Subject: [EXTERNAL] [edk2-devel] [PATCH 1/4] MdePkg: Add new CPER Notification 
types

Add SEA, SEI, and PEI CPER Notification types defined in UEFI 2.8 errata a.
(UEFI 2.8 errata a, mantis 2026)

Signed-off-by: Oleksiy Yakovlev 
---
 MdePkg/Include/Guid/Cper.h | 15 +++
 MdePkg/MdePkg.dec  |  9 +
 2 files changed, 24 insertions(+)

diff --git a/MdePkg/Include/Guid/Cper.h b/MdePkg/Include/Guid/Cper.h
index 0cacd30..b401c14 100644
--- a/MdePkg/Include/Guid/Cper.h
+++ b/MdePkg/Include/Guid/Cper.h
@@ -95,6 +95,18 @@ typedef struct {
   { \
 0x667DD791, 0xC6B3, 0x4c27, { 0x8A, 0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 
0x41 } \
   }
+#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_SEA \
+  { \
+0x9A78788A, 0xBBE8, 0x11E4, { 0x80, 0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 
0xB0 } \
+  }
+#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_SEI \
+  { \
+0x5C284C81, 0xB0AE, 0x4E87, { 0xA3, 0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 
0x23 } \
+  }
+#define EFI_EVENT_NOTIFICATION_TYEP_DMAR_PEI \
+  { \
+0x09A9D5AC, 0x5204, 0x4214, { 0x96, 0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 
0xCD } \
+  }
 ///@}

 ///
@@ -1207,6 +1219,9 @@ extern EFI_GUID gEfiEventNotificationTypeInitGuid;
 extern EFI_GUID gEfiEventNotificationTypeNmiGuid;
 extern EFI_GUID gEfiEventNotificationTypeBootGuid;
 extern EFI_GUID gEfiEventNotificationTypeDmarGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeaGuid;
+extern EFI_GUID gEfiEventNotificationTypeSeiGuid;
+extern EFI_GUID gEfiEventNotificationTypePeiGuid;

 extern EFI_GUID gEfiProcessorGenericErrorSectionGuid;
 extern EFI_GUID gEfiProcessorSpecificErrorSectionGuid;
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index ac1f533..99e75f7 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -434,6 +434,15 @@
   gEfiEventNotificationTypeDmarGuid  = { 0x667DD791, 0xC6B3, 0x4c27, { 0x8A, 
0x6B, 0x0F, 0x8E, 0x72, 0x2D, 0xEB, 0x41 }}

   ## Include/Guid/Cper.h
+  gEfiEventNotificationTypeSeaGuid   = { 0x9A78788A, 0xBBE8, 0x11E4, { 0x80, 
0x9E, 0x67, 0x61, 0x1E, 0x5D, 0x46, 0xB0 }}
+
+  ## Include/Guid/Cper.h
+  gEfiEventNotificationTypeSeiGuid   = { 0x5C284C81, 0xB0AE, 0x4E87, { 0xA3, 
0x22, 0xB0, 0x4C, 0x85, 0x62, 0x43, 0x23 }}
+
+  ## Include/Guid/Cper.h
+  gEfiEventNotificationTypePeiGuid   = { 0x09A9D5AC, 0x5204, 0x4214, { 0x96, 
0xE5, 0x94, 0x99, 0x2E, 0x75, 0x2B, 0xCD }}
+
+  ## Include/Guid/Cper.h
   gEfiProcessorGenericErrorSectionGuid  = { 0x9876ccad, 0x47b4, 0x4bdb, { 
0xb6, 0x5e, 0x16, 0xf1, 0x93, 0xc4, 0xf3, 0xdb }}

   ## Include/Guid/Cper.h
--
2.9.0.windows.1


Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary 
to American Megatrends (AMI).  This communication is intended to be read only 
by the individual or entity to whom it is addressed or by their designee. If 
the reader of this message is not the intended recipient, you are on notice 
that any distribution of this message, in any form, is strictly prohibited.  
Please promptly notify the sender by reply e-mail or by telephone at 
770-246-8600, and then delete or destroy all copies of the transmission.




Please consider the environment before printing this email.

The information contained in this message may be confidential and proprietary 
to American Megatrends (AMI).  This communication is intended to be read only 
by the individual or entity to whom it is addressed or by their designee. If 
the reader of this message is not the intended recipient, you are on notice 
that any distribution of this message, in any form, is strictly prohibited.  
Please promptly notify the sender by reply e-mail or by telephone at 

[edk2-devel] Reminder: Tomorrow's TianoCore Community Meeting at 9am and 7.30pm (PST)

2020-05-06 Thread Soumya Guptha
Dear Community Members,
Please note the time for tomorrow's community meeting - 9-10am (PST) and 
7.30-8.30pm (PST).

You can view the calendar here - 
https://edk2.groups.io/g/devel/viewevent?repeatid=23293=700773=2020-04-16

I hope to see you all tomorrow.

Regards,
Soumya

Soumya Guptha
Open Source Program Manager, SFP/IAGS
Office: 503.712.8038
Cell: 503.528.6157



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58745): https://edk2.groups.io/g/devel/message/58745
Mute This Topic: https://groups.io/mt/74037476/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 3/3] UefiCpuPkg/CpuExceptionHandler: Revert CpuExceptionHandler binary patching

2020-05-06 Thread Laszlo Ersek
On 05/06/20 18:33, Tom Lendacky wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340
> 
> Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
> revert the changes made to the ExceptionHandlerAsm.nasm in commit
> 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool
> chain") so that binary patching of flash code is not performed.
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Liming Gao 
> Signed-off-by: Tom Lendacky 
> ---
>  .../X64/ExceptionHandlerAsm.nasm  | 25 +--
>  1 file changed, 6 insertions(+), 19 deletions(-)

Apart from the subject update, this patch is identical to the last patch
in the v1 series -- for which I gave R-b:

df31ace8-ea40-332f-e6a7-1dc40c0e9b5f@redhat.com">http://mid.mail-archive.com/df31ace8-ea40-332f-e6a7-1dc40c0e9b5f@redhat.com
https://edk2.groups.io/g/devel/message/58666

So I think my R-b should have been picked up.

Anyway:

Reviewed-by: Laszlo Ersek 

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58741): https://edk2.groups.io/g/devel/message/58741
Mute This Topic: https://groups.io/mt/74032334/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms:PATCH v5 7/7] IntelSiliconPkg/DxeAslUpdateLib: Add DxeAslUpdateLib support

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 7/7] IntelSiliconPkg/DxeAslUpdateLib: Add 
DxeAslUpdateLib support

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

This commit adds DxeAslUpdateLib library support in IntelSiliconPkg, which 
allows AML to be updated in DXE.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   | 
520 

 Silicon/Intel/IntelSiliconPkg/Include/Library/AslUpdateLib.h  | 
116 

 Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec |   
4 
 Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.inf |  
42 ++
 4 files changed, 682 insertions(+)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
new file mode 100644
index 00..6bca596b43
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdate
+++ Lib.c
@@ -0,0 +1,520 @@
+/** @file
+  Boot service DXE ASL update library implementation.
+  Note that the current version of the library updates AML.
+
+  These functions in this file can be called during DXE and cannot be 
+ called during runtime  or in SMM which should use a RT or SMM library.
+
+  This library uses the ACPI Support protocol.
+
+  Copyright (c) 2020, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+//
+// Function implemenations
+//
+static EFI_ACPI_SDT_PROTOCOL  *mAcpiSdt = NULL;
+static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
+
+/**
+  Initialize the ASL update library state.
+  This must be called at the beggining of the function calls in this library.
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+**/
+EFI_STATUS
+InitializeAslUpdateLib (
+  VOID
+  )
+{
+  EFI_STATUS  Status;
+
+  ///
+  /// Locate ACPI tables
+  ///
+  Status = gBS->LocateProtocol (, NULL, (VOID 
+**) );
+  ASSERT_EFI_ERROR (Status);
+  Status = gBS->LocateProtocol (, NULL, (VOID 
+**) );
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  This function calculates and updates an UINT8 checksum.
+
+  @param  Buffer  Pointer to buffer to checksum
+  @param  SizeNumber of bytes to checksum
+  @param  ChecksumOffset  Offset to place the checksum result in
+
+  @retval EFI_SUCCESS  The function completed successfully.
+**/
+EFI_STATUS
+AcpiPlatformChecksum (
+  IN VOID   *Buffer,
+  IN UINTN  Size,
+  IN UINTN  ChecksumOffset
+  )
+{
+  UINT8 Sum;
+  UINT8 *Ptr;
+
+  Sum = 0;
+  //
+  // Initialize pointer
+  //
+  Ptr = Buffer;
+
+  //
+  // set checksum to 0 first
+  //
+  Ptr[ChecksumOffset] = 0;
+
+  //
+  // add all content of buffer
+  //
+  while ((Size--) != 0) {
+Sum = (UINT8) (Sum + (*Ptr++));
+  }
+  //
+  // set checksum
+  //
+  Ptr = Buffer;
+  Ptr[ChecksumOffset] = (UINT8) (0xff - Sum + 1);
+
+  return EFI_SUCCESS;
+}
+
+
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  

Re: [edk2-devel] [edk2-platforms:PATCH v5 6/7] CoffeelakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 6/7] CoffeelakeSiliconPkg/DxeAslUpdateLib: 
Cleans up APIs

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib() but the 
library itself runs it internally. This commit deletes the redundant calls in 
caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally so this commit makes 
it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced so they are 
removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
  | 198 
--
 
Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 | 100 
++--
 Silicon/Intel/CoffeelakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c   
  |   3 ---
 Silicon/Intel/CoffeelakeSiliconPkg/Include/Library/AslUpdateLib.h  
  | 120 
++--
 4 files changed, 192 insertions(+), 229 deletions(-)

diff --git 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 04cf66fd2f..28d20980af 100644
--- 
a/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ b/Silicon/Intel/CoffeelakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslU
+++ pdateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-  Copyright (c) 2019 Intel Corporation. All rights reserved. 
+  Copyright (c) 2019 -2020, Intel Corporation. All rights reserved. 
+ 
 
   SPDX-License-Identifier: BSD-2-Clause-Patent  **/
@@ -30,7 +30,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -51,9 +51,65 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  - The 

Re: [edk2-devel] [edk2-platforms:PATCH v5 5/7] KabylakeSiliconPkg/DxeAslUpdateLib: Cleans up APIs

2020-05-06 Thread Chaganty, Rangasai V
Reviewed-by: Sai Chaganty 

-Original Message-
From: Shindo, Miki  
Sent: Tuesday, May 05, 2020 8:17 PM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Agyeman, Prince ; 
Ni, Ray 
Subject: [edk2-platforms:PATCH v5 5/7] KabylakeSiliconPkg/DxeAslUpdateLib: 
Cleans up APIs

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2536

Callers of DxeAslUpdateLib don't have to call InitializeAslUpdateLib() but the 
library itself runs it internally. This commit deletes the redundant calls in 
caller side and makes it an internal call.
LocateAcpiTableByOemTableId() is unreferenced externally so this commit makes 
it an internal call.
PSS_PACKAGE_LAYOUT and AML_RESRC_TEMP_END_TAG are both unreferenced so they are 
removed.
AslUpdateLib.h is cleaned up accordingly.

Signed-off-by: Miki Shindo 
Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Prince Agyeman 
Cc: Ray Ni 
Acked-by: Nate DeSimone 
Reviewed-by: Ray Ni 
Reviewed-by: Sai Chaganty 
Reviewed-by: Chasel Chiu 

---
 Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
| 213 
+
 
Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLibNull/DxeAslUpdateLibNull.c
 | 100 
+++-
 Silicon/Intel/KabylakeSiliconPkg/Pch/PchInit/Dxe/PchAcpi.c 
|   5 +
 Silicon/Intel/KabylakeSiliconPkg/Include/Library/AslUpdateLib.h
| 134 
++
 4 files changed, 227 insertions(+), 225 deletions(-)

diff --git 
a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c 
b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
index 87c6b15ed2..67507643ea 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpdateLib.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Library/DxeAslUpdateLib/DxeAslUpd
+++ ateLib.c
@@ -6,7 +6,7 @@
 
   This library uses the ACPI Support protocol.
 
-Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) 2017 - 2020, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -29,7 +29,7 @@ static EFI_ACPI_TABLE_PROTOCOL*mAcpiTable = NULL;
 
 /**
   Initialize the ASL update library state.
-  This must be called prior to invoking other library functions.
+  This must be called at the beggining of the function calls in this library.
 
   @retval EFI_SUCCESS  - The function completed successfully.
 **/
@@ -50,9 +50,65 @@ InitializeAslUpdateLib (
   return Status;
 }
 
+/**
+  This function uses the ACPI SDT protocol to locate an ACPI SSDT table.
+
+  @param[in] TableId   - Pointer to an ASCII string containing the OEM 
Table ID from the ACPI table header
+  @param[in] TableIdSize   - Length of the TableId to match.  Table ID are 
8 bytes long, this function
+ will consider it a match if the first 
TableIdSize bytes match
+  @param[in, out] Table- Updated with a pointer to the table
+  @param[in, out] Handle   - AcpiSupport protocol table handle for the 
table found
+
+  @retval EFI_SUCCESS  - The function completed successfully.
+  @retval EFI_NOT_FOUND- Failed to locate AcpiTable.
+  @retval EFI_NOT_READY- Not ready to locate AcpiTable.
+**/
+EFI_STATUS
+LocateAcpiTableByOemTableId (
+  IN  UINT8 *TableId,
+  IN  UINT8 TableIdSize,
+  IN OUT  EFI_ACPI_DESCRIPTION_HEADER   **Table,
+  IN OUT  UINTN *Handle
+  )
+{
+  EFI_STATUS  Status;
+  INTNIndex;
+  EFI_ACPI_TABLE_VERSION  Version;
+  EFI_ACPI_DESCRIPTION_HEADER *OrgTable;
+
+  if (mAcpiSdt == NULL) {
+InitializeAslUpdateLib ();
+if (mAcpiSdt == NULL) {
+  return EFI_NOT_READY;
+}
+  }
+  ///
+  /// Locate table with matching ID
+  ///
+  Version = 0;
+  Index = 0;
+  do {
+Status = mAcpiSdt->GetAcpiTable (Index, (EFI_ACPI_SDT_HEADER **), 
, Handle);
+if (Status == EFI_NOT_FOUND) {
+  break;
+}
+ASSERT_EFI_ERROR (Status);
+Index++;
+  } while (CompareMem (&(OrgTable->OemTableId), TableId, TableIdSize));
+
+  if (Status != EFI_NOT_FOUND) {
+*Table = AllocateCopyPool (OrgTable->Length, OrgTable);
+ASSERT (*Table);
+  }
+
+  ///
+  /// If we found the table, there will be no error.
+  ///
+  return Status;
+}
 
 /**
-  This procedure will update immediate value assigned to a Name
+  This procedure will update immediate value assigned to a Name.
 
   @param[in] AslSignature  

Re: [edk2-devel] [PATCH v2 0/3] XCODE5 toolchain binary patching fix

2020-05-06 Thread Laszlo Ersek
On 05/06/20 18:32, Tom Lendacky wrote:
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340
>
> Commit 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass
> XCODE5 tool chain") introduced binary patching in the
> ExceptionHandlerAsm.nasm in order to support the XCODE5 toolchain.
> However, the CpuExceptionHandlerLib can be used during SEC phase which
> would result in binary patching of flash.
>
> This series creates a new CpuExceptionHandlerLib file to support the
> required binary patching for the XCODE5 toolchain, while reverting the
> changes from commit 2db0ccc2d7fe in the standard file. As the Pei, Dxe
> and SMM versions of the library operate in memory (as opposed to
> flash), only the SEC/PEI version is of the library is updated to use
> the version of the ExceptionHandlerAsm.nasm that does not perform
> binary patching.
>
> This is accomplished in phases:
>   - Create a new XCODE5 specific version of the
> ExceptionHandlerAsm.nasm file and update all CpuExceptionHandler
> INF files to use it while also creating a new SEC/PEI
> CpuExceptionHandler INF file specifically for the XCODE5
> toolchain.
>   - Update all package DSC files that use the
> SecPeiCpuExceptionHandlerLib version of the library to use the
> XCODE5 version of the library, Xcode5SecPeiCpuExceptionHandlerLib,
> when the XCODE5 toolchain is used.
>   - Revert the changes made by commit 2db0ccc2d7fe in the standard
> file and update the SecPeiCpuExceptionHandlerLib.inf file to use
> the standard file.
>
> I don't have access to an XCODE5 toolchain setup, so I have not tested
> this with XCODE5. I would like to request that someone who does please
> test this.
>
> Also, will this change have an impact on any of the platform builds
> outside of this tree?

This series takes care of all the "SecPeiCpuExceptionHandlerLib.inf"
occurrences in edk2.

Regarding edk2-platforms, with master being at 644e223bb371
("Platform/RaspberryPi: create DXE phase SerialPortLib version for
RPi3", 2020-05-06):

$ git grep -l \
  
'UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf'

Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
Platform/Intel/QuarkPlatformPkg/Quark.dsc
Platform/Intel/QuarkPlatformPkg/QuarkMin.dsc
Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc

I don't know what's best for these platforms: an XCODE5-compatible
source code that does the wrong thing when run from flash, or an
XCODE5-incompatible source code that does the right thing.

If all of these platforms lived in edk2 proper, I would suggest
inserting patches for them just before patch#3 in this series --
similarly to your OvmfPkg patch. But, these platforms live outside of
edk2, and I don't know if they are ever built with XCODE5...

... You could propose a separate edk2-platforms series:

Platform/Intel/MinPlatformPkg/Include/Dsc/CorePeiLib.dsc
  Chasel Chiu 
  Nate DeSimone 
  Liming Gao 

Platform/Intel/QuarkPlatformPkg/Quark.dsc
  Michael D Kinney 
  Kelly Steele 

Platform/Intel/QuarkPlatformPkg/QuarkMin.dsc
  Michael D Kinney 
  Kelly Steele 

Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
  Zailiang Sun 
  Yi Qian 

Platform/Intel/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
  Zailiang Sun 
  Yi Qian 

and we could then delay just the pushing of patch#3 in this series until
the edk2-platforms patches have been merged too.

> In other words, should the new INF be the one that uses the reverted
> ExceptionHandlerAsm.nasm file and it be called something like
> BaseSecPeiCpuExceptionHandlerLib.inf?

Keeping the current (= self-patching) logic associated with the current
filename ("SecPeiCpuExceptionHandlerLib.inf") would certainly eliminate
the headache about out-of-tree platforms. But it would also mean we'd
have to use a special prefix for the *non-broken* SEC INF file. And that
irks me quite a bit. The quirk is in the patching variant, and IMO that
should be reflected by the file name.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58743): https://edk2.groups.io/g/devel/message/58743
Mute This Topic: https://groups.io/mt/74032330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v2 2/3] OvmfPkg: Use toolchain appropriate CpuExceptionHandlerLib

2020-05-06 Thread Laszlo Ersek
On 05/06/20 18:33, Tom Lendacky wrote:
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340
> 
> During the SEC phase, use the XCODE5 CpuExceptionHandlerLib library in
> place of the standard library when building with the XCODE5 toolchain.
> The SEC XCODE5 version of the library performs binary patching and should
> only be used when building with the XCODE5 toolchain.
> 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Anthony Perard 
> Cc: Julien Grall 
> Cc: Liming Gao 
> Signed-off-by: Tom Lendacky 
> ---
>  OvmfPkg/OvmfPkgIa32.dsc| 4 
>  OvmfPkg/OvmfPkgIa32X64.dsc | 4 
>  OvmfPkg/OvmfPkgX64.dsc | 4 
>  OvmfPkg/OvmfXen.dsc| 4 
>  4 files changed, 16 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 7c8b51f43b66..41ac3202961b 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -246,7 +246,11 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
>
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +!if $(TOOL_CHAIN_TAG) == "XCODE5"
> +  
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
> +!else
>
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
> +!endif
>  
>  [LibraryClasses.common.PEI_CORE]
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index a0596c44168c..c2f11aee2cec 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -250,7 +250,11 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
>
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +!if $(TOOL_CHAIN_TAG) == "XCODE5"
> +  
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
> +!else
>
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
> +!endif
>  
>  [LibraryClasses.common.PEI_CORE]
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 2e764b6b7233..643e6041ad53 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -250,7 +250,11 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
>
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +!if $(TOOL_CHAIN_TAG) == "XCODE5"
> +  
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
> +!else
>
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
> +!endif
>  
>  [LibraryClasses.common.PEI_CORE]
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
> index 8b3615e0b07e..143dc6d5a766 100644
> --- a/OvmfPkg/OvmfXen.dsc
> +++ b/OvmfPkg/OvmfXen.dsc
> @@ -228,7 +228,11 @@ [LibraryClasses.common.SEC]
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
>
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
>
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +!if $(TOOL_CHAIN_TAG) == "XCODE5"
> +  
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
> +!else
>
> CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
> +!endif
>  
>  [LibraryClasses.common.PEI_CORE]
>HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> 

Reviewed-by: Laszlo Ersek 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58740): https://edk2.groups.io/g/devel/message/58740
Mute This Topic: https://groups.io/mt/74032333/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EkdRepo: Update Checkout Pin to Support Multiple Manifest Repos

2020-05-06 Thread Ashley E Desimone
Update the checkout pin command to look for pin files only in
the workspace's source manifest repository.

Signed-off-by: Ashley E Desimone 
Cc: Nate DeSimone 
Cc: Puja Pandya 
Cc: Erik Bjorge 
Cc: Bret Barkelew 
Cc: Prince Agyeman 
---
 edkrepo/commands/checkout_pin_command.py | 19 +--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/edkrepo/commands/checkout_pin_command.py 
b/edkrepo/commands/checkout_pin_command.py
index 31df825..5272236 100644
--- a/edkrepo/commands/checkout_pin_command.py
+++ b/edkrepo/commands/checkout_pin_command.py
@@ -11,13 +11,15 @@ import os
 
 from git import Repo
 
-from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgument
+from edkrepo.commands.edkrepo_command import EdkrepoCommand, OverrideArgument, 
SourceManifestRepoArgument
 import edkrepo.commands.arguments.checkout_pin_args as arguments
 import edkrepo.commands.humble.checkout_pin_humble as humble
 from edkrepo.common.common_repo_functions import sparse_checkout_enabled, 
reset_sparse_checkout, sparse_checkout
 from edkrepo.common.common_repo_functions import check_dirty_repos, 
checkout_repos, combinations_in_manifest
 from edkrepo.common.humble import SPARSE_CHECKOUT, SPARSE_RESET
 from edkrepo.common.edkrepo_exception import 
EdkrepoInvalidParametersException, EdkrepoProjectMismatchException
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
find_project_in_all_indices
+from 
edkrepo.common.workspace_maintenance.humble.manifest_repos_maintenance_humble 
import PROJ_NOT_IN_REPO, SOURCE_MANIFEST_REPO_NOT_FOUND
 from edkrepo.config.config_factory import get_workspace_path, 
get_workspace_manifest
 from edkrepo_manifest_parser.edk_manifest import ManifestXml
 
@@ -38,12 +40,25 @@ class CheckoutPinCommand(EdkrepoCommand):
  'required' : True,
  'help-text' : arguments.PIN_FILE_HELP})
 args.append(OverrideArgument)
+args.append(SourceManifestRepoArgument)
 return metadata
 
 def run_command(self, args, config):
 workspace_path = get_workspace_path()
 manifest = get_workspace_manifest()
-pin_path = self.__get_pin_path(args, workspace_path, 
config['cfg_file'].manifest_repo_abs_local_path, manifest)
+
+manifest_repo, cfg, manifest_path = find_project_in_all_indices 
(manifest.project_info.codename,
+ 
config['cfg_file'],
+ 
config['user_cfg_file'],
+ 
PROJ_NOT_IN_REPO.format(manifest.project_info.codename),
+ 
SOURCE_MANIFEST_REPO_NOT_FOUND.format(manifest.project_info.codename),
+ 
args.source_manifest_repo)
+if 'user' not in cfg:
+manifest_repo_path = 
config['cfg_file'].manifest_repo_abs_path(manifest_repo)
+else:
+manifest_repo_path = 
config['user_cfg_file'].manifest_repo_abs_path(manifest_repo)
+
+pin_path = self.__get_pin_path(args, workspace_path, 
manifest_repo_path, manifest)
 pin = ManifestXml(pin_path)
 manifest_sources = 
manifest.get_repo_sources(manifest.general_config.current_combo)
 check_dirty_repos(manifest, workspace_path)
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58766): https://edk2.groups.io/g/devel/message/58766
Mute This Topic: https://groups.io/mt/74043047/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Integrate multiple manifest repository support in the manifest command

2020-05-06 Thread Ashley E Desimone
Signed-off-by: Ashley E Desimone 
Cc: Nate DeSimone 
Cc: Puja Pandya 
Cc: Erik Bjorge 
Cc: Bret Barkelew 
Cc: Prince Agyeman 
---
 edkrepo/commands/manifest_command.py | 79 +++-
 1 file changed, 50 insertions(+), 29 deletions(-)

diff --git a/edkrepo/commands/manifest_command.py 
b/edkrepo/commands/manifest_command.py
index 44218c9..9e7d204 100644
--- a/edkrepo/commands/manifest_command.py
+++ b/edkrepo/commands/manifest_command.py
@@ -3,7 +3,7 @@
 ## @file
 # manifest_command.py
 #
-# Copyright (c) 2017- 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017- 2020, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 
@@ -18,6 +18,9 @@ import edkrepo.commands.arguments.manifest_args as arguments
 from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceInvalidException
 from edkrepo.common.common_repo_functions import pull_latest_manifest_repo, 
verify_manifest_data
 from edkrepo.common.ui_functions import init_color_console
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
list_available_manifest_repos
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
pull_all_manifest_repos
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
find_source_manifest_repo
 from edkrepo.config.config_factory import get_workspace_manifest
 from edkrepo_manifest_parser.edk_manifest import CiIndexXml
 
@@ -44,46 +47,64 @@ class ManifestCommand(EdkrepoCommand):
 print()
 init_color_console(args.color)
 
-# Get path to global manifest file
-global_manifest_directory = 
config['cfg_file'].manifest_repo_abs_local_path
-if args.verbose:
-print("Manifest directory:")
-print(global_manifest_directory)
-print()
-index_path = os.path.join(global_manifest_directory, 'CiIndex.xml')
+cfg_file = config['cfg_file']
+user_cfg = config['user_cfg_file']
+cfg_man_repos, user_cfg_man_repos, conflicts = 
list_available_manifest_repos(cfg_file, user_cfg)
+man_repos = {}
 
-pull_latest_manifest_repo(args, config)
-print()
+pull_all_manifest_repos(cfg_file, user_cfg, False)
 
-ci_index_xml = CiIndexXml(index_path)
+# Get paths to the global manifest dirs and their index files
+for repo in cfg_man_repos:
+global_manifest_directory = cfg_file.manifest_repo_abs_path(repo)
+index_path = os.path.join(global_manifest_directory, 'CiIndex.xml')
+man_repos[repo] = (global_manifest_directory, index_path)
+for repo in user_cfg_man_repos:
+global_manifest_directory = user_cfg.manifest_repo_abs_path(repo)
+index_path = os.path.join(global_manifest_directory, 'CiIndex.xml')
+man_repos[repo] = (global_manifest_directory, index_path)
 
 try:
-current_project = get_workspace_manifest().project_info.codename
+wkspc_manifest = get_workspace_manifest()
+current_project = wkspc_manifest.project_info.codename
+src_man_repo = find_source_manifest_repo(wkspc_manifest, cfg_file, 
user_cfg, None)
 except EdkrepoWorkspaceInvalidException:
 current_project = None
+src_man_repo = None
 
-# Attempt to make sure the manifest data is good
-try:
-verify_manifest_data(global_manifest_directory, config, 
verbose=args.verbose, verify_all=True, verify_archived=args.archived)
-except:
+for repo in man_repos.keys():
 print()
-
-print("Projects:")
-for project in ci_index_xml.project_list:
-if project == current_project:
-print("* {}{}{}".format(Fore.GREEN, project, Fore.RESET))
-else:
-print("  {}".format(project))
+print("Manifest directory:")
+print(repo)
 if args.verbose:
-print("   -> {}".format(ci_index_xml.get_project_xml(project)))
-
-if args.archived:
+print('Manifest directory path:')
+print(man_repos[repo][0])
 print()
-print("Archived Projects:")
-for project in ci_index_xml.archived_project_list:
-if project == current_project:
+
+ci_index_xml = CiIndexXml(man_repos[repo][1])
+
+# Attempt to make sure the manifest data is good
+try:
+verify_manifest_data(global_manifest_directory, config, 
verbose=args.verbose, verify_all=True, verify_archived=args.archived)
+except:
+print()
+
+print("Projects:")
+for project in ci_index_xml.project_list:
+if (project == current_project and src_man_repo == repo) or 
(not src_man_repo and project == current_project):
 print("* 

[edk2-devel] [edk2-staging/EdkRepo] [PATCH] EdkRepo: Update Create-Pin to be support multiple manifest repositories

2020-05-06 Thread Ashley E Desimone
Update the create pin command to select and interact with only
the workspaces source manifest repository.

Signed-off-by: Ashley E Desimone 
Cc: Nate DeSimone 
Cc: Puja Pandya 
Cc: Erik Bjorge 
Cc: Bret Barkelew 
Cc: Prince Agyeman 
---
 edkrepo/commands/create_pin_command.py | 26 --
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/edkrepo/commands/create_pin_command.py 
b/edkrepo/commands/create_pin_command.py
index f8618e5..5b77649 100644
--- a/edkrepo/commands/create_pin_command.py
+++ b/edkrepo/commands/create_pin_command.py
@@ -12,14 +12,16 @@ from collections import namedtuple
 
 from git import Repo
 
-from edkrepo.commands.edkrepo_command import EdkrepoCommand
+from edkrepo.commands.edkrepo_command import EdkrepoCommand, 
SourceManifestRepoArgument
 import edkrepo.commands.arguments.create_pin_args as arguments
-from edkrepo.common.common_repo_functions import pull_latest_manifest_repo
 from edkrepo.common.edkrepo_exception import EdkrepoManifestInvalidException, 
EdkrepoInvalidParametersException
 from edkrepo.common.edkrepo_exception import EdkrepoWorkspaceCorruptException
 from edkrepo.common.humble import WRITING_PIN_FILE, GENERATING_PIN_DATA, 
GENERATING_REPO_DATA, BRANCH, COMMIT
 from edkrepo.common.humble import COMMIT_MESSAGE, PIN_PATH_NOT_PRESENT, 
PIN_FILE_ALREADY_EXISTS, PATH_AND_FILEPATH_USED
 from edkrepo.common.humble import MISSING_REPO
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
find_project_in_all_indices
+from edkrepo.common.workspace_maintenance.manifest_repos_maintenance import 
pull_workspace_manifest_repo
+from 
edkrepo.common.workspace_maintenance.humble.manifest_repos_maintenance_humble 
import PROJ_NOT_IN_REPO, SOURCE_MANIFEST_REPO_NOT_FOUND
 from edkrepo.config.config_factory import get_workspace_manifest, 
get_workspace_path
 from edkrepo_manifest_parser.edk_manifest import ManifestXml
 
@@ -49,6 +51,7 @@ class CreatePinCommand(EdkrepoCommand):
  'positional': False,
  'required': False,
  'help-text': arguments.PUSH_HELP})
+args.append(SourceManifestRepoArgument)
 return metadata
 
 def run_command(self, args, config):
@@ -56,14 +59,25 @@ class CreatePinCommand(EdkrepoCommand):
 if args.push and os.path.dirname(args.PinFileName):
 raise EdkrepoInvalidParametersException(PATH_AND_FILEPATH_USED)
 
-pull_latest_manifest_repo(args, config)
 workspace_path = get_workspace_path()
 manifest = get_workspace_manifest()
 
+manifest_repo, cfg, manifest_repo_path = 
find_project_in_all_indices(manifest.project_info.codename,
+   
  config['cfg_file'],
+   
  config['user_cfg_file'],
+   
  PROJ_NOT_IN_REPO.format(manifest.project_info.codename),
+   
  SOURCE_MANIFEST_REPO_NOT_FOUND.format(manifest.project_info.codename),
+   
  args.source_manifest_repo)
+pull_workspace_manifest_repo(manifest, config['cfg_file'], 
config['user_cfg_file'], args.source_manifest_repo, False)
+
+if 'user' not in cfg:
+manifest_repo_path = 
config['cfg_file'].manifest_repo_abs_path(manifest_repo)
+else:
+manifest_repo_path = 
config['user_cfg_file'].manifest_repo_abs_path(manifest_repo)
 # If the push flag is enabled use general_config.pin_path to determine 
global manifest relative location to save
 # pin file to.
 if args.push and manifest.general_config.pin_path is not None:
-pin_dir = 
os.path.join(config['cfg_file'].manifest_repo_abs_local_path, 
os.path.normpath(manifest.general_config.pin_path))
+pin_dir = os.path.join(manifest_repo_path, 
os.path.normpath(manifest.general_config.pin_path))
 pin_file_name = os.path.join(pin_dir, args.PinFileName)
 elif args.push and manifest.general_config.pin_path is None:
 raise EdkrepoManifestInvalidException(PIN_PATH_NOT_PRESENT)
@@ -104,7 +118,7 @@ class CreatePinCommand(EdkrepoCommand):
 
 # commit and push the pin file
 if args.push:
-manifest_repo = 
Repo(config['cfg_file'].manifest_repo_abs_local_path)
+manifest_repo = Repo(manifest_repo_path)
 # Create a local branch with the same name as the pin file arg and 
check it out before attempting the push
 # to master
 master_branch = manifest_repo.active_branch
@@ -124,4 +138,4 @@ class CreatePinCommand(EdkrepoCommand):
 manifest_repo.git.push('origin', 'HEAD:master')
 finally:
 

[edk2-devel] [edk2-platform][PATCH v1 0/2] Update ASIX USB Networking drivers

2020-05-06 Thread Samer El-Haj-Mahmoud
This series adds two new ASIX USB networking drivers, Ax88179 and Ax88772c.

Cc: Ray Ni 
Cc: Leif Lindholm 
Cc: Ard Biesheuvel 

Signed-off-by: Samer El-Haj-Mahmoud 

Samer El-Haj-Mahmoud (2):
  OptionRomPkg: UsbNetworking: ASIX Ax88179 driver
  Drivers/OptionRomPkg: UsbNetworking: ASIX Ax88772c driver v2.8.0

 .../Bus/Usb/UsbNetworking/Ax88179/Ax88179.inf |   66 +
 .../Usb/UsbNetworking/Ax88772c/Ax88772c.inf   |   65 +
 .../Bus/Usb/UsbNetworking/Ax88179/Ax88179.h   | 1127 
 .../Bus/Usb/UsbNetworking/Ax88772c/Ax88772.h  | 1097 +++
 .../Bus/Usb/UsbNetworking/Ax88179/Ax88179.c   | 1026 +++
 .../Usb/UsbNetworking/Ax88179/ComponentName.c |  290 +++
 .../Usb/UsbNetworking/Ax88179/DriverBinding.c |  620 +++
 .../Usb/UsbNetworking/Ax88179/SimpleNetwork.c | 1585 
 .../Bus/Usb/UsbNetworking/Ax88772c/Ax88772.c  | 1296 +
 .../UsbNetworking/Ax88772c/ComponentName.c|  246 +++
 .../UsbNetworking/Ax88772c/DriverBinding.c|  637 +++
 .../UsbNetworking/Ax88772c/SimpleNetwork.c| 1612 +
 12 files changed, 9667 insertions(+)
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/Ax88179.inf
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/Ax88772c.inf
 create mode 100644 Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/Ax88179.h
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/Ax88772.h
 create mode 100644 Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/Ax88179.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/ComponentName.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/DriverBinding.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88179/SimpleNetwork.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/Ax88772.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/ComponentName.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/DriverBinding.c
 create mode 100644 
Drivers/OptionRomPkg/Bus/Usb/UsbNetworking/Ax88772c/SimpleNetwork.c

-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58771): https://edk2.groups.io/g/devel/message/58771
Mute This Topic: https://groups.io/mt/74044144/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Dong, Eric
Hi Tom,

> -Original Message-
> From: Tom Lendacky 
> Sent: Thursday, May 7, 2020 2:33 AM
> To: Dong, Eric ; devel@edk2.groups.io;
> ler...@redhat.com
> Cc: Justen, Jordan L ; Ard Biesheuvel
> ; Kinney, Michael D
> ; Gao, Liming ; Ni, Ray
> ; Brijesh Singh ; Wang, Jian J
> ; Wu, Hao A 
> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
> be used in support of SEV-ES
> 
> Hi Eric,
> 
> On 5/6/20 10:06 AM, Dong, Eric wrote:
> > Hi Tom,
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io  On Behalf Of
> >> Lendacky, Thomas
> >> Sent: Wednesday, May 6, 2020 9:20 PM
> >> To: Dong, Eric ; devel@edk2.groups.io;
> >> ler...@redhat.com
> >> Cc: Justen, Jordan L ; Ard Biesheuvel
> >> ; Kinney, Michael D
> >> ; Gao, Liming ; Ni,
> Ray
> >> ; Brijesh Singh ; Wang, Jian
> J
> >> ; Wu, Hao A 
> >> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs
> to
> >> be used in support of SEV-ES
> >>
> >> On 5/5/20 8:53 PM, Dong, Eric wrote:
> >>>
> >>>
>  -Original Message-
>  From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf
> Of
>  Laszlo Ersek
>  Sent: Tuesday, May 5, 2020 11:30 PM
>  To: Tom Lendacky ; Dong, Eric
>  ; devel@edk2.groups.io
>  Cc: Justen, Jordan L ; Ard Biesheuvel
>  ; Kinney, Michael D
>  ; Gao, Liming ;
> Ni,
>  Ray ; Brijesh Singh ;
> Wang,
>  Jian J ; Wu, Hao A 
>  Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create
> PCDs
>  to be used in support of SEV-ES
> 
>  On 05/04/20 18:41, Tom Lendacky wrote:
> 
> > Is there an easy way to run everything that this link points, too?
> > Is it just creating a pull request that does this? I don't want to
> > take up a lot of your time, so if there's some documentation on how
> > to run an integration test to find and fix issues like this, just point 
> > me
> to it.
> 
>  Just create a pull request; it will set off CI, and you can review VS
>  build errors there (if any).
> 
>  Your PR will automatically be closed (rejected) regardless of whether
>  CI succeeds or not. PRs are merged -- in fact, *auto*-merged, by the
>  "mergify bot" -- if and only if (a) the CI run succeeds, and (b) the PR 
>  has
> >> the "push"
>  label set.
> 
>  And only edk2 maintainers have permission to set the "push" label.
>  Any PR without the "push" label qualifies as a "personal test build".
>  So you can freely experiment with PRs, because you can't (even
>  unwittingly) satisfy condition (b).
> 
> 
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
>  hub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-
> >> Development
>  -
> >>
> data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a9
> >> 57285
> 
> >>
> 08d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63724
> >> 326821
> 
> >>
> 7382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYB
> >> c%3D&
>  amp;reserved=0
>  Process
> 
> >>>
> >>> Thanks Laszlo for your explanation.
> >>>
> >>> I found this patch serial is incompatible for the existed platforms.
> >>> Can you help to fix the build failure for these platforms in
> >>>
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >>> ub.com%2Ftianocore%2Fedk2-
> >> platformsdata=02%7C01%7Cthomas.lendacky
> >>> %40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884
> e6
> >> 08e11a8
> >>>
> >>
> 2d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6Z
> >> vFmPzjcx
> >>> Go9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0
> >>>
> >>
> >> I have fixed all of the build issues associated with the VS compiler using
> the
> >> pull request method that Laszlo mentioned. I then successfully built the
> RPi4
> >> platform under GCC (build -n 32 -a AARCH64 -t GCC5 -p
> >> Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.
> >>
> >> Is there a particular platform that experiences an issue or are the 
> >> failures
> >> related to the VS compiler errors that my next series will have fixed?
> >
> > I used the KabylakeRvp3 platform with your changes in Edk2 and met
> failures.
> > KabylakeRvp3 code at Edk2-
> platforms\Platform\Intel\KabylakeOpenBoardPkg\
> >
> >   I used below command to build the code.
> > C:\Code\OpenSource\edk2-platforms\Platform\Intel>build_bios.py --
> platform KabylakeRvp3
> >
> > You need clone below repositories to build the code.
> > Edk2: g...@github.com:tianocore/edk2.git
> > Edk2-Platform g...@github.com:tianocore/edk2-platforms.git
> > edk2-non-osi :  g...@github.com:tianocore/edk2-non-osi.git
> > FSP: g...@github.com:IntelFsp/FSP.git
> 
> On my Linux system, I cloned all the libraries and set the WORKSPACE and
> PACKAGES_PATH env variables, sourced edksetup.sh and issued:
> 
> python3 edk2-platforms/Platform/Intel/build_bios.py --platform
> KabylakeRvp3
> 
> and got the following errors:
> 
> Traceback 

[edk2-devel] Updated Event: TianoCore Bug Triage - APAC / NAMO #cal-invite

2020-05-06 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:PUBLISH
CALSCALE:GREGORIAN
BEGIN:VEVENT
UID:mlda.1580078539586725120.r...@groups.io
DTSTAMP:20200507T011644Z
ORGANIZER;CN=Brian Richardson:mailto:brian.richard...@intel.com
DTSTART;TZID=Asia/Chongqing:20200513T093000
DTEND;TZID=Asia/Chongqing:20200513T103000
RRULE:FREQ=WEEKLY;INTERVAL=1;BYDAY=WE
SUMMARY:TianoCore Bug Triage - APAC / NAMO
DESCRIPTION:https://www.tianocore.org/bug-triage\n\nMeeting URL\n\nhttps:
 //bluejeans.com/889357567?src=join_info\n\nMeeting ID\n\n889 357 567\n\nW
 ant to dial in from a phone?\n\nDial one of the following numbers:\n\n+1.
 408.740.7256 (US (San Jose))\n\n+1.408.317.9253 (US (Primary, San Jose))\
 n\n(see all numbers - https://www.bluejeans.com/numbers)\n\nEnter the mee
 ting ID and passcode followed by #
LOCATION:https://bluejeans.com/889357567?src=join_info
SEQUENCE:0
EXDATE:20200422T013000Z
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Dong, Eric
Hi Tom,

> -Original Message-
> From: Tom Lendacky 
> Sent: Thursday, May 7, 2020 2:33 AM
> To: Dong, Eric ; devel@edk2.groups.io;
> ler...@redhat.com
> Cc: Justen, Jordan L ; Ard Biesheuvel
> ; Kinney, Michael D
> ; Gao, Liming ; Ni, Ray
> ; Brijesh Singh ; Wang, Jian J
> ; Wu, Hao A 
> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
> be used in support of SEV-ES
> 
> Hi Eric,
> 
> On 5/6/20 10:06 AM, Dong, Eric wrote:
> > Hi Tom,
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io  On Behalf Of
> >> Lendacky, Thomas
> >> Sent: Wednesday, May 6, 2020 9:20 PM
> >> To: Dong, Eric ; devel@edk2.groups.io;
> >> ler...@redhat.com
> >> Cc: Justen, Jordan L ; Ard Biesheuvel
> >> ; Kinney, Michael D
> >> ; Gao, Liming ; Ni,
> >> Ray ; Brijesh Singh ; Wang,
> >> Jian J ; Wu, Hao A 
> >> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs
> >> to be used in support of SEV-ES
> >>
> >> On 5/5/20 8:53 PM, Dong, Eric wrote:
> >>>
> >>>
>  -Original Message-
>  From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf
>  Of Laszlo Ersek
>  Sent: Tuesday, May 5, 2020 11:30 PM
>  To: Tom Lendacky ; Dong, Eric
>  ; devel@edk2.groups.io
>  Cc: Justen, Jordan L ; Ard Biesheuvel
>  ; Kinney, Michael D
>  ; Gao, Liming ;
>  Ni, Ray ; Brijesh Singh ;
>  Wang, Jian J ; Wu, Hao A
>  
>  Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create
>  PCDs to be used in support of SEV-ES
> 
>  On 05/04/20 18:41, Tom Lendacky wrote:
> 
> > Is there an easy way to run everything that this link points, too?
> > Is it just creating a pull request that does this? I don't want to
> > take up a lot of your time, so if there's some documentation on
> > how to run an integration test to find and fix issues like this, just 
> > point
> me to it.
> 
>  Just create a pull request; it will set off CI, and you can review
>  VS build errors there (if any).
> 
>  Your PR will automatically be closed (rejected) regardless of
>  whether CI succeeds or not. PRs are merged -- in fact,
>  *auto*-merged, by the "mergify bot" -- if and only if (a) the CI
>  run succeeds, and (b) the PR has
> >> the "push"
>  label set.
> 
>  And only edk2 maintainers have permission to set the "push" label.
>  Any PR without the "push" label qualifies as a "personal test build".
>  So you can freely experiment with PRs, because you can't (even
>  unwittingly) satisfy condition (b).
> 
> 
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
>  hub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-
> >> Development
>  -
> >>
> data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a9
> >> 57285
> 
> >>
> 08d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63724
> >> 326821
> 
> >>
> 7382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYB
> >> c%3D&
>  amp;reserved=0
>  Process
> 
> >>>
> >>> Thanks Laszlo for your explanation.
> >>>
> >>> I found this patch serial is incompatible for the existed platforms.
> >>> Can you help to fix the build failure for these platforms in
> >>>
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> >> h
> >>> ub.com%2Ftianocore%2Fedk2-
> >> platformsdata=02%7C01%7Cthomas.lendacky
> >>> %40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884
> e6
> >> 08e11a8
> >>>
> >>
> 2d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6Z
> >> vFmPzjcx
> >>> Go9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0
> >>>
> >>
> >> I have fixed all of the build issues associated with the VS compiler
> >> using the pull request method that Laszlo mentioned. I then
> >> successfully built the RPi4 platform under GCC (build -n 32 -a
> >> AARCH64 -t GCC5 -p
> >> Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.
> >>
> >> Is there a particular platform that experiences an issue or are the
> >> failures related to the VS compiler errors that my next series will have
> fixed?
> >
> > I used the KabylakeRvp3 platform with your changes in Edk2 and met
> failures.
> > KabylakeRvp3 code at
> > Edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\
> >
> >   I used below command to build the code.
> > C:\Code\OpenSource\edk2-platforms\Platform\Intel>build_bios.py
> > --platform KabylakeRvp3
> >
> > You need clone below repositories to build the code.
> > Edk2: g...@github.com:tianocore/edk2.git Edk2-Platform
> > g...@github.com:tianocore/edk2-platforms.git
> > edk2-non-osi :  g...@github.com:tianocore/edk2-non-osi.git
> > FSP: g...@github.com:IntelFsp/FSP.git
> 
> On my Linux system, I cloned all the libraries and set the WORKSPACE and
> PACKAGES_PATH env variables, sourced edksetup.sh and issued:
> 
> python3 edk2-platforms/Platform/Intel/build_bios.py --platform
> KabylakeRvp3
> 
> and got the following errors:
> 
> Traceback 

Re: [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to SetupGit.py

2020-05-06 Thread Bob Feng
This patch looks good for me.

Reviewed-by: Bob Feng 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Laszlo Ersek
Sent: Thursday, May 7, 2020 12:36 AM
To: Feng, Bob C ; Gao, Liming 
Cc: devel@edk2.groups.io; l...@nuviainc.com; rebe...@bsdio.com
Subject: Re: [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to 
SetupGit.py

On 05/06/20 12:31, Leif Lindholm wrote:
> On Tue, May 05, 2020 at 17:40:35 +0200, Laszlo Ersek wrote:
>> CC Leif
>>
>> On 05/01/20 22:00, Rebecca Cran wrote:
>>> Allow users who didn't clone one of the TianoCore repos from a 
>>> canonical URL to specify the name of the repo (edk2, edk2-platforms 
>>> or edk2-non-osi) when running SetupGit.py to allow them to configure 
>>> their repo properly.
>>>
>>> The new option is:
>>>
>>>   -n repo, --name repo  set the repo name to configure for, if not
>>> detected automatically
>>>
>>> Signed-off-by: Rebecca Cran 
>>> Cc: Bob Feng 
>>> Cc: Liming Gao 
> 
> I did consider this scenario when writing the code, but couldn't 
> decide on a method for overriding, and wasn't 100% it wasn't just a 
> theoretical issue. This solution looks sensible.
> Reviewed-by: Leif Lindholm 

Thanks!

Bob, Liming, can one of you please ACK and also merge this patch?

Thanks,
Laszlo

> 
> As a sidenote - now this exists, it could make sense to also add 
> options for overriding 'list' and 'prefix'.
> 
> /
> Leif
> 
>>> ---
>>> Tested with:
>>>   pylama : no new issues detected
>>> Option tested:
>>>   -n : correctly said a parameter was needed
>>>   -n edk2 : configured the repo for edk2
>>>   -n edk2-foo : errored out with a list of repo names
>>>   -n edk2-platforms : updated the configuration for edk2-platforms
>>>
>>> Note the error block in __main__ if the upstream isn't found is 
>>> redundant, since it already errors out and exits in get_upstream.
>>>
>>>  BaseTools/Scripts/SetupGit.py | 12 +---
>>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/BaseTools/Scripts/SetupGit.py 
>>> b/BaseTools/Scripts/SetupGit.py index e320ba2f887e..4416111ac0a5 
>>> 100644
>>> --- a/BaseTools/Scripts/SetupGit.py
>>> +++ b/BaseTools/Scripts/SetupGit.py
>>> @@ -106,10 +106,11 @@ def fuzzy_match_repo_url(one, other):
>>>  return False
>>>
>>>
>>> -def get_upstream(url):
>>> +def get_upstream(url, name):
>>>  """Extracts the dict for the current repo origin."""
>>>  for upstream in UPSTREAMS:
>>> -if fuzzy_match_repo_url(upstream['repo'], url):
>>> +if (fuzzy_match_repo_url(upstream['repo'], url) or
>>> +upstream['name'] == name):
>>>  return upstream
>>>  print("Unknown upstream '%s' - aborting!" % url)
>>>  sys.exit(3)
>>> @@ -143,6 +144,11 @@ if __name__ == '__main__':
>>>  help='overwrite existing settings conflicting with 
>>> program defaults',
>>>  action='store_true',
>>>  required=False)
>>> +PARSER.add_argument('-n', '--name', type=str, metavar='repo',
>>> +choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
>>> +help='set the repo name to configure for, if not '
>>> + 'detected automatically',
>>> +required=False)
>>>  PARSER.add_argument('-v', '--verbose',
>>>  help='enable more detailed output',
>>>  action='store_true', @@ -156,7 +162,7 @@ if 
>>> __name__ == '__main__':
>>>
>>>  URL = REPO.remotes.origin.url
>>>
>>> -UPSTREAM = get_upstream(URL)
>>> +UPSTREAM = get_upstream(URL, ARGS.name)
>>>  if not UPSTREAM:
>>>  print("Upstream '%s' unknown, aborting!" % URL)
>>>  sys.exit(7)
>>>
>>
>>
>>
>>
> 
> 
> 





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58767): https://edk2.groups.io/g/devel/message/58767
Mute This Topic: https://groups.io/mt/73406555/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V3 3/8] CryptoPkg/BaseCryptLib: Retire ARC4 algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

ARC4 is not secure any longer.
Remove the ARC4 support from edk2.
Change the ARC4 field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any longer.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/Driver/Crypto.c | 125 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  | 132 ---
 .../Library/BaseCryptLib/BaseCryptLib.inf |   1 -
 .../Library/BaseCryptLib/Cipher/CryptArc4.c   | 205 --
 .../BaseCryptLib/Cipher/CryptArc4Null.c   | 124 ---
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |   4 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 -
 .../BaseCryptLibNull/Cipher/CryptArc4Null.c   | 124 ---
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 147 -
 .../Library/Include/openssl/opensslconf.h |   3 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   |   3 -
 .../Library/OpensslLib/OpensslLibCrypto.inf   |   3 -
 CryptoPkg/Private/Protocol/Crypto.h   | 115 ++
 18 files changed, 43 insertions(+), 961 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptArc4Null.c

diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 95fc834bde..388a6e4b4b 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -1982,150 +1982,61 @@ CryptoServiceAesCbcDecrypt (
 }
 
 /**
-  Retrieves the size, in bytes, of the context buffer required for ARC4 
operations.
-
-  If this interface is not supported, then return zero.
-
-  @return  The size, in bytes, of the context buffer required for ARC4 
operations.
-  @retval  0   This interface is not supported.
+  ARC4 is deprecated and unsupported any longer.
+  Keep the function field for binary compability.
 
 **/
 UINTN
 EFIAPI
-CryptoServiceArc4GetContextSize (
+DeprecatedCryptoServiceArc4GetContextSize (
   VOID
   )
 {
-  return CALL_BASECRYPTLIB (Arc4.Services.GetContextSize, Arc4GetContextSize, 
(), 0);
+  return BaseCryptLibServciceDeprecated ("Arc4GetContextSize"), 0;
 }
 
-/**
-  Initializes user-supplied memory as ARC4 context for subsequent use.
-
-  This function initializes user-supplied memory pointed by Arc4Context as 
ARC4 context.
-  In addition, it sets up all ARC4 key materials for subsequent encryption and 
decryption
-  operations.
-
-  If Arc4Context is NULL, then return FALSE.
-  If Key is NULL, then return FALSE.
-  If KeySize does not in the range of [5, 256] bytes, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[out]  Arc4Context  Pointer to ARC4 context being initialized.
-  @param[in]   Key  Pointer to the user-supplied ARC4 key.
-  @param[in]   KeySize  Size of ARC4 key in bytes.
-
-  @retval TRUE   ARC4 context initialization succeeded.
-  @retval FALSE  ARC4 context initialization failed.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceArc4Init (
+DeprecatedCryptoServiceArc4Init (
   OUT  VOID *Arc4Context,
   IN   CONST UINT8  *Key,
   IN   UINTNKeySize
   )
 {
-  return CALL_BASECRYPTLIB (Arc4.Services.Init, Arc4Init, (Arc4Context, Key, 
KeySize), FALSE);
+  return BaseCryptLibServciceDeprecated ("Arc4Init"), FALSE;
 }
 
-/**
-  Performs ARC4 encryption on a data buffer of the specified size.
-
-  This function performs ARC4 encryption on data buffer pointed by Input, of 
specified
-  size of InputSize.
-  Arc4Context should be already correctly initialized by Arc4Init(). Behavior 
with
-  invalid ARC4 context is undefined.
-
-  If Arc4Context is NULL, then return FALSE.
-  If Input is NULL, then return FALSE.
-  If Output is NULL, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[in, out]  Arc4Context  Pointer to the ARC4 context.
-  @param[in]   InputPointer to the buffer containing the data to 
be encrypted.
-  @param[in]   InputSizeSize of the Input buffer in bytes.
-  @param[out]  Output   Pointer to a buffer that receives the ARC4 
encryption output.
-
-  @retval TRUE   ARC4 encryption succeeded.
-  @retval FALSE  ARC4 encryption failed.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceArc4Encrypt (
+DeprecatedCryptoServiceArc4Encrypt (
   IN OUT  VOID *Arc4Context,
   IN  CONST UINT8  *Input,
   IN  UINTNInputSize,
   OUT UINT8*Output
   )
 {
-  return 

[edk2-devel] [PATCH V3 7/8] CryptoPkg/BaseCryptLib: Retire HMAC SHA1 algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

HMAC SHA1 is not secure any longer.
Remove the HMAC SHA1 support from edk2.
Change the HMAC SHA1 field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any long.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/CryptoPkg.dsc   |   3 -
 CryptoPkg/Driver/Crypto.c | 128 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  | 133 ---
 .../Library/BaseCryptLib/BaseCryptLib.inf |   1 -
 .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c | 216 --
 .../BaseCryptLib/Hmac/CryptHmacSha1Null.c | 139 ---
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   4 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |   4 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 -
 .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c | 139 ---
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 151 
 CryptoPkg/Private/Protocol/Crypto.h   | 121 ++
 16 files changed, 45 insertions(+), 1009 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 9ddf73f9fa..1af78468a1 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -137,7 +137,6 @@
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
 
 !if $(CRYPTO_SERVICES) IN "PACKAGE ALL"
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
@@ -163,7 +162,6 @@
 !endif
 
 !if $(CRYPTO_SERVICES) == MIN_PEI
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family 
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family 
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
@@ -178,7 +176,6 @@
 !endif
 
 !if $(CRYPTO_SERVICES) == MIN_DXE_MIN_SMM
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs1v2Encrypt
 | TRUE
   
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs5HashPassword
  | TRUE
diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index dfde1cc005..95172de981 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -1170,154 +1170,68 @@ DeprecatedCryptoServiceHmacMd5Final (
 }
 
 /**
-  Allocates and initializes one HMAC_CTX context for subsequent HMAC-SHA1 use.
-
-  If this interface is not supported, then return NULL.
-
-  @return  Pointer to the HMAC_CTX context that has been initialized.
-   If the allocations fails, HmacSha1New() returns NULL.
-  @return  NULL   This interface is not supported.
+  HMAC SHA1 is deprecated and unsupported any longer.
+  Keep the function field for binary compability.
 
 **/
 VOID *
 EFIAPI
-CryptoServiceHmacSha1New (
+DeprecatedCryptoServiceHmacSha1New (
   VOID
   )
 {
-  return CALL_BASECRYPTLIB (HmacSha1.Services.New, HmacSha1New, (), NULL);
+  return BaseCryptLibServciceDeprecated ("HmacSha1New"), NULL;
 }
 
-/**
-  Release the specified HMAC_CTX context.
-
-  If this interface is not supported, then do nothing.
-
-  @param[in]  HmacSha1Ctx  Pointer to the HMAC_CTX context to be released.
-
-**/
 VOID
 EFIAPI
-CryptoServiceHmacSha1Free (
+DeprecatedCryptoServiceHmacSha1Free (
   IN  VOID  *HmacSha1Ctx
   )
 {
-  CALL_VOID_BASECRYPTLIB (HmacSha1.Services.Free, HmacSha1Free, (HmacSha1Ctx));
+  BaseCryptLibServciceDeprecated ("HmacSha1Free");
 }
 
-/**
-  Set user-supplied key for 

[edk2-devel] [PATCH V3 2/8] CryptoPkg/BaseCrpytLib: Retire MD4 algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

MD4 is not secure any longer.
Remove the MD4 support from edk2.
Change the MD4 field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any longer.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/CryptoPkg.dsc   |   1 -
 CryptoPkg/Driver/Crypto.c | 135 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  | 145 
 .../Library/BaseCryptLib/BaseCryptLib.inf |   3 +-
 .../Library/BaseCryptLib/Hash/CryptMd4.c  | 223 --
 .../Library/BaseCryptLib/Hash/CryptMd4Null.c  | 143 ---
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   5 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |   6 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   5 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |   6 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   5 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |   6 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 -
 .../BaseCryptLibNull/Hash/CryptMd4Null.c  | 143 ---
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 158 -
 .../Library/Include/openssl/opensslconf.h |   3 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   |   3 -
 .../Library/OpensslLib/OpensslLibCrypto.inf   |   3 -
 CryptoPkg/Private/Protocol/Crypto.h   | 123 ++
 19 files changed, 55 insertions(+), 1062 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hash/CryptMd4Null.c

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index f79ff331cf..6ed7046563 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -140,7 +140,6 @@
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacMd5.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md4.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 05ad4b5d55..95fc834bde 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -124,161 +124,68 @@ CryptoServiceGetCryptoVersion (
 
//=
 
 /**
-  Retrieves the size, in bytes, of the context buffer required for MD4 hash 
operations.
-
-  If this interface is not supported, then return zero.
-
-  @return  The size, in bytes, of the context buffer required for MD4 hash 
operations.
-  @retval  0   This interface is not supported.
+  MD4 is deprecated and unsupported any longer.
+  Keep the function field for binary compability.
 
 **/
 UINTN
 EFIAPI
-CryptoServiceMd4GetContextSize (
+DeprecatedCryptoServiceMd4GetContextSize (
   VOID
   )
 {
-  return CALL_BASECRYPTLIB (Md4.Services.GetContextSize, Md4GetContextSize, 
(), 0);
+  return BaseCryptLibServciceDeprecated ("Md4GetContextSize"), 0;
 }
 
-/**
-  Initializes user-supplied memory pointed by Md4Context as MD4 hash context 
for
-  subsequent use.
-
-  If Md4Context is NULL, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[out]  Md4Context  Pointer to MD4 context being initialized.
-
-  @retval TRUE   MD4 context initialization succeeded.
-  @retval FALSE  MD4 context initialization failed.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceMd4Init (
+DeprecatedCryptoServiceMd4Init (
   OUT  VOID  *Md4Context
   )
 {
-  return CALL_BASECRYPTLIB (Md4.Services.Init, Md4Init, (Md4Context), FALSE);
+  return BaseCryptLibServciceDeprecated ("Md4Init"), FALSE;
 }
 
-/**
-  Makes a copy of an existing MD4 context.
-
-  If Md4Context is NULL, then return FALSE.
-  If NewMd4Context is NULL, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[in]  Md4Context Pointer to MD4 context being copied.
-  @param[out] NewMd4Context  Pointer to new MD4 context.
-
-  @retval TRUE   MD4 context copy succeeded.
-  @retval FALSE  MD4 context copy failed.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceMd4Duplicate (
+DeprecatedCryptoServiceMd4Duplicate (
   IN   CONST VOID  

[edk2-devel] [PATCH V3 0/8] CryptoPkg: Retire the deprecated functions

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

Retire below deprecated functions:
MD4, ARC4, TDES, AES ECB MODE, HMAC MD5, HMAC SHA1.

V2:
Seprate the MD5 and SHA1 changes to other patch set.
Change the deprecated function wrapper implementatuion in
EDKII_CRYPTO_PROTOCOL to call a dummy function to print debug
message and assert.

V3:
Remove the missing part of deprecated functions in V2.
Change the name field in the EDKII_CRYPTO_PROTOCOL to indicate
the function is deprecated and unsupported.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 

Zhichao Gao (8):
  CryptoPkg/CryptoDxe: Add function to indicate the deprecated algorithm
  CryptoPkg/BaseCrpytLib: Retire MD4 algorithm
  CryptoPkg/BaseCryptLib: Retire ARC4 algorithm
  CryptoPkg/BaseCryptLib: Retire the Tdes algorithm
  CryptoPkg/BaseCryptLib: Retire Aes Ecb mode algorithm
  CryptoPkg/BaseCryptLib: Retire HMAC MD5 algorithm
  CryptoPkg/BaseCryptLib: Retire HMAC SHA1 algorithm
  CryptoPkg/Crypto.h: Update the version of Crypto Driver

 CryptoPkg/CryptoPkg.dsc   |   46 +-
 CryptoPkg/Driver/Crypto.c |  780 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  |  809 
 .../Library/BaseCryptLib/BaseCryptLib.inf |7 +-
 .../Library/BaseCryptLib/Cipher/CryptAes.c|  114 --
 .../BaseCryptLib/Cipher/CryptAesNull.c|   52 -
 .../Library/BaseCryptLib/Cipher/CryptArc4.c   |  205 ---
 .../BaseCryptLib/Cipher/CryptArc4Null.c   |  124 --
 .../Library/BaseCryptLib/Cipher/CryptTdes.c   |  364 --
 .../BaseCryptLib/Cipher/CryptTdesNull.c   |  160 ---
 .../Library/BaseCryptLib/Hash/CryptMd4.c  |  223 
 .../Library/BaseCryptLib/Hash/CryptMd4Null.c  |  143 --
 .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c  |  216 ---
 .../BaseCryptLib/Hmac/CryptHmacMd5Null.c  |  139 --
 .../Library/BaseCryptLib/Hmac/CryptHmacSha1.c |  216 ---
 .../BaseCryptLib/Hmac/CryptHmacSha1Null.c |  139 --
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   11 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |4 +-
 CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c |7 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   11 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |4 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   12 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |4 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |5 -
 .../BaseCryptLibNull/Cipher/CryptAesNull.c|   52 -
 .../BaseCryptLibNull/Cipher/CryptArc4Null.c   |  124 --
 .../BaseCryptLibNull/Cipher/CryptTdesNull.c   |  160 ---
 .../BaseCryptLibNull/Hash/CryptMd4Null.c  |  143 --
 .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c  |  139 --
 .../BaseCryptLibNull/Hmac/CryptHmacSha1Null.c |  139 --
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 1157 ++---
 .../Library/Include/openssl/opensslconf.h |9 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   |   28 -
 .../Library/OpensslLib/OpensslLibCrypto.inf   |   28 -
 CryptoPkg/Private/Protocol/Crypto.h   |  708 ++
 35 files changed, 389 insertions(+), 6093 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptArc4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdes.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdesNull.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hash/CryptMd4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacSha1Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptArc4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptTdesNull.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hash/CryptMd4Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacSha1Null.c

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58756): https://edk2.groups.io/g/devel/message/58756
Mute This Topic: https://groups.io/mt/74041185/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V3 8/8] CryptoPkg/Crypto.h: Update the version of Crypto Driver

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

The binary is totally changed, so update the Crypto Version to 7:
1. Retire below deprecated function:
MD4, ARC4, TDES, AES ECB MODE, HMAC MD5, HMAC SHA1

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/Private/Protocol/Crypto.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CryptoPkg/Private/Protocol/Crypto.h 
b/CryptoPkg/Private/Protocol/Crypto.h
index d167390774..4e3292ffc1 100644
--- a/CryptoPkg/Private/Protocol/Crypto.h
+++ b/CryptoPkg/Private/Protocol/Crypto.h
@@ -20,7 +20,7 @@
 /// the EDK II Crypto Protocol is extended, this version define must be
 /// increased.
 ///
-#define EDKII_CRYPTO_VERSION 6
+#define EDKII_CRYPTO_VERSION 7
 
 ///
 /// EDK II Crypto Protocol forward declaration
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58764): https://edk2.groups.io/g/devel/message/58764
Mute This Topic: https://groups.io/mt/74041201/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V3 1/8] CryptoPkg/CryptoDxe: Add function to indicate the deprecated algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

Add a internal worker function to indicate the deprecated functions.
It would print out debug messages and asserts ot inform the consumer
they are using a deprecated function.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/Driver/Crypto.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 35bf2d3d92..05ad4b5d55 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -86,6 +86,24 @@ BaseCryptLibServciceNotEnabled (
   ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
 }
 
+/**
+  Internal worker function that prints a debug message and asserts if a call is
+  made to a BaseCryptLib function that is deprecated and unsupported any 
longer.
+
+  @param[in]  FunctionName  Null-terminated ASCII string that is the name of an
+EDK II Crypto service.
+
+**/
+static
+VOID
+BaseCryptLibServciceDeprecated (
+  IN CONST CHAR8  *FunctionName
+  )
+{
+  DEBUG ((DEBUG_ERROR, "[%a] Function %a() is deprecated and unsupported any 
longer\n", gEfiCallerBaseName, FunctionName));
+  ASSERT_EFI_ERROR (EFI_UNSUPPORTED);
+}
+
 /**
   Returns the version of the EDK II Crypto Protocol.
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58757): https://edk2.groups.io/g/devel/message/58757
Mute This Topic: https://groups.io/mt/74041186/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH V3 6/8] CryptoPkg/BaseCryptLib: Retire HMAC MD5 algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

HMAC MD5 is not secure any longer.
Remove the HMAC MD5 support from edk2.
Change the HMAC MD5 field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any long.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/CryptoPkg.dsc   |   1 -
 CryptoPkg/Driver/Crypto.c | 128 ++-
 CryptoPkg/Include/Library/BaseCryptLib.h  | 203 
 .../Library/BaseCryptLib/BaseCryptLib.inf |   1 -
 .../Library/BaseCryptLib/Hmac/CryptHmacMd5.c  | 216 --
 .../BaseCryptLib/Hmac/CryptHmacMd5Null.c  | 139 ---
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |   4 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |   4 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 -
 .../BaseCryptLibNull/Hmac/CryptHmacMd5Null.c  | 139 ---
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 151 
 CryptoPkg/Private/Protocol/Crypto.h   | 117 ++
 16 files changed, 45 insertions(+), 1072 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Hmac/CryptHmacMd5Null.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Hmac/CryptHmacMd5Null.c

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 1f68cc633b..9ddf73f9fa 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -137,7 +137,6 @@
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
 
 !if $(CRYPTO_SERVICES) IN "PACKAGE ALL"
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacMd5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
   gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 341df3b814..dfde1cc005 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -1105,154 +1105,68 @@ CryptoServiceSm3HashAll (
 
//=
 
 /**
-  Allocates and initializes one HMAC_CTX context for subsequent HMAC-MD5 use.
-
-  If this interface is not supported, then return NULL.
-
-  @return  Pointer to the HMAC_CTX context that has been initialized.
-   If the allocations fails, HmacMd5New() returns NULL.
-  @retval  NULL  This interface is not supported.
+  HMAC MD5 is deprecated and unsupported any longer.
+  Keep the function field for binary compability.
 
 **/
 VOID *
 EFIAPI
-CryptoServiceHmacMd5New (
+DeprecatedCryptoServiceHmacMd5New (
   VOID
   )
 {
-  return CALL_BASECRYPTLIB (HmacMd5.Services.New, HmacMd5New, (), NULL);
+  return BaseCryptLibServciceDeprecated ("HmacMd5New"), NULL;
 }
 
-/**
-  Release the specified HMAC_CTX context.
-
-  If this interface is not supported, then do nothing.
-
-  @param[in]  HmacMd5Ctx  Pointer to the HMAC_CTX context to be released.
-
-**/
 VOID
 EFIAPI
-CryptoServiceHmacMd5Free (
+DeprecatedCryptoServiceHmacMd5Free (
   IN  VOID  *HmacMd5Ctx
   )
 {
-  CALL_VOID_BASECRYPTLIB (HmacMd5.Services.Free, HmacMd5Free, (HmacMd5Ctx));
+  BaseCryptLibServciceDeprecated ("HmacMd5Free");
 }
 
-/**
-  Set user-supplied key for subsequent use. It must be done before any
-  calling to HmacMd5Update().
-
-  If HmacMd5Context is NULL, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[out]  HmacMd5Context  Pointer to HMAC-MD5 context.
-  @param[in]   Key Pointer to the user-supplied key.
-  @param[in]   KeySize Key size in bytes.
-
-  @retval TRUE   Key is set successfully.
-  @retval FALSE  Key is set unsuccessfully.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceHmacMd5SetKey (
+DeprecatedCryptoServiceHmacMd5SetKey (
   OUT  VOID *HmacMd5Context,
   IN   CONST UINT8  *Key,
   IN   UINTNKeySize
   )
 {
-  return CALL_BASECRYPTLIB (HmacMd5.Services.SetKey, HmacMd5SetKey, 
(HmacMd5Context, Key, KeySize), FALSE);
+  return BaseCryptLibServciceDeprecated ("HmacMd5SetKey"), FALSE;
 }
 
-/**
-  Makes a copy of an existing HMAC-MD5 context.
-
-  If HmacMd5Context is NULL, then return FALSE.
-  If NewHmacMd5Context is NULL, then return FALSE.
-  If this interface is not supported, then return 

[edk2-devel] [PATCH V3 4/8] CryptoPkg/BaseCryptLib: Retire the Tdes algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

Tdes is not secure any longer.
Remove the Tdes support from edk2.
Change the Tdes field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any longer.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/Driver/Crypto.c | 181 +
 CryptoPkg/Include/Library/BaseCryptLib.h  | 196 --
 .../Library/BaseCryptLib/BaseCryptLib.inf |   1 -
 .../Library/BaseCryptLib/Cipher/CryptTdes.c   | 364 --
 .../BaseCryptLib/Cipher/CryptTdesNull.c   | 160 
 .../Library/BaseCryptLib/PeiCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/PeiCryptLib.uni  |   6 +-
 CryptoPkg/Library/BaseCryptLib/Pem/CryptPem.c |   7 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/RuntimeCryptLib.uni  |   6 +-
 .../Library/BaseCryptLib/SmmCryptLib.inf  |   3 +-
 .../Library/BaseCryptLib/SmmCryptLib.uni  |   6 +-
 .../BaseCryptLibNull/BaseCryptLibNull.inf |   1 -
 .../BaseCryptLibNull/Cipher/CryptTdesNull.c   | 160 
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  | 214 --
 .../Library/Include/openssl/opensslconf.h |   3 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   |  21 -
 .../Library/OpensslLib/OpensslLibCrypto.inf   |  21 -
 CryptoPkg/Private/Protocol/Crypto.h   | 169 +---
 19 files changed, 53 insertions(+), 1472 deletions(-)
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdes.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLib/Cipher/CryptTdesNull.c
 delete mode 100644 CryptoPkg/Library/BaseCryptLibNull/Cipher/CryptTdesNull.c

diff --git a/CryptoPkg/Driver/Crypto.c b/CryptoPkg/Driver/Crypto.c
index 388a6e4b4b..a4106aae0b 100644
--- a/CryptoPkg/Driver/Crypto.c
+++ b/CryptoPkg/Driver/Crypto.c
@@ -1557,167 +1557,57 @@ CryptoServiceHmacSha256Final (
 
//=
 
 /**
-  Retrieves the size, in bytes, of the context buffer required for TDES 
operations.
-
-  If this interface is not supported, then return zero.
-
-  @return  The size, in bytes, of the context buffer required for TDES 
operations.
-  @retval  0   This interface is not supported.
+  TDES is deprecated and unsupported any longer.
+  Keep the function field for binary compability.
 
 **/
 UINTN
 EFIAPI
-CryptoServiceTdesGetContextSize (
+DeprecatedCryptoServiceTdesGetContextSize (
   VOID
   )
 {
-  return CALL_BASECRYPTLIB (Tdes.Services.GetContextSize, TdesGetContextSize, 
(), 0);
+  return BaseCryptLibServciceDeprecated ("TdesGetContextSize"), 0;
 }
 
-/**
-  Initializes user-supplied memory as TDES context for subsequent use.
-
-  This function initializes user-supplied memory pointed by TdesContext as 
TDES context.
-  In addition, it sets up all TDES key materials for subsequent encryption and 
decryption
-  operations.
-  There are 3 key options as follows:
-  KeyLength = 64,  Keying option 1: K1 == K2 == K3 (Backward compatibility 
with DES)
-  KeyLength = 128, Keying option 2: K1 != K2 and K3 = K1 (Less Security)
-  KeyLength = 192  Keying option 3: K1 != K2 != K3 (Strongest)
-
-  If TdesContext is NULL, then return FALSE.
-  If Key is NULL, then return FALSE.
-  If KeyLength is not valid, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[out]  TdesContext  Pointer to TDES context being initialized.
-  @param[in]   Key  Pointer to the user-supplied TDES key.
-  @param[in]   KeyLengthLength of TDES key in bits.
-
-  @retval TRUE   TDES context initialization succeeded.
-  @retval FALSE  TDES context initialization failed.
-  @retval FALSE  This interface is not supported.
-
-**/
 BOOLEAN
 EFIAPI
-CryptoServiceTdesInit (
+DeprecatedCryptoServiceTdesInit (
   OUT  VOID *TdesContext,
   IN   CONST UINT8  *Key,
   IN   UINTNKeyLength
   )
 {
-  return CALL_BASECRYPTLIB (Tdes.Services.Init, TdesInit, (TdesContext, Key, 
KeyLength), FALSE);
+  return BaseCryptLibServciceDeprecated ("TdesInit"), FALSE;
 }
 
-/**
-  Performs TDES encryption on a data buffer of the specified size in ECB mode.
-
-  This function performs TDES encryption on data buffer pointed by Input, of 
specified
-  size of InputSize, in ECB mode.
-  InputSize must be multiple of block size (8 bytes). This function does not 
perform
-  padding. Caller must perform padding, if necessary, to ensure valid input 
data size.
-  TdesContext should be already correctly initialized by TdesInit(). Behavior 
with
-  invalid TDES context is undefined.
-
-  If TdesContext is NULL, then return FALSE.
-  If Input is NULL, then return FALSE.
-  If InputSize is not multiple of block size (8 bytes), then return FALSE.
-  If Output is NULL, then return FALSE.
-  If this interface is not supported, then return FALSE.
-
-  @param[in]   TdesContext  Pointer to the TDES 

[edk2-devel] [PATCH V3 5/8] CryptoPkg/BaseCryptLib: Retire Aes Ecb mode algorithm

2020-05-06 Thread Gao, Zhichao
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1898

Aes Ecb mode is not secure any longer.
Remove the Aes Ecb mode support from edk2.
Change the Aes Ecb mode field name in EDKII_CRYPTO_PROTOCOL to indicate the
function is unsupported any long.

Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Siyuan Fu 
Cc: Michael D Kinney 
Cc: Jiewen Yao 
Signed-off-by: Zhichao Gao 
---
 CryptoPkg/CryptoPkg.dsc   |  45 +++
 CryptoPkg/Driver/Crypto.c |  65 ++
 .../Library/BaseCryptLib/Cipher/CryptAes.c| 114 --
 .../BaseCryptLib/Cipher/CryptAesNull.c|  52 
 .../BaseCryptLibNull/Cipher/CryptAesNull.c|  52 
 .../BaseCryptLibOnProtocolPpi/CryptLib.c  |  76 
 CryptoPkg/Library/OpensslLib/OpensslLib.inf   |   1 -
 .../Library/OpensslLib/OpensslLibCrypto.inf   |   1 -
 CryptoPkg/Private/Protocol/Crypto.h   |  61 ++
 9 files changed, 40 insertions(+), 427 deletions(-)

diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 6ed7046563..1f68cc633b 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -137,27 +137,30 @@
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x06
 
 !if $(CRYPTO_SERVICES) IN "PACKAGE ALL"
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacMd5.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Random.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.X509.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tdes.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Arc4.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Hkdf.Family   | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Tls.Family| 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsSet.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.TlsGet.Family | 
PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacMd5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Md5.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Dh.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Random.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family   
   

Re: [edk2-devel] [PATCH v1 0/3] Check if required ACPI tables are installed

2020-05-06 Thread Gao, Zhichao
Pushed at 8af507c1f16d9cc311e83397881016e3887acfbb.. 
faef5a367c8345df906be3755e15e0dabc3105b3

> -Original Message-
> From: Krzysztof Koch 
> Sent: Friday, May 1, 2020 7:27 PM
> To: devel@edk2.groups.io; Gao, Zhichao ; Ni, Ray
> 
> Cc: Sami Mujawar ; Matteo Carlini
> ; Laura Moretta ; nd
> 
> Subject: RE: [edk2-devel] [PATCH v1 0/3] Check if required ACPI tables are
> installed
> 
> Hi Zhichao,
> 
> Any idea when this patch set will get merged?
> 
> Kind regards,
> 
> Krzysztof
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gao, Zhichao
> via groups.io
> Sent: Friday, April 17, 2020 8:20
> To: Krzysztof Koch ; devel@edk2.groups.io; Ni, Ray
> 
> Cc: Sami Mujawar ; Matteo Carlini
> ; Laura Moretta ; nd
> 
> Subject: Re: [edk2-devel] [PATCH v1 0/3] Check if required ACPI tables are
> installed
> 
> For the patch set:
> Reviewed-by: Zhichao Gao 
> 
> Thanks,
> Zhichao
> 
> > -Original Message-
> > From: Krzysztof Koch 
> > Sent: Tuesday, April 14, 2020 4:50 PM
> > To: devel@edk2.groups.io; Ni, Ray ; Gao, Zhichao
> > 
> > Cc: Sami Mujawar ; Matteo Carlini
> > ; Laura Moretta ; nd
> > 
> > Subject: RE: [edk2-devel] [PATCH v1 0/3] Check if required ACPI tables
> > are installed
> >
> > Hi,
> >
> > Can I get a review for this patch series?
> >
> > Thanks,
> >
> > Krzysztof
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of
> > Krzysztof Koch via Groups.Io
> > Sent: Wednesday, March 25, 2020 9:39
> > To: devel@edk2.groups.io
> > Cc: ray...@intel.com; zhichao@intel.com; Sami Mujawar
> > ; Matteo Carlini ;
> Laura
> > Moretta ; nd 
> > Subject: [edk2-devel] [PATCH v1 0/3] Check if required ACPI tables are
> > installed
> >
> > This patch series adds a new capability to the Acpiview UEFI shell tool.
> > Using the -r command line parameter, it is now possible to choose a
> > specification which lists mandatory ACPI tables. The parameter value
> > is then consumed by a library which validates ACPI tables identified
> > on the platform against these requirements.
> >
> > The -r parameter is architecture agnostic. However, as of now, the
> > possible values for the parameter are only defined in the context of
> > the Arm architecture.
> >
> > For Arm-based platforms, it is now possible to validate that Server
> > Base Boot Requirements (SBBR) mandatory ACPI tables are present on the
> platform.
> >
> > Changes can be seen at:
> > https://github.com/KrzysztofKoch1/edk2/tree/617_sbbr_validate_acpi_tab
> > l
> > e_counts_v1
> >
> > Krzysztof Koch (3):
> >   ShellPkg: acpiview: Add -r parameter for table requirements validation
> >   ShellPkg: acpiview: Add library for SBBR ACPI requirements validation
> >   ShellPkg: acpiview: Check if SBBR mandatory ACPI tables are
> > installed
> >
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c 
> >   |
> > 16 ++
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
> >   | 104
> > -
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
> >   |  44
> > +++-
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
> > | 222 
> >  ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
> > |  91 
> >
> > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> > dLib.inf |   6 +-
> >
> > ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewComman
> > dLib.uni |  14 +-
> >  7 files changed, 492 insertions(+), 5 deletions(-)  create mode
> > 100644
> > ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c
> >  create mode 100644
> > ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h
> >
> > --
> > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
> >
> >
> >
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58768): https://edk2.groups.io/g/devel/message/58768
Mute This Topic: https://groups.io/mt/72537308/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2] IntelFsp2Pkg: Support Multi-Phase SiInit and debug handlers.

2020-05-06 Thread Chiu, Chasel
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2698

To enhance FSP silicon initialization flexibility an optional
Multi-Phase API is introduced and FSP header needs update for
new API offset. Also new SecCore module created for
FspMultiPhaseSiInit API

New ARCH_UPD introduced for enhancing FSP debug message
flexibility now bootloader can pass its own debug handler
function pointer and FSP will call the function to handle
debug message.

Cc: Maurice Ma 
Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Chasel Chiu 
---
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c  |   6 +++---
 IntelFsp2Pkg/FspSecCore/FspSecCoreSS.inf|  48 

 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm |   5 -
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntrySS.nasm |  61 
+
 IntelFsp2Pkg/Include/FspEas/FspApi.h| 124 
++--
 IntelFsp2Pkg/Include/FspGlobalData.h|   3 ++-
 IntelFsp2Pkg/Include/Guid/FspHeaderFile.h   |  10 --
 7 files changed, 248 insertions(+), 9 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c 
b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
index 8e0595fe9a..1334959005 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFspApiChk.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -59,7 +59,7 @@ FspApiCallingCheck (
 Status = EFI_UNSUPPORTED;
   }
 }
-  } else if (ApiIdx == FspSiliconInitApiIndex) {
+  } else if ((ApiIdx == FspSiliconInitApiIndex) || (ApiIdx == 
FspMultiPhaseSiInitApiIndex)) {
 //
 // FspSiliconInit check
 //
@@ -68,7 +68,7 @@ FspApiCallingCheck (
 } else {
   if (FspData->Signature != FSP_GLOBAL_DATA_SIGNATURE) {
 Status = EFI_UNSUPPORTED;
-  } else if (EFI_ERROR (FspUpdSignatureCheck (ApiIdx, ApiParam))) {
+  } else if (EFI_ERROR (FspUpdSignatureCheck (FspSiliconInitApiIndex, 
ApiParam))) {
 Status = EFI_INVALID_PARAMETER;
   }
 }
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreSS.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreSS.inf
new file mode 100644
index 00..184101c7d3
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreSS.inf
@@ -0,0 +1,48 @@
+## @file
+#  Sec Core for FSP to support MultiPhase (SeparatePhase) SiInitialization.
+#
+#  Copyright (c) 2020, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = FspSecCoreSS
+  FILE_GUID  = DF0FCD70-264A-40BF-BBD4-06C76DB19CB1
+  MODULE_TYPE= SEC
+  VERSION_STRING = 1.0
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32
+#
+
+[Sources]
+  SecFspApiChk.c
+  SecFsp.h
+
+[Sources.IA32]
+  Ia32/Stack.nasm
+  Ia32/FspApiEntrySS.nasm
+  Ia32/FspApiEntryCommon.nasm
+  Ia32/FspHelper.nasm
+
+[Binaries.Ia32]
+  RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
+
+[Packages]
+  MdePkg/MdePkg.dec
+  IntelFsp2Pkg/IntelFsp2Pkg.dec
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  BaseLib
+  PciCf8Lib
+  SerialPortLib
+  FspSwitchStackLib
+  FspCommonLib
+  FspSecPlatformLib
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm
index bb4451b145..26ae7d9fd3 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryCommon.nasm
@@ -1,7 +1,7 @@
 ;; @file
 ;  Provide FSP API entry points.
 ;
-; Copyright (c) 2016, Intel Corporation. All rights reserved.
+; Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
 ; SPDX-License-Identifier: BSD-2-Clause-Patent
 ;;
 
@@ -62,6 +62,9 @@ FspApiCommon2:
   cmpeax, 3   ; FspMemoryInit API
   jz FspApiCommon3
 
+  cmpeax, 6   ; FspMultiPhaseSiInitApiIndex API
+  jz FspApiCommon3
+
   call   ASM_PFX(AsmGetFspInfoHeader)
   jmpASM_PFX(Loader2PeiSwitchStack)
 
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntrySS.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntrySS.nasm
new file mode 100644
index 00..278934dc47
--- /dev/null
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntrySS.nasm
@@ -0,0 +1,61 @@
+;; @file
+;  Provide FSP API entry points.
+;
+; Copyright (c) 2020, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+
+SECTION .text
+
+;
+; Following functions will be provided in C
+;
+extern ASM_PFX(FspApiCommon)
+

Re: [edk2-devel] [edk2-platforms][PATCH 1/1] RPi: allow selecting which system config tables are exposed

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 2:59 AM, Andrei Warkentin wrote:

Today we just have an option to hide DT entirely, while ACPI
is always exposed. This change extends the option to
provide all three choices:
- ACPI only
- ACPI + DT
- DT only

Why? Because not all OSes will prefer DT over ACPI when both are available.

To do this cleanly, move the variable structure and value definitions
into a separate header, ConfigVars.h.

Signed-off-by: Andrei Warkentin 


I'd prefer it if DT and ACPI were mutually exclusive, so that it is 
never left up to the OS to reason about which one is the correct one.


This aligns with other platforms we have in the tree.


---
  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c  |  20 +--
  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf|   2 +-
  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   9 +-
  Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 146 
++--
  Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c|   6 +-
  Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf  |   2 +-
  Platform/RaspberryPi/Include/ConfigVars.h   | 131 
++
  Platform/RaspberryPi/RPi3/RPi3.dsc  |   4 +-
  Platform/RaspberryPi/RPi4/RPi4.dsc  |   4 +-
  Platform/RaspberryPi/RaspberryPi.dec|   2 +-
  10 files changed, 171 insertions(+), 155 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index c90c2530..00867879 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -22,6 +22,7 @@
  #include 
  #include 
  #include 
+#include 
  #include "ConfigDxeFormSetGuid.h"
  
  #define FREQ_1_MHZ 100

@@ -154,11 +155,11 @@ SetupVariables (
}
  
Size = sizeof (UINT32);

-  Status = gRT->GetVariable (L"OptDeviceTree",
+  Status = gRT->GetVariable (L"SystemTableMode",
,
NULL, , );
if (EFI_ERROR (Status)) {
-PcdSet32 (PcdOptDeviceTree, PcdGet32 (PcdOptDeviceTree));
+PcdSet32 (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
}
  
Size = sizeof (UINT32);

@@ -259,10 +260,10 @@ ApplyVariables (
UINT64 SystemMemorySize;
  
switch (CpuClock) {

-  case 0: // Low
+  case CHIPSET_CPU_CLOCK_LOW:
  Rate = FixedPcdGet32 (PcdCpuLowSpeedMHz) * FREQ_1_MHZ;
  break;
-  case 1: // Default
+  case CHIPSET_CPU_CLOCK_DEFAULT:
  /*
   * What the Raspberry Pi Foundation calls "max clock rate" is really the 
default value
   * from: 
https://www.raspberrypi.org/documentation/configuration/config-txt/overclocking.md
@@ -272,10 +273,10 @@ ApplyVariables (
DEBUG ((DEBUG_ERROR, "Couldn't read default CPU speed %r\n", Status));
  }
  break;
-  case 2: // Max
+  case CHIPSET_CPU_CLOCK_MAX:
  Rate = FixedPcdGet32 (PcdCpuMaxSpeedMHz) * FREQ_1_MHZ;
  break;
-  case 3: // Custom
+  case CHIPSET_CPU_CLOCK_CUSTOM:
  Rate = CustomCpuClock * FREQ_1_MHZ;
  break;
}
@@ -487,8 +488,11 @@ ConfigInitialize (
  DEBUG ((DEBUG_ERROR, "Couldn't install ConfigDxe configuration pages: 
%r\n", Status));
}
  
-  Status = LocateAndInstallAcpiFromFv ();

-  ASSERT_EFI_ERROR (Status);
+  if (PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_ACPI ||
+  PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {
+ Status = LocateAndInstallAcpiFromFv ();
+ ASSERT_EFI_ERROR (Status);
+  }
  
return EFI_SUCCESS;

  }
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index 57963baf..e47f3af6 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -77,7 +77,7 @@
gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
-  gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree
+  gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
gRaspberryPiTokenSpaceGuid.PcdRamMoreThan3GB
gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB
  
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni

index 07660072..7195e497 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
@@ -41,10 +41,11 @@
  #string STR_ADVANCED_3GB_OFF #language en-US "Disabled"
  #string STR_ADVANCED_3GB_ON  #language en-US "Enabled"
  
-#string STR_ADVANCED_DT_PROMPT   #language en-US "Device Tree"

-#string STR_ADVANCED_DT_HELP #language en-US "Disable this option to force 
OSes such as GNU/Linux to use ACPI"
-#string STR_ADVANCED_DT_OFF  #language en-US "Disabled (Force ACPI)"
-#string STR_ADVANCED_DT_ON   #language en-US "Enabled"
+#string 

[edk2-devel] [PATCH] EmbeddedPkg/EmbeddedPkg.dsc: remove some stale component references

2020-05-06 Thread Ard Biesheuvel
Some driver were recently moved to edk2-platforms, but the DSC file
in EmbeddedPkg still refers to them. Drop these references.

Signed-off-by: Ard Biesheuvel 
---
 EmbeddedPkg/EmbeddedPkg.dsc | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
index 8842acc4cbf4..e88d76ab2f04 100644
--- a/EmbeddedPkg/EmbeddedPkg.dsc
+++ b/EmbeddedPkg/EmbeddedPkg.dsc
@@ -225,10 +225,6 @@ [Components.common]
 
   EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
 
-  # Drivers
-  EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
-  EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
-
   EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
   EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
   EmbeddedPkg/Library/FdtLib/FdtLib.inf
@@ -243,9 +239,6 @@ [Components.common]
   DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
   }
 
-[Components.ARM]
-  EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf
-
 [Components.ARM, Components.AARCH64]
   EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf
   EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58685): https://edk2.groups.io/g/devel/message/58685
Mute This Topic: https://groups.io/mt/74024182/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/1] SignedCapsulePkg: Add handling of NULL returned from FMP Descriptor

2020-05-06 Thread Gaurav Jain
Firmware management protocol that does not support GetImageInfo
return Unsupported.
hence FMP Image Information Buffer is NULL.
Freeing NULL buffer results in Exception.

Added NULL check for Image Info buffer
and skip processing FMP protocol handle,
which does not support GetImageInfo.

Signed-off-by: Gaurav Jain 
---
 .../Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 
a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c 
b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
index bdb70bdb32cc..b4438ac6f55a 100644
--- a/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
+++ b/SignedCapsulePkg/Universal/SystemFirmwareUpdate/SystemFirmwareUpdateDxe.c
@@ -579,7 +579,7 @@ GetFmpImageDescriptors (
 // PackageVersionName
   );
   if (Status != EFI_BUFFER_TOO_SMALL) {
-DEBUG ((DEBUG_ERROR, "SystemFirmwareUpdateDxe: Unexpected Failure.  Status 
= %r\n", Status));
+DEBUG ((DEBUG_INFO, "SystemFirmwareUpdateDxe: Status = %r\n", Status));
 return NULL;
   }
 
@@ -678,6 +678,9 @@ FindMatchingFmpHandles (
 
 );
 
+if (OriginalFmpImageInfoBuf == NULL) {
+  continue;
+}
 //
 // Loop through the set of EFI_FIRMWARE_IMAGE_DESCRIPTORs.
 //
-- 
2.7.4


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58686): https://edk2.groups.io/g/devel/message/58686
Mute This Topic: https://groups.io/mt/74024929/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH edk2-platforms 1/1] Platform/RaspberryPi/RPi4: drop Cortex-A53 erratum workaround

2020-05-06 Thread Ard Biesheuvel
The Raspberry Pi4 uses Cortex-A72 cores so it has no need for the
Cortex-A53 ADRP erratum workaround.

Signed-off-by: Ard Biesheuvel 
---
 Platform/RaspberryPi/RPi4/RPi4.dsc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index a112174c5303..0d54fa477ca2 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -242,7 +242,6 @@ [BuildOptions]
   GCC:*_*_*_ASLPP_FLAGS   = -DRPI_MODEL=4
   GCC:*_*_*_ASLCC_FLAGS   = -DRPI_MODEL=4
   GCC:*_*_*_VFRPP_FLAGS   = -DRPI_MODEL=4
-  GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
   GCC:RELEASE_*_*_CC_FLAGS= -DMDEPKG_NDEBUG -DNDEBUG
 
 [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58687): https://edk2.groups.io/g/devel/message/58687
Mute This Topic: https://groups.io/mt/74025440/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] EmbeddedPkg/EmbeddedPkg.dsc: remove some stale component references

2020-05-06 Thread Leif Lindholm
On Wed, May 06, 2020 at 09:06:37 +0200, Ard Biesheuvel wrote:
> Some driver were recently moved to edk2-platforms, but the DSC file
> in EmbeddedPkg still refers to them. Drop these references.
> 
> Signed-off-by: Ard Biesheuvel 

Sorry, should have cought that in review.
Reviewed-by: Leif Lindholm 


> ---
>  EmbeddedPkg/EmbeddedPkg.dsc | 7 ---
>  1 file changed, 7 deletions(-)
> 
> diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc
> index 8842acc4cbf4..e88d76ab2f04 100644
> --- a/EmbeddedPkg/EmbeddedPkg.dsc
> +++ b/EmbeddedPkg/EmbeddedPkg.dsc
> @@ -225,10 +225,6 @@ [Components.common]
>  
>EmbeddedPkg/Universal/MmcDxe/MmcDxe.inf
>  
> -  # Drivers
> -  EmbeddedPkg/Drivers/Lan9118Dxe/Lan9118Dxe.inf
> -  EmbeddedPkg/Drivers/SataSiI3132Dxe/SataSiI3132Dxe.inf
> -
>EmbeddedPkg/Library/AcpiLib/AcpiLib.inf
>EmbeddedPkg/Library/DebugAgentTimerLibNull/DebugAgentTimerLibNull.inf
>EmbeddedPkg/Library/FdtLib/FdtLib.inf
> @@ -243,9 +239,6 @@ [Components.common]
>DmaLib|EmbeddedPkg/Library/NonCoherentDmaLib/NonCoherentDmaLib.inf
>}
>  
> -[Components.ARM]
> -  EmbeddedPkg/Drivers/Isp1761UsbDxe/Isp1761UsbDxe.inf
> -
>  [Components.ARM, Components.AARCH64]
>EmbeddedPkg/Application/AndroidBoot/AndroidBootApp.inf
>EmbeddedPkg/Application/AndroidFastboot/AndroidFastbootApp.inf
> -- 
> 2.17.1
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58688): https://edk2.groups.io/g/devel/message/58688
Mute This Topic: https://groups.io/mt/74024182/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 1/1] Platform/RaspberryPi/RPi4: drop Cortex-A53 erratum workaround

2020-05-06 Thread Leif Lindholm
On Wed, May 06, 2020 at 11:56:14 +0200, Ard Biesheuvel wrote:
> The Raspberry Pi4 uses Cortex-A72 cores so it has no need for the
> Cortex-A53 ADRP erratum workaround.
> 
> Signed-off-by: Ard Biesheuvel 

Reviewed-by: Leif Lindholm 

> ---
>  Platform/RaspberryPi/RPi4/RPi4.dsc | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
> b/Platform/RaspberryPi/RPi4/RPi4.dsc
> index a112174c5303..0d54fa477ca2 100644
> --- a/Platform/RaspberryPi/RPi4/RPi4.dsc
> +++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
> @@ -242,7 +242,6 @@ [BuildOptions]
>GCC:*_*_*_ASLPP_FLAGS   = -DRPI_MODEL=4
>GCC:*_*_*_ASLCC_FLAGS   = -DRPI_MODEL=4
>GCC:*_*_*_VFRPP_FLAGS   = -DRPI_MODEL=4
> -  GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
>GCC:RELEASE_*_*_CC_FLAGS= -DMDEPKG_NDEBUG -DNDEBUG
>  
>  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]
> -- 
> 2.17.1
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58689): https://edk2.groups.io/g/devel/message/58689
Mute This Topic: https://groups.io/mt/74025440/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 1/5] Platform/RaspberryPi/DualSerialPortLib: split up to ease reuse

2020-05-06 Thread Pete Batard

One minor whitespace issue inline:

On 2020.05.05 15:50, Ard Biesheuvel wrote:

In preparation of creating different versions of DualSerialPortLib,
split off the parts that will be shared between all versions.

Signed-off-by: Ard Biesheuvel 
---
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf |   
5 +-
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.h   |  
82 +++
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c   | 
229 +---
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLibCommon.c | 
218 +++
  4 files changed, 305 insertions(+), 229 deletions(-)

diff --git 
a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf 
b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
index af1e6b026fe6..fda9ff2bcbf9 100644
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
@@ -19,9 +19,8 @@ [Defines]
  
  [Packages]

ArmPlatformPkg/ArmPlatformPkg.dec
-  EmbeddedPkg/EmbeddedPkg.dec
-  MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
Silicon/Broadcom/Bcm283x/Bcm283x.dec
  
  [LibraryClasses]

@@ -32,6 +31,8 @@ [LibraryClasses]
  
  [Sources]

DualSerialPortLib.c
+  DualSerialPortLib.h
+  DualSerialPortLibCommon.c
  
  [Pcd]

gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterAccessWidth ## 
SOMETIMES_CONSUMES
diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.h 
b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.h
new file mode 100644
index ..a8d150f516b9
--- /dev/null
+++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.h
@@ -0,0 +1,82 @@
+/** @file
+  16550 and PL011 Serial Port library functions for Raspberry Pi
+
+  Copyright (c) 2020, Pete Batard 
+  Copyright (c) 2018, AMD Incorporated. All rights reserved.
+  Copyright (c) 2014, Hewlett-Packard Development Company, L.P.
+  Copyright (c) 2012 - 2016, ARM Ltd. All rights reserved.
+  Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+
+#define PL011_UART_REGISTER_BASE  BCM2836_PL011_UART_BASE_ADDRESS
+#define MINI_UART_REGISTER_BASE   (BCM2836_MINI_UART_BASE_ADDRESS + 0x40)
+
+//
+// 16550 UART register offsets and bitfields
+//
+#define R_UART_RXBUF  0   // LCR_DLAB = 0
+#define R_UART_TXBUF  0   // LCR_DLAB = 0
+#define R_UART_BAUD_LOW   0   // LCR_DLAB = 1
+#define R_UART_BAUD_HIGH  1   // LCR_DLAB = 1
+#define R_UART_IER1   // LCR_DLAB = 0
+#define R_UART_FCR2
+#define   B_UART_FCR_FIFOEBIT0
+#define   B_UART_FCR_FIFO64   BIT5
+#define R_UART_LCR3
+#define   B_UART_LCR_DLAB BIT7
+#define R_UART_MCR4
+#define   B_UART_MCR_DTRC BIT0
+#define   B_UART_MCR_RTS  BIT1
+#define R_UART_LSR5
+#define   B_UART_LSR_RXRDYBIT0
+#define   B_UART_LSR_TXRDYBIT5
+#define   B_UART_LSR_TEMT BIT6
+#define R_UART_MSR6
+#define   B_UART_MSR_CTS  BIT4
+#define   B_UART_MSR_DSR  BIT5
+#define   B_UART_MSR_RI   BIT6
+#define   B_UART_MSR_DCD  BIT7
+
+extern BOOLEAN UsePl011Uart;
+extern BOOLEAN UsePl011UartSet;
+
+/**
+  Read an 8-bit 16550 register.
+
+  @param  BaseThe base address register of UART device.
+  @param  Offset  The offset of the 16550 register to read.
+
+  @return The value read from the 16550 register.
+
+**/
+UINT8
+SerialPortReadRegister (
+  UINTN  Base,
+  UINTN  Offset
+  );
+
+/**
+  Write an 8-bit 16550 register.
+
+  @param  BaseThe base address register of UART device.
+  @param  Offset  The offset of the 16550 register to write.
+  @param  Value   The value to write to the 16550 register specified by Offset.
+
+  @return The value written to the 16550 register.
+
+**/
+UINT8
+SerialPortWriteRegister (
+  UINTN  Base,
+  UINTN  Offset,
+  UINT8  Value
+  );
+


There's an extra trailing space here that could be removed.


diff --git a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c 
b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
index 05e12f383785..b1d17d3fa04a 100644
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
+++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
@@ -13,132 +13,13 @@
  **/
  
  #include 

-#include 
-#include 
-#include 
  #include 
  #include 
  #include 
  #include 
  #include 
  
-BOOLEAN UsePl011Uart  = FALSE;

-BOOLEAN UsePl011UartSet   = FALSE;
-
-#define PL011_UART_REGISTER_BASE  BCM2836_PL011_UART_BASE_ADDRESS
-#define MINI_UART_REGISTER_BASE   (BCM2836_MINI_UART_BASE_ADDRESS + 0x40)
-
-//
-// 16550 UART register offsets and bitfields
-//

Re: [edk2-devel] [PATCH edk2-platforms 2/5] Platform/RaspberryPi: introduce DebugDualSerialPortLib

2020-05-06 Thread Pete Batard

On 2020.05.05 15:50, Ard Biesheuvel wrote:

On DEBUG builds that use the serial port directly for debug output,
every module reinitializes the UART hardware, through the DebugLib
constructor calling SerialPortInitialize.

This is unnecessary, but usually harmless. However, in cases where this
requires information that is non-trivial to obtain (e.g., the rate of
the clock source feeding the baud clock), it results in a special kind
of dependency hell that can only be fully appreciated by seasoned EDK2
connoisseurs [0].

As a first step towards solving this mess, implement a special version
of the Raspberry Pi dual serial port library that only implements the
SerialPortInitialize() and SerialPortWrite() library functions, and make
the former an empty stub. This makes it only suitable for use by modules
that inherit a dependency on SerialPortLib via DebugLib, and requires us
to ensure that the baud clock is programmed correctly by the SEC phase.

Use this version of the library to satisfy all SerialPortLib dependencies
except the ones in PrePi and in SerialDxe. These will retain the full
version, which is the only one that still consumes PcdSerialClockRate.

[0] There are two distinct problems making this mess almost unsolvable:
   - SerialPortInitialize() is called directly in various places instead
 of relying on constructor ordering, so adding a constructor to a
 SerialPortLib implementation does not help,
   - Constructor ordering resolution in the EDK2 tooling fails to take
 transitive dependencies into account if an intermediate library has
 no constructor it self. For instance, if LibA depends on LibB, which
 depends on LibC, the constructors of LibA and LibC could be called in
 any order if LibB does not have a constructor itself (and fixing this
 breaks all the platforms in the tree)

Signed-off-by: Ard Biesheuvel 
---
  Platform/RaspberryPi/RPi3/RPi3.dsc| 
12 +++--
  Platform/RaspberryPi/RPi4/RPi4.dsc| 
12 +++--
  Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSerialPortLib.inf | 
46 
  Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSerialPortLib.c   | 
28 
  4 files changed, 92 insertions(+), 6 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 563fb891b841..d7218219fc5a 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -127,7 +127,7 @@ [LibraryClasses.common]
# Dual serial port library

PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
-  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSerialPortLib.inf
  
# Cryptographic libraries

IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -521,7 +521,10 @@ [Components.common]
#
# PEI Phase modules
#
-  ArmPlatformPkg/PrePi/PeiUniCore.inf
+  ArmPlatformPkg/PrePi/PeiUniCore.inf {
+
+  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+  }
  
#

# DXE
@@ -569,7 +572,10 @@ [Components.common]
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
-  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
+  MdeModulePkg/Universal/SerialDxe/SerialDxe.inf {
+
+  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+  }
Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
  
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 4deccd9d3ecc..4fb015b077e6 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -127,7 +127,7 @@ [LibraryClasses.common]
# Dual serial port library

PL011UartClockLib|ArmPlatformPkg/Library/PL011UartClockLib/PL011UartClockLib.inf
PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
-  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DebugDualSerialPortLib.inf
  
# Cryptographic libraries

IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -536,7 +536,10 @@ [Components.common]
#
# PEI Phase modules
#
-  ArmPlatformPkg/PrePi/PeiUniCore.inf
+  ArmPlatformPkg/PrePi/PeiUniCore.inf {
+
+  
SerialPortLib|Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.inf
+  }
  
#

# DXE
@@ -584,7 +587,10 @@ [Components.common]
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf

Re: [edk2-devel] [PATCH edk2-platforms 3/5] Platform/RaspberryPi: fix 16550 divisor calculation logic

2020-05-06 Thread Pete Batard

One general remark below:

On 2020.05.05 19:10, Ard Biesheuvel wrote:

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

The 16550 'miniUART' on the Raspberry Pi gets its input clock from
different sources on RPi3 and RPi3. Fix the logic that derives the


This should be 'Rpi3 and RPi4'


divisor for the 16550 baud clock on the respective platforms.

While at it, make the input clock PCD patchable for RPi3 so we can
manipulate it at runtime in a future patch.


For the sake of harmonization between platforms, wouldn't we want to 
also declare the PCD patchable on RPi4 as well (even though we obviously 
aren't going to patch it for the time being)?


There is some plan of factorizing the DSC content, so if that doesn't 
hurt us, I'd propose we try to keep the Pi3 and Pi4 version as close as 
possible.


This also ties in with my remark for the next patch.



Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Co-authored-by: Ard Biesheuvel 
Signed-off-by: Pete Batard 
Signed-off-by: Ard Biesheuvel 
---
  Platform/RaspberryPi/RPi3/RPi3.dsc 
|  4 +++-
  Platform/RaspberryPi/RPi4/RPi4.dsc 
|  2 +-
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c | 
14 --

  3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc

index d7218219fc5a..96b27400eef8 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -409,7 +409,6 @@ [PcdsFixedAtBuild.common]
    gArmPlatformTokenSpaceGuid.PL011UartClkInHz|4800
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|5
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
    gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
@@ -441,6 +440,9 @@ [PcdsFixedAtBuild.common]
    gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
+[PcdsPatchableInModule]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|25000
+
  [PcdsDynamicHii.common.DEFAULT]
    #
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc

index 4fb015b077e6..5d8bd88d7e34 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -420,7 +420,7 @@ [PcdsFixedAtBuild.common]
    gArmPlatformTokenSpaceGuid.PL011UartClkInHz|4800
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|5
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|10
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
    gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
diff --git 
a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c 
b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c

index b1d17d3fa04a..5e83bbf022eb 100644
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
+++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
@@ -41,18 +41,20 @@ SerialPortGetDivisor (
    // On the Raspberry Pi, the clock to use for the 16650-compatible 
UART
    // is the base clock divided by the 12.12 fixed point VPU clock 
divisor.

    //
-  BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate) * 4;
+  BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate);
+#if (RPI_MODEL == 4)
    Divisor = MmioRead32(BCM2836_CM_BASE + 
BCM2836_CM_VPU_CLOCK_DIVISOR) & 0xFF;

    if (Divisor != 0)
  BaseClockRate = (BaseClockRate << 12) / Divisor;
+#endif
    //
-  // Now calculate divisor for baud generator
-  //    Ref_Clk_Rate / Baud_Rate / 16
+  // As per the BCM2xxx datasheets:
+  // baudrate = system_clock_freq / (8 * (divisor + 1)).
    //
-  Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 16);
-  if (((UINT32)BaseClockRate % (SerialBaudRate * 16)) >= 
SerialBaudRate * 8) {

-    Divisor++;
+  Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 8);
+  if (Divisor != 0) {
+    Divisor--;
    }
    return Divisor;
  }








Reviewed-by: Pete Batard 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58692): https://edk2.groups.io/g/devel/message/58692
Mute This Topic: https://groups.io/mt/73999456/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 4/5] Platform/RaspberryPi3: query firmware for 16550 input clock at boot

2020-05-06 Thread Pete Batard

One remark below:

On 2020.05.05 19:11, Ard Biesheuvel wrote:

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

Query the firmware for the clock rate that is used to drive the
16550 baud clock, so that we can program the correct baud rate.

Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Co-authored-by: Ard Biesheuvel 
Signed-off-by: Pete Batard 
Signed-off-by: Ard Biesheuvel 
---
  Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
| 25 +++-

  1 file changed, 24 insertions(+), 1 deletion(-)

diff --git 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S

index 91dfe1bb981e..35580e4ed73a 100644
--- 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
+++ 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S

@@ -3,7 +3,7 @@
   *  Copyright (c) 2020, Andrei Warkentin 
   *  Copyright (c) 2019-2020, Pete Batard 
   *  Copyright (c) 2016, Linaro Limited. All rights reserved.
- *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+ *  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
   *
   *  SPDX-License-Identifier: BSD-2-Clause-Patent
   *
@@ -85,6 +85,14 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  adr x2, mBoardRevision
  str w0, [x2]
+#if (RPI_MODEL == 3)


As noted by Pete off-list, doing this doesn't work unless we add 
something like


GCC:*_*_*_PP_FLAGS  = -DRPI_MODEL=3

to the [BuildOptions] in RPi3.dsc




+    run .Lclkinfo_buffer
+
+    ldr w0, .Lfrequency
+    adrp    x2, _gPcd_BinaryPatch_PcdSerialClockRate
+    str w0, [x2, :lo12:_gPcd_BinaryPatch_PcdSerialClockRate]
+#endif
+


Since we're modifying a patchable PCD here, shouldn't we add a:

[PatchPcd]
  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate

section in PlatformLib.inf?

Of course, if we do that, we can't keep PcdSerialClockRate fixed for 
RPi4, as the build process will complain about PCD mismatch.


I also wouldn't mind a comment that explains how one arrives at figuring 
out that "_gPcd_BinaryPatch_PcdSerialClockRate" should be used to locate 
our address (and possibly the addition of :lo12:), because I don't think 
it's going to be that straightforward for people reading the code for 
the first time, though I fear that the explanation will boil down to "we 
need to do it this specific way for a gcc aarch64 relocation"...



  ret
  .align  4
@@ -127,6 +135,21 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  .long   0   // end tag
  .set    .Lrevinfo_size, . - .Lrevinfo_buffer
+#if (RPI_MODEL == 3)
+    .align  4
+.Lclkinfo_buffer:
+    .long   .Lclkinfo_size
+    .long   0x0
+    .long   RPI_MBOX_GET_CLOCK_RATE
+    .long   8   // buf size
+    .long   4   // input len
+    .long   4   // clock id: 0x04 = Core/VPU
+.Lfrequency:
+    .long   0   // frequency
+    .long   0   // end tag
+    .set    .Lclkinfo_size, . - .Lclkinfo_buffer
+#endif
+
  //UINTN
  //ArmPlatformGetPrimaryCoreMpId (
  //  VOID








With addition of "GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=3" in the .dsc:
Reviewed-by: Pete Batard 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58693): https://edk2.groups.io/g/devel/message/58693
Mute This Topic: https://groups.io/mt/73999457/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 3/5] Platform/RaspberryPi: fix 16550 divisor calculation logic

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 12:18 PM, Pete Batard wrote:

One general remark below:

On 2020.05.05 19:10, Ard Biesheuvel wrote:

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

The 16550 'miniUART' on the Raspberry Pi gets its input clock from
different sources on RPi3 and RPi3. Fix the logic that derives the


This should be 'Rpi3 and RPi4'


divisor for the 16550 baud clock on the respective platforms.

While at it, make the input clock PCD patchable for RPi3 so we can
manipulate it at runtime in a future patch.


For the sake of harmonization between platforms, wouldn't we want to 
also declare the PCD patchable on RPi4 as well (even though we obviously 
aren't going to patch it for the time being)?




I'd prefer not to. That way, we can easily spot problems when the 
patching code is incorporated inadvertently.


There is some plan of factorizing the DSC content, so if that doesn't 
hurt us, I'd propose we try to keep the Pi3 and Pi4 version as close as 
possible.


This also ties in with my remark for the next patch.



Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Co-authored-by: Ard Biesheuvel 
Signed-off-by: Pete Batard 
Signed-off-by: Ard Biesheuvel 
---
  Platform/RaspberryPi/RPi3/RPi3.dsc |  4 +++-
  Platform/RaspberryPi/RPi4/RPi4.dsc |  2 +-
  Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c 
| 14 --

  3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc

index d7218219fc5a..96b27400eef8 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -409,7 +409,6 @@ [PcdsFixedAtBuild.common]
    gArmPlatformTokenSpaceGuid.PL011UartClkInHz|4800
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|5
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
    gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
@@ -441,6 +440,9 @@ [PcdsFixedAtBuild.common]
    gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor|L"EDK2"
    gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
+[PcdsPatchableInModule]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|25000
+
  [PcdsDynamicHii.common.DEFAULT]
    #
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc

index 4fb015b077e6..5d8bd88d7e34 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -420,7 +420,7 @@ [PcdsFixedAtBuild.common]
    gArmPlatformTokenSpaceGuid.PL011UartClkInHz|4800
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio|TRUE
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterStride|4
-  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|5
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate|10
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialFifoControl|0x27
    gEfiMdeModulePkgTokenSpaceGuid.PcdSerialExtendedTxFifoSize|8
    gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate|115200
diff --git 
a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c 
b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c

index b1d17d3fa04a..5e83bbf022eb 100644
--- a/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
+++ b/Platform/RaspberryPi/Library/DualSerialPortLib/DualSerialPortLib.c
@@ -41,18 +41,20 @@ SerialPortGetDivisor (
    // On the Raspberry Pi, the clock to use for the 16650-compatible 
UART
    // is the base clock divided by the 12.12 fixed point VPU clock 
divisor.

    //
-  BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate) * 4;
+  BaseClockRate = (UINT64)PcdGet32 (PcdSerialClockRate);
+#if (RPI_MODEL == 4)
    Divisor = MmioRead32(BCM2836_CM_BASE + 
BCM2836_CM_VPU_CLOCK_DIVISOR) & 0xFF;

    if (Divisor != 0)
  BaseClockRate = (BaseClockRate << 12) / Divisor;
+#endif
    //
-  // Now calculate divisor for baud generator
-  //    Ref_Clk_Rate / Baud_Rate / 16
+  // As per the BCM2xxx datasheets:
+  // baudrate = system_clock_freq / (8 * (divisor + 1)).
    //
-  Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 16);
-  if (((UINT32)BaseClockRate % (SerialBaudRate * 16)) >= 
SerialBaudRate * 8) {

-    Divisor++;
+  Divisor = (UINT32)BaseClockRate / (SerialBaudRate * 8);
+  if (Divisor != 0) {
+    Divisor--;
    }
    return Divisor;
  }








Reviewed-by: Pete Batard 




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58695): https://edk2.groups.io/g/devel/message/58695
Mute This Topic: https://groups.io/mt/73999456/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 4/5] Platform/RaspberryPi3: query firmware for 16550 input clock at boot

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 12:18 PM, Pete Batard wrote:

One remark below:

On 2020.05.05 19:11, Ard Biesheuvel wrote:

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

Query the firmware for the clock rate that is used to drive the
16550 baud clock, so that we can program the correct baud rate.

Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Co-authored-by: Ard Biesheuvel 
Signed-off-by: Pete Batard 
Signed-off-by: Ard Biesheuvel 
---
  
Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
| 25 +++-

  1 file changed, 24 insertions(+), 1 deletion(-)

diff --git 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 


index 91dfe1bb981e..35580e4ed73a 100644
--- 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
+++ 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S

@@ -3,7 +3,7 @@
   *  Copyright (c) 2020, Andrei Warkentin 
   *  Copyright (c) 2019-2020, Pete Batard 
   *  Copyright (c) 2016, Linaro Limited. All rights reserved.
- *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+ *  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
   *
   *  SPDX-License-Identifier: BSD-2-Clause-Patent
   *
@@ -85,6 +85,14 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  adr x2, mBoardRevision
  str w0, [x2]
+#if (RPI_MODEL == 3)


As noted by Pete off-list, doing this doesn't work unless we add 
something like


GCC:*_*_*_PP_FLAGS  = -DRPI_MODEL=3

to the [BuildOptions] in RPi3.dsc




+    run .Lclkinfo_buffer
+
+    ldr w0, .Lfrequency
+    adrp    x2, _gPcd_BinaryPatch_PcdSerialClockRate
+    str w0, [x2, :lo12:_gPcd_BinaryPatch_PcdSerialClockRate]
+#endif
+


Since we're modifying a patchable PCD here, shouldn't we add a:

[PatchPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate

section in PlatformLib.inf?



We should add it, but we can add it to the [Pcd] section.

Alternatively, we could have different .INFs for RPi3 and RPi4, but that 
is really overkill IMO.


Making it patchable on both platforms just to patch it on one is also 
unnecessary I think. The current approach will ensure that we catch any 
issues at build time, without any major hacks,].


Of course, if we do that, we can't keep PcdSerialClockRate fixed for 
RPi4, as the build process will complain about PCD mismatch.


I also wouldn't mind a comment that explains how one arrives at figuring 
out that "_gPcd_BinaryPatch_PcdSerialClockRate" should be used to locate 
our address (and possibly the addition of :lo12:), because I don't think 
it's going to be that straightforward for people reading the code for 
the first time, though I fear that the explanation will boil down to "we 
need to do it this specific way for a gcc aarch64 relocation"...




We don't actually need the adrp/str pair with the lo12 here, I will 
replace it with adr. (Just muscle memory)





  ret
  .align  4
@@ -127,6 +135,21 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  .long   0   // end tag
  .set    .Lrevinfo_size, . - .Lrevinfo_buffer
+#if (RPI_MODEL == 3)
+    .align  4
+.Lclkinfo_buffer:
+    .long   .Lclkinfo_size
+    .long   0x0
+    .long   RPI_MBOX_GET_CLOCK_RATE
+    .long   8   // buf size
+    .long   4   // input len
+    .long   4   // clock id: 0x04 = Core/VPU
+.Lfrequency:
+    .long   0   // frequency
+    .long   0   // end tag
+    .set    .Lclkinfo_size, . - .Lclkinfo_buffer
+#endif
+
  //UINTN
  //ArmPlatformGetPrimaryCoreMpId (
  //  VOID








With addition of "GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=3" in the .dsc:
Reviewed-by: Pete Batard 




Thanks


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58696): https://edk2.groups.io/g/devel/message/58696
Mute This Topic: https://groups.io/mt/73999457/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to SetupGit.py

2020-05-06 Thread Leif Lindholm
On Tue, May 05, 2020 at 17:40:35 +0200, Laszlo Ersek wrote:
> CC Leif
> 
> On 05/01/20 22:00, Rebecca Cran wrote:
> > Allow users who didn't clone one of the TianoCore repos from a
> > canonical URL to specify the name of the repo (edk2, edk2-platforms
> > or edk2-non-osi) when running SetupGit.py to allow them to configure
> > their repo properly.
> > 
> > The new option is:
> > 
> >   -n repo, --name repo  set the repo name to configure for, if not
> > detected automatically
> > 
> > Signed-off-by: Rebecca Cran 
> > Cc: Bob Feng 
> > Cc: Liming Gao 

I did consider this scenario when writing the code, but couldn't
decide on a method for overriding, and wasn't 100% it wasn't just a
theoretical issue. This solution looks sensible.
Reviewed-by: Leif Lindholm 

As a sidenote - now this exists, it could make sense to also add
options for overriding 'list' and 'prefix'.

/
Leif

> > ---
> > Tested with:
> >   pylama : no new issues detected
> > Option tested:
> >   -n : correctly said a parameter was needed
> >   -n edk2 : configured the repo for edk2
> >   -n edk2-foo : errored out with a list of repo names
> >   -n edk2-platforms : updated the configuration for edk2-platforms
> > 
> > Note the error block in __main__ if the upstream isn't found is
> > redundant, since it already errors out and exits in get_upstream.
> > 
> >  BaseTools/Scripts/SetupGit.py | 12 +---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py
> > index e320ba2f887e..4416111ac0a5 100644
> > --- a/BaseTools/Scripts/SetupGit.py
> > +++ b/BaseTools/Scripts/SetupGit.py
> > @@ -106,10 +106,11 @@ def fuzzy_match_repo_url(one, other):
> >  return False
> >  
> >  
> > -def get_upstream(url):
> > +def get_upstream(url, name):
> >  """Extracts the dict for the current repo origin."""
> >  for upstream in UPSTREAMS:
> > -if fuzzy_match_repo_url(upstream['repo'], url):
> > +if (fuzzy_match_repo_url(upstream['repo'], url) or
> > +upstream['name'] == name):
> >  return upstream
> >  print("Unknown upstream '%s' - aborting!" % url)
> >  sys.exit(3)
> > @@ -143,6 +144,11 @@ if __name__ == '__main__':
> >  help='overwrite existing settings conflicting with 
> > program defaults',
> >  action='store_true',
> >  required=False)
> > +PARSER.add_argument('-n', '--name', type=str, metavar='repo',
> > +choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
> > +help='set the repo name to configure for, if not '
> > + 'detected automatically',
> > +required=False)
> >  PARSER.add_argument('-v', '--verbose',
> >  help='enable more detailed output',
> >  action='store_true',
> > @@ -156,7 +162,7 @@ if __name__ == '__main__':
> >  
> >  URL = REPO.remotes.origin.url
> >  
> > -UPSTREAM = get_upstream(URL)
> > +UPSTREAM = get_upstream(URL, ARGS.name)
> >  if not UPSTREAM:
> >  print("Upstream '%s' unknown, aborting!" % URL)
> >  sys.exit(7)
> > 
> 
> 
> 
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58697): https://edk2.groups.io/g/devel/message/58697
Mute This Topic: https://groups.io/mt/73406555/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 4/5] Platform/RaspberryPi3: query firmware for 16550 input clock at boot

2020-05-06 Thread Pete Batard

On 2020.05.06 11:31, Ard Biesheuvel wrote:

On 5/6/20 12:18 PM, Pete Batard wrote:

One remark below:

On 2020.05.05 19:11, Ard Biesheuvel wrote:

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

Query the firmware for the clock rate that is used to drive the
16550 baud clock, so that we can program the correct baud rate.

Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Co-authored-by: Ard Biesheuvel 
Signed-off-by: Pete Batard 
Signed-off-by: Ard Biesheuvel 
---
Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
| 25 +++-

  1 file changed, 24 insertions(+), 1 deletion(-)

diff --git 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S

index 91dfe1bb981e..35580e4ed73a 100644
--- 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
+++ 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S

@@ -3,7 +3,7 @@
   *  Copyright (c) 2020, Andrei Warkentin 
   *  Copyright (c) 2019-2020, Pete Batard 
   *  Copyright (c) 2016, Linaro Limited. All rights reserved.
- *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
+ *  Copyright (c) 2011-2020, ARM Limited. All rights reserved.
   *
   *  SPDX-License-Identifier: BSD-2-Clause-Patent
   *
@@ -85,6 +85,14 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  adr x2, mBoardRevision
  str w0, [x2]
+#if (RPI_MODEL == 3)


As noted by Pete off-list, doing this doesn't work unless we add 
something like


GCC:*_*_*_PP_FLAGS  = -DRPI_MODEL=3

to the [BuildOptions] in RPi3.dsc




+    run .Lclkinfo_buffer
+
+    ldr w0, .Lfrequency
+    adrp    x2, _gPcd_BinaryPatch_PcdSerialClockRate
+    str w0, [x2, :lo12:_gPcd_BinaryPatch_PcdSerialClockRate]
+#endif
+


Since we're modifying a patchable PCD here, shouldn't we add a:

[PatchPcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdSerialClockRate

section in PlatformLib.inf?



We should add it, but we can add it to the [Pcd] section.

Alternatively, we could have different .INFs for RPi3 and RPi4, but that 
is really overkill IMO.


Making it patchable on both platforms just to patch it on one is also 
unnecessary I think. The current approach will ensure that we catch any 
issues at build time, without any major hacks,].


Yeah, I'm also fine with what we have at the moment, and I sure don't 
want separate .INFs for Pi3 and Pi4.




Of course, if we do that, we can't keep PcdSerialClockRate fixed for 
RPi4, as the build process will complain about PCD mismatch.


I also wouldn't mind a comment that explains how one arrives at 
figuring out that "_gPcd_BinaryPatch_PcdSerialClockRate" should be 
used to locate our address (and possibly the addition of :lo12:), 
because I don't think it's going to be that straightforward for people 
reading the code for the first time, though I fear that the 
explanation will boil down to "we need to do it this specific way for 
a gcc aarch64 relocation"...




We don't actually need the adrp/str pair with the lo12 here, I will 
replace it with adr. (Just muscle memory)


Sounds good, thanks!

/Pete






  ret
  .align  4
@@ -127,6 +135,21 @@ ASM_FUNC (ArmPlatformPeiBootAction)
  .long   0   // end tag
  .set    .Lrevinfo_size, . - .Lrevinfo_buffer
+#if (RPI_MODEL == 3)
+    .align  4
+.Lclkinfo_buffer:
+    .long   .Lclkinfo_size
+    .long   0x0
+    .long   RPI_MBOX_GET_CLOCK_RATE
+    .long   8   // buf size
+    .long   4   // input len
+    .long   4   // clock id: 0x04 = Core/VPU
+.Lfrequency:
+    .long   0   // frequency
+    .long   0   // end tag
+    .set    .Lclkinfo_size, . - .Lclkinfo_buffer
+#endif
+
  //UINTN
  //ArmPlatformGetPrimaryCoreMpId (
  //  VOID








With addition of "GCC:*_*_*_PP_FLAGS = -DRPI_MODEL=3" in the .dsc:
Reviewed-by: Pete Batard 




Thanks




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58698): https://edk2.groups.io/g/devel/message/58698
Mute This Topic: https://groups.io/mt/73999457/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms v4 12/24] Silicon/NXP: Move RAM retrieval from SocLib

2020-05-06 Thread Leif Lindholm
Hi Pankaj,

I have a few minor comments on this patch, but I have pushed 1-11/24
as ca1a7187861c..725d1198e262.

On Fri, May 01, 2020 at 11:19:43 +0530, Pankaj Bansal wrote:
> From: Pankaj Bansal 
> 
> RAM retrieval using SMC commands is common to all Layerscape SOCs.
> Therefore, move it to common MemoryInit Pei Lib.
> 
> Signed-off-by: Pankaj Bansal 
> ---
> 
> Notes:
> V4:
> - fixed line adds white space error in MemoryInitPeiLib.h
> - Added SMC_OK and SMC_UOK Macros to denote the return values from
>   SMC calls
> - Added explanation for SMC_DRAM_BANK_INFO and DRAM_REGION_INFO in
>   MemoryInitPeiLib.h
> - Modified GetDramSize to check for return value of SMC call against
>   SMC_OK. Also added comments when returning 0 from this function
> - Modified GetDramRegionsInfo for loop and return values as per Leif's
>   suggestion. Also added DEBUG_ERROR in case of return BUFFER_TOO_SMALL.
> - Added SMC_OK in GetDramRegionsInfo
> - Check for GetDramRegionsInfo return value in MemoryPeim
> - regios -> regions
> 
> V3:
> - sort headers alphabetically
> - Moved DRAM region retrieval and Total DRAM size retrieval to separate
>   functions
> - Fixed MemoryPeim function description
> - Modified check on FoundSystemMem = TRUE to check the RAM region against
>   MemoryPeim function input arguments UefiMemoryBase and UefiMemorySize
> - (!DramRegions[Index].Size) => (DramRegions[Index].Size == 0)
> - (FoundSystemMem) => (FoundSystemMem == TRUE)
> - Added explanation for starting for loop from the last DRAM region
> 
>  Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.inf |   7 +-
>  Silicon/NXP/Library/SocLib/LS1043aSocLib.inf   |   1 -
>  Silicon/NXP/Include/DramInfo.h |  38 
>  Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.h   |  38 
>  Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.c   | 205 
> 
>  Silicon/NXP/Library/SocLib/Chassis.c   |  67 ---
>  6 files changed, 211 insertions(+), 145 deletions(-)
> 
> diff --git a/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.inf 
> b/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.inf
> index a5bd39415def..ad2371115b17 100644
> --- a/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.inf
> +++ b/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.inf
> @@ -18,7 +18,6 @@
>  [Sources]
>MemoryInitPeiLib.c
>  
> -
>  [Packages]
>ArmPkg/ArmPkg.dec
>ArmPlatformPkg/ArmPlatformPkg.dec
> @@ -30,6 +29,7 @@
>  [LibraryClasses]
>ArmMmuLib
>ArmPlatformLib
> +  ArmSmcLib
>DebugLib
>HobLib
>PcdLib
> @@ -40,6 +40,11 @@
>  [FeaturePcd]
>gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
>  
> +[FixedPcd]
> +  gArmTokenSpaceGuid.PcdFdBaseAddress
> +  gArmTokenSpaceGuid.PcdFdSize
> +  gArmPlatformTokenSpaceGuid.PcdSystemMemoryUefiRegionSize
> +
>  [Pcd]
>gArmTokenSpaceGuid.PcdSystemMemoryBase
>gArmTokenSpaceGuid.PcdSystemMemorySize
> diff --git a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf 
> b/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> index b7c7fc78cc8f..99d89498e0e2 100644
> --- a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> +++ b/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> @@ -20,7 +20,6 @@
>Silicon/NXP/NxpQoriqLs.dec
>  
>  [LibraryClasses]
> -  ArmSmcLib
>BaseLib
>DebugLib
>IoAccessLib
> diff --git a/Silicon/NXP/Include/DramInfo.h b/Silicon/NXP/Include/DramInfo.h
> deleted file mode 100644
> index a934aaeff1f5..
> --- a/Silicon/NXP/Include/DramInfo.h
> +++ /dev/null
> @@ -1,38 +0,0 @@
> -/** @file
> -*  Header defining the structure for Dram Information
> -*
> -*  Copyright 2019 NXP
> -*
> -*  SPDX-License-Identifier: BSD-2-Clause-Patent
> -*
> -**/
> -
> -#ifndef DRAM_INFO_H_
> -#define DRAM_INFO_H_
> -
> -#include 
> -
> -#define SMC_DRAM_BANK_INFO  (0xC200FF12)
> -
> -typedef struct {
> -  UINTNBaseAddress;
> -  UINTNSize;
> -} DRAM_REGION_INFO;
> -
> -typedef struct {
> -  UINT32NumOfDrams;
> -  UINT32Reserved;
> -  DRAM_REGION_INFO  DramRegion[3];
> -} DRAM_INFO;
> -
> -EFI_STATUS
> -GetDramBankInfo (
> -  IN OUT DRAM_INFO *DramInfo
> -  );
> -
> -VOID
> -UpdateDpaaDram (
> -  IN OUT DRAM_INFO *DramInfo
> -  );
> -
> -#endif /* DRAM_INFO_H_ */
> diff --git a/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.h 
> b/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.h
> new file mode 100644
> index ..7a41f4d226f1
> --- /dev/null
> +++ b/Silicon/NXP/Library/MemoryInitPei/MemoryInitPeiLib.h
> @@ -0,0 +1,38 @@
> +/** @file
> +*
> +*  Copyright 2020 NXP
> +*
> +*  SPDX-License-Identifier: BSD-2-Clause-Patent
> +*
> +**/
> +
> +#ifndef MEMORY_INIT_PEI_LIB_H_
> +#define MEMORY_INIT_PEI_LIB_H_
> +
> +#include 
> +
> +// Specifies the Maximum regions onto which DDR memory can be mapped in
> +// a Platform
> +#define MAX_DRAM_REGIONS3
> +

Re: [edk2-devel] [PATCH edk2-platforms v4 15/24] Silicon: NXP: Remove direct calls to SwapMmio* APIs

2020-05-06 Thread Leif Lindholm
On Fri, May 01, 2020 at 11:19:46 +0530, Pankaj Bansal wrote:
> From: Pankaj Bansal 
> 
> The SwapMmio** APIs are supposed to be called indirectly via
> GetMmioOperations** APIs.
> Therefore, remove the SwapMmio** APIs from IoAccessLib.h and make
> these APIs STATIC to IoAccessLib.c, so that no accidental call can
> be made to these.
> 
> Signed-off-by: Pankaj Bansal 

Reviewed-by: Leif Lindholm 

> ---
> 
> Notes:
> V4:
> - Use GetMmioOperations in place of GetMmioOperations32
> - Use MMIO_OPERATIONS in place of MMIO_OPERATIONS_32
> 
> V3:
> - New commit
> 
>  Silicon/NXP/Include/Library/IoAccessLib.h | 236 +---
>  Silicon/NXP/Library/IoAccessLib/IoAccessLib.c |  17 +-
>  Silicon/NXP/Library/SocLib/Chassis.c  |  10 +-
>  3 files changed, 22 insertions(+), 241 deletions(-)
> 
> diff --git a/Silicon/NXP/Include/Library/IoAccessLib.h 
> b/Silicon/NXP/Include/Library/IoAccessLib.h
> index 0f5b19dcf149..3dbb35d2ce5a 100644
> --- a/Silicon/NXP/Include/Library/IoAccessLib.h
> +++ b/Silicon/NXP/Include/Library/IoAccessLib.h
> @@ -1,6 +1,6 @@
>  /** @file
>   *
> - *  Copyright 2017-2019 NXP
> + *  Copyright 2017-2020 NXP
>   *
>   * SPDX-License-Identifier: BSD-2-Clause-Patent
>   *
> @@ -47,238 +47,4 @@ GetMmioOperations  (
>IN  BOOLEAN  Swap
>);
>  
> -/**
> -  MmioRead16 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to read.
> -
> -  @return The value read.
> -
> -**/
> -UINT16
> -EFIAPI
> -SwapMmioRead16 (
> -  IN  UINTN Address
> -  );
> -
> -/**
> -  MmioRead32 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to read.
> -
> -  @return The value read.
> -
> -**/
> -UINT32
> -EFIAPI
> -SwapMmioRead32 (
> -  IN  UINTN Address
> -  );
> -
> -/**
> -  MmioRead64 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to read.
> -
> -  @return The value read.
> -
> -**/
> -UINT64
> -EFIAPI
> -SwapMmioRead64 (
> -  IN  UINTN Address
> -  );
> -
> -/**
> -  MmioWrite16 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  Value   The value to write to the MMIO register.
> -
> -**/
> -UINT16
> -EFIAPI
> -SwapMmioWrite16 (
> -  IN  UINTN Address,
> -  IN  UINT16Value
> -  );
> -
> -/**
> -  MmioWrite32 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  Value   The value to write to the MMIO register.
> -
> -**/
> -UINT32
> -EFIAPI
> -SwapMmioWrite32 (
> -  IN  UINTN Address,
> -  IN  UINT32Value
> -  );
> -
> -/**
> -  MmioWrite64 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  Value   The value to write to the MMIO register.
> -
> -**/
> -UINT64
> -EFIAPI
> -SwapMmioWrite64 (
> -  IN  UINTN Address,
> -  IN  UINT64Value
> -  );
> -
> -/**
> -  MmioAndThenOr16 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  AndData The value to AND with the read value from the MMIO 
> register.
> -  @param  OrData  The value to OR with the result of the AND operation.
> -
> -  @return The value written back to the MMIO register.
> -
> -**/
> -UINT16
> -EFIAPI
> -SwapMmioAndThenOr16 (
> -  IN  UINTN Address,
> -  IN  UINT16AndData,
> -  IN  UINT16OrData
> -  );
> -
> -/**
> -  MmioAndThenOr32 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  AndData The value to AND with the read value from the MMIO 
> register.
> -  @param  OrData  The value to OR with the result of the AND operation.
> -
> -  @return The value written back to the MMIO register.
> -
> -**/
> -UINT32
> -EFIAPI
> -SwapMmioAndThenOr32 (
> -  IN  UINTN Address,
> -  IN  UINT32AndData,
> -  IN  UINT32OrData
> -  );
> -
> -/**
> -  MmioAndThenOr64 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  AndData The value to AND with the read value from the MMIO 
> register.
> -  @param  OrData  The value to OR with the result of the AND operation.
> -
> -  @return The value written back to the MMIO register.
> -
> -**/
> -UINT64
> -EFIAPI
> -SwapMmioAndThenOr64 (
> -  IN  UINTN Address,
> -  IN  UINT64AndData,
> -  IN  UINT64OrData
> -  );
> -
> -/**
> -  MmioOr16 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  OrData  The value to OR with the read value from the MMIO register.
> -
> -  @return The value written back to the MMIO register.
> -
> -**/
> -UINT16
> -EFIAPI
> -SwapMmioOr16 (
> -  IN  UINTN Address,
> -  IN  UINT16OrData
> -  );
> -
> -/**
> -  MmioOr32 for Big-Endian modules.
> -
> -  @param  Address The MMIO register to write.
> -  @param  OrData  The value to OR with the read value from the MMIO register.
> -
> -  @return The value written back to the MMIO register.
> -
> -**/
> -UINT32
> -EFIAPI
> -SwapMmioOr32 (
> -  IN  UINTN Address,
> -  IN  UINT32OrData
> -  );
> -
> -/**
> -  MmioOr64 for 

Re: [edk2-devel] [PATCH edk2-platforms v4 16/24] Silicon/NXP: Add Chassis2 Package

2020-05-06 Thread Leif Lindholm
On Fri, May 01, 2020 at 11:19:47 +0530, Pankaj Bansal wrote:
> From: Pankaj Bansal 
> 
> A Chassis is a base framework used for building SoCs.
> We can think of Chassis/Soc/Platform(a.k.a Board) in Object model terms.
> Chassis is base. Soc is based on some Chassis.
> Platform is based on some Soc.
> 
> SOCs that are designed around same chassis, reuse most of the components.
> 
> Therefore, add the package for Chassis2. LS1043A and LS1046A SOCs belong
> to Chassis2.
> 
> Signed-off-by: Pankaj Bansal 

Reviewed-by: Leif Lindholm 

> ---
> 
> Notes:
> V4:
> - Fixed line adds whitespace error
> - Added Uefi.h in Chassis.h
> - Fixed Typo Borad -> Board in commit description
> - Fixed license in ChassisLib.inf
> - Added lines between Copyright and license in ChassisLib.c
> 
> V3:
> - in patch description Oops -> Object model
> - Sorted includes alphabetically
> - removed direct calls to SwapMmio** APIs and used GetMmioOperations**
> 
>  Silicon/NXP/Chassis2/Chassis2.dec  | 22 +
>  Silicon/NXP/NxpQoriqLs.dec |  4 +
>  Silicon/NXP/Chassis2/Chassis2.dsc.inc  | 10 ++
>  Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf | 33 +++
>  Silicon/NXP/Chassis2/Include/Chassis.h | 36 +++
>  Silicon/NXP/Include/Library/ChassisLib.h   | 51 ++
>  Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.c   | 98 
> 
>  7 files changed, 254 insertions(+)
> 
> diff --git a/Silicon/NXP/Chassis2/Chassis2.dec 
> b/Silicon/NXP/Chassis2/Chassis2.dec
> new file mode 100644
> index ..d3674cd6dff9
> --- /dev/null
> +++ b/Silicon/NXP/Chassis2/Chassis2.dec
> @@ -0,0 +1,22 @@
> +# @file
> +# NXP Layerscape processor package.
> +#
> +# Copyright 2020 NXP
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +
> +[Defines]
> +  DEC_SPECIFICATION  = 1.27
> +  PACKAGE_VERSION= 0.1
> +
> +
> +#
> +# Include Section - list of Include Paths that are provided by this package.
> +#   Comments are used for Keywords and Module Types.
> +#
> +#
> +
> +[Includes.common]
> +  Include# Root include for the package
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index e61592b4fe61..b327e52da139 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -14,6 +14,9 @@
>Include
>  
>  [LibraryClasses]
> +  ##  @libraryclass  Provides Chassis specific functions to other modules
> +  ChassisLib|Include/Library/ChassisLib.h
> +
>##  @libraryclass  Provides services to read/write to I2c devices
>I2cLib|Include/Library/I2cLib.h
>  
> @@ -29,3 +32,4 @@
>  
>  [PcdsFeatureFlag]
>gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x0315
> +  gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x0316
> diff --git a/Silicon/NXP/Chassis2/Chassis2.dsc.inc 
> b/Silicon/NXP/Chassis2/Chassis2.dsc.inc
> new file mode 100644
> index ..db8e5a92eacb
> --- /dev/null
> +++ b/Silicon/NXP/Chassis2/Chassis2.dsc.inc
> @@ -0,0 +1,10 @@
> +#  @file
> +#
> +#  Copyright 2020 NXP
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +
> +[LibraryClasses.common]
> +  ChassisLib|Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
> diff --git a/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf 
> b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
> new file mode 100644
> index ..f5dbd1349dc5
> --- /dev/null
> +++ b/Silicon/NXP/Chassis2/Library/ChassisLib/ChassisLib.inf
> @@ -0,0 +1,33 @@
> +#  @file
> +#
> +#  Copyright 2020 NXP
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +#
> +
> +[Defines]
> +  INF_VERSION= 1.27
> +  BASE_NAME  = Chassis2Lib
> +  FILE_GUID  = fae0d077-5fc2-494f-b8e1-c51a3023ee3e
> +  MODULE_TYPE= BASE
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = ChassisLib
> +
> +[Packages]
> +  ArmPkg/ArmPkg.dec
> +  MdePkg/MdePkg.dec
> +  Silicon/NXP/Chassis2/Chassis2.dec
> +  Silicon/NXP/NxpQoriqLs.dec
> +
> +[LibraryClasses]
> +  IoAccessLib
> +  IoLib
> +  PcdLib
> +  SerialPortLib
> +
> +[Sources.common]
> +  ChassisLib.c
> +
> +[FeaturePcd]
> +  gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian
> diff --git a/Silicon/NXP/Chassis2/Include/Chassis.h 
> b/Silicon/NXP/Chassis2/Include/Chassis.h
> new file mode 100644
> index ..14e21ef9daf4
> --- /dev/null
> +++ b/Silicon/NXP/Chassis2/Include/Chassis.h
> @@ -0,0 +1,36 @@
> +/** @file
> +
> +  Copyright 2020 NXP
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +#ifndef CHASSIS_H__
> +#define CHASSIS_H__
> +
> +#include 
> +

Re: [edk2-devel] [PATCH edk2-platforms v4 17/24] Silicon/NXP/LS1043A: Use ChassisLib from Chassis2 Pkg

2020-05-06 Thread Leif Lindholm
On Fri, May 01, 2020 at 11:19:48 +0530, Pankaj Bansal wrote:
> From: Pankaj Bansal 
> 
> Now the we have added Chassis Package, move the chassis specific common
> code for all SOCs belonging to same chassis to ChassisLib.
> 
> Use ChassisLib APIs in SocLib.
> 
> Signed-off-by: Pankaj Bansal 

You've actually dropped my R-b here (which was given for v2).

/
Leif

> ---
> 
> Notes:
> V4:
> - No change
> 
> V3:
> - No change
> 
>  Silicon/NXP/NxpQoriqLs.dec   |  6 --
>  Silicon/NXP/LS1043A/LS1043A.dsc.inc  |  9 ++-
>  Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf   |  1 +
>  Platform/NXP/LS1043aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf |  1 +
>  Silicon/NXP/Library/SocLib/LS1043aSocLib.inf | 15 
> +
>  Silicon/NXP/Include/Chassis2/NxpSoc.h| 44 
> --
>  Silicon/NXP/LS1043A/Include/Soc.h|  6 +-
>  Silicon/NXP/Library/SocLib/NxpChassis.h  | 22 
> ---
>  Silicon/NXP/Library/SocLib/Chassis.c | 61 
> 
>  Silicon/NXP/Library/SocLib/Chassis2/Soc.c| 19 
> +-
>  10 files changed, 14 insertions(+), 170 deletions(-)
> 
> diff --git a/Silicon/NXP/NxpQoriqLs.dec b/Silicon/NXP/NxpQoriqLs.dec
> index b327e52da139..0722f59ef4f6 100644
> --- a/Silicon/NXP/NxpQoriqLs.dec
> +++ b/Silicon/NXP/NxpQoriqLs.dec
> @@ -24,12 +24,6 @@
>gNxpQoriqLsTokenSpaceGuid  = {0x98657342, 0x4aee, 0x4fc6, {0xbc, 0xb5, 
> 0xff, 0x45, 0xb7, 0xa8, 0x71, 0xf2}}
>gNxpNonDiscoverableI2cMasterGuid = { 0x5f2c099c, 0x54a3, 0x4dd4, {0x9e, 
> 0xc5, 0xe9, 0x12, 0x8c, 0x36, 0x81, 0x6a}}
>  
> -[PcdsFixedAtBuild.common]
> -  #
> -  # Pcds to support Big Endian IPs
> -  #
> -  gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian|FALSE|BOOLEAN|0x311
> -
>  [PcdsFeatureFlag]
>gNxpQoriqLsTokenSpaceGuid.PcdI2cErratumA009203|FALSE|BOOLEAN|0x0315
>gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|FALSE|BOOLEAN|0x0316
> diff --git a/Silicon/NXP/LS1043A/LS1043A.dsc.inc 
> b/Silicon/NXP/LS1043A/LS1043A.dsc.inc
> index 7690e4caa593..ea0854f967a3 100644
> --- a/Silicon/NXP/LS1043A/LS1043A.dsc.inc
> +++ b/Silicon/NXP/LS1043A/LS1043A.dsc.inc
> @@ -7,6 +7,8 @@
>  #
>  #
>  
> +!include Silicon/NXP/Chassis2/Chassis2.dsc.inc
> +
>  [LibraryClasses.common]
>SocLib|Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
>SerialPortLib|Silicon/NXP/Library/DUartPortLib/DUartPortLib.inf
> @@ -26,9 +28,6 @@
>  [PcdsFixedAtBuild.common]
>gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase|0x021c0500
>  
> -  #
> -  # Big Endian IPs
> -  #
> -  gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian|TRUE
> -
> +[PcdsFeatureFlag]
> +  gNxpQoriqLsTokenSpaceGuid.PcdDcfgBigEndian|TRUE
>  ##
> diff --git a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf 
> b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> index 038d48949a39..e522db81e5c0 100644
> --- a/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> +++ b/Platform/NXP/LS1043aRdbPkg/Drivers/PlatformDxe/PlatformDxe.inf
> @@ -24,6 +24,7 @@
>MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
>Silicon/Maxim/Library/Ds1307RtcLib/Ds1307RtcLib.dec
> +  Silicon/NXP/Chassis2/Chassis2.dec
>Silicon/NXP/LS1043A/LS1043A.dec
>Silicon/NXP/NxpQoriqLs.dec
>  
> diff --git 
> a/Platform/NXP/LS1043aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf 
> b/Platform/NXP/LS1043aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf
> index 7a43ad86d183..07ca6b34445f 100644
> --- a/Platform/NXP/LS1043aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf
> +++ b/Platform/NXP/LS1043aRdbPkg/Library/ArmPlatformLib/ArmPlatformLib.inf
> @@ -19,6 +19,7 @@
>ArmPlatformPkg/ArmPlatformPkg.dec
>EmbeddedPkg/EmbeddedPkg.dec
>MdePkg/MdePkg.dec
> +  Silicon/NXP/Chassis2/Chassis2.dec
>Silicon/NXP/LS1043A/LS1043A.dec
>Silicon/NXP/NxpQoriqLs.dec
>  
> diff --git a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf 
> b/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> index bb15e0a3d710..1d042bbfc4e4 100644
> --- a/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> +++ b/Silicon/NXP/Library/SocLib/LS1043aSocLib.inf
> @@ -14,25 +14,14 @@
>LIBRARY_CLASS  = SocLib
>  
>  [Packages]
> -  ArmPkg/ArmPkg.dec
> -  MdeModulePkg/MdeModulePkg.dec
>MdePkg/MdePkg.dec
> +  Silicon/NXP/Chassis2/Chassis2.dec
>Silicon/NXP/LS1043A/LS1043A.dec
>Silicon/NXP/NxpQoriqLs.dec
>  
>  [LibraryClasses]
> -  BaseLib
> +  ChassisLib
>DebugLib
> -  IoAccessLib
> -  SerialPortLib
>  
>  [Sources.common]
> -  Chassis.c
>Chassis2/Soc.c
> -
> -[BuildOptions]
> -  GCC:*_*_*_CC_FLAGS = -DCHASSIS2
> -
> -[FixedPcd]
> -  gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
> -  gNxpQoriqLsTokenSpaceGuid.PcdGurBigEndian
> diff --git a/Silicon/NXP/Include/Chassis2/NxpSoc.h 
> 

Re: [edk2-devel] [PATCH edk2-platforms v4 24/24] Platform/NXP/LS1043aRdbPkg: Add PEI Phase

2020-05-06 Thread Leif Lindholm
On Fri, May 01, 2020 at 11:19:55 +0530, Pankaj Bansal wrote:
> From: Pankaj Bansal 
> 
> Add PEI phase to LS1043aRdb. This is needed because we need to have
> dynamic PCDs support to be able to reserve memory before reporting
> memory to UEFI firmware.
> Using PEI phase we are now also dynamically setting the
> PcdSystemMemoryBase and PcdSystemMemorySize depending upon the DRAM
> regions detected.
> This in turn would depend on the DDR DIMMs installed on board.
> 
> Signed-off-by: Pankaj Bansal 

Reviewed-by: Leif Lindholm 

I think that leaves us with only 12/24 outstanding - could you send
out a v5 of just that patch?

/
Leif

> ---
> 
> Notes:
> V4:
> - Use ArmPkg version of PeiServicesTablePointerLib instead of MdePkg.
>   This allows us to run PEI phase from memory mapped flash devices
> 
> V3:
> - Update commit description
> 
>  Silicon/NXP/NxpQoriqLs.dsc.inc| 63 
> +-
>  Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.dsc  |  9 ---
>  Platform/NXP/LS1043aRdbPkg/LS1043aRdbPkg.fdf  | 18 --
>  Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf |  3 +-
>  Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.c   | 67 
> +++-
>  5 files changed, 99 insertions(+), 61 deletions(-)
> 
> diff --git a/Silicon/NXP/NxpQoriqLs.dsc.inc b/Silicon/NXP/NxpQoriqLs.dsc.inc
> index 3c8b11d9e04c..03759c7cee7c 100644
> --- a/Silicon/NXP/NxpQoriqLs.dsc.inc
> +++ b/Silicon/NXP/NxpQoriqLs.dsc.inc
> @@ -93,46 +93,53 @@
>CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
>
> NonDiscoverableDeviceRegistrationLib|MdeModulePkg/Library/NonDiscoverableDeviceRegistrationLib/NonDiscoverableDeviceRegistrationLib.inf
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> +  
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
>  
>I2cLib|Silicon/NXP/Library/I2cLib/I2cLib.inf
>
> ResetSystemLib|ArmPkg/Library/ArmSmcPsciResetSystemLib/ArmSmcPsciResetSystemLib.inf
>IoAccessLib|Silicon/NXP/Library/IoAccessLib/IoAccessLib.inf
>  
> +  PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
>MemoryInitPeiLib|Silicon/NXP/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
>  
>  [LibraryClasses.common.SEC]
>PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
> -  
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
> -  
> ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
> -  
> LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
> -  PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> -  HobLib|EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
> -  
> PrePiHobListPointerLib|ArmPlatformPkg/Library/PrePiHobListPointerLib/PrePiHobListPointerLib.inf
> -  
> MemoryAllocationLib|EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf
> +  
> DebugAgentLib|ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf
> +  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> +  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> +  
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> +  
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +
> +[LibraryClasses.common.PEI_CORE]
> +  PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
> +  HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
> +  PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> +  
> MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
> +  PeiCoreEntryPoint|MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
>PerformanceLib|MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
> -  PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
> +  
> ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
> +  
> ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
> +  
> OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
>  
> -  # 1/123 faster than Stm or Vstm version
> -  BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
> -
> -  # Uncomment to turn on GDB stub in SEC.
> -  #DebugAgentLib|EmbeddedPkg/Library/GdbDebugAgent/GdbDebugAgent.inf
> +  
> PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
>  
>  [LibraryClasses.common.PEIM]
>PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
>PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
>PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
> -  
> PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
> +  
> 

[edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RPi/AcpiTables: Update all tables to latest ACPI

2020-05-06 Thread Pete Batard
Because of its widespread availability and low price, we expect the
Raspberry Pi source to be used by platform developers as a starting
point to create their own platform implementation.

As such, it makes a lot of sense to want to use the most up to date
underlying standards, even if the pay off is limited in this case,
or may even be seen as a liability in terms of ensuring greater
compatibility with older OSes, as it may help others benefit from
the latest improvements and features brought by modern ACPI.

We also happen to already be using ACPI 6.3 constructs, such as
PPTT (which was only introduced in ACPI 6.2 and further extended
in 6.3), and have some reliance on 6.x GIC, as the original MADT
binary blobs from Microsoft were 6.0 and abuse the GICR Base
Address field in order for Windows to boot properly (for reasons
that the proprietary nature of the Windows kernel makes difficult
to determine). So in effect, we did apply a potential breaking
change to Windows when we downgraded MADT to ACPI 5.1, though we
did validate at the time that the downgrade in ACPI version didn't
*seem* to break OS functionality. Still, because we are in the
dark as to what the ACPI fields we removed when downgrading ACPI
version were being used for, we obviously want to add them back.

Therefore, since we do see a need for ACPI 6.x features, and
effectively have a 6.3 table with PPTT, and also since we have
tested that we are not seeing ill effects from doing so for the
most common OSes we support, we bring all of the relevant ACPI
tables to version 6.3.

This is mostly accomplished by simply altering the version of
ACPI being references in the macros, except for the new fields
being initialized in the MADT table where we:
* Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even
  as this field is not supposed to apply to any of our platforms,
  this is what Microsoft used in the original Pi 3 hardcoded MADT
  blobs and Windows 10 doesn't boot on the Pi 3 if set to 0.
* Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC
  is v2 only.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/AcpiTables/AcpiTables.h |  8 ++--
 Platform/RaspberryPi/AcpiTables/Csrt.aslc| 14 +++
 Platform/RaspberryPi/AcpiTables/Dbg2.aslc|  6 +--
 Platform/RaspberryPi/AcpiTables/Fadt.aslc| 43 +---
 Platform/RaspberryPi/AcpiTables/Gtdt.aslc| 14 +++
 Platform/RaspberryPi/AcpiTables/Madt.aslc| 41 +++
 Platform/RaspberryPi/AcpiTables/Spcr.aslc|  4 +-
 7 files changed, 66 insertions(+), 64 deletions(-)

diff --git a/Platform/RaspberryPi/AcpiTables/AcpiTables.h 
b/Platform/RaspberryPi/AcpiTables/AcpiTables.h
index dfae763d8107..37e2a6bdf409 100644
--- a/Platform/RaspberryPi/AcpiTables/AcpiTables.h
+++ b/Platform/RaspberryPi/AcpiTables/AcpiTables.h
@@ -32,7 +32,7 @@
 #endif
 #define EFI_ACPI_OEM_REVISION 0x0200
 #define EFI_ACPI_CREATOR_ID   SIGNATURE_32 ('E','D','K','2')
-#define EFI_ACPI_CREATOR_REVISION 0x0200
+#define EFI_ACPI_CREATOR_REVISION 0x0300
 
 #define EFI_ACPI_VENDOR_IDSIGNATURE_32 ('R','P','I','F')
 
@@ -63,7 +63,7 @@
 #define RPI_SYSTEM_TIMER_BASE_ADDRESS 0xFF80001C
 #endif
 
-#define EFI_ACPI_5_1_CSRT_REVISION0x
+#define EFI_ACPI_6_3_CSRT_REVISION0x
 
 typedef enum
 {
@@ -95,7 +95,7 @@ typedef struct
   UINT16 Revision;// 2 bytes
   UINT16 Reserved;// 2 bytes
   UINT32 SharedInfoLength;// 4 bytes
-} EFI_ACPI_5_1_CSRT_RESOURCE_GROUP_HEADER;
+} EFI_ACPI_6_3_CSRT_RESOURCE_GROUP_HEADER;
 
 //
 // CSRT Resource Descriptor 12 bytes total
@@ -106,7 +106,7 @@ typedef struct
   UINT16 ResourceType;// 2 bytes
   UINT16 ResourceSubType; // 2 bytes
   UINT32 UID; // 4 bytes
-} EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER;
+} EFI_ACPI_6_3_CSRT_RESOURCE_DESCRIPTOR_HEADER;
 
 //
 // Interrupts. These are specific to each platform
diff --git a/Platform/RaspberryPi/AcpiTables/Csrt.aslc 
b/Platform/RaspberryPi/AcpiTables/Csrt.aslc
index 03d888fffb8b..76dbdfafba2c 100644
--- a/Platform/RaspberryPi/AcpiTables/Csrt.aslc
+++ b/Platform/RaspberryPi/AcpiTables/Csrt.aslc
@@ -41,7 +41,7 @@ typedef struct
 //
 typedef struct
 {
-  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
+  EFI_ACPI_6_3_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaControllerHeader;
   DMA_CONTROLLER_VENDOR_DATA ControllerVendorData;
 } RD_DMA_CONTROLLER;
 
@@ -61,7 +61,7 @@ typedef struct
 //
 typedef struct
 {
-  EFI_ACPI_5_1_CSRT_RESOURCE_DESCRIPTOR_HEADER DmaChannelHeader;
+  

Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RPi/AcpiTables: Update all tables to latest ACPI

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 2:45 PM, Pete Batard wrote:

On 2020.05.06 13:26, Ard Biesheuvel wrote:

On 5/6/20 1:37 PM, Pete Batard wrote:
...

Therefore, since we do see a need for ACPI 6.x features, and
effectively have a 6.3 table with PPTT, and also since we have
tested that we are not seeing ill effects from doing so for the
most common OSes we support, we bring all of the relevant ACPI
tables to version 6.3.

This is mostly accomplished by simply altering the version of
ACPI being references in the macros,


OK, so even the macros that resolve to the exact same code are 
renamed. I suppose this means a blanket rename of everything once ACPI 
6.4 comes out?


No.

I am considering that we are still in the process of introducing the 
platform, therefore we introduce it with the most up to date version of 
ACPI at that time.


Though I could see some point in doing so, I have no plan to update out 
ACPI for the Pi's every time a new version is released, unless there is 
an actual need to do so for a specific table or there is a blanket 
request (from seeing lots of folks using our code as a starting point) 
that warrants it.


In other words, even as RPi3 was introduced a year ago, I consider that 
we are still in the process of adding RPi3/RPi4 as a brand new platform, 
and therefore want to use the most up to date ACPI at the time of 
introduction. But I'm definitely not making a point of trying to follow 
ACPI updates past that this.




Good.


except for the new fields
being initialized in the MADT table where we:
* Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even
   as this field is not supposed to apply to any of our platforms,
   this is what Microsoft used in the original Pi 3 hardcoded MADT
   blobs and Windows 10 doesn't boot on the Pi 3 if set to 0.


Fair enough.


* Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC
   is v2 only.



OK. But you are introducing new references to ACPI_6_0 macros here. If 
the point is to rename everything for cosmetic reasons, shouldn't you 
use 6.3 there as well?


Well, EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT was not updated for 6_1, 6_2, 
6_3 (most likely because the macro, which is defined in 
EmbeddedPkg/Include/Library/AcpiLib.h applies the same for all 6.x 
versions), so I just used the highest version I could find, which is 
6_0. This is based on what I saw other platforms do.


I don't mind sending an EDK2 patch to add the various 
EFI_ACPI_6_x_GIC_DISTRIBUTOR_INIT if that's what you request, but that 
seems a bit like overkill and may break existing platforms, because it 
will most likely require moving EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT to a 
different header (MdePkg/Include/IndustryStandard/Acpi60.h).




Fair enough.

Reviewed-by: Ard Biesheuvel 

Pushed as 66d1b02429fa..11189124fbc2




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58709): https://edk2.groups.io/g/devel/message/58709
Mute This Topic: https://groups.io/mt/74026589/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard CpuExceptionHandlerLib

2020-05-06 Thread Lendacky, Thomas

On 5/5/20 5:15 PM, Laszlo Ersek via groups.io wrote:

On 05/01/20 22:17, Lendacky, Thomas wrote:

BZ: 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340data=02%7C01%7Cthomas.lendacky%40amd.com%7Cd2ec699d2c644a55724008d7f141d96f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243137431443098sdata=oTTju7144KZc8VCmQqu74UilIOzQyji9jlO%2BMJeZYyU%3Dreserved=0

Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
revert the changes made to the ExceptionHandlerAsm.nasm in commit
2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool
chain") so that binary patching of flash code is not performed.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Signed-off-by: Tom Lendacky 
---
  .../X64/ExceptionHandlerAsm.nasm  | 25 +--
  1 file changed, 6 insertions(+), 19 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 19198f273137..3814f9de3703 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -34,7 +34,7 @@ AsmIdtVectorBegin:
  db  0x6a; push  #VectorNum
  db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) 
/ 32) ; VectorNum
  pushrax
-mov rax, strict qword 0 ;mov rax, ASM_PFX(CommonInterruptEntry)
+mov rax, ASM_PFX(CommonInterruptEntry)
  jmp rax
  %endrep
  AsmIdtVectorEnd:
@@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
  @VectorNum:
  db  0  ; 0 will be fixed
  pushrax
-mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
-JmpAbsoluteAddress:
+mov rax, HookAfterStubHeaderEnd
  jmp rax
  HookAfterStubHeaderEnd:
  mov rax, rsp
@@ -257,7 +256,8 @@ HasErrorCode:
  ; and make sure RSP is 16-byte aligned
  ;
  sub rsp, 4 * 8 + 8
-callASM_PFX(CommonExceptionHandler)
+mov rax, ASM_PFX(CommonExceptionHandler)
+callrax
  add rsp, 4 * 8 + 8

  cli
@@ -365,24 +365,11 @@ DoIret:
  ; comments here for definition of address map
  global ASM_PFX(AsmGetTemplateAddressMap)
  ASM_PFX(AsmGetTemplateAddressMap):
-lea rax, [AsmIdtVectorBegin]
+mov rax, AsmIdtVectorBegin
  mov qword [rcx], rax
  mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-lea rax, [HookAfterStubHeaderBegin]
+mov rax, HookAfterStubHeaderBegin
  mov qword [rcx + 0x10], rax
-
-; Fix up CommonInterruptEntry address
-learax, [ASM_PFX(CommonInterruptEntry)]
-learcx, [AsmIdtVectorBegin]
-%rep  32
-movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax
-addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-%endrep
-; Fix up HookAfterStubHeaderEnd
-learax, [HookAfterStubHeaderEnd]
-learcx, [JmpAbsoluteAddress]
-movqword [rcx - 8], rax
-
  ret

  
;-



With this patch applied, the differences with the "original" remain:

$ git diff 2db0ccc2d7fe^..HEAD -- \
   UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm


diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index ba8993d84b0b..3814f9de3703 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -1,12 +1,6 @@
  
;-- 
;
-; Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.
-; This program and the accompanying materials
-; are licensed and made available under the terms and conditions of the BSD 
License
-; which accompanies this distribution.  The full text of the license may be 
found at
-; 
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopensource.org%2Flicenses%2Fbsd-license.phpdata=02%7C01%7Cthomas.lendacky%40amd.com%7Cd2ec699d2c644a55724008d7f141d96f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243137431443098sdata=SZAc83Y%2BwZauGcj47EDgc10fnxSucy2ljeI9PcaJSvE%3Dreserved=0.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+; Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
  ;
  ; Module Name:
  ;


This is expected.


@@ -189,17 +183,19 @@ HasErrorCode:
  pushrax
  pushrax
  sidt[rsp]
-xchgrax, [rsp + 2]
-xchgrax, [rsp]
-xchgrax, [rsp + 8]
+mov  

Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard CpuExceptionHandlerLib

2020-05-06 Thread Liming Gao
Thomas:

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Lendacky, 
> Thomas
> Sent: Wednesday, May 6, 2020 10:35 PM
> To: devel@edk2.groups.io; ler...@redhat.com
> Cc: Justen, Jordan L ; Ard Biesheuvel 
> ; Gao, Liming ;
> Dong, Eric ; Ni, Ray ; Brijesh Singh 
> ; Anthony Perard
> ; You, Benjamin ; Dong, 
> Guo ; Julien Grall
> ; Ma, Maurice ; Andrew Fish 
> 
> Subject: Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert 
> binary patching in standard CpuExceptionHandlerLib
> 
> On 5/5/20 5:15 PM, Laszlo Ersek via groups.io wrote:
> > On 05/01/20 22:17, Lendacky, Thomas wrote:
> >> BZ:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340d
> ata=02%7C01%7Cthomas.lendacky%40amd.com%7Cd2ec699d2c644a55724008d7f141d96f%7C3dd8961fe4884e608e11a82d994e183d%
> 7C0%7C0%7C637243137431443098sdata=oTTju7144KZc8VCmQqu74UilIOzQyji9jlO%2BMJeZYyU%3Dreserved=0
> >>
> >> Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
> >> revert the changes made to the ExceptionHandlerAsm.nasm in commit
> >> 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool
> >> chain") so that binary patching of flash code is not performed.
> >>
> >> Cc: Eric Dong 
> >> Cc: Ray Ni 
> >> Cc: Laszlo Ersek 
> >> Cc: Liming Gao 
> >> Signed-off-by: Tom Lendacky 
> >> ---
> >>   .../X64/ExceptionHandlerAsm.nasm  | 25 +--
> >>   1 file changed, 6 insertions(+), 19 deletions(-)
> >>
> >> diff --git 
> >> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> index 19198f273137..3814f9de3703 100644
> >> --- 
> >> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> +++ 
> >> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> @@ -34,7 +34,7 @@ AsmIdtVectorBegin:
> >>   db  0x6a; push  #VectorNum
> >>   db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - 
> >> AsmIdtVectorBegin) / 32) ; VectorNum
> >>   pushrax
> >> -mov rax, strict qword 0 ;mov rax, 
> >> ASM_PFX(CommonInterruptEntry)
> >> +mov rax, ASM_PFX(CommonInterruptEntry)
> >>   jmp rax
> >>   %endrep
> >>   AsmIdtVectorEnd:
> >> @@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
> >>   @VectorNum:
> >>   db  0  ; 0 will be fixed
> >>   pushrax
> >> -mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
> >> -JmpAbsoluteAddress:
> >> +mov rax, HookAfterStubHeaderEnd
> >>   jmp rax
> >>   HookAfterStubHeaderEnd:
> >>   mov rax, rsp
> >> @@ -257,7 +256,8 @@ HasErrorCode:
> >>   ; and make sure RSP is 16-byte aligned
> >>   ;
> >>   sub rsp, 4 * 8 + 8
> >> -callASM_PFX(CommonExceptionHandler)
> >> +mov rax, ASM_PFX(CommonExceptionHandler)
> >> +callrax
> >>   add rsp, 4 * 8 + 8
> >>
> >>   cli
> >> @@ -365,24 +365,11 @@ DoIret:
> >>   ; comments here for definition of address map
> >>   global ASM_PFX(AsmGetTemplateAddressMap)
> >>   ASM_PFX(AsmGetTemplateAddressMap):
> >> -lea rax, [AsmIdtVectorBegin]
> >> +mov rax, AsmIdtVectorBegin
> >>   mov qword [rcx], rax
> >>   mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 
> >> 32
> >> -lea rax, [HookAfterStubHeaderBegin]
> >> +mov rax, HookAfterStubHeaderBegin
> >>   mov qword [rcx + 0x10], rax
> >> -
> >> -; Fix up CommonInterruptEntry address
> >> -learax, [ASM_PFX(CommonInterruptEntry)]
> >> -learcx, [AsmIdtVectorBegin]
> >> -%rep  32
> >> -movqword [rcx + (JmpAbsoluteAddress - 8 - 
> >> HookAfterStubHeaderBegin)], rax
> >> -addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
> >> -%endrep
> >> -; Fix up HookAfterStubHeaderEnd
> >> -learax, [HookAfterStubHeaderEnd]
> >> -learcx, [JmpAbsoluteAddress]
> >> -movqword [rcx - 8], rax
> >> -
> >>   ret
> >>
> >>   
> >> ;-
> >>
> >
> > With this patch applied, the differences with the "original" remain:
> >
> > $ git diff 2db0ccc2d7fe^..HEAD -- \
> >
> > UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >
> >> diff --git 
> >> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> index ba8993d84b0b..3814f9de3703 100644
> >> --- 
> >> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> +++ 
> >> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
> >> @@ -1,12 +1,6 @@
> >>   
> >> ;--
> >>  ;
> >> -; Copyright (c) 2012 - 2014, Intel Corporation. All rights 

Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Lendacky, Thomas

On 5/5/20 8:53 PM, Dong, Eric wrote:




-Original Message-
From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
Laszlo Ersek
Sent: Tuesday, May 5, 2020 11:30 PM
To: Tom Lendacky ; Dong, Eric
; devel@edk2.groups.io
Cc: Justen, Jordan L ; Ard Biesheuvel
; Kinney, Michael D
; Gao, Liming ; Ni, Ray
; Brijesh Singh ; Wang, Jian J
; Wu, Hao A 
Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
be used in support of SEV-ES

On 05/04/20 18:41, Tom Lendacky wrote:


Is there an easy way to run everything that this link points, too? Is
it just creating a pull request that does this? I don't want to take
up a lot of your time, so if there's some documentation on how to run
an integration test to find and fix issues like this, just point me to it.


Just create a pull request; it will set off CI, and you can review VS build 
errors
there (if any).

Your PR will automatically be closed (rejected) regardless of whether CI
succeeds or not. PRs are merged -- in fact, *auto*-merged, by the "mergify
bot" -- if and only if (a) the CI run succeeds, and (b) the PR has the "push"
label set.

And only edk2 maintainers have permission to set the "push" label. Any PR
without the "push" label qualifies as a "personal test build". So you can freely
experiment with PRs, because you can't (even unwittingly) satisfy condition
(b).

https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-Development-data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYBc%3Dreserved=0
Process



Thanks Laszlo for your explanation.

I found this patch serial is incompatible for the existed platforms. Can you help to fix 
the build failure for these platforms in 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Fedk2-platformsdata=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6ZvFmPzjcxGo9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0



I have fixed all of the build issues associated with the VS compiler using 
the pull request method that Laszlo mentioned. I then successfully built 
the RPi4 platform under GCC (build -n 32 -a AARCH64 -t GCC5 -p 
Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.


Is there a particular platform that experiences an issue or are the 
failures related to the VS compiler errors that my next series will have 
fixed?



I think you also needs to add an wiki page to explain what need to do if an 
platform needs to integrate your changes, also it's better to explain this 
feature in the page.
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwikidata=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=xLkoV4zWhxtsbqszqPc0lEAl%2BYLL%2B2wg1nIXql8a64E%3Dreserved=0


I don't see any platform other than OVMF using this feature as it is a 
virtualization feature. Having said that I can add an explanation of what 
is needed should another virtualization platform be created under EDK2 
that wants to support SEV-ES. And, as you said, I can also explain the 
feature overall on the page.





If you want to include this change in the next edk2 release, you need to add one item for 
it in the release plan page, sample can be found in below pages: 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-Release-Planningdata=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=kcDVjYHMS9bRRZOlKEk5ynFNT39AnxchJAMak%2Bn870I%3Dreserved=0


Thanks. Is there anyone in particular that I need to request this feature 
be added?


Thanks,
Tom




Thanks,
Eric


Thanks,
Laszlo





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58711): https://edk2.groups.io/g/devel/message/58711
Mute This Topic: https://groups.io/mt/73201887/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RPi/AcpiTables: Update all tables to latest ACPI

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 1:37 PM, Pete Batard wrote:
...

Therefore, since we do see a need for ACPI 6.x features, and
effectively have a 6.3 table with PPTT, and also since we have
tested that we are not seeing ill effects from doing so for the
most common OSes we support, we bring all of the relevant ACPI
tables to version 6.3.

This is mostly accomplished by simply altering the version of
ACPI being references in the macros,


OK, so even the macros that resolve to the exact same code are renamed. 
I suppose this means a blanket rename of everything once ACPI 6.4 comes out?



except for the new fields
being initialized in the MADT table where we:
* Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even
   as this field is not supposed to apply to any of our platforms,
   this is what Microsoft used in the original Pi 3 hardcoded MADT
   blobs and Windows 10 doesn't boot on the Pi 3 if set to 0.


Fair enough.


* Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC
   is v2 only.



OK. But you are introducing new references to ACPI_6_0 macros here. If 
the point is to rename everything for cosmetic reasons, shouldn't you 
use 6.3 there as well?


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58705): https://edk2.groups.io/g/devel/message/58705
Mute This Topic: https://groups.io/mt/74026589/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH edk2-platforms 1/1] Platform/RaspberryPi/RPi4: drop Cortex-A53 erratum workaround

2020-05-06 Thread Ard Biesheuvel

On 5/6/20 12:14 PM, Leif Lindholm wrote:

On Wed, May 06, 2020 at 11:56:14 +0200, Ard Biesheuvel wrote:

The Raspberry Pi4 uses Cortex-A72 cores so it has no need for the
Cortex-A53 ADRP erratum workaround.

Signed-off-by: Ard Biesheuvel 


Reviewed-by: Leif Lindholm 



Thanks

Pushed as 35a5402a718f..66d1b02429fa


---
  Platform/RaspberryPi/RPi4/RPi4.dsc | 1 -
  1 file changed, 1 deletion(-)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index a112174c5303..0d54fa477ca2 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -242,7 +242,6 @@ [BuildOptions]
GCC:*_*_*_ASLPP_FLAGS   = -DRPI_MODEL=4
GCC:*_*_*_ASLCC_FLAGS   = -DRPI_MODEL=4
GCC:*_*_*_VFRPP_FLAGS   = -DRPI_MODEL=4
-  GCC:*_*_AARCH64_DLINK_FLAGS = -Wl,--fix-cortex-a53-843419
GCC:RELEASE_*_*_CC_FLAGS= -DMDEPKG_NDEBUG -DNDEBUG
  
  [BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]

--
2.17.1




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58707): https://edk2.groups.io/g/devel/message/58707
Mute This Topic: https://groups.io/mt/74025440/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RPi/AcpiTables: Update all tables to latest ACPI

2020-05-06 Thread Pete Batard

On 2020.05.06 13:26, Ard Biesheuvel wrote:

On 5/6/20 1:37 PM, Pete Batard wrote:
...

Therefore, since we do see a need for ACPI 6.x features, and
effectively have a 6.3 table with PPTT, and also since we have
tested that we are not seeing ill effects from doing so for the
most common OSes we support, we bring all of the relevant ACPI
tables to version 6.3.

This is mostly accomplished by simply altering the version of
ACPI being references in the macros,


OK, so even the macros that resolve to the exact same code are renamed. 
I suppose this means a blanket rename of everything once ACPI 6.4 comes 
out?


No.

I am considering that we are still in the process of introducing the 
platform, therefore we introduce it with the most up to date version of 
ACPI at that time.


Though I could see some point in doing so, I have no plan to update out 
ACPI for the Pi's every time a new version is released, unless there is 
an actual need to do so for a specific table or there is a blanket 
request (from seeing lots of folks using our code as a starting point) 
that warrants it.


In other words, even as RPi3 was introduced a year ago, I consider that 
we are still in the process of adding RPi3/RPi4 as a brand new platform, 
and therefore want to use the most up to date ACPI at the time of 
introduction. But I'm definitely not making a point of trying to follow 
ACPI updates past that this.





except for the new fields
being initialized in the MADT table where we:
* Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even
   as this field is not supposed to apply to any of our platforms,
   this is what Microsoft used in the original Pi 3 hardcoded MADT
   blobs and Windows 10 doesn't boot on the Pi 3 if set to 0.


Fair enough.


* Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC
   is v2 only.



OK. But you are introducing new references to ACPI_6_0 macros here. If 
the point is to rename everything for cosmetic reasons, shouldn't you 
use 6.3 there as well?


Well, EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT was not updated for 6_1, 6_2, 
6_3 (most likely because the macro, which is defined in 
EmbeddedPkg/Include/Library/AcpiLib.h applies the same for all 6.x 
versions), so I just used the highest version I could find, which is 
6_0. This is based on what I saw other platforms do.


I don't mind sending an EDK2 patch to add the various 
EFI_ACPI_6_x_GIC_DISTRIBUTOR_INIT if that's what you request, but that 
seems a bit like overkill and may break existing platforms, because it 
will most likely require moving EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT to a 
different header (MdePkg/Include/IndustryStandard/Acpi60.h).


Regards,

/Pete

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58708): https://edk2.groups.io/g/devel/message/58708
Mute This Topic: https://groups.io/mt/74026589/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RPi/AcpiTables: Update all tables to latest ACPI

2020-05-06 Thread Pete Batard

On 2020.05.06 13:50, Ard Biesheuvel wrote:

On 5/6/20 2:45 PM, Pete Batard wrote:

On 2020.05.06 13:26, Ard Biesheuvel wrote:

On 5/6/20 1:37 PM, Pete Batard wrote:
...

Therefore, since we do see a need for ACPI 6.x features, and
effectively have a 6.3 table with PPTT, and also since we have
tested that we are not seeing ill effects from doing so for the
most common OSes we support, we bring all of the relevant ACPI
tables to version 6.3.

This is mostly accomplished by simply altering the version of
ACPI being references in the macros,


OK, so even the macros that resolve to the exact same code are 
renamed. I suppose this means a blanket rename of everything once 
ACPI 6.4 comes out?


No.

I am considering that we are still in the process of introducing the 
platform, therefore we introduce it with the most up to date version 
of ACPI at that time.


Though I could see some point in doing so, I have no plan to update 
out ACPI for the Pi's every time a new version is released, unless 
there is an actual need to do so for a specific table or there is a 
blanket request (from seeing lots of folks using our code as a 
starting point) that warrants it.


In other words, even as RPi3 was introduced a year ago, I consider 
that we are still in the process of adding RPi3/RPi4 as a brand new 
platform, and therefore want to use the most up to date ACPI at the 
time of introduction. But I'm definitely not making a point of trying 
to follow ACPI updates past that this.




Good.


except for the new fields
being initialized in the MADT table where we:
* Use 1 for GICR Base Address in GICC_STRUCTURE_INIT because, even
   as this field is not supposed to apply to any of our platforms,
   this is what Microsoft used in the original Pi 3 hardcoded MADT
   blobs and Windows 10 doesn't boot on the Pi 3 if set to 0.


Fair enough.


* Use 2 for GIC version in GIC_DISTRIBUTOR_INIT, since the Pi 4 GIC
   is v2 only.



OK. But you are introducing new references to ACPI_6_0 macros here. 
If the point is to rename everything for cosmetic reasons, shouldn't 
you use 6.3 there as well?


Well, EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT was not updated for 6_1, 6_2, 
6_3 (most likely because the macro, which is defined in 
EmbeddedPkg/Include/Library/AcpiLib.h applies the same for all 6.x 
versions), so I just used the highest version I could find, which is 
6_0. This is based on what I saw other platforms do.


I don't mind sending an EDK2 patch to add the various 
EFI_ACPI_6_x_GIC_DISTRIBUTOR_INIT if that's what you request, but that 
seems a bit like overkill and may break existing platforms, because it 
will most likely require moving EFI_ACPI_6_0_GIC_DISTRIBUTOR_INIT to a 
different header (MdePkg/Include/IndustryStandard/Acpi60.h).




Fair enough.

Reviewed-by: Ard Biesheuvel 

Pushed as 66d1b02429fa..11189124fbc2


Thanks!

/Pete

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58710): https://edk2.groups.io/g/devel/message/58710
Mute This Topic: https://groups.io/mt/74026589/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 0/4] FmpDevicePkg: Move capsule dependency implement to library

2020-05-06 Thread Liming Gao
Reviewed-by: Liming Gao 

> -Original Message-
> From: Xu, Wei6 
> Sent: Tuesday, April 28, 2020 9:25 PM
> To: devel@edk2.groups.io
> Cc: Kinney, Michael D ; Gao, Liming 
> ; Sean Brogan
> 
> Subject: [edk2-devel] [PATCH 0/4] FmpDevicePkg: Move capsule dependency 
> implement to library
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2696
> 
> This patch series move the implementation of Fmp Capsule Dependency from
>  FmpDxe driver into two library classes. FmpDependencyLib is a base lib
>  to provide generic dependency evaluation services. FmpDependencyCheckLib
>  is a platform lib to provide dependency check services during firmware
>  update. Platform can perform the dependency check in platform specific
>  manner by implementing its own FmpDependencyCheckLib.
> This patch series also add unit test for EvaluateDependency API in
>  FmpDependencyLib.
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Sean Brogan 
> Signed-off-by: Wei6 Xu 
> 
> 
> Wei6 Xu (4):
>   FmpDevicePkg: Add FmpDependency library class and BASE instance
>   FmpDevicePkg/Test: Add FmpDependencyLib unit test.
>   FmpDevicePkg: Add FmpDependencyCheck library class and instances
>   FmpDevicePkg/FmpDxe: Use FmpDependencyLib and FmpDependencyCheckLib
> 
>  FmpDevicePkg/FmpDevicePkg.ci.yaml  |  10 +
>  FmpDevicePkg/FmpDevicePkg.dec  |  15 +-
>  FmpDevicePkg/FmpDevicePkg.dsc  |  14 +-
>  FmpDevicePkg/FmpDevicePkg.uni  |   4 +-
>  FmpDevicePkg/FmpDxe/Dependency.h   |  63 ---
>  FmpDevicePkg/FmpDxe/FmpDxe.c   | 255 ++
>  FmpDevicePkg/FmpDxe/FmpDxe.h   |   3 +
>  FmpDevicePkg/FmpDxe/FmpDxe.inf |   4 +-
>  FmpDevicePkg/FmpDxe/FmpDxeLib.inf  |   4 +-
>  .../Include/Library/FmpDependencyCheckLib.h|  71 +++
>  FmpDevicePkg/Include/Library/FmpDependencyLib.h| 104 
>  .../FmpDependencyCheckLib/FmpDependencyCheckLib.c  | 533 
> +
>  .../FmpDependencyCheckLib.inf  |  51 ++
>  .../FmpDependencyCheckLib.uni  |  13 +
>  .../FmpDependencyCheckLibNull.c|  74 +++
>  .../FmpDependencyCheckLibNull.inf  |  30 ++
>  .../FmpDependencyCheckLibNull.uni  |  13 +
>  .../FmpDependencyLib/FmpDependencyLib.c}   | 314 
>  .../Library/FmpDependencyLib/FmpDependencyLib.inf  |  34 ++
>  .../Library/FmpDependencyLib/FmpDependencyLib.uni  |  12 +
>  FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc |  28 ++
>  .../FmpDependencyLib/EvaluateDependencyUnitTest.c  | 271 +++
>  .../FmpDependencyLibUnitTestsHost.inf  |  34 ++
>  .../FmpDependencyLibUnitTestsUefi.inf  |  35 ++
>  24 files changed, 1508 insertions(+), 481 deletions(-)
>  delete mode 100644 FmpDevicePkg/FmpDxe/Dependency.h
>  create mode 100644 FmpDevicePkg/Include/Library/FmpDependencyCheckLib.h
>  create mode 100644 FmpDevicePkg/Include/Library/FmpDependencyLib.h
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.inf
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.uni
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLibNull/FmpDependencyCheckLibNull.c
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLibNull/FmpDependencyCheckLibNull.inf
>  create mode 100644 
> FmpDevicePkg/Library/FmpDependencyCheckLibNull/FmpDependencyCheckLibNull.uni
>  rename FmpDevicePkg/{FmpDxe/Dependency.c => 
> Library/FmpDependencyLib/FmpDependencyLib.c} (55%)
>  create mode 100644 FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.inf
>  create mode 100644 FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.uni
>  create mode 100644 FmpDevicePkg/Test/FmpDeviceHostPkgTest.dsc
>  create mode 100644 
> FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c
>  create mode 100644 
> FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibUnitTestsHost.inf
>  create mode 100644 
> FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/FmpDependencyLibUnitTestsUefi.inf
> 
> --
> 2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58712): https://edk2.groups.io/g/devel/message/58712
Mute This Topic: https://groups.io/mt/73326866/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH 1/3] Platform/RPi: Fortify mailbox code

2020-05-06 Thread Ard Biesheuvel

On 5/4/20 1:15 PM, Pete Batard wrote:

From: Andrei Warkentin 

As part of the analysis done in:
https://github.com/raspberrypi/firmware/issues/1376:
* Bump up max tries, to avoid command time-outs.
* Macro-ify RaspberryPiHelper.S some more to make code more maintainable.
* Add ".align 4" before every command buffer.

Co-authored-by: Pete Batard 
Co-authored-by: Andrei Warkentin 
Signed-off-by: Pete Batard 


This patch

Reviewed-by: Ard Biesheuvel 

Pushed as 725d1198e262..35a5402a718f



---
  Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c | 11 +---
  Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h  | 11 +++-
  Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S | 60 

  3 files changed, 37 insertions(+), 45 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c 
b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
index 40c78b5d57cf..6c45cf47f082 100644
--- a/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ b/Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
@@ -1,5 +1,6 @@
  /** @file
   *
+ *  Copyright (c) 2020, Pete Batard 
   *  Copyright (c) 2019, ARM Limited. All rights reserved.
   *  Copyright (c) 2017-2018, Andrei Warkentin 
   *  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
@@ -30,12 +31,6 @@
  //
  #define NUM_PAGES   1
  
-//

-// The number of iterations to perform when waiting for the mailbox
-// status to change
-//
-#define MAX_TRIES   0x10
-
  STATIC VOID  *mDmaBuffer;
  STATIC VOID  *mDmaBufferMapping;
  STATIC UINTN mDmaBufferBusAddress;
@@ -62,7 +57,7 @@ DrainMailbox (
  }
  ArmDataSynchronizationBarrier ();
  MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
-  } while (++Tries < MAX_TRIES);
+  } while (++Tries < RPI_MBOX_MAX_TRIES);
  
return FALSE;

  }
@@ -86,7 +81,7 @@ MailboxWaitForStatusCleared (
return TRUE;
  }
  ArmDataSynchronizationBarrier ();
-  } while (++Tries < MAX_TRIES);
+  } while (++Tries < RPI_MBOX_MAX_TRIES);
  
return FALSE;

  }
diff --git a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h 
b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
index 584786a61dfd..3328be582df1 100644
--- a/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
+++ b/Platform/RaspberryPi/Include/IndustryStandard/RpiMbox.h
@@ -1,6 +1,6 @@
  /** @file
   *
- * Copyright (c) 2019, Pete Batard 
+ * Copyright (c) 2019-2020, Pete Batard 
   * Copyright (c) 2016, Linaro Limited. All rights reserved.
   *
   * SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -10,6 +10,15 @@
  #ifndef __RASPBERRY_PI_MAILBOX_H__
  #define __RASPBERRY_PI_MAILBOX_H__
  
+/*

+ * Number of iterations to perform when waiting for the mailbox.
+ *
+ * This number was arrived at empirically, following discussion
+ * at https://github.com/raspberrypi/firmware/issues/1376, to
+ * avoid mailbox time-outs on some commands.
+ */
+#define RPI_MBOX_MAX_TRIES0x800
+
  /* Mailbox channels */
  #define RPI_MBOX_PM_CHANNEL   0
  #define RPI_MBOX_FB_CHANNEL   1
diff --git 
a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S 
b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
index cc58406e1bfc..91dfe1bb981e 100644
--- a/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
+++ b/Platform/RaspberryPi/Library/PlatformLib/AArch64/RaspberryPiHelper.S
@@ -1,6 +1,7 @@
  /** @file
   *
- *  Copyright (c) 2019, Pete Batard 
+ *  Copyright (c) 2020, Andrei Warkentin 
+ *  Copyright (c) 2019-2020, Pete Batard 
   *  Copyright (c) 2016, Linaro Limited. All rights reserved.
   *  Copyright (c) 2011-2013, ARM Limited. All rights reserved.
   *
@@ -13,10 +14,8 @@
  #include 
  #include 
  
-#define MAX_TRIES 0x10

-
  .macro  drain
-mov x5, #MAX_TRIES
+mov x5, #RPI_MBOX_MAX_TRIES
  0:  ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
  tbnzw6, #BCM2836_MBOX_STATUS_EMPTY, 1f
  dmb ld
@@ -27,7 +26,7 @@
  .endm
  
  .macro  poll, status

-mov x5, #MAX_TRIES
+mov x5, #RPI_MBOX_MAX_TRIES
  0:  ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
  tbz w6, #\status, 1f
  dmb ld
@@ -36,23 +35,30 @@
  1:
  .endm
  
+.macro  run, command_buffer

+adr x0, \command_buffer
+orr x0, x0, #RPI_MBOX_VC_CHANNEL
+add x0, x0, x1
+
+pollBCM2836_MBOX_STATUS_FULL
+str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET]
+dmb sy
+pollBCM2836_MBOX_STATUS_EMPTY
+dmb sy
+ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET]
+dmb ld
+.endm
+
  ASM_FUNC (ArmPlatformPeiBootAction)
-adr x0, .Lmeminfo_buffer
  mov x1, #FixedPcdGet64 (PcdDmaDeviceOffset)
  orr x0, x0, #RPI_MBOX_VC_CHANNEL
  // x1 holds the value of 

Re: [edk2-devel] [PATCH] UefiCpuPkg/MpInitLib: Remove Executable attribute from MpLib.h

2020-05-06 Thread Laszlo Ersek
On 05/06/20 03:31, Dong, Eric wrote:
> Acked-by: Eric Dong 
> 
> Hi Laszlo,
> 
> I saw you already provided Review-by tag and I can't verify the change, so I 
> don't add comments for this patch.
> 
> I will provide Acked-by tag for the similar case next time.

Thank you -- I only have an "R" role for UefiCpuPkg; I don't think I
should push any UefiCpuPkg patch without "M" approval.

> I have pushed this change.

Thank you!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58715): https://edk2.groups.io/g/devel/message/58715
Mute This Topic: https://groups.io/mt/73191992/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/1] ShellPkg: smbiosview - print field values as unsigned integers

2020-05-06 Thread Rebecca Cran
This prevents overflow when printing DWORD fields such as the type 17
tables's extended DIMM size.

Signed-off-by: Rebecca Cran 
Cc: Ray Ni 
Cc: Zhichao Gao 
Cc: Philippe Mathieu-Daude 
---
 .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index a75caff3de34..1ea7b84bd0fa 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -49,7 +49,7 @@
 #define PRINT_STRUCT_VALUE(pStruct, type, element) \
   do { \
 ShellPrintEx(-1,-1,L"%a",#element); \
-ShellPrintEx(-1,-1,L": %d\n", (pStruct->type->element)); \
+ShellPrintEx(-1,-1,L": %u\n", (pStruct->type->element)); \
   } while (0);
 
 #define PRINT_STRUCT_VALUE_H(pStruct, type, element) \
@@ -634,8 +634,8 @@ SmbiosPrintStructure (
   NumOfItem = (Struct->Type14->Hdr.Length - 5) / 3;
   PRINT_PENDING_STRING (Struct, Type14, GroupName);
   for (Index = 0; Index < NumOfItem; Index++) {
-ShellPrintEx(-1,-1,L"ItemType %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemType);
-ShellPrintEx(-1,-1,L"ItemHandle %d: %d\n", Index + 1, 
Struct->Type14->Group[Index].ItemHandle);
+ShellPrintEx(-1,-1,L"ItemType %u: %u\n", Index + 1, 
Struct->Type14->Group[Index].ItemType);
+ShellPrintEx(-1,-1,L"ItemHandle %u: %u\n", Index + 1, 
Struct->Type14->Group[Index].ItemHandle);
   }
 }
 break;
-- 
2.26.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58725): https://edk2.groups.io/g/devel/message/58725
Mute This Topic: https://groups.io/mt/74032727/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Laszlo Ersek
On 05/06/20 15:19, Tom Lendacky wrote:
> On 5/5/20 8:53 PM, Dong, Eric wrote:
>>
>>
>>> -Original Message-
>>> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
>>> Laszlo Ersek
>>> Sent: Tuesday, May 5, 2020 11:30 PM
>>> To: Tom Lendacky ; Dong, Eric
>>> ; devel@edk2.groups.io
>>> Cc: Justen, Jordan L ; Ard Biesheuvel
>>> ; Kinney, Michael D
>>> ; Gao, Liming ; Ni,
>>> Ray
>>> ; Brijesh Singh ; Wang, Jian J
>>> ; Wu, Hao A 
>>> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
>>> be used in support of SEV-ES
>>>
>>> On 05/04/20 18:41, Tom Lendacky wrote:
>>>
 Is there an easy way to run everything that this link points, too? Is
 it just creating a pull request that does this? I don't want to take
 up a lot of your time, so if there's some documentation on how to run
 an integration test to find and fix issues like this, just point me
 to it.
>>>
>>> Just create a pull request; it will set off CI, and you can review VS
>>> build errors
>>> there (if any).
>>>
>>> Your PR will automatically be closed (rejected) regardless of whether CI
>>> succeeds or not. PRs are merged -- in fact, *auto*-merged, by the
>>> "mergify
>>> bot" -- if and only if (a) the CI run succeeds, and (b) the PR has
>>> the "push"
>>> label set.
>>>
>>> And only edk2 maintainers have permission to set the "push" label.
>>> Any PR
>>> without the "push" label qualifies as a "personal test build". So you
>>> can freely
>>> experiment with PRs, because you can't (even unwittingly) satisfy
>>> condition
>>> (b).
>>>
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-Development-data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYBc%3Dreserved=0
>>>
>>> Process
>>>
>>
>> Thanks Laszlo for your explanation.
>>
>> I found this patch serial is incompatible for the existed platforms.
>> Can you help to fix the build failure for these platforms in
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Ftianocore%2Fedk2-platformsdata=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6ZvFmPzjcxGo9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0
>>
>>
> 
> I have fixed all of the build issues associated with the VS compiler
> using the pull request method that Laszlo mentioned. I then successfully
> built the RPi4 platform under GCC (build -n 32 -a AARCH64 -t GCC5 -p
> Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.
> 
> Is there a particular platform that experiences an issue or are the
> failures related to the VS compiler errors that my next series will have
> fixed?

I think that Eric refers to various (as of yet, unspecified) platform
DSCs in the edk2-platforms tree, which consume edk2.

https://github.com/tianocore/edk2-platforms/

I don't fully agree with Eric on this observation. I agree somewhat.

I have always made the argument that *all* platform code should reside
in edk2; in other words, we should not have a separate edk2-platforms
repository. Then it is feasible for a contributor to adapt dependent
platform code in the same patch series that modifies core code.

But I have not been successful in arguing against the edk2-platforms
tree's existence, and so we have two projects now, with separate git
histories. Therefore, the pattern sometiems followed is to split the
edk2 (core) patch series into multiple sub-series, and to post an
edk2-platforms series in the middle, to help edk2-platforms cope with
the edk2 changes.

The question is of course how complicated this is. If the edk2-platforms
patches are not difficult, then I think the edk2-platforms maintainers
may ask the contributor to submit patches for edk2-platforms too, as a
*courtesy*. But if the edk2-platforms patches are many or complicated,
then I think it's *unfair* to block edk2 changes *only* due to
edk2-platforms dependencies. The edk2 contributor may not be familiar
with the edk2-platforms stuff at all; worse, firmware platforms in the
latter tree have often very quirky build instructions.

Inside a single git tree, a contributor is justifiedly expected to track
down dependencies and to update them (see for example Tom's patches for
UefiPayloadPkg!), but in other trees, that's not necessarily the case.

If we'd like Tom to adapt edk2-platforms to the edk2 changes, and maybe
even restructure the edk2 series in order to accommodate this, then the
*bare minimum* is to provide specific error messages and build instructions.

> 
>> I think you also needs to add an wiki page to explain what need to do
>> if an platform needs to integrate your changes, also it's better to
>> explain this feature in the page.
>> 

[edk2-devel] [PATCH resend 0/7] Add support for MM communicate2 protocol (PI 1.7a)

2020-05-06 Thread Ard Biesheuvel
Now that version 1.7 errata A of the PI spec has finally been released,
we can take another look at this series, which incorporates the new MM
communicate2 protocol definition, updates the producers for conventional
SMM and standalone MM, and updates the variable store components to consume
the new version of the protocol. This solves a long standing compatibility
issue which made standalone MM fundamentally incompatible with a virtually
remapped address space as installed by SetVirtualAddressMap().

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Jiewen Yao 

Ard Biesheuvel (7):
  MdePkg: introduce MM communicate 2 protocol
  MdeModulePkg/SmmIpl: expose MM communicate 2 protocol
  ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol
  MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol
  MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2
  MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2
  StandaloneMmPkg: switch to MM communicate 2 protocol

 .../MmCommunicationDxe/MmCommunication.c  | 81 +--
 .../MmCommunicationDxe/MmCommunication.inf|  6 +-
 .../Application/VariableInfo/VariableInfo.c   | 19 +++--
 .../Application/VariableInfo/VariableInfo.inf |  2 +-
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c| 80 ++
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf  |  1 +
 MdeModulePkg/Include/Guid/SmmVariableCommon.h |  6 +-
 .../FaultTolerantWriteSmmCommon.h |  2 +-
 .../FaultTolerantWriteSmmDxe.c| 25 +++---
 .../FaultTolerantWriteSmmDxe.h|  2 +-
 .../FaultTolerantWriteSmmDxe.inf  |  4 +-
 .../RuntimeDxe/VariableSmmRuntimeDxe.c| 39 -
 .../RuntimeDxe/VariableSmmRuntimeDxe.inf  |  4 +-
 MdePkg/Include/Protocol/MmCommunication2.h| 69 
 MdePkg/MdePkg.dec |  7 ++
 StandaloneMmPkg/Core/StandaloneMmCore.h   |  2 +-
 .../StandaloneMmCpu/AArch64/StandaloneMmCpu.h |  2 +-
 17 files changed, 256 insertions(+), 95 deletions(-)
 create mode 100644 MdePkg/Include/Protocol/MmCommunication2.h

-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58726): https://edk2.groups.io/g/devel/message/58726
Mute This Topic: https://groups.io/mt/74033563/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH resend 5/7] MdeModulePkg/FaultTolerantWriteSmmDxe: switch to MM communicate 2

2020-05-06 Thread Ard Biesheuvel
Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h |  
2 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c| 
25 +++-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.h|  
2 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.inf  |  
4 ++--
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
index 4546a1b445b9..5f0eec0506ed 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
@@ -29,7 +29,7 @@ typedef struct {
 ///
 /// Size of SMM communicate header, without including the payload.
 ///
-#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, 
Data))
+#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, 
Data))
 
 ///
 /// Size of SMM FTW communicate function header, without including the payload.
diff --git 
a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
index 6e3eb3b58b09..24c20950296d 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmDxe.c
@@ -11,7 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "FaultTolerantWriteSmmDxe.h"
 
 EFI_HANDLE mHandle   = NULL;
-EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication= NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL *mMmCommunication2= NULL;
 UINTN  mPrivateDataSize  = 0;
 
 EFI_FAULT_TOLERANT_WRITE_PROTOCOL  mFaultTolerantWriteDriver = {
@@ -40,7 +40,7 @@ InitCommunicateBuffer (
   IN  UINTN Function
   )
 {
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_FTW_COMMUNICATE_FUNCTION_HEADER   *SmmFtwFunctionHeader;
 
   //
@@ -74,7 +74,7 @@ InitCommunicateBuffer (
 **/
 EFI_STATUS
 SendCommunicateBuffer (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader,
   IN  UINTN DataSize
   )
 {
@@ -83,7 +83,10 @@ SendCommunicateBuffer (
   SMM_FTW_COMMUNICATE_FUNCTION_HEADER   *SmmFtwFunctionHeader;
 
   CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + 
SMM_FTW_COMMUNICATE_HEADER_SIZE;
-  Status = mSmmCommunication->Communicate (mSmmCommunication, 
SmmCommunicateHeader, );
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+   SmmCommunicateHeader,
+   SmmCommunicateHeader,
+   );
   ASSERT_EFI_ERROR (Status);
 
   SmmFtwFunctionHeader = (SMM_FTW_COMMUNICATE_FUNCTION_HEADER *) 
SmmCommunicateHeader->Data;
@@ -148,7 +151,7 @@ FtwGetMaxBlockSize (
 {
   EFI_STATUSStatus;
   UINTN PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_FTW_GET_MAX_BLOCK_SIZE_HEADER *SmmFtwBlockSizeHeader;
 
   //
@@ -204,7 +207,7 @@ FtwAllocate (
 {
   EFI_STATUSStatus;
   UINTN PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_FTW_ALLOCATE_HEADER   *SmmFtwAllocateHeader;
 
   //
@@ -270,7 +273,7 @@ FtwWrite (
 {
   EFI_STATUSStatus;
   UINTN PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_FTW_WRITE_HEADER  *SmmFtwWriteHeader;
 
   //
@@ -336,7 +339,7 @@ FtwRestart (
 {
   EFI_STATUSStatus;
   UINTN PayloadSize;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_FTW_RESTART_HEADER*SmmFtwRestartHeader;
 
   //
@@ -381,7 +384,7 @@ FtwAbort (
   )
 {
   EFI_STATUSStatus;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER 

[edk2-devel] [PATCH resend 2/7] MdeModulePkg/SmmIpl: expose MM communicate 2 protocol

2020-05-06 Thread Ard Biesheuvel
The MM communicate 2 protocol was introduced to factor out the mismatch
between traditional MM, which requires the physical address of the MM
buffer to be passed, and standalone MM, which copies the MM communicate
buffer data into a separate buffer, requiring the virtual address. For
this reason, MM communicate 2 carries both addresses, allowing the
implementation to decide which address it needs.

This hides this implementation detail from the callers of the protocol,
which simply passes both addresses without having to reason about what the
implementation of the protocol actually needs.

Note that the old version of the protocol is retained, in order to support
existing implementations that don't require this flexibility.

Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c   | 80 
 MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf |  1 +
 2 files changed, 81 insertions(+)

diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c 
b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
index 20b84eaee277..0385f1d4bdee 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
@@ -10,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -118,6 +119,39 @@ SmmCommunicationCommunicate (
   IN OUT UINTN *CommSize OPTIONAL
   );
 
+/**
+  Communicates with a registered handler.
+
+  This function provides a service to send and receive messages from a 
registered UEFI service.
+
+  @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication 
buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSizeThe size of the data buffer being passed in. 
On exit, the size of data
+ being returned. Zero if the handler does not 
wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESSThe message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.
+  @retval EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM 
implementation.
+ If this error is returned, the MessageLength 
field
+ in the CommBuffer header or the integer 
pointed by
+ CommSize, are updated to reflect the maximum 
payload
+ size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED  The CommunicateBuffer parameter or CommSize 
parameter,
+ if not omitted, are in address range that 
cannot be
+ accessed by the MM environment.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmCommunicationMmCommunicate2 (
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID   *CommBufferPhysical,
+  IN OUT VOID   *CommBufferVirtual,
+  IN OUT UINTN  *CommSize OPTIONAL
+  );
+
 /**
   Event notification that is fired every time a gEfiSmmConfigurationProtocol 
installs.
 
@@ -240,6 +274,13 @@ EFI_SMM_COMMUNICATION_PROTOCOL  mSmmCommunication = {
   SmmCommunicationCommunicate
 };
 
+//
+// PI 1.7 MM Communication Protocol 2 instance
+//
+EFI_MM_COMMUNICATION2_PROTOCOL  mMmCommunication2 = {
+  SmmCommunicationMmCommunicate2
+};
+
 //
 // SMM Core Private Data structure that contains the data shared between
 // the SMM IPL and the SMM Core.
@@ -576,6 +617,44 @@ SmmCommunicationCommunicate (
   return (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;
 }
 
+/**
+  Communicates with a registered handler.
+
+  This function provides a service to send and receive messages from a 
registered UEFI service.
+
+  @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication 
buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSizeThe size of the data buffer being passed in. 
On exit, the size of data
+ being returned. Zero if the handler does not 
wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESSThe message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  The CommBuffer was NULL.
+  @retval EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM 
implementation.
+ If this error is returned, the MessageLength 
field
+ in the CommBuffer header or the integer 
pointed by
+ CommSize, are updated to reflect the maximum 
payload
+ size the implementation can accommodate.
+  @retval 

[edk2-devel] [PATCH resend 1/7] MdePkg: introduce MM communicate 2 protocol

2020-05-06 Thread Ard Biesheuvel
Add the protocol definition of the MM communicate 2 protocol,
which has been introduced by version 1.7 errata A of the PI spec.

Signed-off-by: Ard Biesheuvel 
---
 MdePkg/Include/Protocol/MmCommunication2.h | 69 
 MdePkg/MdePkg.dec  |  7 ++
 2 files changed, 76 insertions(+)

diff --git a/MdePkg/Include/Protocol/MmCommunication2.h 
b/MdePkg/Include/Protocol/MmCommunication2.h
new file mode 100644
index ..05f56dcae53e
--- /dev/null
+++ b/MdePkg/Include/Protocol/MmCommunication2.h
@@ -0,0 +1,69 @@
+/** @file
+  EFI MM Communication Protocol 2 as defined in the PI 1.7 errata A 
specification.
+
+  This protocol provides a means of communicating between drivers outside of 
MM and MMI
+  handlers inside of MM.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved.
+  Copyright (c) 2020, Arm Limited. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _MM_COMMUNICATION2_H_
+#define _MM_COMMUNICATION2_H_
+
+#include 
+
+#define EFI_MM_COMMUNICATION2_PROTOCOL_GUID \
+  { \
+0x378daedc, 0xf06b, 0x4446, { 0x83, 0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 
0xa3 } \
+  }
+
+typedef struct _EFI_MM_COMMUNICATION2_PROTOCOL  EFI_MM_COMMUNICATION2_PROTOCOL;
+
+/**
+  Communicates with a registered handler.
+
+  This function provides a service to send and receive messages from a 
registered UEFI service.
+
+  @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication 
buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSizeThe size of the data buffer being passed in. 
On exit, the size of data
+ being returned. Zero if the handler does not 
wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESSThe message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or 
CommBufferVirtual was NULL.
+  @retval EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM 
implementation.
+ If this error is returned, the MessageLength 
field
+ in the CommBuffer header or the integer 
pointed by
+ CommSize, are updated to reflect the maximum 
payload
+ size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED  The CommunicateBuffer parameter or CommSize 
parameter,
+ if not omitted, are in address range that 
cannot be
+ accessed by the MM environment.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MM_COMMUNICATE2)(
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID   *CommBufferPhysical,
+  IN OUT VOID   *CommBufferVirtual,
+  IN OUT UINTN  *CommSize OPTIONAL
+  );
+
+///
+/// EFI MM Communication Protocol provides runtime services for communicating
+/// between DXE drivers and a registered MMI handler.
+///
+struct _EFI_MM_COMMUNICATION2_PROTOCOL {
+  EFI_MM_COMMUNICATE2  Communicate;
+};
+
+extern EFI_GUID gEfiMmCommunication2ProtocolGuid;
+
+#endif
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 6c37c2181c62..e2a79dd85db6 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1277,6 +1277,13 @@ [Protocols]
   ## Include/Protocol/SpiSmmNorFlash.h
   gEfiSpiSmmNorFlashProtocolGuid = { 0xaab18f19, 0xfe14, 0x4666, { 
0x86, 0x04, 0x87, 0xff, 0x6d, 0x66, 0x2c, 0x9a }}
 
+  #
+  # Protocols defined in PI 1.7.
+  #
+
+  ## Include/Protocol/MmCommunication2.h
+  gEfiMmCommunication2ProtocolGuid  = { 0x378daedc, 0xf06b, 0x4446, { 0x83, 
0x14, 0x40, 0xab, 0x93, 0x3c, 0x87, 0xa3 }}
+
   #
   # Protocols defined in UEFI2.1/UEFI2.0/EFI1.1
   #
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58727): https://edk2.groups.io/g/devel/message/58727
Mute This Topic: https://groups.io/mt/74033564/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH resend 3/7] ArmPkg/MmCommunicationDxe: expose MM Communicate 2 protocol

2020-05-06 Thread Ard Biesheuvel
Implement the new MmCommunication2 protocol which supports the use
of standalone MM at runtime inside an address space that has been
virtually remapped by the OS.

Note that the implementation of the old MM Communicate protocol is
removed: it never worked correctly so there is no point in keeping it.

Signed-off-by: Ard Biesheuvel 
---
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c   | 81 +---
 ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf |  6 +-
 2 files changed, 41 insertions(+), 46 deletions(-)

diff --git a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c 
b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
index a9e06be1adc2..9457eaf1d809 100644
--- a/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
+++ b/ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.c
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2016-2018, ARM Limited. All rights reserved.
+  Copyright (c) 2016-2020, ARM Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -16,7 +16,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 
@@ -39,39 +39,34 @@ STATIC EFI_HANDLE  mMmCommunicateHandle;
 /**
   Communicates with a registered handler.
 
-  This function provides an interface to send and receive messages to the
-  Standalone MM environment on behalf of UEFI services.  This function is part
-  of the MM Communication Protocol that may be called in physical mode prior to
-  SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().
+  This function provides a service to send and receive messages from a 
registered UEFI service.
 
-  @param[in]  ThisThe EFI_MM_COMMUNICATION_PROTOCOL
-  instance.
-  @param[in, out] CommBuffer  A pointer to the buffer to convey
-  into MMRAM.
-  @param[in, out] CommSizeThe size of the data buffer being
-  passed in. This is optional.
+  @param[in] ThisThe EFI_MM_COMMUNICATION_PROTOCOL instance.
+  @param[in] CommBufferPhysical  Physical address of the MM communication 
buffer
+  @param[in] CommBufferVirtual   Virtual address of the MM communication buffer
+  @param[in] CommSizeThe size of the data buffer being passed in. 
On exit, the size of data
+ being returned. Zero if the handler does not 
wish to reply with any data.
+ This parameter is optional and may be NULL.
+
+  @retval EFI_SUCCESSThe message was successfully posted.
+  @retval EFI_INVALID_PARAMETER  CommBufferPhysical was NULL or 
CommBufferVirtual was NULL.
+  @retval EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM 
implementation.
+ If this error is returned, the MessageLength 
field
+ in the CommBuffer header or the integer 
pointed by
+ CommSize, are updated to reflect the maximum 
payload
+ size the implementation can accommodate.
+  @retval EFI_ACCESS_DENIED  The CommunicateBuffer parameter or CommSize 
parameter,
+ if not omitted, are in address range that 
cannot be
+ accessed by the MM environment.
 
-  @retval EFI_SUCCESS The message was successfully posted.
-  @retval EFI_INVALID_PARAMETER   The CommBuffer was NULL.
-  @retval EFI_BAD_BUFFER_SIZE The buffer size is incorrect for the MM
-  implementation. If this error is
-  returned, the MessageLength field in
-  the CommBuffer header or the integer
-  pointed by CommSize are updated to 
reflect
-  the maximum payload size the
-  implementation can accommodate.
-  @retval EFI_ACCESS_DENIED   The CommunicateBuffer parameter
-  or CommSize parameter, if not omitted,
-  are in address range that cannot be
-  accessed by the MM environment
 **/
-STATIC
 EFI_STATUS
 EFIAPI
-MmCommunicationCommunicate (
-  IN CONST EFI_MM_COMMUNICATION_PROTOCOL  *This,
-  IN OUT VOID *CommBuffer,
-  IN OUT UINTN*CommSize OPTIONAL
+MmCommunication2Communicate (
+  IN CONST EFI_MM_COMMUNICATION2_PROTOCOL   *This,
+  IN OUT VOID   *CommBufferPhysical,
+  IN OUT VOID   *CommBufferVirtual,
+  IN OUT UINTN  *CommSize OPTIONAL
   )
 {
   EFI_MM_COMMUNICATE_HEADER   *CommunicateHeader;
@@ -87,11 +82,11 @@ MmCommunicationCommunicate (
   //
   // Check parameters
   //
-  if 

[edk2-devel] [PATCH resend 6/7] MdeModulePkg/VariableSmmRuntimeDxe: switch to MM communicate 2

2020-05-06 Thread Ard Biesheuvel
Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Include/Guid/SmmVariableCommon.h|  6 +--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c   | 39 
+++-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf |  4 +-
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/MdeModulePkg/Include/Guid/SmmVariableCommon.h 
b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
index ceef44dfd2d7..8ddc94b92da6 100644
--- a/MdeModulePkg/Include/Guid/SmmVariableCommon.h
+++ b/MdeModulePkg/Include/Guid/SmmVariableCommon.h
@@ -20,7 +20,7 @@ extern EFI_GUID gSmmVariableWriteGuid;
 //
 // This structure is used for SMM variable. the collected statistics data is 
saved in SMRAM. It can be got from
 // SMI handler. The communication buffer should be:
-// EFI_SMM_COMMUNICATE_HEADER + SMM_VARIABLE_COMMUNICATE_HEADER + payload.
+// EFI_MM_COMMUNICATE_HEADER + SMM_VARIABLE_COMMUNICATE_HEADER + payload.
 //
 typedef struct {
   UINTN   Function;
@@ -53,7 +53,7 @@ typedef struct {
 //
 #define SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE   6
 //
-// The payload for this function is VARIABLE_INFO_ENTRY. The GUID in 
EFI_SMM_COMMUNICATE_HEADER
+// The payload for this function is VARIABLE_INFO_ENTRY. The GUID in 
EFI_MM_COMMUNICATE_HEADER
 // is gEfiSmmVariableProtocolGuid.
 //
 #define SMM_VARIABLE_FUNCTION_GET_STATISTICS  7
@@ -81,7 +81,7 @@ typedef struct {
 ///
 /// Size of SMM communicate header, without including the payload.
 ///
-#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, 
Data))
+#define SMM_COMMUNICATE_HEADER_SIZE  (OFFSET_OF (EFI_MM_COMMUNICATE_HEADER, 
Data))
 
 ///
 /// Size of SMM variable communicate header, without including the payload.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
index ca833fb0244d..663a1aaa128f 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.c
@@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
@@ -45,7 +45,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 EFI_HANDLE   mHandle= NULL;
 EFI_SMM_VARIABLE_PROTOCOL   *mSmmVariable   = NULL;
 EFI_EVENTmVirtualAddressChangeEvent = NULL;
-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication  = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2  = NULL;
 UINT8   *mVariableBuffer= NULL;
 UINT8   *mVariableBufferPhysical= NULL;
 VARIABLE_INFO_ENTRY *mVariableInfo  = NULL;
@@ -210,7 +210,7 @@ InitCommunicateBuffer (
   IN  UINTN Function
   )
 {
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER   *SmmVariableFunctionHeader;
 
 
@@ -218,7 +218,7 @@ InitCommunicateBuffer (
 return EFI_INVALID_PARAMETER;
   }
 
-  SmmCommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer;
+  SmmCommunicateHeader = (EFI_MM_COMMUNICATE_HEADER *) mVariableBuffer;
   CopyGuid (>HeaderGuid, );
   SmmCommunicateHeader->MessageLength = DataSize + 
SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
 
@@ -248,14 +248,17 @@ SendCommunicateBuffer (
 {
   EFI_STATUSStatus;
   UINTN CommSize;
-  EFI_SMM_COMMUNICATE_HEADER*SmmCommunicateHeader;
+  EFI_MM_COMMUNICATE_HEADER *SmmCommunicateHeader;
   SMM_VARIABLE_COMMUNICATE_HEADER   *SmmVariableFunctionHeader;
 
   CommSize = DataSize + SMM_COMMUNICATE_HEADER_SIZE + 
SMM_VARIABLE_COMMUNICATE_HEADER_SIZE;
-  Status = mSmmCommunication->Communicate (mSmmCommunication, 
mVariableBufferPhysical, );
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+   mVariableBufferPhysical,
+   mVariableBuffer,
+   );
   ASSERT_EFI_ERROR (Status);
 
-  SmmCommunicateHeader  = (EFI_SMM_COMMUNICATE_HEADER *) mVariableBuffer;
+  SmmCommunicateHeader  = (EFI_MM_COMMUNICATE_HEADER *) mVariableBuffer;
   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER 
*)SmmCommunicateHeader->Data;
   return  SmmVariableFunctionHeader->ReturnStatus;
 }
@@ -1309,7 +1312,7 @@ VariableAddressChangeEvent (
   )
 {
   EfiConvertPointer (0x0, (VOID **) );
-  EfiConvertPointer (0x0, (VOID **) );
+  EfiConvertPointer (0x0, (VOID **) );
   EfiConvertPointer 

[edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol

2020-05-06 Thread Ard Biesheuvel
Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Application/VariableInfo/VariableInfo.c   | 19 +++
 MdeModulePkg/Application/VariableInfo/VariableInfo.inf |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.c 
b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
index c04ba182132f..a7df365b5895 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.c
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
@@ -20,10 +20,10 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 
-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2 = NULL;
 
 /**
   This function get the variable statistics data from SMM variable driver.
@@ -41,7 +41,7 @@ EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
 EFI_STATUS
 EFIAPI
 GetVariableStatisticsData (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER  *SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER   *SmmCommunicateHeader,
   IN OUT  UINTN   *SmmCommunicateSize
   )
 {
@@ -49,12 +49,15 @@ GetVariableStatisticsData (
   SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;
 
   CopyGuid (>HeaderGuid, );
-  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF 
(EFI_SMM_COMMUNICATE_HEADER, Data);
+  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF 
(EFI_MM_COMMUNICATE_HEADER, Data);
 
   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) 
>Data[0];
   SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_STATISTICS;
 
-  Status = mSmmCommunication->Communicate (mSmmCommunication, 
SmmCommunicateHeader, SmmCommunicateSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+   SmmCommunicateHeader,
+   SmmCommunicateHeader,
+   SmmCommunicateSize);
   ASSERT_EFI_ERROR (Status);
 
   Status = SmmVariableFunctionHeader->ReturnStatus;
@@ -76,7 +79,7 @@ PrintInfoFromSmm (
 {
   EFI_STATUS Status;
   VARIABLE_INFO_ENTRY*VariableInfo;
-  EFI_SMM_COMMUNICATE_HEADER *CommBuffer;
+  EFI_MM_COMMUNICATE_HEADER  *CommBuffer;
   UINTN  RealCommSize;
   UINTN  CommSize;
   SMM_VARIABLE_COMMUNICATE_HEADER*FunctionHeader;
@@ -92,7 +95,7 @@ PrintInfoFromSmm (
 return Status;
   }
 
-  Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
+  Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
   if (EFI_ERROR (Status)) {
 return Status;
   }
@@ -117,7 +120,7 @@ PrintInfoFromSmm (
 if (Size > MaxSize) {
   MaxSize = Size;
   RealCommSize = MaxSize;
-  CommBuffer = (EFI_SMM_COMMUNICATE_HEADER *) (UINTN) 
Entry->PhysicalStart;
+  CommBuffer = (EFI_MM_COMMUNICATE_HEADER *) (UINTN) 
Entry->PhysicalStart;
 }
   }
 }
diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf 
b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
index 0706ea2ead59..f7c533b54641 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
@@ -41,7 +41,7 @@ [LibraryClasses]
   MemoryAllocationLib
 
 [Protocols]
-  gEfiSmmCommunicationProtocolGuid   ## SOMETIMES_CONSUMES
+  gEfiMmCommunication2ProtocolGuid   ## SOMETIMES_CONSUMES
 
   ## UNDEFINED# Used to do smm communication
   ## SOMETIMES_CONSUMES
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58730): https://edk2.groups.io/g/devel/message/58730
Mute This Topic: https://groups.io/mt/74033571/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH resend 7/7] StandaloneMmPkg: switch to MM communicate 2 protocol

2020-05-06 Thread Ard Biesheuvel
Update the reference to MM communicate to refer to the MM communicate 2
protocol instead. This makes no difference for the MM side of the
implementation, but is more accurate nonetheless, since the original MM
protocol does not work in combination with standalone MM.

Signed-off-by: Ard Biesheuvel 
---
 StandaloneMmPkg/Core/StandaloneMmCore.h   | 2 +-
 StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h 
b/StandaloneMmPkg/Core/StandaloneMmCore.h
index 86f6cfa55a35..96c195311add 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.h
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.h
@@ -18,7 +18,7 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
 #include 
 
diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h 
b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
index 71be5cf17272..47a020c27b95 100644
--- a/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
+++ b/StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/StandaloneMmCpu.h
@@ -10,7 +10,7 @@
 #ifndef _ARM_TF_CPU_DRIVER_H_
 #define _ARM_TF_CPU_DRIVER_H_
 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58733): https://edk2.groups.io/g/devel/message/58733
Mute This Topic: https://groups.io/mt/74033577/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [EXTERNAL] [edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: switch to MM communicate 2 protocol

2020-05-06 Thread Bret Barkelew via groups.io
Note that the VariablePolicy code that is still out for review also uses Mm 
communication and would need to be updated if it lands first.

- Bret

From: Ard Biesheuvel via groups.io
Sent: Wednesday, May 6, 2020 10:28 AM
To: devel@edk2.groups.io
Cc: Ard Biesheuvel; Kinney, Michael 
D; Liming Gao; 
Jian J Wang; Hao A Wu; 
Leif Lindholm; Sami 
Mujawar; Yao, Jiewen
Subject: [EXTERNAL] [edk2-devel] [PATCH resend 4/7] MdeModulePkg/VariableInfo: 
switch to MM communicate 2 protocol

Switch to the new MM communicate 2 protocol which supports both
traditional and standalone MM.

Signed-off-by: Ard Biesheuvel 
---
 MdeModulePkg/Application/VariableInfo/VariableInfo.c   | 19 +++
 MdeModulePkg/Application/VariableInfo/VariableInfo.inf |  2 +-
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.c 
b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
index c04ba182132f..a7df365b5895 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.c
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.c
@@ -20,10 +20,10 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 

-EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
+EFI_MM_COMMUNICATION2_PROTOCOL  *mMmCommunication2 = NULL;

 /**
   This function get the variable statistics data from SMM variable driver.
@@ -41,7 +41,7 @@ EFI_SMM_COMMUNICATION_PROTOCOL  *mSmmCommunication = NULL;
 EFI_STATUS
 EFIAPI
 GetVariableStatisticsData (
-  IN OUT  EFI_SMM_COMMUNICATE_HEADER  *SmmCommunicateHeader,
+  IN OUT  EFI_MM_COMMUNICATE_HEADER   *SmmCommunicateHeader,
   IN OUT  UINTN   *SmmCommunicateSize
   )
 {
@@ -49,12 +49,15 @@ GetVariableStatisticsData (
   SMM_VARIABLE_COMMUNICATE_HEADER *SmmVariableFunctionHeader;

   CopyGuid (>HeaderGuid, );
-  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF 
(EFI_SMM_COMMUNICATE_HEADER, Data);
+  SmmCommunicateHeader->MessageLength = *SmmCommunicateSize - OFFSET_OF 
(EFI_MM_COMMUNICATE_HEADER, Data);

   SmmVariableFunctionHeader = (SMM_VARIABLE_COMMUNICATE_HEADER *) 
>Data[0];
   SmmVariableFunctionHeader->Function = SMM_VARIABLE_FUNCTION_GET_STATISTICS;

-  Status = mSmmCommunication->Communicate (mSmmCommunication, 
SmmCommunicateHeader, SmmCommunicateSize);
+  Status = mMmCommunication2->Communicate (mMmCommunication2,
+   SmmCommunicateHeader,
+   SmmCommunicateHeader,
+   SmmCommunicateSize);
   ASSERT_EFI_ERROR (Status);

   Status = SmmVariableFunctionHeader->ReturnStatus;
@@ -76,7 +79,7 @@ PrintInfoFromSmm (
 {
   EFI_STATUS Status;
   VARIABLE_INFO_ENTRY*VariableInfo;
-  EFI_SMM_COMMUNICATE_HEADER *CommBuffer;
+  EFI_MM_COMMUNICATE_HEADER  *CommBuffer;
   UINTN  RealCommSize;
   UINTN  CommSize;
   SMM_VARIABLE_COMMUNICATE_HEADER*FunctionHeader;
@@ -92,7 +95,7 @@ PrintInfoFromSmm (
 return Status;
   }

-  Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
+  Status = gBS->LocateProtocol (, NULL, (VOID 
**) );
   if (EFI_ERROR (Status)) {
 return Status;
   }
@@ -117,7 +120,7 @@ PrintInfoFromSmm (
 if (Size > MaxSize) {
   MaxSize = Size;
   RealCommSize = MaxSize;
-  CommBuffer = (EFI_SMM_COMMUNICATE_HEADER *) (UINTN) 
Entry->PhysicalStart;
+  CommBuffer = (EFI_MM_COMMUNICATE_HEADER *) (UINTN) 
Entry->PhysicalStart;
 }
   }
 }
diff --git a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf 
b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
index 0706ea2ead59..f7c533b54641 100644
--- a/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
+++ b/MdeModulePkg/Application/VariableInfo/VariableInfo.inf
@@ -41,7 +41,7 @@ [LibraryClasses]
   MemoryAllocationLib

 [Protocols]
-  gEfiSmmCommunicationProtocolGuid   ## SOMETIMES_CONSUMES
+  gEfiMmCommunication2ProtocolGuid   ## SOMETIMES_CONSUMES

   ## UNDEFINED# Used to do smm communication
   ## SOMETIMES_CONSUMES
--
2.17.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58734): https://edk2.groups.io/g/devel/message/58734
Mute This Topic: https://groups.io/mt/74034122/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 1/3] UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific

2020-05-06 Thread Lendacky, Thomas
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340

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 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Signed-off-by: Tom Lendacky 
---
 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
   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 ..3ed1378d6fa6
--- /dev/null
+++ 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
@@ -0,0 +1,54 @@
+## @file
+#  

[edk2-devel] [PATCH v2 0/3] XCODE5 toolchain binary patching fix

2020-05-06 Thread Lendacky, Thomas


BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340

Commit 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass
XCODE5 tool chain") introduced binary patching in the
ExceptionHandlerAsm.nasm in order to support the XCODE5 toolchain.
However, the CpuExceptionHandlerLib can be used during SEC phase which
would result in binary patching of flash.

This series creates a new CpuExceptionHandlerLib file to support
the required binary patching for the XCODE5 toolchain, while reverting
the changes from commit 2db0ccc2d7fe in the standard file. As the Pei,
Dxe and SMM versions of the library operate in memory (as opposed to
flash), only the SEC/PEI version is of the library is updated to use the
version of the ExceptionHandlerAsm.nasm that does not perform binary
patching.

This is accomplished in phases:
  - Create a new XCODE5 specific version of the ExceptionHandlerAsm.nasm
file and update all CpuExceptionHandler INF files to use it while also
creating a new SEC/PEI CpuExceptionHandler INF file specifically for
the XCODE5 toolchain.
  - Update all package DSC files that use the SecPeiCpuExceptionHandlerLib
version of the library to use the XCODE5 version of the library,
Xcode5SecPeiCpuExceptionHandlerLib, when the XCODE5 toolchain is used.
  - Revert the changes made by commit 2db0ccc2d7fe in the standard file
and update the SecPeiCpuExceptionHandlerLib.inf file to use the
standard file.

I don't have access to an XCODE5 toolchain setup, so I have not tested
this with XCODE5. I would like to request that someone who does please
test this.

Also, will this change have an impact on any of the platform builds
outside of this tree? In other words, should the new INF be the one that
uses the reverted ExceptionHandlerAsm.nasm file and it be called something
like BaseSecPeiCpuExceptionHandlerLib.inf?

---

These patches are based on commit:
befd18fca68b ("EmbeddedPkg/EmbeddedPkg.dsc: remove some stale component 
references")

Cc: Andrew Fish 
Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Eric Dong 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Cc: Ray Ni 

Changes since v1:
- Only apply the revert to the Sec/Pei CpuExceptionHandler library and
  leave the Pei, Dxe and Smm versions using the binary patching version.
- Generate a unique file GUID for the new library INF file and create
  a corresponding UNI file.
- Remove any references to SEV-ES (original patches accidentally submitted
  from wrong tree).

Tom Lendacky (3):
  UefiCpuPkg/CpuExceptionHandler: Make XCODE5 changes toolchain specific
  OvmfPkg: Use toolchain appropriate CpuExceptionHandlerLib
  UefiCpuPkg/CpuExceptionHandler: Revert CpuExceptionHandler binary
patching

 OvmfPkg/OvmfPkgIa32.dsc   |   4 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   4 +
 OvmfPkg/OvmfPkgX64.dsc|   4 +
 OvmfPkg/OvmfXen.dsc   |   4 +
 UefiCpuPkg/UefiCpuPkg.dsc |   5 +
 .../DxeCpuExceptionHandlerLib.inf |   2 +-
 .../PeiCpuExceptionHandlerLib.inf |   2 +-
 .../SmmCpuExceptionHandlerLib.inf |   2 +-
 .../Xcode5SecPeiCpuExceptionHandlerLib.inf|  54 +++
 .../X64/ExceptionHandlerAsm.nasm  |  25 +-
 .../X64/Xcode5ExceptionHandlerAsm.nasm| 396 ++
 .../Xcode5SecPeiCpuExceptionHandlerLib.uni|  17 +
 12 files changed, 497 insertions(+), 22 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

-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58719): https://edk2.groups.io/g/devel/message/58719
Mute This Topic: https://groups.io/mt/74032330/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 3/3] UefiCpuPkg/CpuExceptionHandler: Revert CpuExceptionHandler binary patching

2020-05-06 Thread Lendacky, Thomas
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340

Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
revert the changes made to the ExceptionHandlerAsm.nasm in commit
2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5 tool
chain") so that binary patching of flash code is not performed.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Liming Gao 
Signed-off-by: Tom Lendacky 
---
 .../X64/ExceptionHandlerAsm.nasm  | 25 +--
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git 
a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm 
b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
index 19198f273137..3814f9de3703 100644
--- a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
+++ b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
@@ -34,7 +34,7 @@ AsmIdtVectorBegin:
 db  0x6a; push  #VectorNum
 db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd - AsmIdtVectorBegin) / 
32) ; VectorNum
 pushrax
-mov rax, strict qword 0 ;mov rax, ASM_PFX(CommonInterruptEntry)
+mov rax, ASM_PFX(CommonInterruptEntry)
 jmp rax
 %endrep
 AsmIdtVectorEnd:
@@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
 @VectorNum:
 db  0  ; 0 will be fixed
 pushrax
-mov rax, strict qword 0 ; mov rax, HookAfterStubHeaderEnd
-JmpAbsoluteAddress:
+mov rax, HookAfterStubHeaderEnd
 jmp rax
 HookAfterStubHeaderEnd:
 mov rax, rsp
@@ -257,7 +256,8 @@ HasErrorCode:
 ; and make sure RSP is 16-byte aligned
 ;
 sub rsp, 4 * 8 + 8
-callASM_PFX(CommonExceptionHandler)
+mov rax, ASM_PFX(CommonExceptionHandler)
+callrax
 add rsp, 4 * 8 + 8
 
 cli
@@ -365,24 +365,11 @@ DoIret:
 ; comments here for definition of address map
 global ASM_PFX(AsmGetTemplateAddressMap)
 ASM_PFX(AsmGetTemplateAddressMap):
-lea rax, [AsmIdtVectorBegin]
+mov rax, AsmIdtVectorBegin
 mov qword [rcx], rax
 mov qword [rcx + 0x8],  (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-lea rax, [HookAfterStubHeaderBegin]
+mov rax, HookAfterStubHeaderBegin
 mov qword [rcx + 0x10], rax
-
-; Fix up CommonInterruptEntry address
-learax, [ASM_PFX(CommonInterruptEntry)]
-learcx, [AsmIdtVectorBegin]
-%rep  32
-movqword [rcx + (JmpAbsoluteAddress - 8 - HookAfterStubHeaderBegin)], 
rax
-addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
-%endrep
-; Fix up HookAfterStubHeaderEnd
-learax, [HookAfterStubHeaderEnd]
-learcx, [JmpAbsoluteAddress]
-movqword [rcx - 8], rax
-
 ret
 
 
;-
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58722): https://edk2.groups.io/g/devel/message/58722
Mute This Topic: https://groups.io/mt/74032334/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v2 2/3] OvmfPkg: Use toolchain appropriate CpuExceptionHandlerLib

2020-05-06 Thread Lendacky, Thomas
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2340

During the SEC phase, use the XCODE5 CpuExceptionHandlerLib library in
place of the standard library when building with the XCODE5 toolchain.
The SEC XCODE5 version of the library performs binary patching and should
only be used when building with the XCODE5 toolchain.

Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Anthony Perard 
Cc: Julien Grall 
Cc: Liming Gao 
Signed-off-by: Tom Lendacky 
---
 OvmfPkg/OvmfPkgIa32.dsc| 4 
 OvmfPkg/OvmfPkgIa32X64.dsc | 4 
 OvmfPkg/OvmfPkgX64.dsc | 4 
 OvmfPkg/OvmfXen.dsc| 4 
 4 files changed, 16 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 7c8b51f43b66..41ac3202961b 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -246,7 +246,11 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+!if $(TOOL_CHAIN_TAG) == "XCODE5"
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+!endif
 
 [LibraryClasses.common.PEI_CORE]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a0596c44168c..c2f11aee2cec 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -250,7 +250,11 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+!if $(TOOL_CHAIN_TAG) == "XCODE5"
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+!endif
 
 [LibraryClasses.common.PEI_CORE]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 2e764b6b7233..643e6041ad53 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -250,7 +250,11 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+!if $(TOOL_CHAIN_TAG) == "XCODE5"
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+!endif
 
 [LibraryClasses.common.PEI_CORE]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
diff --git a/OvmfPkg/OvmfXen.dsc b/OvmfPkg/OvmfXen.dsc
index 8b3615e0b07e..143dc6d5a766 100644
--- a/OvmfPkg/OvmfXen.dsc
+++ b/OvmfPkg/OvmfXen.dsc
@@ -228,7 +228,11 @@ [LibraryClasses.common.SEC]
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLibIdt/PeiServicesTablePointerLibIdt.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
+!if $(TOOL_CHAIN_TAG) == "XCODE5"
+  
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/Xcode5SecPeiCpuExceptionHandlerLib.inf
+!else
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
+!endif
 
 [LibraryClasses.common.PEI_CORE]
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58721): https://edk2.groups.io/g/devel/message/58721
Mute This Topic: https://groups.io/mt/74032333/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard CpuExceptionHandlerLib

2020-05-06 Thread Laszlo Ersek
On 05/06/20 16:35, Tom Lendacky wrote:
> On 5/5/20 5:15 PM, Laszlo Ersek via groups.io wrote:
>> On 05/01/20 22:17, Lendacky, Thomas wrote:
>>> BZ:
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340data=02%7C01%7Cthomas.lendacky%40amd.com%7Cd2ec699d2c644a55724008d7f141d96f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243137431443098sdata=oTTju7144KZc8VCmQqu74UilIOzQyji9jlO%2BMJeZYyU%3Dreserved=0
>>>
>>>
>>> Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
>>> revert the changes made to the ExceptionHandlerAsm.nasm in commit
>>> 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5
>>> tool
>>> chain") so that binary patching of flash code is not performed.
>>>
>>> Cc: Eric Dong 
>>> Cc: Ray Ni 
>>> Cc: Laszlo Ersek 
>>> Cc: Liming Gao 
>>> Signed-off-by: Tom Lendacky 
>>> ---
>>>   .../X64/ExceptionHandlerAsm.nasm  | 25 +--
>>>   1 file changed, 6 insertions(+), 19 deletions(-)
>>>
>>> diff --git
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> index 19198f273137..3814f9de3703 100644
>>> ---
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> +++
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> @@ -34,7 +34,7 @@ AsmIdtVectorBegin:
>>>   db  0x6a    ; push  #VectorNum
>>>   db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd -
>>> AsmIdtVectorBegin) / 32) ; VectorNum
>>>   push    rax
>>> -    mov rax, strict qword 0 ;    mov rax,
>>> ASM_PFX(CommonInterruptEntry)
>>> +    mov rax, ASM_PFX(CommonInterruptEntry)
>>>   jmp rax
>>>   %endrep
>>>   AsmIdtVectorEnd:
>>> @@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
>>>   @VectorNum:
>>>   db  0  ; 0 will be fixed
>>>   push    rax
>>> -    mov rax, strict qword 0 ; mov rax,
>>> HookAfterStubHeaderEnd
>>> -JmpAbsoluteAddress:
>>> +    mov rax, HookAfterStubHeaderEnd
>>>   jmp rax
>>>   HookAfterStubHeaderEnd:
>>>   mov rax, rsp
>>> @@ -257,7 +256,8 @@ HasErrorCode:
>>>   ; and make sure RSP is 16-byte aligned
>>>   ;
>>>   sub rsp, 4 * 8 + 8
>>> -    call    ASM_PFX(CommonExceptionHandler)
>>> +    mov rax, ASM_PFX(CommonExceptionHandler)
>>> +    call    rax
>>>   add rsp, 4 * 8 + 8
>>>
>>>   cli
>>> @@ -365,24 +365,11 @@ DoIret:
>>>   ; comments here for definition of address map
>>>   global ASM_PFX(AsmGetTemplateAddressMap)
>>>   ASM_PFX(AsmGetTemplateAddressMap):
>>> -    lea rax, [AsmIdtVectorBegin]
>>> +    mov rax, AsmIdtVectorBegin
>>>   mov qword [rcx], rax
>>>   mov qword [rcx + 0x8],  (AsmIdtVectorEnd -
>>> AsmIdtVectorBegin) / 32
>>> -    lea rax, [HookAfterStubHeaderBegin]
>>> +    mov rax, HookAfterStubHeaderBegin
>>>   mov qword [rcx + 0x10], rax
>>> -
>>> -; Fix up CommonInterruptEntry address
>>> -    lea    rax, [ASM_PFX(CommonInterruptEntry)]
>>> -    lea    rcx, [AsmIdtVectorBegin]
>>> -%rep  32
>>> -    mov    qword [rcx + (JmpAbsoluteAddress - 8 -
>>> HookAfterStubHeaderBegin)], rax
>>> -    add    rcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32
>>> -%endrep
>>> -; Fix up HookAfterStubHeaderEnd
>>> -    lea    rax, [HookAfterStubHeaderEnd]
>>> -    lea    rcx, [JmpAbsoluteAddress]
>>> -    mov    qword [rcx - 8], rax
>>> -
>>>   ret
>>>
>>>  
>>> ;-
>>>
>>>
>>
>> With this patch applied, the differences with the "original" remain:
>>
>> $ git diff 2db0ccc2d7fe^..HEAD -- \
>>   
>> UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>
>>> diff --git
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> index ba8993d84b0b..3814f9de3703 100644
>>> ---
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> +++
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> @@ -1,12 +1,6 @@
>>>  
>>> ;--
>>> ;
>>> -; Copyright (c) 2012 - 2014, Intel Corporation. All rights
>>> reserved.
>>> -; This program and the accompanying materials
>>> -; are licensed and made available under the terms and conditions of
>>> the BSD License
>>> -; which accompanies this distribution.  The full text of the license
>>> may be found at
>>> -;
>>> https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fopensource.org%2Flicenses%2Fbsd-license.phpdata=02%7C01%7Cthomas.lendacky%40amd.com%7Cd2ec699d2c644a55724008d7f141d96f%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637243137431443098sdata=SZAc83Y%2BwZauGcj47EDgc10fnxSucy2ljeI9PcaJSvE%3Dreserved=0.
>>>
>>> -;
>>> -; 

Re: [edk2-devel] [PATCH edk2-platforms 0/5] Platform/RaspberryPi: fix serialportlib dependency hell

2020-05-06 Thread Ard Biesheuvel

On 5/5/20 4:50 PM, Ard Biesheuvel wrote:

This proposes an alternative approach to the issue described in
https://github.com/raspberrypi/firmware/issues/1376.

Instead of fiddling with HobLib internals and relying on headers being
included in the correct order, this replaces all DEBUG uses of SerialPortLib
with an implementation that doesn't reprogram the UART at all (and so does
not need to know the value of the base clock), and updates the two remaining
users to query the firmware for the correct value before touching the h/w.

NOTE: build tested only.

Ard Biesheuvel (5):
   Platform/RaspberryPi/DualSerialPortLib: split up to ease reuse
   Platform/RaspberryPi: introduce DebugDualSerialPortLib
   Platform/RaspberryPi: fix 16550 divisor calculation logic
   Platform/RaspberryPi3: query firmware for 16550 input clock at boot
   Platform/RaspberryPi: create DXE phase SerialPortLib version for RPi3



I have pushed this as 11189124fbc2..644e223bb371 with Pete's ack, after 
making the changes as discussed in the individual replies.



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58717): https://edk2.groups.io/g/devel/message/58717
Mute This Topic: https://groups.io/mt/73999452/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platforms][PATCH 1/1] RPi: allow selecting which system config tables are exposed

2020-05-06 Thread Andrei Warkentin
Ok that sounds reasonable to me. I'll remove the "both" option entirely.

A

From: devel@edk2.groups.io  on behalf of Ard Biesheuvel 
via groups.io 
Sent: Wednesday, May 6, 2020 1:38 AM
To: Andrei Warkentin ; devel@edk2.groups.io 

Cc: l...@nuviainc.com ; p...@akeo.ie ; 
phi...@redhat.com 
Subject: Re: [edk2-devel] [edk2-platforms][PATCH 1/1] RPi: allow selecting 
which system config tables are exposed

On 5/6/20 2:59 AM, Andrei Warkentin wrote:
> Today we just have an option to hide DT entirely, while ACPI
> is always exposed. This change extends the option to
> provide all three choices:
> - ACPI only
> - ACPI + DT
> - DT only
>
> Why? Because not all OSes will prefer DT over ACPI when both are available.
>
> To do this cleanly, move the variable structure and value definitions
> into a separate header, ConfigVars.h.
>
> Signed-off-by: Andrei Warkentin 

I'd prefer it if DT and ACPI were mutually exclusive, so that it is
never left up to the OS to reason about which one is the correct one.

This aligns with other platforms we have in the tree.

> ---
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c  |  20 +--
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf|   2 +-
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni |   9 +-
>   Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr | 146 
> ++--
>   Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.c|   6 +-
>   Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf  |   2 +-
>   Platform/RaspberryPi/Include/ConfigVars.h   | 131 
> ++
>   Platform/RaspberryPi/RPi3/RPi3.dsc  |   4 +-
>   Platform/RaspberryPi/RPi4/RPi4.dsc  |   4 +-
>   Platform/RaspberryPi/RaspberryPi.dec|   2 +-
>   10 files changed, 171 insertions(+), 155 deletions(-)
>
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c 
> b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> index c90c2530..00867879 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
> @@ -22,6 +22,7 @@
>   #include 
>   #include 
>   #include 
> +#include 
>   #include "ConfigDxeFormSetGuid.h"
>
>   #define FREQ_1_MHZ 100
> @@ -154,11 +155,11 @@ SetupVariables (
> }
>
> Size = sizeof (UINT32);
> -  Status = gRT->GetVariable (L"OptDeviceTree",
> +  Status = gRT->GetVariable (L"SystemTableMode",
> ,
> NULL, , );
> if (EFI_ERROR (Status)) {
> -PcdSet32 (PcdOptDeviceTree, PcdGet32 (PcdOptDeviceTree));
> +PcdSet32 (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
> }
>
> Size = sizeof (UINT32);
> @@ -259,10 +260,10 @@ ApplyVariables (
> UINT64 SystemMemorySize;
>
> switch (CpuClock) {
> -  case 0: // Low
> +  case CHIPSET_CPU_CLOCK_LOW:
>   Rate = FixedPcdGet32 (PcdCpuLowSpeedMHz) * FREQ_1_MHZ;
>   break;
> -  case 1: // Default
> +  case CHIPSET_CPU_CLOCK_DEFAULT:
>   /*
>* What the Raspberry Pi Foundation calls "max clock rate" is really 
> the default value
>* from: 
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.raspberrypi.org%2Fdocumentation%2Fconfiguration%2Fconfig-txt%2Foverclocking.mddata=02%7C01%7Cawarkentin%40vmware.com%7Cc02f0ea3653949b6847c08d7f1882716%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C637243439445722301sdata=BQl1mDfJ3Yt6YB%2FQGs6z6DoQ%2BQEiuGTuBAhIvsYrZ0w%3Dreserved=0
> @@ -272,10 +273,10 @@ ApplyVariables (
> DEBUG ((DEBUG_ERROR, "Couldn't read default CPU speed %r\n", Status));
>   }
>   break;
> -  case 2: // Max
> +  case CHIPSET_CPU_CLOCK_MAX:
>   Rate = FixedPcdGet32 (PcdCpuMaxSpeedMHz) * FREQ_1_MHZ;
>   break;
> -  case 3: // Custom
> +  case CHIPSET_CPU_CLOCK_CUSTOM:
>   Rate = CustomCpuClock * FREQ_1_MHZ;
>   break;
> }
> @@ -487,8 +488,11 @@ ConfigInitialize (
>   DEBUG ((DEBUG_ERROR, "Couldn't install ConfigDxe configuration pages: 
> %r\n", Status));
> }
>
> -  Status = LocateAndInstallAcpiFromFv ();
> -  ASSERT_EFI_ERROR (Status);
> +  if (PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_ACPI ||
> +  PcdGet32 (PcdSystemTableMode) == SYSTEM_TABLE_MODE_BOTH) {
> + Status = LocateAndInstallAcpiFromFv ();
> + ASSERT_EFI_ERROR (Status);
> +  }
>
> return EFI_SUCCESS;
>   }
> diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf 
> b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> index 57963baf..e47f3af6 100644
> --- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> +++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
> @@ -77,7 +77,7 @@
> gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
> gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
> gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
> -  gRaspberryPiTokenSpaceGuid.PcdOptDeviceTree
> +  gRaspberryPiTokenSpaceGuid.PcdSystemTableMode
>   

Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to be used in support of SEV-ES

2020-05-06 Thread Dong, Eric
Hi Tom,

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> Lendacky, Thomas
> Sent: Wednesday, May 6, 2020 9:20 PM
> To: Dong, Eric ; devel@edk2.groups.io;
> ler...@redhat.com
> Cc: Justen, Jordan L ; Ard Biesheuvel
> ; Kinney, Michael D
> ; Gao, Liming ; Ni, Ray
> ; Brijesh Singh ; Wang, Jian J
> ; Wu, Hao A 
> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs to
> be used in support of SEV-ES
> 
> On 5/5/20 8:53 PM, Dong, Eric wrote:
> >
> >
> >> -Original Message-
> >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> >> Laszlo Ersek
> >> Sent: Tuesday, May 5, 2020 11:30 PM
> >> To: Tom Lendacky ; Dong, Eric
> >> ; devel@edk2.groups.io
> >> Cc: Justen, Jordan L ; Ard Biesheuvel
> >> ; Kinney, Michael D
> >> ; Gao, Liming ; Ni,
> >> Ray ; Brijesh Singh ; Wang,
> >> Jian J ; Wu, Hao A 
> >> Subject: Re: [edk2-devel] [PATCH v7 01/43] MdeModulePkg: Create PCDs
> >> to be used in support of SEV-ES
> >>
> >> On 05/04/20 18:41, Tom Lendacky wrote:
> >>
> >>> Is there an easy way to run everything that this link points, too?
> >>> Is it just creating a pull request that does this? I don't want to
> >>> take up a lot of your time, so if there's some documentation on how
> >>> to run an integration test to find and fix issues like this, just point 
> >>> me to it.
> >>
> >> Just create a pull request; it will set off CI, and you can review VS
> >> build errors there (if any).
> >>
> >> Your PR will automatically be closed (rejected) regardless of whether
> >> CI succeeds or not. PRs are merged -- in fact, *auto*-merged, by the
> >> "mergify bot" -- if and only if (a) the CI run succeeds, and (b) the PR has
> the "push"
> >> label set.
> >>
> >> And only edk2 maintainers have permission to set the "push" label.
> >> Any PR without the "push" label qualifies as a "personal test build".
> >> So you can freely experiment with PRs, because you can't (even
> >> unwittingly) satisfy condition (b).
> >>
> >>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
> >> hub.com%2Ftianocore%2Ftianocore.github.io%2Fwiki%2FEDK-II-
> Development
> >> -
> data=02%7C01%7Cthomas.lendacky%40amd.com%7C9cff3475aff84a9
> 57285
> >>
> 08d7f1604c99%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63724
> 326821
> >>
> 7382019sdata=3%2FIKB174QaVLaqO0u1gdrL0izXmhEZ%2Byvj3iC13UYB
> c%3D&
> >> amp;reserved=0
> >> Process
> >>
> >
> > Thanks Laszlo for your explanation.
> >
> > I found this patch serial is incompatible for the existed platforms.
> > Can you help to fix the build failure for these platforms in
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> > ub.com%2Ftianocore%2Fedk2-
> platformsdata=02%7C01%7Cthomas.lendacky
> > %40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd8961fe4884e6
> 08e11a8
> >
> 2d994e183d%7C0%7C0%7C637243268217382019sdata=jU0qrB%2BV6Z
> vFmPzjcx
> > Go9o2Pu1%2FrhRW0gUZTMv%2BiXDQ%3Dreserved=0
> >
> 
> I have fixed all of the build issues associated with the VS compiler using the
> pull request method that Laszlo mentioned. I then successfully built the RPi4
> platform under GCC (build -n 32 -a AARCH64 -t GCC5 -p
> Platform/RaspberryPi/RPi4/RPi4.dsc) using the AARCH64 cross compiler.
> 
> Is there a particular platform that experiences an issue or are the failures
> related to the VS compiler errors that my next series will have fixed?

I used the KabylakeRvp3 platform with your changes in Edk2 and met failures.  
KabylakeRvp3 code at Edk2-platforms\Platform\Intel\KabylakeOpenBoardPkg\

 I used below command to build the code.
C:\Code\OpenSource\edk2-platforms\Platform\Intel>build_bios.py --platform 
KabylakeRvp3

You need clone below repositories to build the code.
Edk2: g...@github.com:tianocore/edk2.git
Edk2-Platform g...@github.com:tianocore/edk2-platforms.git
edk2-non-osi :  g...@github.com:tianocore/edk2-non-osi.git
FSP: g...@github.com:IntelFsp/FSP.git

> 
> > I think you also needs to add an wiki page to explain what need to do if an
> platform needs to integrate your changes, also it's better to explain this
> feature in the page.
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2Ftianocore%2Ftianocore.github.io%2Fwikidata=02%7C01%7
> Ctho
> >
> mas.lendacky%40amd.com%7C9cff3475aff84a95728508d7f1604c99%7C3dd89
> 61fe4
> >
> 884e608e11a82d994e183d%7C0%7C0%7C637243268217382019sdata=x
> LkoV4zW
> > hxtsbqszqPc0lEAl%2BYLL%2B2wg1nIXql8a64E%3Dreserved=0
> 
> I don't see any platform other than OVMF using this feature as it is a
> virtualization feature. Having said that I can add an explanation of what is
> needed should another virtualization platform be created under EDK2 that
> wants to support SEV-ES. And, as you said, I can also explain the feature
> overall on the page.
> 

I think your page includes two parts, one is how to change the platform code to 
make the platform pass build, 
the other is if the platform needs to enable the virtualization 

Re: [edk2-devel] [PATCH 1/1] BaseTools: add repo name option to SetupGit.py

2020-05-06 Thread Laszlo Ersek
On 05/06/20 12:31, Leif Lindholm wrote:
> On Tue, May 05, 2020 at 17:40:35 +0200, Laszlo Ersek wrote:
>> CC Leif
>>
>> On 05/01/20 22:00, Rebecca Cran wrote:
>>> Allow users who didn't clone one of the TianoCore repos from a
>>> canonical URL to specify the name of the repo (edk2, edk2-platforms
>>> or edk2-non-osi) when running SetupGit.py to allow them to configure
>>> their repo properly.
>>>
>>> The new option is:
>>>
>>>   -n repo, --name repo  set the repo name to configure for, if not
>>> detected automatically
>>>
>>> Signed-off-by: Rebecca Cran 
>>> Cc: Bob Feng 
>>> Cc: Liming Gao 
> 
> I did consider this scenario when writing the code, but couldn't
> decide on a method for overriding, and wasn't 100% it wasn't just a
> theoretical issue. This solution looks sensible.
> Reviewed-by: Leif Lindholm 

Thanks!

Bob, Liming, can one of you please ACK and also merge this patch?

Thanks,
Laszlo

> 
> As a sidenote - now this exists, it could make sense to also add
> options for overriding 'list' and 'prefix'.
> 
> /
> Leif
> 
>>> ---
>>> Tested with:
>>>   pylama : no new issues detected
>>> Option tested:
>>>   -n : correctly said a parameter was needed
>>>   -n edk2 : configured the repo for edk2
>>>   -n edk2-foo : errored out with a list of repo names
>>>   -n edk2-platforms : updated the configuration for edk2-platforms
>>>
>>> Note the error block in __main__ if the upstream isn't found is
>>> redundant, since it already errors out and exits in get_upstream.
>>>
>>>  BaseTools/Scripts/SetupGit.py | 12 +---
>>>  1 file changed, 9 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/BaseTools/Scripts/SetupGit.py b/BaseTools/Scripts/SetupGit.py
>>> index e320ba2f887e..4416111ac0a5 100644
>>> --- a/BaseTools/Scripts/SetupGit.py
>>> +++ b/BaseTools/Scripts/SetupGit.py
>>> @@ -106,10 +106,11 @@ def fuzzy_match_repo_url(one, other):
>>>  return False
>>>  
>>>  
>>> -def get_upstream(url):
>>> +def get_upstream(url, name):
>>>  """Extracts the dict for the current repo origin."""
>>>  for upstream in UPSTREAMS:
>>> -if fuzzy_match_repo_url(upstream['repo'], url):
>>> +if (fuzzy_match_repo_url(upstream['repo'], url) or
>>> +upstream['name'] == name):
>>>  return upstream
>>>  print("Unknown upstream '%s' - aborting!" % url)
>>>  sys.exit(3)
>>> @@ -143,6 +144,11 @@ if __name__ == '__main__':
>>>  help='overwrite existing settings conflicting with 
>>> program defaults',
>>>  action='store_true',
>>>  required=False)
>>> +PARSER.add_argument('-n', '--name', type=str, metavar='repo',
>>> +choices=['edk2', 'edk2-platforms', 'edk2-non-osi'],
>>> +help='set the repo name to configure for, if not '
>>> + 'detected automatically',
>>> +required=False)
>>>  PARSER.add_argument('-v', '--verbose',
>>>  help='enable more detailed output',
>>>  action='store_true',
>>> @@ -156,7 +162,7 @@ if __name__ == '__main__':
>>>  
>>>  URL = REPO.remotes.origin.url
>>>  
>>> -UPSTREAM = get_upstream(URL)
>>> +UPSTREAM = get_upstream(URL, ARGS.name)
>>>  if not UPSTREAM:
>>>  print("Upstream '%s' unknown, aborting!" % URL)
>>>  sys.exit(7)
>>>
>>
>>
>>
>>
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#58724): https://edk2.groups.io/g/devel/message/58724
Mute This Topic: https://groups.io/mt/73406555/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [EXTERNAL] Re: [edk2-devel] [PATCH 4/4] UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard CpuExceptionHandlerLib

2020-05-06 Thread Bret Barkelew via groups.io

> Should that
> section not use the !if check and just list both .inf files
> (SecPeiCpuExceptionHandlerLib.inf and
> Xcode5SecPeiCpuExceptionHandlerLib.inf)?

Hmmm, this is a very good point; after all, the updated (=reverted)
"SecPeiCpuExceptionHandlerLib.inf" instance will not build with XCODE5.
Therefore we should list both lib instance INF files under [Components],
but make "SecPeiCpuExceptionHandlerLib.inf" conditional on non-XCODE5.


Xcode5SecPeiCpuExceptionHandlerLib.inf could be added to the ignore list in the 
CI yaml file. PR gating CI currently only uses GCC and VS2017/19 and shouldn’t 
have a problem with the reverted lib. This makes 
Xcode5SecPeiCpuExceptionHandlerLib the exception which can be documented in the 
ignore list (why it’s being ignored).

Thoughts?

- Bret

From: Laszlo Ersek via groups.io
Sent: Wednesday, May 6, 2020 9:33 AM
To: Tom Lendacky; 
devel@edk2.groups.io
Cc: Jordan Justen; Ard 
Biesheuvel; Liming 
Gao; Eric Dong; Ray 
Ni; Brijesh Singh; 
Anthony Perard; Benjamin 
You; Guo Dong; Julien 
Grall; Maurice Ma; Andrew 
Fish
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH 4/4] 
UefiCpuPkg/CpuExceptionHandler: Revert binary patching in standard 
CpuExceptionHandlerLib

On 05/06/20 16:35, Tom Lendacky wrote:
> On 5/5/20 5:15 PM, Laszlo Ersek via groups.io wrote:
>> On 05/01/20 22:17, Lendacky, Thomas wrote:
>>> BZ:
>>> https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2340data=02%7C01%7CBret.Barkelew%40microsoft.com%7Ca9365fbefc53477c9e3308d7f1db4560%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637243796372782584sdata=R%2B5IgncDzx7viv3yIwX3MloX1QlzuUJ4bZlKnc%2B0xoI%3Dreserved=0
>>>
>>>
>>> Now that an XCODE5 specific CpuExceptionHandlerLib library is in place,
>>> revert the changes made to the ExceptionHandlerAsm.nasm in commit
>>> 2db0ccc2d7fe ("UefiCpuPkg: Update CpuExceptionHandlerLib pass XCODE5
>>> tool
>>> chain") so that binary patching of flash code is not performed.
>>>
>>> Cc: Eric Dong 
>>> Cc: Ray Ni 
>>> Cc: Laszlo Ersek 
>>> Cc: Liming Gao 
>>> Signed-off-by: Tom Lendacky 
>>> ---
>>>   .../X64/ExceptionHandlerAsm.nasm  | 25 +--
>>>   1 file changed, 6 insertions(+), 19 deletions(-)
>>>
>>> diff --git
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> index 19198f273137..3814f9de3703 100644
>>> ---
>>> a/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> +++
>>> b/UefiCpuPkg/Library/CpuExceptionHandlerLib/X64/ExceptionHandlerAsm.nasm
>>> @@ -34,7 +34,7 @@ AsmIdtVectorBegin:
>>>   db  0x6a; push  #VectorNum
>>>   db  ($ - AsmIdtVectorBegin) / ((AsmIdtVectorEnd -
>>> AsmIdtVectorBegin) / 32) ; VectorNum
>>>   pushrax
>>> -mov rax, strict qword 0 ;mov rax,
>>> ASM_PFX(CommonInterruptEntry)
>>> +mov rax, ASM_PFX(CommonInterruptEntry)
>>>   jmp rax
>>>   %endrep
>>>   AsmIdtVectorEnd:
>>> @@ -44,8 +44,7 @@ HookAfterStubHeaderBegin:
>>>   @VectorNum:
>>>   db  0  ; 0 will be fixed
>>>   pushrax
>>> -mov rax, strict qword 0 ; mov rax,
>>> HookAfterStubHeaderEnd
>>> -JmpAbsoluteAddress:
>>> +mov rax, HookAfterStubHeaderEnd
>>>   jmp rax
>>>   HookAfterStubHeaderEnd:
>>>   mov rax, rsp
>>> @@ -257,7 +256,8 @@ HasErrorCode:
>>>   ; and make sure RSP is 16-byte aligned
>>>   ;
>>>   sub rsp, 4 * 8 + 8
>>> -callASM_PFX(CommonExceptionHandler)
>>> +mov rax, ASM_PFX(CommonExceptionHandler)
>>> +callrax
>>>   add rsp, 4 * 8 + 8
>>>
>>>   cli
>>> @@ -365,24 +365,11 @@ DoIret:
>>>   ; comments here for definition of address map
>>>   global ASM_PFX(AsmGetTemplateAddressMap)
>>>   ASM_PFX(AsmGetTemplateAddressMap):
>>> -lea rax, [AsmIdtVectorBegin]
>>> +mov rax, AsmIdtVectorBegin
>>>   mov qword [rcx], rax
>>>   mov qword [rcx + 0x8],  (AsmIdtVectorEnd -
>>> AsmIdtVectorBegin) / 32
>>> -lea rax, [HookAfterStubHeaderBegin]
>>> +mov rax, HookAfterStubHeaderBegin
>>>   mov qword [rcx + 0x10], rax
>>> -
>>> -; Fix up CommonInterruptEntry address
>>> -learax, [ASM_PFX(CommonInterruptEntry)]
>>> -learcx, [AsmIdtVectorBegin]
>>> -%rep  32
>>> -movqword [rcx + (JmpAbsoluteAddress - 8 -
>>> HookAfterStubHeaderBegin)], rax
>>> -addrcx, (AsmIdtVectorEnd - AsmIdtVectorBegin) / 32