Re: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-12 Thread Guomin Jiang
Hi Liming,

Below is the detail why need this change. If you only care usage. Please jump 
to "How to use it" directly.

Why need:
1. Replication build is not new, you can refer https://reproducible-builds.org 
for detail
2. The benefit is that 1) make sure the same commit generate same binary so we 
can sure that it is not modified by anyone 2) store the binary in the repo 
without concern of different binary with same code.

What's barrier in EDK2 implement?
1. Very depend on Toolchain(for example VS, GCC, CLANG). Different toolchain 
have different feature set and different toolchain version have different 
feature set.
2. Deploy new toolchain need big effort, include but not limit deploy it in CI 
CD system, update toolchain, size concern, feature change, etc

What's the change:
1. The change want to address one issue that we encounter in replication build: 
the ASSERT in EDK2 will be different in different environment. For example: 
file path, back slash or forward slash, etc

How to use it:
1. If you want to keep current ASSERT string format. No action is required and 
the change keep back compatible
2. If you want to customize the ASSERT string format. You can use additional 
tool to generate PATH and define macro in BuildOptions or tools_def.

Note:
1. Replication build need many effort: 1) address the pdb path, 2) address the 
timestamp, etc
2. This change is not target for resolving all issue in replication build
3. I think it is a small step toward space even though it haven't fix every 
thing.

Thank
Guomin

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of
> gaoliming
> Sent: Wednesday, April 13, 2022 9:03 AM
> To: Jiang, Guomin ; devel@edk2.groups.io
> Cc: Kinney, Michael D ; Liu, Zhiguang
> 
> Subject: [edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use
> DEBUG_FILE_PATH to specify debug file path.
> 
> Guomin:
>   Can you introduce DEBUG_FILE_PATH usage? If the developer wants to
> enable this feature, how configure DEBUG_FILE_PATH?
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: Guomin Jiang 
> > 发送时间: 2022年4月12日 18:25
> > 收件人: devel@edk2.groups.io
> > 抄送: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu 
> > 主题: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify
> > debug file path.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> >
> > Use DEBUG_FILE_PATH to control ASSERT path
> >
> > Motivation and Goal:
> > 1. Make replication build more easy and less toolchain dependency 2.
> > Consume the ASSERT string easy for downstream 3. Make code more clear
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Signed-off-by: Guomin Jiang 
> > ---
> >  MdePkg/Include/Library/DebugLib.h | 34
> > +--
> >  1 file changed, 23 insertions(+), 11 deletions(-)
> >
> > diff --git a/MdePkg/Include/Library/DebugLib.h
> > b/MdePkg/Include/Library/DebugLib.h
> > index 8d3d08638d73..a76a268a00b6 100644
> > --- a/MdePkg/Include/Library/DebugLib.h
> > +++ b/MdePkg/Include/Library/DebugLib.h
> > @@ -8,7 +8,7 @@
> >of size reduction when compiler optimization is disabled. If
> > MDEPKG_NDEBUG is
> >defined, then debug and assert related macros wrapped by it are the
> > NULL implementations.
> >
> > -Copyright (c) 2006 - 2020, Intel Corporation. All rights
> > reserved.
> > +Copyright (c) 2006 - 2022, Intel Corporation. All rights
> > +reserved.
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -85,6 +85,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #define DEBUG_LINE_NUMBER  __LINE__  #endif
> >
> > +//
> > +// Source file path.
> > +// Default is use the __FILE__ macro value provided by compiler. The
> > __FILE__
> > +// mapping can be overriden by predefining DEBUG_FILE_PATH // //
> > +Defining DEBUG_FILE_PATH to a fixed value is useful when comparing
> > builds
> > +// across machine or configuration with different slash or path file.
> > +//
> > +#ifndef DEBUG_FILE_PATH
> > +#define DEBUG_FILE_PATH  __FILE__
> > +#endif
> > +
> > +//
> > +// Use below override to keep CLANG specific behavior // #if defined
> > +(__clang__) && defined (__FILE_NAME__)
> > +  #undef DEBUG_FILE_PATH
> > +#define DEBUG_FILE_PATH  __FILE_NAME__ #endif
> > +
> >  /**
> >Macro that converts a Boolean expression to a Null-terminated ASCII
> > string.
> >
> > @@ -337,17 +357,9 @@ UnitTestDebugAssert (
> >IN CONST CHAR8  *Description
> >);
> >
> > -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> > _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__,
> > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > -  #else
> > -#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__,
> > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> > -  #endif
> > +#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE_PATH,
> > DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))  #else
> > -  #if defined (__clang__) && defined (__FILE_NAME__) -#define
> > 

Re: [edk2-devel][PATCH v4 0/8] Support PEI 64bit in IntelFsp2Pkg and IntelFsp2WrapperPkg

2022-04-12 Thread Chiu, Chasel


Thanks Ted for updating patch!
For this patch series, Reviewed-by: Chasel Chiu 


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Kuo,
> Ted
> Sent: Wednesday, April 13, 2022 10:43 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel][PATCH v4 0/8] Support PEI 64bit in IntelFsp2Pkg and
> IntelFsp2WrapperPkg
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
> 
> Currently PEI drivers/libraries only support 32bit in IntelFsp2Pkg and
> IntelFsp2WrapperPkg. The patches below are needed to support these
> drivers/libraries in 64bit.
> 
> V2 changes:
> 1.Change FSPM_UPD_COMMON2 to FSPM_UPD_COMMON_FSP24 in
> FspApiEntryM.nasm.
> 2.Add FSPx_UPD_COMMON_FSP24 in FspApi.h.
> 3.Add 3 additional patches for supporting X64 in IntelFsp2WrapperPkg.
> 
> V3 changes:
> 1.Update FSPT_ARCH2_UPD and add FSPT_CORE_UPD back.
> 2.Use 0x instead of MAX_ADDRESS to reflect the default of
> FspData.
> 3.Remove EnableMultiPhaseMemoryInit from FSPM_ARCH2_UPD.
> 4.Bump GenCfgOpt version to 0.57.
> 
> V4 changes:
> 1.Added EFIAPI to SwapStack and PEI_CORE_ENTRY.
> 2.Cast FspData from pointer to UINTN and then from UINTN to UINT32.
> 3.Corrected few typos.
> 
> Ted Kuo (8):
>   IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit
>   IntelFsp2Pkg: Add FSPx_ARCH2_UPD support for X64
>   IntelFsp2Pkg: Update FSP_GLOBAL_DATA and FSP_PLAT_DATA for X64
>   IntelFsp2Pkg: FspSecCore support for X64
>   IntelFsp2Pkg: SecFspSecPlatformLibNull support for X64
>   IntelFsp2WrapperPkg: Adopt FSPM_UPD_COMMON_FSP24 for X64
>   IntelFsp2WrapperPkg: BaseFspWrapperApiLib support for X64
>   IntelFsp2WrapperPkg: SecFspWrapperPlatformSecLibSample support for
> X64
> 
>  IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c   |   1 +
>  IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf  |   8 +-
>  IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf|   9 +-
>  IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf|   8 +-
>  IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf|  10 +-
>  .../FspSecCore/Ia32/FspApiEntryCommon.nasm |   4 +-
>  IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm |  30 +-
>  IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm |  96 +++-
>  IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  |   8 +-
>  IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm|  10 +-
>  IntelFsp2Pkg/FspSecCore/SecFsp.c   |  10 +-
>  IntelFsp2Pkg/FspSecCore/SecFsp.h   |   2 +-
>  IntelFsp2Pkg/FspSecCore/SecFspApiChk.c |   8 +-
>  IntelFsp2Pkg/FspSecCore/SecMain.c  |   8 +-
>  IntelFsp2Pkg/FspSecCore/SecMain.h  |  18 +-
>  IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm| 103 +
>  IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm |  76 
>  IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm  | 262 +++
>  IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm  |  67 +++
>  IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm  | 495
> +
>  IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm |  34 ++
>  IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc  |  11 +
>  IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm   |  22 +
>  IntelFsp2Pkg/FspSecCore/X64/Stack.nasm |  73 +++
>  IntelFsp2Pkg/Include/FspEas/FspApi.h   | 145 +-
>  IntelFsp2Pkg/Include/FspGlobalData.h   |  51 ++-
>  IntelFsp2Pkg/Include/Guid/FspHeaderFile.h  |  14 +-
>  IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc | 284 
>  IntelFsp2Pkg/IntelFsp2Pkg.dsc  |   2 +-
>  .../Library/BaseFspCommonLib/FspCommonLib.c|   4 +-
>  .../BaseFspSwitchStackLib/FspSwitchStackLib.c  |   1 +
>  .../Library/BaseFspSwitchStackLib/X64/Stack.nasm   |   5 +-
>  .../SecFspSecPlatformLibNull/Ia32/Flat32.nasm  |   2 +-
>  .../SecFspSecPlatformLibNull.inf   |   6 +-
>  .../SecFspSecPlatformLibNull/X64/Long64.nasm   |  31 ++
>  .../SecFspSecPlatformLibNull/X64/SecCarInit.nasm   |  40 ++
>  IntelFsp2Pkg/Tools/GenCfgOpt.py|   4 +-
>  .../FspmWrapperPeim/FspmWrapperPeim.c  |  25 +-
>  .../BaseFspWrapperApiLib/FspWrapperApiLib.c|  42 +-
>  .../BaseFspWrapperApiLib/IA32/DispatchExecute.c|  21 +
>  .../BaseFspWrapperApiLib/X64/DispatchExecute.c |  45 +-
>  .../{Ia32 => }/Fsp.h   |   0
>  .../Ia32/Stack.nasm|   6 +-
>  .../SecFspWrapperPlatformSecLibSample.inf  |   7 +-
>  .../SecRamInitData.c   |  22 +-
>  .../X64/PeiCoreEntry.nasm  | 149 +++
>  .../X64/SecEntry.nasm  | 171 +++
>  .../X64/Stack.nasm |  73 +++
>  48 files changed, 2413 insertions(+), 110 deletions(-)  create mode 100644
> IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm
>  create mode 100644
> IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm
>  create mode 

Re: [edk2-devel][PATCH v4 1/8] IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit

2022-04-12 Thread Chiu, Chasel


Hi Ted,

Please see my comments below inline.

Thanks,
Chasel


> -Original Message-
> From: Kuo, Ted 
> Sent: Wednesday, April 13, 2022 10:43 AM
> To: devel@edk2.groups.io
> Cc: Chiu, Chasel ; Desimone, Nathaniel L
> ; Zeng, Star ; S,
> Ashraf Ali 
> Subject: [edk2-devel][PATCH v4 1/8] IntelFsp2Pkg: X64 compatible changes
> to support PEI in 64bit
> 
> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
> 1.Added EFIAPI to FspNotifyPhasePeimEntryPoint, SwapStack and
>   PEI_CORE_ENTRY.
> 2.Cast FspData from pointer to UINTN and then from UINTN to UINT32.

This statement might cause confusion. We can update it later when pushing the 
patch, no need to send another V5.
We actually only cast FspData pointer to UINT32 when verifying the pointer is 
valid or not, we do not cast it to UINT32 when consuming the data pointer.
So we still can support 64bits FspData pointer.




> 3.Changed AsmReadEsp to AsmReadStackPointer.
> 4.Changed the type of the return value of AsmReadStackPointer
>   from UINT32 to UINTN.
> 5.Changed the type of TemporaryMemoryBase, PermenentMemoryBase
>   and BootLoaderStack from UINT32 to UINTN.
> 6..Some type casting to pointers are UINT32. Changed them to
>   UINTN to accommodate both IA32 and X64.
> 7.Corrected some typos.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Star Zeng 
> Cc: Ashraf Ali S 
> Signed-off-by: Ted Kuo 
> ---
>  IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c   |  1 +
>  IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  |  8 
>  IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm| 10 +-
>  IntelFsp2Pkg/FspSecCore/SecFsp.c   |  8 
>  IntelFsp2Pkg/FspSecCore/SecFsp.h   |  2 +-
>  IntelFsp2Pkg/FspSecCore/SecFspApiChk.c |  8 
>  IntelFsp2Pkg/FspSecCore/SecMain.c  |  8 
>  IntelFsp2Pkg/FspSecCore/SecMain.h  | 18 
> ++
>  .../Library/BaseFspSwitchStackLib/FspSwitchStackLib.c  |  1
> +  .../Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm  |  2 +-
>  10 files changed, 35 insertions(+), 31 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> index 88f5540fef..66d39cc70c 100644
> --- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> +++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
> @@ -112,6 +112,7 @@ WaitForNotify (
>@retval EFI_OUT_OF_RESOURCES Insufficient resources to create
> database
>  **/
>  EFI_STATUS
> +EFIAPI
>  FspNotifyPhasePeimEntryPoint (
>IN   EFI_PEI_FILE_HANDLE  FileHandle,
>IN CONST EFI_PEI_SERVICES **PeiServices
> diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
> b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
> index 8046b43745..d40dad5a52 100644
> --- a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
> +++ b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
> @@ -9,14 +9,14 @@
>  SECTION .text
> 
>  
> ;--
> -; UINT32
> +; UINTN
>  ; EFIAPI
> -; AsmReadEsp (
> +; AsmReadStackPointer (
>  ;   VOID
>  ;   );
>  
> ;--
> -global ASM_PFX(AsmReadEsp)
> -ASM_PFX(AsmReadEsp):
> +global ASM_PFX(AsmReadStackPointer)
> +ASM_PFX(AsmReadStackPointer):
>  mov eax, esp
>  ret
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
> b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
> index 5a7e27c240..ce20639890 100644
> --- a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
> +++ b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
> @@ -9,20 +9,20 @@
>  ;
>  
> ;--
> 
> -SECTION .text
> +SECTION .text
> 
>  
> ;--
>  ; VOID
>  ; EFIAPI
>  ; SecSwitchStack (
>  ;   UINT32   TemporaryMemoryBase,
> -;   UINT32   PermenentMemoryBase
> +;   UINT32   PermanentMemoryBase
>  ;   );
>  
> ;--
>  global ASM_PFX(SecSwitchStack)
>  ASM_PFX(SecSwitchStack):
>  ;
> -; Save three register: eax, ebx, ecx
> +; Save four register: eax, ebx, ecx, edx
>  ;
>  push  eax
>  push  ebx
> @@ -55,7 +55,7 @@ ASM_PFX(SecSwitchStack):
>  mov   dword [eax + 12], edx
>  mov   edx, dword [esp + 16]; Update this function's return address
> into permanent memory
>  mov   dword [eax + 16], edx
> -mov   esp, eax ; From now, esp is pointed to 
> permanent
> memory
> +mov   esp, eax ; From now, esp is pointed to permanent
> memory
> 
>  ;
>  ; Fixup the ebp point to permanent memory @@ -63,7 +63,7 @@
> ASM_PFX(SecSwitchStack):
>  mov   eax, ebp
>  sub   eax, ebx
>  add   eax, ecx
> -mov   ebp, eax; From now, ebp is pointed to 

Re: [edk2-devel] [PATCH v3 2/6] OvmfPkg/FdtPciHostBridgeLib: io range is not mandatory

2022-04-12 Thread Abner Chang



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Tuesday, April 12, 2022 5:04 PM
> To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist)
> 
> Cc: Leif Lindholm ; Ard Biesheuvel
> ; Jordan Justen ;
> Jian J Wang ; Ray Ni ; Hao A Wu
> ; Jiewen Yao ; Liming Gao
> ; Pawel Polawski ;
> Oliver Steffen 
> Subject: Re: [edk2-devel] [PATCH v3 2/6] OvmfPkg/FdtPciHostBridgeLib: io
> range is not mandatory
> 
>   Hi,
> 
> > > -  Io.Base   = IoBase;
> > > -  Io.Limit  = IoBase + IoSize - 1;
> > > +  if (IoSize) {
> > > +Io.Base  = IoBase;
> > > +Io.Limit = IoBase + IoSize - 1;
> > > +  } else {
> > > +Io.Base  = MAX_UINT64;
> > > +Io.Limit = 0;
> > HI Gerd,
> > Does the consumer of Io (in PCI_ROOT_BRIDGE structure) know that the
> MAX_UINT64 for Io.Base refers to no memory map I/O?
> 
> Patch #1 handles that.
Ok, I had my comment in the response to patch #1.
Thanks
Abner
> 
> take care,
>   Gerd
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88839): https://edk2.groups.io/g/devel/message/88839
Mute This Topic: https://groups.io/mt/90309349/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 1/6] MdeModulePkg/PciHostBridge: io range is not mandatory

2022-04-12 Thread Abner Chang



> -Original Message-
> From: Gerd Hoffmann 
> Sent: Thursday, April 7, 2022 5:33 PM
> To: devel@edk2.groups.io
> Cc: Leif Lindholm ; Ard Biesheuvel
> ; Jordan Justen ;
> Jian J Wang ; Ray Ni ; Hao A Wu
> ; Gerd Hoffmann ; Jiewen Yao
> ; Liming Gao ; Pawel
> Polawski ; Chang, Abner (HPS SW/FW Technologist)
> ; Oliver Steffen ; Ard
> Biesheuvel 
> Subject: [PATCH v3 1/6] MdeModulePkg/PciHostBridge: io range is not
> mandatory
> 
> io range is not mandatory according to pcie spec,
> so allow bridge configurations without io address
> space assigned.
> 
> Signed-off-by: Gerd Hoffmann 
> Reviewed-by: Ard Biesheuvel 
> ---
>  MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> index b20bcd310ad5..51a3b987967f 100644
> --- a/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> +++ b/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciHostBridge.c
> @@ -1085,6 +1085,9 @@ NotifyPhase (
>RootBridge->ResAllocNode[Index].Base   = BaseAddress;
>RootBridge->ResAllocNode[Index].Status = ResAllocated;
>DEBUG ((DEBUG_INFO, "Success\n"));
> +} else if (Index == TypeIo) {
How do we tell the BaseAddress is set to UINT64 because "(BaseAddress < Limit)" 
or "gDS->AllocateMemorySpace()" returns error in AllocateResource() for TypeIo ?
Is "else if (Index == TypeIo  && RootBridge->Io.Base == MAX_UINT64)" more 
reliable? Or I missed the code logic here?

> +  /* optional on PCIe */
We should use double back slash for the comment in the function if my 
understanding of the coding standard is correct.

Abner

> +  DEBUG ((DEBUG_INFO, "No IO\n"));
>  } else {
>ReturnStatus = EFI_OUT_OF_RESOURCES;
>DEBUG ((DEBUG_ERROR, "Out Of Resource!\n"));
> --
> 2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88838): https://edk2.groups.io/g/devel/message/88838
Mute This Topic: https://groups.io/mt/90309345/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Regression: 100x I/O performance slowdown in SEC phase caused by TDX

2022-04-12 Thread Min Xu
On April 13, 2022 5:22 AM, James Bottom wrote:
> 
> I'm using a SEC phase which has a TPM driver to experiment with sorting out
> measured boot, which is how I noticed (usually SEC doesn't do MMIO) .
> What I'm seeing is after commit b6b2de884864 ("MdePkg: Support mmio for
> Tdx guest in BaseIoLibIntrinsic") we get a massive slowdown of about 100x in
> TPM performance.  The reason seems to be this addition to the
> mmioreadX/mmiowriteX code:
> 
>  MemoryFence ();
> -*(volatile UINT16 *)Address = Value;
> +
> +if (IsTdxGuest ()) {
> +  TdMmioWrite16 (Address, Value);
> +} else {
> +  *(volatile UINT16 *)Address = Value;
> +}
> +
>  MemoryFence ();
> 
> 
> The problem is that IsTdxGuest () has this structure:
> 
> BOOLEAN
> EFIAPI
> IsTdxGuest (
>   VOID
>   )
> {
>   if (mTdxProbed) {
> return mTdxEnabled;
>   }
> 
>   mTdxEnabled = TdIsEnabled ();
>   mTdxProbed  = TRUE;
> 
>   return mTdxEnabled;
> }
> 
> Which is trying to cache the result of the probe in the efi data segment.
> However, that doesn't work in SEC, because the data segment is read only
> (so the write seems to succeed but a read will always return the original
> value), leading to us calling TdIsEnabled() check for every mmio we do,
> which is causing the slowdown because it's very expensive.
> 
The analysis is right. I hadn't thought the basic IO would be heavily called in 
SEC phase. I will fix it as soon as possible.

My thought is that a TdProbeLib will be introduced in MdePkg. In MdePkg this 
lib is of null instance. It just simply return TD_PROBE_NON which means it is 
not Td guest. This lib will be added in MdePkg/MdeLibs.dsc.inc (like 
RegisterFilterLibNull). 
In OvmfPkg TdProbeLib will be implemented. It checks the OvmfWorkArea to 
determine the guest type.

Thanks
Min



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88837): https://edk2.groups.io/g/devel/message/88837
Mute This Topic: https://groups.io/mt/90427994/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 25/33] MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.

2022-04-12 Thread Chao Li
Hi Abner,

You pointed out that you attached a patch to your last email, but I didn't find 
it, do you forgot to put it? In the current EDK II code repo, I can not find 
the patch which you mentioned.

--
Thanks,
Chao


On 4月 8 2022, at 7:26 晚上, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
> Recently there is a work to migrate UefiCpuLib to CpuLib (patch attached), 
> you may want to sync up your changes with that patch set. RISC-V will do the 
> same work later.
>
> Thanks
> Abner
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:56 PM
> > To: devel@edk2.groups.io
> > Cc: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 25/33]
> > MdePkg/BaseCpuLib: LoongArch Base CPU library implementation.
> >
> > Implement LoongArch CPU related functions in BaseCpuLib.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Chao Li 
> > ---
> > MdePkg/Library/BaseCpuLib/BaseCpuLib.inf | 7 ++-
> > MdePkg/Library/BaseCpuLib/BaseCpuLib.uni | 5 +++--
> > MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S | 15
> > +++
> > MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S | 15
> > +++
> > 4 files changed, 39 insertions(+), 3 deletions(-)
> > create mode 100644 MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> > create mode 100644 MdePkg/Library/BaseCpuLib/LoongArch/CpuSleep.S
> >
> > diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> > b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> > index 950f5229b2..3101fc656e 100644
> > --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> > +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
> > @@ -8,6 +8,7 @@
> > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > # Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
> > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> > reserved.
> > +# Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> > rights reserved.
> > #
> > # SPDX-License-Identifier: BSD-2-Clause-Patent
> > #
> > @@ -25,7 +26,7 @@
> >
> >
> > #
> > -# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64
> > +# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 RISCV64
> > LOONGARCH64
> > #
> >
> > [Sources.IA32]
> > @@ -63,6 +64,10 @@
> > [Sources.RISCV64]
> > RiscV/Cpu.S
> >
> > +[Sources.LOONGARCH64]
> > + LoongArch/CpuFlushTlb.S | GCC
> > + LoongArch/CpuSleep.S | GCC
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> >
> > diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> > b/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> > index 80dc495786..7c5c8dfb37 100644
> > --- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> > +++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.uni
> > @@ -1,13 +1,14 @@
> > // /** @file
> > // Instance of CPU Library for various architecture.
> > //
> > -// CPU Library implemented using ASM functions for IA-32, X64 and RISCV64,
> > +// CPU Library implemented using ASM functions for IA-32, X64, RISCV64
> > and LoongArch64,
> > // PAL CALLs for IPF, and empty functions for EBC.
> > //
> > // Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
> > // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > // Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
> > // Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> > reserved.
> > +// Portions Copyright (c) 2022, Loongson Technology Corporation Limited.
> > All rights reserved.
> > //
> > // SPDX-License-Identifier: BSD-2-Clause-Patent
> > //
> > @@ -16,5 +17,5 @@
> >
> > #string STR_MODULE_ABSTRACT #language en-US "Instance of CPU
> > Library for various architectures"
> >
> > -#string STR_MODULE_DESCRIPTION #language en-US "CPU Library
> > implemented using ASM functions for IA-32, X64 and RISCV64, PAL CALLs for
> > IPF, and empty functions for EBC."
> > +#string STR_MODULE_DESCRIPTION #language en-US "CPU Library
> > implemented using ASM functions for IA-32, X64, RISCV64 and LoongArch64,
> > PAL CALLs for IPF, and empty functions for EBC."
> >
> > diff --git a/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> > b/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> > new file mode 100644
> > index 00..8b792f0a37
> > --- /dev/null
> > +++ b/MdePkg/Library/BaseCpuLib/LoongArch/CpuFlushTlb.S
> > @@ -0,0 +1,15 @@
> > +#--
> > +#
> > +# CpuFlushTlb() for LoongArch64
> > +#
> > +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > +#
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent
> > +#
> > +#--
> > +ASM_GLOBAL ASM_PFX(CpuFlushTlb)
> > +
> > +ASM_PFX(CpuFlushTlb):
> > + tlbflush
> > + jirl $zero, $ra, 0
> > + .end
> > diff --git 

[edk2-devel] [PATCH v2] MdePkg: Update smbiosview type 9 with SMBIOS 3.5 fields

2022-04-12 Thread Bo Chang Ke
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3896

update smbiosview type 9 related fileds.

Signed-off-by: Bo Chang Ke 
Cc: Zhiguang Liu 
Cc: Zhichao Gao 
Cc: Dandan Bi 
Cc: Star Zeng 
---
 MdePkg/Include/IndustryStandard/SmBios.h | 49 +++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h 
b/MdePkg/Include/IndustryStandard/SmBios.h
index 2b1567b052..52f2e35ee9 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -1306,6 +1306,11 @@ typedef enum {
   SlotTypePciExpressMini52pinWithBSKO= 0x21,///< PCI Express Mini 
52-pin (CEM spec. 2.0) with bottom-side keep-outs.
   SlotTypePciExpressMini52pinWithoutBSKO = 0x22,///< PCI Express Mini 
52-pin (CEM spec. 2.0) without bottom-side keep-outs.
   SlotTypePciExpressMini76pin= 0x23,///< PCI Express Mini 
76-pin (CEM spec. 2.0) Corresponds to Display-Mini card.
+  SlotTypePCIExpressGen4SFF_8639 = 0x24,///< U.2
+  SlotTypePCIExpressGen5SFF_8639 = 0x25,///< U.2
+  SlotTypeOCPNIC30SmallFormFactor= 0x26,///< SFF
+  SlotTypeOCPNIC30LargeFormFactor= 0x27,///< LFF
+  SlotTypeOCPNICPriorto30= 0x28,
   SlotTypeCXLFlexbus10   = 0x30,
   SlotTypePC98C20= 0xA0,
   SlotTypePC98C24= 0xA1,
@@ -1335,7 +1340,16 @@ typedef enum {
   SlotTypePciExpressGen4X2   = 0xBA,
   SlotTypePciExpressGen4X4   = 0xBB,
   SlotTypePciExpressGen4X8   = 0xBC,
-  SlotTypePciExpressGen4X16  = 0xBD
+  SlotTypePciExpressGen4X16  = 0xBD,
+  SlotTypePCIExpressGen5 = 0xBE,
+  SlotTypePCIExpressGen5X1   = 0xBF,
+  SlotTypePCIExpressGen5X2   = 0xC0,
+  SlotTypePCIExpressGen5X4   = 0xC1,
+  SlotTypePCIExpressGen5X8   = 0xC2,
+  SlotTypePCIExpressGen5X16  = 0xC3,
+  SlotTypePCIExpressGen6andBeyond= 0xC4,
+  SlotTypeEnterpriseandDatacenter1UE1FormFactorSlot = 0xC5,
+  SlotTypeEnterpriseandDatacenter3E3FormFactorSlot  = 0xC6
 } MISC_SLOT_TYPE;
 
 ///
@@ -1358,6 +1372,39 @@ typedef enum {
   SlotDataBusWidth32X = 0x0E ///< Or X32
 } MISC_SLOT_DATA_BUS_WIDTH;
 
+///
+/// System Slots - Slot Physical Width.
+///
+typedef enum {
+  SlotPhysicalWidthOther   = 0x01,
+  SlotPhysicalWidthUnknown = 0x02,
+  SlotPhysicalWidth8Bit= 0x03,
+  SlotPhysicalWidth16Bit   = 0x04,
+  SlotPhysicalWidth32Bit   = 0x05,
+  SlotPhysicalWidth64Bit   = 0x06,
+  SlotPhysicalWidth128Bit  = 0x07,
+  SlotPhysicalWidth1X  = 0x08,///< Or X1
+  SlotPhysicalWidth2X  = 0x09,///< Or X2
+  SlotPhysicalWidth4X  = 0x0A,///< Or X4
+  SlotPhysicalWidth8X  = 0x0B,///< Or X8
+  SlotPhysicalWidth12X = 0x0C,///< Or X12
+  SlotPhysicalWidth16X = 0x0D,///< Or X16
+  SlotPhysicalWidth32X = 0x0E ///< Or X32
+} MISC_SLOT_PHYSICAL_WIDTH;
+
+///
+/// System Slots - Slot Information.
+///
+typedef enum {
+  others = 0x00,
+  Gen1   = 0x01,
+  Gen2   = 0x01,
+  Gen3   = 0x03,
+  Gen4   = 0x04,
+  Gen5   = 0x05,
+  Gen6   = 0x06
+} MISC_SLOT_INFORMATION;
+
 ///
 /// System Slots - Current Usage.
 ///
-- 
2.32.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88835): https://edk2.groups.io/g/devel/message/88835
Mute This Topic: https://groups.io/mt/90433755/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2] ShellPkg: Update smbiosview type 9 with SMBIOS 3.5 fields

2022-04-12 Thread Bo Chang Ke
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3896

update smbiosview type 9 related fileds.

Signed-off-by: Bo Chang Ke 
Cc: Ray Ni 
Cc: Zhichao Gao 
---
 .../SmbiosView/PrintInfo.c|   7 +-
 .../SmbiosView/QueryTable.c   | 237 ++
 .../SmbiosView/QueryTable.h   |  36 +++
 .../SmbiosView/SmbiosViewStrings.uni  |   5 +-
 4 files changed, 280 insertions(+), 5 deletions(-)

diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
index b144600a25..003892274b 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
@@ -635,6 +635,9 @@ SmbiosPrintStructure (
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DEV_FUNC_NUM), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DevFuncNum);
 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_DATA_BUS_WIDTH), gShellDebug1HiiHandle, 
PeerGroupPtr[Index].DataBusWidth);
   }
+  DisplaySystemSlotHeight (Struct->Type9->SlotHeight, Option);
+  DisplaySystemSlotPhysicalWidth (Struct->Type9->SlotPhysicalWidth, 
Option);
+  DisplaySystemSlotInformation (Struct->Type9->SlotInformation, 
Option);
 }
   }
 
@@ -2898,10 +2901,6 @@ DisplaySystemSlotId (
   IN UINT8   Option
   )
 {
-  //
-  // Display slot type first
-  //
-  DisplaySystemSlotType (SlotType, Option);
 
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN 
(STR_SMBIOSVIEW_PRINTINFO_SLOT_ID), gShellDebug1HiiHandle);
   //
diff --git 
a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
index c4a6acb167..95aef61ff4 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/QueryTable.c
@@ -1447,6 +1447,26 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
 0x23,
 L"PCI Express Mini 76-pin (CEM spec. 2.0) Corresponds to Display-Mini card"
   },
