[edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in order of relative performance in MADT

2022-11-15 Thread JackX Lin
BIOS should keep MADT ordering by big core first then small core

Signed-off-by: JackX Lin 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Donald Kuo 
Cc: Chandana C Kumar 
Cc: JackX Lin 
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 94 
+++---
 1 file changed, 87 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c 
b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 6e57b638e0..bafe359668 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -18,6 +18,7 @@ typedef struct {
   UINT32   Flags;
   UINT32   SocketNum;
   UINT32   Thread;
+  UINT8CpuCoreType;
 } EFI_CPU_ID_ORDER_MAP;
 
 //
@@ -131,6 +132,49 @@ AppendCpuMapTableEntry (
 
 }
 
+/**
+  Function will go through all processors to identify Core or Atom
+  by checking Core Type and update in IsBigCore.
+
+  @param[in] CpuApicIdOrderTable Point to a buffer which will be 
filled in Core type information.
+**/
+VOID
+STATIC
+EFIAPI
+CollectCpuCoreType (
+  IN EFI_CPU_ID_ORDER_MAP*CpuApicIdOrderTable
+  )
+{
+  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
+  UINT32  Eax;
+  UINTN   ApNumber;
+  EFI_STATUS  Status;
+  UINT8   CoreType;
+
+  Status = mMpService->WhoAmI (
+ mMpService,
+ 
+ );
+  ASSERT_EFI_ERROR (Status);
+
+  ///
+  /// Check Hetero feature is supported
+  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
+  ///
+  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
);
+  if (Edx.Bits.Hybrid == 1) {
+//
+// Check which is the running core by reading CPUID.(EAX=1AH, ECX=00H):EAX
+//
+AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
+CoreType = (UINT8) ((Eax & 0xFF00) >> 24);
+  } else {
+CoreType = CPUID_CORE_TYPE_INTEL_CORE;
+  }
+
+  CpuApicIdOrderTable[ApNumber].CpuCoreType = CoreType;
+}
+
 /**
   Collect all processors information and create a Cpu Apic Id table.
 
@@ -138,7 +182,7 @@ AppendCpuMapTableEntry (
 **/
 EFI_STATUS
 CreateCpuLocalApicInTable (
-  IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable
+  IN EFI_CPU_ID_ORDER_MAP   *CpuApicIdOrderTable
   )
 {
   EFI_STATUSStatus;
@@ -146,9 +190,24 @@ CreateCpuLocalApicInTable (
   UINT32Index;
   UINT32CurrProcessor;
   EFI_CPU_ID_ORDER_MAP  *CpuIdMapPtr;
+  EFI_CPU_ID_ORDER_MAP  *TempCpuApicIdOrderTable;
   UINT32Socket;
 
-  Status = EFI_SUCCESS;
+  TempCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof 
(EFI_CPU_ID_ORDER_MAP));
+  if (TempCpuApicIdOrderTable == NULL) {
+return EFI_UNSUPPORTED;
+  }
+
+  CollectCpuCoreType (TempCpuApicIdOrderTable);
+  mMpService->StartupAllAPs (
+mMpService,   // This
+(EFI_AP_PROCEDURE) CollectCpuCoreType,// Procedure
+TRUE, // SingleThread
+NULL, // WaitEvent
+0,// 
TimeoutInMicrosecsond
+TempCpuApicIdOrderTable,  // ProcedureArgument
+NULL  // FailedCpuList
+);
 
   for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; 
CurrProcessor++, Index++) {
 Status = mMpService->GetProcessorInfo (
@@ -157,9 +216,9 @@ CreateCpuLocalApicInTable (

);
 
-CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) [Index];
+CpuIdMapPtr = (EFI_CPU_ID_ORDER_MAP *) [Index];
 if ((ProcessorInfoBuffer.StatusFlag & PROCESSOR_ENABLED_BIT) != 0) {
-  CpuIdMapPtr->ApicId  = (UINT32)ProcessorInfoBuffer.ProcessorId;
+  CpuIdMapPtr->ApicId  = (UINT32) ProcessorInfoBuffer.ProcessorId;
   CpuIdMapPtr->Thread  = ProcessorInfoBuffer.Location.Thread;
   CpuIdMapPtr->Flags   = ((ProcessorInfoBuffer.StatusFlag & 
PROCESSOR_ENABLED_BIT) != 0);
   CpuIdMapPtr->SocketNum = ProcessorInfoBuffer.Location.Package;
@@ -184,22 +243,43 @@ CreateCpuLocalApicInTable (
   //
   DEBUG ((DEBUG_INFO, "BspApicId - 0x%x\n", GetApicId ()));
 
-
   //
   // Fill in AcpiProcessorUid.
   //
   for (Socket = 0; Socket < FixedPcdGet32 (PcdMaxCpuSocketCount); Socket++) {
 for (CurrProcessor = 0, Index = 0; CurrProcessor < mNumberOfCpus; 
CurrProcessor++) {
-  if 

Re: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in order of relative performance in MADT

2022-11-15 Thread JackX Lin
Hi Michael,

I think I understand what you mentioned, 
I will provide another patch.
Thank you.

Jack

-Original Message-
From: Kinney, Michael D  
Sent: Wednesday, November 16, 2022 11:51 AM
To: devel@edk2.groups.io; Lin, JackX ; Kinney, Michael D 

Cc: Chiu, Chasel ; Desimone, Nathaniel L 
; Oram, Isaac W ; Gao, 
Liming ; Dong, Eric ; Kuo, 
Donald ; Kumar, Chandana C 
Subject: RE: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores 
in order of relative performance in MADT

I see the CoreType is an 8-bit field, but this gets filtered down to IsBigCore 
BOOLEAN.

If there may be different core type values, would it be more flexible to 
collect the 8-bit core type value from each CPU and have a configurable policy 
on how to sort the CPUs in the MADT based on the core type values?

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of JackX 
> Lin
> Sent: Tuesday, November 15, 2022 6:53 PM
> To: devel@edk2.groups.io
> Cc: Lin, JackX ; Lin, JackX 
> ; Chiu, Chasel ; Desimone, 
> Nathaniel L ; Oram, Isaac W 
> ; Gao, Liming ; 
> Dong, Eric ; Kuo, Donald ; 
> Kumar, Chandana C 
> Subject: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present 
> cores in order of relative performance in MADT
> 
> BIOS should keep MADT ordering by big core first then small core
> 
> Signed-off-by: JackX Lin 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Isaac Oram 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Cc: Donald Kuo 
> Cc: Chandana C Kumar 
> Cc: JackX Lin 
> ---
>  Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 149
> 
> ++---
>  1 file changed, 142 insertions(+), 7 deletions(-)
> 
> diff --git 
> a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> index 6e57b638e0..02c1dd3a91 100644
> --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> @@ -18,6 +18,7 @@ typedef struct {
>UINT32   Flags;
>UINT32   SocketNum;
>UINT32   Thread;
> +  BOOLEAN  IsBigCore;
>  } EFI_CPU_ID_ORDER_MAP;
> 
>  //
> @@ -131,6 +132,104 @@ AppendCpuMapTableEntry (
> 
>  }
> 
> +/**
> +  Detect if Hetero Core is supported.
> +
> +  @retval TRUE - Processor support HeteroCore
> +  @retval FALSE - Processor doesnt support HeteroCore **/ BOOLEAN 
> +EFIAPI IsHeteroCoreSupported (
> +  VOID
> +  )
> +{
> +  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
> +
> +  ///
> +  /// Check Hetero feature is supported
> +  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
> +  ///
> +  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, 
> +NULL, );
> +  if (Edx.Bits.Hybrid == 1) {
> +return TRUE;
> +  }
> +  return FALSE;
> +}
> +
> +/**
> +  Detect the type of core, whether it is Big/Small Core.
> +
> +  @param[out]CoreType  Output pointer that get 
> CPUID_NATIVE_MODEL_ID_INFO data
> + 10h - Quark
> + 20h - Atom
> + 30H - Knights
> + 40H - Core
> +**/
> +VOID
> +EFIAPI
> +GetCoreType (
> +  OUT  UINT8   *CoreType
> +  )
> +{
> +  UINT32   Eax;
> +
> +  if (IsHeteroCoreSupported ()) {
> +//
> +// Check which is the running core by reading CPUID.(EAX=1AH, 
> ECX=00H):EAX
> +//
> +AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
> +*CoreType = (UINT8)((Eax & 0xFF00) >> 24);
> +  } else {
> +*CoreType = CPUID_CORE_TYPE_INTEL_CORE;
> +  }
> +}
> +
> +/**
> +  Function will go through all processors to identify Core or Atom
> +  by checking Core Type and update in IsBigCore.
> +
> +  @param[in] CpuApicIdOrderTable Point to a buffer which will be 
> filled in Core type information.
> +**/
> +VOID
> +STATIC
> +EFIAPI
> +CollectCpuCoreType (
> +  IN EFI_CPU_ID_ORDER_MAP*CpuApicIdOrderTable
> +  )
> +{
> +  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
> +  UINT32  Eax;
> +  UINTN   ApNumber;
> +  EFI_STATUS  Status;
> +  UINT8   CoreType;
> +
> +  Status = mMpService->WhoAmI (
> + mMpService,
> + 
> + );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  ///
> +  /// Check Hetero feature is supported  /// with 
> + CPUID.(EAX=7,ECX=0):EDX[15]=1  ///  AsmCpuidEx 
> + (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
> + );  if (Edx.Bits.Hybrid == 1) {
> +//
> +// Check which is the running core by reading CPUID.(EAX=1AH, 
> ECX=00H):EAX
> +//
> +AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
> +CoreType = (UINT8) ((Eax & 0xFF00) >> 24);  } else {
> +CoreType = CPUID_CORE_TYPE_INTEL_CORE;  }
> +
> 

Re: [edk2-devel] [PATCH] UefiPayloadPkg: The UPL info section is not aligned at 4-byte boundary

2022-11-15 Thread Guo Dong


Reviewed-by: Guo Dong 

-Original Message-
From: Hsu, VictorX  
Sent: Tuesday, November 15, 2022 8:08 PM
To: devel@edk2.groups.io
Cc: Hsu, VictorX ; Dong, Guo ; Ni, 
Ray ; Lu, James ; Guo, Gua 

Subject: [PATCH] UefiPayloadPkg: The UPL info section is not aligned at 4-byte 
boundary

From: VictorX Hsu 

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

1.Upgrade spec revision to 0.9
2.Align .upld_info with 4-byte boundary by spec

Cc: Guo Dong 
Cc: Ray Ni 
Cc: James Lu 
Cc: Gua Guo 
Signed-off-by: VictorX Hsu 
---
 UefiPayloadPkg/UniversalPayloadBuild.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py 
b/UefiPayloadPkg/UniversalPayloadBuild.py
index 6003de36d1..50a5950e7c 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -31,7 +31,7 @@ class UPLD_INFO_HEADER(LittleEndianStructure):
 def __init__(self):

 self.Identifier =  b'PLDH'

 self.HeaderLength   = sizeof(UPLD_INFO_HEADER)

-self.SpecRevision   = 0x0007

+self.SpecRevision   = 0x0009

 self.Revision   = 0x010105

 self.ImageId= b'UEFI'

 self.ProducerId = b'INTEL'

@@ -133,7 +133,7 @@ def BuildUniversalPayload(Args, MacroList):
FvOutputDir,

EntryOutputDir

)

-set_section= '"{}" -I {} -O {} --set-section-alignment 
.upld.upld_info=16 --set-section-alignment .upld.uefi_fv=16 {}'.format (

+set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 
--set-section-alignment .upld.uefi_fv=16 {}'.format (

LlvmObjcopyPath,

ObjCopyFlag,

ObjCopyFlag,

-- 
2.28.0.windows.1



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




Re: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in order of relative performance in MADT

2022-11-15 Thread Michael D Kinney
I see the CoreType is an 8-bit field, but this gets filtered down to IsBigCore 
BOOLEAN.

If there may be different core type values, would it be more flexible to collect
the 8-bit core type value from each CPU and have a configurable policy on how to
sort the CPUs in the MADT based on the core type values?

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of JackX Lin
> Sent: Tuesday, November 15, 2022 6:53 PM
> To: devel@edk2.groups.io
> Cc: Lin, JackX ; Lin, JackX ; Chiu, 
> Chasel ; Desimone,
> Nathaniel L ; Oram, Isaac W 
> ; Gao, Liming ;
> Dong, Eric ; Kuo, Donald ; Kumar, 
> Chandana C 
> Subject: [edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in 
> order of relative performance in MADT
> 
> BIOS should keep MADT ordering by big core first then small core
> 
> Signed-off-by: JackX Lin 
> Cc: Chasel Chiu 
> Cc: Nate DeSimone 
> Cc: Isaac Oram 
> Cc: Liming Gao 
> Cc: Eric Dong 
> Cc: Donald Kuo 
> Cc: Chandana C Kumar 
> Cc: JackX Lin 
> ---
>  Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 149
> 
> ++---
>  1 file changed, 142 insertions(+), 7 deletions(-)
> 
> diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> index 6e57b638e0..02c1dd3a91 100644
> --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
> @@ -18,6 +18,7 @@ typedef struct {
>UINT32   Flags;
>UINT32   SocketNum;
>UINT32   Thread;
> +  BOOLEAN  IsBigCore;
>  } EFI_CPU_ID_ORDER_MAP;
> 
>  //
> @@ -131,6 +132,104 @@ AppendCpuMapTableEntry (
> 
>  }
> 
> +/**
> +  Detect if Hetero Core is supported.
> +
> +  @retval TRUE - Processor support HeteroCore
> +  @retval FALSE - Processor doesnt support HeteroCore
> +**/
> +BOOLEAN
> +EFIAPI
> +IsHeteroCoreSupported (
> +  VOID
> +  )
> +{
> +  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
> +
> +  ///
> +  /// Check Hetero feature is supported
> +  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
> +  ///
> +  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
> );
> +  if (Edx.Bits.Hybrid == 1) {
> +return TRUE;
> +  }
> +  return FALSE;
> +}
> +
> +/**
> +  Detect the type of core, whether it is Big/Small Core.
> +
> +  @param[out]CoreType  Output pointer that get 
> CPUID_NATIVE_MODEL_ID_INFO data
> + 10h - Quark
> + 20h - Atom
> + 30H - Knights
> + 40H - Core
> +**/
> +VOID
> +EFIAPI
> +GetCoreType (
> +  OUT  UINT8   *CoreType
> +  )
> +{
> +  UINT32   Eax;
> +
> +  if (IsHeteroCoreSupported ()) {
> +//
> +// Check which is the running core by reading CPUID.(EAX=1AH, 
> ECX=00H):EAX
> +//
> +AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
> +*CoreType = (UINT8)((Eax & 0xFF00) >> 24);
> +  } else {
> +*CoreType = CPUID_CORE_TYPE_INTEL_CORE;
> +  }
> +}
> +
> +/**
> +  Function will go through all processors to identify Core or Atom
> +  by checking Core Type and update in IsBigCore.
> +
> +  @param[in] CpuApicIdOrderTable Point to a buffer which will be 
> filled in Core type information.
> +**/
> +VOID
> +STATIC
> +EFIAPI
> +CollectCpuCoreType (
> +  IN EFI_CPU_ID_ORDER_MAP*CpuApicIdOrderTable
> +  )
> +{
> +  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
> +  UINT32  Eax;
> +  UINTN   ApNumber;
> +  EFI_STATUS  Status;
> +  UINT8   CoreType;
> +
> +  Status = mMpService->WhoAmI (
> + mMpService,
> + 
> + );
> +  ASSERT_EFI_ERROR (Status);
> +
> +  ///
> +  /// Check Hetero feature is supported
> +  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
> +  ///
> +  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
> );
> +  if (Edx.Bits.Hybrid == 1) {
> +//
> +// Check which is the running core by reading CPUID.(EAX=1AH, 
> ECX=00H):EAX
> +//
> +AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
> +CoreType = (UINT8) ((Eax & 0xFF00) >> 24);
> +  } else {
> +CoreType = CPUID_CORE_TYPE_INTEL_CORE;
> +  }
> +
> +  if (CoreType == CPUID_CORE_TYPE_INTEL_CORE) {
> +CpuApicIdOrderTable[ApNumber].IsBigCore = TRUE;
> +  }
> +}
> +
>  /**
>Collect all processors information and create a Cpu Apic Id table.
> 
> @@ -138,7 +237,7 @@ AppendCpuMapTableEntry (
>  **/
>  EFI_STATUS
>  CreateCpuLocalApicInTable (
> -  IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable
> +  IN EFI_CPU_ID_ORDER_MAP   *CpuApicIdOrderTable
>)
>  {
>EFI_STATUSStatus;
> @@ 

Re: [edk2-devel] [PATCH] UefiPayloadPkg: The UPL info section is not aligned at 4-byte boundary

2022-11-15 Thread Lu, James
Reviewed-by: James Lu 

-Original Message-
From: Hsu, VictorX  
Sent: Wednesday, November 16, 2022 11:08 AM
To: devel@edk2.groups.io
Cc: Hsu, VictorX ; Dong, Guo ; Ni, 
Ray ; Lu, James ; Guo, Gua 

Subject: [PATCH] UefiPayloadPkg: The UPL info section is not aligned at 4-byte 
boundary

From: VictorX Hsu 

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

1.Upgrade spec revision to 0.9
2.Align .upld_info with 4-byte boundary by spec

Cc: Guo Dong 
Cc: Ray Ni 
Cc: James Lu 
Cc: Gua Guo 
Signed-off-by: VictorX Hsu 
---
 UefiPayloadPkg/UniversalPayloadBuild.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py 
b/UefiPayloadPkg/UniversalPayloadBuild.py
index 6003de36d1..50a5950e7c 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -31,7 +31,7 @@ class UPLD_INFO_HEADER(LittleEndianStructure):
 def __init__(self):

 self.Identifier =  b'PLDH'

 self.HeaderLength   = sizeof(UPLD_INFO_HEADER)

-self.SpecRevision   = 0x0007

+self.SpecRevision   = 0x0009

 self.Revision   = 0x010105

 self.ImageId= b'UEFI'

 self.ProducerId = b'INTEL'

@@ -133,7 +133,7 @@ def BuildUniversalPayload(Args, MacroList):
FvOutputDir,

EntryOutputDir

)