+  {
+0x24,
+L"PCI Express Gen 4 SFF-8639 (U.2)"
+  },
+  {
+0x25,
+L"PCI Express Gen 5 SFF-8639 (U.2)"
+  },
+  {
+0x26,
+L"OCP NIC 3.0 Small Form Factor (SFF)"
+  },
+  {
+0x27,
+L"OCP NIC 3.0 Large Form Factor (LFF)"
+  },
+  {
+0x28,
+L"OCP NIC Prior to 3.0"
+  },
   {
 SlotTypeCXLFlexbus10,
 L"CXL Flexbus 1.0"
@@ -1566,6 +1586,42 @@ TABLE_ITEM  SystemSlotTypeTable[] = {
   {
 SlotTypePciExpressGen4X16,
 L"PCI Express Gen 4 X16"
+  },
+  {
+SlotTypePCIExpressGen5,
+L"PCI Express Gen 5"
+  },
+  {
+SlotTypePCIExpressGen5X1,
+L"PCI Express Gen 5 x1"
+  },
+  {
+SlotTypePCIExpressGen5X2,
+L"PCI Express Gen 5 x2"
+  },
+  {
+SlotTypePCIExpressGen5X4,
+L"PCI Express Gen 5 x4"
+  },
+  {
+SlotTypePCIExpressGen5X8,
+L"PCI Express Gen 5 x8"
+  },
+  {
+SlotTypePCIExpressGen5X16,
+L"PCI Express Gen 5 x16"
+  },
+  {
+SlotTypePCIExpressGen6andBeyond,
+L"PCI Express Gen 6 and Beyond"
+  },
+  {
+SlotTypeEnterpriseandDatacenter1UE1FormFactorSlot,
+L"Enterprise and Datacenter 1U E1 Form Factor Slot"
+  },
+  {
+SlotTypeEnterpriseandDatacenter3E3FormFactorSlot,
+L"Enterprise and Datacenter 3'E3 Form Factor Slot"
   }
 };
 
@@ -1628,6 +1684,96 @@ TABLE_ITEM  SystemSlotDataBusWidthTable[] = {
   }
 };
 
+TABLE_ITEM  SystemSlotPhysicalWidthTable[] = {
+  {
+0x01,
+L" Other"
+  },
+  {
+0x02,
+L" Unknown"
+  },
+  {
+0x03,
+L" 8 bit"
+  },
+  {
+0x04,
+L" 16 bit"
+  },
+  {
+0x05,
+L" 32 bit"
+  },
+  {
+0x06,
+L" 64 bit"
+  },
+  {
+0x07,
+L" 128 bit"
+  },
+  {
+0x08,
+L" 1x or x1"
+  },
+  {
+0x09,
+L" 2x or x2"
+  },
+  {
+0x0A,
+L" 4x or x4"
+  },
+  {
+0x0B,
+L" 8x or x8"
+  },
+  {
+0x0C,
+L" 12x or x12"
+  },
+  {
+0x0D,
+L" 16x or x16"
+  },
+  {
+0x0E,
+L" 32x or x32"
+  }
+};
+
+TABLE_ITEM  SystemSlotInformationTable[] = {
+  {
+0x00,
+L" Others"
+  },
+  {
+0x01,
+L" Gen 1"
+  },
+  {
+0x02,
+L" Gen 2"
+  },
+  {
+0x03,
+L" Gen 3"
+  },
+  {
+0x04,
+L" Gen 4"
+  },
+  {
+0x05,
+L" Gen 5"
+  },
+  {
+0x06,
+L" Gen 6"
+  }
+};
+
 TABLE_ITEM  SystemSlotCurrentUsageTable[] = {
   {
 0x01,
@@ -1670,6 +1816,30 @@ TABLE_ITEM  SystemSlotLengthTable[] = {
   },
 };
 
+TABLE_ITEM  SystemSlotHeightTable[] = {
+  {
+0x00,
+L" Not applicable"
+  },
+  {
+0x01,
+L" Other"
+  },
+  {
+0x02,
+L" Unkown"
+  },
+  {
+0x03,
+L" Full height"
+  },
+  {
+0x04,
+L" Low-Profile"
+  },
+
+};
+
 TABLE_ITEM  SlotCharacteristics1Table[] = {
   {
 0,
@@ -1722,6 +1892,22 @@ TABLE_ITEM  SlotCharacteristics2Table[] = {
   {
 3,
 L" PCIe 

[edk2-devel][PATCH v4 8/8] IntelFsp2WrapperPkg: SecFspWrapperPlatformSecLibSample support for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
1.Added SecFspWrapperPlatformSecLibSample support for X64.
2.Adopted FSPT_ARCH2_UPD in SecFspWrapperPlatformSecLibSample.
3.Moved Fsp.h up one level to be shared across IA32 and X64.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 .../{Ia32 => }/Fsp.h   |   0
 .../Ia32/Stack.nasm|   6 +-
 .../SecFspWrapperPlatformSecLibSample.inf  |   7 +-
 .../SecRamInitData.c   |  22 +--
 .../X64/PeiCoreEntry.nasm  | 149 ++
 .../X64/SecEntry.nasm  | 171 +
 .../X64/Stack.nasm |  73 +
 7 files changed, 415 insertions(+), 13 deletions(-)
 rename IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/{Ia32 => 
}/Fsp.h (100%)
 create mode 100644 
IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/PeiCoreEntry.nasm
 create mode 100644 
IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/SecEntry.nasm
 create mode 100644 
IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/X64/Stack.nasm

diff --git 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Fsp.h 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Fsp.h
similarity index 100%
rename from 
IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Fsp.h
rename to IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Fsp.h
diff --git 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Stack.nasm 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Stack.nasm
index d7394cf286..65e9c2e895 100644
--- 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Stack.nasm
+++ 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/Ia32/Stack.nasm
@@ -22,7 +22,7 @@
 global ASM_PFX(SecSwitchStack)
 ASM_PFX(SecSwitchStack):
 ;
-; Save three register: eax, ebx, ecx
+; Save four register: eax, ebx, ecx, edx
 ;
 push  eax
 push  ebx
@@ -55,7 +55,7 @@ ASM_PFX(SecSwitchStack):
 mov   dword [eax + 12], edx
 mov   edx, dword [esp + 16]; Update this function's return address 
into permanent memory
 mov   dword [eax + 16], edx
-mov   esp, eax ; From now, esp is pointed to permanent 
memory
+mov   esp, eax ; From now, esp is pointed to permanent 
memory
 
 ;
 ; Fixup the ebp point to permanent memory
@@ -63,7 +63,7 @@ ASM_PFX(SecSwitchStack):
 mov   eax, ebp
 sub   eax, ebx
 add   eax, ecx
-mov   ebp, eax; From now, ebp is pointed to permanent 
memory
+mov   ebp, eax ; From now, ebp is pointed to permanent 
memory
 
 pop   edx
 pop   ecx
diff --git 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf
 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf
index 027b127724..7aa4297bcc 100644
--- 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf
+++ 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf
@@ -39,13 +39,18 @@
   SecGetPerformance.c
   SecTempRamDone.c
   PlatformInit.c
+  Fsp.h
 
 [Sources.IA32]
-  Ia32/Fsp.h
   Ia32/SecEntry.nasm
   Ia32/PeiCoreEntry.nasm
   Ia32/Stack.nasm
 
+[Sources.X64]
+  X64/SecEntry.nasm
+  X64/PeiCoreEntry.nasm
+  X64/Stack.nasm
+
 

 #
 # Package Dependency Section - list of Package files that are required for
diff --git 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamInitData.c
 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamInitData.c
index 03616cb418..4a7478c2c3 100644
--- 
a/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamInitData.c
+++ 
b/IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecRamInitData.c
@@ -10,18 +10,20 @@
 #include 
 
 typedef struct {
-  UINT32MicrocodeRegionBase;
-  UINT32MicrocodeRegionSize;
-  UINT32CodeRegionBase;
-  UINT32CodeRegionSize;
+  EFI_PHYSICAL_ADDRESS  MicrocodeRegionBase;
+  UINT64MicrocodeRegionSize;
+  EFI_PHYSICAL_ADDRESS  CodeRegionBase;
+  UINT64CodeRegionSize;
 } FSPT_CORE_UPD;
 
 typedef struct {
   FSP_UPD_HEADERFspUpdHeader;
   //
-  // If platform does not support FSP spec 2.2 remove FSPT_ARCH_UPD structure.
+  // If FSP spec version < 2.2, remove FSPT_ARCH_UPD structure.
+  // Else If FSP spec version >= 2.2 and FSP spec version < 2.4, use 
FSPT_ARCH_UPD structure.
+  // Else, use FSPT_ARCH2_UPD structure.
   //
-  FSPT_ARCH_UPD FsptArchUpd;
+  FSPT_ARCH2_UPDFsptArchUpd;

[edk2-devel][PATCH v4 7/8] IntelFsp2WrapperPkg: BaseFspWrapperApiLib support for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
Add Execute64BitCode to execute 64bit code from long mode directly
in PEI 64bit.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 .../BaseFspWrapperApiLib/FspWrapperApiLib.c| 42 +---
 .../BaseFspWrapperApiLib/IA32/DispatchExecute.c| 21 ++
 .../BaseFspWrapperApiLib/X64/DispatchExecute.c | 45 +-
 3 files changed, 101 insertions(+), 7 deletions(-)

diff --git 
a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c 
b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c
index 67faad927c..ba4fe3903e 100644
--- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c
+++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/FspWrapperApiLib.c
@@ -13,7 +13,7 @@
 #include 
 
 /**
-  Wrapper for a thunk  to transition from long mode to compatibility mode to 
execute 32-bit code and then transit back to
+  Wrapper for a thunk to transition from long mode to compatibility mode to 
execute 32-bit code and then transit back to
   long mode.
 
   @param[in] Function The 32bit code entry to be executed.
@@ -29,6 +29,22 @@ Execute32BitCode (
   IN UINT64  Param2
   );
 
+/**
+  Wrapper to execute 64-bit code directly from long mode.
+
+  @param[in] Function The 64bit code entry to be executed.
+  @param[in] Param1   The first parameter to pass to 64bit code.
+  @param[in] Param2   The second parameter to pass to 64bit code.
+
+  @return EFI_STATUS.
+**/
+EFI_STATUS
+Execute64BitCode (
+  IN UINT64  Function,
+  IN UINT64  Param1,
+  IN UINT64  Param2
+  );
+
 /**
   Find FSP header pointer.
 
@@ -94,7 +110,11 @@ CallFspNotifyPhase (
 
   NotifyPhaseApi = (FSP_NOTIFY_PHASE)((UINTN)FspHeader->ImageBase + 
FspHeader->NotifyPhaseEntryOffset);
   InterruptState = SaveAndDisableInterrupts ();
-  Status = Execute32BitCode ((UINTN)NotifyPhaseApi, 
(UINTN)NotifyPhaseParams, (UINTN)NULL);
+  if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == 
FSP_IA32) {
+Status = Execute32BitCode ((UINTN)NotifyPhaseApi, 
(UINTN)NotifyPhaseParams, (UINTN)NULL);
+  } else {
+Status = Execute64BitCode ((UINTN)NotifyPhaseApi, 
(UINTN)NotifyPhaseParams, (UINTN)NULL);
+  }
   SetInterruptState (InterruptState);
 
   return Status;
@@ -127,7 +147,11 @@ CallFspMemoryInit (
 
   FspMemoryInitApi = (FSP_MEMORY_INIT)((UINTN)FspHeader->ImageBase + 
FspHeader->FspMemoryInitEntryOffset);
   InterruptState   = SaveAndDisableInterrupts ();
-  Status   = Execute32BitCode ((UINTN)FspMemoryInitApi, 
(UINTN)FspmUpdDataPtr, (UINTN)HobListPtr);
+  if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == 
FSP_IA32) {
+Status = Execute32BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDataPtr, 
(UINTN)HobListPtr);
+  } else {
+Status = Execute64BitCode ((UINTN)FspMemoryInitApi, (UINTN)FspmUpdDataPtr, 
(UINTN)HobListPtr);
+  }
   SetInterruptState (InterruptState);
 
   return Status;
@@ -158,7 +182,11 @@ CallTempRamExit (
 
   TempRamExitApi = (FSP_TEMP_RAM_EXIT)((UINTN)FspHeader->ImageBase + 
FspHeader->TempRamExitEntryOffset);
   InterruptState = SaveAndDisableInterrupts ();
-  Status = Execute32BitCode ((UINTN)TempRamExitApi, 
(UINTN)TempRamExitParam, (UINTN)NULL);
+  if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == 
FSP_IA32) {
+Status = Execute32BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExitParam, 
(UINTN)NULL);
+  } else {
+Status = Execute64BitCode ((UINTN)TempRamExitApi, (UINTN)TempRamExitParam, 
(UINTN)NULL);
+  }
   SetInterruptState (InterruptState);
 
   return Status;
@@ -189,7 +217,11 @@ CallFspSiliconInit (
 
   FspSiliconInitApi = (FSP_SILICON_INIT)((UINTN)FspHeader->ImageBase + 
FspHeader->FspSiliconInitEntryOffset);
   InterruptState= SaveAndDisableInterrupts ();
-  Status= Execute32BitCode ((UINTN)FspSiliconInitApi, 
(UINTN)FspsUpdDataPtr, (UINTN)NULL);
+  if ((FspHeader->ImageAttribute & IMAGE_ATTRIBUTE_64BIT_MODE_SUPPORT) == 
FSP_IA32) {
+Status = Execute32BitCode ((UINTN)FspSiliconInitApi, 
(UINTN)FspsUpdDataPtr, (UINTN)NULL);
+  } else {
+Status = Execute64BitCode ((UINTN)FspSiliconInitApi, 
(UINTN)FspsUpdDataPtr, (UINTN)NULL);
+  }
   SetInterruptState (InterruptState);
 
   return Status;
diff --git 
a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute.c 
b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute.c
index 4f6a8dd1a7..a22ed2d539 100644
--- a/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute.c
+++ b/IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/IA32/DispatchExecute.c
@@ -49,3 +49,24 @@ Execute32BitCode (
 
   return Status;
 }
+
+/**
+  Wrapper for a thunk to transition from compatibility mode to long mode to 
execute 64-bit code and then transit back to
+  compatibility mode.
+
+  @param[in] Function The 64bit code entry to 

[edk2-devel][PATCH v4 5/8] IntelFsp2Pkg: SecFspSecPlatformLibNull support for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
1.Added SecFspSecPlatformLibNull support for X64.
2.Added X64 support to IntelFsp2Pkg.dsc.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 IntelFsp2Pkg/IntelFsp2Pkg.dsc  |  2 +-
 .../SecFspSecPlatformLibNull.inf   |  6 +++-
 .../SecFspSecPlatformLibNull/X64/Long64.nasm   | 31 +
 .../SecFspSecPlatformLibNull/X64/SecCarInit.nasm   | 40 ++
 4 files changed, 77 insertions(+), 2 deletions(-)
 create mode 100644 
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm
 create mode 100644 
IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm

diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
index c1414f7e75..1284aa042c 100644
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
@@ -12,7 +12,7 @@
   PLATFORM_VERSION   = 0.1
   DSC_SPECIFICATION  = 0x00010005
   OUTPUT_DIRECTORY   = Build/IntelFsp2Pkg
-  SUPPORTED_ARCHITECTURES= IA32
+  SUPPORTED_ARCHITECTURES= IA32|X64
   BUILD_TARGETS  = DEBUG|RELEASE|NOOPT
   SKUID_IDENTIFIER   = DEFAULT
 
diff --git 
a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf 
b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
index 42e7d83c32..ef859d5ea5 100644
--- a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
+++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/SecFspSecPlatformLibNull.inf
@@ -23,7 +23,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32
+#  VALID_ARCHITECTURES   = IA32 X64
 #
 
 

@@ -39,6 +39,10 @@
   Ia32/Flat32.nasm
   Ia32/SecCarInit.nasm
 
+[Sources.X64]
+  X64/Long64.nasm
+  X64/SecCarInit.nasm
+
 

 #
 # Package Dependency Section - list of Package files that are required for
diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm 
b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm
new file mode 100644
index 00..836257f962
--- /dev/null
+++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/Long64.nasm
@@ -0,0 +1,31 @@
+;; @file
+;  This is the code that performs early platform initialization.
+;  It consumes the reset vector, configures the stack.
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+
+;
+; Define assembler characteristics
+;
+
+extern   ASM_PFX(TempRamInitApi)
+
+SECTION .text
+
+%macro RET_RSI  0
+
+  movdrsi, mm7  ; restore RSI from MM7
+  jmp rsi
+
+%endmacro
+
+;
+; Perform early platform initialization
+;
+global ASM_PFX(SecPlatformInit)
+ASM_PFX(SecPlatformInit):
+
+  RET_RSI
+
diff --git a/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm 
b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm
new file mode 100644
index 00..e64c77ed18
--- /dev/null
+++ b/IntelFsp2Pkg/Library/SecFspSecPlatformLibNull/X64/SecCarInit.nasm
@@ -0,0 +1,40 @@
+;; @file
+;  SEC CAR function
+;
+; Copyright (c) 2022, Intel Corporation. All rights reserved.
+; SPDX-License-Identifier: BSD-2-Clause-Patent
+;;
+
+;
+; Define assembler characteristics
+;
+
+%macro RET_RSI 0
+
+  movdrsi, mm7  ; move ReturnAddress from MM7 to RSI
+  jmp rsi
+
+%endmacro
+
+SECTION .text
+
+;-
+;
+;  Section: SecCarInit
+;
+;  Description: This function initializes the Cache for Data, Stack, and Code
+;
+;-
+global ASM_PFX(SecCarInit)
+ASM_PFX(SecCarInit):
+
+  ;
+  ; Set up CAR
+  ;
+
+  xorrax, rax
+
+SecCarInitExit:
+
+  RET_RSI
+
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88830): https://edk2.groups.io/g/devel/message/88830
Mute This Topic: https://groups.io/mt/90433374/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel][PATCH v4 4/8] IntelFsp2Pkg: FspSecCore support for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
1.Added FspSecCore support for X64.
2.Bumped FSP header revision to 7 to indicate FSP 64bit is supported.
3.Corrected few typos.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf  |   8 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf|   9 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf|   8 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf|  10 +-
 .../FspSecCore/Ia32/FspApiEntryCommon.nasm |   4 +-
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm |   2 +-
 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm| 103 +
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm |  76 
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm  | 262 +++
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm  |  67 +++
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm  | 495 +
 IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm |  34 ++
 IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc  |  11 +
 IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm   |  22 +
 IntelFsp2Pkg/FspSecCore/X64/Stack.nasm |  73 +++
 IntelFsp2Pkg/Include/Guid/FspHeaderFile.h  |  14 +-
 IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc | 284 
 .../Library/BaseFspCommonLib/FspCommonLib.c|   4 +-
 .../Library/BaseFspSwitchStackLib/X64/Stack.nasm   |   5 +-
 19 files changed, 1478 insertions(+), 13 deletions(-)
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Stack.nasm
 create mode 100644 IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc

diff --git a/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf 
b/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf
index 0a24eb2a8b..d64ec12499 100644
--- a/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf
+++ b/IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf
@@ -17,7 +17,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32
+#  VALID_ARCHITECTURES   = IA32 X64
 #
 
 [Sources]
@@ -30,6 +30,12 @@
   Ia32/FspApiEntryCommon.nasm
   Ia32/FspHelper.nasm
 
+[Sources.X64]
+  X64/Stack.nasm
+  X64/Fsp22ApiEntryS.nasm
+  X64/FspApiEntryCommon.nasm
+  X64/FspHelper.nasm
+
 [Binaries.Ia32]
   RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
 
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
index 7b05cae641..34794dd16e 100644
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
@@ -17,7 +17,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32
+#  VALID_ARCHITECTURES   = IA32 X64
 #
 
 [Sources]
@@ -34,6 +34,13 @@
   Ia32/FspHelper.nasm
   Ia32/ReadEsp.nasm
 
+[Sources.X64]
+  X64/Stack.nasm
+  X64/FspApiEntryM.nasm
+  X64/FspApiEntryCommon.nasm
+  X64/FspHelper.nasm
+  X64/ReadRsp.nasm
+
 [Binaries.Ia32]
   RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
 
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf
index 1d9c2554d1..79d4e0674e 100644
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf
@@ -17,7 +17,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32
+#  VALID_ARCHITECTURES   = IA32 X64
 #
 
 [Sources]
@@ -30,6 +30,12 @@
   Ia32/FspApiEntryCommon.nasm
   Ia32/FspHelper.nasm
 
+[Sources.X64]
+  X64/Stack.nasm
+  X64/FspApiEntryS.nasm
+  X64/FspApiEntryCommon.nasm
+  X64/FspHelper.nasm
+
 [Binaries.Ia32]
   RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
 
diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf
index 664bde5678..f08a3b2c2b 100644
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf
@@ -17,17 +17,19 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32
+#  VALID_ARCHITECTURES   = IA32 X64
 #
 
-[Sources]
-
-
 [Sources.IA32]
   Ia32/Stack.nasm
   Ia32/FspApiEntryT.nasm
   Ia32/FspHelper.nasm
 
+[Sources.X64]
+  X64/Stack.nasm
+  X64/FspApiEntryT.nasm
+  X64/FspHelper.nasm
+
 [Binaries.Ia32]
   RAW|Vtf0/Bin/ResetVec.ia32.raw |GCC
 
diff --git 

[edk2-devel][PATCH v4 3/8] IntelFsp2Pkg: Update FSP_GLOBAL_DATA and FSP_PLAT_DATA for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
Updated FSP_GLOBAL_DATA and FSP_PLAT_DATA structures to support
both IA32 and X64.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 IntelFsp2Pkg/FspSecCore/SecFsp.c |  2 +-
 IntelFsp2Pkg/Include/FspGlobalData.h | 51 +---
 2 files changed, 37 insertions(+), 16 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c b/IntelFsp2Pkg/FspSecCore/SecFsp.c
index 85fbc7664c..1ead3c9ce6 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFsp.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c
@@ -130,7 +130,7 @@ FspGlobalDataInit (
   ZeroMem ((VOID *)PeiFspData, sizeof (FSP_GLOBAL_DATA));
 
   PeiFspData->Signature = FSP_GLOBAL_DATA_SIGNATURE;
-  PeiFspData->Version   = 0;
+  PeiFspData->Version   = FSP_GLOBAL_DATA_VERSION;
   PeiFspData->CoreStack = BootLoaderStack;
   PeiFspData->PerfIdx   = 2;
   PeiFspData->PerfSig   = FSP_PERFORMANCE_DATA_SIGNATURE;
diff --git a/IntelFsp2Pkg/Include/FspGlobalData.h 
b/IntelFsp2Pkg/Include/FspGlobalData.h
index 2b534075ae..dcfeed7501 100644
--- a/IntelFsp2Pkg/Include/FspGlobalData.h
+++ b/IntelFsp2Pkg/Include/FspGlobalData.h
@@ -10,8 +10,9 @@
 
 #include 
 
-#define FSP_IN_API_MODE   0
-#define FSP_IN_DISPATCH_MODE  1
+#define FSP_IN_API_MODE 0
+#define FSP_IN_DISPATCH_MODE1
+#define FSP_GLOBAL_DATA_VERSION 1
 
 #pragma pack(1)
 
@@ -28,10 +29,11 @@ typedef enum {
 
 typedef struct  {
   VOID  *DataPtr;
-  UINT32MicrocodeRegionBase;
-  UINT32MicrocodeRegionSize;
-  UINT32CodeRegionBase;
-  UINT32CodeRegionSize;
+  UINTN MicrocodeRegionBase;
+  UINTN MicrocodeRegionSize;
+  UINTN CodeRegionBase;
+  UINTN CodeRegionSize;
+  UINTN Reserved;
 } FSP_PLAT_DATA;
 
 #define FSP_GLOBAL_DATA_SIGNATURESIGNATURE_32 ('F', 'S', 'P', 'D')
@@ -42,15 +44,15 @@ typedef struct  {
   UINT32 Signature;
   UINT8  Version;
   UINT8  Reserved1[3];
+  ///
+  /// Offset 0x08
+  ///
   UINTN  CoreStack;
+  UINTN  Reserved2;
+  ///
+  /// IA32: Offset 0x10; X64: Offset 0x18
+  ///
   UINT32 StatusCode;
-  UINT32 Reserved2[8];
-  FSP_PLAT_DATA  PlatformData;
-  FSP_INFO_HEADER*FspInfoHeader;
-  VOID   *UpdDataPtr;
-  VOID   *TempRamInitUpdPtr;
-  VOID   *MemoryInitUpdPtr;
-  VOID   *SiliconInitUpdPtr;
   UINT8  ApiIdx;
   ///
   /// 0: FSP in API mode; 1: FSP in DISPATCH mode
@@ -60,15 +62,34 @@ typedef struct  {
   UINT8  Reserved3;
   UINT32 NumberOfPhases;
   UINT32 PhasesExecuted;
+  UINT32 Reserved4[8];
   ///
+  /// IA32: Offset 0x40; X64: Offset 0x48
+  /// Start of UINTN and pointer section
+  /// All UINTN and pointer members must be put in this section
+  /// except CoreStack and Reserved2. In addition, the number of
+  /// UINTN and pointer members must be even for natural alignment
+  /// in both IA32 and X64.
+  ///
+  FSP_PLAT_DATA  PlatformData;
+  VOID   *TempRamInitUpdPtr;
+  VOID   *MemoryInitUpdPtr;
+  VOID   *SiliconInitUpdPtr;
+  ///
+  /// IA32: Offset 0x64; X64: Offset 0x90
   /// To store function parameters pointer
   /// so it can be retrieved after stack switched.
   ///
   VOID   *FunctionParameterPtr;
-  UINT8  Reserved4[16];
+  FSP_INFO_HEADER*FspInfoHeader;
+  VOID   *UpdDataPtr;
+  ///
+  /// End of UINTN and pointer section
+  ///
+  UINT8  Reserved5[16];
   UINT32 PerfSig;
   UINT16 PerfLen;
-  UINT16 Reserved5;
+  UINT16 Reserved6;
   UINT32 PerfIdx;
   UINT64 PerfData[32];
 } FSP_GLOBAL_DATA;
-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88828): https://edk2.groups.io/g/devel/message/88828
Mute This Topic: https://groups.io/mt/90433371/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel][PATCH v4 1/8] IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
1.Added EFIAPI to FspNotifyPhasePeimEntryPoint, SwapStack and
  PEI_CORE_ENTRY.
2.Cast FspData from pointer to UINTN and then from UINTN to UINT32.
3.Changed AsmReadEsp to AsmReadStackPointer.
4.Changed the type of the return value of AsmReadStackPointer
  from UINT32 to UINTN.
5.Changed the type of TemporaryMemoryBase, PermenentMemoryBase
  and BootLoaderStack from UINT32 to UINTN.
6..Some type casting to pointers are UINT32. Changed them to
  UINTN to accommodate both IA32 and X64.
7.Corrected some typos.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c   |  1 +
 IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  |  8 
 IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm| 10 +-
 IntelFsp2Pkg/FspSecCore/SecFsp.c   |  8 
 IntelFsp2Pkg/FspSecCore/SecFsp.h   |  2 +-
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c |  8 
 IntelFsp2Pkg/FspSecCore/SecMain.c  |  8 
 IntelFsp2Pkg/FspSecCore/SecMain.h  | 18 ++
 .../Library/BaseFspSwitchStackLib/FspSwitchStackLib.c  |  1 +
 .../Library/SecFspSecPlatformLibNull/Ia32/Flat32.nasm  |  2 +-
 10 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c 
b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
index 88f5540fef..66d39cc70c 100644
--- a/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
+++ b/IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c
@@ -112,6 +112,7 @@ WaitForNotify (
   @retval EFI_OUT_OF_RESOURCES Insufficient resources to create database
 **/
 EFI_STATUS
+EFIAPI
 FspNotifyPhasePeimEntryPoint (
   IN   EFI_PEI_FILE_HANDLE  FileHandle,
   IN CONST EFI_PEI_SERVICES **PeiServices
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
index 8046b43745..d40dad5a52 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm
@@ -9,14 +9,14 @@
 SECTION .text
 
 ;--
-; UINT32
+; UINTN
 ; EFIAPI
-; AsmReadEsp (
+; AsmReadStackPointer (
 ;   VOID
 ;   );
 ;--
-global ASM_PFX(AsmReadEsp)
-ASM_PFX(AsmReadEsp):
+global ASM_PFX(AsmReadStackPointer)
+ASM_PFX(AsmReadStackPointer):
 mov eax, esp
 ret
 
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
index 5a7e27c240..ce20639890 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm
@@ -9,20 +9,20 @@
 ;
 ;--
 
-SECTION .text
+SECTION .text
 
 ;--
 ; VOID
 ; EFIAPI
 ; SecSwitchStack (
 ;   UINT32   TemporaryMemoryBase,
-;   UINT32   PermenentMemoryBase
+;   UINT32   PermanentMemoryBase
 ;   );
 ;--
 global ASM_PFX(SecSwitchStack)
 ASM_PFX(SecSwitchStack):
 ;
-; Save three register: eax, ebx, ecx
+; Save four register: eax, ebx, ecx, edx
 ;
 push  eax
 push  ebx
@@ -55,7 +55,7 @@ ASM_PFX(SecSwitchStack):
 mov   dword [eax + 12], edx
 mov   edx, dword [esp + 16]; Update this function's return address 
into permanent memory
 mov   dword [eax + 16], edx
-mov   esp, eax ; From now, esp is pointed to permanent 
memory
+mov   esp, eax ; From now, esp is pointed to permanent 
memory
 
 ;
 ; Fixup the ebp point to permanent memory
@@ -63,7 +63,7 @@ ASM_PFX(SecSwitchStack):
 mov   eax, ebp
 sub   eax, ebx
 add   eax, ecx
-mov   ebp, eax; From now, ebp is pointed to permanent 
memory
+mov   ebp, eax ; From now, ebp is pointed to permanent 
memory
 
 pop   edx
 pop   ecx
diff --git a/IntelFsp2Pkg/FspSecCore/SecFsp.c b/IntelFsp2Pkg/FspSecCore/SecFsp.c
index 68e588dd41..85fbc7664c 100644
--- a/IntelFsp2Pkg/FspSecCore/SecFsp.c
+++ b/IntelFsp2Pkg/FspSecCore/SecFsp.c
@@ -26,7 +26,7 @@ FspGetExceptionHandler (
   IA32_IDT_GATE_DESCRIPTOR  *IdtGateDescriptor;
   FSP_INFO_HEADER   *FspInfoHeader;
 
-  FspInfoHeader  = (FSP_INFO_HEADER *)AsmGetFspInfoHeader 
();
+  FspInfoHeader  = (FSP_INFO_HEADER 
*)(UINTN)AsmGetFspInfoHeader ();
   ExceptionHandler   = IdtEntryTemplate;
   IdtGateDescriptor  = (IA32_IDT_GATE_DESCRIPTOR 
*)
   Entry  = (IdtGateDescriptor->Bits.OffsetHigh << 
16) | IdtGateDescriptor->Bits.OffsetLow;
@@ -115,7 +115,7 @@ 

[edk2-devel][PATCH v4 0/8] Support PEI 64bit in IntelFsp2Pkg and IntelFsp2WrapperPkg

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893

Currently PEI drivers/libraries only support 32bit in IntelFsp2Pkg and
IntelFsp2WrapperPkg. The patches below are needed to support these
drivers/libraries in 64bit.

V2 changes:
1.Change FSPM_UPD_COMMON2 to FSPM_UPD_COMMON_FSP24 in FspApiEntryM.nasm.
2.Add FSPx_UPD_COMMON_FSP24 in FspApi.h.
3.Add 3 additional patches for supporting X64 in IntelFsp2WrapperPkg.

V3 changes:
1.Update FSPT_ARCH2_UPD and add FSPT_CORE_UPD back.
2.Use 0x instead of MAX_ADDRESS to reflect the default of FspData.
3.Remove EnableMultiPhaseMemoryInit from FSPM_ARCH2_UPD.
4.Bump GenCfgOpt version to 0.57.

V4 changes:
1.Added EFIAPI to SwapStack and PEI_CORE_ENTRY.
2.Cast FspData from pointer to UINTN and then from UINTN to UINT32.
3.Corrected few typos.

Ted Kuo (8):
  IntelFsp2Pkg: X64 compatible changes to support PEI in 64bit
  IntelFsp2Pkg: Add FSPx_ARCH2_UPD support for X64
  IntelFsp2Pkg: Update FSP_GLOBAL_DATA and FSP_PLAT_DATA for X64
  IntelFsp2Pkg: FspSecCore support for X64
  IntelFsp2Pkg: SecFspSecPlatformLibNull support for X64
  IntelFsp2WrapperPkg: Adopt FSPM_UPD_COMMON_FSP24 for X64
  IntelFsp2WrapperPkg: BaseFspWrapperApiLib support for X64
  IntelFsp2WrapperPkg: SecFspWrapperPlatformSecLibSample support for X64

 IntelFsp2Pkg/FspNotifyPhase/FspNotifyPhasePeim.c   |   1 +
 IntelFsp2Pkg/FspSecCore/Fsp22SecCoreS.inf  |   8 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf|   9 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreS.inf|   8 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreT.inf|  10 +-
 .../FspSecCore/Ia32/FspApiEntryCommon.nasm |   4 +-
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm |  30 +-
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm |  96 +++-
 IntelFsp2Pkg/FspSecCore/Ia32/ReadEsp.nasm  |   8 +-
 IntelFsp2Pkg/FspSecCore/Ia32/Stack.nasm|  10 +-
 IntelFsp2Pkg/FspSecCore/SecFsp.c   |  10 +-
 IntelFsp2Pkg/FspSecCore/SecFsp.h   |   2 +-
 IntelFsp2Pkg/FspSecCore/SecFspApiChk.c |   8 +-
 IntelFsp2Pkg/FspSecCore/SecMain.c  |   8 +-
 IntelFsp2Pkg/FspSecCore/SecMain.h  |  18 +-
 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm| 103 +
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm |  76 
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm  | 262 +++
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm  |  67 +++
 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm  | 495 +
 IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm |  34 ++
 IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc  |  11 +
 IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm   |  22 +
 IntelFsp2Pkg/FspSecCore/X64/Stack.nasm |  73 +++
 IntelFsp2Pkg/Include/FspEas/FspApi.h   | 145 +-
 IntelFsp2Pkg/Include/FspGlobalData.h   |  51 ++-
 IntelFsp2Pkg/Include/Guid/FspHeaderFile.h  |  14 +-
 IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc | 284 
 IntelFsp2Pkg/IntelFsp2Pkg.dsc  |   2 +-
 .../Library/BaseFspCommonLib/FspCommonLib.c|   4 +-
 .../BaseFspSwitchStackLib/FspSwitchStackLib.c  |   1 +
 .../Library/BaseFspSwitchStackLib/X64/Stack.nasm   |   5 +-
 .../SecFspSecPlatformLibNull/Ia32/Flat32.nasm  |   2 +-
 .../SecFspSecPlatformLibNull.inf   |   6 +-
 .../SecFspSecPlatformLibNull/X64/Long64.nasm   |  31 ++
 .../SecFspSecPlatformLibNull/X64/SecCarInit.nasm   |  40 ++
 IntelFsp2Pkg/Tools/GenCfgOpt.py|   4 +-
 .../FspmWrapperPeim/FspmWrapperPeim.c  |  25 +-
 .../BaseFspWrapperApiLib/FspWrapperApiLib.c|  42 +-
 .../BaseFspWrapperApiLib/IA32/DispatchExecute.c|  21 +
 .../BaseFspWrapperApiLib/X64/DispatchExecute.c |  45 +-
 .../{Ia32 => }/Fsp.h   |   0
 .../Ia32/Stack.nasm|   6 +-
 .../SecFspWrapperPlatformSecLibSample.inf  |   7 +-
 .../SecRamInitData.c   |  22 +-
 .../X64/PeiCoreEntry.nasm  | 149 +++
 .../X64/SecEntry.nasm  | 171 +++
 .../X64/Stack.nasm |  73 +++
 48 files changed, 2413 insertions(+), 110 deletions(-)
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Fsp22ApiEntryS.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryCommon.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryM.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryS.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspApiEntryT.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/FspHelper.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/MicrocodeLoadNasm.inc
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/ReadRsp.nasm
 create mode 100644 IntelFsp2Pkg/FspSecCore/X64/Stack.nasm
 create mode 100644 IntelFsp2Pkg/Include/SaveRestoreSseAvxNasm.inc
 create mode 

[edk2-devel][PATCH v4 2/8] IntelFsp2Pkg: Add FSPx_ARCH2_UPD support for X64

2022-04-12 Thread Kuo, Ted
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3893
1.Added FSPx_ARCH2_UPD structures which support both IA32 and X64.
2.Added FSPx_UPD_COMMON_FSP24 structures.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Ashraf Ali S 
Signed-off-by: Ted Kuo 
---
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm |  28 +
 IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm |  96 +---
 IntelFsp2Pkg/Include/FspEas/FspApi.h   | 145 -
 IntelFsp2Pkg/Tools/GenCfgOpt.py|   4 +-
 4 files changed, 254 insertions(+), 19 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm
index e7261b41cd..9fa9f28030 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryM.nasm
@@ -32,6 +32,24 @@ struc FSPM_UPD_COMMON
 .size:
 endstruc
 
+struc FSPM_UPD_COMMON_FSP24
+; FSP_UPD_HEADER {
+.FspUpdHeader:  resd  8
+; }
+; FSPM_ARCH2_UPD {
+.Revision:  resb  1
+.Reserved:  resb  3
+.Length resd  1
+.StackBase: resq  1
+.StackSize: resq  1
+.BootLoaderTolumSize:   resd  1
+.BootMode:  resd  1
+.FspEventHandlerresq  1
+.Reserved1: resb 24
+; }
+.size:
+endstruc
+
 ;
 ; Following functions will be provided in C
 ;
@@ -124,12 +142,22 @@ ASM_PFX(FspApiCommonContinue):
   popeax
 
 FspStackSetup:
+  movecx, [edx + FSPM_UPD_COMMON.Revision]
+  cmpecx, 3
+  jaeFspmUpdCommon2
+
   ;
   ; StackBase = temp memory base, StackSize = temp memory size
   ;
   movedi, [edx + FSPM_UPD_COMMON.StackBase]
   movecx, [edx + FSPM_UPD_COMMON.StackSize]
+  jmpChkFspHeapSize
+
+FspmUpdCommon2:
+  movedi, [edx + FSPM_UPD_COMMON_FSP24.StackBase]
+  movecx, [edx + FSPM_UPD_COMMON_FSP24.StackSize]
 
+ChkFspHeapSize:
   ;
   ; Keep using bootloader stack if heap size % is 0
   ;
diff --git a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm 
b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
index 7fd3d6d843..554b143ffa 100644
--- a/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
+++ b/IntelFsp2Pkg/FspSecCore/Ia32/FspApiEntryT.nasm
@@ -84,8 +84,10 @@ struc LoadMicrocodeParamsFsp22
 .FspUpdHeaderRevision:resb1
 .FspUpdHeaderReserved:resb   23
 ; }
-; FSPT_ARCH_UPD{
-.FsptArchUpd: resd8
+; FSPT_ARCH_UPD {
+.FsptArchRevision:resb1
+.FsptArchReserved:resb3
+.FsptArchUpd: resd7
 ; }
 ; FSPT_CORE_UPD {
 .MicrocodeCodeAddr:   resd1
@@ -96,6 +98,28 @@ struc LoadMicrocodeParamsFsp22
 .size:
 endstruc
 
+struc LoadMicrocodeParamsFsp24
+; FSP_UPD_HEADER {
+.FspUpdHeaderSignature:   resd2
+.FspUpdHeaderRevision:resb1
+.FspUpdHeaderReserved:resb   23
+; }
+; FSPT_ARCH2_UPD {
+.FsptArchRevision:resb1
+.FsptArchReserved:resb3
+.FsptArchLength:  resd1
+.FspDebugHandler  resq1
+.FsptArchUpd: resd4
+; }
+; FSPT_CORE_UPD {
+.MicrocodeCodeAddr:   resq1
+.MicrocodeCodeSize:   resq1
+.CodeRegionBase:  resq1
+.CodeRegionSize:  resq1
+; }
+.size:
+endstruc
+
 ;
 ; Define SSE macros
 ;
@@ -172,9 +196,9 @@ ASM_PFX(LoadMicrocodeDefault):
;   Executed by SBSP and NBSP
;   Beginning of microcode update region starts on paragraph boundary
 
-   ;
;
; Save return address to EBP
+   ;
movd   ebp, mm7
 
cmpesp, 0
@@ -188,8 +212,12 @@ ASM_PFX(LoadMicrocodeDefault):
; and report error if size is less than 2k
; first check UPD header revision
cmpbyte [esp + LoadMicrocodeParamsFsp22.FspUpdHeaderRevision], 2
-   jaeFsp22UpdHeader
+   jb Fsp20UpdHeader
+   cmpbyte [esp + LoadMicrocodeParamsFsp22.FsptArchRevision], 2
+   je Fsp24UpdHeader
+   jmpFsp22UpdHeader
 
+Fsp20UpdHeader:
; UPD structure is compliant with FSP spec 2.0/2.1
moveax, dword [esp + LoadMicrocodeParams.MicrocodeCodeSize]
cmpeax, 0
@@ -213,6 +241,19 @@ Fsp22UpdHeader:
movesi, dword [esp + LoadMicrocodeParamsFsp22.MicrocodeCodeAddr]
cmpesi, 0
jnzCheckMainHeader
+   jmpParamError
+
+Fsp24UpdHeader:
+   ; UPD structure is compliant with FSP spec 2.4
+   moveax, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeSize]
+   cmpeax, 0
+   jz Exit2
+   cmpeax, 0800h
+   jl ParamError
+
+   movesi, dword [esp + LoadMicrocodeParamsFsp24.MicrocodeCodeAddr]
+   cmpesi, 0
+   jnzCheckMainHeader
 
 ParamError:
moveax, 08002h
@@ -308,9 +349,13 @@ AdvanceFixedSize:
 
 CheckAddress:
; Check UPD header revision
-   cmpbyte [esp + 

回复: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver.

2022-04-12 Thread gaoliming
Zhihao:
  I remember CI has the check for the package dependency. If this patch passes 
CI, seemly this checker doesn't do. You can see DependencyCheck in 
MdeModulePkg\MdeModulePkg.ci.yaml. 
  And, this patch introduces new dependency in VariableStandaloneMm. It has 
been used in edk2 platform ARM platform. This change will break these platform 
build. Please notify the platform owners. 

Sean and Michael:
  This patch adds UefiCpuPkg library instance SmmCpuRendezvousLib into 
MdeModulePkg.dsc. But, CI can pass. Is this the expected behavior?

Thanks
Liming
> -邮件原件-
> 发件人: Li, Zhihao 
> 发送时间: 2022年4月13日 2:14
> 收件人: Gao, Liming ; devel@edk2.groups.io
> 抄送: Wang, Jian J ; Fu, Siyuan
> ; Ni, Ray ; Kinney, Michael D
> 
> 主题: RE: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use
> SmmWaitForAllProcessor() in VariableSmm driver.
> 
> 1. Although SmmCpuRendezvousLib in UefiCpuPkg, add SmmRendezvousLib.h
> into MdeModulePkg/Include/Library folder bypass the check.
> 2. The SmmRendezvousLib is a standalone MM library and doesn’t have any
> DXE service dependency. It can be used by SMM variable module and MM
> variable module.
> 
> As the patch following, it have passed the Edk2 CI test. The code can run
> successfully in practice, but I'm not sure if this is acceptable in terms of 
> the
> standard.
> 
> -Original Message-
> From: gaoliming 
> Sent: Tuesday, April 12, 2022 9:00 AM
> To: devel@edk2.groups.io; Li, Zhihao 
> Cc: Wang, Jian J ; Fu, Siyuan ;
> Ni, Ray ; Kinney, Michael D 
> Subject: 回复: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use
> SmmWaitForAllProcessor() in VariableSmm driver.
> 
> Zhihao:
>   This patch breaks two things. One is to let MdeModulePkg depend on
> UefiCpuPkg, another is to let VariableStandaloneMm depend on UefiCpuPkg
> SmmCpuRendezvousLib. Please provide your proposal to resolve these two
> dependency first.
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Li, Zhihao
> > 发送时间: 2022年4月11日 15:07
> > 收件人: devel@edk2.groups.io
> > 抄送: Jian J Wang ; Liming Gao
> > ; Siyuan Fu ; Ni Ray
> > ; Michael D Kinney 
> > 主题: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use
> > SmmWaitForAllProcessor() in VariableSmm driver.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3854
> >
> > In UefiCpuPkg, there are a new Protocol with the new service
> > SmmWaitForAllProcessor(), which can be used by SMI handler to
> > optionally wait for other APs to complete SMM rendezvous in relaxed AP
> > mode.
> >
> > This patch use the new service to let VariableSmm driver work normally
> > in relaxed AP mode.
> >
> > Cc: Jian J Wang 
> > Cc: Liming Gao 
> > Cc: Siyuan Fu 
> > Cc: Ni Ray 
> > Cc: Michael D Kinney 
> >
> > Signed-off-by: Zhihao Li 
> > ---
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > | 10 +++-
> >  MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> > | 27 
> >  MdeModulePkg/MdeModulePkg.dec
> > |  5 +++-
> >  MdeModulePkg/MdeModulePkg.dsc
> > |  4 ++-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> > |  3 ++-
> >
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> > |  3 ++-
> >  6 files changed, 47 insertions(+), 5 deletions(-)
> >
> > diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > index 517cae7b00f8..52a9b0e6b202 100644
> > --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > @@ -14,7 +14,7 @@
> >VariableServiceSetVariable(), VariableServiceQueryVariableInfo(),
> > ReclaimForOS(),
> >
> >SmmVariableGetStatistics() should also do validation based on its
> > own knowledge.
> >
> >
> >
> > -Copyright (c) 2010 - 2019, Intel Corporation. All rights
> > reserved.
> >
> > +Copyright (c) 2010 - 2022, Intel Corporation. All rights
> > +reserved.
> >
> >  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> >
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> > @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >  #include 
> >
> >  #include 
> >
> > +#include 
> >
> >
> >
> >  #include 
> >
> >  #include "Variable.h"
> >
> > @@ -656,6 +657,13 @@ SmmVariableHandler (
> >  goto EXIT;
> >
> >}
> >
> >
> >
> > +  if ((SmmVariableHeader->Attributes &
> > EFI_VARIABLE_NON_VOLATILE) != 0) {
> >
> > +if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {
> >
> > +  DEBUG ((DEBUG_ERROR, "SetVariable: fail to wait for all AP
> > check in SMM!\n"));
> >
> > +  goto EXIT;
> >
> > +}
> >
> > +  }
> >
> > +
> >
> >Status = VariableServiceSetVariable (
> >
> >   SmmVariableHeader->Name,
> >
> >   >Guid,
> >
> > diff --git a/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> > b/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> > new file mode 100644
> > index ..82e459e9106e

[edk2-devel] 回复: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-12 Thread gaoliming
Guomin:
  Can you introduce DEBUG_FILE_PATH usage? If the developer wants to enable
this feature, how configure DEBUG_FILE_PATH?

Thanks
Liming
> -邮件原件-
> 发件人: Guomin Jiang 
> 发送时间: 2022年4月12日 18:25
> 收件人: devel@edk2.groups.io
> 抄送: Michael D Kinney ; Liming Gao
> ; Zhiguang Liu 
> 主题: [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify
> debug file path.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840
> 
> Use DEBUG_FILE_PATH to control ASSERT path
> 
> Motivation and Goal:
> 1. Make replication build more easy and less toolchain dependency
> 2. Consume the ASSERT string easy for downstream
> 3. Make code more clear
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Signed-off-by: Guomin Jiang 
> ---
>  MdePkg/Include/Library/DebugLib.h | 34 +--
>  1 file changed, 23 insertions(+), 11 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/DebugLib.h
> b/MdePkg/Include/Library/DebugLib.h
> index 8d3d08638d73..a76a268a00b6 100644
> --- a/MdePkg/Include/Library/DebugLib.h
> +++ b/MdePkg/Include/Library/DebugLib.h
> @@ -8,7 +8,7 @@
>of size reduction when compiler optimization is disabled. If
> MDEPKG_NDEBUG is
>defined, then debug and assert related macros wrapped by it are the
> NULL implementations.
> 
> -Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
>  **/
> @@ -85,6 +85,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #define DEBUG_LINE_NUMBER  __LINE__
>  #endif
> 
> +//
> +// Source file path.
> +// Default is use the __FILE__ macro value provided by compiler. The
> __FILE__
> +// mapping can be overriden by predefining DEBUG_FILE_PATH
> +//
> +// Defining DEBUG_FILE_PATH to a fixed value is useful when comparing
> builds
> +// across machine or configuration with different slash or path file.
> +//
> +#ifndef DEBUG_FILE_PATH
> +#define DEBUG_FILE_PATH  __FILE__
> +#endif
> +
> +//
> +// Use below override to keep CLANG specific behavior
> +//
> +#if defined (__clang__) && defined (__FILE_NAME__)
> +  #undef DEBUG_FILE_PATH
> +#define DEBUG_FILE_PATH  __FILE_NAME__
> +#endif
> +
>  /**
>Macro that converts a Boolean expression to a Null-terminated ASCII
> string.
> 
> @@ -337,17 +357,9 @@ UnitTestDebugAssert (
>IN CONST CHAR8  *Description
>);
> 
> -  #if defined (__clang__) && defined (__FILE_NAME__)
> -#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #else
> -#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #endif
> +#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE_PATH,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
>  #else
> -  #if defined (__clang__) && defined (__FILE_NAME__)
> -#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #else
> -#define _ASSERT(Expression)  DebugAssert (__FILE__,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
> -  #endif
> +#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE_PATH,
> DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
>  #endif
> 
>  /**
> --
> 2.35.1.windows.2





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88823): https://edk2.groups.io/g/devel/message/88823
Mute This Topic: https://groups.io/mt/90431898/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] 回复: 回复: [PATCH v3 0/8] Add Variable Flash Info HOB

2022-04-12 Thread gaoliming
Michael:
  Thanks for your update. Reviewed-by: Liming Gao  
for this patch set.

Thanks
Liming
> -邮件原件-
> 发件人: Michael Kubacki 
> 发送时间: 2022年4月13日 0:32
> 收件人: gaoliming ; devel@edk2.groups.io
> 抄送: 'Abner Chang' ; 'Andrew Fish'
> ; 'Anthony Perard' ; 'Ard
> Biesheuvel' ; 'Benjamin You'
> ; 'Brijesh Singh' ; 'Erdem
> Aktas' ; 'Gerd Hoffmann' ;
> 'Guo Dong' ; 'Hao A Wu' ;
> 'James Bottomley' ; 'Jian J Wang'
> ; 'Jiewen Yao' ; 'Jordan
> Justen' ; 'Julien Grall' ; 'Leif
> Lindholm' ; 'Maurice Ma'
> ; 'Min Xu' ; 'Nickle Wang'
> ; 'Peter Grehan' ; 'Ray Ni'
> ; 'Rebecca Cran' ; 'Sami Mujawar'
> ; 'Sean Rhodes' ;
> 'Sebastien Boeuf' ; 'Tom Lendacky'
> 
> 主题: Re: 回复: [PATCH v3 0/8] Add Variable Flash Info HOB
> 
> Hi Liming,
> 
> To help move reviews along, I went ahead and sent a v4 patch series with
> the following information:
> 
> 1. More details about when the HOB is required.
> 2. More details about when the HOB should be installed in the boot flow.
> 3. A 4 byte reserved field after the "Version" field.
> 
> The details are in MdeModulePkg/Include/Guid/VariableFlashInfo.h
> 
> V4: https://edk2.groups.io/g/devel/message/88787
> CI PR: https://github.com/tianocore/edk2/pull/2768
> 
> Regards,
> Michael
> 
> On 4/11/2022 9:25 PM, gaoliming wrote:
> > Michael:
> >Can you give the suggestion about how to install this variable flash info
> > hob when it is required? Because VariablePei is early PEIM, how to make
> sure
> > the variable flash info hob is installed before GetVariable is called?
> >
> >On VARIABLE_FLASH_INFO structure definition, the first field is UINT32,
> > other fields are all UINT64. How about reserve 4 bytes after the first
> > field? If so, all fields are at the nature alignment address.
> >
> > Thanks
> > Liming
> >> -邮件原件-
> >> 发件人: mikub...@linux.microsoft.com
> 
> >> 发送时间: 2022年4月12日 1:42
> >> 收件人: devel@edk2.groups.io
> >> 抄送: Abner Chang ; Andrew Fish
> >> ; Anthony Perard ; Ard
> >> Biesheuvel ; Benjamin You
> >> ; Brijesh Singh ;
> Erdem
> >> Aktas ; Gerd Hoffmann ;
> >> Guo Dong ; Hao A Wu ;
> James
> >> Bottomley ; Jian J Wang ;
> >> Jiewen Yao ; Jordan Justen
> >> ; Julien Grall ; Leif Lindholm
> >> ; Liming Gao ;
> >> Maurice Ma ; Min Xu ;
> >> Nickle Wang ; Peter Grehan
> ;
> >> Ray Ni ; Rebecca Cran ; Sami
> >> Mujawar ; Sean Rhodes
> ;
> >> Sebastien Boeuf ; Tom Lendacky
> >> 
> >> 主题: [PATCH v3 0/8] Add Variable Flash Info HOB
> >>
> >> From: Michael Kubacki 
> >>
> >> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479
> >>
> >> The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
> >> VariableStandaloneMm, etc. (and their dependent protocol/library
> >> stack), typically acquire UEFI variable store flash information
> >> with PCDs declared in MdeModulePkg.
> >>
> >> For example:
> >> [Pcd]
> >>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
> >>
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
> >>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
> >>
> >> These PCDs work as-is in the StandaloneMm driver if they are not
> >> dynamic such as Dynamic or DynamicEx because PCD services are not
> >> readily available in the Standalone MM environment. Platforms that
> >> use Standalone MM today, must define these PCDs as FixedAtBuild in
> >> their platform build. However, the PCDs do allow platforms to treat
> >> the PCDs as Dynamic/DynamicEx and being able to support that is
> >> currently a gap for Standalone MM.
> >>
> >> This patch series introduces a HOB that can be produced by the
> >> platform to provide the same information. The HOB list is
> >> available to Standalone MM.
> >>
> >> The PCD declarations are left as-is in MdeModulePkg for backward
> >> compatibility. This means unless a platform wants to use the HOB,
> >> their code will continue to work with no change (they do not need
> >> to produce the HOB). Only if the HOB is found, is its value used
> >> instead of the PCDs.
> >>
> >> Due to the large number of consumers of this information, access
> >> to the base address and size values is abstracted in a new library
> >> class (as requested in the v1 series) called VariableFlashInfoLib.
> >>
> >> The API of VariableFlashInfoLib does not bind the underlying data
> >> structure to the information returned to library users to allow
> >> flexibility in the library implementation in the future.
> >>
> >> V3 changes:
> >> 1. To better clarify usage, renamed the members
> >> "NvStorageBaseAddress" and "NvStorageLength" in
> >> "VARIABLE_FLASH_INFO" to "NvVariableBaseAddress" and
> >> "NvVariableLength".
> >> 2. Added description comments to the fields in "VARIABLE_FLASH_INFO".
> >>
> >> V2 changes:
> >> 1. Abstracted flash info data access with VariableFlashInfoLib.
> >> 2. Updated package builds in the repo that build the variable and
> >> FTW drivers to include VariableFlashInfoLib.
> >> 3. Removed a redundant variable assignment in VariableSmm.c.
> >> 4. Updated 

[edk2-devel] [PATCH v2 13/14] UefiPayloadPkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Signed-off-by: Yu Pu 
---
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 1 -
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf  | 1 -
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 1 -
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 -
 4 files changed, 4 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index d1c7425b28f2..ad8a9fd22b66 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -24,7 +24,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index 95446dd99729..d47e8e76cf4c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -55,7 +55,6 @@
   PeCoffLib
   PlatformSupportLib
   CpuLib
-  UefiCpuLib
 
 [Guids]
   gEfiMemoryTypeInformationGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 3b4836042a06..c4f4f28eaa86 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -53,7 +53,6 @@
   HobLib
   PeCoffLib
   CpuLib
-  UefiCpuLib
 
 [Guids]
   gEfiMemoryTypeInformationGuid
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 14a8d157a292..d0527e6e5bce 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -200,7 +200,6 @@
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
   
DxeServicesTableLib|MdePkg/Library/DxeServicesTableLib/DxeServicesTableLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   SortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
 
   #
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88820): https://edk2.groups.io/g/devel/message/88820
Mute This Topic: https://groups.io/mt/90431730/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 12/14] UefiCpuPkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Yu Pu 
---
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c   | 1 -
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c   | 1 -
 UefiCpuPkg/CpuDxe/CpuDxe.h   | 1 -
 UefiCpuPkg/CpuDxe/CpuDxe.inf | 1 -
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 1 -
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 1 -
 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf| 1 -
 UefiCpuPkg/Library/MpInitLib/MpLib.h | 1 -
 UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf| 1 -
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h   | 1 -
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 1 -
 UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfileInternal.h   | 1 -
 UefiCpuPkg/SecCore/SecCore.inf   | 1 -
 UefiCpuPkg/SecCore/SecCoreNative.inf | 1 -
 UefiCpuPkg/SecCore/SecMain.h | 1 -
 15 files changed, 15 deletions(-)

diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c 
b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
index a944c3d01cf7..008b8a070bf9 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
@@ -22,7 +22,6 @@
 #include 
 #include 
 #include 
-#include 
 
 //
 // Library internal functions
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c 
b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index 8b3630d7a302..f00c9bf4c05f 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -23,7 +23,6 @@
 #include 
 #include 
 #include 
-#include 
 
 //
 // Library internal functions
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.h b/UefiCpuPkg/CpuDxe/CpuDxe.h
index 2208671cb932..49a390b4c404 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.h
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.h
@@ -28,7 +28,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf
index d87fe503d152..c14ee3f2784a 100644
--- a/UefiCpuPkg/CpuDxe/CpuDxe.inf
+++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf
@@ -33,7 +33,6 @@
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   LocalApicLib
-  UefiCpuLib
   UefiLib
   CpuExceptionHandlerLib
   HobLib
diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf 
b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
index a85b69e0a11c..8c4eb655481d 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
@@ -39,7 +39,6 @@
   IoLib
   PcdLib
   CpuLib
-  UefiCpuLib
 
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds  ## 
SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf 
b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
index 31ebdd39c616..713f1859c2e7 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
@@ -39,7 +39,6 @@
   IoLib
   PcdLib
   CpuLib
-  UefiCpuLib
 
 [Pcd]
   gUefiCpuPkgTokenSpaceGuid.PcdCpuInitIpiDelayInMicroSeconds  ## 
SOMETIMES_CONSUMES
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf 
b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
index e1cd0b350008..7450d9c729c9 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
@@ -49,7 +49,6 @@
   HobLib
   MtrrLib
   CpuLib
-  UefiCpuLib
   UefiBootServicesTableLib
   DebugAgentLib
   SynchronizationLib
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f8c52426dd5f..693211ae3508 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf 
b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
index 5facf4db9499..98864c648438 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf
@@ -49,7 +49,6 @@
   HobLib
   MtrrLib
   CpuLib
-  UefiCpuLib
   SynchronizationLib
   PeiServicesLib
   PcdLib
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index dfeceec2aadc..d3a6e1702fdd 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -44,7 +44,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf 

[edk2-devel] [PATCH v2 14/14] UefiCpuLib: Remove UefiCpuLib.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib and all modules
are updated to not depend on this library, remove it completely.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Yu Pu 
---
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c | 16 -
 UefiCpuPkg/Include/Library/UefiCpuLib.h| 16 -
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf   | 35 

 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni   | 16 -
 UefiCpuPkg/UefiCpuPkg.dec  |  5 ---
 UefiCpuPkg/UefiCpuPkg.dsc  |  2 --
 6 files changed, 90 deletions(-)

diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c 
b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c
deleted file mode 100644
index eaecd4ae5ed7..
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/** @file
-This library contains a dummy function to pass build.
-
-Copyright (c) 2022, Intel Corporation. All rights reserved.
-
-SPDX-License-Identifier: BSD-2-Clause-Patent
-**/
-#include 
-STATIC
-VOID
-Dummy (
-  VOID
-  )
-{
-
-}
diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h 
b/UefiCpuPkg/Include/Library/UefiCpuLib.h
deleted file mode 100644
index ab6982db6e9c..
--- a/UefiCpuPkg/Include/Library/UefiCpuLib.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/** @file
-  Public header file for UEFI CPU library class.
-
-  This library class defines some routines that are generic for IA32 family CPU
-  to be UEFI specification compliant.
-
-  Copyright (c) 2009 - 2021, Intel Corporation. All rights reserved.
-  Copyright (c) 2020, AMD Inc. All rights reserved.
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef __UEFI_CPU_LIB_H__
-#define __UEFI_CPU_LIB_H__
-
-#endif
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf 
b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
deleted file mode 100644
index 9f8b62d87aae..
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
+++ /dev/null
@@ -1,35 +0,0 @@
-## @file
-#  This library defines some routines that are generic for IA32 family CPU.
-#
-#  The library routines are UEFI specification compliant.
-#
-#  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-#  Copyright (c) 2020, AMD Inc. All rights reserved.
-#  SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
-  INF_VERSION= 0x00010005
-  BASE_NAME  = BaseUefiCpuLib
-  MODULE_UNI_FILE= BaseUefiCpuLib.uni
-  FILE_GUID  = 34C24FD7-7A90-45c2-89FD-946473D9CE98
-  MODULE_TYPE= BASE
-  VERSION_STRING = 1.0
-  LIBRARY_CLASS  = UefiCpuLib
-
-#
-# The following information is for reference only and not required by the 
build tools.
-#
-#  VALID_ARCHITECTURES   = IA32 X64
-#
-
-[Sources]
-  BaseUefiCpuLibNull.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  UefiCpuPkg/UefiCpuPkg.dec
-
-[LibraryClasses]
-  BaseLib
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni 
b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni
deleted file mode 100644
index 83c96cea67ce..
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni
+++ /dev/null
@@ -1,16 +0,0 @@
-// /** @file
-// This library defines some routines that are generic for IA32 family CPU.
-//
-// The library routines are UEFI specification compliant.
-//
-// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
-//
-// SPDX-License-Identifier: BSD-2-Clause-Patent
-//
-// **/
-
-
-#string STR_MODULE_ABSTRACT #language en-US "Defines generic 
routines for IA32 family CPUs."
-
-#string STR_MODULE_DESCRIPTION  #language en-US "The library routines 
comply with the UEFI Specification."
-
diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index 525cde463435..e40d78348f75 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -18,11 +18,6 @@
   Include
 
 [LibraryClasses]
-  ##  @libraryclass  Defines some routines that are generic for IA32 family CPU
-  ## to be UEFI specification compliant.
-  ##
-  UefiCpuLib|Include/Library/UefiCpuLib.h
-
   ##  @libraryclass  Defines some routines that are used to 
register/manage/program
   ## CPU features.
   ##
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index a0bbde9985d3..985a271f18cf 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -31,7 +31,6 @@
   SerialPortLib|MdePkg/Library/BaseSerialPortLibNull/BaseSerialPortLibNull.inf
   
DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
   DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   

[edk2-devel] [PATCH v2 11/14] SourceLevelDebugPkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Hao A Wu 
Signed-off-by: Yu Pu 
---
 SourceLevelDebugPkg/SourceLevelDebugPkg.dsc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc 
b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
index eba64a7b7877..986dd5a769d3 100644
--- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
+++ b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
@@ -35,7 +35,6 @@
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   
SynchronizationLib|MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
   LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
   
PeCoffExtraActionLib|SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88818): https://edk2.groups.io/g/devel/message/88818
Mute This Topic: https://groups.io/mt/90431728/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 09/14] OvmfPkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Signed-off-by: Yu Pu 
---
 OvmfPkg/Sec/SecMain.c  | 1 -
 OvmfPkg/AmdSev/AmdSevX64.dsc   | 1 -
 OvmfPkg/Bhyve/BhyveX64.dsc | 1 -
 OvmfPkg/CloudHv/CloudHvX64.dsc | 1 -
 OvmfPkg/Microvm/MicrovmX64.dsc | 1 -
 OvmfPkg/OvmfPkgIa32.dsc| 1 -
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 -
 OvmfPkg/OvmfPkgX64.dsc | 1 -
 OvmfPkg/OvmfXen.dsc| 1 -
 OvmfPkg/Sec/SecMain.inf| 1 -
 10 files changed, 10 deletions(-)

diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 2c9e439800c7..012ba0ede88a 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -18,7 +18,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index fd56176796d5..6a8dd3c1204a 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -161,7 +161,6 @@
   
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
   
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index 5fa08bebd73c..567a44290258 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -159,7 +159,6 @@
   
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index b4d855d80f56..a543bea6f8cb 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -171,7 +171,6 @@
   
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
   QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 1ea43443ae97..65a8c5698284 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -169,7 +169,6 @@
   
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 85abed24c1a7..8210eb447d5e 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -167,7 +167,6 @@
   
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
   UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
   
SerializeVariablesLib|OvmfPkg/Library/SerializeVariablesLib/SerializeVariablesLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a9c1daecc1a8..806ae6696631 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -171,7 +171,6 @@
   

[edk2-devel] [PATCH v2 10/14] PcAtChipsetPkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Ray Ni 
Signed-off-by: Yu Pu 
---
 PcAtChipsetPkg/PcAtChipsetPkg.dsc | 1 -
 1 file changed, 1 deletion(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc 
b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
index 451e60ddc857..2f02ecf6fd11 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
@@ -42,7 +42,6 @@
   ResetSystemLib|PcAtChipsetPkg/Library/ResetSystemLib/ResetSystemLib.inf
   IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
   LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
 
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88817): https://edk2.groups.io/g/devel/message/88817
Mute This Topic: https://groups.io/mt/90431727/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 08/14] IntelFsp2Pkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Yu Pu
Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
dependency of UefiCpuLib.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Yu Pu 
---
 IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 1 -
 IntelFsp2Pkg/FspSecCore/SecMain.h   | 1 -
 IntelFsp2Pkg/IntelFsp2Pkg.dsc   | 1 -
 IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc | 1 -
 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf | 1 -
 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf | 1 -
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 -
 7 files changed, 7 deletions(-)

diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
index 830471adcf2f..c07b49c4045f 100644
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
@@ -52,7 +52,6 @@
   FspCommonLib
   FspSecPlatformLib
   CpuLib
-  UefiCpuLib
 
 [Pcd]
   gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase  ## CONSUMES
diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h 
b/IntelFsp2Pkg/FspSecCore/SecMain.h
index edb7447d9eff..7288086cc493 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.h
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.h
@@ -21,7 +21,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 typedef VOID (*PEI_CORE_ENTRY) ( \
diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
index c1414f7e75b8..b90be5397d37 100644
--- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
+++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
@@ -27,7 +27,6 @@
   PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   
UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
 
   
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
diff --git a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc 
b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
index 961576c9a73a..31558121185d 100644
--- a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
+++ b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
@@ -107,7 +107,6 @@
   
PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatformHookLibNull.inf
   
PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf
   
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
 !if $(TARGET) == DEBUG
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf 
b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
index e2262d693c55..77af97207990 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
@@ -38,7 +38,6 @@
   FspWrapperPlatformLib
   FspWrapperHobProcessLib
   CpuLib
-  UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
   PerformanceLib
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf 
b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
index 0598f85ab3ac..cad9fad96829 100644
--- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
@@ -39,7 +39,6 @@
   FspWrapperPlatformLib
   FspWrapperHobProcessLib
   CpuLib
-  UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
   PerformanceLib
diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc 
b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
index 21e089000eaf..233cb3d9ce2b 100644
--- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
+++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
@@ -41,7 +41,6 @@
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
 
   # UefiCpuPkg
-  UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
   LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
 
   # FSP Wrapper Lib
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88815): https://edk2.groups.io/g/devel/message/88815
Mute This Topic: https://groups.io/mt/90431725/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 05/14] UefiCpuPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Yu Pu 
---
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c   | 1 +
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c   | 1 +
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf | 1 +
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf | 1 +
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h   | 1 +
 UefiCpuPkg/SecCore/SecCore.inf   | 1 +
 UefiCpuPkg/SecCore/SecCoreNative.inf | 1 +
 UefiCpuPkg/SecCore/SecMain.h | 1 +
 8 files changed, 8 insertions(+)

diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c 
b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
index f9e06b2fca45..a944c3d01cf7 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 //
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c 
b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
index aaa42ff8450b..8b3630d7a302 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 //
diff --git a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf 
b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
index 561baa44b0e6..a85b69e0a11c 100644
--- a/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
+++ b/UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf
@@ -38,6 +38,7 @@
   TimerLib
   IoLib
   PcdLib
+  CpuLib
   UefiCpuLib
 
 [Pcd]
diff --git a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf 
b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
index 1e2a4f8b790f..31ebdd39c616 100644
--- a/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
+++ b/UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
@@ -38,6 +38,7 @@
   TimerLib
   IoLib
   PcdLib
+  CpuLib
   UefiCpuLib
 
 [Pcd]
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index aed872836c99..dfeceec2aadc 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -43,6 +43,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/UefiCpuPkg/SecCore/SecCore.inf b/UefiCpuPkg/SecCore/SecCore.inf
index ded83beb5272..f021997f271c 100644
--- a/UefiCpuPkg/SecCore/SecCore.inf
+++ b/UefiCpuPkg/SecCore/SecCore.inf
@@ -47,6 +47,7 @@
   PlatformSecLib
   PcdLib
   DebugAgentLib
+  CpuLib
   UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
diff --git a/UefiCpuPkg/SecCore/SecCoreNative.inf 
b/UefiCpuPkg/SecCore/SecCoreNative.inf
index b528c5987947..e0a1b44a7e23 100644
--- a/UefiCpuPkg/SecCore/SecCoreNative.inf
+++ b/UefiCpuPkg/SecCore/SecCoreNative.inf
@@ -44,6 +44,7 @@
   PlatformSecLib
   PcdLib
   DebugAgentLib
+  CpuLib
   UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
diff --git a/UefiCpuPkg/SecCore/SecMain.h b/UefiCpuPkg/SecCore/SecMain.h
index 029bee3e7e40..189fcf932625 100644
--- a/UefiCpuPkg/SecCore/SecMain.h
+++ b/UefiCpuPkg/SecCore/SecMain.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88812): https://edk2.groups.io/g/devel/message/88812
Mute This Topic: https://groups.io/mt/90431722/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 06/14] UefiPayloadPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Signed-off-by: Yu Pu 
---
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 1 +
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf  | 1 +
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 1 +
 3 files changed, 3 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 56e0a4c639a0..d1c7425b28f2 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index c4e4339ede4b..95446dd99729 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -54,6 +54,7 @@
   HobLib
   PeCoffLib
   PlatformSupportLib
+  CpuLib
   UefiCpuLib
 
 [Guids]
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 80af5afe0a3f..3b4836042a06 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -52,6 +52,7 @@
   IoLib
   HobLib
   PeCoffLib
+  CpuLib
   UefiCpuLib
 
 [Guids]
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88813): https://edk2.groups.io/g/devel/message/88813
Mute This Topic: https://groups.io/mt/90431723/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 07/14] MdePkg: Move API and implementation from UefiCpuLib to CpuLib

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib. This
patch merges UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Yu Pu 
---
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c => 
MdePkg/Library/BaseCpuLib/X86BaseCpuLib.c |  2 +-
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c 
 | 16 +++
 MdePkg/Include/Library/CpuLib.h
 | 48 +++
 MdePkg/Library/BaseCpuLib/BaseCpuLib.inf   
 |  6 +++
 {UefiCpuPkg/Library/BaseUefiCpuLib => 
MdePkg/Library/BaseCpuLib}/Ia32/InitializeFpu.nasm|  0
 {UefiCpuPkg/Library/BaseUefiCpuLib => 
MdePkg/Library/BaseCpuLib}/X64/InitializeFpu.nasm |  0
 UefiCpuPkg/Include/Library/UefiCpuLib.h
 | 49 
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf   
 |  8 +---
 8 files changed, 72 insertions(+), 57 deletions(-)

diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c 
b/MdePkg/Library/BaseCpuLib/X86BaseCpuLib.c
similarity index 93%
rename from UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
rename to MdePkg/Library/BaseCpuLib/X86BaseCpuLib.c
index 5d925bc273f8..1cad32a4beb0 100644
--- a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c
+++ b/MdePkg/Library/BaseCpuLib/X86BaseCpuLib.c
@@ -13,7 +13,7 @@
 #include 
 
 #include 
-#include 
+#include 
 
 /**
   Determine if the standard CPU signature is "AuthenticAMD".
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c 
b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c
new file mode 100644
index ..eaecd4ae5ed7
--- /dev/null
+++ b/UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLibNull.c
@@ -0,0 +1,16 @@
+/** @file
+This library contains a dummy function to pass build.
+
+Copyright (c) 2022, Intel Corporation. All rights reserved.
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+#include 
+STATIC
+VOID
+Dummy (
+  VOID
+  )
+{
+
+}
diff --git a/MdePkg/Include/Library/CpuLib.h b/MdePkg/Include/Library/CpuLib.h
index 25f6d9478c52..3f29937dc71b 100644
--- a/MdePkg/Include/Library/CpuLib.h
+++ b/MdePkg/Include/Library/CpuLib.h
@@ -41,4 +41,52 @@ CpuFlushTlb (
   VOID
   );
 
+#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
+
+/**
+  Initializes floating point units for requirement of UEFI specification.
+  This function initializes floating-point control word to 0x027F (all 
exceptions
+  masked,double-precision, round-to-nearest) and multimedia-extensions control 
word
+  (if supported) to 0x1F80 (all exceptions masked, round-to-nearest, flush to 
zero
+  for masked underflow).
+**/
+VOID
+EFIAPI
+InitializeFloatingPointUnits (
+  VOID
+  );
+
+/**
+  Determine if the standard CPU signature is "AuthenticAMD".
+  @retval TRUE  The CPU signature matches.
+  @retval FALSE The CPU signature does not match.
+**/
+BOOLEAN
+EFIAPI
+StandardSignatureIsAuthenticAMD (
+  VOID
+  );
+
+/**
+  Return the 32bit CPU family and model value.
+  @return CPUID[01h].EAX with Processor Type and Stepping ID cleared.
+**/
+UINT32
+EFIAPI
+GetCpuFamilyModel (
+  VOID
+  );
+
+/**
+  Return the CPU stepping ID.
+  @return CPU stepping ID value in CPUID[01h].EAX.
+**/
+UINT8
+EFIAPI
+GetCpuSteppingId (
+  VOID
+  );
+
+#endif
+
 #endif
diff --git a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf 
b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
index 950f5229b2a4..7cdbb552c08c 100644
--- a/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
+++ b/MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
@@ -28,6 +28,9 @@
 #  VALID_ARCHITECTURES   = IA32 X64 EBC ARM AARCH64 RISCV64
 #
 
+[Sources.IA32, Sources.X64]
+  X86BaseCpuLib.c
+
 [Sources.IA32]
   Ia32/CpuSleep.c | MSFT
   Ia32/CpuFlushTlb.c | MSFT
@@ -38,10 +41,13 @@
   Ia32/CpuSleepGcc.c | GCC
   Ia32/CpuFlushTlbGcc.c | GCC
 
+  Ia32/InitializeFpu.nasm
+
 [Sources.X64]
   X64/CpuFlushTlb.nasm
   X64/CpuSleep.nasm
 
+  X64/InitializeFpu.nasm
 
 [Sources.EBC]
   Ebc/CpuSleepFlushTlb.c
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm 
b/MdePkg/Library/BaseCpuLib/Ia32/InitializeFpu.nasm
similarity index 100%
rename from UefiCpuPkg/Library/BaseUefiCpuLib/Ia32/InitializeFpu.nasm
rename to MdePkg/Library/BaseCpuLib/Ia32/InitializeFpu.nasm
diff --git a/UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm 
b/MdePkg/Library/BaseCpuLib/X64/InitializeFpu.nasm
similarity index 100%
rename from UefiCpuPkg/Library/BaseUefiCpuLib/X64/InitializeFpu.nasm
rename to MdePkg/Library/BaseCpuLib/X64/InitializeFpu.nasm
diff --git a/UefiCpuPkg/Include/Library/UefiCpuLib.h 
b/UefiCpuPkg/Include/Library/UefiCpuLib.h
index 0ff4a35774c1..ab6982db6e9c 100644
--- a/UefiCpuPkg/Include/Library/UefiCpuLib.h
+++ b/UefiCpuPkg/Include/Library/UefiCpuLib.h
@@ -13,53 

[edk2-devel] [PATCH v2 04/14] OvmfPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Gerd Hoffmann 
Signed-off-by: Yu Pu 
---
 OvmfPkg/Sec/SecMain.c   | 1 +
 OvmfPkg/Sec/SecMain.inf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/OvmfPkg/Sec/SecMain.c b/OvmfPkg/Sec/SecMain.c
index 2c5561661ef3..2c9e439800c7 100644
--- a/OvmfPkg/Sec/SecMain.c
+++ b/OvmfPkg/Sec/SecMain.c
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/OvmfPkg/Sec/SecMain.inf b/OvmfPkg/Sec/SecMain.inf
index 95cf0025e100..6ad366a89333 100644
--- a/OvmfPkg/Sec/SecMain.inf
+++ b/OvmfPkg/Sec/SecMain.inf
@@ -44,6 +44,7 @@
   BaseMemoryLib
   PeiServicesLib
   PcdLib
+  CpuLib
   UefiCpuLib
   DebugAgentLib
   IoLib
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88811): https://edk2.groups.io/g/devel/message/88811
Mute This Topic: https://groups.io/mt/90431721/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 03/14] IntelFsp2WrapperPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Yu Pu 
---
 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf | 1 +
 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf | 1 +
 2 files changed, 2 insertions(+)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf 
b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
index 5d0e0214015f..e2262d693c55 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
@@ -37,6 +37,7 @@
   HobLib
   FspWrapperPlatformLib
   FspWrapperHobProcessLib
+  CpuLib
   UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
diff --git a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf 
b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
index da0049a65435..0598f85ab3ac 100644
--- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
+++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
@@ -38,6 +38,7 @@
   MemoryAllocationLib
   FspWrapperPlatformLib
   FspWrapperHobProcessLib
+  CpuLib
   UefiCpuLib
   PeCoffGetEntryPointLib
   PeCoffExtraActionLib
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88810): https://edk2.groups.io/g/devel/message/88810
Mute This Topic: https://groups.io/mt/90431720/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 02/14] IntelFsp2Pkg: Add CpuLib to module INFs that depend on UefiCpuLib

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Signed-off-by: Yu Pu 
---
 IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 1 +
 IntelFsp2Pkg/FspSecCore/SecMain.h   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf 
b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
index 7b05cae64130..830471adcf2f 100644
--- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
+++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
@@ -51,6 +51,7 @@
   FspSwitchStackLib
   FspCommonLib
   FspSecPlatformLib
+  CpuLib
   UefiCpuLib
 
 [Pcd]
diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h 
b/IntelFsp2Pkg/FspSecCore/SecMain.h
index 7794255af13d..edb7447d9eff 100644
--- a/IntelFsp2Pkg/FspSecCore/SecMain.h
+++ b/IntelFsp2Pkg/FspSecCore/SecMain.h
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88809): https://edk2.groups.io/g/devel/message/88809
Mute This Topic: https://groups.io/mt/90431719/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 01/14] MdePkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Yu Pu
There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
failure, add CpuLib dependency to all modules that depend on UefiCpuLib.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Yu Pu 
---
 MdePkg/MdeLibs.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdePkg/MdeLibs.dsc.inc b/MdePkg/MdeLibs.dsc.inc
index 3c70daf87a0c..015ce46f7d3b 100644
--- a/MdePkg/MdeLibs.dsc.inc
+++ b/MdePkg/MdeLibs.dsc.inc
@@ -13,3 +13,4 @@
 
 [LibraryClasses]
   
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
+  CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
-- 
2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88808): https://edk2.groups.io/g/devel/message/88808
Mute This Topic: https://groups.io/mt/90431718/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 00/14] merge UefiCpuPkg/UefiCpuLib to MdePkg/CpuLib

2022-04-12 Thread Yu Pu
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3394

Today lots of duplicated code call CPUID and calculates the address 
mask. Adding an API named GetPhysicalAddressBits in UefiCpuLib can 
solve this problem, but at the same time cause MdeModulePkg depend 
on UefiCpuPkg which does not meet the design spec. So merge UefiCpuLib 
to CpuLib is a good way to sovle these problems. To minimize the impact,
this change is carried out in four steps.

Yu Pu (14):
  MdePkg: Add CpuLib to module INFs that depend on UefiCpuLib.
  IntelFsp2Pkg: Add CpuLib to module INFs that depend on UefiCpuLib
  IntelFsp2WrapperPkg: Add CpuLib to module INFs that depend on
UefiCpuLib.
  OvmfPkg: Add CpuLib to module INFs that depend on  UefiCpuLib.
  UefiCpuPkg: Add CpuLib to module INFs that depend on  UefiCpuLib.
  UefiPayloadPkg: Add CpuLib to module INFs that  depend on UefiCpuLib.
  MdePkg: Move API and implementation from UefiCpuLib to CpuLib
  IntelFsp2Pkg: Remove UefiCpuLib from module INFs.
  OvmfPkg: Remove UefiCpuLib from module INFs.
  PcAtChipsetPkg: Remove UefiCpuLib from module INFs.
  SourceLevelDebugPkg: Remove UefiCpuLib from module INFs.
  UefiCpuPkg: Remove UefiCpuLib from module INFs.
  UefiPayloadPkg: Remove UefiCpuLib from module INFs.
  UefiCpuLib: Remove UefiCpuLib.

 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.c => 
MdePkg/Library/BaseCpuLib/X86BaseCpuLib.c |  2 +-
 OvmfPkg/Sec/SecMain.c  
 |  2 +-
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.c 
 |  2 +-
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c 
 |  2 +-
 IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
 |  2 +-
 IntelFsp2Pkg/FspSecCore/SecMain.h  
 |  2 +-
 IntelFsp2Pkg/IntelFsp2Pkg.dsc  
 |  1 -
 IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
 |  1 -
 IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
 |  2 +-
 IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
 |  2 +-
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
 |  1 -
 MdePkg/Include/Library/CpuLib.h
 | 48 +++
 MdePkg/Library/BaseCpuLib/BaseCpuLib.inf   
 |  6 ++
 {UefiCpuPkg/Library/BaseUefiCpuLib => 
MdePkg/Library/BaseCpuLib}/Ia32/InitializeFpu.nasm|  0
 {UefiCpuPkg/Library/BaseUefiCpuLib => 
MdePkg/Library/BaseCpuLib}/X64/InitializeFpu.nasm |  0
 MdePkg/MdeLibs.dsc.inc 
 |  1 +
 OvmfPkg/AmdSev/AmdSevX64.dsc   
 |  1 -
 OvmfPkg/Bhyve/BhyveX64.dsc 
 |  1 -
 OvmfPkg/CloudHv/CloudHvX64.dsc 
 |  1 -
 OvmfPkg/Microvm/MicrovmX64.dsc 
 |  1 -
 OvmfPkg/OvmfPkgIa32.dsc
 |  1 -
 OvmfPkg/OvmfPkgIa32X64.dsc 
 |  1 -
 OvmfPkg/OvmfPkgX64.dsc 
 |  1 -
 OvmfPkg/OvmfXen.dsc
 |  1 -
 OvmfPkg/Sec/SecMain.inf
 |  2 +-
 PcAtChipsetPkg/PcAtChipsetPkg.dsc  
 |  1 -
 SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
 |  1 -
 UefiCpuPkg/CpuDxe/CpuDxe.h 
 |  1 -
 UefiCpuPkg/CpuDxe/CpuDxe.inf   
 |  1 -
 UefiCpuPkg/Include/Library/UefiCpuLib.h
 | 65 
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf   
 | 41 
 UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.uni   
 | 16 -
 UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf   
 |  2 +-
 UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf   
 |  2 +-
 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf  

[edk2-devel] Cancelled Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, April 12, 2022 #cal-cancelled

2022-04-12 Thread devel@edk2.groups.io Calendar
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:CANCELLED
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
LAST-MODIFIED:20220317T223602Z
TZURL:http://tzurl.org/zoneinfo-outlook/America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZNAME:PDT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
DTSTART:19700308T02
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:PST
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
DTSTART:19701101T02
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:1238722 
UID:mlda.1580078539586725120.r...@groups.io
DTSTAMP:20220413T005337Z
ORGANIZER;CN=Liming Gao:mailto:gaolim...@byosoft.com.cn
DTSTART:20220413T013000Z
DTEND:20220413T023000Z
SUMMARY:TianoCore Bug Triage - APAC / NAMO
DESCRIPTION:TianoCore Bug Triage - APAC / NAMO\n\nHosted by Liming Gao\n\
 n
 \n\nMicrosoft Teams meeting\n\n*Join on your computer or mobile a
 pp*\n\nClick here to join the meeting ( https://teams.microsoft.com/l/mee
 tup-join/19%3ameeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh%40
 thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255
 d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d )\n\n*Jo
 in with a video conferencing device*\n\nte...@conf.intel.com\n\nVideo Con
 ference ID: 116 062 094 0\n\nAlternate VTC dialing instructions ( https:/
 /conf.intel.com/teams/?conf=1160620940=teams=conf.intel.com=te
 st_call )\n\n*Or call in (audio only)*\n\n+1 916-245-6934\,\,77463821# ( 
 tel:+19162456934\,\,77463821# ) United States\, Sacramento\n\nPhone Confe
 rence ID: 774 638 21#\n\nFind a local number ( https://dialin.teams.micro
 soft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821 ) | Reset PIN (
  https://mysettings.lync.com/pstnconferencing )\n\nLearn More ( https://a
 ka.ms/JoinTeamsMeeting ) | Meeting options ( https://teams.microsoft.com/
 meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e
 =46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_OTUyZTg2NjgtNDh
 lNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2=0=en-US )
LOCATION:https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN
 2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%2
 2%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-
 1242-431b-9a51-92cd01a5df3c%22%7d
SEQUENCE:2
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


Re: [edk2-devel] [PATCH v2 08/14] IntelFsp2Pkg: Remove UefiCpuLib from module INFs.

2022-04-12 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

Thanks,
Chasel

> -Original Message-
> From: Pu, Yu 
> Sent: Tuesday, April 12, 2022 10:52 PM
> To: devel@edk2.groups.io
> Cc: Pu, Yu ; Chiu, Chasel ;
> Desimone, Nathaniel L ; Zeng, Star
> 
> Subject: [PATCH v2 08/14] IntelFsp2Pkg: Remove UefiCpuLib from module
> INFs.
> 
> Because UefiCpuPkg/UefiCpuLib is merged to MdePkg/CpuLib, remove the
> dependency of UefiCpuLib.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Star Zeng 
> Signed-off-by: Yu Pu 
> ---
>  IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 1 -
>  IntelFsp2Pkg/FspSecCore/SecMain.h   | 1 -
>  IntelFsp2Pkg/IntelFsp2Pkg.dsc   | 1 -
>  IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc | 1 -
>  IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf | 1 -
> IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf | 1 -
>  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc | 1 -
>  7 files changed, 7 deletions(-)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> index 830471adcf2f..c07b49c4045f 100644
> --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> @@ -52,7 +52,6 @@
>FspCommonLib   FspSecPlatformLib   CpuLib-  UefiCpuLib  [Pcd]
> gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase  ##
> CONSUMESdiff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h
> b/IntelFsp2Pkg/FspSecCore/SecMain.h
> index edb7447d9eff..7288086cc493 100644
> --- a/IntelFsp2Pkg/FspSecCore/SecMain.h
> +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h
> @@ -21,7 +21,6 @@
>  #include  #include
>  #include -#include
>  #include   typedef VOID
> (*PEI_CORE_ENTRY) ( \diff --git a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> b/IntelFsp2Pkg/IntelFsp2Pkg.dsc index c1414f7e75b8..b90be5397d37
> 100644
> --- a/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> +++ b/IntelFsp2Pkg/IntelFsp2Pkg.dsc
> @@ -27,7 +27,6 @@
>PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
> IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
> UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDeco
> mpressLib.inf-
> UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
> ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseR
> eportStatusCodeLibNull.inf
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanc
> eLibNull.infdiff --git a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
> b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
> index 961576c9a73a..31558121185d 100644
> --- a/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
> +++ b/IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc
> @@ -107,7 +107,6 @@
> 
> PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePl
> atformHookLibNull.inf
> PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanc
> eLibNull.inf
> OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLib
> Null/OemHookStatusCodeLibNull.inf-
> UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf !if
> $(TARGET) == DEBUG
> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort
> .inf
> SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPo
> rtLib16550.infdiff --git
> a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> index e2262d693c55..77af97207990 100644
> --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> @@ -38,7 +38,6 @@
>FspWrapperPlatformLib   FspWrapperHobProcessLib   CpuLib-  UefiCpuLib
> PeCoffGetEntryPointLib   PeCoffExtraActionLib   PerformanceLibdiff --git
> a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> index 0598f85ab3ac..cad9fad96829 100644
> --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> @@ -39,7 +39,6 @@
>FspWrapperPlatformLib   FspWrapperHobProcessLib   CpuLib-  UefiCpuLib
> PeCoffGetEntryPointLib   PeCoffExtraActionLib   PerformanceLibdiff --git
> a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> index 21e089000eaf..233cb3d9ce2b 100644
> --- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> +++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
> @@ -41,7 +41,6 @@
> 
> DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLi
> bNull.inf# UefiCpuPkg-
> UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
> LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf# FSP
> Wrapper Lib--
> 2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88805): https://edk2.groups.io/g/devel/message/88805
Mute This Topic: https://groups.io/mt/90431011/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 03/14] IntelFsp2WrapperPkg: Add CpuLib to module INFs that depend on UefiCpuLib.

2022-04-12 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

Thanks,
Chasel

> -Original Message-
> From: Pu, Yu 
> Sent: Tuesday, April 12, 2022 10:52 PM
> To: devel@edk2.groups.io
> Cc: Pu, Yu ; Chiu, Chasel ;
> Desimone, Nathaniel L ; Zeng, Star
> 
> Subject: [PATCH v2 03/14] IntelFsp2WrapperPkg: Add CpuLib to module
> INFs that depend on UefiCpuLib.
> 
> There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
> UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
> failure, add CpuLib dependency to all modules that depend on UefiCpuLib.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Star Zeng 
> Signed-off-by: Yu Pu 
> ---
>  IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf | 1 +
> IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> index 5d0e0214015f..e2262d693c55 100644
> --- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
> @@ -37,6 +37,7 @@
>HobLib   FspWrapperPlatformLib   FspWrapperHobProcessLib+  CpuLib
> UefiCpuLib   PeCoffGetEntryPointLib   PeCoffExtraActionLibdiff --git
> a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> index da0049a65435..0598f85ab3ac 100644
> --- a/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> +++ b/IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
> @@ -38,6 +38,7 @@
>MemoryAllocationLib   FspWrapperPlatformLib
> FspWrapperHobProcessLib+  CpuLib   UefiCpuLib   PeCoffGetEntryPointLib
> PeCoffExtraActionLib--
> 2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88804): https://edk2.groups.io/g/devel/message/88804
Mute This Topic: https://groups.io/mt/90430992/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 02/14] IntelFsp2Pkg: Add CpuLib to module INFs that depend on UefiCpuLib

2022-04-12 Thread Chiu, Chasel


Reviewed-by: Chasel Chiu 

Thanks,
Chasel


> -Original Message-
> From: Pu, Yu 
> Sent: Tuesday, April 12, 2022 10:52 PM
> To: devel@edk2.groups.io
> Cc: Pu, Yu ; Chiu, Chasel ;
> Desimone, Nathaniel L ; Zeng, Star
> 
> Subject: [PATCH v2 02/14] IntelFsp2Pkg: Add CpuLib to module INFs that
> depend on UefiCpuLib
> 
> There are two libraries: MdePkg/CpuLib and UefiCpuPkg/UefiCpuLib and
> UefiCpuPkg/UefiCpuLib will be merged to MdePkg/CpuLib. To avoid build
> failure, add CpuLib dependency to all modules that depend on UefiCpuLib.
> 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Star Zeng 
> Signed-off-by: Yu Pu 
> ---
>  IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf | 1 +
>  IntelFsp2Pkg/FspSecCore/SecMain.h   | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> index 7b05cae64130..830471adcf2f 100644
> --- a/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> +++ b/IntelFsp2Pkg/FspSecCore/FspSecCoreM.inf
> @@ -51,6 +51,7 @@
>FspSwitchStackLib   FspCommonLib   FspSecPlatformLib+  CpuLib
> UefiCpuLib  [Pcd]diff --git a/IntelFsp2Pkg/FspSecCore/SecMain.h
> b/IntelFsp2Pkg/FspSecCore/SecMain.h
> index 7794255af13d..edb7447d9eff 100644
> --- a/IntelFsp2Pkg/FspSecCore/SecMain.h
> +++ b/IntelFsp2Pkg/FspSecCore/SecMain.h
> @@ -20,6 +20,7 @@
>  #include  #include 
> #include +#include  #include
>  #include  --
> 2.30.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88803): https://edk2.groups.io/g/devel/message/88803
Mute This Topic: https://groups.io/mt/90430990/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch] pip-requirements.txt: Update basetools version to 0.1.17

2022-04-12 Thread Bob Feng
Thank you Mike, I created a PR https://github.com/tianocore/edk2/pull/2770.

Thanks,
Bob

-Original Message-
From: Kinney, Michael D  
Sent: Wednesday, April 13, 2022 7:54 AM
To: Feng, Bob C ; devel@edk2.groups.io; Kinney, Michael D 

Cc: Sean Brogan ; Bret Barkelew 
; Gao, Liming 
Subject: RE: [Patch] pip-requirements.txt: Update basetools version to 0.1.17

Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Feng, Bob C 
> Sent: Tuesday, April 12, 2022 7:23 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C ; Sean Brogan 
> ; Bret Barkelew 
> ; Kinney, Michael D 
> ; Gao, Liming 
> Subject: [Patch] pip-requirements.txt: Update basetools version to 
> 0.1.17
> 
> Synced the basetools patch from edk2 repo to edk2-basetools repo. 
> Update the basetools pip module version to the latest.
> 
> Signed-off-by: Bob Feng 
> 
> Cc: Sean Brogan 
> 
> Cc: Bret Barkelew 
> 
> Cc: Michael D Kinney 
> 
> Cc: Liming Gao 
> 
> 
> ---
>  pip-requirements.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pip-requirements.txt b/pip-requirements.txt index 
> f8bcd9ceb5..89f5ff1733 100644
> --- a/pip-requirements.txt
> +++ b/pip-requirements.txt
> @@ -12,7 +12,7 @@
>  # https://www.python.org/dev/peps/pep-0440/#version-specifiers
> 
>  ##
> 
> 
> 
>  edk2-pytool-library==0.11.2
> 
>  edk2-pytool-extensions~=0.16.0
> 
> -edk2-basetools==0.1.13
> 
> +edk2-basetools==0.1.17
> 
>  antlr4-python3-runtime==4.7.1
> 
> --
> 2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88802): https://edk2.groups.io/g/devel/message/88802
Mute This Topic: https://groups.io/mt/90418955/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [Patch] pip-requirements.txt: Update basetools version to 0.1.17

2022-04-12 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 


> -Original Message-
> From: Feng, Bob C 
> Sent: Tuesday, April 12, 2022 7:23 AM
> To: devel@edk2.groups.io
> Cc: Feng, Bob C ; Sean Brogan 
> ; Bret Barkelew ;
> Kinney, Michael D ; Gao, Liming 
> 
> Subject: [Patch] pip-requirements.txt: Update basetools version to 0.1.17
> 
> Synced the basetools patch from edk2 repo to
> edk2-basetools repo. Update the basetools pip module version
> to the latest.
> 
> Signed-off-by: Bob Feng 
> 
> Cc: Sean Brogan 
> 
> Cc: Bret Barkelew 
> 
> Cc: Michael D Kinney 
> 
> Cc: Liming Gao 
> 
> 
> ---
>  pip-requirements.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/pip-requirements.txt b/pip-requirements.txt
> index f8bcd9ceb5..89f5ff1733 100644
> --- a/pip-requirements.txt
> +++ b/pip-requirements.txt
> @@ -12,7 +12,7 @@
>  # https://www.python.org/dev/peps/pep-0440/#version-specifiers
> 
>  ##
> 
> 
> 
>  edk2-pytool-library==0.11.2
> 
>  edk2-pytool-extensions~=0.16.0
> 
> -edk2-basetools==0.1.13
> 
> +edk2-basetools==0.1.17
> 
>  antlr4-python3-runtime==4.7.1
> 
> --
> 2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88801): https://edk2.groups.io/g/devel/message/88801
Mute This Topic: https://groups.io/mt/90418955/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] Regression: 100x I/O performance slowdown in SEC phase caused by TDX

2022-04-12 Thread James Bottomley
I'm using a SEC phase which has a TPM driver to experiment with sorting
out measured boot, which is how I noticed (usually SEC doesn't do MMIO)
.  What I'm seeing is after commit b6b2de884864 ("MdePkg: Support mmio
for Tdx guest in BaseIoLibIntrinsic") we get a massive slowdown of
about 100x in TPM performance.  The reason seems to be this addition to
the mmioreadX/mmiowriteX code:

 MemoryFence ();
-*(volatile UINT16 *)Address = Value;
+
+if (IsTdxGuest ()) {
+  TdMmioWrite16 (Address, Value);
+} else {
+  *(volatile UINT16 *)Address = Value;
+}
+
 MemoryFence ();


The problem is that IsTdxGuest () has this structure:

BOOLEAN
EFIAPI
IsTdxGuest (
  VOID
  )
{
  if (mTdxProbed) {
return mTdxEnabled;
  }

  mTdxEnabled = TdIsEnabled ();
  mTdxProbed  = TRUE;

  return mTdxEnabled;
}

Which is trying to cache the result of the probe in the efi data
segment.  However, that doesn't work in SEC, because the data segment
is read only (so the write seems to succeed but a read will always
return the original value), leading to us calling TdIsEnabled() check
for every mmio we do, which is causing the slowdown because it's very
expensive.

James




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88800): https://edk2.groups.io/g/devel/message/88800
Mute This Topic: https://groups.io/mt/90427994/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] TDX patches have broken edk2 bisectability in OVMF

2022-04-12 Thread James Bottomley
I've identified a serious performance regression in recent edk2, so
I've been trying to identify it by bisection, but it seems that the TDX
patches have broken bisection in edk2.  You can see this by trying to
checkout b6b2de884864 and build it.  It will give you

Active Platform  = /home/jejb/git/edk2/OvmfPkg/OvmfPkgX64.dsc
.

build.py...
/home/jejb/git/edk2/OvmfPkg/OvmfPkgX64.dsc(...): error 4000: Instance of 
library class [TdxLib] is not found
in 
[/home/jejb/git/edk2/MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf]
 [X64]
consumed by module [/home/jejb/git/edk2/OvmfPkg/Sec/SecMain.inf]
 

I think I can work around this, but it makes bisection extremely
painful, please don't do it again ...

James




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88799): https://edk2.groups.io/g/devel/message/88799
Mute This Topic: https://groups.io/mt/90427519/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] Intel NUC platform firmware -- no serial I/O support?

2022-04-12 Thread manickavasakam karpagavinayagam via groups.io
Laszlo :

Checked internally and came to know that Aptio BIOS for this platform doesn't 
support the serial redirection support during POST.

Thank you

-Manic

 -Original Message-
From: Laszlo Ersek 
Sent: Friday, April 8, 2022 5:20 AM
To: Manickavasakam Karpagavinayagam ; Gerd Hoffmann 
; Srini Narayana ; KarenLee [李致瑤] 
; Harikrishna Doppalapudi 
Cc: devel@edk2.groups.io; Ramesh R. ; Sivaraman Nainar 

Subject: Re: [EXTERNAL] Re: [edk2-devel] Intel NUC platform firmware -- no 
serial I/O support?

Hi Manic,

On 04/07/22 19:04, Manickavasakam Karpagavinayagam wrote:
> Laszlo/Gred :
>
> Can you please let us know the GITHUB project location from where you have 
> downloaded the source ?

I didn't download any new source code. I've just had my local edk2 clone as 
always, and the small patch at the bottom (adding "NucSerialPkg", just for the 
sake of buildig SerialDxe and TerminalDxe in separation) applies on top of 
current master.

Thanks
Laszlo

>
> Thank you
>
> -Manic
>
> -Original Message-
> From: Laszlo Ersek 
> Sent: Thursday, April 7, 2022 10:12 AM
> To: Gerd Hoffmann 
> Cc: devel@edk2.groups.io; Ramesh R. ; Sivaraman
> Nainar ; Manickavasakam Karpagavinayagam
> 
> Subject: [EXTERNAL] Re: [edk2-devel] Intel NUC platform firmware -- no serial 
> I/O support?
>
>
> **CAUTION: The e-mail below is from an external source. Please
> exercise caution before opening attachments, clicking links, or
> following guidance.**
>
> On 04/07/22 14:50, Gerd Hoffmann wrote:
>
>> Well, it at least looks like 16550 / ide hardware.  Not sure how this
>> is actually implemented, I suspect it is virtual, maybe port access
>> traps into SMM and it's emulated there.  Or the management engine can
>> intercept those port accesses somehow.
>
>> If today's hardware still works the same way I'd expect you have a
>> little driver taking the role of SioBusDxe, but binding to
>> PCI_CLASS_COMMUNICATION_SERIAL devices instead of a LPC bridge with
>> isa serial ports behind it.  Possibly the AMI drivers you've seen are
>> just that.
>>
>> Does the NUC accept unsigned firmware updates?  If so we can maybe
>> just add a SioBusDxe driver variant customized for the NUC hardware
>
> You are spot on, but reality is even simpler than this. :)
>
> Here's what I've done:
>
> (1) I cross-referenced three lists of PCI IDs:
>
> (1.1) The supported IDs in the windows UART driver INF file, downloaded from 
> Intel, for this NUC.
>
> (1.2) The "lspci" output on the NUC.
>
> (1.3) The "drivers/mfd/intel-lpss-pci.c" file in the Linux tree.
>
> Result: there is no separate PCI device on this NUC that stands for a
> serial controller. Furthermore, "intel-lpss-pci.c" suggests all the
> "LPSS" serial ports (UARTs) are 16550 compatible -- see the reference
> chain
>
>  -> spt_uart_info -> uart_node -> uart_properties -> 
> "snps,uart-16550-compatible".
>
> (2) While navigating the (graphical) Setup UI, I noticed that HII debug 
> messages *were* sent to the serial port, by this nice, graphical, Setup 
> Browser.
>
> (3) The particular (non-Linux) kernel that I booted on this NUC could 
> flawlessly drive the serial port for input and output just by my 
> specification of the bog standard params baud-rate=115200, 8 data bits, no 
> parity, 1 stop bit.
>
> That gave me the following idea:
>
>> commit 0e794fe273b77830532ffb003b0d5539d7ae9823 (HEAD ->
>> nuc_serial_pkg)
>> Author: Laszlo Ersek 
>> Date:   Thu Apr 7 14:37:13 2022 +0200
>>
>> add NucSerialPkg: build SerialDxe and TerminalDxe for the
>> NUC8i3PNH
>>
>> Signed-off-by: Laszlo Ersek 
>>
>> diff --git a/NucSerialPkg/NucSerialPkg.dec
>> b/NucSerialPkg/NucSerialPkg.dec new file mode 100644 index
>> ..b077cde229c0
>> --- /dev/null
>> +++ b/NucSerialPkg/NucSerialPkg.dec
>> @@ -0,0 +1,13 @@
>> +## @file
>> +#  UART 16650 serial port driver build for the NUC8i3PNH.
>> +#
>> +#  Copyright (c) 2022, Red Hat, Inc.
>> +#
>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent ##
>> +
>> +[Defines]
>> +  DEC_SPECIFICATION  = 1.29
>> +  PACKAGE_NAME   = NucSerialPkg
>> +  PACKAGE_GUID   = afdaaf17-4a06-4d97-a456-1ede0db46bc0
>> +  PACKAGE_VERSION= 0.1
>> diff --git a/NucSerialPkg/NucSerialPkg.dsc
>> b/NucSerialPkg/NucSerialPkg.dsc new file mode 100644 index
>> ..971fb2f96a43
>> --- /dev/null
>> +++ b/NucSerialPkg/NucSerialPkg.dsc
>> @@ -0,0 +1,46 @@
>> +## @file
>> +#  UART 16650 serial port driver build for the NUC8i3PNH.
>> +#
>> +#  Copyright (c) 2022, Red Hat, Inc.
>> +#
>> +#  SPDX-License-Identifier: BSD-2-Clause-Patent ##
>> +
>> +[Defines]
>> +  PLATFORM_NAME  = NucSerial
>> +  PLATFORM_GUID  = 30c397cf-a446-4f41-858f-9ae677547094
>> +  PLATFORM_VERSION   = 0.1
>> +  DSC_SPECIFICATION  = 1.30
>> +  OUTPUT_DIRECTORY   = Build/NucSerial
>> +  SUPPORTED_ARCHITECTURES= X64
>> +  BUILD_TARGETS  = 