-set_section= '"{}" -I {} -O {} --set-section-alignment 
.upld.upld_info=16 --set-section-alignment .upld.uefi_fv=16 {}'.format (

+set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 
--set-section-alignment .upld.uefi_fv=16 {}'.format (

LlvmObjcopyPath,

ObjCopyFlag,

ObjCopyFlag,

-- 
2.28.0.windows.1



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




Re: [edk2-devel] [PATCH v2 1/1] .github/dependabot.yml: Enable dependabot

2022-11-15 Thread Michael D Kinney
Reviewed-by: Michael D Kinney 

Note to Maintainers:  When this feature is merged, PRs from dependabot will be
automatically added to the set of edk2 repo PRs.  Never set 'push' label 
directly
on these PRs.  If a dependency identified by dependedabot looks like one that
should be updated in the edk2 repo, then copy the PR generated by dependabot to
your personal fork and update the commit message to follow the edk2 commit
message requirements and send as a normal code review.

Thanks,

Mike


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael Kubacki
> Sent: Tuesday, November 15, 2022 7:16 PM
> To: devel@edk2.groups.io
> Cc: Sean Brogan ; Kinney, Michael D 
> 
> Subject: [edk2-devel] [PATCH v2 1/1] .github/dependabot.yml: Enable dependabot
> 
> From: Michael Kubacki 
> 
> Enables dependabot in this repo so we can better alerted when
> dependency updates are available.
> 
> This GitHub action will automatically create pull requests and
> summarize the dependency details. Because it is a pull request,
> the CI system will validate the dependency update in the pull
> request.
> 
> Configures dependabot for:
> 
> 1. PIP module updates
> 2. GitHub action updates
> 
> The maintainers/reviewers of the .github directory were added as
> pull request reviewers so they can be notified when the pull request
> is available.
> 
> Cc: Sean Brogan 
> Cc: Michael D Kinney 
> Signed-off-by: Michael Kubacki 
> ---
> 
> Notes:
> An example of the pull requests created by this change
> are available on my edk2 fork:
> 
> https://github.com/makubacki/edk2/pulls
> 
> V2 Changes:
> 
> 1. Removed the "gitsubmodule" package ecosystem
> 
> In the TianoCore Tools and CI Meeting, we decided
> to follow up in the future in enabling submodules
> on a case-by-case basis trying to move between
> release tags.
> 
> For now, this change enables tracking of pip and
> GitHub action dependencies.
> 
>  .github/dependabot.yml | 34 
>  1 file changed, 34 insertions(+)
> 
> diff --git a/.github/dependabot.yml b/.github/dependabot.yml
> new file mode 100644
> index ..b4e0b93b16ca
> --- /dev/null
> +++ b/.github/dependabot.yml
> @@ -0,0 +1,34 @@
> +## @file
> +# Dependabot configuration file to enable GitHub services for managing and 
> updating
> +# dependencies.
> +#
> +# Copyright (c) Microsoft Corporation.
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +# Please see the documentation for all configuration options:
> +# 
> https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
> +##
> +version: 2
> +updates:
> +  - package-ecosystem: "pip"
> +directory: "/"
> +schedule:
> +  interval: "daily"
> +commit-message:
> +  prefix: "pip"
> +reviewers:
> +  - "makubacki"
> +  - "mdkinney"
> +  - "spbrogan"
> +
> +  - package-ecosystem: "github-actions"
> +directory: "/"
> +schedule:
> +  interval: "weekly"
> +  day: "monday"
> +commit-message:
> +  prefix: "GitHub Action"
> +reviewers:
> +  - "makubacki"
> +  - "mdkinney"
> +  - "spbrogan"
> --
> 2.28.0.windows.1
> 
> 
> 
> -=-=-=-=-=-=
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#96416): https://edk2.groups.io/g/devel/message/96416
> Mute This Topic: https://groups.io/mt/95059788/1643496
> Group Owner: devel+ow...@edk2.groups.io
> Unsubscribe: https://edk2.groups.io/g/devel/unsub [michael.d.kin...@intel.com]
> -=-=-=-=-=-=
> 



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




[edk2-devel] [PATCH v2 1/1] .github/dependabot.yml: Enable dependabot

2022-11-15 Thread Michael Kubacki
From: Michael Kubacki 

Enables dependabot in this repo so we can better alerted when
dependency updates are available.

This GitHub action will automatically create pull requests and
summarize the dependency details. Because it is a pull request,
the CI system will validate the dependency update in the pull
request.

Configures dependabot for:

1. PIP module updates
2. GitHub action updates

The maintainers/reviewers of the .github directory were added as
pull request reviewers so they can be notified when the pull request
is available.

Cc: Sean Brogan 
Cc: Michael D Kinney 
Signed-off-by: Michael Kubacki 
---

Notes:
An example of the pull requests created by this change
are available on my edk2 fork:

https://github.com/makubacki/edk2/pulls

V2 Changes:

1. Removed the "gitsubmodule" package ecosystem

In the TianoCore Tools and CI Meeting, we decided
to follow up in the future in enabling submodules
on a case-by-case basis trying to move between
release tags.

For now, this change enables tracking of pip and
GitHub action dependencies.

 .github/dependabot.yml | 34 
 1 file changed, 34 insertions(+)

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index ..b4e0b93b16ca
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,34 @@
+## @file
+# Dependabot configuration file to enable GitHub services for managing and 
updating
+# dependencies.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+# Please see the documentation for all configuration options:
+# 
https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
+##
+version: 2
+updates:
+  - package-ecosystem: "pip"
+directory: "/"
+schedule:
+  interval: "daily"
+commit-message:
+  prefix: "pip"
+reviewers:
+  - "makubacki"
+  - "mdkinney"
+  - "spbrogan"
+
+  - package-ecosystem: "github-actions"
+directory: "/"
+schedule:
+  interval: "weekly"
+  day: "monday"
+commit-message:
+  prefix: "GitHub Action"
+reviewers:
+  - "makubacki"
+  - "mdkinney"
+  - "spbrogan"
-- 
2.28.0.windows.1



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




[edk2-devel] [edk2-platforms: PATCH] BIOS needs to present cores in order of relative performance in MADT

2022-11-15 Thread JackX Lin
BIOS should keep MADT ordering by big core first then small core

Signed-off-by: JackX Lin 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Donald Kuo 
Cc: Chandana C Kumar 
Cc: JackX Lin 
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 149 
++---
 1 file changed, 142 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c 
b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index 6e57b638e0..02c1dd3a91 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -18,6 +18,7 @@ typedef struct {
   UINT32   Flags;
   UINT32   SocketNum;
   UINT32   Thread;
+  BOOLEAN  IsBigCore;
 } EFI_CPU_ID_ORDER_MAP;
 
 //
@@ -131,6 +132,104 @@ AppendCpuMapTableEntry (
 
 }
 
+/**
+  Detect if Hetero Core is supported.
+
+  @retval TRUE - Processor support HeteroCore
+  @retval FALSE - Processor doesnt support HeteroCore
+**/
+BOOLEAN
+EFIAPI
+IsHeteroCoreSupported (
+  VOID
+  )
+{
+  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
+
+  ///
+  /// Check Hetero feature is supported
+  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
+  ///
+  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
);
+  if (Edx.Bits.Hybrid == 1) {
+return TRUE;
+  }
+  return FALSE;
+}
+
+/**
+  Detect the type of core, whether it is Big/Small Core.
+
+  @param[out]CoreType  Output pointer that get 
CPUID_NATIVE_MODEL_ID_INFO data
+ 10h - Quark
+ 20h - Atom
+ 30H - Knights
+ 40H - Core
+**/
+VOID
+EFIAPI
+GetCoreType (
+  OUT  UINT8   *CoreType
+  )
+{
+  UINT32   Eax;
+
+  if (IsHeteroCoreSupported ()) {
+//
+// Check which is the running core by reading CPUID.(EAX=1AH, ECX=00H):EAX
+//
+AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
+*CoreType = (UINT8)((Eax & 0xFF00) >> 24);
+  } else {
+*CoreType = CPUID_CORE_TYPE_INTEL_CORE;
+  }
+}
+
+/**
+  Function will go through all processors to identify Core or Atom
+  by checking Core Type and update in IsBigCore.
+
+  @param[in] CpuApicIdOrderTable Point to a buffer which will be 
filled in Core type information.
+**/
+VOID
+STATIC
+EFIAPI
+CollectCpuCoreType (
+  IN EFI_CPU_ID_ORDER_MAP*CpuApicIdOrderTable
+  )
+{
+  CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS_EDX Edx;
+  UINT32  Eax;
+  UINTN   ApNumber;
+  EFI_STATUS  Status;
+  UINT8   CoreType;
+
+  Status = mMpService->WhoAmI (
+ mMpService,
+ 
+ );
+  ASSERT_EFI_ERROR (Status);
+
+  ///
+  /// Check Hetero feature is supported
+  /// with CPUID.(EAX=7,ECX=0):EDX[15]=1
+  ///
+  AsmCpuidEx (CPUID_STRUCTURED_EXTENDED_FEATURE_FLAGS, 0, NULL, NULL, NULL, 
);
+  if (Edx.Bits.Hybrid == 1) {
+//
+// Check which is the running core by reading CPUID.(EAX=1AH, ECX=00H):EAX
+//
+AsmCpuid (CPUID_HYBRID_INFORMATION, , NULL, NULL, NULL);
+CoreType = (UINT8) ((Eax & 0xFF00) >> 24);
+  } else {
+CoreType = CPUID_CORE_TYPE_INTEL_CORE;
+  }
+
+  if (CoreType == CPUID_CORE_TYPE_INTEL_CORE) {
+CpuApicIdOrderTable[ApNumber].IsBigCore = TRUE;
+  }
+}
+
 /**
   Collect all processors information and create a Cpu Apic Id table.
 
@@ -138,7 +237,7 @@ AppendCpuMapTableEntry (
 **/
 EFI_STATUS
 CreateCpuLocalApicInTable (
-  IN EFI_CPU_ID_ORDER_MAP *CpuApicIdOrderTable
+  IN EFI_CPU_ID_ORDER_MAP   *CpuApicIdOrderTable
   )
 {
   EFI_STATUSStatus;
@@ -146,9 +245,24 @@ CreateCpuLocalApicInTable (
   UINT32Index;
   UINT32CurrProcessor;
   EFI_CPU_ID_ORDER_MAP  *CpuIdMapPtr;
+  EFI_CPU_ID_ORDER_MAP  *TempCpuApicIdOrderTable;
   UINT32Socket;
 
-  Status = EFI_SUCCESS;
+  TempCpuApicIdOrderTable = AllocateZeroPool (mNumberOfCpus * sizeof 
(EFI_CPU_ID_ORDER_MAP));
+  if (TempCpuApicIdOrderTable == NULL) {
+return EFI_UNSUPPORTED;
+  }
+
+  CollectCpuCoreType (TempCpuApicIdOrderTable);
+  mMpService->StartupAllAPs (
+mMpService,   // This
+(EFI_AP_PROCEDURE) CollectCpuCoreType,// Procedure
+TRUE, // SingleThread
+NULL, // WaitEvent
+0,// 
TimeoutInMicrosecsond
+TempCpuApicIdOrderTable,  

[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, November 15, 2022 #cal-reminder

2022-11-15 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

*When:*
Tuesday, November 15, 2022
6:30pm to 7:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d

*Organizer:* Liming Gao gaolim...@byosoft.com.cn ( 
gaolim...@byosoft.com.cn?subject=Re:%20Event:%20TianoCore%20Bug%20Triage%20-%20APAC%20%2F%20NAMO
 )

View Event ( https://edk2.groups.io/g/devel/viewevent?eventid=1268289 )

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

Click here to join the meeting ( 
https://teams.microsoft.com/l/meetup-join/19%3ameeting_OTk1YzJhN2UtOGQwNi00NjY4LWEwMTktY2JiODRlYTY1NmY0%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%226e4ce4c4-1242-431b-9a51-92cd01a5df3c%22%7d
 )

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

Alternate VTC dialing instructions ( 
https://conf.intel.com/teams/?conf=1160620940=teams=conf.intel.com=test_call
 )

*Or call in (audio only)*

+1 916-245-6934,,77463821# ( tel:+19162456934,,77463821# ) United States, 
Sacramento

Phone Conference ID: 774 638 21#

Find a local number ( 
https://dialin.teams.microsoft.com/d195d438-2daa-420e-b9ea-da26f9d1d6d5?id=77463821
 ) | Reset PIN ( https://mysettings.lync.com/pstnconferencing )

Learn More ( https://aka.ms/JoinTeamsMeeting ) | Meeting options ( 
https://teams.microsoft.com/meetingOptions/?organizerId=b286b53a-1218-4db3-bfc9-3d4c5aa7669e=46c98d88-e344-4ed4-8496-4ed7712e255d=19_meeting_OTUyZTg2NjgtNDhlNS00ODVlLTllYTUtYzg1OTNjNjdiZjFh@thread.v2=0=en-US
 )


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




[edk2-devel] [PATCH v1 1/1] .github/ISSUE_TEMPLATE/config.yml: Add initial issue template

2022-11-15 Thread Michael Kubacki
From: Michael Kubacki 

Adds a GitHub issue template to direct contributors familiar with
GitHub's issue tracker to the external resources used by TianoCore.

Cc: Sean Brogan 
Cc: Michael D Kinney 
Signed-off-by: Michael Kubacki 
---

Notes:
An example of what this looks like is in the Issues
section of my edk2 fork:

https://github.com/makubacki/edk2/issues/new/choose

This was discussed in the Nov 14th, 2022 TianoCore
Tools and CI Meeting and received positive feedback
with the suggestion to add this change.

 .github/ISSUE_TEMPLATE/config.yml | 24 
 1 file changed, 24 insertions(+)

diff --git a/.github/ISSUE_TEMPLATE/config.yml 
b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index ..7866c2197aca
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,24 @@
+## @file
+# GitHub issue configuration file.
+#
+# This file is meant to direct contributors familiar with GitHub's issue 
tracker
+# to the external resources used by TianoCore.
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+blank_issues_enabled: false
+contact_links:
+  - name: Bugs and Feature Requests
+url: https://bugzilla.tianocore.org/
+about: Submit bug reports and feature requests here
+  - name: Reporting Security Issues
+url: 
https://github.com/tianocore/tianocore.github.io/wiki/Reporting-Security-Issues
+about: Read the wiki page that describes the process here
+  - name: EDK II Development Mailing List
+url: https://edk2.groups.io/g/devel
+about: Submit code patches and ask questions on the mailing list 
(devel@edk2.groups.io)
+  - name: EDK II Discussions
+url: https://github.com/tianocore/edk2/discussions
+about: You can also reach out on the Discussion section of this repository
-- 
2.28.0.windows.1



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




回复: [edk2-devel] [PATCH 1/1][edk2-stable202211] ArmPkg/ArmTrngLib: Remove ASSERT in GetArmTrngVersion()

2022-11-15 Thread gaoliming via groups.io
PR https://github.com/tianocore/edk2/pull/3641 is created to merge it. 

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 gaoliming via
> groups.io
> 发送时间: 2022年11月15日 10:55
> 收件人: devel@edk2.groups.io; a...@kernel.org; pierre.gond...@arm.com
> 抄送: 'Ard Biesheuvel' ; 'Leif Lindholm'
> ; 'Sami Mujawar' 
> 主题: 回复: [edk2-devel] [PATCH 1/1][edk2-stable202211]
> ArmPkg/ArmTrngLib: Remove ASSERT in GetArmTrngVersion()
> 
> Ard:
>   I am OK to merge it for this stable tag. I will do it.
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Ard
> > Biesheuvel
> > 发送时间: 2022年11月14日 23:10
> > 收件人: pierre.gond...@arm.com
> > 抄送: devel@edk2.groups.io; Ard Biesheuvel
> ;
> > Leif Lindholm ; Sami Mujawar
> > ; Liming Gao 
> > 主题: Re: [edk2-devel] [PATCH 1/1][edk2-stable202211]
> ArmPkg/ArmTrngLib:
> > Remove ASSERT in GetArmTrngVersion()
> >
> > On Mon, 14 Nov 2022 at 15:44,  wrote:
> > >
> > > From: Pierre Gondois 
> > >
> > > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4150
> > >
> > > GetArmTrngVersion() is used to check the presence of an Arm
> > > Trng. If not found, an ASSERT prevents from booting in DEBUG
> > > builds.
> > > Remove this ASSERT.
> > >
> > > Reported-by: Sami Mujawar 
> > > Signed-off-by: Pierre Gondois 
> >
> > Acked-by: Ard Biesheuvel 
> >
> > Liming: please merge this if you are ok with it, or I can merge it if
> > you prefer.
> >
> > > ---
> > >  ArmPkg/Library/ArmTrngLib/ArmTrngLib.c | 1 -
> > >  1 file changed, 1 deletion(-)
> > >
> > > diff --git a/ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
> > b/ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
> > > index fdabc02cd39c..3278722320c8 100644
> > > --- a/ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
> > > +++ b/ArmPkg/Library/ArmTrngLib/ArmTrngLib.c
> > > @@ -344,7 +344,6 @@ ArmTrngLibConstructor (
> > >
> > >Status = GetArmTrngVersion (, );
> > >if (RETURN_ERROR (Status)) {
> > > -ASSERT_RETURN_ERROR (Status);
> > >  goto ErrorHandler;
> > >}
> > >
> > > --
> > > 2.25.1
> > >
> >
> >
> >
> >
> 
> 
> 
> 
> 
> 
> 





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




回复: [edk2-devel] [PATCH v1 00/12] Enable New CodeQL Queries

2022-11-15 Thread gaoliming via groups.io
Michael:
  For BaseTools, MdePkg, and MdeModulePkg, the changes are good to me. 
Reviewed-by: Liming Gao 

Thanks
Liming
> -邮件原件-
> 发件人: Michael Kubacki 
> 发送时间: 2022年11月15日 23:00
> 收件人: devel@edk2.groups.io
> 抄送: Bob Feng ; Dandan Bi ;
> Eric Dong ; Erich McMillan
> ; Guomin Jiang ; Jian J
> Wang ; Jiaxin Wu ; Jiewen Yao
> ; Liming Gao ; Maciej
> Rabeda ; Michael D Kinney
> ; Rahul Kumar ;
> Ray Ni ; Sean Brogan ;
> Siyuan Fu ; Star Zeng ; Xiaoyu Lu
> ; Yuwei Chen ; Zhichao Gao
> ; Zhiguang Liu 
> 主题: Re: [edk2-devel] [PATCH v1 00/12] Enable New CodeQL Queries
> 
> Maintainers/reviewers,
> 
> This is an important series for us to make progress on enabling CodeQL
> and needs cooperation from maintainers across several packages.
> 
> I have not received any feedback yet.
> 
> Most of these patches should not take long to review. Please help review
> your patches so we can continue forward momentum on enabling code
> scanning in the repo.
> 
> Thanks,
> Michael
> 
> On 11/9/2022 12:32 PM, Michael Kubacki wrote:
> > From: Michael Kubacki 
> >
> > Adds queries for the following:
> >
> > 1. cpp/conditionallyuninitializedvariable
> > 2. cpp/pointer-overflow-check
> > 3. cpp/overrunning-write
> > 4. cpp/overrunning-write-with-float
> > 5. cpp/very-likely-overrunning-write
> >
> > These check for vulnerabilities with the following CWEs:
> >
> >- https://cwe.mitre.org/data/definitions/120.html
> >- https://cwe.mitre.org/data/definitions/457.html
> >- https://cwe.mitre.org/data/definitions/676.html
> >- https://cwe.mitre.org/data/definitions/758.html
> >- https://cwe.mitre.org/data/definitions/787.html
> >- https://cwe.mitre.org/data/definitions/805.html
> >
> > The first part of this patch series contains fixes for CodeQL alerts
> > across various packages that are produced by the new queries being
> > enabled.
> >
> > The second part updates the CodeQL queries.
> >
> > Cc: Bob Feng 
> > Cc: Dandan Bi 
> > Cc: Eric Dong 
> > Cc: Erich McMillan 
> > Cc: Guomin Jiang 
> > Cc: Jian J Wang 
> > Cc: Jiaxin Wu 
> > Cc: Jiewen Yao 
> > Cc: Liming Gao 
> > Cc: Maciej Rabeda 
> > Cc: Michael D Kinney 
> > Cc: Michael Kubacki 
> > Cc: Rahul Kumar 
> > Cc: Ray Ni 
> > Cc: Sean Brogan 
> > Cc: Siyuan Fu 
> > Cc: Star Zeng 
> > Cc: Xiaoyu Lu 
> > Cc: Yuwei Chen 
> > Cc: Zhichao Gao 
> > Cc: Zhiguang Liu 
> > Signed-off-by: Michael Kubacki 
> >
> > Erich McMillan (1):
> >MdeModulePkg/SmbiosDxe: Fix pointer and buffer overflow CodeQL
> alerts
> >
> > Michael Kubacki (11):
> >BaseTools/PatchCheck.py: Add PCCTS to tab exemption list
> >BaseTools/VfrCompile: Fix potential buffer overwrites
> >CryptoPkg: Fix conditionally uninitialized variable
> >MdeModulePkg: Fix conditionally uninitialized variables
> >MdePkg: Fix conditionally uninitialized variables
> >NetworkPkg: Fix conditionally uninitialized variables
> >PcAtChipsetPkg: Fix conditionally uninitialized variables
> >ShellPkg: Fix conditionally uninitialized variables
> >UefiCpuPkg: Fix conditionally uninitialized variables
> >.github/codeql/edk2.qls: Enable CWE 457, 676, and 758 queries
> >.github/codeql/edk2.qls: Enable CWE 120, 787, and 805 queries
> >
> >   BaseTools/Source/C/VfrCompile/Pccts/antlr/gen.c   |
> 10 ++--
> >   BaseTools/Source/C/VfrCompile/Pccts/antlr/main.c  |
> 4 +-
> >   CryptoPkg/Library/BaseCryptLib/Pk/CryptX509.c |
> 21 
> >   MdeModulePkg/Bus/Pci/PciBusDxe/PciIo.c
> |  5 +-
> >   MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
> | 24 +
> >   MdeModulePkg/Core/Dxe/Mem/Page.c
> | 17 +++---
> >   MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c |
> 25 +
> >   MdeModulePkg/Library/FileExplorerLib/FileExplorer.c   |  5
> +-
> >   MdeModulePkg/Universal/BdsDxe/BdsEntry.c
> | 33 ++--
> >   MdeModulePkg/Universal/DisplayEngineDxe/ProcessOptions.c  |
> 11 ++--
> >   MdeModulePkg/Universal/HiiDatabaseDxe/Font.c
> | 14 +++--
> >   MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.c
> |  4 +-
> >   MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.c |
> 2 +-
> >   MdePkg/Library/BaseLib/String.c
> | 20 ---
> >   NetworkPkg/Library/DxeHttpLib/DxeHttpLib.c|
> 2 +-
> >   NetworkPkg/TcpDxe/TcpInput.c
> |  3 ++
> >   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcRtc.c|
> 9 ++--
> >   ShellPkg/Application/Shell/Shell.c|
> 2 +-
> >   ShellPkg/Application/Shell/ShellProtocol.c|  4
> +-
> >   ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.c|
> 56 +++-
> >   ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c|
> 18 ---
> >   ShellPkg/Library/UefiShellDebug1CommandsLib/EfiDecompress.c   |
> 9 ++--
> >   ShellPkg/Library/UefiShellDriver1CommandsLib/Connect.c| 14
> ++---
> >   ShellPkg/Library/UefiShellDriver1CommandsLib/Disconnect.c | 17
> +++---
> >   

Re: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling

2022-11-15 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guenzel, Robert
> Sent: Thursday, November 10, 2022 9:51 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling
> 
> When build in DEBUG, the code asserts that 5LPage support is there
> when the physical address width is larger than 48.
> In a RELEASE build it will just force LA57 to 1 in CR4
> even if CPUID(7).ECX[16] says it is not supported.
> 
> The hang (in the ASSERT) in DEBUG is not warranted as there are
> legal configurations with CPUID(7).ECX[16](==LA57)=0
> and with a physical address width of larger than 48 (like 52).
> 
> This is also supported by this code:
> https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c#L221
> There (as long as physical address width is smaller or equal to 52)
> any address width above 48 will be reduced to 48 and the
> system can and will work without 5LPaging.
> 
> The forced setting of LA57 in CR4 (in the absence of LA57 in CPUID(7).ECX)
> is a spec violation and should not happen.
> 
> Hence the proposed fix
> a) removes the assert.
> b) only returns TRUE from Is5LevelPagingNeeded if 5LPaging is actually
>supported by HW.
> 
> Signed-off-by: Robert Guenzel mailto:robert.guen...@intel.com
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> index 6587212f4e..f8b1ac31f1 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> @@ -104,8 +104,8 @@ Is5LevelPagingNeeded (
>  ExtFeatureEcx.Bits.FiveLevelPage
>  ));
> 
> -  if (VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) {
> -ASSERT (ExtFeatureEcx.Bits.FiveLevelPage == 1);
> +  if ((VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) &&
> +  (ExtFeatureEcx.Bits.FiveLevelPage == 1)) {
>  return TRUE;
>} else {
>  return FALSE;
> --
> 2.34.1
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de 
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH 3/4] OvmfPkg/IntelTdx: Enable separate-fv in IntelTdx/IntelTdxX64.fdf

2022-11-15 Thread Min Xu
On November 15, 2022 6:48 PM, Gerd Hoffmann wrote:
>   Hi,
> 
> > So we separate DXEFV into 2 FVs: DXEFV and NCCFV. All the drivers
> > which are not needed by a Confidential Computing guest are moved from
> > DXEFV to NCCFV.
> 
> >  INF  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
> > -INF  OvmfPkg/VirtioScsiDxe/VirtioScsi.inf
> 
> Why keep virtio-blk in DXEFV but drop virtio-scsi?
> 
> > -INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> > -INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf
> 
> These are needed too for virtio-scsi.
That is because virtio-scsi is not needed in Td guest in current stage. So it 
is moved to NCCFV. If in the future it is needed, 
VirtioScsi/ScsiBusDxe/ScsiDiskDxe can be moved back to DXEFV.
> 
> > +INF  FatPkg/EnhancedFatDxe/Fat.inf
> > +INF  ShellPkg/Application/Shell/Shell.inf
> 
> Why add the shell to DXEFV?  Shouldn't this go to NCCFV?
The intention of Separate-Fv is to provide a mechanism that if some DXE phase 
drivers are not needed by a CC guest, they will be moved to NCCFV. So that (1) 
reduce attack surface (2)improve boot performance. We call it a minimal but 
complete cc-guest driver set.
So we are facing a problem that how to define such a minimal but complete 
cc-guest driver set. The usage scenario changes, the driver set changes. For 
example if some CSP think Smbios is mandatory, then he can customize his own 
DXEFV/NCCFV by moving Smbios drivers from NCCFV to DXEFV.
Back to the shell, it can be put in DXEFV or in NCCFV. It depends on the CSP's 
choice.
> 
> Also please wrap this into '!if $(BUILD_SHELL) == TRUE' for consistency with
> the other ovmf build variants.
Thanks for reminder. It will be wrapped in the next version.
> 
Thanks
Min


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




Re: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling

2022-11-15 Thread Michael D Kinney
+UefiCpuPkg maintainers/reviewers.


> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Guenzel, Robert
> Sent: Thursday, November 10, 2022 5:51 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH] UefiCpuPkg: Bug fix in 5LPage handling
> 
> When build in DEBUG, the code asserts that 5LPage support is there
> when the physical address width is larger than 48.
> In a RELEASE build it will just force LA57 to 1 in CR4
> even if CPUID(7).ECX[16] says it is not supported.
> 
> The hang (in the ASSERT) in DEBUG is not warranted as there are
> legal configurations with CPUID(7).ECX[16](==LA57)=0
> and with a physical address width of larger than 48 (like 52).
> 
> This is also supported by this code:
> https://github.com/tianocore/edk2/blob/master/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c#L221
> There (as long as physical address width is smaller or equal to 52)
> any address width above 48 will be reduced to 48 and the
> system can and will work without 5LPaging.
> 
> The forced setting of LA57 in CR4 (in the absence of LA57 in CPUID(7).ECX)
> is a spec violation and should not happen.
> 
> Hence the proposed fix
> a) removes the assert.
> b) only returns TRUE from Is5LevelPagingNeeded if 5LPaging is actually
>supported by HW.
> 
> Signed-off-by: Robert Guenzel mailto:robert.guen...@intel.com
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> index 6587212f4e..f8b1ac31f1 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
> @@ -104,8 +104,8 @@ Is5LevelPagingNeeded (
>  ExtFeatureEcx.Bits.FiveLevelPage
>  ));
> 
> -  if (VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) {
> -ASSERT (ExtFeatureEcx.Bits.FiveLevelPage == 1);
> +  if ((VirPhyAddressSize.Bits.PhysicalAddressBits > 4 * 9 + 12) &&
> +  (ExtFeatureEcx.Bits.FiveLevelPage == 1)) {
>  return TRUE;
>} else {
>  return FALSE;
> --
> 2.34.1
> Intel Deutschland GmbH
> Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
> Tel: +49 89 99 8853-0, www.intel.de 
> Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva
> Chairperson of the Supervisory Board: Nicole Lau
> Registered Office: Munich
> Commercial Register: Amtsgericht Muenchen HRB 186928
> 
> 
> 
> 
> 



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




[edk2-devel] [PATCH] DynamicTablesPkg: SSDT _LPI revision is incorrect

2022-11-15 Thread Jeff Brasen via groups.io
_LPI Revision should be 0 per the ACPI 6.5 specification.
"The revision number of the _LPI object. Current revision is 0."

Signed-off-by: Jeff Brasen 
---
 .../Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
index d06c7615fb..91199c4af2 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
@@ -482,7 +482,7 @@ GenerateLpiStates (
 }
 
 // We do not support the LevelId field for now, let it to 0.
-Status = AmlCreateLpiNode (AslName, 1, 0, ScopeNode, );
+Status = AmlCreateLpiNode (AslName, 0, 0, ScopeNode, );
 if (EFI_ERROR (Status)) {
   ASSERT (0);
   return Status;
-- 
2.25.1



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




[edk2-devel] [PATCH] Update FADT Minor Version to 5

2022-11-15 Thread Ilancheliyan Viswanathan
Update FADT Minor Version to 5

Signed-off-by: Ilancheliyan Viswanathan 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 

---
 MdePkg/Include/IndustryStandard/Acpi65.h | 3141 ++
 1 file changed, 3141 insertions(+)
 create mode 100644 MdePkg/Include/IndustryStandard/Acpi65.h

diff --git a/MdePkg/Include/IndustryStandard/Acpi65.h 
b/MdePkg/Include/IndustryStandard/Acpi65.h
new file mode 100644
index 00..43b69616d9
--- /dev/null
+++ b/MdePkg/Include/IndustryStandard/Acpi65.h
@@ -0,0 +1,3141 @@
+/** @file
+  ACPI 6.5 definitions from the ACPI Specification Revision 6.5 Aug, 2022.
+
+  Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
+  Copyright (c) 2019 - 2021, ARM Ltd. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef ACPI_6_5_H_
+#define ACPI_6_5_H_
+
+#include 
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+
+///
+/// ACPI 6.5 Generic Address Space definition
+///
+typedef struct {
+  UINT8 AddressSpaceId;
+  UINT8 RegisterBitWidth;
+  UINT8 RegisterBitOffset;
+  UINT8 AccessSize;
+  UINT64Address;
+} EFI_ACPI_6_5_GENERIC_ADDRESS_STRUCTURE;
+
+//
+// Generic Address Space Address IDs
+//
+#define EFI_ACPI_6_5_SYSTEM_MEMORY   0x00
+#define EFI_ACPI_6_5_SYSTEM_IO   0x01
+#define EFI_ACPI_6_5_PCI_CONFIGURATION_SPACE 0x02
+#define EFI_ACPI_6_5_EMBEDDED_CONTROLLER 0x03
+#define EFI_ACPI_6_5_SMBUS   0x04
+#define EFI_ACPI_6_5_SYSTEM_CMOS 0x05
+#define EFI_ACPI_6_5_PCI_BAR_TARGET  0x06
+#define EFI_ACPI_6_5_IPMI0x07
+#define EFI_ACPI_6_5_GENERAL_PURPOSE_IO  0x08
+#define EFI_ACPI_6_5_GENERIC_SERIAL_BUS  0x09
+#define EFI_ACPI_6_5_PLATFORM_COMMUNICATION_CHANNEL  0x0A
+#define EFI_ACPI_6_5_FUNCTIONAL_FIXED_HARDWARE   0x7F
+
+//
+// Generic Address Space Access Sizes
+//
+#define EFI_ACPI_6_5_UNDEFINED  0
+#define EFI_ACPI_6_5_BYTE   1
+#define EFI_ACPI_6_5_WORD   2
+#define EFI_ACPI_6_5_DWORD  3
+#define EFI_ACPI_6_5_QWORD  4
+
+//
+// ACPI 6.5 table structures
+//
+
+///
+/// Root System Description Pointer Structure
+///
+typedef struct {
+  UINT64Signature;
+  UINT8 Checksum;
+  UINT8 OemId[6];
+  UINT8 Revision;
+  UINT32RsdtAddress;
+  UINT32Length;
+  UINT64XsdtAddress;
+  UINT8 ExtendedChecksum;
+  UINT8 Reserved[3];
+} EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_POINTER;
+
+///
+/// RSD_PTR Revision (as defined in ACPI 6.5 spec.)
+///
+#define EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION  0x02 ///< 
ACPISpec (Revision 6.5) says current value is 2
+
+///
+/// Common table header, this prefaces all ACPI tables, including FACS, but
+/// excluding the RSD PTR structure
+///
+typedef struct {
+  UINT32Signature;
+  UINT32Length;
+} EFI_ACPI_6_5_COMMON_HEADER;
+
+//
+// Root System Description Table
+// No definition needed as it is a common description table header, the same 
with
+// EFI_ACPI_DESCRIPTION_HEADER, followed by a variable number of UINT32 table 
pointers.
+//
+
+///
+/// RSDT Revision (as defined in ACPI 6.5 spec.)
+///
+#define EFI_ACPI_6_5_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION  0x01
+
+//
+// Extended System Description Table
+// No definition needed as it is a common description table header, the same 
with
+// EFI_ACPI_DESCRIPTION_HEADER, followed by a variable number of UINT64 table 
pointers.
+//
+
+///
+/// XSDT Revision (as defined in ACPI 6.5 spec.)
+///
+#define EFI_ACPI_6_5_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION  0x01
+
+///
+/// Fixed ACPI Description Table Structure (FADT)
+///
+typedef struct {
+  EFI_ACPI_DESCRIPTION_HEADER   Header;
+  UINT32FirmwareCtrl;
+  UINT32Dsdt;
+  UINT8 Reserved0;
+  UINT8 PreferredPmProfile;
+  UINT16SciInt;
+  UINT32SmiCmd;
+  UINT8 AcpiEnable;
+  UINT8 AcpiDisable;
+  UINT8 S4BiosReq;
+  UINT8 PstateCnt;
+  UINT32Pm1aEvtBlk;
+  UINT32Pm1bEvtBlk;
+  UINT32Pm1aCntBlk;
+  UINT32Pm1bCntBlk;
+  UINT32Pm2CntBlk;
+  UINT32PmTmrBlk;
+  UINT32Gpe0Blk;
+  UINT32Gpe1Blk;
+  UINT8 Pm1EvtLen;
+  UINT8 Pm1CntLen;
+  UINT8 Pm2CntLen;
+  UINT8  

[edk2-devel] [PATCH 2/2] BoardModulePkg: Adds PCD to load UEFI Shell image

2022-11-15 Thread Abdul Lateef Attar via groups.io
defines two PCDs, PcdShellFile and PcdShellFileDesc,
which holds the GUID and description of the UEFI shell file to be loaded.

A PCDs based solution gives flexibility to the user to load different
images, by just overriding the DSC file.

The user can load a diagnostic image or test image during
PCDBootToShellOnly or later stages.

Cc: Eric Dong 
Cc: Liming Gao 
Signed-off-by: Abdul Lateef Attar 
---
 Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec  | 5 +
 .../Library/BoardBdsHookLib/BoardBdsHookLib.inf   | 3 +++
 .../Library/BoardBdsHookLib/BoardBootOption.c | 8 +---
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec 
b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index 2953e9527224..73cbd62be030 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -7,6 +7,7 @@
 # for the build infrastructure.

 #

 # Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.

+# Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

 #

 # SPDX-License-Identifier: BSD-2-Clause-Patent

 #

@@ -266,6 +267,10 @@ [PcdsFixedAtBuild, PcdsPatchableInModule]
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUSize|0x|UINT32|0x202B

   
gMinPlatformPkgTokenSpaceGuid.PcdFlashFvFspUOffset|0x|UINT32|0x202C

 

+  # GUID of Shell file to be loaded, default value is gUefiShellFileGuid 
define in ShellPkg.dec

+  gMinPlatformPkgTokenSpaceGuid.PcdShellFile|{GUID({0x7c04a583, 0x9e3e, 
0x4f1c, {0xad, 0x65, 0xe0, 0x52, 0x68, 0xd0, 0xb4, 0xd1}})}|VOID*|0x2230

+  gMinPlatformPkgTokenSpaceGuid.PcdShellFileDesc|L"Internal UEFI Shell 
2.0"|VOID*|0x2231

+

 [PcdsDynamic, PcdsDynamicEx]

   gMinPlatformPkgTokenSpaceGuid.PcdPcIoApicEnable|0x0|UINT32|0x9019

   
gMinPlatformPkgTokenSpaceGuid.PcdAcpiSleepControlRegisterAddressSpaceId|0x00|UINT8|0x0001004B

diff --git 
a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf 
b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
index 69f3fcb55222..e2ac73498b90 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.inf
@@ -2,6 +2,7 @@
 # Module Information file for the Bds Hook Library.

 #

 # Copyright (c) 2019, Intel Corporation. All rights reserved.

+# Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

 #

 # SPDX-License-Identifier: BSD-2-Clause-Patent

 #

@@ -59,6 +60,8 @@ [Pcd]
   gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleInputDevicePath## CONSUMES

   gMinPlatformPkgTokenSpaceGuid.PcdTrustedConsoleOutputDevicePath   ## CONSUMES

   gMinPlatformPkgTokenSpaceGuid.PcdTrustedStorageDevicePath ## CONSUMES

+  gMinPlatformPkgTokenSpaceGuid.PcdShellFile## CONSUMES

+  gMinPlatformPkgTokenSpaceGuid.PcdShellFileDesc## CONSUMES

 

 [Sources]

   BoardBdsHook.h

diff --git 
a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c 
b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
index dec3ce93ef71..de1676dad0c7 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c
@@ -2,6 +2,8 @@
   Driver for Platform Boot Options support.

 

 Copyright (c) 2019, Intel Corporation. All rights reserved.

+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

+

 SPDX-License-Identifier: BSD-2-Clause-Patent

 

 **/

@@ -335,7 +337,6 @@ PlatformBootManagerWaitCallback (
 

 EFI_GUID gUefiShellFileGuid = { 0x7C04A583, 0x9E3E, 0x4f1c, { 0xAD, 0x65, 
0xE0, 0x52, 0x68, 0xD0, 0xB4, 0xD1 } };

 

-#define INTERNAL_UEFI_SHELL_NAME  L"Internal UEFI Shell 2.0"

 #define UEFI_HARD_DRIVE_NAME  L"UEFI Hard Drive"

 

 /**

@@ -352,7 +353,8 @@ RegisterDefaultBootOption (
 

 ShellData = NULL;

 ShellDataSize = 0;

-RegisterFvBootOption (,  INTERNAL_UEFI_SHELL_NAME, 
(UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, ShellDataSize);

+CopyMem (, PcdGetPtr (PcdShellFile), sizeof (GUID));

+RegisterFvBootOption (, (CHAR16 *) PcdGetPtr 
(PcdShellFileDesc), (UINTN) -1, LOAD_OPTION_ACTIVE, (UINT8 *)ShellData, 
ShellDataSize);

 

   //

   // Boot Menu

@@ -557,7 +559,7 @@ BootOptionPriority (
   return 6;

 

 }

-if (StrCmp (BootOption->Description, INTERNAL_UEFI_SHELL_NAME) == 0) {

+if (StrCmp (BootOption->Description, (CHAR16 *) PcdGetPtr 
(PcdShellFileDesc)) == 0) {

   if (PcdGetBool (PcdBootToShellOnly)) {

 return 0;

   }

-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96406): https://edk2.groups.io/g/devel/message/96406
Mute This Topic: https://groups.io/mt/95046165/21656

[edk2-devel] [PATCH 0/2] BoardModulePkg: BoardBdsHookLib GCC fix

2022-11-15 Thread Abdul Lateef Attar via groups.io
 Patch 1: Fix the GCC boot time page fault exception,
  by copying PcdGetPtr to local variables.
 Patch 2: Adds PCD to hold the UEFI shell GUID value
  and description, to provide flexibility to load
  any UEFI application as UEFI shell.

PR : https://github.com/tianocore/edk2-platforms/pull/50

Cc: Eric Dong 
Cc: Liming Gao 
CC: Isaac Oram 

Abdul Lateef Attar (2):
  BoardModulePkg: Copy device path before processing
  BoardModulePkg: Adds PCD to load UEFI Shell image

 .../Intel/MinPlatformPkg/MinPlatformPkg.dec   |  5 +
 .../BoardBdsHookLib/BoardBdsHookLib.inf   |  3 +++
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++-
 .../Library/BoardBdsHookLib/BoardBootOption.c |  8 +---
 4 files changed, 27 insertions(+), 8 deletions(-)

-- 
2.25.1



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




[edk2-devel] [PATCH 1/2] BoardModulePkg: Copy device path before processing

2022-11-15 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

GCC compiler puts the DevicePath PCDs to the read-only
section. During boot if try to process the device path
after PtrGetPtr it throws a page fault exception.

Hence making a local copy using DuplicateDevicePath()
to avoid the page fault exception.

Cc: Eric Dong 
Cc: Liming Gao 

Signed-off-by: Abdul Lateef Attar 
---
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git 
a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c 
b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index 0bcee7c9a4ba..8700118d255a 100644
--- a/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
@@ -3,6 +3,7 @@
   implementation instance of the BDS hook library

 

   Copyright (c) 2019, Intel Corporation. All rights reserved.

+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

   SPDX-License-Identifier: BSD-2-Clause-Patent

 

 **/

@@ -131,7 +132,7 @@ IsTrustedConsole (
 

   switch (ConsoleType) {

 case ConIn:

-  TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleInputDevicePath);

+  TrustedConsoleDevicepath = DuplicateDevicePath (PcdGetPtr 
(PcdTrustedConsoleInputDevicePath));

   break;

 case ConOut:

   //

@@ -147,7 +148,7 @@ IsTrustedConsole (
 TempDevicePath = NextDevicePathNode (TempDevicePath);

   }

 

-  TrustedConsoleDevicepath = PcdGetPtr (PcdTrustedConsoleOutputDevicePath);

+  TrustedConsoleDevicepath = DuplicateDevicePath (PcdGetPtr 
(PcdTrustedConsoleOutputDevicePath));

   break;

 default:

   ASSERT (FALSE);

@@ -171,7 +172,9 @@ IsTrustedConsole (
   } while (TempDevicePath != NULL);

 

   FreePool (ConsoleDevice);

-

+  if (TrustedConsoleDevicepath != NULL) {

+FreePool (TrustedConsoleDevicepath);

+  }

   return FALSE;

 }

 

@@ -624,7 +627,7 @@ ConnectTrustedStorage (
   EFI_STATUSStatus;

   EFI_HANDLEDeviceHandle;

 

-  TrustedStorageDevicepath = PcdGetPtr (PcdTrustedStorageDevicePath);

+  TrustedStorageDevicepath = DuplicateDevicePath (PcdGetPtr 
(PcdTrustedStorageDevicePath));

   DumpDevicePath (L"TrustedStorage", TrustedStorageDevicepath);

 

   TempDevicePath = TrustedStorageDevicepath;

@@ -649,6 +652,9 @@ ConnectTrustedStorage (
 

 FreePool (Instance);

   } while (TempDevicePath != NULL);

+  if (TrustedStorageDevicepath != NULL) {

+FreePool (TrustedStorageDevicepath);

+  }

 }

 

 

@@ -1031,7 +1037,7 @@ AddConsoleVariable (
   EFI_HANDLEGraphicsControllerHandle;

   EFI_DEVICE_PATH   *GopDevicePath;

 

-  TempDevicePath = ConsoleDevicePath;

+  TempDevicePath = DuplicateDevicePath (ConsoleDevicePath);

   do {

 Instance = GetNextDevicePathInstance (, );

 if (Instance == NULL) {

@@ -1074,6 +1080,9 @@ AddConsoleVariable (
 

 FreePool (Instance);

   } while (TempDevicePath != NULL);

+  if (TempDevicePath != NULL) {

+FreePool (TempDevicePath);

+  }

 }

 

 

-- 
2.25.1



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




Re: [edk2-devel] 回复: [PATCH edk2-stable202211 v2 0/2] Update Pytool PIP Versions

2022-11-15 Thread Michael Kubacki

The pull request is rebased and the commits include all Reviewed-by tags.

https://github.com/tianocore/edk2/pull/3632

Thanks,
Michael

On 11/14/2022 10:45 PM, Michael D Kinney wrote:

Reviewed-by: Michael D Kinney 

Approved for edk2-stable202211

Mike


-Original Message-
From: Michael Kubacki 
Sent: Monday, November 14, 2022 7:18 PM
To: devel@edk2.groups.io; Gao, Liming 
Cc: 'Sean Brogan' ; 'Andrew Fish' ; 'Leif 
Lindholm' ;
Kinney, Michael D 
Subject: Re: [edk2-devel] 回复: [PATCH edk2-stable202211 v2 0/2] Update Pytool 
PIP Versions

I would like to elaborate on some of the information in this cover
letter to better emphasize why this should be included in the
edk2-stable202211 stable tag.

These releases of edk2-pytool-library and edk2-pytool-extensions must be
paired together. The edk2-pytool-library release already being used by
edk2 (0.12.0) requires the edk2-pytool-extensions 0.20.0 release.

The updates in this series should be considered "required" as opposed to
"recommended" to ensure compatibility in the stable tag release.

The reasoning for updating edk2-pytool-library from 0.12.0 to 0.12.1 is
straightforward, it fixes the bug described in the cover letter.

The issue with not taking in the 0.20.0 edk2-pytool-extensions update is
that PR Evaluation, which is used in CI to determine what packages to
build, will not build the code in some cases causing build failures to
potentially creep through.

For example, without this update, a PR with a file only changed outside
a package, such as pip-requirements.txt or a file in .pytool, will not
trigger a full build to test the change as a file is not modified within
an edk2 package.

Thanks,
Michael

On 11/14/2022 10:00 PM, gaoliming via groups.io wrote:

Michael:
I have no comments to merge this patch set for the stable tag.

Thanks
Liming

-邮件原件-
发件人: mikub...@linux.microsoft.com 
发送时间: 2022年11月15日 8:19
收件人: devel@edk2.groups.io
抄送: Sean Brogan ; Michael Kubacki
; Liming Gao ;
Andrew Fish ; Leif Lindholm 
主题: [PATCH edk2-stable202211 v2 0/2] Update Pytool PIP Versions

From: Michael Kubacki 

1. Updates edk2-pytool-library to 0.12.1
 - Picks up a minor bug fix

2. Updates edk2-pytool-extensions to 0.20.0
 - Picks up a major release

The changes in each update are in the respective patch commit
messages.

CI was run against both of these patches in this pull request:
https://github.com/tianocore/edk2/pull/3632

These changes are recommended to be included in the edk2-stable202211
tag for the following reasons:

1. edk2-pytool-library 0.12.0 to 0.12.1 includes a single bug fix
 that simply returns file paths from
 Edk2Path.GetContainingModules() with the original case used by
 the operating system. This allow case sensitive callers to match
 paths returned by the function correctly.

 This can impact flows such as PR Eval that use this function to
 determine which modules were impacted by a code change. Without
 this change PR eval may not return consistent/expected results
 across operating systems.

2. The edk2-pytool-library change requires edk2-pytool-extensions
 0.20.0. For this reason, edk2-pytool-extensions setup.py was
 updated in 0.20.0 to specify 0.12.1 as the edk2-pytool-library
 requirement. The logic of determining a package in pytool-library
 (Edk2Path.GetContainingPackage()) needs a corresponding change in
 the edk2-pytool-extensions 0.20.0 release.

 Without this change, flows such as PR Eval will not have updated
 logic for calling the function and return incorrect results.

These changes have been tested against edk2 in pytool integration
testing, the PR linked above, and against similar code in Mu.

V2 changes:

1. Add stable tag to patch subject
2. Explain why changes should be included in stable tag
3. Add Reviewed-by tags to patches from v1

Cc: Sean Brogan 
Cc: Michael Kubacki 
Cc: Liming Gao 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Signed-off-by: Michael Kubacki 

Michael Kubacki (2):
pip-requirements.txt: Update to edk2-pytool-library 0.12.1
pip-requirements.txt: Update to edk2-pytool-extensions 0.20.0

   pip-requirements.txt | 4 ++--
   1 file changed, 2 insertions(+), 2 deletions(-)

--
2.28.0.windows.1

















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




Re: [edk2-devel] [PATCH 3/4] OvmfPkg/IntelTdx: Enable separate-fv in IntelTdx/IntelTdxX64.fdf

2022-11-15 Thread Gerd Hoffmann
  Hi,

> So we separate DXEFV into 2 FVs: DXEFV and NCCFV. All the drivers which
> are not needed by a Confidential Computing guest are moved from DXEFV
> to NCCFV.

>  INF  OvmfPkg/VirtioBlkDxe/VirtioBlk.inf
> -INF  OvmfPkg/VirtioScsiDxe/VirtioScsi.inf

Why keep virtio-blk in DXEFV but drop virtio-scsi?

> -INF  MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBusDxe.inf
> -INF  MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDiskDxe.inf

These are needed too for virtio-scsi.

> +INF  FatPkg/EnhancedFatDxe/Fat.inf
> +INF  ShellPkg/Application/Shell/Shell.inf

Why add the shell to DXEFV?  Shouldn't this go to NCCFV?

Also please wrap this into '!if $(BUILD_SHELL) == TRUE' for
consistency with the other ovmf build variants.

take care,
  Gerd



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




Re: [edk2-devel] [PATCH 0/3] CloudHv:arm: Enable direct kernel boot

2022-11-15 Thread Jianyong Wu
Thanks Sami!

> -Original Message-
> From: Sami Mujawar 
> Sent: Tuesday, November 15, 2022 4:52 PM
> To: Jianyong Wu ; devel@edk2.groups.io
> Cc: ardb+tianoc...@kernel.org; Justin He ; nd
> 
> Subject: Re: [PATCH 0/3] CloudHv:arm: Enable direct kernel boot
> 
> Hi Jianyong,
> 
> Apologies this slipped off my radar.
> I will start reviewing your patches this week.
> 
> Regards,
> 
> Sami Mujawar
> 
> On 15/11/2022, 03:00, "Jianyong Wu"  wrote:
> 
> Hello,
> 
> Long time silent. Any comments?
> 
> Thanks
> Jianyong
> 
> > -Original Message-
> > From: Jianyong Wu 
> > Sent: Friday, September 16, 2022 10:46 AM
> > To: devel@edk2.groups.io; Sami Mujawar 
> > Cc: ardb+tianoc...@kernel.org; Justin He ;
> Jianyong
> > Wu 
> > Subject: [PATCH 0/3] CloudHv:arm: Enable direct kernel boot
> >
> > Direct kernel boot removes the dependency of retrieving kernel image
> from
> > block device. For Cloud Hypervisor, we use the following way to support
> it.
> >
> > 1. Cloud Hypervisor store kernel image into memory and put kernel info,
> >including the memory base and size, into DT; 2. When init memory in
> edk2,
> > the kernel memory region is retrieved from
> >DT and set it as read only memory region; 3. Edk2 fetches kernel from
> > memory and prepare a image handle; 4. Load kernel using LoadImage in
> the
> > end.
> >
> > 1 is done in Cloud Hypervisor, 2 and 3 is done in this patch set, 4 is 
> not
> > affected.
> >
> > github PR link: https://github.com/tianocore/edk2/pull/3339
> >
> > Signed-off-by: Jianyong Wu 
> >
> > Jianyong Wu (3):
> >   CloudHv:arm: add kernel load fs driver
> >   CloudHv:arm: build hob for kernel image memory as read-only
> >   CloudHv:arm: add kernel loader lib dsc/fdf
> >
> >  ArmVirtPkg/ArmVirtCloudHv.dsc |   8 +-
> >  ArmVirtPkg/ArmVirtCloudHv.fdf |   1 +
> >  .../CloudHvKernelLoaderFsDxe.c| 969 ++
> >  .../CloudHvKernelLoaderFsDxe.inf  |  55 +
> >  .../CloudHvVirtMemInfoLib.c   |  66 +-
> >  5 files changed, 1094 insertions(+), 5 deletions(-)  create mode 100644
> > ArmVirtPkg/CloudHvKernelLoaderFsDxe/CloudHvKernelLoaderFsDxe.c
> >  create mode 100644
> > ArmVirtPkg/CloudHvKernelLoaderFsDxe/CloudHvKernelLoaderFsDxe.inf
> >
> > --
> > 2.17.1
> 
> 



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




Re: [edk2-devel] [PATCH 0/3] CloudHv:arm: Enable direct kernel boot

2022-11-15 Thread Sami Mujawar
Hi Jianyong,

Apologies this slipped off my radar. 
I will start reviewing your patches this week.

Regards,

Sami Mujawar

On 15/11/2022, 03:00, "Jianyong Wu"  wrote:

Hello,

Long time silent. Any comments?

Thanks
Jianyong

> -Original Message-
> From: Jianyong Wu 
> Sent: Friday, September 16, 2022 10:46 AM
> To: devel@edk2.groups.io; Sami Mujawar 
> Cc: ardb+tianoc...@kernel.org; Justin He ; Jianyong
> Wu 
> Subject: [PATCH 0/3] CloudHv:arm: Enable direct kernel boot
>
> Direct kernel boot removes the dependency of retrieving kernel image from
> block device. For Cloud Hypervisor, we use the following way to support 
it.
>
> 1. Cloud Hypervisor store kernel image into memory and put kernel info,
>including the memory base and size, into DT; 2. When init memory in 
edk2,
> the kernel memory region is retrieved from
>DT and set it as read only memory region; 3. Edk2 fetches kernel from
> memory and prepare a image handle; 4. Load kernel using LoadImage in the
> end.
>
> 1 is done in Cloud Hypervisor, 2 and 3 is done in this patch set, 4 is not
> affected.
>
> github PR link: https://github.com/tianocore/edk2/pull/3339
>
> Signed-off-by: Jianyong Wu 
>
> Jianyong Wu (3):
>   CloudHv:arm: add kernel load fs driver
>   CloudHv:arm: build hob for kernel image memory as read-only
>   CloudHv:arm: add kernel loader lib dsc/fdf
>
>  ArmVirtPkg/ArmVirtCloudHv.dsc |   8 +-
>  ArmVirtPkg/ArmVirtCloudHv.fdf |   1 +
>  .../CloudHvKernelLoaderFsDxe.c| 969 ++
>  .../CloudHvKernelLoaderFsDxe.inf  |  55 +
>  .../CloudHvVirtMemInfoLib.c   |  66 +-
>  5 files changed, 1094 insertions(+), 5 deletions(-)  create mode 100644
> ArmVirtPkg/CloudHvKernelLoaderFsDxe/CloudHvKernelLoaderFsDxe.c
>  create mode 100644
> ArmVirtPkg/CloudHvKernelLoaderFsDxe/CloudHvKernelLoaderFsDxe.inf
>
> --
> 2.17.1




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




[edk2-devel] [Patch V1 3/3] BaseTools: Add new build option for Variable default value generation

2022-11-15 Thread Yuwei Chen
Add new build option "--gen-default-variable-bin" for Variable
default value generation from Python VFR tool's extended json
output file.

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Yuwei Chen 
---
 edk2basetools/AutoGen/DataPipe.py |   2 ++
 edk2basetools/AutoGen/GenDefaultVar.py| 577 
+
 edk2basetools/AutoGen/ModuleAutoGen.py|   8 
 edk2basetools/Common/GlobalData.py|   5 +
 edk2basetools/VfrCompiler/VfrSyntaxVisitor.py |  12 ++--
 edk2basetools/build/build.py  |  18 ++
 edk2basetools/build/buildoptions.py   |   1 +
 7 files changed, 617 insertions(+), 6 deletions(-)

diff --git a/edk2basetools/AutoGen/DataPipe.py 
b/edk2basetools/AutoGen/DataPipe.py
index 01a90dd..a9bd168 100755
--- a/edk2basetools/AutoGen/DataPipe.py
+++ b/edk2basetools/AutoGen/DataPipe.py
@@ -173,3 +173,5 @@ def FillData(self,PlatformInfo):
 self.DataContainer = 
{"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
 
 self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
+
+self.DataContainer = {"GenDefaultVarBin": GlobalData.gGenDefaultVarBin}
diff --git a/edk2basetools/AutoGen/GenDefaultVar.py 
b/edk2basetools/AutoGen/GenDefaultVar.py
new file mode 100644
index 000..6be898a
--- /dev/null
+++ b/edk2basetools/AutoGen/GenDefaultVar.py
@@ -0,0 +1,577 @@
+import json
+from ctypes import *
+import re
+import copy
+from struct import unpack
+import os
+import Common.EdkLogger as EdkLogger
+
+class GUID(Structure):
+_fields_ = [
+('Guid1',c_uint32),
+('Guid2',c_uint16),
+('Guid3',c_uint16),
+('Guid4',ARRAY(c_uint8, 8)),
+]
+
+def from_list(self, listformat):
+self.Guid1 = listformat[0]
+self.Guid2 = listformat[1]
+self.Guid3 = listformat[2]
+for i in range(8):
+self.Guid4[i] = listformat[i+3]
+
+def __cmp__(self, otherguid):
+if isinstance(otherguid, GUID):
+return 1
+rt = False
+if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and 
self.Guid3 == otherguid.Guid3:
+rt = True
+for i in range(8):
+rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
+return rt
+
+
+class TIME(Structure):
+_fields_ = [
+('Year', c_uint16),
+('Month',c_uint8),
+('Day',  c_uint8),
+('Hour', c_uint8),
+('Minute',   c_uint8),
+('Second',   c_uint8),
+('Pad1', c_uint8),
+('Nanosecond',   c_uint32),
+('TimeZone', c_uint16),
+('Daylight', c_uint8),
+('Pad2', c_uint8),
+]
+def __init__(self):
+self.Year = 0x0
+self.Month = 0x0
+self.Day = 0x0
+self.Hour = 0x0
+self.Minute = 0x0
+self.Second = 0x0
+self.Pad1 = 0x0
+self.Nanosecond = 0x0
+self.TimeZone = 0x0
+self.Daylight = 0x0
+self.Pad2 = 0x0
+
+
+EFI_VARIABLE_GUID = [0xddcf3616, 0x3275, 0x4164,
+ 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d]
+EFI_AUTHENTICATED_VARIABLE_GUID = [
+0xaaf32c78, 0x947b, 0x439a, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92]
+
+AuthVarGuid = GUID()
+AuthVarGuid.from_list(EFI_AUTHENTICATED_VARIABLE_GUID)
+VarGuid = GUID()
+VarGuid.from_list(EFI_VARIABLE_GUID)
+
+# Variable Store Header Format.
+VARIABLE_STORE_FORMATTED = 0x5a
+# Variable Store Header State.
+VARIABLE_STORE_HEALTHY = 0xfe
+
+
+class VARIABLE_STORE_HEADER(Structure):
+_fields_ = [
+('Signature',GUID),
+('Size', c_uint32),
+('Format',   c_uint8),
+('State',c_uint8),
+('Reserved', c_uint16),
+('Reserved1',c_uint32),
+]
+
+
+# Variable data start flag.
+VARIABLE_DATA = 0x55AA
+
+# Variable State flags.
+VAR_IN_DELETED_TRANSITION = 0xfe
+VAR_DELETED = 0xfd
+VAR_HEADER_VALID_ONLY = 0x7f
+VAR_ADDED = 0x3f
+
+
+class VARIABLE_HEADER(Structure):
+_fields_ = [
+('StartId',  c_uint16),
+('State',c_uint8),
+('Reserved', c_uint8),
+

[edk2-devel] [Patch V1 2/3] BaseTools: Add new build option for PyVfrCompiler yaml generation

2022-11-15 Thread Yuwei Chen
Add new build option "--vfr-yaml-enable" for Python VfrCompiler
extended output yaml file generation.

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Yuwei Chen 
---
 edk2basetools/AutoGen/DataPipe.py  |  2 ++
 edk2basetools/AutoGen/ModuleAutoGen.py |  8 
 edk2basetools/Common/GlobalData.py |  4 
 edk2basetools/build/build.py   | 32 
 edk2basetools/build/buildoptions.py|  1 +
 5 files changed, 47 insertions(+)

diff --git a/edk2basetools/AutoGen/DataPipe.py 
b/edk2basetools/AutoGen/DataPipe.py
index f562deb..01a90dd 100755
--- a/edk2basetools/AutoGen/DataPipe.py
+++ b/edk2basetools/AutoGen/DataPipe.py
@@ -171,3 +171,5 @@ def FillData(self,PlatformInfo):
 self.DataContainer = 
{"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
 
 self.DataContainer = 
{"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
+
+self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
diff --git a/edk2basetools/AutoGen/ModuleAutoGen.py 
b/edk2basetools/AutoGen/ModuleAutoGen.py
index a7ca949..679a989 100755
--- a/edk2basetools/AutoGen/ModuleAutoGen.py
+++ b/edk2basetools/AutoGen/ModuleAutoGen.py
@@ -434,6 +434,14 @@ def FfsOutputDir(self):
 def DebugDir(self):
 return _MakeDir((self.BuildDir, "DEBUG"))
 
+@cached_property
+def VarIFiles(self):
+rt = []
+for SrcFile in self.SourceFileList:
+if SrcFile.Ext.lower() == '.vfr':
+rt.append(os.path.join(self.OutputDir, 
"{}.i".format(SrcFile.BaseName)))
+return rt
+
 ## Return the path of custom file
 @cached_property
 def CustomMakefile(self):
diff --git a/edk2basetools/Common/GlobalData.py 
b/edk2basetools/Common/GlobalData.py
index fcde26b..475193e 100755
--- a/edk2basetools/Common/GlobalData.py
+++ b/edk2basetools/Common/GlobalData.py
@@ -123,3 +123,7 @@
 # Common lock for the file access in multiple process AutoGens
 file_lock = None
 
+#
+# Build flag for generate Yaml file from Vfr file
+#
+gVfrYamlEnable = False
diff --git a/edk2basetools/build/build.py b/edk2basetools/build/build.py
index 1ccb4be..f737172 100755
--- a/edk2basetools/build/build.py
+++ b/edk2basetools/build/build.py
@@ -750,6 +750,7 @@ def __init__(self, Target, WorkspaceDir, 
BuildOptions,log_q):
 GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
 GlobalData.gEnableGenfdsMultiThread = not 
BuildOptions.NoGenfdsMultiThread
 GlobalData.gDisableIncludePathCheck = 
BuildOptions.DisableIncludePathCheck
+GlobalData.gVfrYamlEnable = BuildOptions.VfrYamlEnable
 
 if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
 EdkLogger.error("build", OPTION_NOT_SUPPORTED, 
ExtraData="--binary-destination must be used together with --hash.")
@@ -1462,6 +1463,17 @@ def _Build(self, Target, AutoGenObject, 
CreateDepsCodeFile=True, CreateDepsMakeF
 
 # genfds
 if Target == 'fds':
+if GlobalData.gVfrYamlEnable:
+from VfrCompiler.main import VfrParse
+variable_i_filelist = 
os.path.join(AutoGenObject.BuildDir,"variable_i_filelist.txt")
+if os.path.exists(variable_i_filelist):
+with open(variable_i_filelist) as file:
+i_filelist = file.readlines()
+for i_file in i_filelist:
+inputfile = i_file.replace("\n", "")
+yamloutputfile = inputfile.split(".")[0] + '.yaml'
+jsonoutputfile = inputfile.split(".")[0] + '.json'
+VfrParse(inputfile, yamloutputfile, jsonoutputfile)
 if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
 EdkLogger.error("build", COMMAND_FAILURE)
 Threshold = self.GetFreeSizeThreshold()
@@ -2248,6 +2260,15 @@ def PerformAutoGen(self,BuildTarget,ToolChain):
 fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))
 fw.write("BuildDir=%s\n" % Wa.BuildDir)
 fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))
+variable_i_filelist = 
os.path.join(Wa.BuildDir,"variable_i_filelist.txt")
+vfr_var_i = []
+if GlobalData.gVfrYamlEnable:
+for ma in self.AllModules:
+vfr_var_i.extend(ma.VarIFiles)
+SaveFileOnChange(variable_i_filelist, "\n".join(vfr_var_i), False)
+else:
+if os.path.exists(variable_i_filelist):
+os.remove(variable_i_filelist)
 
 if GlobalData.gBinCacheSource:
 BuildModules.extend(self.MakeCacheMiss)
@@ -2360,6 +2381,17 @@ def _MultiThreadBuildPlatform(self):
 #
 # Generate FD image if there's a FDF file found
 #
+if GlobalData.gVfrYamlEnable:
+from VfrCompiler.main import VfrParse
+  

[edk2-devel] [Patch V2 3/3] [edk2-staging]BaseTools: Add new build option for Variable default value generation

2022-11-15 Thread Yuwei Chen
Add new build option "--gen-default-variable-bin" for Variable
default value generation from Python VFR tool's extended json
output file.

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Yuwei Chen 
---
 BaseTools/Source/Python/AutoGen/DataPipe.py |   2 ++
 BaseTools/Source/Python/AutoGen/GenDefaultVar.py| 577 
+
 BaseTools/Source/Python/AutoGen/ModuleAutoGen.py|   8 
 BaseTools/Source/Python/Common/GlobalData.py|   5 +
 BaseTools/Source/Python/VfrCompiler/VfrSyntaxVisitor.py |  12 ++--
 BaseTools/Source/Python/build/build.py  |  19 
++-
 BaseTools/Source/Python/build/buildoptions.py   |   1 +
 7 files changed, 617 insertions(+), 7 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py 
b/BaseTools/Source/Python/AutoGen/DataPipe.py
index c700baf7b7..e45b4a928a 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -173,3 +173,5 @@ class MemoryDataPipe(DataPipe):
 self.DataContainer = 
{"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
 
 self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
+
+self.DataContainer = {"GenDefaultVarBin": GlobalData.gGenDefaultVarBin}
diff --git a/BaseTools/Source/Python/AutoGen/GenDefaultVar.py 
b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
new file mode 100644
index 00..859d4f25eb
--- /dev/null
+++ b/BaseTools/Source/Python/AutoGen/GenDefaultVar.py
@@ -0,0 +1,577 @@
+import json
+from ctypes import *
+import re
+import copy
+from struct import unpack
+import os
+import Common.EdkLogger as EdkLogger
+
+class GUID(Structure):
+_fields_ = [
+('Guid1',c_uint32),
+('Guid2',c_uint16),
+('Guid3',c_uint16),
+('Guid4',ARRAY(c_uint8, 8)),
+]
+
+def from_list(self, listformat):
+self.Guid1 = listformat[0]
+self.Guid2 = listformat[1]
+self.Guid3 = listformat[2]
+for i in range(8):
+self.Guid4[i] = listformat[i+3]
+
+def __cmp__(self, otherguid):
+if isinstance(otherguid, GUID):
+return 1
+rt = False
+if self.Guid1 == otherguid.Guid1 and self.Guid2 == otherguid.Guid2 and 
self.Guid3 == otherguid.Guid3:
+rt = True
+for i in range(8):
+rt = rt & (self.Guid4[i] == otherguid.Guid4[i])
+return rt
+
+
+class TIME(Structure):
+_fields_ = [
+('Year', c_uint16),
+('Month',c_uint8),
+('Day',  c_uint8),
+('Hour', c_uint8),
+('Minute',   c_uint8),
+('Second',   c_uint8),
+('Pad1', c_uint8),
+('Nanosecond',   c_uint32),
+('TimeZone', c_uint16),
+('Daylight', c_uint8),
+('Pad2', c_uint8),
+]
+def __init__(self):
+self.Year = 0x0
+self.Month = 0x0
+self.Day = 0x0
+self.Hour = 0x0
+self.Minute = 0x0
+self.Second = 0x0
+self.Pad1 = 0x0
+self.Nanosecond = 0x0
+self.TimeZone = 0x0
+self.Daylight = 0x0
+self.Pad2 = 0x0
+
+
+EFI_VARIABLE_GUID = [0xddcf3616, 0x3275, 0x4164,
+ 0x98, 0xb6, 0xfe, 0x85, 0x70, 0x7f, 0xfe, 0x7d]
+EFI_AUTHENTICATED_VARIABLE_GUID = [
+0xaaf32c78, 0x947b, 0x439a, 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92]
+
+AuthVarGuid = GUID()
+AuthVarGuid.from_list(EFI_AUTHENTICATED_VARIABLE_GUID)
+VarGuid = GUID()
+VarGuid.from_list(EFI_VARIABLE_GUID)
+
+# Variable Store Header Format.
+VARIABLE_STORE_FORMATTED = 0x5a
+# Variable Store Header State.
+VARIABLE_STORE_HEALTHY = 0xfe
+
+
+class VARIABLE_STORE_HEADER(Structure):
+_fields_ = [
+('Signature',GUID),
+('Size', c_uint32),
+('Format',   c_uint8),
+('State',c_uint8),
+('Reserved', c_uint16),
+('Reserved1',c_uint32),
+]
+
+
+# Variable data start flag.
+VARIABLE_DATA = 0x55AA
+
+# Variable State flags.
+VAR_IN_DELETED_TRANSITION = 0xfe
+VAR_DELETED = 0xfd
+VAR_HEADER_VALID_ONLY = 0x7f
+VAR_ADDED = 0x3f
+
+
+class VARIABLE_HEADER(Structure):
+_fields_ = [
+

[edk2-devel] [Patch V2 2/3] [edk2-staging]BaseTools: Add new build option for PyVfrCompiler yaml generation

2022-11-15 Thread Yuwei Chen
Add new build option "--vfr-yaml-enable" for Python VfrCompiler
extended output yaml file generation.

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Yuwei Chen 
---
 BaseTools/Source/Python/AutoGen/DataPipe.py  |  2 ++
 BaseTools/Source/Python/AutoGen/ModuleAutoGen.py |  8 
 BaseTools/Source/Python/Common/GlobalData.py |  4 
 BaseTools/Source/Python/build/build.py   | 33 
+
 BaseTools/Source/Python/build/buildoptions.py|  1 +
 5 files changed, 48 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py 
b/BaseTools/Source/Python/AutoGen/DataPipe.py
index 848c7a8296..c700baf7b7 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -171,3 +171,5 @@ class MemoryDataPipe(DataPipe):
 self.DataContainer = 
{"EnableGenfdsMultiThread":GlobalData.gEnableGenfdsMultiThread}
 
 self.DataContainer = 
{"gPlatformFinalPcds":GlobalData.gPlatformFinalPcds}
+
+self.DataContainer = {"VfrYamlEnable": GlobalData.gVfrYamlEnable}
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py 
b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
index d05410b329..eb81c3f3af 100755
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -434,6 +434,14 @@ class ModuleAutoGen(AutoGen):
 def DebugDir(self):
 return _MakeDir((self.BuildDir, "DEBUG"))
 
+@cached_property
+def VarIFiles(self):
+rt = []
+for SrcFile in self.SourceFileList:
+if SrcFile.Ext.lower() == '.vfr':
+rt.append(os.path.join(self.OutputDir, 
"{}.i".format(SrcFile.BaseName)))
+return rt
+
 ## Return the path of custom file
 @cached_property
 def CustomMakefile(self):
diff --git a/BaseTools/Source/Python/Common/GlobalData.py 
b/BaseTools/Source/Python/Common/GlobalData.py
index 197bd83666..039a9648aa 100755
--- a/BaseTools/Source/Python/Common/GlobalData.py
+++ b/BaseTools/Source/Python/Common/GlobalData.py
@@ -123,3 +123,7 @@ gSikpAutoGenCache = set()
 # Common lock for the file access in multiple process AutoGens
 file_lock = None
 
+#
+# Build flag for generate Yaml file from Vfr file
+#
+gVfrYamlEnable = False
diff --git a/BaseTools/Source/Python/build/build.py 
b/BaseTools/Source/Python/build/build.py
index 51fb1f433e..7e2f25686d 100755
--- a/BaseTools/Source/Python/build/build.py
+++ b/BaseTools/Source/Python/build/build.py
@@ -748,6 +748,7 @@ class Build():
 GlobalData.gBinCacheSource = BuildOptions.BinCacheSource
 GlobalData.gEnableGenfdsMultiThread = not 
BuildOptions.NoGenfdsMultiThread
 GlobalData.gDisableIncludePathCheck = 
BuildOptions.DisableIncludePathCheck
+GlobalData.gVfrYamlEnable = BuildOptions.VfrYamlEnable
 
 if GlobalData.gBinCacheDest and not GlobalData.gUseHashCache:
 EdkLogger.error("build", OPTION_NOT_SUPPORTED, 
ExtraData="--binary-destination must be used together with --hash.")
@@ -1460,6 +1461,17 @@ class Build():
 
 # genfds
 if Target == 'fds':
+if GlobalData.gVfrYamlEnable:
+from VfrCompiler.main import VfrParse
+variable_i_filelist = 
os.path.join(AutoGenObject.BuildDir,"variable_i_filelist.txt")
+if os.path.exists(variable_i_filelist):
+with open(variable_i_filelist) as file:
+i_filelist = file.readlines()
+for i_file in i_filelist:
+inputfile = i_file.replace("\n", "")
+yamloutputfile = inputfile.split(".")[0] + '.yaml'
+jsonoutputfile = inputfile.split(".")[0] + '.json'
+VfrParse(inputfile, yamloutputfile, jsonoutputfile)
 if GenFdsApi(AutoGenObject.GenFdsCommandDict, self.Db):
 EdkLogger.error("build", COMMAND_FAILURE)
 Threshold = self.GetFreeSizeThreshold()
@@ -2246,6 +2258,15 @@ class Build():
 fw.write("Arch=%s\n" % "|".join((Wa.ArchList)))
 fw.write("BuildDir=%s\n" % Wa.BuildDir)
 fw.write("PlatformGuid=%s\n" % str(Wa.AutoGenObjectList[0].Guid))
+variable_i_filelist = 
os.path.join(Wa.BuildDir,"variable_i_filelist.txt")
+vfr_var_i = []
+if GlobalData.gVfrYamlEnable:
+for ma in self.AllModules:
+vfr_var_i.extend(ma.VarIFiles)
+SaveFileOnChange(variable_i_filelist, "\n".join(vfr_var_i), False)
+else:
+if os.path.exists(variable_i_filelist):
+os.remove(variable_i_filelist)
 
 if GlobalData.gBinCacheSource:
 BuildModules.extend(self.MakeCacheMiss)
@@ -2358,6 +2379,18 @@ class Build():
 #
 # Generate FD image if there's a FDF file found
 #
+if 

Re: [edk2-devel] [PATCH 1/1][edk2-stable202211] SecurityPkg/RngDxe: Fix Rng algo selection for Arm

2022-11-15 Thread PierreGondois




On 11/14/22 20:12, Ard Biesheuvel wrote:

On Mon, 14 Nov 2022 at 19:14, PierreGondois  wrote:


From: Pierre Gondois 

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

PcdCpuRngSupportedAlgorithm is set to the Zero Guid for KvmTool
since it is not possible to predict which algorithm will be
implemented for Arm's FEAT_RNG in the host. Current handling is:
- skipping the Zero Guid, which should not happen to handle
   KvmTool's case,
- triggering an ASSERT if no algorithm was found. However having
   no Rng algorithm is a valid case,

Correctly handle the Zero Guid case and replace the ASSERT by a
warning message when no Rng algorithm is found.
Also simplify the selection of the Rng algorithm when the default
one is selected by just picking up the first element of
mAvailableAlgoArray.



Can you explain a bit more please

What is supposed to happen?

What happens instead?

Why is this patch the correct way to address this issue?


Hello Ard,
mAvailableAlgoArray in RngDxe stores the availble Rng algorithms.
The array is populated in GetAvailableAlgorithms() by testing the
possible algorithms. This is done when the driver is loaded.
PcdCpuRngSupportedAlgorithm is the Guid used to identify the algorithm
behind the RngLib, i.e. the RNDR instruction. It is set to a zero Guid
for KvmTool since it isn't possible to set a unique value for all the
hosts.
When using RngDxe, it is possible to either specify which Rng algorithm
to use or to use a default one. When requesting the default one, the
first element of mAvailableAlgoArray should be used. This is an
arbitrary decision, but mAvailableAlgoArray will always be populated
in the same the order.

On arm64, the 2 possible algorithms are, in order:
- the RngLib, which should use the RNDR instruction
- the TRNG
If there is no TRNG, the only Guid available will be the one for RNDR,
i.e. PcdCpuRngSupportedAlgorithm (zero Guid).

The current code:
- skips the zero Guid, which should not be the case since it represents
  a valid algorithm,
- ASSERT if no algorithm is found. If no algorithm is found, we
  should not stop, just return an error code, and the caller will act
  on this error. A warning is however added in case there is no
  algorithm found,

Regards,
Pierre






Reported-by: Sami Mujawar 
Signed-off-by: Pierre Gondois 
---
  .../RandomNumberGenerator/RngDxe/ArmRngDxe.c  | 15 +++
  SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c |  8 +++-
  2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c 
b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
index 5ba319899ce9..722d53386373 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/ArmRngDxe.c
@@ -76,7 +76,6 @@ RngGetRNG (
)
  {
EFI_STATUS  Status;
-  UINTN   Index;

if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) {
  return EFI_INVALID_PARAMETER;
@@ -86,21 +85,13 @@ RngGetRNG (
  //
  // Use the default RNG algorithm if RNGAlgorithm is NULL.
  //
-for (Index = 0; Index < mAvailableAlgoArrayCount; Index++) {
-  if (!IsZeroGuid ([Index])) {
-RNGAlgorithm = [Index];
-goto FoundAlgo;
-  }
-}
-
-if (Index == mAvailableAlgoArrayCount) {
-  // No algorithm available.
-  ASSERT (Index != mAvailableAlgoArrayCount);
+if (mAvailableAlgoArrayCount != 0) {
+  RNGAlgorithm = [0];
+} else {
return EFI_DEVICE_ERROR;
  }
}

-FoundAlgo:
if (CompareGuid (RNGAlgorithm, PcdGetPtr (PcdCpuRngSupportedAlgorithm))) {
  Status = RngGetBytes (RNGValueLength, RNGValue);
  return Status;
diff --git a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c 
b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c
index 421abb52b8bf..403b31b73609 100644
--- a/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c
+++ b/SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.c
@@ -21,6 +21,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

  #include 
  #include 
+#include 
  #include 
  #include 
  #include 
@@ -80,7 +81,12 @@ RngDriverEntry (
//
// Get the list of available algorithm.
//
-  return GetAvailableAlgorithms ();
+  Status = GetAvailableAlgorithms ();
+  if (mAvailableAlgoArrayCount == 0) {
+DEBUG ((DEBUG_WARN, "No Rng algorithm found in RngDxe.\n"));
+  }
+
+  return Status;
  }

  /**
--
2.25.1




Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96356): https://edk2.groups.io/g/devel/message/96356
Mute This Topic: https://groups.io/mt/95025606/5717338
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ardb+tianoc...@kernel.org]






-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96389): https://edk2.groups.io/g/devel/message/96389
Mute This Topic: https://groups.io/mt/95025606/21656
Group