Re: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver.

2022-04-12 Thread Li, Zhihao
1. Although SmmCpuRendezvousLib in UefiCpuPkg, add SmmRendezvousLib.h into 
MdeModulePkg/Include/Library folder bypass the check.
2. The SmmRendezvousLib is a standalone MM library and doesn’t have any DXE 
service dependency. It can be used by SMM variable module and MM variable 
module.

As the patch following, it have passed the Edk2 CI test. The code can run 
successfully in practice, but I'm not sure if this is acceptable in terms of 
the standard.

-Original Message-
From: gaoliming  
Sent: Tuesday, April 12, 2022 9:00 AM
To: devel@edk2.groups.io; Li, Zhihao 
Cc: Wang, Jian J ; Fu, Siyuan ; Ni, 
Ray ; Kinney, Michael D 
Subject: 回复: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use 
SmmWaitForAllProcessor() in VariableSmm driver.

Zhihao:
  This patch breaks two things. One is to let MdeModulePkg depend on 
UefiCpuPkg, another is to let VariableStandaloneMm depend on UefiCpuPkg 
SmmCpuRendezvousLib. Please provide your proposal to resolve these two 
dependency first. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Li, Zhihao
> 发送时间: 2022年4月11日 15:07
> 收件人: devel@edk2.groups.io
> 抄送: Jian J Wang ; Liming Gao 
> ; Siyuan Fu ; Ni Ray 
> ; Michael D Kinney 
> 主题: [edk2-devel] [PATCH v1 1/1] MdeModulePkg: Use
> SmmWaitForAllProcessor() in VariableSmm driver.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3854
> 
> In UefiCpuPkg, there are a new Protocol with the new service 
> SmmWaitForAllProcessor(), which can be used by SMI handler to 
> optionally wait for other APs to complete SMM rendezvous in relaxed AP 
> mode.
> 
> This patch use the new service to let VariableSmm driver work normally 
> in relaxed AP mode.
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Siyuan Fu 
> Cc: Ni Ray 
> Cc: Michael D Kinney 
> 
> Signed-off-by: Zhihao Li 
> ---
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> | 10 +++-
>  MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> | 27 
>  MdeModulePkg/MdeModulePkg.dec
> |  5 +++-
>  MdeModulePkg/MdeModulePkg.dsc
> |  4 ++-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> |  3 ++-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> |  3 ++-
>  6 files changed, 47 insertions(+), 5 deletions(-)
> 
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> index 517cae7b00f8..52a9b0e6b202 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> @@ -14,7 +14,7 @@
>VariableServiceSetVariable(), VariableServiceQueryVariableInfo(),
> ReclaimForOS(),
> 
>SmmVariableGetStatistics() should also do validation based on its 
> own knowledge.
> 
> 
> 
> -Copyright (c) 2010 - 2019, Intel Corporation. All rights 
> reserved.
> 
> +Copyright (c) 2010 - 2022, Intel Corporation. All rights 
> +reserved.
> 
>  Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> 
>  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
> 
> @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> 
>  #include 
> 
>  #include 
> 
> +#include 
> 
> 
> 
>  #include 
> 
>  #include "Variable.h"
> 
> @@ -656,6 +657,13 @@ SmmVariableHandler (
>  goto EXIT;
> 
>}
> 
> 
> 
> +  if ((SmmVariableHeader->Attributes &
> EFI_VARIABLE_NON_VOLATILE) != 0) {
> 
> +if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {
> 
> +  DEBUG ((DEBUG_ERROR, "SetVariable: fail to wait for all AP
> check in SMM!\n"));
> 
> +  goto EXIT;
> 
> +}
> 
> +  }
> 
> +
> 
>Status = VariableServiceSetVariable (
> 
>   SmmVariableHeader->Name,
> 
>   >Guid,
> 
> diff --git a/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> b/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> new file mode 100644
> index ..82e459e9106e
> --- /dev/null
> +++ b/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h
> @@ -0,0 +1,27 @@
> +/** @file
> 
> +  SMM CPU Rendezvous library header file.
> 
> +
> 
> +  Copyright (c) 2022, Intel Corporation. All rights reserved.
> 
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +
> 
> +**/
> 
> +
> 
> +#ifndef SMM_CPU_RENDEZVOUS_H_
> 
> +#define SMM_CPU_RENDEZVOUS_H_
> 
> +
> 
> +/**
> 
> +  This routine wait for all AP processors to arrive in SMM.
> 
> +
> 
> +  @param[in]  BlockingMode  Blocking mode or non-blocking mode.
> 
> +
> 
> +  @retval EFI_SUCCESS   All processors checked in to SMM.
> 
> +  @retval EFI_TIMEOUT   Wait for all APs until timeout.
> 
> +
> 
> +**/
> 
> +EFI_STATUS
> 
> +EFIAPI
> 
> +SmmWaitForAllProcessor (
> 
> +  IN  BOOLEAN  BlockingMode
> 
> +  );
> 
> +
> 
> +#endif
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec 
> b/MdeModulePkg/MdeModulePkg.dec index 463e889e9a68..06ada41b7344 
> 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -4,7 +4,7 @@
>  # and libraries instances, 

Re: [edk2-devel] 回复: [PATCH v3 0/8] Add Variable Flash Info HOB

2022-04-12 Thread Michael Kubacki

Hi Liming,

To help move reviews along, I went ahead and sent a v4 patch series with 
the following information:


1. More details about when the HOB is required.
2. More details about when the HOB should be installed in the boot flow.
3. A 4 byte reserved field after the "Version" field.

The details are in MdeModulePkg/Include/Guid/VariableFlashInfo.h

V4: https://edk2.groups.io/g/devel/message/88787
CI PR: https://github.com/tianocore/edk2/pull/2768

Regards,
Michael

On 4/11/2022 9:25 PM, gaoliming wrote:

Michael:
   Can you give the suggestion about how to install this variable flash info
hob when it is required? Because VariablePei is early PEIM, how to make sure
the variable flash info hob is installed before GetVariable is called?

   On VARIABLE_FLASH_INFO structure definition, the first field is UINT32,
other fields are all UINT64. How about reserve 4 bytes after the first
field? If so, all fields are at the nature alignment address.

Thanks
Liming

-邮件原件-
发件人: mikub...@linux.microsoft.com 
发送时间: 2022年4月12日 1:42
收件人: devel@edk2.groups.io
抄送: Abner Chang ; Andrew Fish
; Anthony Perard ; Ard
Biesheuvel ; Benjamin You
; Brijesh Singh ; Erdem
Aktas ; Gerd Hoffmann ;
Guo Dong ; Hao A Wu ; James
Bottomley ; Jian J Wang ;
Jiewen Yao ; Jordan Justen
; Julien Grall ; Leif Lindholm
; Liming Gao ;
Maurice Ma ; Min Xu ;
Nickle Wang ; Peter Grehan ;
Ray Ni ; Rebecca Cran ; Sami
Mujawar ; Sean Rhodes ;
Sebastien Boeuf ; Tom Lendacky

主题: [PATCH v3 0/8] Add Variable Flash Info HOB

From: Michael Kubacki 

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

The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
VariableStandaloneMm, etc. (and their dependent protocol/library
stack), typically acquire UEFI variable store flash information
with PCDs declared in MdeModulePkg.

For example:
[Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

These PCDs work as-is in the StandaloneMm driver if they are not
dynamic such as Dynamic or DynamicEx because PCD services are not
readily available in the Standalone MM environment. Platforms that
use Standalone MM today, must define these PCDs as FixedAtBuild in
their platform build. However, the PCDs do allow platforms to treat
the PCDs as Dynamic/DynamicEx and being able to support that is
currently a gap for Standalone MM.

This patch series introduces a HOB that can be produced by the
platform to provide the same information. The HOB list is
available to Standalone MM.

The PCD declarations are left as-is in MdeModulePkg for backward
compatibility. This means unless a platform wants to use the HOB,
their code will continue to work with no change (they do not need
to produce the HOB). Only if the HOB is found, is its value used
instead of the PCDs.

Due to the large number of consumers of this information, access
to the base address and size values is abstracted in a new library
class (as requested in the v1 series) called VariableFlashInfoLib.

The API of VariableFlashInfoLib does not bind the underlying data
structure to the information returned to library users to allow
flexibility in the library implementation in the future.

V3 changes:
1. To better clarify usage, renamed the members
"NvStorageBaseAddress" and "NvStorageLength" in
"VARIABLE_FLASH_INFO" to "NvVariableBaseAddress" and
"NvVariableLength".
2. Added description comments to the fields in "VARIABLE_FLASH_INFO".

V2 changes:
1. Abstracted flash info data access with VariableFlashInfoLib.
2. Updated package builds in the repo that build the variable and
FTW drivers to include VariableFlashInfoLib.
3. Removed a redundant variable assignment in VariableSmm.c.
4. Updated comments in FtwMisc.c and FaultTolerantWritePei.c to
indicate driver assumption is UINTN (not UINT32)
5. Added a version field to the VARIABLE_FLASH_INFO structure.

Cc: Abner Chang 
Cc: Andrew Fish 
Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Benjamin You 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: Guo Dong 
Cc: Hao A Wu 
Cc: James Bottomley 
Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Maurice Ma 
Cc: Min Xu 
Cc: Nickle Wang 
Cc: Peter Grehan 
Cc: Ray Ni 
Cc: Rebecca Cran 
Cc: Sami Mujawar 
Cc: Sean Rhodes 
Cc: Sebastien Boeuf 
Cc: Tom Lendacky 
Signed-off-by: Michael Kubacki 

Michael Kubacki (8):
   MdeModulePkg: Add Variable Flash Info HOB
   MdeModulePkg/VariableFlashInfoLib: Add initial library
   MdeModulePkg/Variable: Consume Variable Flash Info
   MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
   ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
   EmulatorPkg: Add VariableFlashInfoLib
   OvmfPkg: Add VariableFlashInfoLib
   UefiPayloadPkg: Add VariableFlashInfoLib


MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c
| 178 

[edk2-devel] [PATCH v4 8/8] UefiPayloadPkg: Add VariableFlashInfoLib

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Maurice Ma 
Cc: Benjamin You 
Cc: Sean Rhodes 
Signed-off-by: Michael Kubacki 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 17b30589e77c..4d9bbc80c866 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -272,6 +272,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf
   
ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
 
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88795): https://edk2.groups.io/g/devel/message/88795
Mute This Topic: https://groups.io/mt/90421985/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 7/8] OvmfPkg: Add VariableFlashInfoLib

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: James Bottomley 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Min Xu 
Cc: Peter Grehan 
Cc: Rebecca Cran 
Cc: Sebastien Boeuf 
Cc: Tom Lendacky 
Signed-off-by: Michael Kubacki 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 1 +
 OvmfPkg/Bhyve/BhyveX64.dsc   | 1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 1 +
 OvmfPkg/Microvm/MicrovmX64.dsc   | 1 +
 OvmfPkg/OvmfPkgIa32.dsc  | 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
 OvmfPkg/OvmfPkgX64.dsc   | 1 +
 OvmfPkg/OvmfXen.dsc  | 1 +
 9 files changed, 9 insertions(+)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index fcdc3efab204..3868c577fe39 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -195,6 +195,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 !if $(BUILD_SHELL) == TRUE
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index e1b6b8e15f36..3df49e54de8a 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -206,6 +206,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
   #
   # Network libraries
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 20f3bc340807..19b84275eba3 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -216,6 +216,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 245155d41b30..f21a33ed6ba3 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -184,6 +184,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 59580ccd4691..d8603f016a0c 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -206,6 +206,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e4218b01f0fc..c689d4707046 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -213,6 +213,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
 
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index a80cdaacb8bc..44c75639aa5d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -217,6 +217,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   

[edk2-devel] [PATCH v4 6/8] EmulatorPkg: Add VariableFlashInfoLib

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Andrew Fish 
Cc: Ray Ni 
Cc: Abner Chang 
Cc: Nickle Wang 
Signed-off-by: Michael Kubacki 
---
 EmulatorPkg/EmulatorPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..4cf886b9eac7 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -122,6 +122,7 @@ [LibraryClasses]
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
   ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
   FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88793): https://edk2.groups.io/g/devel/message/88793
Mute This Topic: https://groups.io/mt/90421978/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 5/8] ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Ard Biesheuvel 
Cc: Leif Lindholm 
Cc: Sami Mujawar 
Cc: Gerd Hoffmann 
Cc: Julien Grall 
Signed-off-by: Michael Kubacki 
---
 ArmVirtPkg/ArmVirt.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index ba711deac025..988c1eb75529 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -177,6 +177,7 @@ [LibraryClasses.common]
   
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
 !endif
   VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+  
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
   
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
   
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
   
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88792): https://edk2.groups.io/g/devel/message/88792
Mute This Topic: https://groups.io/mt/90421975/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v4 4/8] MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds support to the UEFI variable fault tolerant write (FTW) drivers
to receive FTW base and size information dynamically via the Variable
Flash Information library.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
 | 41 +---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c  
 |  7 +++-
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c   
 | 28 -
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h  
 |  7 +++-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf 
 | 10 +
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf 
 | 10 +
 
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf 
| 10 +
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.inf 
 | 10 +
 8 files changed, 63 insertions(+), 60 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
index 661e1487673b..f1335870e797 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c
@@ -987,22 +987,43 @@ InitFtwDevice (
   OUT EFI_FTW_DEVICE  **FtwData
   )
 {
-  EFI_FTW_DEVICE  *FtwDevice;
+  EFI_STATUSStatus;
+  EFI_PHYSICAL_ADDRESS  WorkSpaceAddress;
+  UINT64Size;
+  UINTN FtwWorkingSize;
+  EFI_FTW_DEVICE*FtwDevice;
+
+  FtwWorkingSize = 0;
+
+  Status = GetVariableFlashFtwWorkingInfo (, );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUintn (Size, );
+  // This driver currently assumes the size will be UINTN so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
 
   //
   // Allocate private data of this driver,
   // Including the FtwWorkSpace[FTW_WORK_SPACE_SIZE].
   //
-  FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + PcdGet32 
(PcdFlashNvStorageFtwWorkingSize));
+  FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + FtwWorkingSize);
   if (FtwDevice == NULL) {
 return EFI_OUT_OF_RESOURCES;
   }
 
+  FtwDevice->WorkSpaceAddress = WorkSpaceAddress;
+  FtwDevice->WorkSpaceLength  = FtwWorkingSize;
+
+  Status = GetVariableFlashFtwSpareInfo (>SpareAreaAddress, );
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUintn (Size, >SpareAreaLength);
+  // This driver currently assumes the size will be UINTN so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
+
   //
   // Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE.
   //
-  FtwDevice->WorkSpaceLength = (UINTN)PcdGet32 
(PcdFlashNvStorageFtwWorkingSize);
-  FtwDevice->SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
   if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) {
 DEBUG ((DEBUG_ERROR, "Ftw: Workspace or Spare block does not exist!\n"));
 FreePool (FtwDevice);
@@ -1015,16 +1036,6 @@ InitFtwDevice (
   FtwDevice->FtwWorkSpaceLba = (EFI_LBA)(-1);
   FtwDevice->FtwSpareLba = (EFI_LBA)(-1);
 
-  FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 
(PcdFlashNvStorageFtwWorkingBase64);
-  if (FtwDevice->WorkSpaceAddress == 0) {
-FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 
(PcdFlashNvStorageFtwWorkingBase);
-  }
-
-  FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 
(PcdFlashNvStorageFtwSpareBase64);
-  if (FtwDevice->SpareAreaAddress == 0) {
-FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 
(PcdFlashNvStorageFtwSpareBase);
-  }
-
   *FtwData = FtwDevice;
   return EFI_SUCCESS;
 }
@@ -1277,7 +1288,7 @@ InitFtwProtocol (
   FtwDevice->FtwLastWriteHeader = NULL;
   FtwDevice->FtwLastWriteRecord = NULL;
 
-  InitializeLocalWorkSpaceHeader ();
+  InitializeLocalWorkSpaceHeader (FtwDevice->WorkSpaceLength);
 
   //
   // Refresh the working space data from working block
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c 
b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index 61e7a92ccea1..fd563643eb63 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -16,10 +16,13 @@ EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER  
mWorkingBlockHeader = { ZERO_GUID, 0, 0
 
   Since Signature and WriteQueueSize have been known, Crc can be calculated 
out,
   then the work space header will be fixed.
+
+  @param[in]  WorkSpaceLength Length in bytes of the FTW workspace area.
+
 **/
 VOID
 InitializeLocalWorkSpaceHeader (
-  VOID
+  IN  UINTN  WorkSpaceLength
   )
 {
   //
@@ -46,7 +49,7 @@ InitializeLocalWorkSpaceHeader (
 ,
 sizeof (EFI_GUID)

[edk2-devel] [PATCH v4 3/8] MdeModulePkg/Variable: Consume Variable Flash Info

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm
to acquire variable flash information from the Variable Flash
Information library.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Universal/Variable/Pei/Variable.c  | 14 
+-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c| 16 

 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c| 14 
++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c| 17 
+
 MdeModulePkg/Universal/Variable/Pei/Variable.h  |  2 ++
 MdeModulePkg/Universal/Variable/Pei/VariablePei.inf |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h   |  7 
++-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf   |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf  |  5 ++---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf |  5 ++---
 10 files changed, 56 insertions(+), 34 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/Pei/Variable.c 
b/MdeModulePkg/Universal/Variable/Pei/Variable.c
index b36dd0de67b2..26a4c73b45a5 100644
--- a/MdeModulePkg/Universal/Variable/Pei/Variable.c
+++ b/MdeModulePkg/Universal/Variable/Pei/Variable.c
@@ -567,11 +567,13 @@ GetVariableStore (
   OUT VARIABLE_STORE_INFO  *StoreInfo
   )
 {
+  EFI_STATUSStatus;
   EFI_HOB_GUID_TYPE *GuidHob;
   EFI_FIRMWARE_VOLUME_HEADER*FvHeader;
   VARIABLE_STORE_HEADER *VariableStoreHeader;
   EFI_PHYSICAL_ADDRESS  NvStorageBase;
   UINT32NvStorageSize;
+  UINT64NvStorageSize64;
   FAULT_TOLERANT_WRITE_LAST_WRITE_DATA  *FtwLastWriteData;
   UINT32BackUpOffset;
 
@@ -591,11 +593,13 @@ GetVariableStore (
 // Emulated non-volatile variable mode is not enabled.
 //
 
-NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
-NvStorageBase = (EFI_PHYSICAL_ADDRESS)(PcdGet64 
(PcdFlashNvStorageVariableBase64) != 0 ?
-   PcdGet64 
(PcdFlashNvStorageVariableBase64) :
-   PcdGet32 
(PcdFlashNvStorageVariableBase)
-   );
+Status = GetVariableFlashNvStorageInfo (, 
);
+ASSERT_EFI_ERROR (Status);
+
+Status = SafeUint64ToUint32 (NvStorageSize64, );
+// This driver currently assumes the size will be UINT32 so assert the 
value is safe for now.
+ASSERT_EFI_ERROR (Status);
+
 ASSERT (NvStorageBase != 0);
 
 //
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
index 03fec3048dc4..d5c409c914d1 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c
@@ -423,6 +423,8 @@ FtwNotificationEvent (
   EFI_PHYSICAL_ADDRESSVariableStoreBase;
   UINT64  VariableStoreLength;
   UINTN   FtwMaxBlockSize;
+  UINT32  NvStorageVariableSize;
+  UINT64  NvStorageVariableSize64;
 
   //
   // Ensure FTW protocol is installed.
@@ -432,14 +434,20 @@ FtwNotificationEvent (
 return;
   }
 
+  Status = GetVariableFlashNvStorageInfo (, 
);
+  ASSERT_EFI_ERROR (Status);
+
+  Status = SafeUint64ToUint32 (NvStorageVariableSize64, 
);
+  // This driver currently assumes the size will be UINT32 so assert the value 
is safe for now.
+  ASSERT_EFI_ERROR (Status);
+
+  VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
+
   Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, );
   if (!EFI_ERROR (Status)) {
-ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
+ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
   }
 
-  NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
-  VariableStoreBase = NvStorageVariableBase + 
mNvFvHeaderCache->HeaderLength;
-
   //
   // Let NonVolatileVariableBase point to flash variable store base directly 
after FTW ready.
   //
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c 
b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
index 5e9d40b67ac2..9e2d8fe0fe0c 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c
@@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
   EFI_PHYSICAL_ADDRESS  NvStorageBase;
   UINT8 *NvStorageData;
 

[edk2-devel] [PATCH v4 2/8] MdeModulePkg/VariableFlashInfoLib: Add initial library

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds a new library class VariableFlashInfoLib that abstracts access
to variable flash information. The instance provided first attempts
to retrieve information from the Variable Flash Info HOB. If that
HOB is not present, it falls back to the PCDs defined in
MdeModulePkg.

This fall back behavior provides backward compatibility for platforms
that only provide PCDs but also allows platforms that need to
dynamically provide the information using the Variable Flash Info HOB
to do so at runtime.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c   | 
178 
 MdeModulePkg/Include/Library/VariableFlashInfoLib.h|  
68 
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf |  
48 ++
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.uni |  
12 ++
 MdeModulePkg/MdeModulePkg.dec  |   
4 +
 MdeModulePkg/MdeModulePkg.dsc  |   
2 +
 6 files changed, 312 insertions(+)

diff --git 
a/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c 
b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c
new file mode 100644
index ..a1db97bdf218
--- /dev/null
+++ b/MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c
@@ -0,0 +1,178 @@
+/** @file
+  Variable Flash Information Library
+
+  Copyright (c) Microsoft Corporation
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Get the HOB that contains variable flash information.
+
+  @param[out] VariableFlashInfo   Pointer to a pointer to set to the variable 
flash information structure.
+
+  @retval EFI_SUCCESS Variable flash information was found 
successfully.
+  @retval EFI_INVALID_PARAMETER   The VariableFlashInfo pointer given is NULL.
+  @retval EFI_NOT_FOUND   Variable flash information could not be 
found.
+
+**/
+EFI_STATUS
+GetVariableFlashInfoFromHob (
+  OUT VARIABLE_FLASH_INFO  **VariableFlashInfo
+  )
+{
+  EFI_HOB_GUID_TYPE  *GuidHob;
+
+  if (VariableFlashInfo == NULL) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  GuidHob = GetFirstGuidHob ();
+  if (GuidHob == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  *VariableFlashInfo = GET_GUID_HOB_DATA (GuidHob);
+
+  //
+  // Assert if more than one variable flash information HOB is present.
+  //
+  DEBUG_CODE (
+if ((GetNextGuidHob (, GET_NEXT_HOB (GuidHob)) 
!= NULL)) {
+DEBUG ((DEBUG_ERROR, "ERROR: Found two variable flash information 
HOBs\n"));
+ASSERT (FALSE);
+  }
+
+);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Get the base address and size for the NV storage area used for UEFI variable 
storage.
+
+  @param[out] BaseAddressThe NV storage base address.
+  @param[out] Length The NV storage length in bytes.
+
+  @retval EFI_SUCCESS NV storage information was found 
successfully.
+  @retval EFI_INVALID_PARAMETER   A required pointer parameter is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+GetVariableFlashNvStorageInfo (
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64*Length
+  )
+{
+  EFI_STATUS   Status;
+  VARIABLE_FLASH_INFO  *VariableFlashInfo;
+
+  if ((BaseAddress == NULL) || (Length == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = GetVariableFlashInfoFromHob ();
+  if (!EFI_ERROR (Status)) {
+*BaseAddress = VariableFlashInfo->NvVariableBaseAddress;
+*Length  = VariableFlashInfo->NvVariableLength;
+  } else {
+*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 
(PcdFlashNvStorageVariableBase64) != 0 ?
+  PcdGet64 
(PcdFlashNvStorageVariableBase64) :
+  PcdGet32 
(PcdFlashNvStorageVariableBase)
+  );
+*Length = (UINT64)PcdGet32 (PcdFlashNvStorageVariableSize);
+  }
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Get the base address and size for the fault tolerant write (FTW) spare
+  area used for UEFI variable storage.
+
+  @param[out] BaseAddressThe FTW spare base address.
+  @param[out] Length The FTW spare length in bytes.
+
+  @retval EFI_SUCCESS FTW spare information was found successfully.
+  @retval EFI_INVALID_PARAMETER   A required pointer parameter is NULL.
+  @retval EFI_NOT_FOUND   FTW spare information could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+GetVariableFlashFtwSpareInfo (
+  OUT EFI_PHYSICAL_ADDRESS  *BaseAddress,
+  OUT UINT64*Length
+  )
+{
+  EFI_STATUS   Status;
+  VARIABLE_FLASH_INFO  *VariableFlashInfo;
+
+  if ((BaseAddress == NULL) || (Length == NULL)) {
+return EFI_INVALID_PARAMETER;
+  }
+

[edk2-devel] [PATCH v4 1/8] MdeModulePkg: Add Variable Flash Info HOB

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

Adds a new GUID that is used to identify a HOB that passes variable
flash information to UEFI variable drivers in HOB consumption phases
such as DXE, Traditional MM, and Standalone MM.

This information was previously passed directly with PCDs such
as EfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
and gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize.

However, the Standalone MM variable driver instance does not have
direct access to the PCD database. Therefore, this HOB will first
be considered as the source for variable flash information and
if platforms do not produce the HOB, reading the information from
the PCDs directly will be a backup to provide backward
compatibility.

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael Kubacki 
---
 MdeModulePkg/Include/Guid/VariableFlashInfo.h | 111 
 MdeModulePkg/MdeModulePkg.dec |   4 +
 2 files changed, 115 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/VariableFlashInfo.h 
b/MdeModulePkg/Include/Guid/VariableFlashInfo.h
new file mode 100644
index ..992a0dcdd384
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/VariableFlashInfo.h
@@ -0,0 +1,111 @@
+/** @file
+  This file defines the GUID and data structure used to pass information about
+  a variable store mapped on flash (i.e. a MMIO firmware volume) to the modules
+  that consume that information such as the DXE and MM UEFI variable drivers.
+
+  The HOB described in this file is currently optional. It is primarily 
provided
+  to allow a platform to dynamically describe the flash information to 
environments
+  such as Standalone MM that cannot access the prior method using dynamic PCDs.
+
+  Even for platforms that use Standalone MM, if the information is only stored
+  statically such as with FixedAtBuild PCDs, the HOB is not required.
+
+  Every point of consumption in this package that uses the PCDs will first 
check
+  for the HOB and use its value if present.
+
+  Early modules such as the PEI UEFI variable driver might also consume this
+  information. For modules such as these, that execute early in the boot flow,
+  at least two approaches are possible depending on platform design.
+
+  1. If the information in the HOB exactly matches the information in the PCDs,
+ (i.e. the HOB values are set using the PCD values), let the driver read
+ the information from the PCD and produce the HOB later in boot.
+
+  2. Produce the HOB very early in boot. For example, the earliest point the 
HOB
+ is currently consumed is in FaultTolerantWritePei. Note that 
FaultTolerantWritePei
+ produces gEdkiiFaultTolerantWriteGuid which is a dependency for 
VariablePei.
+
+ Therefore, attaching a NULL class library to FaultTolerantWritePei with a
+ constructor that produces the HOB will guarantee it is produced before 
the first
+ point of consumption as the constructor is executed before the module 
entry point.
+
+  Copyright (c) Microsoft Corporation.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef VARIABLE_FLASH_INFO_H_
+#define VARIABLE_FLASH_INFO_H_
+
+#define VARIABLE_FLASH_INFO_HOB_GUID \
+  { 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 
0x90 }}
+
+#define VARIABLE_FLASH_INFO_HOB_VERSION  1
+
+extern EFI_GUID  gVariableFlashInfoHobGuid;
+
+#pragma pack (push, 1)
+
+///
+/// This structure can be used to describe UEFI variable
+/// flash information.
+///
+typedef struct {
+  ///
+  /// Version of this structure.
+  ///
+  /// Increment the value when the structure is modified.
+  ///
+  UINT32  Version;
+  ///
+  /// Reserved field.
+  ///
+  /// Currently reserved for natural alignment.
+  ///
+  UINT32  Reserved;
+  ///
+  /// Base address of the non-volatile variable range in the flash device.
+  ///
+  /// Note that this address should align with the block size requirements of 
the flash device.
+  ///
+  EFI_PHYSICAL_ADDRESSNvVariableBaseAddress;
+  ///
+  /// Size of the non-volatile variable range in the flash device.
+  ///
+  /// Note that this value should be less than or equal to FtwSpareLength to 
support reclaim of
+  /// entire variable store area.
+  /// Note that this address should align with the block size requirements of 
the flash device.
+  ///
+  UINT64  NvVariableLength;
+  ///
+  /// Base address of the FTW spare block range in the flash device.
+  ///
+  /// Note that this address should align with the block size requirements of 
the flash device.
+  ///
+  EFI_PHYSICAL_ADDRESSFtwSpareBaseAddress;
+  ///
+  /// Size of the FTW spare block range in the flash device.
+  ///
+  /// Note that this value should be greater than or equal to NvVariableLength.
+  /// Note that this address should align with the block size requirements of 
the flash device.
+  ///
+  UINT64  

[edk2-devel] [PATCH v4 0/8] Add Variable Flash Info HOB

2022-04-12 Thread Michael Kubacki
From: Michael Kubacki 

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

The UEFI variable drivers such as VariableRuntimeDxe, VariableSmm,
VariableStandaloneMm, etc. (and their dependent protocol/library
stack), typically acquire UEFI variable store flash information
with PCDs declared in MdeModulePkg.

For example:
[Pcd]
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

These PCDs work as-is in the StandaloneMm driver if they are not
dynamic such as Dynamic or DynamicEx because PCD services are not
readily available in the Standalone MM environment. Platforms that
use Standalone MM today, must define these PCDs as FixedAtBuild in
their platform build. However, the PCDs do allow platforms to treat
the PCDs as Dynamic/DynamicEx and being able to support that is
currently a gap for Standalone MM.

This patch series introduces a HOB that can be produced by the
platform to provide the same information. The HOB list is
available to Standalone MM.

The PCD declarations are left as-is in MdeModulePkg for backward
compatibility. This means unless a platform wants to use the HOB,
their code will continue to work with no change (they do not need
to produce the HOB). Only if the HOB is found, is its value used
instead of the PCDs.

Due to the large number of consumers of this information, access
to the base address and size values is abstracted in a new library
class (as requested in the v1 series) called VariableFlashInfoLib.

The API of VariableFlashInfoLib does not bind the underlying data
structure to the information returned to library users to allow
flexibility in the library implementation in the future.

V4 changes:
1. Add a UINT32 "Reserved" field to VARIABLE_FLASH_INFO.
2. Add a descriptive comment to VariableFlashInfo.h to explain
   HOB usage.

V3 changes:
1. To better clarify usage, renamed the members
   "NvStorageBaseAddress" and "NvStorageLength" in
   "VARIABLE_FLASH_INFO" to "NvVariableBaseAddress" and
   "NvVariableLength".
2. Added description comments to the fields in "VARIABLE_FLASH_INFO".

V2 changes:
1. Abstracted flash info data access with VariableFlashInfoLib.
2. Updated package builds in the repo that build the variable and
   FTW drivers to include VariableFlashInfoLib.
3. Removed a redundant variable assignment in VariableSmm.c.
4. Updated comments in FtwMisc.c and FaultTolerantWritePei.c to
   indicate driver assumption is UINTN (not UINT32)
5. Added a version field to the VARIABLE_FLASH_INFO structure.

Cc: Abner Chang 
Cc: Andrew Fish 
Cc: Anthony Perard 
Cc: Ard Biesheuvel 
Cc: Benjamin You 
Cc: Brijesh Singh 
Cc: Erdem Aktas 
Cc: Gerd Hoffmann 
Cc: Guo Dong 
Cc: Hao A Wu 
Cc: James Bottomley 
Cc: Jian J Wang 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Julien Grall 
Cc: Leif Lindholm 
Cc: Liming Gao 
Cc: Maurice Ma 
Cc: Min Xu 
Cc: Nickle Wang 
Cc: Peter Grehan 
Cc: Ray Ni 
Cc: Rebecca Cran 
Cc: Sami Mujawar 
Cc: Sean Rhodes 
Cc: Sebastien Boeuf 
Cc: Tom Lendacky 
Signed-off-by: Michael Kubacki 

Michael Kubacki (8):
  MdeModulePkg: Add Variable Flash Info HOB
  MdeModulePkg/VariableFlashInfoLib: Add initial library
  MdeModulePkg/Variable: Consume Variable Flash Info
  MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
  ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
  EmulatorPkg: Add VariableFlashInfoLib
  OvmfPkg: Add VariableFlashInfoLib
  UefiPayloadPkg: Add VariableFlashInfoLib

 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.c   
 | 178 
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FtwMisc.c 
 |  41 +++--
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c  
 |   7 +-
 MdeModulePkg/Universal/FaultTolerantWritePei/FaultTolerantWritePei.c   
 |  28 +--
 MdeModulePkg/Universal/Variable/Pei/Variable.c 
 |  14 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableDxe.c   
 |  16 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c   
 |  14 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c   
 |  17 +-
 ArmVirtPkg/ArmVirt.dsc.inc 
 |   1 +
 EmulatorPkg/EmulatorPkg.dsc
 |   1 +
 MdeModulePkg/Include/Guid/VariableFlashInfo.h  
 | 111 
 MdeModulePkg/Include/Library/VariableFlashInfoLib.h
 |  68 
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf 
 |  48 ++
 MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.uni 
 |  12 ++
 MdeModulePkg/MdeModulePkg.dec  
 |   8 +
 MdeModulePkg/MdeModulePkg.dsc

[edk2-devel] ArmPlatformPkg: understanding PrePi vs PrePeiCore

2022-04-12 Thread Rebecca Cran
I've been working on cleaning up some of the code in ArmPlatformPkg and 
have been trying to understand the differences between PrePi and PrePeiCore.
It looks like PrePi was added to save space over PrePeiCore, but I'm 
wondering if we still need it? I'm guessing most of the platforms below 
could use the latter, possibly with the exception of BeagleBoard and 
VExpress?



Platforms using PrePi/Pei{Uni,MP}Core:

RPi3
RPi4
HiKey
BeagleBoard
VExpress-FVP
ArmJuno
HiKey960
DurianPkg
VExpress-CTA15-A7

--
Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88786): https://edk2.groups.io/g/devel/message/88786
Mute This Topic: https://groups.io/mt/90421325/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 0/8] CryptoPkg updates for openssl 3.0

2022-04-12 Thread Yao, Jiewen
Thanks for the contribution.
Merged https://github.com/tianocore/edk2/pull/2766

> -Original Message-
> From: Gerd Hoffmann 
> Sent: Monday, April 11, 2022 7:25 PM
> To: devel@edk2.groups.io
> Cc: Oliver Steffen ; Pawel Polawski
> ; Wang, Jian J ; Xiaoyu Lu
> ; Yao, Jiewen ; Jiang, Guomin
> ; Gerd Hoffmann 
> Subject: [PATCH v3 0/8] CryptoPkg updates for openssl 3.0
> 
> First batch of patches which update CrtLibSupport so it has everything
> needed to build openssl3.  Also a testcase update for openssl3.
> 
> This does not update the openssl submodule, that'll happen in a
> followup patch series.
> 
> v3:
>  - move strcpy() from .h to .c file.
>  - pick up review tags
> v2:
>  - rebase to latest master.
>  - add codestyle exception for fcntl.h.
> 
> Gerd Hoffmann (8):
>   CryptoPkg/CrtLibSupport: add fcntl.h
>   CryptoPkg/CrtLibSupport: add strstr()
>   CryptoPkg/CrtLibSupport: add INT_MIN
>   CryptoPkg/CrtLibSupport: add UINT_MAX
>   CryptoPkg/CrtLibSupport: add MODULESDIR
>   CryptoPkg/CrtLibSupport: add off_t
>   CryptoPkg/CrtLibSupport: fix strcpy
>   CryptoPkg/UnitTest: fix DH testcase
> 
>  CryptoPkg/Library/Include/CrtLibSupport.h| 12 +++-
>  CryptoPkg/Library/Include/fcntl.h|  9 +
>  CryptoPkg/Library/BaseCryptLib/SysCall/CrtWrapper.c  | 10 ++
>  .../Test/UnitTest/Library/BaseCryptLib/DhTests.c |  6 +++---
>  CryptoPkg/CryptoPkg.ci.yaml  |  1 +
>  5 files changed, 34 insertions(+), 4 deletions(-)
>  create mode 100644 CryptoPkg/Library/Include/fcntl.h
> 
> --
> 2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88785): https://edk2.groups.io/g/devel/message/88785
Mute This Topic: https://groups.io/mt/90392478/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [Patch] pip-requirements.txt: Update basetools version to 0.1.17

2022-04-12 Thread Bob Feng
Synced the basetools patch from edk2 repo to
edk2-basetools repo. Update the basetools pip module version
to the latest.

Signed-off-by: Bob Feng 
Cc: Sean Brogan 
Cc: Bret Barkelew 
Cc: Michael D Kinney 
Cc: Liming Gao 

---
 pip-requirements.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pip-requirements.txt b/pip-requirements.txt
index f8bcd9ceb5..89f5ff1733 100644
--- a/pip-requirements.txt
+++ b/pip-requirements.txt
@@ -12,7 +12,7 @@
 # https://www.python.org/dev/peps/pep-0440/#version-specifiers
 ##
 
 edk2-pytool-library==0.11.2
 edk2-pytool-extensions~=0.16.0
-edk2-basetools==0.1.13
+edk2-basetools==0.1.17
 antlr4-python3-runtime==4.7.1
-- 
2.29.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88784): https://edk2.groups.io/g/devel/message/88784
Mute This Topic: https://groups.io/mt/90418955/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 10/10] MdePkg/CompilerIntrinsicsLib: add new sources to CompilerIntrinsicsLib.inf

2022-04-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 .../CompilerIntrinsicsLib.inf | 20 +++
 1 file changed, 20 insertions(+)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf 
b/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
index 1604f1ee802f..448ec56b94e1 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
@@ -96,6 +96,26 @@ [Sources.IA32]
   Ia32/MathLShiftS64.nasm   | GCC
   Ia32/MathRShiftU64.nasm   | GCC
 
+  Ia32/llmul.c  | MSFT# __allmul
+  Ia32/llshr.c  | MSFT# __allshr
+  Ia32/ulldiv.c | MSFT# __aulldiv
+  Ia32/ullrem.c | MSFT# __aullrem
+  Ia32/lldiv.c  | MSFT# __alldiv
+  Ia32/llrem.c  | MSFT# __allrem
+  Ia32/lldvrm.c | MSFT# __alldvrm
+  Ia32/ulldvrm.c| MSFT# __aulldvrm
+
+  Ia32/llmul.c  | INTEL
+  Ia32/llshr.c  | INTEL
+  Ia32/ulldiv.c | INTEL
+  Ia32/ullrem.c | INTEL
+  Ia32/lldiv.c  | INTEL
+  Ia32/llrem.c  | INTEL
+  Ia32/lldvrm.c | INTEL
+  Ia32/ulldvrm.c| INTEL
+
+  Ia32/Gcc.c| GCC
+
 [Packages]
   MdePkg/MdePkg.dec
 
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88783): https://edk2.groups.io/g/devel/message/88783
Mute This Topic: https://groups.io/mt/90418645/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 09/10] MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c

2022-04-12 Thread Gerd Hoffmann
Implementations for those functions already exist,
so remove them to avoid duplicate symbols.

Signed-off-by: Gerd Hoffmann 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 47 ---
 1 file changed, 47 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index 3c47bef63c4d..7502d5afe65a 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -20,55 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include 
 
-// Shift Datum left by Count bits.
-// ===
-int
-__ashlsi3 (
-  int  Datum,
-  int  Count
-  )
-{
-  return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long
-__ashldi3 (
-  long  Datum,
-  int   Count
-  )
-{
-  return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long long
-__ashlti3 (
-  long long  Datum,
-  intCount
-  )
-{
-  return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
 // Arithmetically shift Datum right by Count bits.
 // ===
-int
-__ashrsi3 (
-  int  Datum,
-  int  Count
-  )
-{
-  return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
-long
-__ashrdi3 (
-  long  Datum,
-  int   Count
-  )
-{
-  return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
-}
-
 long long
 __ashrti3 (
   long long  Datum,
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88782): https://edk2.groups.io/g/devel/message/88782
Mute This Topic: https://groups.io/mt/90418644/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 08/10] MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c

2022-04-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 22 ---
 1 file changed, 22 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index d0996d6276bc..3c47bef63c4d 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -28,7 +28,6 @@ __ashlsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -38,7 +37,6 @@ __ashldi3 (
   int   Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -48,7 +46,6 @@ __ashlti3 (
   intCount
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -60,7 +57,6 @@ __ashrsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -70,7 +66,6 @@ __ashrdi3 (
   int   Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -80,7 +75,6 @@ __ashrti3 (
   intCount
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -92,7 +86,6 @@ __divsi3 (
   int  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
 }
 
@@ -105,7 +98,6 @@ __divdi3 (
   INT64  Quotient;
 
   Quotient = DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
-  DEBUG ((DEBUG_INFO, "%a: %Ld / %Ld = %Ld\n", __func__, Dividend, Divisor, 
Quotient));
 
   return Quotient;
 }
@@ -116,7 +108,6 @@ __divti3 (
   long long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
 }
 
@@ -128,7 +119,6 @@ __lshrsi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -138,7 +128,6 @@ __lshrdi3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -148,7 +137,6 @@ __lshrti3 (
   int  Count
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)RShiftU64 ((UINT64)Datum, (UINTN)Count);
 }
 
@@ -163,7 +151,6 @@ __modsi3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "modsi3: %d %% %d = %d\n", Dividend, Divisor, 
(int)Remainder));
 
   return (int)Remainder;
 }
@@ -177,7 +164,6 @@ __moddi3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "moddi3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, 
(INT64)Divisor, Remainder));
 
   return Remainder;
 }
@@ -191,7 +177,6 @@ __modti3 (
   INT64  Remainder;
 
   (void)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, );
-  DEBUG ((DEBUG_INFO, "modti3: %Ld %% %Ld = %Ld\n", (INT64)Dividend, 
(INT64)Divisor, Remainder));
 
   return (long long)Remainder;
 }
@@ -204,7 +189,6 @@ __multi3 (
   long long  Multiplier
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)MultS64x64 ((INT64)Multiplicand, (INT64)Multiplier);
 }
 
@@ -216,7 +200,6 @@ __udivsi3 (
   unsigned int  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (int)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL);
 }
 
@@ -226,7 +209,6 @@ __udivdi3 (
   unsigned long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, NULL);
 }
 
@@ -236,7 +218,6 @@ __udivti3 (
   unsigned long long  Divisor
   )
 {
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   return (long long)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, 
NULL);
 }
 
@@ -249,7 +230,6 @@ __umodsi3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned int)Remainder;
@@ -263,7 +243,6 @@ __umoddi3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned long)Remainder;
@@ -277,7 +256,6 @@ __umodti3 (
 {
   UINT64  Remainder;
 
-  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
   (void)DivU64x64Remainder ((UINT64)Dividend, (UINT64)Divisor, );
 
   return (unsigned long long)Remainder;
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88781): https://edk2.groups.io/g/devel/message/88781
Mute This Topic: https://groups.io/mt/90418642/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 07/10] MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c

2022-04-12 Thread Gerd Hoffmann
Does not exist and is not needed.

Signed-off-by: Gerd Hoffmann 
---
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index bb211022c0e4..d0996d6276bc 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -17,7 +17,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
 #include 
 #include 
-#include 
 
 #include 
 
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88780): https://edk2.groups.io/g/devel/message/88780
Mute This Topic: https://groups.io/mt/90418639/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 02/10] MdePkg/CompilerIntrinsicsLib: fix msft sources for x64

2022-04-12 Thread Gerd Hoffmann
Update #if conditions so the 64bit version is picked for X64 too.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
---
 MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c  | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c  | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c | 2 +-
 MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
index cedbfca47139..2fac8f1e23e3 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index 0eafa83ed476..730aa806d50b 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index f68eb52a6ca5..3207b94a8675 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
index 5882cd28b06d..deb902c6ae88 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -7,7 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64)
+#if defined (_M_ARM64) || defined (_M_X64)
 typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88779): https://edk2.groups.io/g/devel/message/88779
Mute This Topic: https://groups.io/mt/90418638/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 06/10] MdePkg/CompilerIntrinsicsLib: add SPDX License tags

2022-04-12 Thread Gerd Hoffmann
It's not an exact match, edk2 expects "BSD-2-Clause-Patent" but
http://opensource.org/licenses/bsd-license.php references in comments
is "BSD-2-Clause".

Guess I need an explicit Intel explicitly agreeing to this even though
that is a rather minor change ...

Signed-off-by: Gerd Hoffmann 
---
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S   | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S  | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S | 2 ++
 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S | 2 ++
 16 files changed, 32 insertions(+)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
index 430139fc5ee0..bb211022c0e4 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
index 792974d7b119..cf2eec2a70b4 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
index a1f87f6af5c3..1fbe11bea751 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
index 61a5c416b912..3f9c54454128 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
index f415fe82dd59..5a73d539a650 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
index f2121a713bd7..665b628b4014 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
@@ -9,6 +9,8 @@
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php.
 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c 

[edk2-devel] [PATCH v2 01/10] MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg

2022-04-12 Thread Gerd Hoffmann
First step in creating a single, common compiler intrinsics library for
everybody who needs it.  Move the ArmPkg library to MdePkg, update all
references.  No code changes.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc|   2 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc|   2 +-
 ArmPkg/ArmPkg.dsc |   3 +--
 .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc   |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc |   2 +-
 CryptoPkg/CryptoPkg.dsc   |   2 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc |   2 +-
 EmbeddedPkg/EmbeddedPkg.dsc   |   2 +-
 FatPkg/FatPkg.dsc |   2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |   2 +-
 MdeModulePkg/MdeModulePkg.dsc |   2 +-
 MdePkg/MdePkg.dsc |   1 +
 NetworkPkg/NetworkPkg.dsc |   2 +-
 RedfishPkg/RedfishPkg.dsc |   2 +-
 SecurityPkg/SecurityPkg.dsc   |   2 +-
 ShellPkg/ShellPkg.dsc |   2 +-
 SignedCapsulePkg/SignedCapsulePkg.dsc |   2 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc   |   2 +-
 .../CompilerIntrinsicsLib.inf |   1 -
 {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h|   0
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c |   0
 .../Library/CompilerIntrinsicsLib/memcpy.c|   0
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |   0
 .../CompilerIntrinsicsLib/memmove_ms.c|   0
 .../Library/CompilerIntrinsicsLib/memset.c|   0
 .../Library/CompilerIntrinsicsLib/memset_ms.c |   0
 ArmPkg/ArmPkg.ci.yaml |   1 -
 .../DEBUG_XCODE31/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../DEBUG_XCODE32/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 .../CompilerIntrinsicsLib/AArch64/Atomics.S   |   0
 .../CompilerIntrinsicsLib/Arm/ashldi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/ashrdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/clzsi2.S|   0
 .../CompilerIntrinsicsLib/Arm/ctzsi2.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/div.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/div.asm |   0
 .../CompilerIntrinsicsLib/Arm/divdi3.S|   0
 .../CompilerIntrinsicsLib/Arm/divsi3.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/lasr.S  |   0
 .../CompilerIntrinsicsLib/Arm/lasr.asm|   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.S   |   0
 .../CompilerIntrinsicsLib/Arm/ldivmod.asm |   0
 .../Library/CompilerIntrinsicsLib/Arm/llsl.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsl.asm|   0
 .../Library/CompilerIntrinsicsLib/Arm/llsr.S  |   0
 .../CompilerIntrinsicsLib/Arm/llsr.asm|   0
 .../CompilerIntrinsicsLib/Arm/lshrdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/memmove.S   |   0
 .../CompilerIntrinsicsLib/Arm/memmove.asm |   0
 .../CompilerIntrinsicsLib/Arm/moddi3.S|   0
 .../CompilerIntrinsicsLib/Arm/modsi3.S|   0
 .../CompilerIntrinsicsLib/Arm/muldi3.S|   0
 .../Library/CompilerIntrinsicsLib/Arm/mullu.S |   0
 .../CompilerIntrinsicsLib/Arm/mullu.asm   |   0
 .../CompilerIntrinsicsLib/Arm/sourcery.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch.asm  |   0
 .../CompilerIntrinsicsLib/Arm/switch16.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch32.S  |   0
 .../CompilerIntrinsicsLib/Arm/switch8.S   |   0
 .../CompilerIntrinsicsLib/Arm/switchu8.S  |   0
 .../CompilerIntrinsicsLib/Arm/ucmpdi2.S   |   0
 .../CompilerIntrinsicsLib/Arm/udivdi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/udivmoddi4.S|   0
 .../CompilerIntrinsicsLib/Arm/udivsi3.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/uldiv.S |   0
 .../CompilerIntrinsicsLib/Arm/uldiv.asm   |   0
 .../CompilerIntrinsicsLib/Arm/umoddi3.S   |   0
 .../CompilerIntrinsicsLib/Arm/umodsi3.S   |   0
 .../Library/CompilerIntrinsicsLib/Arm/uread.S |   0
 .../CompilerIntrinsicsLib/Arm/uread.asm   |   0
 .../CompilerIntrinsicsLib/Arm/uwrite.S|   0
 .../CompilerIntrinsicsLib/Arm/uwrite.asm  |   0
 MdePkg/MdePkg.ci.yaml |   1 +
 73 files changed, 19 insertions(+), 20 deletions(-)
 rename {ArmPkg => 
MdePkg}/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf (95%)
 rename {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c (100%)
 rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S 
(100%)
 rename {ArmPkg => 

[edk2-devel] [PATCH v2 03/10] MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file

2022-04-12 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 .../{memset_ms.c => types_ms.h}   | 29 +--
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |  6 +---
 .../CompilerIntrinsicsLib/memmove_ms.c|  6 +---
 .../Library/CompilerIntrinsicsLib/memset_ms.c |  6 +---
 4 files changed, 4 insertions(+), 43 deletions(-)
 copy MdePkg/Library/CompilerIntrinsicsLib/{memset_ms.c => types_ms.h} (52%)

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
similarity index 52%
copy from MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
copy to MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
index deb902c6ae88..d8b578be1f46 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/types_ms.h
@@ -1,6 +1,6 @@
 // 
--
 //
-// Copyright (c) 2017, Pete Batard. All rights reserved.
+// Copyright (c) 2019, Pete Batard. All rights reserved.
 // Copyright (c) 2021, Arm Limited. All rights reserved.
 //
 // SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -12,30 +12,3 @@ typedef unsigned __int64 size_t;
 #else
 typedef unsigned __int32 size_t;
 #endif
-
-void *
-memset (
-  void *,
-  int,
-  size_t
-  );
-
-#pragma intrinsic(memset)
-#pragma function(memset)
-void *
-memset (
-  void*s,
-  int c,
-  size_t  n
-  )
-{
-  unsigned char  *d;
-
-  d = s;
-
-  while (n-- != 0) {
-*d++ = (unsigned char)c;
-  }
-
-  return s;
-}
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
index 730aa806d50b..d2c3d7198121 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memcpy (
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
index 3207b94a8675..837744a2920c 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memmove (
diff --git a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c 
b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
index deb902c6ae88..3569bebdf80b 100644
--- a/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
+++ b/MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
@@ -7,11 +7,7 @@
 //
 // 
--
 
-#if defined (_M_ARM64) || defined (_M_X64)
-typedef unsigned __int64 size_t;
-#else
-typedef unsigned __int32 size_t;
-#endif
+#include "types_ms.h"
 
 void *
 memset (
-- 
2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88777): https://edk2.groups.io/g/devel/message/88777
Mute This Topic: https://groups.io/mt/90418636/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH v2 05/10] MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo

2022-04-12 Thread Gerd Hoffmann
Copy over unmodified (except for running through uncrustify), from
https://github.com/tianocore/edk2-libc/tree/master/StdLib/LibC/CRT

Signed-off-by: Gerd Hoffmann 
---
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 283 ++
 .../CompilerIntrinsicsLib/Ia32/lldiv.c|  98 ++
 .../CompilerIntrinsicsLib/Ia32/lldvrm.c   | 102 +++
 .../CompilerIntrinsicsLib/Ia32/llmul.c|  82 +
 .../CompilerIntrinsicsLib/Ia32/llrem.c|  95 ++
 .../CompilerIntrinsicsLib/Ia32/llshl.c|  57 
 .../CompilerIntrinsicsLib/Ia32/llshr.c|  61 
 .../CompilerIntrinsicsLib/Ia32/ulldiv.c   |  89 ++
 .../CompilerIntrinsicsLib/Ia32/ulldvrm.c  | 102 +++
 .../CompilerIntrinsicsLib/Ia32/ullrem.c   |  95 ++
 .../CompilerIntrinsicsLib/Ia32/ullshr.c   |  60 
 .../CompilerIntrinsicsLib/Ia32/ashrdi3.S  |  66 
 .../CompilerIntrinsicsLib/Ia32/mulll.S|  77 +
 .../CompilerIntrinsicsLib/Ia32/shldi3.S   |  62 
 .../CompilerIntrinsicsLib/Ia32/udivdi3.S  |  83 +
 .../CompilerIntrinsicsLib/Ia32/umoddi3.S  |  89 ++
 16 files changed, 1501 insertions(+)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/lldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llmul.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llrem.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshl.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/llshr.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldiv.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ulldvrm.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullrem.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ullshr.c
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/ashrdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/mulll.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/shldi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/udivdi3.S
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/Ia32/umoddi3.S

diff --git a/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c 
b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
new file mode 100644
index ..430139fc5ee0
--- /dev/null
+++ b/MdePkg/Library/CompilerIntrinsicsLib/Ia32/Gcc.c
@@ -0,0 +1,283 @@
+/** @file
+  Integer Arithmetic Run-time support functions for GCC.
+  The integer arithmetic routines are used on platforms that don't provide
+  hardware support for arithmetic operations on some modes..
+
+  Copyright (c) 2009 - 2011, 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
+  http://opensource.org/licenses/bsd-license.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include 
+#include 
+#include 
+
+#include 
+
+// Shift Datum left by Count bits.
+// ===
+int
+__ashlsi3 (
+  int  Datum,
+  int  Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long
+__ashldi3 (
+  long  Datum,
+  int   Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long long
+__ashlti3 (
+  long long  Datum,
+  intCount
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long long)LShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+// Arithmetically shift Datum right by Count bits.
+// ===
+int
+__ashrsi3 (
+  int  Datum,
+  int  Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long
+__ashrdi3 (
+  long  Datum,
+  int   Count
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+long long
+__ashrti3 (
+  long long  Datum,
+  intCount
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (long long)ARShiftU64 ((UINT64)Datum, (UINTN)Count);
+}
+
+// Return the quotient of the signed division of Dividend and Divisor
+// ===
+int
+__divsi3 (
+  int  Dividend,
+  int  Divisor
+  )
+{
+  DEBUG ((DEBUG_INFO, "%a:\n", __func__));
+  return (int)DivS64x64Remainder ((INT64)Dividend, (INT64)Divisor, NULL);
+}
+
+INT64
+__divdi3 (
+  INT64  Dividend,
+  INT64  Divisor
+  )
+{
+  INT64  Quotient;
+
+  

[edk2-devel] [PATCH v2 04/10] MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp

2022-04-12 Thread Gerd Hoffmann
Move intrinsics for ia32 from CryptoPkg/Library/IntrinsicLib
to MdePkg/Library/CompilerIntrinsicsLib.  Also move strcmp.

Remove CryptoPkg/Library/IntrinsicLib.
Use MdePkg/Library/CompilerIntrinsicsLib instead.
Update all references.

Signed-off-by: Gerd Hoffmann 
Acked-by: Jiewen Yao 
Acked-by: Ard Biesheuvel 
---
 ArmVirtPkg/ArmVirt.dsc.inc|  2 +-
 CryptoPkg/CryptoPkg.dsc   |  3 +-
 EmulatorPkg/EmulatorPkg.dsc   |  2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |  2 +-
 NetworkPkg/NetworkPkg.dsc |  2 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc  |  2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|  2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc|  2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |  2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|  2 +-
 OvmfPkg/OvmfPkgIa32.dsc   |  2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|  2 +-
 OvmfPkg/OvmfPkgX64.dsc|  2 +-
 OvmfPkg/OvmfXen.dsc   |  2 +-
 SecurityPkg/SecurityPkg.dsc   | 10 +--
 SignedCapsulePkg/SignedCapsulePkg.dsc | 12 +--
 UefiPayloadPkg/UefiPayloadPkg.dsc |  2 +-
 .../Library/IntrinsicLib/IntrinsicLib.inf | 67 -
 .../CompilerIntrinsicsLib.inf | 14 
 CryptoPkg/Library/IntrinsicLib/CopyMem.c  | 47 
 .../Library/IntrinsicLib/MemoryIntrinsics.c   | 74 ---
 .../CompilerIntrinsicsLib}/Ia32/MathFtol.c|  0
 .../Ia32/MathLShiftS64.c  |  0
 .../Ia32/MathRShiftU64.c  |  0
 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c | 33 +
 .../Library/IntrinsicLib/BaseIntrinsicLib.uni | 16 
 .../Ia32/MathLShiftS64.nasm   |  0
 .../Ia32/MathRShiftU64.nasm   |  0
 28 files changed, 73 insertions(+), 231 deletions(-)
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/CopyMem.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathFtol.c (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.c (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.c (100%)
 create mode 100644 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c
 delete mode 100644 CryptoPkg/Library/IntrinsicLib/BaseIntrinsicLib.uni
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathLShiftS64.nasm (100%)
 rename {CryptoPkg/Library/IntrinsicLib => 
MdePkg/Library/CompilerIntrinsicsLib}/Ia32/MathRShiftU64.nasm (100%)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 97edf0487964..d8b3db4f75ce 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -154,7 +154,7 @@ [LibraryClasses.common]
   #
   # CryptoPkg libraries needed by multiple firmware features
   #
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  IntrinsicLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
 !if $(NETWORK_TLS_ENABLE) == TRUE
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
 !else
diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 2d4d4c2797e5..d593ae0e709c 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -103,7 +103,7 @@ [LibraryClasses]
   
UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
  #???
   IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf   
   #???
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  IntrinsicLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
   SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
 
 [LibraryClasses.ARM]
@@ -240,7 +240,6 @@ [Components]
   CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
   CryptoPkg/Library/BaseCryptLibNull/BaseCryptLibNull.inf
-  CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
   CryptoPkg/Library/TlsLib/TlsLib.inf
   CryptoPkg/Library/TlsLibNull/TlsLibNull.inf
   CryptoPkg/Library/OpensslLib/OpensslLib.inf
diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
index 554c13ddb500..f3a97b2e4577 100644
--- a/EmulatorPkg/EmulatorPkg.dsc
+++ b/EmulatorPkg/EmulatorPkg.dsc
@@ -128,7 +128,7 @@ [LibraryClasses]
 
 !if $(SECURE_BOOT_ENABLE) == TRUE
   RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
-  IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+  IntrinsicLib|MdePkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
   OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
   

[edk2-devel] [PATCH v2 00/10] consolidate compiler intrinsics

2022-04-12 Thread Gerd Hoffmann
This is an attept to start cleaning up the messy compiler intrinsics
situation.  Today we don't have a core intrinsics library, resulting
in everybody creating their own.  ArmPkg has one, CryptoPkg has one.
I'm sure there are many more.

This doesn't make sense.  Given we can't avoid compiler intrinsics (as
proven by the existence of those libraries) we should better have them
as core library so we have to maintain a single version only.

Given we already have BaseIoLibIntrinsic in MdePkg we can place the
compiler intrinsics there too.  This little patch series does just that:
It moves over the existing ArmPkg intrinsics, fixes them to build on
non-arm too, and adds additional bits from the CryptoPkg intrinsics.

v2 changes:
 - rebase to latest master.
 - add review tags
 - add patch moving size_t to header file (patch #3).
 - add patches copying over more intrinsics from
   edk2-libc repo (patches #5 -> #10).

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3649

take care,
  Gerd

Gerd Hoffmann (10):
  MdePkg: promote CompilerIntrinsicsLib from ArmPkg to MdePkg
  MdePkg/CompilerIntrinsicsLib: fix msft sources for x64
  MdePkg/CompilerIntrinsicsLib: move size_t typedef to header file
  MdePkg/CompilerIntrinsicsLib: move ia32 intrinsics and strcmp
  MdePkg/CompilerIntrinsicsLib: copy over intrinsics from edk2-libc repo
  MdePkg/CompilerIntrinsicsLib: add SPDX License tags
  MdePkg/CompilerIntrinsicsLib: drop include from Gcc.c
  MdePkg/CompilerIntrinsicsLib: drop debug logging from Gcc.c
  MdePkg/CompilerIntrinsicsLib: remove duplicate functions from Gcc.c
  MdePkg/CompilerIntrinsicsLib: add new sources to
CompilerIntrinsicsLib.inf

 ArmVirtPkg/ArmVirt.dsc.inc|   4 +-
 .../UnitTestFrameworkPkgTarget.dsc.inc|   2 +-
 ArmPkg/ArmPkg.dsc |   3 +-
 .../ArmCrashDumpDxe/ArmCrashDumpDxe.dsc   |   2 +-
 ArmPlatformPkg/ArmPlatformPkg.dsc |   2 +-
 CryptoPkg/CryptoPkg.dsc   |   5 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc |   2 +-
 EmbeddedPkg/EmbeddedPkg.dsc   |   2 +-
 EmulatorPkg/EmulatorPkg.dsc   |   2 +-
 FatPkg/FatPkg.dsc |   2 +-
 FmpDevicePkg/FmpDevicePkg.dsc |   4 +-
 MdeModulePkg/MdeModulePkg.dsc |   2 +-
 MdePkg/MdePkg.dsc |   1 +
 NetworkPkg/NetworkPkg.dsc |   4 +-
 OvmfPkg/AmdSev/AmdSevX64.dsc  |   2 +-
 OvmfPkg/Bhyve/BhyveX64.dsc|   2 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc|   2 +-
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   2 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|   2 +-
 OvmfPkg/OvmfPkgIa32.dsc   |   2 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|   2 +-
 OvmfPkg/OvmfPkgX64.dsc|   2 +-
 OvmfPkg/OvmfXen.dsc   |   2 +-
 RedfishPkg/RedfishPkg.dsc |   2 +-
 SecurityPkg/SecurityPkg.dsc   |  12 +-
 ShellPkg/ShellPkg.dsc |   2 +-
 SignedCapsulePkg/SignedCapsulePkg.dsc |  14 +-
 StandaloneMmPkg/StandaloneMmPkg.dsc   |   2 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc |   2 +-
 .../Library/IntrinsicLib/IntrinsicLib.inf |  67 --
 .../CompilerIntrinsicsLib.inf |  35 ++-
 {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h|   0
 .../Library/CompilerIntrinsicsLib/types_ms.h  |  14 ++
 CryptoPkg/Library/IntrinsicLib/CopyMem.c  |  47 
 .../Library/IntrinsicLib/MemoryIntrinsics.c   |  74 --
 .../Library/CompilerIntrinsicsLib/Ia32/Gcc.c  | 215 ++
 .../CompilerIntrinsicsLib}/Ia32/MathFtol.c|   0
 .../Ia32/MathLShiftS64.c  |   0
 .../Ia32/MathRShiftU64.c  |   0
 .../CompilerIntrinsicsLib/Ia32/lldiv.c| 100 
 .../CompilerIntrinsicsLib/Ia32/lldvrm.c   | 104 +
 .../CompilerIntrinsicsLib/Ia32/llmul.c|  84 +++
 .../CompilerIntrinsicsLib/Ia32/llrem.c|  97 
 .../CompilerIntrinsicsLib/Ia32/llshl.c|  10 +-
 .../CompilerIntrinsicsLib/Ia32/llshr.c|  63 +
 .../CompilerIntrinsicsLib/Ia32/ulldiv.c   |  91 
 .../CompilerIntrinsicsLib/Ia32/ulldvrm.c  | 104 +
 .../CompilerIntrinsicsLib/Ia32/ullrem.c   |  97 
 .../CompilerIntrinsicsLib/Ia32/ullshr.c   |  10 +-
 .../Library/CompilerIntrinsicsLib/memcmp_ms.c |   2 +-
 .../Library/CompilerIntrinsicsLib/memcpy.c|   0
 .../Library/CompilerIntrinsicsLib/memcpy_ms.c |   6 +-
 .../CompilerIntrinsicsLib/memmove_ms.c|   6 +-
 .../Library/CompilerIntrinsicsLib/memset.c|   0
 .../Library/CompilerIntrinsicsLib/memset_ms.c |   6 +-
 MdePkg/Library/CompilerIntrinsicsLib/strcmp.c |  33 +++
 ArmPkg/ArmPkg.ci.yaml |   1 -
 .../DEBUG_XCODE31/CompilerIntrinsicsLib.lib   | Bin 36072 -> 36072 bytes
 

Re: [edk2-devel] [edk2-libc Patch 1/1] AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI environment

2022-04-12 Thread Jayaprakash, N
Hi Mike,

This patch is yet to be merged. Could you look into this?

Regards,
JP

-Original Message-
From: Kinney, Michael D  
Sent: 08 April 2022 23:30
To: Jayaprakash, N ; devel@edk2.groups.io; Kinney, 
Michael D 
Cc: Frinzell, Aaron 
Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for UEFI 
environment

Thanks JP.

That makes sense.  Bypass all the OS specific services in UEFI environment and 
generate UUID using time and random number.

Reviewed-by: Michael D Kinney 

Mike


> -Original Message-
> From: Jayaprakash, N 
> Sent: Friday, April 8, 2022 10:19 AM
> To: devel@edk2.groups.io; Jayaprakash, N ; 
> Kinney, Michael D 
> Cc: Frinzell, Aaron 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> + Aaron
> 
> Regards,
> JP
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of 
> Jayaprakash, N
> Sent: 08 April 2022 22:12
> To: Kinney, Michael D ; 
> devel@edk2.groups.io
> Subject: Re: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> The UUID generation is done through the random number generation & 
> time unix time stamp features available through the built-in python modules 
> 'random' and 'time' respectively.
> The random number & time (unix time stamp or epoch) based method of 
> generating the UUID is already there in uuid.py module, with this patch 
> request enabled this path to take effect for UEFI invocation of this module.
> 
> There are some OS specific ways to generate the UUID's such as by 
> using the libuuid on Linux kind of OS, windll.rpcrt4 library on windows.
> These will not work for UEFI and hence added appropriate platform 
> check to ensure that this path is not taken for UEFI invocation.
> 
> Besides this there are MAC address based algorithms available in uuid.py 
> module.
> These algorism are based on reading MAC address through various OS 
> supported methods such as ipconfig command processing, NetBIOS calls 
> on Windows, using netstat command in Linux, lanscan in Unix, from arp - 
> address resolution protocol in Linux, NetBSD and other flavours of Linux.
> These are currently not enabled for UEFI invocation of the uuid 
> module. This has been done through platform check added at appropriate place 
> in the uuid.py module code.
> 
> Regards,
> JP
> -Original Message-
> From: Kinney, Michael D 
> Sent: 08 April 2022 21:14
> To: devel@edk2.groups.io; Jayaprakash, N ; 
> Kinney, Michael D 
> Subject: RE: [edk2-devel] [edk2-libc Patch 1/1] 
> AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> UEFI environment
> 
> How is a UUID generated in UEFI env?  Is there a dependency on MAC address or 
> random number generator?
> 
> Can you add a description of the technique to the BZ and the commit message?
> 
> Thanks,
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of 
> > Jayaprakash, N
> > Sent: Friday, April 8, 2022 4:52 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [edk2-libc Patch 1/1]
> > AppPkg\Applications\Python\Python-3.6.8\Lib: uuid.py module port for 
> > UEFI environment
> >
> >  REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3899
> >
> >  This is commit contains the UEFI port of uuid.py module. Made 
> > necessary  changes required to uuid.py module to support UEFI environment.
> >  Porting of this module to UEFI is required for open source tools 
> > such as Chipsec to function properly.
> >
> >  Cc: Rebecca Cran 
> >  Cc: Michael D Kinney 
> >  Signed-off-by: Jayaprakash N 
> > ---
> >  .../Python/Python-3.6.8/Lib/uuid.py   | 94 ++-
> >  1 file changed, 50 insertions(+), 44 deletions(-)
> >
> > diff --git a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > index db8b2ef..84ed0b8 100644
> > --- a/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > +++ b/AppPkg/Applications/Python/Python-3.6.8/Lib/uuid.py
> > @@ -471,57 +471,61 @@ def _netbios_getnode():
> >  continue
> >  return int.from_bytes(bytes, 'big')
> >
> > +
> >  # Thanks to Thomas Heller for ctypes and for his help with its use here.
> >
> >  # If ctypes is available, use it to find system routines for UUID 
> > generation.
> >  # XXX This makes the module non-thread-safe!
> >  _uuid_generate_time = _UuidCreate = None
> > -try:
> > -import ctypes, ctypes.util
> > -import sys
> > -
> > -# The uuid_generate_* routines are provided by libuuid on at least
> > -# Linux and FreeBSD, and provided by libc on Mac OS X.
> > -_libnames = ['uuid']
> > -if not sys.platform.startswith('win'):
> > -_libnames.append('c')
> > -for libname in _libnames:
> > -try:
> > -lib = 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 30/33] MdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.

2022-04-12 Thread Chao Li
Hi Abner,

Yes, I think it might be a coincidence, in fact, we have been using the UDK2018 
since 2018, and this code are not been modified after adding it.
I think maybe be our are all refer to the ARM architecture. Looking at this 
code, the function HandOffToDxeCore just switches from the PEI stage to the DXE 
stage, make stack of C environment, ends of PEI, and prepare to enter the DXE 
core.

--
Thanks,
Chao


On 4月 8 2022, at 7:13 晚上, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
> DxeLoadFunc.c is almost the same as RISC-V instance. However, I don't have 
> idea how to leverage it because DxeLoadFunc is currently in the 
> architecture-based folder.
>
> Acked-by: Abner Chang 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 4:02 PM
> > To: devel@edk2.groups.io
> > Cc: Liming Gao ; Guomin Jiang
> > ; Baoqi Zhang 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 30/33]
> > MdeModulePkg/DxeIplPeim : LoongArch DxeIPL implementation.
> >
> > Implement LoongArch DxeIPL instance.
> >
> > Cc: Liming Gao 
> > Cc: Guomin Jiang 
> >
> > Signed-off-by: Chao Li 
> > Co-authored-by: Baoqi Zhang 
> > ---
> > MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 6 +-
> > .../Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c | 61
> > +++
> > 2 files changed, 66 insertions(+), 1 deletion(-)
> > create mode 100644
> > MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> >
> > diff --git a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> > b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> > index 19b8a4c8ae..052ea0ec1a 100644
> > --- a/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> > +++ b/MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
> > @@ -8,6 +8,7 @@
> > # Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> > # Copyright (c) 2017, AMD Incorporated. All rights reserved.
> > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> > reserved.
> > +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > #
> > # SPDX-License-Identifier: BSD-2-Clause-Patent
> > #
> > @@ -26,7 +27,7 @@
> > #
> > # The following information is for reference only and not required by the
> > build tools.
> > #
> > -# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
> > AARCH64 RISCV64
> > +# VALID_ARCHITECTURES = IA32 X64 EBC (EBC is for build only)
> > AARCH64 RISCV64 LOONGARCH64
> > #
> >
> > [Sources]
> > @@ -53,6 +54,9 @@
> > [Sources.RISCV64]
> > RiscV64/DxeLoadFunc.c
> >
> > +[Sources.LOONGARCH64]
> > + LoongArch64/DxeLoadFunc.c
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> > MdeModulePkg/MdeModulePkg.dec
> > diff --git a/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> > b/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> > new file mode 100644
> > index 00..27ffc072d0
> > --- /dev/null
> > +++ b/MdeModulePkg/Core/DxeIplPeim/LoongArch64/DxeLoadFunc.c
> > @@ -0,0 +1,61 @@
> > +/** @file
> > + LoongArch specifc functionality for DxeLoad.
> > +
> > + Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include "DxeIpl.h"
> > +
> > +/**
> > + Transfers control to DxeCore.
> > +
> > + This function performs a CPU architecture specific operations to execute
> > + the entry point of DxeCore with the parameters of HobList.
> > + It also installs EFI_END_OF_PEI_PPI to signal the end of PEI phase.
> > +
> > + @param DxeCoreEntryPoint The entry point of DxeCore.
> > + @param HobList The start of HobList passed to DxeCore.
> > +
> > +**/
> > +VOID
> > +HandOffToDxeCore (
> > + IN EFI_PHYSICAL_ADDRESS DxeCoreEntryPoint,
> > + IN EFI_PEI_HOB_POINTERS HobList
> > + )
> > +{
> > + VOID *BaseOfStack;
> > + VOID *TopOfStack;
> > + EFI_STATUS Status;
> > +
> > + //
> > + // Allocate 128KB for the Stack
> > + //
> > + BaseOfStack = AllocatePages (EFI_SIZE_TO_PAGES (STACK_SIZE));
> > + ASSERT (BaseOfStack != NULL);
> > + //
> > + // Compute the top of the stack we were allocated. Pre-allocate a UINTN
> > + // for safety.
> > + //
> > + TopOfStack = (VOID *) ((UINTN) BaseOfStack + EFI_SIZE_TO_PAGES
> > (STACK_SIZE) * EFI_PAGE_SIZE - CPU_STACK_ALIGNMENT);
> > + TopOfStack = ALIGN_POINTER (TopOfStack, CPU_STACK_ALIGNMENT);
> > + //
> > + // End of PEI phase singal
> > + //
> > + Status = PeiServicesInstallPpi ();
> > + ASSERT_EFI_ERROR (Status);
> > +
> > + //
> > + // Update the contents of BSP stack HOB to reflect the real stack info
> > passed to DxeCore.
> > + //
> > + UpdateStackHob ((EFI_PHYSICAL_ADDRESS)(UINTN) BaseOfStack,
> > STACK_SIZE);
> > +
> > + SwitchStack (
> > + (SWITCH_STACK_ENTRY_POINT)(UINTN)DxeCoreEntryPoint,
> > + HobList.Raw,
> > + NULL,
> > + TopOfStack
> > + );
> > +}
> > --
> > 2.27.0
> >
> >
> >
> > 
> >
>



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88771): 

[edk2-devel] [PATCH v2 1/1] MdePkg/Include: Use DEBUG_FILE_PATH to specify debug file path.

2022-04-12 Thread Guomin Jiang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3840

Use DEBUG_FILE_PATH to control ASSERT path

Motivation and Goal:
1. Make replication build more easy and less toolchain dependency
2. Consume the ASSERT string easy for downstream
3. Make code more clear

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Guomin Jiang 
---
 MdePkg/Include/Library/DebugLib.h | 34 +--
 1 file changed, 23 insertions(+), 11 deletions(-)

diff --git a/MdePkg/Include/Library/DebugLib.h 
b/MdePkg/Include/Library/DebugLib.h
index 8d3d08638d73..a76a268a00b6 100644
--- a/MdePkg/Include/Library/DebugLib.h
+++ b/MdePkg/Include/Library/DebugLib.h
@@ -8,7 +8,7 @@
   of size reduction when compiler optimization is disabled. If MDEPKG_NDEBUG is
   defined, then debug and assert related macros wrapped by it are the NULL 
implementations.
 
-Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -85,6 +85,26 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #define DEBUG_LINE_NUMBER  __LINE__
 #endif
 
+//
+// Source file path.
+// Default is use the __FILE__ macro value provided by compiler. The __FILE__
+// mapping can be overriden by predefining DEBUG_FILE_PATH
+//
+// Defining DEBUG_FILE_PATH to a fixed value is useful when comparing builds
+// across machine or configuration with different slash or path file.
+//
+#ifndef DEBUG_FILE_PATH
+#define DEBUG_FILE_PATH  __FILE__
+#endif
+
+//
+// Use below override to keep CLANG specific behavior
+//
+#if defined (__clang__) && defined (__FILE_NAME__)
+  #undef DEBUG_FILE_PATH
+#define DEBUG_FILE_PATH  __FILE_NAME__
+#endif
+
 /**
   Macro that converts a Boolean expression to a Null-terminated ASCII string.
 
@@ -337,17 +357,9 @@ UnitTestDebugAssert (
   IN CONST CHAR8  *Description
   );
 
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE_NAME__, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  UnitTestDebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  UnitTestDebugAssert (DEBUG_FILE_PATH, 
DEBUG_LINE_NUMBER, DEBUG_EXPRESSION_STRING (Expression))
 #else
-  #if defined (__clang__) && defined (__FILE_NAME__)
-#define _ASSERT(Expression)  DebugAssert (__FILE_NAME__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #else
-#define _ASSERT(Expression)  DebugAssert (__FILE__, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
-  #endif
+#define _ASSERT(Expression)  DebugAssert (DEBUG_FILE_PATH, DEBUG_LINE_NUMBER, 
DEBUG_EXPRESSION_STRING (Expression))
 #endif
 
 /**
-- 
2.35.1.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88770): https://edk2.groups.io/g/devel/message/88770
Mute This Topic: https://groups.io/mt/90415241/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 26/33] MdePkg/BaseSynchronizationLib: LoongArch cache related code.

2022-04-12 Thread Chao Li
Hi Abner,

All of the feedback that you pointed out I will fix it in the next version, 
thank you!

--
Thanks,
Chao


On 4月 8 2022, at 7:02 晚上, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:56 PM
> > To: devel@edk2.groups.io
> > Cc: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu ; Baoqi
> > Zhang 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 26/33]
> > MdePkg/BaseSynchronizationLib: LoongArch cache related code.
> >
> > Support LoongArch cache related functions.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Chao Li 
> > Co-authored-by: Baoqi Zhang 
> > ---
> > .../BaseSynchronizationLib.inf | 5 +
> > .../LoongArch64/Synchronization.c | 239 ++
> > 2 files changed, 244 insertions(+)
> > create mode 100644
> > MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> >
> > diff --git
> > a/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> > b/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> > index 83d5b8ed7c..3cf5b6d4b1 100755
> > --- a/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> > +++ b/MdePkg/Library/BaseSynchronizationLib/BaseSynchronizationLib.inf
> > @@ -4,6 +4,7 @@
> > # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
> > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > # Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> > reserved.
> > +# Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > #
> > # SPDX-License-Identifier: BSD-2-Clause-Patent
> > #
> > @@ -83,6 +84,10 @@
> > Synchronization.c
> > RiscV64/Synchronization.S
> >
> > +[Sources.LOONGARCH64]
> > + Synchronization.c
> > + LoongArch64/Synchronization.c
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> >
> > diff --git
> > a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> > b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> > new file mode 100644
> > index 00..a191a50c81
> > --- /dev/null
> > +++
> > b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c
> > @@ -0,0 +1,239 @@
> > +/** @file
> > + LoongArch synchronization functions.
> > +
> > + Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#include 
> > +
> > +/**
> > + Performs an atomic compare exchange operation on a 16-bit
> > + unsigned integer.
> > +
> > + Performs an atomic compare exchange operation on the 16-bit
> > + unsigned integer specified by Value. If Value is equal to
> > + CompareValue, then Value is set to ExchangeValue and
> > + CompareValue is returned. If Value is not equal to
> > + CompareValue, then Value is returned. The compare exchange
> > + operation must be performed using MP safe mechanisms.
> > +
> > + @param Value A pointer to the 16-bit value for the
> > + compare exchange operation.
> > + @param CompareValue 16-bit value used in compare operation.
> > + @param ExchangeValue 16-bit value used in exchange operation.
> > +
> > + @return The original *Value before exchange.
> I see the modifiers (e.g., IN and/or OUT) are not assigned to @param of 
> arguments in the function header across the source files in this patch set. I 
> know some old source files don't have modifiers neither, however, we should 
> have those in the new source file according to the coding standard.
>
> > +
> > +**/
> > +UINT16
> > +EFIAPI
> > +InternalSyncCompareExchange16 (
> > + IN volatile UINT16 *Value,
> > + IN UINT16 CompareValue,
> > + IN UINT16 ExchangeValue
> > + )
> > +{
> > + UINT32 RetValue, Temp, Shift;
> > + UINT64 Mask, LocalCompareValue, LocalExchangeValue;
> > + volatile UINT32 *Ptr32;
> I can't find the statement in the edk2 C coding standard spec, however as I 
> can remember each local variable should start at a new line.
> > +
> > + /* Check that ptr is naturally aligned */
> > + ASSERT(!((UINT64)Value & (sizeof(Value) - 1)));
> Please use double back slash for the comment.
> > +
> > + /* Mask inputs to the correct size. */
> > + Mask = (((~0UL) - (1UL << (0)) + 1) & (~0UL >> (64 - 1 - ((sizeof(UINT16) 
> > * 8)
> > - 1;
> > + LocalCompareValue = ((UINT64)CompareValue) & Mask;
> > + LocalExchangeValue = ((UINT64)ExchangeValue) & Mask;
> > +
> > + /*
> > + * Calculate a shift & mask that correspond to the value we wish to
> > + * compare & exchange within the naturally aligned 4 byte integer
> > + * that includes it.
> > + */
> > + Shift = (UINT64)Value & 0x3;
> > + Shift *= 8; /* BITS_PER_BYTE */
> > + LocalCompareValue <<= Shift;
> > + LocalExchangeValue <<= Shift;
> > + Mask <<= Shift;
> > +
> > + /*
> > + * Calculate a pointer to the naturally aligned 4 byte integer that
> > 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33] MdePkg/BasePeCoff: Add LoongArch PE/Coff related code.

2022-04-12 Thread Chao Li


--
Thanks,
Chao


On 4月 8 2022, at 5:38 下午, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:56 PM
> > To: devel@edk2.groups.io
> > Cc: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu ; Baoqi
> > Zhang 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 24/33]
> > MdePkg/BasePeCoff: Add LoongArch PE/Coff related code.
> >
> > Add LoongArch image relocation.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Chao Li 
> > Co-authored-by: Baoqi Zhang 
> > ---
> > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 3 +-
> > .../Library/BasePeCoffLib/BasePeCoffLib.inf | 5 +
> > .../Library/BasePeCoffLib/BasePeCoffLib.uni | 2 +
> > .../BasePeCoffLib/LoongArch/PeCoffLoaderEx.c | 132
> > ++
> > 4 files changed, 141 insertions(+), 1 deletion(-)
> > create mode 100644
> > MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> >
> > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > index 6d8d9faeb8..97a8aaf8c7 100644
> > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > @@ -1,6 +1,6 @@
> > /** @file
> > Base PE/COFF loader supports loading any PE32/PE32+ or TE image, but
> > - only supports relocating IA32, x64, IPF, ARM, RISC-V and EBC images.
> > + only supports relocating IA32, x64, IPF, ARM, RISC-V, LoongArch and EBC
> > images.
> >
> > Caution: This file requires additional review when modified.
> > This library will have external input - PE/COFF image.
> > @@ -18,6 +18,7 @@
> > Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> > Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> > All rights reserved.
> > + Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> > rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> > index 110b6d5a09..3b8b8eb191 100644
> > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf
> > @@ -4,6 +4,7 @@
> > # The IA32 version library support loading IA32, X64 and EBC PE/COFF images.
> > # The X64 version library support loading IA32, X64 and EBC PE/COFF images.
> > # The RISC-V version library support loading RISC-V images.
> > +# The LoongArch version library support loading LoongArch images.
> > #
> > # Caution: This module requires additional review when modified.
> > # This library will have external input - PE/COFF image.
> > @@ -13,6 +14,7 @@
> > # Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> > # Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > # Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> > All rights reserved.
> > +# Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> > rights reserved.
> > #
> > # SPDX-License-Identifier: BSD-2-Clause-Patent
> > #
> > @@ -46,6 +48,9 @@
> > [Sources.RISCV64]
> > RiscV/PeCoffLoaderEx.c
> >
> > +[Sources.LOONGARCH64]
> > + LoongArch/PeCoffLoaderEx.c
> > +
> > [Packages]
> > MdePkg/MdePkg.dec
> >
> > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> > b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> > index 55417029f2..1f731344e1 100644
> > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoffLib.uni
> > @@ -5,6 +5,7 @@
> > // The IA32 version library support loading IA32, X64 and EBC PE/COFF
> > images.
> > // The X64 version library support loading IA32, X64 and EBC PE/COFF images.
> > // The RISC-V version library support loading RISC-V32 and RISC-V64 PE/COFF
> > images.
> > +// The LoongArch version library support loading LoongArch32 and
> > LoongArch64 PE/COFF images.
> > //
> > // Caution: This module requires additional review when modified.
> > // This library will have external input - PE/COFF image.
> > @@ -14,6 +15,7 @@
> > // Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> > // Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > // Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP.
> > All rights reserved.
> > +// Portions Copyright (c) 2022, Loongson Technology Corporation Limited.
> > All rights reserved.
> > //
> > // SPDX-License-Identifier: BSD-2-Clause-Patent
> > //
> > diff --git a/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> > b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> > new file mode 100644
> > index 00..ec572c2dd6
> > --- /dev/null
> > +++ b/MdePkg/Library/BasePeCoffLib/LoongArch/PeCoffLoaderEx.c
> > @@ -0,0 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 13/33] BaseTools: BaseTools changes for LoongArch platform.

2022-04-12 Thread Chao Li
Hi Anber,

Please check my reply in the mail.

--
Thanks,
Chao


On 4月 8 2022, at 2:25 下午, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:55 PM
> > To: devel@edk2.groups.io
> > Cc: Bob Feng ; Liming Gao
> > ; Yuwei Chen ; Baoqi
> > Zhang 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 13/33]
> > BaseTools: BaseTools changes for LoongArch platform.
> >
> > C code changes for building EDK2 LoongArch platform.
> >
> > Cc: Bob Feng 
> > Cc: Liming Gao 
> > Cc: Yuwei Chen 
> >
> > Signed-off-by: Chao Li 
> > Co-authored-by: Baoqi Zhang 
> > ---
> > BaseTools/Source/C/Common/BasePeCoff.c | 15 +-
> > BaseTools/Source/C/Common/PeCoffLoaderEx.c | 76 +
> > BaseTools/Source/C/GenFv/GenFvInternalLib.c | 128 ++-
> > BaseTools/Source/C/GenFw/Elf64Convert.c | 153 +-
> > BaseTools/Source/C/GenFw/elf_common.h | 58 +++
> > .../C/Include/IndustryStandard/PeImage.h | 57 ---
> > 6 files changed, 454 insertions(+), 33 deletions(-)
> >
> > diff --git a/BaseTools/Source/C/Common/BasePeCoff.c
> > b/BaseTools/Source/C/Common/BasePeCoff.c
> > index 62fbb2985c..30400d1341 100644
> > --- a/BaseTools/Source/C/Common/BasePeCoff.c
> > +++ b/BaseTools/Source/C/Common/BasePeCoff.c
> > @@ -5,6 +5,7 @@
> > Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
> > Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
> > Portions Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
> > rights reserved.
> > +Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> > rights reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > **/
> > @@ -68,6 +69,14 @@ PeCoffLoaderRelocateRiscVImage (
> > IN UINT64 Adjust
> > );
> >
> > +RETURN_STATUS
> > +PeCoffLoaderRelocateLoongArch64Image (
> > + IN UINT16 *Reloc,
> > + IN OUT CHAR8 *Fixup,
> > + IN OUT CHAR8 **FixupData,
> > + IN UINT64 Adjust
> > + );
> > +
> > STATIC
> > RETURN_STATUS
> > PeCoffLoaderGetPeHeader (
> > @@ -184,7 +193,8 @@ Returns:
> > ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \
> > ImageContext->Machine != EFI_IMAGE_MACHINE_EBC && \
> > ImageContext->Machine != EFI_IMAGE_MACHINE_AARCH64 && \
> > - ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64) {
> > + ImageContext->Machine != EFI_IMAGE_MACHINE_RISCV64 && \
> > + ImageContext->Machine != EFI_IMAGE_MACHINE_LOONGARCH64) {
> > if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) {
> > //
> > // There are two types of ARM images. Pure ARM and ARM/Thumb.
> > @@ -815,6 +825,9 @@ Returns:
> > case EFI_IMAGE_MACHINE_RISCV64:
> > Status = PeCoffLoaderRelocateRiscVImage (Reloc, Fixup, ,
> > Adjust);
> > break;
> > + case EFI_IMAGE_MACHINE_LOONGARCH64:
> > + Status = PeCoffLoaderRelocateLoongArch64Image (Reloc, Fixup,
> > , Adjust);
> > + break;
> > default:
> > Status = RETURN_UNSUPPORTED;
> > break;
> > diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> > b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> > index 799f282970..b50ce8bdef 100644
> > --- a/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> > +++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
> > @@ -4,6 +4,7 @@ IA32 and X64 Specific relocation fixups
> > Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
> > Portions Copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.
> > Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights
> > reserved.
> > +Copyright (c) 2022, Loongson Technology Corporation Limited. All rights
> > reserved.
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > --*/
> > @@ -332,3 +333,78 @@ PeCoffLoaderRelocateArmImage (
> >
> > return RETURN_SUCCESS;
> > }
> > +
> > +/**
> > + Performs a LoongArch specific relocation fixup.
> > +
> > + @param Reloc Pointer to the relocation record.
> > + @param Fixup Pointer to the address to fix up.
> > + @param FixupData Pointer to a buffer to log the fixups.
> > + @param Adjust The offset to adjust the fixup.
> > +
> > + @return Status code.
> > +**/
> > +RETURN_STATUS
> > +PeCoffLoaderRelocateLoongArch64Image (
> > + IN UINT16 *Reloc,
> > + IN OUT CHAR8 *Fixup,
> > + IN OUT CHAR8 **FixupData,
> > + IN UINT64 Adjust
> > + )
> > +{
> > + UINT8 RelocType;
> > + UINT64 Value = 0;
> > + UINT64 Tmp1 = 0;
> > + UINT64 Tmp2 = 0;
> > +
> > + RelocType = ((*Reloc) >> 12);
> > +
> > + switch (RelocType) {
> > + case EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA:
> > + /* The next four instructions are used to load a 64 bit address, we
> > change it together*/
> > + Value = (*(UINT32*)Fixup & 0x1e0) << 7 | /* lu12i.w 20bits from
> > bit5 */
> Please use double back slash for the comment in the function. So the comment 
> in the entire file look consistent. This applied to the changes in this patch.
>

Chao: Okay, I will revise it in the next version.

> + (*((UINT32*)Fixup + 1) & 0x3ffc00) >> 10; /* ori 12bits 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 20/33] MdePkg/Include: LoongArch definitions.

2022-04-12 Thread Chao Li
Hi Abner,
Yes, the PE/COFF has been adapted to LoongArch32 and LoongArch64, please refer 
to: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format 
(https://link.getmailspring.com/link/9a61f0c8-a7fa-41ad-b0f6-769ec7687...@getmailspring.com/0?redirect=https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fwin32%2Fdebug%2Fpe-format=ZGV2ZWxAZWRrMi5ncm91cHMuaW8%3D)
 and search "LoongArch" for more information.

--
Thanks,
Chao


On 4月 7 2022, at 10:23 晚上, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:56 PM
> > To: devel@edk2.groups.io
> > Cc: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 20/33]
> > MdePkg/Include: LoongArch definitions.
> >
> > Add LoongArch processor related definitions.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Chao Li 
> > ---
> > MdePkg/Include/IndustryStandard/PeImage.h | 9 
> > MdePkg/Include/Protocol/DebugSupport.h | 65
> > ---
> > MdePkg/Include/Protocol/PxeBaseCode.h | 3 ++
> > MdePkg/Include/Uefi/UefiBaseType.h | 14 +
> > MdePkg/Include/Uefi/UefiSpec.h | 16 +++---
> > 5 files changed, 94 insertions(+), 13 deletions(-)
> >
> > diff --git a/MdePkg/Include/IndustryStandard/PeImage.h
> > b/MdePkg/Include/IndustryStandard/PeImage.h
> > index 3109dc20f8..3741f21719 100644
> > --- a/MdePkg/Include/IndustryStandard/PeImage.h
> > +++ b/MdePkg/Include/IndustryStandard/PeImage.h
> > @@ -10,6 +10,7 @@
> > Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> > Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
> > Portions Copyright (c) 2016 - 2020, Hewlett Packard Enterprise Development
> > LP. All rights reserved.
> > +Portions Copyright (c) 2022, Loongson Technology Corporation Limited. All
> > rights reserved.
> >
> > SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -38,6 +39,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > #define IMAGE_FILE_MACHINE_RISCV32 0x5032
> > #define IMAGE_FILE_MACHINE_RISCV64 0x5064
> > #define IMAGE_FILE_MACHINE_RISCV128 0x5128
> > +#define IMAGE_FILE_MACHINE_LOONGARCH32 0x6232
> > +#define IMAGE_FILE_MACHINE_LOONGARCH64 0x6264
>
> Are those Loongarch machine types already defined in PeCoff spec? Could you 
> please point me to the spec?
> The rest looks good to me.
> Acked-by: Abner Chang 
> >
> > //
> > // EXE file formats
> > @@ -503,6 +506,12 @@ typedef struct {
> > #define EFI_IMAGE_REL_BASED_RISCV_LOW12I 7
> > #define EFI_IMAGE_REL_BASED_RISCV_LOW12S 8
> >
> > +//
> > +// Relocation types of LoongArch processor.
> > +//
> > +#define EFI_IMAGE_REL_BASED_LOONGARCH32_MARK_LA 8
> > +#define EFI_IMAGE_REL_BASED_LOONGARCH64_MARK_LA 8
> > +
> > ///
> > /// Line number format.
> > ///
> > diff --git a/MdePkg/Include/Protocol/DebugSupport.h
> > b/MdePkg/Include/Protocol/DebugSupport.h
> > index ec5b92a5c5..47e3a44410 100644
> > --- a/MdePkg/Include/Protocol/DebugSupport.h
> > +++ b/MdePkg/Include/Protocol/DebugSupport.h
> > @@ -654,17 +654,68 @@ typedef struct {
> > UINT64 X31;
> > } EFI_SYSTEM_CONTEXT_RISCV64;
> >
> > +//
> > +// LoongArch processor exception types.
> > +//
> > +#define MAX_LOONGARCH_EXCEPTION 14
> > +
> > +typedef struct {
> > + UINT64 R0;
> > + UINT64 R1;
> > + UINT64 R2;
> > + UINT64 R3;
> > + UINT64 R4;
> > + UINT64 R5;
> > + UINT64 R6;
> > + UINT64 R7;
> > + UINT64 R8;
> > + UINT64 R9;
> > + UINT64 R10;
> > + UINT64 R11;
> > + UINT64 R12;
> > + UINT64 R13;
> > + UINT64 R14;
> > + UINT64 R15;
> > + UINT64 R16;
> > + UINT64 R17;
> > + UINT64 R18;
> > + UINT64 R19;
> > + UINT64 R20;
> > + UINT64 R21;
> > + UINT64 R22;
> > + UINT64 R23;
> > + UINT64 R24;
> > + UINT64 R25;
> > + UINT64 R26;
> > + UINT64 R27;
> > + UINT64 R28;
> > + UINT64 R29;
> > + UINT64 R30;
> > + UINT64 R31;
> > +
> > + UINT64 CRMD; // CuRrent MoDe information
> > + UINT64 PRMD; // PRe-exception MoDe information
> > + UINT64 EUEN; // Extended component Unit ENable
> > + UINT64 MISC; // MISCellaneous controller
> > + UINT64 ECFG; // Exception ConFiGuration
> > + UINT64 ESTAT; // Exception STATus
> > + UINT64 ERA; // Exception Return Address
> > + UINT64 BADV; // BAD Virtual address
> > + UINT64 BADI; // BAD Instruction
> > +} EFI_SYSTEM_CONTEXT_LOONGARCH64;
> > +
> > ///
> > /// Universal EFI_SYSTEM_CONTEXT definition.
> > ///
> > typedef union {
> > - EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc;
> > - EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;
> > - EFI_SYSTEM_CONTEXT_X64 *SystemContextX64;
> > - EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf;
> > - EFI_SYSTEM_CONTEXT_ARM *SystemContextArm;
> > - EFI_SYSTEM_CONTEXT_AARCH64 *SystemContextAArch64;
> > - EFI_SYSTEM_CONTEXT_RISCV64 *SystemContextRiscV64;
> > + EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc;
> > + EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;
> > + EFI_SYSTEM_CONTEXT_X64 

Re: [edk2-devel] [staging/LoongArch RESEND PATCH v1 19/33] MdePkg: Add LoongArch LOONGARCH64 binding

2022-04-12 Thread Chao Li
Hi Abner,

Do I have to remove a "_" at the head and tail? All I found in MdePkg is that 
*.h files have two "_" at the head and tail. If you are sure that EDK II coding 
style must contain only one "_" at the head and tail, I will modify it.

--
Thanks,
Chao


On 4月 7 2022, at 10:15 晚上, "Chang, Abner (HPS SW/FW Technologist)" 
 wrote:
>
>
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Chao Li
> > Sent: Wednesday, February 9, 2022 2:56 PM
> > To: devel@edk2.groups.io
> > Cc: Michael D Kinney ; Liming Gao
> > ; Zhiguang Liu ; Baoqi
> > Zhang ; Dongyan Qian
> > 
> > Subject: [edk2-devel] [staging/LoongArch RESEND PATCH v1 19/33] MdePkg:
> > Add LoongArch LOONGARCH64 binding
> >
> > Add LOONGARCH64 sections in MdePkg.dec and LOONGARCH64
> > ProcessorBind.h
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> >
> > Signed-off-by: Chao Li 
> > Co-authored-by: Baoqi Zhang 
> > Co-authored-by: Dongyan Qian 
> > ---
> > MdePkg/Include/LoongArch64/ProcessorBind.h | 121
> > +
> > MdePkg/MdePkg.dec | 4 +
> > MdePkg/MdePkg.dsc | 3 +-
> > 3 files changed, 127 insertions(+), 1 deletion(-)
> > create mode 100644 MdePkg/Include/LoongArch64/ProcessorBind.h
> >
> > diff --git a/MdePkg/Include/LoongArch64/ProcessorBind.h
> > b/MdePkg/Include/LoongArch64/ProcessorBind.h
> > new file mode 100644
> > index 00..a10481e285
> > --- /dev/null
> > +++ b/MdePkg/Include/LoongArch64/ProcessorBind.h
> > @@ -0,0 +1,121 @@
> > +/** @file
> > + Processor or Compiler specific defines and types for LoongArch
> > +
> > + Copyright (c) 2022 Loongson Technology Corporation Limited. All rights
> > reserved.
> > +
> > + SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +#ifndef __PROCESSOR_BIND_H__
> > +#define __PROCESSOR_BIND_H__
> Please remove the leading "_" and only keep one trailing "_" to follow the 
> edk2 coding standard. RISC-V ProcessorBind.h has the mistake.
>
> Abner
> > +
> > +//
> > +// Define the processor type so other code can make processor based
> > choices
> > +//
> > +#define MDE_CPU_LOONGARCH64
> > +
> > +#define EFIAPI
> > +
> > +//
> > +// Make sure we are using the correct packing rules per EFI specification
> > +//
> > +#ifndef __GNUC__
> > +#pragma pack()
> > +#endif
> > +
> > +//
> > +// Assume standard LoongArch 64-bit alignment.
> > +// Need to check portability of long long
> > +//
> > +typedef unsigned long UINT64;
> > +typedef long INT64;
> > +typedef unsigned int UINT32;
> > +typedef int INT32;
> > +typedef unsigned short UINT16;
> > +typedef unsigned short CHAR16;
> > +typedef short INT16;
> > +typedef unsigned char BOOLEAN;
> > +typedef unsigned char UINT8;
> > +typedef char CHAR8;
> > +typedef char INT8;
> > +
> > +//
> > +// Unsigned value of native width. (4 bytes on supported 32-bit processor
> > instructions,
> > +// 8 bytes on supported 64-bit processor instructions)
> > +//
> > +
> > +typedef UINT64 UINTN;
> > +
> > +//
> > +// Signed value of native width. (4 bytes on supported 32-bit processor
> > instructions,
> > +// 8 bytes on supported 64-bit processor instructions)
> > +//
> > +typedef INT64 INTN;
> > +
> > +//
> > +// Processor specific defines
> > +//
> > +
> > +//
> > +// A value of native width with the highest bit set.
> > +//
> > +#define MAX_BIT 0x8000ULL
> > +//
> > +// A value of native width with the two highest bits set.
> > +//
> > +#define MAX_2_BITS 0xC000ULL
> > +
> > +//
> > +// Maximum legal LoongArch 64-bit address
> > +//
> > +#define MAX_ADDRESS 0xULL
> > +
> > +//
> > +// Maximum usable address at boot time (48 bits using 4KB pages)
> > +//
> > +#define MAX_ALLOC_ADDRESS 0xULL
> > +
> > +
> > +//
> > +// Maximum legal LoongArch 64-bit INTN and UINTN values.
> > +//
> > +#define MAX_INTN ((INTN)0x7FFFULL)
> > +#define MAX_UINTN ((UINTN)0xULL)
> > +
> > +//
> > +// Page allocation granularity for LoongArch
> > +//
> > +#define DEFAULT_PAGE_ALLOCATION_GRANULARITY (0x1000)
> > +#define RUNTIME_PAGE_ALLOCATION_GRANULARITY (0x1)
> > +
> > +#if defined(__GNUC__)
> > + //
> > + // For GNU assembly code, .global or .globl can declare global symbols.
> > + // Define this macro to unify the usage.
> > + //
> > + #define ASM_GLOBAL .globl
> > +#endif
> > +
> > +//
> > +// The stack alignment required for LoongArch
> > +//
> > +#define CPU_STACK_ALIGNMENT 16
> > +
> > +/**
> > + Return the pointer to the first instruction of a function given a function
> > pointer.
> > + On LOONGARCH CPU architectures, these two pointer values are the same,
> > + so the implementation of this macro is very simple.
> > +
> > + @param FunctionPointer A pointer to a function.
> > +
> > + @return The pointer to the first instruction of a function given a 
> > function
> > pointer.
> > +
> > +**/
> > +#define FUNCTION_ENTRY_POINT(FunctionPointer) (VOID
> > *)(UINTN)(FunctionPointer)
> > +
> > +#ifndef 

Re: [edk2-devel] [PATCH v3 2/6] OvmfPkg/FdtPciHostBridgeLib: io range is not mandatory

2022-04-12 Thread Gerd Hoffmann
  Hi,

> > -  Io.Base   = IoBase;
> > -  Io.Limit  = IoBase + IoSize - 1;
> > +  if (IoSize) {
> > +Io.Base  = IoBase;
> > +Io.Limit = IoBase + IoSize - 1;
> > +  } else {
> > +Io.Base  = MAX_UINT64;
> > +Io.Limit = 0;
> HI Gerd,
> Does the consumer of Io (in PCI_ROOT_BRIDGE structure) know that the 
> MAX_UINT64 for Io.Base refers to no memory map I/O?

Patch #1 handles that.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88764): https://edk2.groups.io/g/devel/message/88764
Mute This Topic: https://groups.io/mt/90309349/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v3 2/6] OvmfPkg/FdtPciHostBridgeLib: io range is not mandatory

2022-04-12 Thread Abner Chang



> -Original Message-
> From: Gerd Hoffmann 
> Sent: Thursday, April 7, 2022 5:33 PM
> To: devel@edk2.groups.io
> Cc: Leif Lindholm ; Ard Biesheuvel
> ; Jordan Justen ;
> Jian J Wang ; Ray Ni ; Hao A Wu
> ; Gerd Hoffmann ; Jiewen Yao
> ; Liming Gao ; Pawel
> Polawski ; Chang, Abner (HPS SW/FW Technologist)
> ; Oliver Steffen 
> Subject: [PATCH v3 2/6] OvmfPkg/FdtPciHostBridgeLib: io range is not
> mandatory
> 
> io range is not mandatory according to pcie spec,
> so allow host bridges without io address space.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  .../FdtPciHostBridgeLib/FdtPciHostBridgeLib.c | 45 ++-
>  1 file changed, 23 insertions(+), 22 deletions(-)
> 
> diff --git a/OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
> b/OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
> index 98828e0b262b..823ea47c80a3 100644
> --- a/OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
> +++ b/OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c
> @@ -292,13 +292,8 @@ ProcessPciHost (
>  }
>}
> 
> -  if ((*IoSize == 0) || (*Mmio32Size == 0)) {
> -DEBUG ((
> -  DEBUG_ERROR,
> -  "%a: %a space empty\n",
> -  __FUNCTION__,
> -  (*IoSize == 0) ? "IO" : "MMIO32"
> -  ));
> +  if (*Mmio32Size == 0) {
> +DEBUG ((DEBUG_ERROR, "%a: MMIO32 space empty\n",
> __FUNCTION__));
>  return EFI_PROTOCOL_ERROR;
>}
> 
> @@ -333,13 +328,15 @@ ProcessPciHost (
>  return Status;
>}
> 
> -  //
> -  // Map the MMIO window that provides I/O access - the PCI host bridge
> code
> -  // is not aware of this translation and so it will only map the I/O view
> -  // in the GCD I/O map.
> -  //
> -  Status = MapGcdMmioSpace (*IoBase + IoTranslation, *IoSize);
> -  ASSERT_EFI_ERROR (Status);
> +  if (*IoSize) {
> +//
> +// Map the MMIO window that provides I/O access - the PCI host bridge
> code
> +// is not aware of this translation and so it will only map the I/O view
> +// in the GCD I/O map.
> +//
> +Status = MapGcdMmioSpace (*IoBase + IoTranslation, *IoSize);
> +ASSERT_EFI_ERROR (Status);
> +  }
> 
>return Status;
>  }
> @@ -413,17 +410,21 @@ PciHostBridgeGetRootBridges (
> 
>AllocationAttributes = EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM;
> 
> -  Io.Base   = IoBase;
> -  Io.Limit  = IoBase + IoSize - 1;
> +  if (IoSize) {
> +Io.Base  = IoBase;
> +Io.Limit = IoBase + IoSize - 1;
> +  } else {
> +Io.Base  = MAX_UINT64;
> +Io.Limit = 0;
HI Gerd,
Does the consumer of Io (in PCI_ROOT_BRIDGE structure) know that the MAX_UINT64 
for Io.Base refers to no memory map I/O?
Abner
> +  }
> +
>Mem.Base  = Mmio32Base;
>Mem.Limit = Mmio32Base + Mmio32Size - 1;
> 
> -  if (sizeof (UINTN) == sizeof (UINT64)) {
> -MemAbove4G.Base  = Mmio64Base;
> -MemAbove4G.Limit = Mmio64Base + Mmio64Size - 1;
> -if (Mmio64Size > 0) {
> -  AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
> -}
> +  if ((sizeof (UINTN) == sizeof (UINT64)) && Mmio64Size) {
> +MemAbove4G.Base   = Mmio64Base;
> +MemAbove4G.Limit  = Mmio64Base + Mmio64Size - 1;
> +AllocationAttributes |= EFI_PCI_HOST_BRIDGE_MEM64_DECODE;
>} else {
>  //
>  // UEFI mandates a 1:1 virtual-to-physical mapping, so on a 32-bit
> --
> 2.35.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88763): https://edk2.groups.io/g/devel/message/88763
Mute This Topic: https://groups.io/mt/90309349/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/2] MdeModulePkg/dec: update the PcdCpuStackGuard property

2022-04-12 Thread Jeff Fan
Please correct the commit message which confused me.

It should be "Update the PcdCpuStackGuard to support PcdsPatchableInModule, 
PcdsDynamci and PcdsDynamciEx ... ..."

Thanks!
Jeff


fanjianf...@byosoft.com.cn
 
From: Chen, Gang C
Date: 2022-04-11 18:13
To: devel
CC: guomin.jiang; dandan.bi; di.zhang; Jian J Wang; Liming Gao
Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg/dec: update the PcdCpuStackGuard 
property
Update the PcdCpuStackGuard from PcdsFixedAtBuild to PcdsDynamicEx
for the requirement to set different value in FSP API mode and FSP
Dispatch mode.
 
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3897
 
Cc: Jian J Wang 
Cc: Liming Gao 
Cc: devel@edk2.groups.io
 
Signed-off-by: Gang Chen 
---
MdeModulePkg/MdeModulePkg.dec | 14 +++---
1 file changed, 7 insertions(+), 7 deletions(-)
 
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 463e889e9a..72e7e2eced 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -1070,13 +1070,6 @@
   # @Prompt The Heap Guard feature mask
   gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask|0x0|UINT8|0x30001054
-  ## Indicates if UEFI Stack Guard will be enabled.
-  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
consequences.
-  #   TRUE  - UEFI Stack Guard will be enabled.
-  #   FALSE - UEFI Stack Guard will be disabled.
-  # @Prompt Enable UEFI Stack Guard.
-  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055
-
[PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Dynamic type PCD can be registered callback function for Pcd setting 
action.
   #  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of 
callback function
@@ -2079,6 +2072,13 @@
   # @Prompt Enable PCIe Resizable BAR Capability support.
   
gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport|FALSE|BOOLEAN|0x1024
+  ## Indicates if UEFI Stack Guard will be enabled.
+  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
consequences.
+  #   TRUE  - UEFI Stack Guard will be enabled.
+  #   FALSE - UEFI Stack Guard will be disabled.
+  # @Prompt Enable UEFI Stack Guard.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x00010025
+
[PcdsPatchableInModule]
   ## Specify memory size with page number for PEI code when
   #  Loading Module at Fixed Address feature is enabled.
-- 
2.35.1
 
 
 

 
 
 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88762): https://edk2.groups.io/g/devel/message/88762
Mute This Topic: https://groups.io/mt/90391665/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/2] MdeModulePkg/dec: update the PcdCpuStackGuard property

2022-04-12 Thread Jeff Fan
On 32bit protectd mode, is there any impact if PcdCpuStackGuard is set to TRUE? 
 Even thers is no page table enabling at that time.

Best Regards,
Jeff



fanjianf...@byosoft.com.cn
 
From: Chen, Gang C
Date: 2022-04-11 22:51
To: Ni, Ray; devel@edk2.groups.io; Liu, Shuo
CC: Jiang, Guomin; Bi, Dandan; Zhang, Di; Wang, Jian J; Gao, Liming
Subject: Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/dec: update the 
PcdCpuStackGuard property
This impact of this change is not as simple as what the patch does.
-->You're correct, that's why the PATCH 2/2 removed the check in AP.
 
Why cannot FSP API and Dispatch mode use the same setting? (either enabled or 
disabled)
-->For example, in coreboot, it's 32-bit, so there is no Paging needed. In this 
case, it needs to disable it for FSP API mode. But this feature is needed for 
Dispatch mode. 
 
@Liu, Shuo, if any information is wrong or missed, please correct me. Thanks.
 
Best Regards
Gang
 
-Original Message-
From: Ni, Ray  
Sent: Monday, April 11, 2022 9:55 PM
To: devel@edk2.groups.io; Chen, Gang C 
Cc: Jiang, Guomin ; Bi, Dandan ; 
Zhang, Di ; Wang, Jian J ; Gao, 
Liming 
Subject: RE: [edk2-devel] [PATCH 1/2] MdeModulePkg/dec: update the 
PcdCpuStackGuard property
 
FixedAtBuild PCD can be accessed at any time from any CPU.
But dynamic PCD can only be accessed from BSP and after PCD database is 
initialized.
 
This impact of this change is not as simple as what the patch does.
 
Why cannot FSP API and Dispatch mode use the same setting? (either enabled or 
disabled)
 
Thanks,
Ray
 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Chen, 
> Gang C
> Sent: Monday, April 11, 2022 6:14 PM
> To: devel@edk2.groups.io
> Cc: Jiang, Guomin ; Bi, Dandan 
> ; Zhang, Di ; Wang, Jian J 
> ; Gao, Liming 
> Subject: [edk2-devel] [PATCH 1/2] MdeModulePkg/dec: update the 
> PcdCpuStackGuard property
> 
> Update the PcdCpuStackGuard from PcdsFixedAtBuild to PcdsDynamicEx for 
> the requirement to set different value in FSP API mode and FSP 
> Dispatch mode.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3897
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: devel@edk2.groups.io
> 
> Signed-off-by: Gang Chen 
> ---
>  MdeModulePkg/MdeModulePkg.dec | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec 
> b/MdeModulePkg/MdeModulePkg.dec index 463e889e9a..72e7e2eced 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -1070,13 +1070,6 @@
># @Prompt The Heap Guard feature mask
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdHeapGuardPropertyMask|0x0|UINT8|0x30
> 001054
> 
> -  ## Indicates if UEFI Stack Guard will be enabled.
> -  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
> consequences.
> -  #   TRUE  - UEFI Stack Guard will be enabled.
> -  #   FALSE - UEFI Stack Guard will be disabled.
> -  # @Prompt Enable UEFI Stack Guard.
> -  
> gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x300010
> 55
> -
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
>## Dynamic type PCD can be registered callback function for Pcd setting 
> action.
>#  PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum 
> number of callback function @@ -2079,6 +2072,13 @@
># @Prompt Enable PCIe Resizable BAR Capability support.
>
> gEfiMdeModulePkgTokenSpaceGuid.PcdPcieResizableBarSupport|FALSE|BOOLEA
> N|0x1024
> 
> +  ## Indicates if UEFI Stack Guard will be enabled.
> +  #  If enabled, stack overflow in UEFI can be caught, preventing chaotic 
> consequences.
> +  #   TRUE  - UEFI Stack Guard will be enabled.
> +  #   FALSE - UEFI Stack Guard will be disabled.
> +  # @Prompt Enable UEFI Stack Guard.
> +  
> + gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x0001
> + 0025
> +
>  [PcdsPatchableInModule]
>## Specify memory size with page number for PEI code when
>#  Loading Module at Fixed Address feature is enabled.
> --
> 2.35.1
> 
> 
> 
> 
> 
 
 
 

 
 
 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#88761): https://edk2.groups.io/g/devel/message/88761
Mute This Topic: https://groups.io/mt/90391665/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-