Re: [edk2-devel] [PATCH v10 4/5] MdePkg: Utilize Cache Management Operations Implementation For RISC-V

2023-12-18 Thread Dhaval Sharma
Thanks. Just to clarify, In the earlier formatting
"InvalidateDataCacheRange:\
> +   Zicbom not supported.\n" \
A missing " after *Range:\ was causing slightly skewed prints. After adding
this " it looks okay. So that is one change I had addressed.
But if keeping it in a single line works better please feel free to update.
And Thanks!


On Tue, Dec 19, 2023 at 12:59 PM Sunil V L  wrote:

> On Wed, Dec 13, 2023 at 08:29:30PM +0530, Dhaval Sharma wrote:
> > Use newly defined cache management operations for RISC-V where possible
> > It builds up on the support added for RISC-V cache management
> > instructions in BaseLib.
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Cc: Laszlo Ersek 
> > Cc: Pedro Falcato 
> >
> > Signed-off-by: Dhaval Sharma 
> > Acked-by: Laszlo Ersek 
> > Reviewed-by: Pedro Falcato 
> > ---
> >
> > Notes:
> > V10:
> > - Fix formatting to keep comments within 80
> > - Replace RV with RISC-V
> > - Fix an issue with multi line comments
> > - Added assert to an unsupported function
> > - Minor case modification in str in .uni
> >
> > V9:
> > - Fixed an issue with Instruction cache invalidation. Use fence.i
> >   instruction as CMO does not support i-cache operations.
> > V8:
> > - Added note to convert PCD into RISC-V feature bitmap pointer
> > - Modified function names to be more explicit about cache ops
> > - Added RB tag
> > V7:
> > - Added PcdLib
> > - Restructure DEBUG message based on feedback on V6
> > - Make naming consistent to CMO, remove all CBO references
> > - Add ASSERT for not supported functions instead of plain debug
> message
> > - Added RB tag
> > V6:
> > - Utilize cache management instructions if HW supports it
> >   This patch is part of restructuring on top of v5
> >
> >  MdePkg/MdePkg.dec  |
>  8 +
> >  MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf |
>  5 +
> >  MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c|
> 177 
> >  MdePkg/MdePkg.uni  |
>  4 +
> >  4 files changed, 166 insertions(+), 28 deletions(-)
> >
> > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> > index ac54338089e8..fa92673ff633 100644
> > --- a/MdePkg/MdePkg.dec
> > +++ b/MdePkg/MdePkg.dec
> > @@ -2399,6 +2399,14 @@ [PcdsFixedAtBuild.AARCH64,
> PcdsPatchableInModule.AARCH64]
> ># @Prompt CPU Rng algorithm's GUID.
> >
> gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x0037
> >
> > +[PcdsFixedAtBuild.RISCV64, PcdsPatchableInModule.RISCV64]
> > +  #
> > +  # Configurability to override RISC-V CPU Features
> > +  # BIT 0 = Cache Management Operations. This bit is relevant only if
> > +  # previous stage has feature enabled and user wants to disable it.
> > +  #
> > +
> gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0x|UINT64|0x69
> > +
> >  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
> >## This value is used to set the base address of PCI express
> hierarchy.
> ># @Prompt PCI Express Base Address.
> > diff --git
> a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > index 6fd9cbe5f6c9..601a38d6c109 100644
> > --- a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > +++ b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> > @@ -56,3 +56,8 @@ [LibraryClasses]
> >BaseLib
> >DebugLib
> >
> > +[LibraryClasses.RISCV64]
> > +  PcdLib
> > +
> > +[Pcd.RISCV64]
> > +  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride  ## CONSUMES
> > diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > index ac2a3c23a249..7c53a17abbb5 100644
> > --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > @@ -2,6 +2,7 @@
> >RISC-V specific functionality for cache.
> >
> >Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
> rights reserved.
> > +  Copyright (c) 2023, Rivos Inc. All rights reserved.
> >
> >SPDX-License-Identifier: BSD-2-Clause-Patent
> >  **/
> > @@ -9,10 +10,116 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> > +
> > +//
> > +// TODO: Grab cache block size and make Cache Management Operation
> > +// enabling decision based on RISC-V CPU HOB in
> > +// future when it is available and convert PcdRiscVFeatureOverride
> > +// PCD to a pointer that contains pointer to bitmap structure
> > +// which can be operated more elegantly.
> > +//
> > +#define RISCV_CACHE_BLOCK_SIZE 64
> > +#define RISCV_CPU_FEATURE_CMO_BITMASK  0x1
> > +
> > +typedef enum {
> > +  CacheOpClean,
> > +  

Re: [edk2-devel] [PATCH] BaseTools: FMMT GuidTool Auto Select Config file Enabling

2023-12-18 Thread Guo, Gua
Hi @Gao, Liming and @Rebecca Cran

I may need to get your help for review it, any concern you can also share for 
us.

Thanks,
Gua

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Yuwei Chen
Sent: Friday, December 15, 2023 5:12 PM
To: devel@edk2.groups.io
Cc: Rebecca Cran ; Gao, Liming ; 
Feng, Bob C 
Subject: [edk2-devel] [PATCH] BaseTools: FMMT GuidTool Auto Select Config file 
Enabling

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

Currently, Python FMMT tool does not support automatically select FMMTConf.ini 
file which saves GuidTool settings.
This patch supports this features.

Cc: Rebecca Cran 
Cc: Liming Gao 
Cc: Bob Feng 

Signed-off-by: Yuwei Chen 
---
 BaseTools/Source/Python/FMMT/core/GuidTools.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/FMMT/core/GuidTools.py 
b/BaseTools/Source/Python/FMMT/core/GuidTools.py
index a25681709b..f6bdeffa50 100644
--- a/BaseTools/Source/Python/FMMT/core/GuidTools.py
+++ b/BaseTools/Source/Python/FMMT/core/GuidTools.py
@@ -110,7 +110,7 @@ class GUIDTools:
 if os.environ['FmmtConfPath']: self.tooldef_file = 
os.path.join(os.environ['FmmtConfPath'], 'FmmtConf.ini') else:- 
   PathList = os.environ['PATH']+PathList = 
os.environ['PATH'].split(os.pathsep) for CurrentPath in PathList:   
  if os.path.exists(os.path.join(CurrentPath, 'FmmtConf.ini')): 
self.tooldef_file = os.path.join(CurrentPath, 'FmmtConf.ini')-- 
2.42.0.windows.2



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112587): https://edk2.groups.io/g/devel/message/112587
Mute This Topic: https://groups.io/mt/103187642/6998960
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [gua@intel.com] 
-=-=-=-=-=-=




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




Re: [edk2-devel] [PATCH v10 5/5] OvmfPkg/RiscVVirt: Override for RISC-V CPU Features

2023-12-18 Thread Sunil V L
On Wed, Dec 13, 2023 at 08:29:31PM +0530, Dhaval wrote:
> This PCD provides a way for platform to override any
> HW features that are default enabled by previous stages
> of FW (like OpenSBI). For the case where previous/prev
> stage has disabled the feature, this override is not
> useful and its usage should be avoided.
> 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Gerd Hoffmann 
> Cc: Sunil V L 
> Cc: Andrei Warkentin 
> Cc: Laszlo Ersek 
> Cc: Pedro Falcato 
> 
> Signed-off-by: Dhaval Sharma 
> Acked-by: Laszlo Ersek 
> Reviewed-by: Andrei Warkentin 
> ---
> 
> Notes:
> V10:
> - Only keep CMO feature bitmask bit to disabled. Unimplemented bits
>   remain 1.
> V8:
> - Added RV tag
> V7:
> - Added RB tag
> v6:
> - Modify PCD name according to changes made in Baselib implementation
> V5:
> - Introduce PCD for platform
> 
>  OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc 
> b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> index fe320525153f..a050f1ffc1d4 100644
> --- a/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> +++ b/OvmfPkg/RiscVVirt/RiscVVirt.dsc.inc
> @@ -203,6 +203,7 @@ [PcdsFeatureFlag]
>gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
>  
>  [PcdsFixedAtBuild.common]
> +  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0xFFFE
This needs to be a 64-bit value. Again, I will fix it before merging.

Reviewed-by: Sunil V L 


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




Re: [edk2-devel] [PATCH v10 4/5] MdePkg: Utilize Cache Management Operations Implementation For RISC-V

2023-12-18 Thread Sunil V L
On Wed, Dec 13, 2023 at 08:29:30PM +0530, Dhaval Sharma wrote:
> Use newly defined cache management operations for RISC-V where possible
> It builds up on the support added for RISC-V cache management
> instructions in BaseLib.
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Cc: Zhiguang Liu 
> Cc: Laszlo Ersek 
> Cc: Pedro Falcato 
> 
> Signed-off-by: Dhaval Sharma 
> Acked-by: Laszlo Ersek 
> Reviewed-by: Pedro Falcato 
> ---
> 
> Notes:
> V10:
> - Fix formatting to keep comments within 80
> - Replace RV with RISC-V
> - Fix an issue with multi line comments
> - Added assert to an unsupported function
> - Minor case modification in str in .uni
> 
> V9:
> - Fixed an issue with Instruction cache invalidation. Use fence.i
>   instruction as CMO does not support i-cache operations.
> V8:
> - Added note to convert PCD into RISC-V feature bitmap pointer
> - Modified function names to be more explicit about cache ops
> - Added RB tag
> V7:
> - Added PcdLib
> - Restructure DEBUG message based on feedback on V6
> - Make naming consistent to CMO, remove all CBO references
> - Add ASSERT for not supported functions instead of plain debug message
> - Added RB tag
> V6:
> - Utilize cache management instructions if HW supports it
>   This patch is part of restructuring on top of v5
> 
>  MdePkg/MdePkg.dec  |   8 +
>  MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf |   5 +
>  MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c| 177 
> 
>  MdePkg/MdePkg.uni  |   4 +
>  4 files changed, 166 insertions(+), 28 deletions(-)
> 
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index ac54338089e8..fa92673ff633 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -2399,6 +2399,14 @@ [PcdsFixedAtBuild.AARCH64, 
> PcdsPatchableInModule.AARCH64]
># @Prompt CPU Rng algorithm's GUID.
>
> gEfiMdePkgTokenSpaceGuid.PcdCpuRngSupportedAlgorithm|{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}|VOID*|0x0037
>  
> +[PcdsFixedAtBuild.RISCV64, PcdsPatchableInModule.RISCV64]
> +  #
> +  # Configurability to override RISC-V CPU Features
> +  # BIT 0 = Cache Management Operations. This bit is relevant only if
> +  # previous stage has feature enabled and user wants to disable it.
> +  #
> +  
> gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride|0x|UINT64|0x69
> +
>  [PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
>## This value is used to set the base address of PCI express hierarchy.
># @Prompt PCI Express Base Address.
> diff --git 
> a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf 
> b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> index 6fd9cbe5f6c9..601a38d6c109 100644
> --- a/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
> @@ -56,3 +56,8 @@ [LibraryClasses]
>BaseLib
>DebugLib
>  
> +[LibraryClasses.RISCV64]
> +  PcdLib
> +
> +[Pcd.RISCV64]
> +  gEfiMdePkgTokenSpaceGuid.PcdRiscVFeatureOverride  ## CONSUMES
> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c 
> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> index ac2a3c23a249..7c53a17abbb5 100644
> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> @@ -2,6 +2,7 @@
>RISC-V specific functionality for cache.
>  
>Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All rights 
> reserved.
> +  Copyright (c) 2023, Rivos Inc. All rights reserved.
>  
>SPDX-License-Identifier: BSD-2-Clause-Patent
>  **/
> @@ -9,10 +10,116 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +
> +//
> +// TODO: Grab cache block size and make Cache Management Operation
> +// enabling decision based on RISC-V CPU HOB in
> +// future when it is available and convert PcdRiscVFeatureOverride
> +// PCD to a pointer that contains pointer to bitmap structure
> +// which can be operated more elegantly.
> +//
> +#define RISCV_CACHE_BLOCK_SIZE 64
> +#define RISCV_CPU_FEATURE_CMO_BITMASK  0x1
> +
> +typedef enum {
> +  CacheOpClean,
> +  CacheOpFlush,
> +  CacheOpInvld,
> +} CACHE_OP;
> +
> +/**
> +Verify CBOs are supported by this HW
> +TODO: Use RISC-V CPU HOB once available.
> +
> +**/
> +STATIC
> +BOOLEAN
> +RiscVIsCMOEnabled (
> +  VOID
> +  )
> +{
> +  // If CMO is disabled in HW, skip Override check
> +  // Otherwise this PCD can override settings
> +  return ((PcdGet64 (PcdRiscVFeatureOverride) & 
> RISCV_CPU_FEATURE_CMO_BITMASK) != 0);
> +}
> +
> +/**
> +  Performs required opeartion on cache lines in the cache coherency domain
> +  of the calling CPU. If Address is not aligned on a cache line boundary,
> +  then 

[edk2-devel] [PATCH v5 8/8] UefiCpuPkg/PiSmmCpuDxeSmm: Consume SmmCpuSyncLib

2023-12-18 Thread Wu, Jiaxin
There is the SmmCpuSyncLib Library class define the SMM CPU sync
flow, which is aligned with existing SMM CPU driver sync behavior.
This patch is to consume SmmCpuSyncLib instance directly.

With this change, SMM CPU Sync flow/logic can be customized
with different implementation no matter for any purpose, e.g.
performance tuning, handle specific register, etc.

Cc: Laszlo Ersek 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c| 274 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h   |   6 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |   1 +
 3 files changed, 68 insertions(+), 213 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 9b477b6695..4fbb0bba87 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -27,122 +27,10 @@ MM_COMPLETIONmSmmStartupThisApToken;
 //
 // Processor specified by mPackageFirstThreadIndex[PackageIndex] will do the 
package-scope register check.
 //
 UINT32  *mPackageFirstThreadIndex = NULL;
 
-/**
-  Performs an atomic compare exchange operation to get semaphore.
-  The compare exchange operation must be performed using
-  MP safe mechanisms.
-
-  @param  SemIN:  32-bit unsigned integer
- OUT: original integer - 1
-  @return Original integer - 1
-
-**/
-UINT32
-WaitForSemaphore (
-  IN OUT  volatile UINT32  *Sem
-  )
-{
-  UINT32  Value;
-
-  for ( ; ;) {
-Value = *Sem;
-if ((Value != 0) &&
-(InterlockedCompareExchange32 (
-   (UINT32 *)Sem,
-   Value,
-   Value - 1
-   ) == Value))
-{
-  break;
-}
-
-CpuPause ();
-  }
-
-  return Value - 1;
-}
-
-/**
-  Performs an atomic compare exchange operation to release semaphore.
-  The compare exchange operation must be performed using
-  MP safe mechanisms.
-
-  @param  SemIN:  32-bit unsigned integer
- OUT: original integer + 1
-  @return Original integer + 1
-
-**/
-UINT32
-ReleaseSemaphore (
-  IN OUT  volatile UINT32  *Sem
-  )
-{
-  UINT32  Value;
-
-  do {
-Value = *Sem;
-  } while (Value + 1 != 0 &&
-   InterlockedCompareExchange32 (
- (UINT32 *)Sem,
- Value,
- Value + 1
- ) != Value);
-
-  return Value + 1;
-}
-
-/**
-  Performs an atomic compare exchange operation to lock semaphore.
-  The compare exchange operation must be performed using
-  MP safe mechanisms.
-
-  @param  SemIN:  32-bit unsigned integer
- OUT: -1
-  @return Original integer
-
-**/
-UINT32
-LockdownSemaphore (
-  IN OUT  volatile UINT32  *Sem
-  )
-{
-  UINT32  Value;
-
-  do {
-Value = *Sem;
-  } while (InterlockedCompareExchange32 (
- (UINT32 *)Sem,
- Value,
- (UINT32)-1
- ) != Value);
-
-  return Value;
-}
-
-/**
-  Used for BSP to wait all APs.
-  Wait all APs to performs an atomic compare exchange operation to release 
semaphore.
-
-  @param   NumberOfAPs  AP number
-
-**/
-VOID
-WaitForAllAPs (
-  IN  UINTN  NumberOfAPs
-  )
-{
-  UINTN  BspIndex;
-
-  BspIndex = mSmmMpSyncData->BspIndex;
-  while (NumberOfAPs-- > 0) {
-WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
-  }
-}
-
 /**
   Used for BSP to release all APs.
   Performs an atomic compare exchange operation to release semaphore
   for each AP.
 
@@ -154,57 +42,15 @@ ReleaseAllAPs (
 {
   UINTN  Index;
 
   for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
 if (IsPresentAp (Index)) {
-  ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);
+  SmmCpuSyncReleaseOneAp (mSmmMpSyncData->SyncContext, Index, 
gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu);
 }
   }
 }
 
-/**
-  Used for BSP to release one AP.
-
-  @param  ApSem IN:  32-bit unsigned integer
-OUT: original integer + 1
-**/
-VOID
-ReleaseOneAp   (
-  IN OUT  volatile UINT32  *ApSem
-  )
-{
-  ReleaseSemaphore (ApSem);
-}
-
-/**
-  Used for AP to wait BSP.
-
-  @param  ApSem  IN:  32-bit unsigned integer
- OUT: original integer - 1
-**/
-VOID
-WaitForBsp  (
-  IN OUT  volatile UINT32  *ApSem
-  )
-{
-  WaitForSemaphore (ApSem);
-}
-
-/**
-  Used for AP to release BSP.
-
-  @param  BspSem IN:  32-bit unsigned integer
- OUT: original integer + 1
-**/
-VOID
-ReleaseBsp   (
-  IN OUT  volatile UINT32  *BspSem
-  )
-{
-  ReleaseSemaphore (BspSem);
-}
-
 /**
   Check whether the index of CPU perform the package level register
   programming during System Management Mode initialization.
 
   The index of Processor specified by mPackageFirstThreadIndex[PackageIndex]
@@ -292,35 +138,35 @@ AllCpusInSmmExceptBlockedDisabled (
 
   BlockedCount  

[edk2-devel] [PATCH v5 7/8] UefiCpuPkg/PiSmmCpuDxeSmm: Simplify RunningApCount decrement

2023-12-18 Thread Wu, Jiaxin
To decrease the count of RunningApCount, InterlockedDecrement is
enough to achieve that.

This patch is to simplify RunningApCount decrement.

Cc: Laszlo Ersek 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 54542262a2..9b477b6695 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1450,11 +1450,11 @@ InternalSmmStartupAllAPs (
 
   //
   // Decrease the count to mark this processor(AP or BSP) as finished.
   //
   if (ProcToken != NULL) {
-WaitForSemaphore (>RunningApCount);
+InterlockedDecrement (>RunningApCount);
   }
 }
   }
 
   ReleaseAllAPs ();
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v5 6/8] UefiPayloadPkg: Specifies SmmCpuSyncLib instance

2023-12-18 Thread Wu, Jiaxin
This patch is to specify SmmCpuSyncLib instance for UefiPayloadPkg.

Cc: Laszlo Ersek 
Cc: Guo Dong 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 
Cc: Ray Ni 
Cc: Zeng Star 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Gua Guo 
Reviewed-by: Ray Ni 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index a65f9d5b83..b8b13ad201 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -253,10 +253,11 @@
   #
   MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
   LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.inf
   MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
   CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
+  SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
 
   #
   # Platform
   #
 !if $(CPU_TIMER_LIB_ENABLE) == TRUE && $(UNIVERSAL_PAYLOAD) == TRUE
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v5 5/8] OvmfPkg: Specifies SmmCpuSyncLib instance

2023-12-18 Thread Wu, Jiaxin
This patch is to specify SmmCpuSyncLib instance for OvmfPkg.

Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Ray Ni 
---
 OvmfPkg/CloudHv/CloudHvX64.dsc | 1 +
 OvmfPkg/OvmfPkgIa32.dsc| 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc | 1 +
 4 files changed, 4 insertions(+)

diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 1660548e07..af594959a9 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -907,10 +907,11 @@
   }
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
   }
 
   #
   # Variable driver stack (SMM)
   #
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 6e8488007c..28379961a7 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -952,10 +952,11 @@
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
   }
 
   #
   # Variable driver stack (SMM)
   #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 413ea71984..5e9eee628a 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -970,10 +970,11 @@
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
   }
 
   #
   # Variable driver stack (SMM)
   #
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index f92d70..bf4c7906c4 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -1040,10 +1040,11 @@
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
   MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
   }
 
   #
   # Variable driver stack (SMM)
   #
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v5 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-18 Thread Wu, Jiaxin
Implements SmmCpuSyncLib Library instance. The instance refers the
existing SMM CPU driver (PiSmmCpuDxeSmm) sync implementation
and behavior:
1.Abstract Counter and Run semaphores into SmmCpuSyncCtx.
2.Abstract CPU arrival count operation to
SmmCpuSyncGetArrivedCpuCount(), SmmCpuSyncCheckInCpu(),
SmmCpuSyncCheckOutCpu(), SmmCpuSyncLockDoor().
Implementation is aligned with existing SMM CPU driver.
3. Abstract SMM CPU Sync flow to:
BSP: SmmCpuSyncReleaseOneAp  -->  AP: SmmCpuSyncWaitForBsp
BSP: SmmCpuSyncWaitForAPs<--  AP: SmmCpuSyncReleaseBsp
Semaphores release & wait during sync flow is same as existing SMM
CPU driver.
4.Same operation to Counter and Run semaphores by leverage the atomic
compare exchange.

Cc: Laszlo Ersek 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
---
 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c   | 652 +
 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf |  34 ++
 UefiCpuPkg/UefiCpuPkg.dsc  |   2 +
 3 files changed, 688 insertions(+)
 create mode 100644 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
 create mode 100644 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf

diff --git a/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c 
b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
new file mode 100644
index 00..d517d4b706
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
@@ -0,0 +1,652 @@
+/** @file
+  SMM CPU Sync lib implementation.
+
+  The lib provides 3 sets of APIs:
+  1. ContextInit/ContextDeinit/ContextReset:
+
+ContextInit() is called in driver's entrypoint to allocate and initialize 
the SMM CPU Sync context.
+ContextDeinit() is called in driver's unload function to deinitialize the 
SMM CPU Sync context.
+ContextReset() is called by one of CPUs after all CPUs are ready to exit 
SMI, which allows CPU to
+check into the next SMI from this point.
+
+  2. GetArrivedCpuCount/CheckInCpu/CheckOutCpu/LockDoor:
+When SMI happens, all processors including BSP enter to SMM mode by 
calling CheckInCpu().
+CheckOutCpu() can be called in error handling flow for the CPU who calls 
CheckInCpu() earlier.
+The elected BSP calls LockDoor() so that CheckInCpu() and CheckOutCpu() 
will return the error code after that.
+GetArrivedCpuCount() returns the number of checked-in CPUs.
+
+  3. WaitForAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
+WaitForAPs() & ReleaseOneAp() are called from BSP to wait the number of 
APs and release one specific AP.
+WaitForBsp() & ReleaseBsp() are called from APs to wait and release BSP.
+The 4 APIs are used to synchronize the running flow among BSP and APs.
+BSP and AP Sync flow can be easy understand as below:
+BSP: ReleaseOneAp  -->  AP: WaitForBsp
+BSP: WaitForAPs<--  AP: ReleaseBsp
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+///
+/// The implementation shall place one semaphore on exclusive cache line for 
good performance.
+///
+typedef volatile UINT32 SMM_CPU_SYNC_SEMAPHORE;
+
+typedef struct {
+  ///
+  /// Used for control each CPU continue run or wait for signal
+  ///
+  SMM_CPU_SYNC_SEMAPHORE*Run;
+} SMM_CPU_SYNC_SEMAPHORE_FOR_EACH_CPU;
+
+struct SMM_CPU_SYNC_CONTEXT  {
+  ///
+  /// Indicate all CPUs in the system.
+  ///
+  UINTN  NumberOfCpus;
+  ///
+  /// Address of semaphores.
+  ///
+  VOID   *SemBuffer;
+  ///
+  /// Size of semaphores.
+  ///
+  UINTN  SemBufferPages;
+  ///
+  /// Before the door is locked, CpuCount stores the arrived CPU count.
+  /// After the door is locked, CpuCount is set to -1 indicating the door is 
locked.
+  /// ArrivedCpuCountUponLock stores the arrived CPU count then.
+  ///
+  UINTN  ArrivedCpuCountUponLock;
+  ///
+  /// Indicate CPUs entered SMM before lock door.
+  ///
+  SMM_CPU_SYNC_SEMAPHORE *CpuCount;
+  ///
+  /// Define an array of structure for each CPU semaphore due to the size 
alignment
+  /// requirement. With the array of structure for each CPU semaphore, it's 
easy to
+  /// reach the specific CPU with CPU Index for its own semaphore access: 
CpuSem[CpuIndex].
+  ///
+  SMM_CPU_SYNC_SEMAPHORE_FOR_EACH_CPUCpuSem[];
+};
+
+/**
+  Performs an atomic compare exchange operation to get semaphore.
+  The compare exchange operation must be performed using MP safe
+  mechanisms.
+
+  @param[in,out]  SemIN:  32-bit unsigned integer
+ OUT: original integer - 1 if Sem is not locked.
+ OUT: MAX_UINT32 if Sem is locked.
+
+  @retval Original integer - 1 if Sem is not locked.
+  MAX_UINT32 if Sem is locked.
+
+**/
+STATIC
+UINT32

[edk2-devel] [PATCH v5 3/8] MdePkg/MdeLibs.dsc.inc: Add SafeIntLib instance

2023-12-18 Thread Wu, Jiaxin
This patch is to add SafeIntLib in MdeLibs.dsc.inc

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Laszlo Ersek 
Cc: Ray Ni 
Cc: Zeng Star 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Michael D Kinney 
---
 MdePkg/MdeLibs.dsc.inc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdePkg/MdeLibs.dsc.inc b/MdePkg/MdeLibs.dsc.inc
index 4580481cb5..deb35c1a18 100644
--- a/MdePkg/MdeLibs.dsc.inc
+++ b/MdePkg/MdeLibs.dsc.inc
@@ -14,5 +14,6 @@
 [LibraryClasses]
   ArmTrngLib|MdePkg/Library/BaseArmTrngLibNull/BaseArmTrngLibNull.inf
   
RegisterFilterLib|MdePkg/Library/RegisterFilterLibNull/RegisterFilterLibNull.inf
   CpuLib|MdePkg/Library/BaseCpuLib/BaseCpuLib.inf
   
SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf
+  SafeIntLib|MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf
-- 
2.16.2.windows.1



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




[edk2-devel] [PATCH v5 2/8] UefiCpuPkg: Adds SmmCpuSyncLib library class

2023-12-18 Thread Wu, Jiaxin
Intel is planning to provide different SMM CPU Sync implementation
along with some specific registers to improve the SMI performance,
hence need SmmCpuSyncLib Library for Intel.

This patch is to:
1.Adds SmmCpuSyncLib Library class in UefiCpuPkg.dec.
2.Adds SmmCpuSyncLib.h function declaration header file.

For the new SmmCpuSyncLib, it provides 3 sets of APIs:

1. ContextInit/ContextDeinit/ContextReset:
ContextInit() is called in driver's entrypoint to allocate and
initialize the SMM CPU Sync context. ContextDeinit() is called in
driver's unload function to deinitialize SMM CPU Sync context.
ContextReset() is called before CPU exist SMI, which allows CPU to
check into the next SMI from this point.

2. GetArrivedCpuCount/CheckInCpu/CheckOutCpu/LockDoor:
When SMI happens, all processors including BSP enter to SMM mode by
calling CheckInCpu(). The elected BSP calls LockDoor() so that
CheckInCpu() will return the error code after that. CheckOutCpu() can
be called in error handling flow for the CPU who calls CheckInCpu()
earlier. GetArrivedCpuCount() returns the number of checked-in CPUs.

3. WaitForAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
WaitForAPs() & ReleaseOneAp() are called from BSP to wait the number
of APs and release one specific AP. WaitForBsp() & ReleaseBsp() are
called from APs to wait and release BSP. The 4 APIs are used to
synchronize the running flow among BSP and APs. BSP and AP Sync flow
can be easy understand as below:
BSP: ReleaseOneAp  -->  AP: WaitForBsp
BSP: WaitForAPs<--  AP: ReleaseBsp

Cc: Laszlo Ersek 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Gerd Hoffmann 
Cc: Rahul Kumar 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/Include/Library/SmmCpuSyncLib.h | 290 +
 UefiCpuPkg/UefiCpuPkg.dec  |   3 +
 2 files changed, 293 insertions(+)
 create mode 100644 UefiCpuPkg/Include/Library/SmmCpuSyncLib.h

diff --git a/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h 
b/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
new file mode 100644
index 00..4d273095c9
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
@@ -0,0 +1,290 @@
+/** @file
+  Library that provides SMM CPU Sync related operations.
+
+  The lib provides 3 sets of APIs:
+  1. ContextInit/ContextDeinit/ContextReset:
+
+ContextInit() is called in driver's entrypoint to allocate and initialize 
the SMM CPU Sync context.
+ContextDeinit() is called in driver's unload function to deinitialize the 
SMM CPU Sync context.
+ContextReset() is called by one of CPUs after all CPUs are ready to exit 
SMI, which allows CPU to
+check into the next SMI from this point.
+
+  2. GetArrivedCpuCount/CheckInCpu/CheckOutCpu/LockDoor:
+When SMI happens, all processors including BSP enter to SMM mode by 
calling CheckInCpu().
+CheckOutCpu() can be called in error handling flow for the CPU who calls 
CheckInCpu() earlier.
+The elected BSP calls LockDoor() so that CheckInCpu() and CheckOutCpu() 
will return the error code after that.
+GetArrivedCpuCount() returns the number of checked-in CPUs.
+
+  3. WaitForAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
+WaitForAPs() & ReleaseOneAp() are called from BSP to wait the number of 
APs and release one specific AP.
+WaitForBsp() & ReleaseBsp() are called from APs to wait and release BSP.
+The 4 APIs are used to synchronize the running flow among BSP and APs.
+BSP and AP Sync flow can be easy understand as below:
+BSP: ReleaseOneAp  -->  AP: WaitForBsp
+BSP: WaitForAPs<--  AP: ReleaseBsp
+
+  Copyright (c) 2023, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef SMM_CPU_SYNC_LIB_H_
+#define SMM_CPU_SYNC_LIB_H_
+
+#include 
+
+//
+// Opaque structure for SMM CPU Sync context.
+//
+typedef struct SMM_CPU_SYNC_CONTEXT SMM_CPU_SYNC_CONTEXT;
+
+/**
+  Create and initialize the SMM CPU Sync context. It is to allocate and 
initialize the
+  SMM CPU Sync context.
+
+  If Context is NULL, then ASSERT().
+
+  @param[in]  NumberOfCpus  The number of Logical Processors in the 
system.
+  @param[out] Context   Pointer to the new created and initialized 
SMM CPU Sync context object.
+NULL will be returned if any error happen 
during init.
+
+  @retval RETURN_SUCCESSThe SMM CPU Sync context was successful 
created and initialized.
+  @retval RETURN_OUT_OF_RESOURCES   There are not enough resources available 
to create and initialize SMM CPU Sync context.
+  @retval RETURN_BUFFER_TOO_SMALL   Overflow happen
+
+**/
+RETURN_STATUS
+EFIAPI
+SmmCpuSyncContextInit (
+  IN   UINTN NumberOfCpus,
+  OUT  SMM_CPU_SYNC_CONTEXT  **Context
+  );
+
+/**
+  Deinit an allocated SMM CPU Sync context. The resources allocated in 
SmmCpuSyncContextInit() will
+  be freed.
+
+  If Context is NULL, then ASSERT().
+
+  @param[in,out]  Context Pointer to the SMM CPU Sync context object to be 

[edk2-devel] [PATCH v5 1/8] UefiCpuPkg/PiSmmCpuDxeSmm: Optimize Semaphore Sync between BSP and AP

2023-12-18 Thread Wu, Jiaxin
This patch is to define 3 new functions (WaitForBsp & ReleaseBsp &
ReleaseOneAp) used for the semaphore sync between BSP & AP. With the
change, BSP and AP Sync flow will be easy understand as below:
BSP: ReleaseAllAPs or ReleaseOneAp --> AP: WaitForBsp
BSP: WaitForAllAPs <-- AP: ReleaseBsp

Cc: Laszlo Ersek 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Zeng Star 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Jiaxin Wu 
Reviewed-by: Laszlo Ersek 
Reviewed-by: Ray Ni 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 72 ---
 1 file changed, 58 insertions(+), 14 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c 
b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index b279f5dfcc..54542262a2 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -120,10 +120,11 @@ LockdownSemaphore (
 
   return Value;
 }
 
 /**
+  Used for BSP to wait all APs.
   Wait all APs to performs an atomic compare exchange operation to release 
semaphore.
 
   @param   NumberOfAPs  AP number
 
 **/
@@ -139,10 +140,11 @@ WaitForAllAPs (
 WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
   }
 }
 
 /**
+  Used for BSP to release all APs.
   Performs an atomic compare exchange operation to release semaphore
   for each AP.
 
 **/
 VOID
@@ -157,10 +159,52 @@ ReleaseAllAPs (
   ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);
 }
   }
 }
 
+/**
+  Used for BSP to release one AP.
+
+  @param  ApSem IN:  32-bit unsigned integer
+OUT: original integer + 1
+**/
+VOID
+ReleaseOneAp   (
+  IN OUT  volatile UINT32  *ApSem
+  )
+{
+  ReleaseSemaphore (ApSem);
+}
+
+/**
+  Used for AP to wait BSP.
+
+  @param  ApSem  IN:  32-bit unsigned integer
+ OUT: original integer - 1
+**/
+VOID
+WaitForBsp  (
+  IN OUT  volatile UINT32  *ApSem
+  )
+{
+  WaitForSemaphore (ApSem);
+}
+
+/**
+  Used for AP to release BSP.
+
+  @param  BspSem IN:  32-bit unsigned integer
+ OUT: original integer + 1
+**/
+VOID
+ReleaseBsp   (
+  IN OUT  volatile UINT32  *BspSem
+  )
+{
+  ReleaseSemaphore (BspSem);
+}
+
 /**
   Check whether the index of CPU perform the package level register
   programming during System Management Mode initialization.
 
   The index of Processor specified by mPackageFirstThreadIndex[PackageIndex]
@@ -632,11 +676,11 @@ BSPHandler (
   // Signal all APs it's time for backup MTRRs
   //
   ReleaseAllAPs ();
 
   //
-  // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at
+  // WaitForAllAPs() may wait for ever if an AP happens to enter SMM at
   // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been 
set
   // to a large enough value to avoid this situation.
   // Note: For HT capable CPUs, threads within a core share the same set 
of MTRRs.
   // We do the backup first and then set MTRR to avoid race condition for 
threads
   // in the same core.
@@ -652,11 +696,11 @@ BSPHandler (
   // Let all processors program SMM MTRRs together
   //
   ReleaseAllAPs ();
 
   //
-  // WaitForSemaphore() may wait for ever if an AP happens to enter SMM at
+  // WaitForAllAPs() may wait for ever if an AP happens to enter SMM at
   // exactly this point. Please make sure PcdCpuSmmMaxSyncLoops has been 
set
   // to a large enough value to avoid this situation.
   //
   ReplaceOSMtrrs (CpuIndex);
 
@@ -898,50 +942,50 @@ APHandler (
 
   if ((SyncMode == SmmCpuSyncModeTradition) || 
SmmCpuFeaturesNeedConfigureMtrrs ()) {
 //
 // Notify BSP of arrival at this point
 //
-ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
+ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run);
   }
 
   if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
 //
 // Wait for the signal from BSP to backup MTRRs
 //
-WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run);
+WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run);
 
 //
 // Backup OS MTRRs
 //
 MtrrGetAllMtrrs ();
 
 //
 // Signal BSP the completion of this AP
 //
-ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
+ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run);
 
 //
 // Wait for BSP's signal to program MTRRs
 //
-WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run);
+WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run);
 
 //
 // Replace OS MTRRs with SMI MTRRs
 //
 ReplaceOSMtrrs (CpuIndex);
 
 //
 // Signal BSP the completion of this AP
 //
-ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
+ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run);
   }
 
   while (TRUE) {
 //
 // Wait for something to happen
 //
-WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run);
+WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run);
 
 //
 // Check 

[edk2-devel] [PATCH v5 0/8] Refine SMM CPU Sync flow and abstract SmmCpuSyncLib

2023-12-18 Thread Wu, Jiaxin
The series patches are to refine SMM CPU Sync flow.
After the refinement, SmmCpuSyncLib is abstracted for
any user to provide different SMM CPU Sync implementation.

Jiaxin Wu (8):
  UefiCpuPkg/PiSmmCpuDxeSmm: Optimize Semaphore Sync between BSP and AP
  UefiCpuPkg: Adds SmmCpuSyncLib library class
  MdePkg/MdeLibs.dsc.inc: Add SafeIntLib instance
  UefiCpuPkg: Implements SmmCpuSyncLib library instance
  OvmfPkg: Specifies SmmCpuSyncLib instance
  UefiPayloadPkg: Specifies SmmCpuSyncLib instance
  UefiCpuPkg/PiSmmCpuDxeSmm: Simplify RunningApCount decrement
  UefiCpuPkg/PiSmmCpuDxeSmm: Consume SmmCpuSyncLib

 MdePkg/MdeLibs.dsc.inc |   1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc |   1 +
 OvmfPkg/OvmfPkgIa32.dsc|   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc |   1 +
 OvmfPkg/OvmfPkgX64.dsc |   1 +
 UefiCpuPkg/Include/Library/SmmCpuSyncLib.h | 290 +
 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c   | 652 +
 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf |  34 ++
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c  | 234 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h |   6 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf   |   1 +
 UefiCpuPkg/UefiCpuPkg.dec  |   3 +
 UefiCpuPkg/UefiCpuPkg.dsc  |   2 +
 UefiPayloadPkg/UefiPayloadPkg.dsc  |   1 +
 14 files changed, 1057 insertions(+), 171 deletions(-)
 create mode 100644 UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
 create mode 100644 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.c
 create mode 100644 UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf

-- 
2.16.2.windows.1



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




Re: [edk2-devel] [PATCH v4 12/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

2023-12-18 Thread Chao Li

Hi Ray,


Thanks,
Chao
On 2023/12/19 14:29, Ni, Ray wrote:

Plan B:
It only returns the attribute and length of the first part, leaving it up to 
the caller to decide to look for the next part.
I'm leaning toward plan B, what do you think?

I like plan B as well. Do you think that "EndAddress" can be removed from the 
param list?

Imaging from caller perspective, the code can be like follows:
BaseAddress = 0;
While (TRUE) {
   GetMemoryRegionAttributes (
 BaseAddress,
 ,
 
   );
   If (Length == 0) {
 Break;
   }
   // dump BaseAddress, Length, Attributes
   BaseAddress += Length;
}


Cool, one more question:

Do you mean the "Length" parameter will have both in/out properties?


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




Re: [edk2-devel] Clarification on LoadFile2 Protocol Installation for Network Boot Devices

2023-12-18 Thread Sivaraman Nainar via groups.io
Hello Saloni:

Thanks for Clarifying.

Yes. If Network Devices MUST install LoadFile2 then it would be good that 
section 18 includes network devices. Do we need to request UEFI forum for the 
same?

Thanks
Siva
From: Kasbekar, Saloni 
Sent: Tuesday, December 19, 2023 1:41 AM
To: devel@edk2.groups.io; Sivaraman Nainar ; 
Clark-williams, Zachary 
Cc: Natalya Kalistratova ; Dhanaraj V ; 
Santhosh Kumar V ; GengYou Zhou (周庚佑) 

Subject: [EXTERNAL] RE: Clarification on LoadFile2 Protocol Installation for 
Network Boot Devices


**CAUTION: The e-mail below is from an external source. Please exercise caution 
before opening attachments, clicking links, or following guidance.**
Hi Siva,

“The EFI_LOAD_FILE2_PROTOCOL is a simple protocol used to obtain files from 
arbitrary devices that are not boot
options”
“The EFI_LOAD_FILE_PROTOCOL is used for devices that do not directly support 
file systems. Network devices
commonly boot in this model where the image is materialized without the need of 
a file system.”

Based on the above statements, I believe the Network stack is fine using the 
current EFI_LOAD_FILE_PROTOCOL and not the EFI_LOAD_FILE2_PROTOCOL as they are 
currently loaded as boot options. We currently do install the 
EFI_LOAD_FILE_PROTOCOL within the Network stack. Eg -
  //
  // Create a child handle for the HTTP boot and install DevPath and Load file 
protocol on it.
  //
  CopyMem (>Ip6Nic->LoadFile, , sizeof 
(Private->LoadFile));
  Status = gBS->InstallMultipleProtocolInterfaces (
  >Ip6Nic->Controller,
  ,
  >Ip6Nic->LoadFile,
  ,
  Private->Ip6Nic->DevicePath,
  NULL
  );

Maybe we need to update #18 to include Network devices?

Thanks,
Saloni

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Sivaraman 
Nainar via groups.io
Sent: Friday, December 15, 2023 3:29 AM
To: devel@edk2.groups.io; Clark-williams, Zachary 
mailto:zachary.clark-willi...@intel.com>>; 
Kasbekar, Saloni mailto:saloni.kasbe...@intel.com>>
Cc: Natalya Kalistratova mailto:natal...@ami.com>>; Dhanaraj 
V mailto:vdhana...@ami.com>>; Santhosh Kumar V 
mailto:santhoshkum...@ami.com>>; GengYou Zhou (周庚佑) 
mailto:gengyouz...@ami.com>>
Subject: [edk2-devel] reg: Clarification on LoadFile2 Protocol Installation for 
Network Boot Devices

Hello ZClarkWilliams:

Could you please help to clarify if NetworkStack MUST install the LoadFile2 
Protocol or not. With reference to the below spec item, the LoadFile2 protocol 
must be implemented.

In one of the BIOS environment, the Setup Browser Locates the LoadFile2 
instance of Network Boot Device and it not found as it not installed by the 
current NetworkPkg.

Can you please comment if there is any reason behind not installing during the 
HTTP Boot.
“UEFI SPEC
2.6.3 Driver-Specific Elements There are a number of UEFI elements that can be 
added or removed depending on the features that a specific driver requires. 
Drivers can be implemented by platform firmware developers to support buses and 
devices in a specific platform. Drivers can also be implemented by add-in card 
vendors for devices that might be integrated into the platform hardware or 
added to a platform through an expansion slot. The following list includes 
possible driver features, and the UEFI elements that are required for each 
feature type:

  1.  If a driver is written for a boot device that is not a block-oriented 
device, a file system-based device, or a console device, then the 
EFI_LOAD_FILE2_PROTOCOL must be implemented.
“

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

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


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

Re: [edk2-devel] [PATCH v4 11/37] UefiCpuPkg: Add CPU exception library for LoongArch

2023-12-18 Thread Ni, Ray
Acked-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Chao Li 
> Sent: Tuesday, December 12, 2023 9:12 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Baoqi Zhang 
> Subject: [PATCH v4 11/37] UefiCpuPkg: Add CPU exception library for
> LoongArch
> 
> Added a new library named LoongArch64CpuExceptionHandlerLib, and
> modified the way LoongArch exceptions are expressed.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> ---
>  MdePkg/Include/Protocol/DebugSupport.h|  76 +++--
>  .../DxeCpuExceptionHandlerLib.inf |  45 +++
>  .../DxeCpuExceptionHandlerLib.uni |  15 +
>  .../DxeExceptionLib.c | 198 +++
>  .../ExceptionCommon.c | 170 ++
>  .../ExceptionCommon.h | 111 ++
>  .../LoongArch64/ArchExceptionHandler.c| 213 
>  .../LoongArch64/ExceptionHandlerAsm.S | 320
> ++
>  .../SecPeiCpuExceptionHandlerLib.inf  |  45 +++
>  .../SecPeiCpuExceptionHandlerLib.uni  |  15 +
>  .../SecPeiExceptionLib.c  |  88 +
>  UefiCpuPkg/UefiCpuPkg.dec |   6 +
>  UefiCpuPkg/UefiCpuPkg.dsc |   2 +
>  13 files changed, 1272 insertions(+), 32 deletions(-)
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/DxeCpuException
> HandlerLib.inf
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/DxeCpuException
> HandlerLib.uni
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/DxeExceptionLib.c
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/ExceptionCommon
> .c
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/ExceptionCommon
> .h
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/LoongArch64/Arch
> ExceptionHandler.c
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/LoongArch64/Exce
> ptionHandlerAsm.S
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/SecPeiCpuExcepti
> onHandlerLib.inf
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/SecPeiCpuExcepti
> onHandlerLib.uni
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64CpuExceptionHandlerLib/SecPeiExceptionLi
> b.c
> 
> diff --git a/MdePkg/Include/Protocol/DebugSupport.h
> b/MdePkg/Include/Protocol/DebugSupport.h
> index 9742663619..cc4828 100644
> --- a/MdePkg/Include/Protocol/DebugSupport.h
> +++ b/MdePkg/Include/Protocol/DebugSupport.h
> @@ -680,33 +680,45 @@ typedef struct {
>UINT32STVAL;
>  } EFI_SYSTEM_CONTEXT_RISCV64;
> 
> -//
> -// LoongArch processor exception types.
> -//
> -#define EXCEPT_LOONGARCH_INT   0
> -#define EXCEPT_LOONGARCH_PIL   1
> -#define EXCEPT_LOONGARCH_PIS   2
> -#define EXCEPT_LOONGARCH_PIF   3
> -#define EXCEPT_LOONGARCH_PME   4
> -#define EXCEPT_LOONGARCH_PNR   5
> -#define EXCEPT_LOONGARCH_PNX   6
> -#define EXCEPT_LOONGARCH_PPI   7
> -#define EXCEPT_LOONGARCH_ADE   8
> -#define EXCEPT_LOONGARCH_ALE   9
> -#define EXCEPT_LOONGARCH_BCE   10
> -#define EXCEPT_LOONGARCH_SYS   11
> -#define EXCEPT_LOONGARCH_BRK   12
> -#define EXCEPT_LOONGARCH_INE   13
> -#define EXCEPT_LOONGARCH_IPE   14
> -#define EXCEPT_LOONGARCH_FPD   15
> -#define EXCEPT_LOONGARCH_SXD   16
> -#define EXCEPT_LOONGARCH_ASXD  17
> -#define EXCEPT_LOONGARCH_FPE   18
> -#define EXCEPT_LOONGARCH_TBR   64 // For code only, there is no such
> type in the ISA spec, the TLB refill is defined for an independent exception.
> -
> -//
> -// LoongArch processor Interrupt types.
> -//
> +///
> +/// LoongArch processor exception types.
> +///
> +#define EXCEPT_LOONGARCH_ECODE_SHIFT  16
> +#define EXCEPT_LOONGARCH_INT  (0 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PIL  (1 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PIS  (2 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PIF  (3 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PME  (4 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PNR  (5 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PNX  (6 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_PPI  (7 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_ADE  (8 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_ALE  (9 <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_BCE  (10  <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_SYS  (11  <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define EXCEPT_LOONGARCH_BRK  (12  <<
> EXCEPT_LOONGARCH_ECODE_SHIFT)
> +#define 

Re: [edk2-devel] [PATCH v4 14/37] UefiCpuPkg: Add multiprocessor library for LoongArch64

2023-12-18 Thread Ni, Ray
Acked-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Chao Li 
> Sent: Tuesday, December 12, 2023 9:12 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann 
> Subject: [PATCH v4 14/37] UefiCpuPkg: Add multiprocessor library for
> LoongArch64
> 
> Added a new library named LoongArch64MpInitLib.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Chao Li 
> Acked-by: Ray Ni 
> ---
>  .../LoongArch64MpInitLib/DxeMpInitLib.inf |   45 +
>  .../LoongArch64MpInitLib/DxeMpInitLib.uni |   15 +
>  .../Library/LoongArch64MpInitLib/DxeMpLib.c   |  480 +
>  .../Library/LoongArch64MpInitLib/MpLib.c  | 1596
> +
>  .../Library/LoongArch64MpInitLib/MpLib.h  |  361 
>  .../LoongArch64MpInitLib/PeiMpInitLib.inf |   37 +
>  .../LoongArch64MpInitLib/PeiMpInitLib.uni |   15 +
>  .../Library/LoongArch64MpInitLib/PeiMpLib.c   |  404 +
>  UefiCpuPkg/UefiCpuPkg.dsc |2 +
>  9 files changed, 2955 insertions(+)
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.inf
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.uni
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpLib.c
>  create mode 100644 UefiCpuPkg/Library/LoongArch64MpInitLib/MpLib.c
>  create mode 100644 UefiCpuPkg/Library/LoongArch64MpInitLib/MpLib.h
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64MpInitLib/PeiMpInitLib.inf
>  create mode 100644
> UefiCpuPkg/Library/LoongArch64MpInitLib/PeiMpInitLib.uni
>  create mode 100644 UefiCpuPkg/Library/LoongArch64MpInitLib/PeiMpLib.c
> 
> diff --git a/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.inf
> b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.inf
> new file mode 100644
> index 00..64f0508046
> --- /dev/null
> +++ b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.inf
> @@ -0,0 +1,45 @@
> +## @file
> +#  LoongArch64 MP initialize support functions for DXE phase.
> +#
> +#  Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +
> +[Defines]
> +  INF_VERSION= 1.29
> +  BASE_NAME  = DxeMpInitLib
> +  MODULE_UNI_FILE= DxeMpInitLib.uni
> +  FILE_GUID  =
> C3B9ACAA-B67C-D3E0-E70D-7982B6EA2931
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.1
> +  LIBRARY_CLASS  = MpInitLib|DXE_DRIVER
> +
> +[Sources.common]
> +  DxeMpLib.c
> +  MpLib.c
> +  MpLib.h
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  UefiCpuPkg/UefiCpuPkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  CpuLib
> +  DebugAgentLib
> +  HobLib
> +  MemoryAllocationLib
> +  SynchronizationLib
> +  TimerLib
> +  UefiLib
> +
> +[Protocols]
> +  gEfiTimerArchProtocolGuid ##
> SOMETIMES_CONSUMES
> +
> +[Pcd]
> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber
> ## CONSUMES
> +  gUefiCpuPkgTokenSpaceGuid.PcdCpuApInitTimeOutInMicroSeconds
> ## CONSUMES
> +
> gUefiCpuPkgTokenSpaceGuid.PcdCpuApStatusCheckIntervalInMicroSeconds
> ## CONSUMES
> diff --git a/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.uni
> b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.uni
> new file mode 100644
> index 00..aebbdbbb0e
> --- /dev/null
> +++ b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpInitLib.uni
> @@ -0,0 +1,15 @@
> +// /** @file
> +// MP Initialize Library instance for DXE driver.
> +//
> +// MP Initialize Library instance for DXE driver.
> +//
> +// Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US "MP
> Initialize Library instance for DXE driver."
> +
> +#string STR_MODULE_DESCRIPTION  #language en-US "MP
> Initialize Library instance for DXE driver."
> diff --git a/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpLib.c
> b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpLib.c
> new file mode 100644
> index 00..26ca4c34fe
> --- /dev/null
> +++ b/UefiCpuPkg/Library/LoongArch64MpInitLib/DxeMpLib.c
> @@ -0,0 +1,480 @@
> +/** @file
> +  LoongArch64 MP initialize support functions for DXE phase.
> +
> +  Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include "MpLib.h"
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +CPU_MP_DATA   *mCpuMpData= NULL;
> +EFI_EVENT mCheckAllApsEvent  = NULL;
> +volatile BOOLEAN  mStopCheckAllApsStatus = TRUE;
> +
> +/**
> +  Enable Debug Agent to support source debugging on AP function.
> +
> +**/
> +VOID

Re: [edk2-devel] [PATCH v4 15/37] UefiCpuPkg: Add CpuDxe driver for LoongArch64

2023-12-18 Thread Ni, Ray
Acked-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Chao Li 
> Sent: Tuesday, December 12, 2023 9:13 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann ;
> Baoqi Zhang ; Dongyan Qian
> 
> Subject: [PATCH v4 15/37] UefiCpuPkg: Add CpuDxe driver for LoongArch64
> 
> Added a new DXE driver named CpuDxeLoongArch64.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Chao Li 
> Co-authored-by: Baoqi Zhang 
> Co-authored-by: Dongyan Qian 
> ---
>  UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.c| 435
> ++
>  UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.h| 281 
>  UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.inf  |  60 +++
>  UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.uni  |  15 +
>  UefiCpuPkg/CpuDxeLoongArch64/CpuMp.c | 544
> +++
>  UefiCpuPkg/CpuDxeLoongArch64/CpuMp.h | 471
> 
>  UefiCpuPkg/CpuDxeLoongArch64/Exception.c | 150 +++
>  UefiCpuPkg/UefiCpuPkg.dsc|   1 +
>  8 files changed, 1957 insertions(+)
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.c
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.h
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.inf
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.uni
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuMp.c
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/CpuMp.h
>  create mode 100644 UefiCpuPkg/CpuDxeLoongArch64/Exception.c
> 
> diff --git a/UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.c
> b/UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.c
> new file mode 100644
> index 00..b1e20047c8
> --- /dev/null
> +++ b/UefiCpuPkg/CpuDxeLoongArch64/CpuDxe.c
> @@ -0,0 +1,435 @@
> +/** @file CpuDxe.c
> +
> +  CPU DXE Module to produce CPU ARCH Protocol.
> +
> +  Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include "CpuDxe.h"
> +#include "CpuMp.h"
> +#include 
> +#include 
> +#include 
> +
> +//
> +// Globals used to initialize the protocol
> +//
> +EFI_HANDLE mCpuHandle = NULL;
> +EFI_CPU_ARCH_PROTOCOL  gCpu   = {
> +  CpuFlushCpuDataCache,
> +  CpuEnableInterrupt,
> +  CpuDisableInterrupt,
> +  CpuGetInterruptState,
> +  CpuInit,
> +  CpuRegisterInterruptHandler,
> +  CpuGetTimerValue,
> +  CpuSetMemoryAttributes,
> +  0,  // NumberOfTimers
> +  4,  // DmaBufferAlignment
> +};
> +
> +/**
> +  This function flushes the range of addresses from Start to Start+Length
> +  from the processor's data cache. If Start is not aligned to a cache line
> +  boundary, then the bytes before Start to the preceding cache line
> boundary
> +  are also flushed. If Start+Length is not aligned to a cache line boundary,
> +  then the bytes past Start+Length to the end of the next cache line
> boundary
> +  are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate
> must be
> +  supported. If the data cache is fully coherent with all DMA operations,
> then
> +  this function can just return EFI_SUCCESS. If the processor does not
> support
> +  flushing a range of the data cache, then the entire data cache can be
> flushed.
> +
> +  @param  This The EFI_CPU_ARCH_PROTOCOL instance.
> +  @param  StartThe beginning physical address to flush
> from the processor's data
> +   cache.
> +  @param  Length   The number of bytes to flush from the
> processor's data cache. This
> +   function may flush more bytes than Length
> specifies depending upon
> +   the granularity of the flush operation that
> the processor supports.
> +  @param  FlushTypeSpecifies the type of flush operation to
> perform.
> +
> +  @retval EFI_SUCCESS   The address range from Start to
> Start+Length was flushed from
> +the processor's data cache.
> +  @retval EFI_INVALID_PARAMETER The processor does not support the
> cache flush type specified
> +by FlushType.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +CpuFlushCpuDataCache (
> +  IN EFI_CPU_ARCH_PROTOCOL  *This,
> +  IN EFI_PHYSICAL_ADDRESS   Start,
> +  IN UINT64 Length,
> +  IN EFI_CPU_FLUSH_TYPE FlushType
> +  )
> +{
> +  switch (FlushType) {
> +case EfiCpuFlushTypeWriteBack:
> +  WriteBackDataCacheRange ((VOID *)(UINTN)Start, (UINTN)Length);
> +  break;
> +case EfiCpuFlushTypeInvalidate:
> +  InvalidateDataCacheRange ((VOID *)(UINTN)Start, (UINTN)Length);
> +  break;
> +case EfiCpuFlushTypeWriteBackInvalidate:
> +  WriteBackInvalidateDataCacheRange ((VOID *)(UINTN)Start,
> (UINTN)Length);
> +  break;
> +default:
> +  return EFI_INVALID_PARAMETER;
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +/**
> +  This function enables interrupt 

Re: [edk2-devel] [PATCH v4 10/37] UefiCpuPkg: Add LoongArch64 CPU Timer library

2023-12-18 Thread Ni, Ray
Acked-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Chao Li 
> Sent: Tuesday, December 12, 2023 9:12 PM
> To: devel@edk2.groups.io
> Cc: Dong, Eric ; Ni, Ray ; Kumar,
> Rahul R ; Gerd Hoffmann 
> Subject: [PATCH v4 10/37] UefiCpuPkg: Add LoongArch64 CPU Timer library
> 
> Add the LoongArch64 CPU Timer library, using CPUCFG 0x4 and 0x5 for
> Stable Counter frequency.
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4584
> 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Chao Li 
> ---
>  .../BaseLoongArch64CpuTimerLib.inf|  29 ++
>  .../BaseLoongArch64CpuTimerLib.uni|  15 ++
>  .../BaseLoongArch64CpuTimerLib/CpuTimerLib.c  | 251
> ++
>  UefiCpuPkg/UefiCpuPkg.dsc |   3 +
>  4 files changed, 298 insertions(+)
>  create mode 100644
> UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuTim
> erLib.inf
>  create mode 100644
> UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuTim
> erLib.uni
>  create mode 100644
> UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/CpuTimerLib.c
> 
> diff --git
> a/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.inf
> b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.inf
> new file mode 100644
> index 00..ab94d91858
> --- /dev/null
> +++
> b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.inf
> @@ -0,0 +1,29 @@
> +## @file
> +#  Base CPU Timer Library
> +#
> +#  Provides base timer support using CPUCFG 0x4 and 0x5 stable counter
> frequency.
> +#
> +#  Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION   = 0x00010029
> +  BASE_NAME =
> BaseLoongArch64CpuTimerLib
> +  FILE_GUID =
> 740389C7-CC44-4A2F-88DC-89D97D312E7C
> +  MODULE_TYPE   = BASE
> +  VERSION_STRING= 1.0
> +  LIBRARY_CLASS = TimerLib
> +  MODULE_UNI_FILE   =
> BaseLoongArch64CpuTimerLib.uni
> +
> +[Sources]
> +  CpuTimerLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  DebugLib
> +  SafeIntLib
> diff --git
> a/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.uni
> b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.uni
> new file mode 100644
> index 00..72d38ec679
> --- /dev/null
> +++
> b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/BaseLoongArch64CpuT
> imerLib.uni
> @@ -0,0 +1,15 @@
> +// /** @file
> +// Base CPU Timer Library
> +//
> +// Provides base timer support using CPUCFG 0x4 and 0x5 stable counter
> frequency.
> +//
> +// Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +//
> +// SPDX-License-Identifier: BSD-2-Clause-Patent
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT #language en-US
> "LOONGARCH CPU Timer Library"
> +
> +#string STR_MODULE_DESCRIPTION  #language en-US "Provides
> basic timer support using CPUCFG 0x4 and 0x5 stable counter frequency."
> diff --git a/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/CpuTimerLib.c
> b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/CpuTimerLib.c
> new file mode 100644
> index 00..828ca4a51a
> --- /dev/null
> +++ b/UefiCpuPkg/Library/BaseLoongArch64CpuTimerLib/CpuTimerLib.c
> @@ -0,0 +1,251 @@
> +/** @file
> +  CPUCFG 0x4 and 0x5 for Stable Counter frequency instance of Timer
> Library.
> +
> +  Copyright (c) 2023, Loongson Technology Corporation Limited. All rights
> reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/**
> +  Calculate clock frequency using CPUCFG 0x4 and 0x5 registers.
> +
> +  @param  VOID.
> +
> +  @return The frequency in Hz.
> +
> +**/
> +STATIC
> +UINT64
> +CalcConstFreq (
> +  VOID
> +  )
> +{
> +  UINT32 BaseFreq;
> +  UINT64 ClockMultiplier;
> +  UINT32 ClockDivide;
> +  CPUCFG_REG4_INFO_DATA  CcFreq;
> +  CPUCFG_REG5_INFO_DATA  CpucfgReg5Data;
> +  UINT64 StableTimerFreq;
> +
> +  //
> +  // Get the the crystal frequency corresponding to the constant
> +  // frequency timer and the clock used by the timer.
> +  //
> +  AsmCpucfg (CPUCFG_REG4_INFO, );
> +
> +  //
> +  // Get the multiplication factor and frequency division factor
> +  // corresponding to the constant frequency timer and the clock
> +  // used by the timer.
> +  //
> +  AsmCpucfg (CPUCFG_REG5_INFO, );
> +
> +  BaseFreq= CcFreq.Bits.CC_FREQ;
> +  ClockMultiplier = CpucfgReg5Data.Bits.CC_MUL & 0x;
> +  ClockDivide = CpucfgReg5Data.Bits.CC_DIV & 0x;
> +
> +  if ((BaseFreq == 0x0) || (ClockMultiplier == 0x0) || 

Re: [edk2-devel] [PATCH v4 12/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

2023-12-18 Thread Ni, Ray
> Plan B:
> It only returns the attribute and length of the first part, leaving it up to 
> the caller to decide to look for the next part.
> I'm leaning toward plan B, what do you think?

I like plan B as well. Do you think that "EndAddress" can be removed from the 
param list?

Imaging from caller perspective, the code can be like follows:
BaseAddress = 0;
While (TRUE) {
  GetMemoryRegionAttributes (
BaseAddress,
,

  );
  If (Length == 0) {
Break;
  }
  // dump BaseAddress, Length, Attributes
  BaseAddress += Length;
}


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




回复: [edk2-devel] [PATCH v5 0/2] Support customized FV Migration Information

2023-12-18 Thread gaoliming via groups.io
Fan:
 This version patch is good to me.  Reviewed-by: Liming Gao
 for this patch set.

Thanks
Liming
> -邮件原件-
> 发件人: Wang, Fan 
> 发送时间: 2023年12月14日 22:15
> 收件人: Gao, Liming ; Kumar, Rahul R
> 
> 抄送: Wang, Fan ; Wang, Jian J
> ; Ni, Ray ; Kinney, Michael D
> ; Jiang, Guomin ;
> devel@edk2.groups.io
> 主题: RE: [edk2-devel] [PATCH v5 0/2] Support customized FV Migration
> Information
> 
> Hi Liming and Kumar
> 
> Could you help review this v5 patch:
> 
> MdeModulePkg: Support customized FV Migration Information:
> https://github.com/fanwang2intel/edk2/commit/83c55a73107bfb13df1d8b5
> 22e0ea1d18ef3d86b
> 
> SecurityPkg: Support customized FV Migration Information
> https://github.com/fanwang2intel/edk2/commit/6f7e955f1d63a875f69ebc08
> 4885e76610acc722
> 
> v5:
> - Remove RemoveFvHobsInTemporaryMemory() since no consumer will call
> this API now.
> - Separate patches to different packages.
> 
> Best Regards
> Fan
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Wang Fan
> Sent: Thursday, December 14, 2023 9:53 PM
> To: devel@edk2.groups.io
> Cc: Wang, Fan 
> Subject: [edk2-devel] [PATCH v5 0/2] Support customized FV Migration
> Information
> 
> There are use cases which not all FVs need be migrated from TempRam to
> permanent memory before TempRam tears down. This new guid is introduced
> to avoid unnecessary FV migration to improve boot performance. Platform
can
> publish MigrationInfo hob with this guid to customize FV migration info,
and
> PeiCore will only migrate FVs indicated by this Hob info.
> 
> This is a backwards compatible change, PeiCore will check MigrationInfo
hob
> before migration. If MigrationInfo hobs exists, only migrate FVs recorded
by
> hobs. If MigrationInfo hobs not exists, migrate all FVs to permanent
memory.
> 
> In Tcg driver, when MigratedFvInfo hob is detected, existing code logic is
> assuming FV raw data is already copied, and raw data base address is also
> recorded. Due to the new PeiCore change, the platform can publish hob to
> indicate raw data need be copied or not along with FV migration.
> 
> Two cases need be considered to skip copy for boot performance: The first
> case is FV is not expected to be measured in post-mem phase, we should use
> MeasurementExcludedPpiGuid to skip measurement. The second case is FV
> raw data has no need to do rebase operation after migration, then
> measurement should calculate hash directly from FV base address.
> 
> Fan Wang (2):
>   MdeModulePkg: Support customized FV Migration Information
>   SecurityPkg: Support customized FV Migration Information
> 
>  MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c | 84
> ++-
> MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 40 -
>  MdeModulePkg/Core/Pei/PeiMain.h   | 11 ---
>  MdeModulePkg/Core/Pei/PeiMain.inf |  1 +
>  MdeModulePkg/Include/Guid/MigratedFvInfo.h| 42 +-
>  MdeModulePkg/MdeModulePkg.dec |  3 +-
>  SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c |  7 +-
>  SecurityPkg/Tcg/TcgPei/TcgPei.c   |  7 +-
>  8 files changed, 116 insertions(+), 79 deletions(-)
> 
> --
> 2.29.2.windows.2
> 
> 
> 
> 
> 





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




Re: [edk2-devel] [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-18 Thread Ni, Ray
> 
> SemAddr is the address of allocated buffer (SemBuffer), "SemAddr +=
> OneSemSize" will make SemAddr point to the part of allocated buffer. is it
> possible integer overflow? If so, the allocatepage should fail?

Good reason! I agree.


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




[edk2-devel] [PATCH v1 2/2] IpmiFeaturePkg/GenericIpmi: Fix GCC compiler error

2023-12-18 Thread Huang, Li-Xia
Fix GCC compiler error in StandaloneMmGenericIpmi.

Cc: Abner Chang 
Cc: Nate DeSimone 

Signed-off-by: Lixia Huang 
---
 
Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 | 2 --
 1 file changed, 2 deletions(-)

diff --git 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
index 1b9841e4b745..edc9eec9395a 100644
--- 
a/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
+++ 
b/Features/Intel/OutOfBandManagement/IpmiFeaturePkg/GenericIpmi/StandaloneMm/StandaloneMmGenericIpmi.c
@@ -185,12 +185,10 @@ Returns:
 **/
 {
   EFI_STATUSStatus;
-  UINT8 ErrorCount;
   IPMI_INTERFACE_STATE  InterfaceState;
   UINT8 Index;
 
   DEBUG ((DEBUG_INFO, "SmmInitializeIpmiKcsPhysicalLayer entry \n"));
-  ErrorCount = 0;
   InterfaceState = IpmiInterfaceNotReady;
 
   Status = gMmst->MmAllocatePool (
-- 
2.26.2.windows.1



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




Re: [edk2-devel] [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-18 Thread Wu, Jiaxin
Thanks Ray.

> 
> 1. It's not "LockedCpuCount". It's "ArrivedCpuCountUponLock".
>   Comments can be:
> Before the door is locked, CpuCount stores the arrived CPU count.
> After the door is locked, CpuCount is set to -1 indicating the door is 
> locked.
> ArrivedCpuCpuntUponLock stores the arrived CPU count then.
> 
> 

Ok, I will update.

> > +/**
> > +  Performs an atomic compare exchange operation to get semaphore.
> > +  The compare exchange operation must be performed using MP safe
> > +  mechanisms.
> > +
> > +  @param[in,out]  SemIN:  32-bit unsigned integer
> > + OUT: original integer - 1 if Sem is not locked.
> > + OUT: original integer if Sem is locked
> > (MAX_UINT32).
> > +
> > +  @retval Original integer - 1 if Sem is not locked.
> > +  Original integer if Sem is locked (MAX_UINT32).
> 
> 2. Can just say "MAX_UINT32 if Sem is locked".
> 
> 

Agree.

> > +
> > +  //
> > +  // Assign CPU Semaphore pointer
> > +  //
> > +  CpuSem = (*Context)->CpuSem;
> > +  for (CpuIndex = 0; CpuIndex < NumberOfCpus; CpuIndex++) {
> > +CpuSem->Run  = (SMM_CPU_SYNC_SEMAPHORE *)SemAddr;
> > +*CpuSem->Run = 0;
> > +
> > +CpuSem++;
> > +SemAddr += OneSemSize;
> 
> 5. SafeIntLib was used earlier to make sure no integer overflow.
>   But "SemAddr += OneSemSize" is simply ignoring the danger of integer
> overflow.
>   I agree (NumberOfCpus + 1) * OneSemSize shouldn't cause integer overflow
> when code runs to here.
>   But initial value of SemAddr is not zero. It's still possible the SemAddr +
> (NumberOfCpus+1)*OneSemSize causes integer overflow.
>   I am ok if you don't fix it as I don't believe the integer overflow could 
> happen
> in 5 years.

SemAddr is the address of allocated buffer (SemBuffer), "SemAddr += 
OneSemSize" will make SemAddr point to the part of allocated buffer. is it 
possible integer overflow? If so, the allocatepage should fail?


Thanks,
Jiaxin  



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




Re: [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present.

2023-12-18 Thread Yuanhao Xie
Hi Ray,

It means that:
The "SmmCpuRendezvous" function has a bug in that it summons all APs into SMM, 
but there is a time gap before they are set as "present." During this window, 
if using the "setVariable" operation, it can cause issues because "setVariable" 
requires all APs to be in SMM and marked as "present." Therefore, this patch 
adds extra logic to "SmmCpuRendezvous" to check if the APs are already 
"present" before proceeding.

Thanks,
Yuanhao
-Original Message-
From: Ni, Ray  
Sent: Tuesday, December 19, 2023 12:01 PM
To: Xie, Yuanhao ; devel@edk2.groups.io
Cc: Li, Zhihao ; Kumar, Rahul R ; 
Gerd Hoffmann ; Wu, Jiaxin 
Subject: RE: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all 
Aps in Present.

Yuanhao, Zhihao,
Can you kindly explain a bit more about this sentence in commit message " SMM 
read save state requires AP must be present."?

Thanks,
Ray
> -Original Message-
> From: Xie, Yuanhao 
> Sent: Friday, December 15, 2023 5:30 PM
> To: devel@edk2.groups.io
> Cc: Xie, Yuanhao ; Li, Zhihao 
> ; Ni, Ray ; Kumar, Rahul R 
> ; Gerd Hoffmann ; Wu, 
> Jiaxin 
> Subject: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure 
> all Aps in Present.
> 
> SMM read save state requires AP must be present.
> This patch aim to avoid the AP not ready for save state check.
> Furthermore, SmmWaitForApArrival has two callers: SmmCpuRendezvous and 
> BSPHandler, the behavior of the two callers can be consistent by add 
> the while loop to check the present of the APs to SmmCpuRendezvous.
> 
> Signed-off-by: Zhihao Li 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Jiaxin Wu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 27
> +++
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +
>  2 files changed, 40 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> index c0485b0519..3e98955319 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> @@ -416,8 +416,15 @@ SmmCpuRendezvous (
>IN BOOLEANBlockingMode
>)
>  {
> +  UINTN   Index;
> +  UINTN   PresentCount;
> +  UINT32  BlockedCount;
> +  UINT32  DisabledCount;
>EFI_STATUS  Status;
> 
> +  BlockedCount  = 0;
> +  DisabledCount = 0;
> +
>//
>// Return success immediately if all CPUs are already synchronized.
>//
> @@ -436,6 +443,26 @@ SmmCpuRendezvous (
>  // There are some APs outside SMM, Wait for all avaiable APs to arrive.
>  //
>  SmmWaitForApArrival ();
> +
> +//
> +// Make sure all APs have their Present flag set
> +//
> +while (TRUE) {
> +  PresentCount = 0;
> +  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
> +if (*(mSmmMpSyncData->CpuData[Index].Present)) {
> +  PresentCount++;
> +}
> +  }
> +
> +  GetSmmDelayedBlockedDisabledCount (NULL, ,
> );
> +  if (PresentCount == mMaxNumberOfCpus - BlockedCount -
> DisabledCount ) {
> +break;
> +  }
> +
> +  CpuPause ();
> +}
> +
>  Status = mSmmMpSyncData->AllApArrivedWithException ?
> EFI_SUCCESS : EFI_TIMEOUT;
>} else {
>  //
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index f18345881b..e3538957fb 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -1552,6 +1552,19 @@ SmmWaitForApArrival (
>VOID
>);
> 
> +/**
> +  Returns the Number of SMM Delayed & Blocked & Disabled Thread Count.
> +  @param[in,out] DelayedCount  The Number of SMM Delayed Thread
> Count.
> +  @param[in,out] BlockedCount  The Number of SMM Blocked Thread
> Count.
> +  @param[in,out] DisabledCount The Number of SMM Disabled Thread
> Count.
> +**/
> +VOID
> +GetSmmDelayedBlockedDisabledCount (
> +  IN OUT UINT32  *DelayedCount,
> +  IN OUT UINT32  *BlockedCount,
> +  IN OUT UINT32  *DisabledCount
> +  );
> +
>  /**
>Write unprotect read-only pages if Cr0.Bits.WP is 1.
> 
> --
> 2.39.1.windows.1



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




[edk2-devel] [PATCH 2/2] FmpDevicePkg: Add DECLARE_LENGTH opcode of dependency expression

2023-12-18 Thread Li, Yi
Mantis: https://mantis.uefi.org/mantis/view.php?id=2025

To avoid messy parsing of the Depex section of a Capsule, it would
be a lot easier for everyone involved if we preceded the Capsule Depex
Section with a length declaration. It provides simple bounds checking
to avoid having to parse the op-codes, but in the case of a malformed
depex being parsed, avoid other issues which can be messy.

REF: UEFI spec 2.10 Table 23.4

Signed-off-by: Yi Li 

Cc: Liming Gao 
Cc: Michael D Kinney 
Cc: Wei6 Xu 
---
 .../FmpDependencyLib/FmpDependencyLib.c   | 35 
 .../PrivateInclude/FmpLastAttemptStatus.h |  3 +
 .../EvaluateDependencyUnitTest.c  | 84 ---
 3 files changed, 110 insertions(+), 12 deletions(-)

diff --git a/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c 
b/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c
index 76a1ee3f40db..50662e74e065 100644
--- a/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c
+++ b/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c
@@ -234,6 +234,7 @@ EvaluateDependency (
   GUID   ImageTypeId;
   UINT32 Version;
   UINT32 LocalLastAttemptStatus;
+  UINT32 DeclaredLength;
 
   LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
 
@@ -489,6 +490,37 @@ EvaluateDependency (
 }
 
 return Element1.Value.Boolean;
+  case EFI_FMP_DEP_DECLARE_LENGTH:
+if (Iterator + sizeof (UINT32) >= (UINT8 *)Dependencies->Dependencies 
+ DependenciesSize ) {
+  DEBUG ((DEBUG_ERROR, "EvaluateDependency: DECLARE_LENGTH extends 
beyond end of dependency expression!\n"));
+  LocalLastAttemptStatus = 
LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_BEYOND_DEPEX;
+  goto Error;
+}
+
+//
+// This opcode must be the first one in a dependency expression.
+//
+if (Iterator != Dependencies->Dependencies) {
+  DEBUG ((DEBUG_ERROR, "EvaluateDependency: DECLARE_LENGTH is not the 
first opcode!\n"));
+  LocalLastAttemptStatus = 
LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_NOT_FIRST_OPCODE;
+  goto Error;
+}
+
+DeclaredLength = *(UINT32 *)(Iterator + 1);
+if (DeclaredLength != DependenciesSize) {
+  DEBUG ((DEBUG_ERROR, "EvaluateDependency: DECLARE_LENGTH is not 
equal to length of dependency expression!\n"));
+  LocalLastAttemptStatus = 
LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_INCORRECT;
+  goto Error;
+}
+
+Status = Push (DeclaredLength, VersionType);
+if (EFI_ERROR (Status)) {
+  LocalLastAttemptStatus = 
LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+  goto Error;
+}
+
+Iterator = Iterator + sizeof (UINT32);
+break;
   default:
 DEBUG ((DEBUG_ERROR, "EvaluateDependency: Unknown Opcode - %02x!\n", 
*Iterator));
 LocalLastAttemptStatus = 
LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_UNKNOWN_OPCODE;
@@ -574,6 +606,9 @@ ValidateDependency (
 }
 
 return TRUE;
+  case EFI_FMP_DEP_DECLARE_LENGTH:
+Depex += sizeof (UINT32) + 1;
+break;
   default:
 return FALSE;
 }
diff --git a/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h 
b/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h
index 39a55dd2c643..aaa3334909c8 100644
--- a/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h
+++ b/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h
@@ -66,6 +66,9 @@ enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST {
   LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_FMP_NOT_FOUND,
   LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE,
   LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE,
+  LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_NOT_FIRST_OPCODE,
+  LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_BEYOND_DEPEX,
+  LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_DECLARE_LENGTH_INCORRECT,
 
   ///
   /// Last attempt status codes used in FmpDependencyCheckLib
diff --git 
a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c
 
b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c
index 0edb7f67306f..352887af2c5e 100644
--- 
a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c
+++ 
b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c
@@ -125,19 +125,75 @@ static UINT8  mExpression11[] = {
   EFI_FMP_DEP_END
 };
 
+// Valid Dependency Expression 7: With correct declared length
+static UINT8  mExpression12[] = {
+  EFI_FMP_DEP_DECLARE_LENGTH, 0x35, 0x00, 0x00, 0x00,
+  EFI_FMP_DEP_PUSH_VERSION,   0x01, 0x00, 0x00, 0x00,
+  EFI_FMP_DEP_PUSH_GUID,  0xFA, 0x4D, 0x14, 0x97,0x8E,  0xEB, 0x4D, 0xD1, 
0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
+  EFI_FMP_DEP_GT,
+  EFI_FMP_DEP_PUSH_VERSION,   0x03, 0x00, 0x00, 0x00,
+  EFI_FMP_DEP_PUSH_GUID,  0x70, 0x73, 0x2A, 0xA4,0x3A,  

[edk2-devel] [PATCH 1/2] MdePkg: Add DECLARE_LENGTH opcode of dependency expression

2023-12-18 Thread Li, Yi
Mantis: https://mantis.uefi.org/mantis/view.php?id=2025

To avoid messy parsing of the Depex section of a Capsule, it would
be a lot easier for everyone involved if we preceded the Capsule Depex
Section with a length declaration. It provides simple bounds checking
to avoid having to parse the op-codes, but in the case of a malformed
depex being parsed, avoid other issues which can be messy.

REF: UEFI spec 2.10 Table 23.4

Signed-off-by: Yi Li 

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
---
 MdePkg/Include/Protocol/FirmwareManagement.h | 29 ++--
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/MdePkg/Include/Protocol/FirmwareManagement.h 
b/MdePkg/Include/Protocol/FirmwareManagement.h
index f37067df3455..e535bb697d88 100644
--- a/MdePkg/Include/Protocol/FirmwareManagement.h
+++ b/MdePkg/Include/Protocol/FirmwareManagement.h
@@ -30,20 +30,21 @@ typedef struct _EFI_FIRMWARE_MANAGEMENT_PROTOCOL 
EFI_FIRMWARE_MANAGEMENT_PROTOCO
 ///
 /// Dependency Expression Opcode
 ///
-#define EFI_FMP_DEP_PUSH_GUID 0x00
-#define EFI_FMP_DEP_PUSH_VERSION  0x01
-#define EFI_FMP_DEP_VERSION_STR   0x02
-#define EFI_FMP_DEP_AND   0x03
-#define EFI_FMP_DEP_OR0x04
-#define EFI_FMP_DEP_NOT   0x05
-#define EFI_FMP_DEP_TRUE  0x06
-#define EFI_FMP_DEP_FALSE 0x07
-#define EFI_FMP_DEP_EQ0x08
-#define EFI_FMP_DEP_GT0x09
-#define EFI_FMP_DEP_GTE   0x0A
-#define EFI_FMP_DEP_LT0x0B
-#define EFI_FMP_DEP_LTE   0x0C
-#define EFI_FMP_DEP_END   0x0D
+#define EFI_FMP_DEP_PUSH_GUID   0x00
+#define EFI_FMP_DEP_PUSH_VERSION0x01
+#define EFI_FMP_DEP_VERSION_STR 0x02
+#define EFI_FMP_DEP_AND 0x03
+#define EFI_FMP_DEP_OR  0x04
+#define EFI_FMP_DEP_NOT 0x05
+#define EFI_FMP_DEP_TRUE0x06
+#define EFI_FMP_DEP_FALSE   0x07
+#define EFI_FMP_DEP_EQ  0x08
+#define EFI_FMP_DEP_GT  0x09
+#define EFI_FMP_DEP_GTE 0x0A
+#define EFI_FMP_DEP_LT  0x0B
+#define EFI_FMP_DEP_LTE 0x0C
+#define EFI_FMP_DEP_END 0x0D
+#define EFI_FMP_DEP_DECLARE_LENGTH  0x0E
 
 ///
 /// Image Attribute - Dependency
-- 
2.42.0.windows.2



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




[edk2-devel] [PATCH 0/2] Add DECLARE_LENGTH opcode of dependency expression

2023-12-18 Thread Li, Yi
Mantis: https://mantis.uefi.org/mantis/view.php?id=2025

To avoid messy parsing of the Depex section of a Capsule, it would
be a lot easier for everyone involved if we preceded the Capsule Depex
Section with a length declaration. It provides simple bounds checking
to avoid having to parse the op-codes, but in the case of a malformed
depex being parsed, avoid other issues which can be messy.

REF: UEFI spec 2.10 Table 23.4
Syntax
DECLARE_LENGTH <32-bit Length>
Description
Declares an 32-bit byte length of the entire dependency expression.
Behaviors and Restrictions
This opcode must be the first one in a dependency expression.

Yi Li (2):
  MdePkg: Add DECLARE_LENGTH opcode of dependency expression
  FmpDevicePkg: Add DECLARE_LENGTH opcode of dependency expression

 .../FmpDependencyLib/FmpDependencyLib.c   | 35 
 .../PrivateInclude/FmpLastAttemptStatus.h |  3 +
 .../EvaluateDependencyUnitTest.c  | 84 ---
 MdePkg/Include/Protocol/FirmwareManagement.h  | 29 +++
 4 files changed, 125 insertions(+), 26 deletions(-)

-- 
2.42.0.windows.2



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




[edk2-devel] [edk2-redfish-client][PATCH] RedfishClientPkg: Add debug messages

2023-12-18 Thread Chang, Abner via groups.io
From: Abner Chang 

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Cc: Mike Maslenkin 
---
 .../ComputerSystemCollectionDxe.c  |  3 ++-
 .../EdkIIRedfishResourceConfigLib.c|  7 ++-
 .../Library/RedfishVersionLib/RedfishVersionLib.c  |  2 ++
 .../RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c  | 10 ++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git 
a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
 
b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
index 595a960300..74003406ef 100644
--- 
a/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
+++ 
b/RedfishClientPkg/Features/ComputerSystemCollectionDxe/ComputerSystemCollectionDxe.c
@@ -107,7 +107,7 @@ HandleResource (
 DEBUG ((REDFISH_DEBUG_TRACE, "%a provision for %s\n", __func__, Uri));
 Status = EdkIIRedfishResourceConfigProvisioning (, Uri, 
Private->InformationExchange, FALSE);
 if (EFI_ERROR (Status)) {
-  DEBUG ((DEBUG_ERROR, "%a: failed to provision with GET mode: %r\n", 
__func__, Status));
+  DEBUG ((DEBUG_ERROR, "%a: failed to provision with PATCH mode: %r\n", 
__func__, Status));
 }
 
 return Status;
@@ -385,6 +385,7 @@ RedfishCollectionFeatureCallback (
 
   StrCatS (ResourceUri, MAX_URI_LENGTH, Private->RedfishVersion);
   StrCatS (ResourceUri, MAX_URI_LENGTH, 
InformationExchange->SendInformation.FullUri);
+  DEBUG ((DEBUG_MANAGEABILITY, "%a: Redfish collection resource URI - %s\n", 
__func__, ResourceUri));
 
   //
   // Initialize collection path
diff --git 
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
 
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
index 7a7bb4dece..09ae3921e3 100644
--- 
a/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
+++ 
b/RedfishClientPkg/Library/EdkIIRedfishResourceConfigLib/EdkIIRedfishResourceConfigLib.c
@@ -78,7 +78,12 @@ GetRedfishSchemaInfo (
  
  );
   if (EFI_ERROR (Status)) {
-DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __func__, Status));
+if (Status == EFI_UNSUPPORTED) {
+  DEBUG ((DEBUG_ERROR, "%a, No proper JSON to C structure converter for 
this Redfish resource.\n", __func__));
+} else {
+  DEBUG ((DEBUG_ERROR, "%a, ToStructure() failed: %r\n", __func__, 
Status));
+}
+
 return Status;
   }
 
diff --git a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c 
b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c
index 45e156ca94..bcaca3c745 100644
--- a/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c
+++ b/RedfishClientPkg/Library/RedfishVersionLib/RedfishVersionLib.c
@@ -140,6 +140,7 @@ RedfishGetVersion (
 
   if (VersionString != NULL) {
 CacheVersion (Service, VersionString);
+DEBUG ((DEBUG_MANAGEABILITY, "%a: Redfish version - %s\n", __func__, 
VersionString));
 return VersionString;
   }
 
@@ -150,6 +151,7 @@ ON_ERROR:
 VersionString = REDFISH_VERSION_DEFAULT_STRING;
   }
 
+  DEBUG ((DEBUG_MANAGEABILITY, "%a: Redfish version - %s\n", __func__, 
VersionString));
   return AllocateCopyPool (StrSize (VersionString), VersionString);
 }
 
diff --git a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c 
b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
index c0c3ec476f..dce83a8a98 100644
--- a/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
+++ b/RedfishClientPkg/RedfishFeatureCoreDxe/RedfishFeatureCoreDxe.c
@@ -135,6 +135,12 @@ StartUpFeatureDriver (
 return;
   }
 
+  if (CurrentConfigLanguageUri != NULL) {
+DEBUG ((DEBUG_MANAGEABILITY, "%a: Current Config Language URI - %s\n", 
__func__, CurrentConfigLanguageUri));
+  } else {
+DEBUG ((DEBUG_MANAGEABILITY, "%a: Current Config Language URI - Servie 
Root\n", __func__));
+  }
+
   NextParentUri = (EFI_STRING)AllocateZeroPool (MaxParentUriLength * sizeof 
(CHAR16));
   if (NextParentUri == NULL) {
 DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for parent configure 
language.\n", __func__));
@@ -151,6 +157,10 @@ StartUpFeatureDriver (
   ThisList->InformationExchange = mInformationExchange;
   Status= SetupExchangeInformationInfo (ThisList, 
NextParentUri);
   if (!EFI_ERROR (Status)) {
+DEBUG ((DEBUG_MANAGEABILITY, "%a: Sender exchange information for 
Collection Feature Driver:\n", __func__));
+DEBUG ((DEBUG_MANAGEABILITY, "  Parent URI   : %s\n", 
ThisList->InformationExchange->SendInformation.ParentUri));
+DEBUG ((DEBUG_MANAGEABILITY, "  Property name: %s\n", 
ThisList->InformationExchange->SendInformation.PropertyName));
+DEBUG ((DEBUG_MANAGEABILITY, "  Full URI : %s\n", 

Re: [edk2-devel] [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation error conditions.

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 10:12 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; nick...@nvidia.com; ig...@ami.com
> Subject: Re: [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation
> error conditions.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> On Mon, Dec 18, 2023 at 7:47 AM Chang, Abner 
> wrote:
> >
> > [AMD Official Use Only - General]
> >
> > > -Original Message-
> > > From: Mike Maslenkin 
> > > Sent: Friday, December 15, 2023 7:25 AM
> > > To: devel@edk2.groups.io
> > > Cc: Chang, Abner ; nick...@nvidia.com;
> > > ig...@ami.com; Mike Maslenkin 
> > > Subject: [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation
> > > error conditions.
> > >
> > > Caution: This message originated from an External Source. Use proper
> caution
> > > when opening attachments, clicking links, or responding.
> > >
> > >
> > > Cc: Abner Chang 
> > > Cc: Nickle Wang 
> > > Cc: Igor Kulchytskyy 
> > > Signed-off-by: Mike Maslenkin 
> > > ---
> > >  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 85 --
> -
> > >  1 file changed, 75 insertions(+), 10 deletions(-)
> > >
> > > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > > b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > > index 3499a855570c..9d1678c3429e 100644
> > > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > > @@ -748,38 +748,103 @@ InitInformationData (
> > >if (RedfishLocation != NULL) {
> > >
> > >  AllocationSize= AsciiStrSize (RedfishLocation) * sizeof 
> > > (CHAR16);
> > >
> > >  Information->Location = AllocatePool (AllocationSize);
> > >
> > > -AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > > AllocationSize);
> > >
> > > -DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> > > Information->Location));
> > >
> > > +if (Information->Location != NULL) {
> > >
> > > +  AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > > AllocationSize);
> > >
> > > +  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> > > Information->Location));
> > >
> > > +} else {
> > >
> > > +  DEBUG ((
> > >
> > > +DEBUG_ERROR,
> > >
> > > +"%a: Can not allocate memory for Redfish service location: 
> > > %a.\n",
> > >
> > > +__func__,
> > >
> > > +RedfishLocation
> > >
> > > +));
> > >
> > > +}
> > >
> > >}
> > >
> > >
> > >
> > >if (Uuid != NULL) {
> > >
> > >  AllocationSize= AsciiStrSize (Uuid) * sizeof (CHAR16);
> > >
> > >  Information->Uuid = AllocatePool (AllocationSize);
> > >
> > > -AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
> > >
> > > -DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information-
> > > >Uuid));
> > >
> > > +if (Information->Uuid != NULL) {
> > >
> > > +  AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
> > >
> > > +  DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n",
> Information-
> > > >Uuid));
> > >
> > > +} else {
> > >
> > > +  DEBUG ((
> > >
> > > +DEBUG_ERROR,
> > >
> > > +"%a: Can not allocate memory for Service UUID: %a.\n",
> > >
> > > +__func__,
> > >
> > > +Uuid
> > >
> > > +));
> > >
> > > +}
> > >
> > >}
> > >
> > >
> > >
> > >if (Os != NULL) {
> > >
> > >  AllocationSize  = AsciiStrSize (Os) * sizeof (CHAR16);
> > >
> > >  Information->Os = AllocatePool (AllocationSize);
> > >
> > > -AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
> > >
> > > +if (Information->Os != NULL) {
> > >
> > > +  AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
> > >
> > > +} else {
> > >
> > > +  DEBUG ((
> > >
> > > +DEBUG_ERROR,
> > >
> > > +"%a: Can not allocate memory for Redfish service OS: %a.\n",
> > >
> > > +__func__,
> > >
> > > +Os
> > >
> > > +));
> > >
> > > +}
> > >
> > >}
> > >
> > >
> > >
> > >if (OsVer != NULL) {
> > >
> > >  AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16);
> > >
> > >  Information->OsVersion = AllocatePool (AllocationSize);
> > >
> > > -AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, 
> > > AllocationSize);
> > >
> > > -DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s,
> Version:%s.\n",
> > > Information->Os, Information->OsVersion));
> > >
> > > +if (Information->OsVersion != NULL) {
> > >
> > > +  AsciiStrToUnicodeStrS (OsVer, Information->OsVersion,
> AllocationSize);
> > >
> > > +  DEBUG ((
> > >
> > > +DEBUG_MANAGEABILITY,
> > >
> > > +"Redfish service OS: %s, Version:%s.\n",
> >
> > Jus a note here:  We expect 

Re: [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present.

2023-12-18 Thread Ni, Ray
Yuanhao, Zhihao,
Can you kindly explain a bit more about this sentence in commit message " SMM 
read save state requires AP must be present."?

Thanks,
Ray
> -Original Message-
> From: Xie, Yuanhao 
> Sent: Friday, December 15, 2023 5:30 PM
> To: devel@edk2.groups.io
> Cc: Xie, Yuanhao ; Li, Zhihao ;
> Ni, Ray ; Kumar, Rahul R ; Gerd
> Hoffmann ; Wu, Jiaxin 
> Subject: [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous
> ensure all Aps in Present.
> 
> SMM read save state requires AP must be present.
> This patch aim to avoid the AP not ready for save state check.
> Furthermore, SmmWaitForApArrival has two callers: SmmCpuRendezvous and
> BSPHandler, the behavior of the two callers can be consistent by add
> the while loop to check the present of the APs to SmmCpuRendezvous.
> 
> Signed-off-by: Zhihao Li 
> Cc: Ray Ni 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Cc: Jiaxin Wu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 27
> +++
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +
>  2 files changed, 40 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> index c0485b0519..3e98955319 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
> @@ -416,8 +416,15 @@ SmmCpuRendezvous (
>IN BOOLEANBlockingMode
>)
>  {
> +  UINTN   Index;
> +  UINTN   PresentCount;
> +  UINT32  BlockedCount;
> +  UINT32  DisabledCount;
>EFI_STATUS  Status;
> 
> +  BlockedCount  = 0;
> +  DisabledCount = 0;
> +
>//
>// Return success immediately if all CPUs are already synchronized.
>//
> @@ -436,6 +443,26 @@ SmmCpuRendezvous (
>  // There are some APs outside SMM, Wait for all avaiable APs to arrive.
>  //
>  SmmWaitForApArrival ();
> +
> +//
> +// Make sure all APs have their Present flag set
> +//
> +while (TRUE) {
> +  PresentCount = 0;
> +  for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
> +if (*(mSmmMpSyncData->CpuData[Index].Present)) {
> +  PresentCount++;
> +}
> +  }
> +
> +  GetSmmDelayedBlockedDisabledCount (NULL, ,
> );
> +  if (PresentCount == mMaxNumberOfCpus - BlockedCount -
> DisabledCount ) {
> +break;
> +  }
> +
> +  CpuPause ();
> +}
> +
>  Status = mSmmMpSyncData->AllApArrivedWithException ?
> EFI_SUCCESS : EFI_TIMEOUT;
>} else {
>  //
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> index f18345881b..e3538957fb 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
> @@ -1552,6 +1552,19 @@ SmmWaitForApArrival (
>VOID
>);
> 
> +/**
> +  Returns the Number of SMM Delayed & Blocked & Disabled Thread Count.
> +  @param[in,out] DelayedCount  The Number of SMM Delayed Thread
> Count.
> +  @param[in,out] BlockedCount  The Number of SMM Blocked Thread
> Count.
> +  @param[in,out] DisabledCount The Number of SMM Disabled Thread
> Count.
> +**/
> +VOID
> +GetSmmDelayedBlockedDisabledCount (
> +  IN OUT UINT32  *DelayedCount,
> +  IN OUT UINT32  *BlockedCount,
> +  IN OUT UINT32  *DisabledCount
> +  );
> +
>  /**
>Write unprotect read-only pages if Cr0.Bits.WP is 1.
> 
> --
> 2.39.1.windows.1



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




Re: [edk2-devel] [PATCH v4 1/8] UefiCpuPkg/PiSmmCpuDxeSmm: Optimize Semaphore Sync between BSP and AP

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Kumar, Rahul R
> ; Gerd Hoffmann 
> Subject: [PATCH v4 1/8] UefiCpuPkg/PiSmmCpuDxeSmm: Optimize
> Semaphore Sync between BSP and AP
> 
> This patch is to define 3 new functions (WaitForBsp & ReleaseBsp &
> ReleaseOneAp) used for the semaphore sync between BSP & AP. With the
> change, BSP and AP Sync flow will be easy understand as below:
> BSP: ReleaseAllAPs or ReleaseOneAp --> AP: WaitForBsp
> BSP: WaitForAllAPs <-- AP: ReleaseBsp
> 
> Cc: Laszlo Ersek 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Jiaxin Wu 
> Reviewed-by: Laszlo Ersek 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 72
> ---
>  1 file changed, 58 insertions(+), 14 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index b279f5dfcc..54542262a2 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -120,10 +120,11 @@ LockdownSemaphore (
> 
>return Value;
>  }
> 
>  /**
> +  Used for BSP to wait all APs.
>Wait all APs to performs an atomic compare exchange operation to
> release semaphore.
> 
>@param   NumberOfAPs  AP number
> 
>  **/
> @@ -139,10 +140,11 @@ WaitForAllAPs (
>  WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
>}
>  }
> 
>  /**
> +  Used for BSP to release all APs.
>Performs an atomic compare exchange operation to release semaphore
>for each AP.
> 
>  **/
>  VOID
> @@ -157,10 +159,52 @@ ReleaseAllAPs (
>ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);
>  }
>}
>  }
> 
> +/**
> +  Used for BSP to release one AP.
> +
> +  @param  ApSem IN:  32-bit unsigned integer
> +OUT: original integer + 1
> +**/
> +VOID
> +ReleaseOneAp   (
> +  IN OUT  volatile UINT32  *ApSem
> +  )
> +{
> +  ReleaseSemaphore (ApSem);
> +}
> +
> +/**
> +  Used for AP to wait BSP.
> +
> +  @param  ApSem  IN:  32-bit unsigned integer
> + OUT: original integer - 1
> +**/
> +VOID
> +WaitForBsp  (
> +  IN OUT  volatile UINT32  *ApSem
> +  )
> +{
> +  WaitForSemaphore (ApSem);
> +}
> +
> +/**
> +  Used for AP to release BSP.
> +
> +  @param  BspSem IN:  32-bit unsigned integer
> + OUT: original integer + 1
> +**/
> +VOID
> +ReleaseBsp   (
> +  IN OUT  volatile UINT32  *BspSem
> +  )
> +{
> +  ReleaseSemaphore (BspSem);
> +}
> +
>  /**
>Check whether the index of CPU perform the package level register
>programming during System Management Mode initialization.
> 
>The index of Processor specified by
> mPackageFirstThreadIndex[PackageIndex]
> @@ -632,11 +676,11 @@ BSPHandler (
>// Signal all APs it's time for backup MTRRs
>//
>ReleaseAllAPs ();
> 
>//
> -  // WaitForSemaphore() may wait for ever if an AP happens to enter
> SMM at
> +  // WaitForAllAPs() may wait for ever if an AP happens to enter SMM
> at
>// exactly this point. Please make sure PcdCpuSmmMaxSyncLoops
> has been set
>// to a large enough value to avoid this situation.
>// Note: For HT capable CPUs, threads within a core share the same
> set of MTRRs.
>// We do the backup first and then set MTRR to avoid race condition
> for threads
>// in the same core.
> @@ -652,11 +696,11 @@ BSPHandler (
>// Let all processors program SMM MTRRs together
>//
>ReleaseAllAPs ();
> 
>//
> -  // WaitForSemaphore() may wait for ever if an AP happens to enter
> SMM at
> +  // WaitForAllAPs() may wait for ever if an AP happens to enter SMM
> at
>// exactly this point. Please make sure PcdCpuSmmMaxSyncLoops
> has been set
>// to a large enough value to avoid this situation.
>//
>ReplaceOSMtrrs (CpuIndex);
> 
> @@ -898,50 +942,50 @@ APHandler (
> 
>if ((SyncMode == SmmCpuSyncModeTradition) ||
> SmmCpuFeaturesNeedConfigureMtrrs ()) {
>  //
>  // Notify BSP of arrival at this point
>  //
> -ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
> +ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run);
>}
> 
>if (SmmCpuFeaturesNeedConfigureMtrrs ()) {
>  //
>  // Wait for the signal from BSP to backup MTRRs
>  //
> -WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run);
> +WaitForBsp (mSmmMpSyncData->CpuData[CpuIndex].Run);
> 
>  //
>  // Backup OS MTRRs
>  //
>  MtrrGetAllMtrrs ();
> 
>  //
>  // Signal BSP the completion of this AP
>  //
> -ReleaseSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
> +ReleaseBsp (mSmmMpSyncData->CpuData[BspIndex].Run);
> 
>  //
>  // Wait for BSP's signal 

Re: [edk2-devel] [PATCH v4 2/8] UefiCpuPkg: Adds SmmCpuSyncLib library class

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Gerd Hoffmann
> ; Kumar, Rahul R 
> Subject: [PATCH v4 2/8] UefiCpuPkg: Adds SmmCpuSyncLib library class
> 
> Intel is planning to provide different SMM CPU Sync implementation
> along with some specific registers to improve the SMI performance,
> hence need SmmCpuSyncLib Library for Intel.
> 
> This patch is to:
> 1.Adds SmmCpuSyncLib Library class in UefiCpuPkg.dec.
> 2.Adds SmmCpuSyncLib.h function declaration header file.
> 
> For the new SmmCpuSyncLib, it provides 3 sets of APIs:
> 
> 1. ContextInit/ContextDeinit/ContextReset:
> ContextInit() is called in driver's entrypoint to allocate and
> initialize the SMM CPU Sync context. ContextDeinit() is called in
> driver's unload function to deinitialize SMM CPU Sync context.
> ContextReset() is called before CPU exist SMI, which allows CPU to
> check into the next SMI from this point.
> 
> 2. GetArrivedCpuCount/CheckInCpu/CheckOutCpu/LockDoor:
> When SMI happens, all processors including BSP enter to SMM mode by
> calling CheckInCpu(). The elected BSP calls LockDoor() so that
> CheckInCpu() will return the error code after that. CheckOutCpu() can
> be called in error handling flow for the CPU who calls CheckInCpu()
> earlier. GetArrivedCpuCount() returns the number of checked-in CPUs.
> 
> 3. WaitForAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
> WaitForAPs() & ReleaseOneAp() are called from BSP to wait the number
> of APs and release one specific AP. WaitForBsp() & ReleaseBsp() are
> called from APs to wait and release BSP. The 4 APIs are used to
> synchronize the running flow among BSP and APs. BSP and AP Sync flow
> can be easy understand as below:
> BSP: ReleaseOneAp  -->  AP: WaitForBsp
> BSP: WaitForAPs<--  AP: ReleaseBsp
> 
> Cc: Laszlo Ersek 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Gerd Hoffmann 
> Cc: Rahul Kumar 
> Signed-off-by: Jiaxin Wu 
> ---
>  UefiCpuPkg/Include/Library/SmmCpuSyncLib.h | 290
> +
>  UefiCpuPkg/UefiCpuPkg.dec  |   3 +
>  2 files changed, 293 insertions(+)
>  create mode 100644 UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
> 
> diff --git a/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
> b/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
> new file mode 100644
> index 00..4d273095c9
> --- /dev/null
> +++ b/UefiCpuPkg/Include/Library/SmmCpuSyncLib.h
> @@ -0,0 +1,290 @@
> +/** @file
> +  Library that provides SMM CPU Sync related operations.
> +
> +  The lib provides 3 sets of APIs:
> +  1. ContextInit/ContextDeinit/ContextReset:
> +
> +ContextInit() is called in driver's entrypoint to allocate and 
> initialize the
> SMM CPU Sync context.
> +ContextDeinit() is called in driver's unload function to deinitialize the
> SMM CPU Sync context.
> +ContextReset() is called by one of CPUs after all CPUs are ready to exit
> SMI, which allows CPU to
> +check into the next SMI from this point.
> +
> +  2. GetArrivedCpuCount/CheckInCpu/CheckOutCpu/LockDoor:
> +When SMI happens, all processors including BSP enter to SMM mode by
> calling CheckInCpu().
> +CheckOutCpu() can be called in error handling flow for the CPU who
> calls CheckInCpu() earlier.
> +The elected BSP calls LockDoor() so that CheckInCpu() and
> CheckOutCpu() will return the error code after that.
> +GetArrivedCpuCount() returns the number of checked-in CPUs.
> +
> +  3. WaitForAPs/ReleaseOneAp/WaitForBsp/ReleaseBsp
> +WaitForAPs() & ReleaseOneAp() are called from BSP to wait the number
> of APs and release one specific AP.
> +WaitForBsp() & ReleaseBsp() are called from APs to wait and release
> BSP.
> +The 4 APIs are used to synchronize the running flow among BSP and
> APs.
> +BSP and AP Sync flow can be easy understand as below:
> +BSP: ReleaseOneAp  -->  AP: WaitForBsp
> +BSP: WaitForAPs<--  AP: ReleaseBsp
> +
> +  Copyright (c) 2023, Intel Corporation. All rights reserved.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef SMM_CPU_SYNC_LIB_H_
> +#define SMM_CPU_SYNC_LIB_H_
> +
> +#include 
> +
> +//
> +// Opaque structure for SMM CPU Sync context.
> +//
> +typedef struct SMM_CPU_SYNC_CONTEXT SMM_CPU_SYNC_CONTEXT;
> +
> +/**
> +  Create and initialize the SMM CPU Sync context. It is to allocate and
> initialize the
> +  SMM CPU Sync context.
> +
> +  If Context is NULL, then ASSERT().
> +
> +  @param[in]  NumberOfCpus  The number of Logical
> Processors in the system.
> +  @param[out] Context   Pointer to the new created and
> initialized SMM CPU Sync context object.
> +NULL will be returned if any
> error happen during init.
> +
> +  @retval RETURN_SUCCESSThe SMM CPU Sync context
> was successful created and initialized.
> +  @retval RETURN_OUT_OF_RESOURCES   

Re: [edk2-devel] [PATCH v4 5/8] OvmfPkg: Specifies SmmCpuSyncLib instance

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Ard Biesheuvel
> ; Yao, Jiewen ; Justen,
> Jordan L ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Kumar, Rahul R
> ; Gerd Hoffmann 
> Subject: [PATCH v4 5/8] OvmfPkg: Specifies SmmCpuSyncLib instance
> 
> This patch is to specify SmmCpuSyncLib instance for OvmfPkg.
> 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Jiewen Yao 
> Cc: Jordan Justen 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Rahul Kumar 
> Cc: Gerd Hoffmann 
> Signed-off-by: Jiaxin Wu 
> ---
>  OvmfPkg/CloudHv/CloudHvX64.dsc | 1 +
>  OvmfPkg/OvmfPkgIa32.dsc| 1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
>  OvmfPkg/OvmfPkgX64.dsc | 1 +
>  4 files changed, 4 insertions(+)
> 
> diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc
> b/OvmfPkg/CloudHv/CloudHvX64.dsc
> index 1660548e07..af594959a9 100644
> --- a/OvmfPkg/CloudHv/CloudHvX64.dsc
> +++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
> @@ -907,10 +907,11 @@
>}
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> 
> SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/
> SmmCpuPlatformHookLibQemu.inf
> 
> SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature
> sLib.inf
> +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
>}
> 
>#
># Variable driver stack (SMM)
>#
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 6e8488007c..28379961a7 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -952,10 +952,11 @@
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> 
> SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/
> SmmCpuPlatformHookLibQemu.inf
> 
> SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature
> sLib.inf
> 
> MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.
> inf
> +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
>}
> 
>#
># Variable driver stack (SMM)
>#
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 413ea71984..5e9eee628a 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -970,10 +970,11 @@
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> 
> SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/
> SmmCpuPlatformHookLibQemu.inf
> 
> SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature
> sLib.inf
> 
> MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.
> inf
> +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
>}
> 
>#
># Variable driver stack (SMM)
>#
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index f92d70..bf4c7906c4 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -1040,10 +1040,11 @@
>UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
>  
> 
> SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/
> SmmCpuPlatformHookLibQemu.inf
> 
> SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeature
> sLib.inf
> 
> MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.
> inf
> +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
>}
> 
>#
># Variable driver stack (SMM)
>#
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH v4 6/8] UefiPayloadPkg: Specifies SmmCpuSyncLib instance

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Guo ;
> Rhodes, Sean ; Lu, James ;
> Guo, Gua ; Ni, Ray ; Zeng, Star
> 
> Subject: [PATCH v4 6/8] UefiPayloadPkg: Specifies SmmCpuSyncLib instance
> 
> This patch is to specify SmmCpuSyncLib instance for UefiPayloadPkg.
> 
> Cc: Laszlo Ersek 
> Cc: Guo Dong 
> Cc: Sean Rhodes 
> Cc: James Lu 
> Cc: Gua Guo 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Signed-off-by: Jiaxin Wu 
> Reviewed-by: Gua Guo 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index a65f9d5b83..b8b13ad201 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -253,10 +253,11 @@
>#
>MtrrLib|UefiCpuPkg/Library/MtrrLib/MtrrLib.inf
> 
> LocalApicLib|UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.in
> f
>MicrocodeLib|UefiCpuPkg/Library/MicrocodeLib/MicrocodeLib.inf
> 
> CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
> +
> SmmCpuSyncLib|UefiCpuPkg/Library/SmmCpuSyncLib/SmmCpuSyncLib.inf
> 
>#
># Platform
>#
>  !if $(CPU_TIMER_LIB_ENABLE) == TRUE && $(UNIVERSAL_PAYLOAD) ==
> TRUE
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH v4 7/8] UefiCpuPkg/PiSmmCpuDxeSmm: Simplify RunningApCount decrement

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Gerd Hoffmann
> ; Kumar, Rahul R 
> Subject: [PATCH v4 7/8] UefiCpuPkg/PiSmmCpuDxeSmm: Simplify
> RunningApCount decrement
> 
> To decrease the count of RunningApCount, InterlockedDecrement is
> enough to achieve that.
> 
> This patch is to simplify RunningApCount decrement.
> 
> Cc: Laszlo Ersek 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Gerd Hoffmann 
> Cc: Rahul Kumar 
> Signed-off-by: Jiaxin Wu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 54542262a2..9b477b6695 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1450,11 +1450,11 @@ InternalSmmStartupAllAPs (
> 
>//
>// Decrease the count to mark this processor(AP or BSP) as finished.
>//
>if (ProcToken != NULL) {
> -WaitForSemaphore (>RunningApCount);
> +InterlockedDecrement (>RunningApCount);
>}
>  }
>}
> 
>ReleaseAllAPs ();
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH v4 8/8] UefiCpuPkg/PiSmmCpuDxeSmm: Consume SmmCpuSyncLib

2023-12-18 Thread Ni, Ray
Reviewed-by: Ray Ni 

Thanks,
Ray
> -Original Message-
> From: Wu, Jiaxin 
> Sent: Friday, December 15, 2023 5:55 PM
> To: devel@edk2.groups.io
> Cc: Laszlo Ersek ; Dong, Eric ; Ni,
> Ray ; Zeng, Star ; Gerd Hoffmann
> ; Kumar, Rahul R 
> Subject: [PATCH v4 8/8] UefiCpuPkg/PiSmmCpuDxeSmm: Consume
> SmmCpuSyncLib
> 
> There is the SmmCpuSyncLib Library class define the SMM CPU sync
> flow, which is aligned with existing SMM CPU driver sync behavior.
> This patch is to consume SmmCpuSyncLib instance directly.
> 
> With this change, SMM CPU Sync flow/logic can be customized
> with different implementation no matter for any purpose, e.g.
> performance tuning, handle specific register, etc.
> 
> Cc: Laszlo Ersek 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Zeng Star 
> Cc: Gerd Hoffmann 
> Cc: Rahul Kumar 
> Signed-off-by: Jiaxin Wu 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c| 274
> +++
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h   |   6 +-
>  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf |   1 +
>  3 files changed, 68 insertions(+), 213 deletions(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 9b477b6695..4fbb0bba87 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -27,122 +27,10 @@ MM_COMPLETION
> mSmmStartupThisApToken;
>  //
>  // Processor specified by mPackageFirstThreadIndex[PackageIndex] will do
> the package-scope register check.
>  //
>  UINT32  *mPackageFirstThreadIndex = NULL;
> 
> -/**
> -  Performs an atomic compare exchange operation to get semaphore.
> -  The compare exchange operation must be performed using
> -  MP safe mechanisms.
> -
> -  @param  SemIN:  32-bit unsigned integer
> - OUT: original integer - 1
> -  @return Original integer - 1
> -
> -**/
> -UINT32
> -WaitForSemaphore (
> -  IN OUT  volatile UINT32  *Sem
> -  )
> -{
> -  UINT32  Value;
> -
> -  for ( ; ;) {
> -Value = *Sem;
> -if ((Value != 0) &&
> -(InterlockedCompareExchange32 (
> -   (UINT32 *)Sem,
> -   Value,
> -   Value - 1
> -   ) == Value))
> -{
> -  break;
> -}
> -
> -CpuPause ();
> -  }
> -
> -  return Value - 1;
> -}
> -
> -/**
> -  Performs an atomic compare exchange operation to release semaphore.
> -  The compare exchange operation must be performed using
> -  MP safe mechanisms.
> -
> -  @param  SemIN:  32-bit unsigned integer
> - OUT: original integer + 1
> -  @return Original integer + 1
> -
> -**/
> -UINT32
> -ReleaseSemaphore (
> -  IN OUT  volatile UINT32  *Sem
> -  )
> -{
> -  UINT32  Value;
> -
> -  do {
> -Value = *Sem;
> -  } while (Value + 1 != 0 &&
> -   InterlockedCompareExchange32 (
> - (UINT32 *)Sem,
> - Value,
> - Value + 1
> - ) != Value);
> -
> -  return Value + 1;
> -}
> -
> -/**
> -  Performs an atomic compare exchange operation to lock semaphore.
> -  The compare exchange operation must be performed using
> -  MP safe mechanisms.
> -
> -  @param  SemIN:  32-bit unsigned integer
> - OUT: -1
> -  @return Original integer
> -
> -**/
> -UINT32
> -LockdownSemaphore (
> -  IN OUT  volatile UINT32  *Sem
> -  )
> -{
> -  UINT32  Value;
> -
> -  do {
> -Value = *Sem;
> -  } while (InterlockedCompareExchange32 (
> - (UINT32 *)Sem,
> - Value,
> - (UINT32)-1
> - ) != Value);
> -
> -  return Value;
> -}
> -
> -/**
> -  Used for BSP to wait all APs.
> -  Wait all APs to performs an atomic compare exchange operation to release
> semaphore.
> -
> -  @param   NumberOfAPs  AP number
> -
> -**/
> -VOID
> -WaitForAllAPs (
> -  IN  UINTN  NumberOfAPs
> -  )
> -{
> -  UINTN  BspIndex;
> -
> -  BspIndex = mSmmMpSyncData->BspIndex;
> -  while (NumberOfAPs-- > 0) {
> -WaitForSemaphore (mSmmMpSyncData->CpuData[BspIndex].Run);
> -  }
> -}
> -
>  /**
>Used for BSP to release all APs.
>Performs an atomic compare exchange operation to release semaphore
>for each AP.
> 
> @@ -154,57 +42,15 @@ ReleaseAllAPs (
>  {
>UINTN  Index;
> 
>for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
>  if (IsPresentAp (Index)) {
> -  ReleaseSemaphore (mSmmMpSyncData->CpuData[Index].Run);
> +  SmmCpuSyncReleaseOneAp (mSmmMpSyncData->SyncContext,
> Index, gSmmCpuPrivate->SmmCoreEntryContext.CurrentlyExecutingCpu);
>  }
>}
>  }
> 
> -/**
> -  Used for BSP to release one AP.
> -
> -  @param  ApSem IN:  32-bit unsigned integer
> -OUT: original integer + 1
> -**/
> -VOID
> -ReleaseOneAp   (
> -  IN OUT  volatile UINT32  *ApSem
> -  )
> -{
> -  ReleaseSemaphore (ApSem);
> -}
> -
> -/**
> -  Used for AP to wait BSP.
> -
> -  @param  ApSem  IN:  32-bit unsigned integer
> - OUT: original integer 

Re: [edk2-devel] [edk2-redfish-client][PATCH v2 3/3] RedfishClientPkg: fix access to unitialized variable.

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Reviewed-by: Abner Chang 

> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 9:00 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; nick...@nvidia.com;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH v2 3/3] RedfishClientPkg: fix access to
> unitialized variable.
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> It is possible that at the time of accessing to AsciiLocation pointer
> the memory is not allocated.
>
> Also gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) emits a warning for
> this case:
>
> RedfishFeatureUtilityLib.c:1889:37: error: 'AsciiLocation' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
>*Location = StrAsciiToUnicode (AsciiLocation);
>
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Signed-off-by: Mike Maslenkin 
> Reviewed-by: Nickle Wang 
>
> ---
>  .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c| 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> index 0f0b050d7eba..01c054ae3b70 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> +++
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> @@ -1856,7 +1856,8 @@ GetEtagAndLocation (
>}
>
>
>
>if (Location != NULL) {
>
> -*Location = NULL;
>
> +*Location = NULL;
>
> +AsciiLocation = NULL;
>
>
>
>  if (*(Response->StatusCode) == HTTP_STATUS_200_OK) {
>
>Header = HttpFindHeader (Response->HeaderCount, Response->Headers,
> HTTP_HEADER_LOCATION);
>
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH v2 1/3] RedfishClientPkg: add check for NULL pointer to avoid ASSERT

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Reviewed-by: Abner Chang 

> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 9:00 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; nick...@nvidia.com;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH v2 1/3] RedfishClientPkg: add check for
> NULL pointer to avoid ASSERT
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Initially RedfishPlatformConfigGetConfigureLang could return success
> even if ConfigureLangList is empty. After fixing this condition,
> RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't
> help to avoid ASSERT because the error path is the same as for non-empty
> list.
>
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Signed-off-by: Mike Maslenkin 
> Reviewed-by: Nickle Wang 
> ---
>  .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c   | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> index 4cb7621c25c4..0f0b050d7eba 100644
> ---
> a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> +++
> b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.
> c
> @@ -3118,7 +3118,9 @@ LeaveFunction:
>  FreePool (ConfigureLangBuffer);
>
>}
>
>
>
> -  FreePool (ConfigureLangList);
>
> +  if (ConfigureLangList != NULL) {
>
> +FreePool (ConfigureLangList);
>
> +  }
>
>
>
>*NumberOfValues = (UINT32)ListCount;
>
>return FirstEmptyPropKeyValueList;
>
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH v2 2/3] RedfishClientPkg: fix typo in EfiRestJsonStructureProtocolIsReady

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Reviewed-by: Abner Chang 

> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 9:00 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; nick...@nvidia.com;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH v2 2/3] RedfishClientPkg: fix typo in
> EfiRestJsonStructureProtocolIsReady
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Signed-off-by: Mike Maslenkin 
> Reviewed-by: Nickle Wang 
>
> ---
>  RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> index 8b9bdc313832..85dc546120e2 100644
> --- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> +++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
> @@ -562,7 +562,7 @@ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL
> mRedfishConfigHandler = {
>  **/
>
>  VOID
>
>  EFIAPI
>
> -EfiRestJasonStructureProtocolIsReady (
>
> +EfiRestJsonStructureProtocolIsReady (
>
>IN  EFI_EVENT  Event,
>
>IN  VOID   *Context
>
>)
>
> @@ -829,7 +829,7 @@ RedfishResourceEntryPoint (
>EfiCreateProtocolNotifyEvent (
>
>  ,
>
>  TPL_CALLBACK,
>
> -EfiRestJasonStructureProtocolIsReady,
>
> +EfiRestJsonStructureProtocolIsReady,
>
>  NULL,
>
>  
>
>  );
>
> --
> 2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [edk2-redfish-client][PATCH v2 0/3] change method for provisioning + minor fixes

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Yes,  Copyright (c)  2023, Contributor   is good for 
you now.

Abner


> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 10:40 AM
> To: Chang, Abner 
> Cc: devel@edk2.groups.io; nick...@nvidia.com; ig...@ami.com
> Subject: Re: [edk2-redfish-client][PATCH v2 0/3] change method for
> provisioning + minor fixes
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> Hi Abner,
>
> Ok. I've already done it. But copyright change mentioned is for
> another patchset to edk2's RedfishPkg.
> Whereas you mentioned  FIRST - LAST, would you like me to add
> copyrights for these changes?
> I guess LAST is not required for the new added code.
> I didn't add any copyrights previously,  so for my case it would be:
> Copyright (c)  2023, Contributor  
> in any place.
>
> Regard,
> Mike.
>
>
>
> On Tue, Dec 19, 2023 at 5:04 AM Chang, Abner 
> wrote:
> >
> > [AMD Official Use Only - General]
> >
> > Hi Mike,
> > According the conversation I had with Rebecca, please update your
> copyright that follow below format on the later patches you send; as you use
> the individual contributor copyright.
> >
> > Copyright (c) FIRST - LAST, Contributor  
> >
> > Thanks
> > Abner
> >
> > > -Original Message-
> > > From: Mike Maslenkin 
> > > Sent: Tuesday, December 19, 2023 9:00 AM
> > > To: devel@edk2.groups.io
> > > Cc: Chang, Abner ; nick...@nvidia.com;
> > > ig...@ami.com; Mike Maslenkin 
> > > Subject: [edk2-redfish-client][PATCH v2 0/3] change method for
> provisioning
> > > + minor fixes
> > >
> > > Caution: This message originated from an External Source. Use proper
> caution
> > > when opening attachments, clicking links, or responding.
> > >
> > >
> > > This patch set contains minor fixes.
> > >
> > > diff from v1:
> > >  original patch 4/4 with change related to BIOS resources provisioning
> > > removed.
> > >
> > > PR: https://github.com/tianocore/edk2-redfish-client/pull/64
> > >
> > > Cc: Abner Chang 
> > > Cc: Igor Kulchytskyy 
> > > Cc: Nickle Wang 
> > > Signed-off-by: Mike Maslenkin 
> >


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




[edk2-devel] [Resend PATCH v4 4/4] DynamicTablesPkg: AML Code generation to invoke a method

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Adds API to generate AML code to invoke/call another
method. Also provides ability to pass arguments of
type integer, string, ArgObj or LocalObj.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
---
 .../Include/Library/AmlLib/AmlLib.h   | 112 +
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 236 +-
 2 files changed, 347 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index eb8740692f..fb16637f02 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -101,6 +101,56 @@ typedef enum {
   AmlAddressRangeMax  = 4
 } AML_MEMORY_ATTRIBUTES_MTP;
 
+/** Method parameter types
+
+  Possible values are:
+0 - AmlMethodParamTypeInteger
+1 - AmlMethodParamTypeString
+2 - AmlMethodParamTypeArg
+3 - AmlMethodParamTypeLocal
+
+  @par Reference(s)
+  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
+
+**/
+typedef enum {
+  AmlMethodParamTypeInteger = 0,
+  AmlMethodParamTypeString  = 1,
+  AmlMethodParamTypeArg = 2,
+  AmlMethodParamTypeLocal   = 3
+} AML_METHOD_PARAM_TYPE;
+
+/** AML Method parameter data
+  holds the AML method parameter data.
+**/
+typedef union {
+  UINT8 Arg;
+  UINT8 Local;
+  UINT64Integer;
+  VOID  *Buffer;
+} AML_METHOD_PARAM_DATA;
+
+/** structure to hold AML method parameter types
+  Type  -   Type of parameter
+  Data  -   holds data of parameter
+if Type is AmlMethodParamTypeInteger
+  then Data is of type Integer to hold integer value.
+if Type is AmlMethodParamTypeString
+  then Data contains null terminated string.
+If Type is AmlMethodParamTypeArg
+  then Data contains the Argument number,
+  0 to 6 are supported value.
+If Type is AmlMethodParamTypeLocal
+  then Data contains the Local variable number,
+  0 to 7 are supported value.
+  DataSize - for future use
+**/
+typedef struct {
+  AML_METHOD_PARAM_TYPEType;
+  AML_METHOD_PARAM_DATAData;
+  UINTNDataSize;
+} AML_METHOD_PARAM;
+
 /** Parse the definition block.
 
   The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
@@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage (
   IN AML_OBJECT_NODE_HANDLE  NamedNode
   );
 
+/** AML code generation to invoke/call another method.
+
+  This method is subset implementation of MethodInvocation
+  defined in the ACPI specification 6.5,
+  section 20.2.5 "Term Objects Encoding".
+  Added integer, string, ArgObj and LocalObj support.
+
+  Example 1:
+AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
+is equivalent of the following ASL code:
+  MET0 ();
+
+  Example 2:
+AML_METHOD_PARAM  Param[4];
+Param[0].Data.Integer = 0x100;
+Param[0].Type = AmlMethodParamTypeInteger;
+Param[1].Data.Buffer = "TEST";
+Param[1].Type = AmlMethodParamTypeString;
+Param[2].Data.Arg = 0;
+Param[2].Type = AmlMethodParamTypeArg;
+Param[3].Data.Local = 2;
+Param[3].Type = AmlMethodParamTypeLocal;
+AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
+
+is equivalent of the following ASL code:
+  MET0 (0x100, "TEST", Arg0, Local2);
+
+  Example 3:
+AML_METHOD_PARAM  Param[2];
+Param[0].Data.Arg = 0;
+Param[0].Type = AmlMethodParamTypeArg;
+Param[1].Data.Integer = 0x100;
+Param[1].Type = AmlMethodParamTypeInteger;
+AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, 
);
+AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
+
+is equivalent of the following ASL code:
+Method (MET2, 2, Serialized)
+{
+  MET3 (Arg0, 0x0100)
+}
+
+  @param [in] MethodNameString  Method name to be called/invoked.
+  @param [in] NumArgs   Number of arguments to be passed,
+0 to 7 are permissible values.
+  @param [in] Parameterscontains the parameter data.
+  @param [in] ParentNodeset ParentNode as the parent
+of the node created.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+ **/
+EFI_STATUS
+EFIAPI
+AmlCodeGenInvokeMethod (
+  IN  CONST CHAR8 *MethodNameString,
+  INUINT8 NumArgs,
+  INAML_METHOD_PARAM  *Parameters   OPTIONAL,
+  INAML_NODE_HANDLE   ParentNode
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a6db34fb97..688eefdcef 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -2,6 +2,7 @@
   AML Code 

[edk2-devel] [Resend PATCH v4 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the function pointer typedef AML_PARSE_FUNCTION,
otherwise some compiler like VS2019 gives error.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c 
b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
index 8e584d4930..d3a51a94c7 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
@@ -100,8 +100,7 @@ AmlParseStream (
 **/
 typedef
 EFI_STATUS
-EFIAPI
-(*AML_PARSE_FUNCTION) (
+(EFIAPI *AML_PARSE_FUNCTION)(
   IN  CONST AML_NODE_HEADER   *Node,
   INAML_PARSE_FORMAT  ExpectedFormat,
   IN  OUT   AML_STREAM*FStream,
-- 
2.34.1



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




[edk2-devel] [Resend PATCH v4 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the parameters of AmlCodeGenRdWordBusNumber() to
UINT16 to generate word bus number.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h   | 10 +-
 .../Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 5e340b94ce..eb8740692f 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -714,11 +714,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 60fe69ba6d..46243f981c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -848,11 +848,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
-- 
2.34.1



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




[edk2-devel] [Resend PATCH v4 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Add helper functions to generate AML resource data
for word I/O.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 .../Include/Library/AmlLib/AmlLib.h   | 65 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 88 +++
 2 files changed, 153 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 71e8539b30..5e340b94ce 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -2,6 +2,7 @@
   AML Lib.
 
   Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -724,6 +725,70 @@ AmlCodeGenRdWordBusNumber (
   OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
   );
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  IsMinFixed   Minimum address is fixed.
+  @param [in]  IsMaxFixed   Maximum address is fixed.
+  @param [in]  IsPosDecode  Decode parameter
+  @param [in]  IsaRangesPossible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+  @param [in]  AddressGranularity   Address granularity.
+  @param [in]  AddressMinimum   Minimum address.
+  @param [in]  AddressMaximum   Maximum address.
+  @param [in]  AddressTranslation   Address translation.
+  @param [in]  RangeLength  Range length.
+  @param [in]  ResourceSourceIndex  Resource Source index.
+Not supported. Must be 0.
+  @param [in]  ResourceSource   Resource Source.
+Not supported. Must be NULL.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter.
+  @param [in]  IsTypeStatic TranslationType parameter.
+  @param [in]  NameOpNode   NameOp object node defining a named object.
+If provided, append the new resource data
+node to the list of resource data elements
+of this node.
+  @param [out] NewRdNodeIf provided and success,
+contain the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdWordIo (
+  INBOOLEAN IsResourceConsumer,
+  INBOOLEAN IsMinFixed,
+  INBOOLEAN IsMaxFixed,
+  INBOOLEAN IsPosDecode,
+  INUINT8 IsaRanges,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
+  INUINT8 ResourceSourceIndex,
+  IN  CONST CHAR8 *ResourceSource,
+  INBOOLEAN IsDenseTranslation,
+  INBOOLEAN IsTypeStatic,
+  INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+  OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "QWordIO ()" ASL function.
 
   The Resource Data effectively created is a QWord Address Space Resource
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bc1c1d119..60fe69ba6d 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -2,6 +2,7 @@
   AML Resource Data Code Generation.
 
   Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -878,6 +879,93 @@ AmlCodeGenRdWordBusNumber (
);
 }
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data 

[edk2-devel] [Resend PATCH v4 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

PR: https://github.com/tianocore/edk2/pull/5157

Resending patch with CI failure fix and added example.

V4: delta changes
  Address Pierre's review comments.
  Merged patch 4 & patch 5.
  Also added parameter logic suggested by Pierre.
V3: delta changes
  CI fix and error handling for 
DynamicTablesPkg: Adds API to generate a method with ArgN.
  Added new patch "DynamicTablesPkg: Adds wrapper API 
AmlCodeGenMethodInvokeMethodArgn"
V2:
  Added new API to generate a method which
  invokes another method with argument.
V1:
Code changes to
Add API to generate word I/O ranges.
Correct the parameter to generate word bus number.
Corrects the function pointer typedef

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Cc: Abdul Lateef Attar 

Abdul Lateef Attar (4):
  DynamicTablesPkg: AML Code generation for word I/O ranges
  DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  DynamicTablesPkg: Corrects function pointer typedef of
AML_PARSE_FUNCTION
  DynamicTablesPkg: AML Code generation to invoke a method

 .../Include/Library/AmlLib/AmlLib.h   | 187 +-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 236 +-
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++-
 .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
 4 files changed, 511 insertions(+), 13 deletions(-)

-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112668): https://edk2.groups.io/g/devel/message/112668
Mute This Topic: https://groups.io/mt/103256858/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 14/14] RedfishPkg: RedfishDiscoverDxe: add [] brackets to URI for IPv6 addresses

2023-12-18 Thread Mike Maslenkin
Hi Abner,

On Mon, Dec 18, 2023 at 7:58 AM Chang, Abner  wrote:
>
> [AMD Official Use Only - General]
>
> > -Original Message-
> > From: Mike Maslenkin 
> > Sent: Friday, December 15, 2023 7:25 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner ; nick...@nvidia.com;
> > ig...@ami.com; Mike Maslenkin 
> > Subject: [PATCH v2 14/14] RedfishPkg: RedfishDiscoverDxe: add [] brackets to
> > URI for IPv6 addresses
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > URI is generated based on the RedfishLocation containing an ASCII string
> > representing the IP address. So, in the case of IPv4 the canonical
> > representation of an IPv4 address was inserted into the resulting Unicode
> > string i.e: "http{,s}://X.X.X.X/".
> >
> > In the case of IPv6, to access resources, the IP address must be specified
> > in brackets, i.e. the resulting string should look like:
> >   "http{,s}://[X::X:X:X:X]/".
> >
> > Cc: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Signed-off-by: Mike Maslenkin 
> > ---
> >  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 21 ---
> >  1 file changed, 18 insertions(+), 3 deletions(-)
> >
> > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > index 9d1678c3429e..38eaf4f6decc 100644
> > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > @@ -715,6 +715,7 @@ DiscoverRedfishHostInterface (
> >The function initalizes particular strings into
> > EFI_REDFISH_DISCOVERED_INFORMATION structure
> >
> >
> >
> >@param[in]  Information   EFI_REDFISH_DISCOVERED_INFORMATION
> >
> > +  @param[in]  IsIpv6Flag indicating IP version 6 protocol 
> > is used
> >
> >@param[in]  RedfishVersionRedfish version.
> >
> >@param[in]  RedfishLocation   Redfish location.
> >
> >@param[in]  Uuid  Service UUID string.
> >
> > @@ -729,6 +730,7 @@ STATIC
> >  VOID
> >
> >  InitInformationData (
> >
> >IN EFI_REDFISH_DISCOVERED_INFORMATION  *Information,
> >
> > +  IN BOOLEAN IsIpv6,
> >
> >IN UINTN   *RedfishVersion OPTIONAL,
> >
> >IN CONST CHAR8 *RedfishLocation OPTIONAL,
> >
> >IN CONST CHAR8 *Uuid OPTIONAL,
> >
> > @@ -738,7 +740,8 @@ InitInformationData (
> >IN CONST CHAR8 *ProductVer OPTIONAL
> >
> >)
> >
> >  {
> >
> > -  UINTN  AllocationSize;
> >
> > +  UINTNAllocationSize;
> >
> > +  CONST CHAR8  *IpAddress;
> >
> >
> >
> >if (RedfishVersion != NULL) {
> >
> >  Information->RedfishVersion = *RedfishVersion;
> >
> > @@ -746,10 +749,21 @@ InitInformationData (
> >}
> >
> >
> >
> >if (RedfishLocation != NULL) {
> >
> > -AllocationSize= AsciiStrSize (RedfishLocation) * sizeof 
> > (CHAR16);
> >
> > +AllocationSize = AsciiStrSize (RedfishLocation) * sizeof (CHAR16);
> >
> > +IpAddress  = RedfishLocation;
> Not quite understand why do we need a copy of RedfishLocation in IpAddress?
> I think we can use RedfishLocation for UnicodeSPrintAsciiFormat later, right?

I'll remove IpAddress variable.
It was added into initial RFC as a minimal change reducing a number of
type casts.
It was also added as self-describing code to show we are supposed to
be dealing with RedfishLocation in IP address string format and not
anything else.

> Thanks
> Abner
>
> >
> > +
> >
> > +if (IsIpv6) {
> >
> > +  AllocationSize += 2 * sizeof (CHAR16); // take into account '[' and 
> > ']'
> >
> > +}
> >
> > +
> >
> >  Information->Location = AllocatePool (AllocationSize);
> >
> >  if (Information->Location != NULL) {
> >
> > -  AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > AllocationSize);
> >
> > +  if (IsIpv6) {
> >
> > +UnicodeSPrintAsciiFormat (Information->Location, AllocationSize,
> > "[%a]", IpAddress);
> >
> > +  } else {
> >
> > +AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > AllocationSize);
> >
> > +  }
> >
> > +
> >
> >DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> > Information->Location));
> >
> >  } else {
> >
> >DEBUG ((
> >
> > @@ -991,6 +1005,7 @@ AddAndSignalNewRedfishService (
> >
> >
> >  InitInformationData (
> >
> >>Information,
> >
> > +  CheckIsIpVersion6 (NetworkInterface),
> >
> >RedfishVersion,
> >
> >RedfishLocation,
> >
> >Uuid,
> >
> > --
> > 2.32.0 (Apple Git-132)
>


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

Re: [edk2-devel] [edk2-redfish-client][PATCH v2 0/3] change method for provisioning + minor fixes

2023-12-18 Thread Mike Maslenkin
Hi Abner,

Ok. I've already done it. But copyright change mentioned is for
another patchset to edk2's RedfishPkg.
Whereas you mentioned  FIRST - LAST, would you like me to add
copyrights for these changes?
I guess LAST is not required for the new added code.
I didn't add any copyrights previously,  so for my case it would be:
Copyright (c)  2023, Contributor  
in any place.

Regard,
Mike.



On Tue, Dec 19, 2023 at 5:04 AM Chang, Abner  wrote:
>
> [AMD Official Use Only - General]
>
> Hi Mike,
> According the conversation I had with Rebecca, please update your copyright 
> that follow below format on the later patches you send; as you use the 
> individual contributor copyright.
>
> Copyright (c) FIRST - LAST, Contributor  
>
> Thanks
> Abner
>
> > -Original Message-
> > From: Mike Maslenkin 
> > Sent: Tuesday, December 19, 2023 9:00 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner ; nick...@nvidia.com;
> > ig...@ami.com; Mike Maslenkin 
> > Subject: [edk2-redfish-client][PATCH v2 0/3] change method for provisioning
> > + minor fixes
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > This patch set contains minor fixes.
> >
> > diff from v1:
> >  original patch 4/4 with change related to BIOS resources provisioning
> > removed.
> >
> > PR: https://github.com/tianocore/edk2-redfish-client/pull/64
> >
> > Cc: Abner Chang 
> > Cc: Igor Kulchytskyy 
> > Cc: Nickle Wang 
> > Signed-off-by: Mike Maslenkin 
>


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




[edk2-devel] Event: TianoCore Bug Triage - APAC / NAMO - Tuesday, December 19, 2023 #cal-reminder

2023-12-18 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

*When:*
Tuesday, December 19, 2023
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=2138175 )

*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 (#112665): https://edk2.groups.io/g/devel/message/112665
Mute This Topic: https://groups.io/mt/103256394/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]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation error conditions.

2023-12-18 Thread Mike Maslenkin
Hi Abner,

On Mon, Dec 18, 2023 at 7:47 AM Chang, Abner  wrote:
>
> [AMD Official Use Only - General]
>
> > -Original Message-
> > From: Mike Maslenkin 
> > Sent: Friday, December 15, 2023 7:25 AM
> > To: devel@edk2.groups.io
> > Cc: Chang, Abner ; nick...@nvidia.com;
> > ig...@ami.com; Mike Maslenkin 
> > Subject: [PATCH v2 13/14] RedfishDiscoverDxe: handle memory allocation
> > error conditions.
> >
> > Caution: This message originated from an External Source. Use proper caution
> > when opening attachments, clicking links, or responding.
> >
> >
> > Cc: Abner Chang 
> > Cc: Nickle Wang 
> > Cc: Igor Kulchytskyy 
> > Signed-off-by: Mike Maslenkin 
> > ---
> >  .../RedfishDiscoverDxe/RedfishDiscoverDxe.c   | 85 ---
> >  1 file changed, 75 insertions(+), 10 deletions(-)
> >
> > diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > index 3499a855570c..9d1678c3429e 100644
> > --- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > +++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
> > @@ -748,38 +748,103 @@ InitInformationData (
> >if (RedfishLocation != NULL) {
> >
> >  AllocationSize= AsciiStrSize (RedfishLocation) * sizeof 
> > (CHAR16);
> >
> >  Information->Location = AllocatePool (AllocationSize);
> >
> > -AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > AllocationSize);
> >
> > -DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> > Information->Location));
> >
> > +if (Information->Location != NULL) {
> >
> > +  AsciiStrToUnicodeStrS (RedfishLocation, Information->Location,
> > AllocationSize);
> >
> > +  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service location: %s.\n",
> > Information->Location));
> >
> > +} else {
> >
> > +  DEBUG ((
> >
> > +DEBUG_ERROR,
> >
> > +"%a: Can not allocate memory for Redfish service location: %a.\n",
> >
> > +__func__,
> >
> > +RedfishLocation
> >
> > +));
> >
> > +}
> >
> >}
> >
> >
> >
> >if (Uuid != NULL) {
> >
> >  AllocationSize= AsciiStrSize (Uuid) * sizeof (CHAR16);
> >
> >  Information->Uuid = AllocatePool (AllocationSize);
> >
> > -AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
> >
> > -DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information-
> > >Uuid));
> >
> > +if (Information->Uuid != NULL) {
> >
> > +  AsciiStrToUnicodeStrS (Uuid, Information->Uuid, AllocationSize);
> >
> > +  DEBUG ((DEBUG_MANAGEABILITY, "Service UUID: %s.\n", Information-
> > >Uuid));
> >
> > +} else {
> >
> > +  DEBUG ((
> >
> > +DEBUG_ERROR,
> >
> > +"%a: Can not allocate memory for Service UUID: %a.\n",
> >
> > +__func__,
> >
> > +Uuid
> >
> > +));
> >
> > +}
> >
> >}
> >
> >
> >
> >if (Os != NULL) {
> >
> >  AllocationSize  = AsciiStrSize (Os) * sizeof (CHAR16);
> >
> >  Information->Os = AllocatePool (AllocationSize);
> >
> > -AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
> >
> > +if (Information->Os != NULL) {
> >
> > +  AsciiStrToUnicodeStrS (Os, Information->Os, AllocationSize);
> >
> > +} else {
> >
> > +  DEBUG ((
> >
> > +DEBUG_ERROR,
> >
> > +"%a: Can not allocate memory for Redfish service OS: %a.\n",
> >
> > +__func__,
> >
> > +Os
> >
> > +));
> >
> > +}
> >
> >}
> >
> >
> >
> >if (OsVer != NULL) {
> >
> >  AllocationSize = AsciiStrSize (OsVer) * sizeof (CHAR16);
> >
> >  Information->OsVersion = AllocatePool (AllocationSize);
> >
> > -AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, AllocationSize);
> >
> > -DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s, Version:%s.\n",
> > Information->Os, Information->OsVersion));
> >
> > +if (Information->OsVersion != NULL) {
> >
> > +  AsciiStrToUnicodeStrS (OsVer, Information->OsVersion, 
> > AllocationSize);
> >
> > +  DEBUG ((
> >
> > +DEBUG_MANAGEABILITY,
> >
> > +"Redfish service OS: %s, Version:%s.\n",
>
> Jus a note here:  We expect the debug message will be  for the 
> case when Information->Os is NULL.

Not sure I understood right, but there is no problem with this at this time.
But I see this patch is bad.
1. Did original code print OsVer correctly at all?

There were two conditions:

if (Os != NULL) {
  DiscoveredInstance->Information.Os = (CHAR16 *)AllocatePool
(AsciiStrSize ((const CHAR8 *)Os) * sizeof (CHAR16));
  AsciiStrToUnicodeStrS ((const CHAR8 *)Os,
DiscoveredInstance->Information.Os, AsciiStrSize ((const CHAR8 *)Os) *
sizeof (CHAR16));
  DEBUG ((DEBUG_MANAGEABILITY, "Redfish service OS: %s,
Version:%s.\n", DiscoveredInstance->Information.Os,
DiscoveredInstance->Information.OsVersion));
}

if (OsVer != NULL) {
  DiscoveredInstance->Information.OsVersion = (CHAR16
*)AllocatePool 

Re: [edk2-devel] [edk2-redfish-client][PATCH v2 0/3] change method for provisioning + minor fixes

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hi Mike,
According the conversation I had with Rebecca, please update your copyright 
that follow below format on the later patches you send; as you use the 
individual contributor copyright.

Copyright (c) FIRST - LAST, Contributor  

Thanks
Abner

> -Original Message-
> From: Mike Maslenkin 
> Sent: Tuesday, December 19, 2023 9:00 AM
> To: devel@edk2.groups.io
> Cc: Chang, Abner ; nick...@nvidia.com;
> ig...@ami.com; Mike Maslenkin 
> Subject: [edk2-redfish-client][PATCH v2 0/3] change method for provisioning
> + minor fixes
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> This patch set contains minor fixes.
>
> diff from v1:
>  original patch 4/4 with change related to BIOS resources provisioning
> removed.
>
> PR: https://github.com/tianocore/edk2-redfish-client/pull/64
>
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nickle Wang 
> Signed-off-by: Mike Maslenkin 



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


--- Begin Message ---
Hmm, ok, thanks Rebecca.
So that would be:
Copyright (c) FIRST - LAST, Contributor  

Thanks
Abner


> -Original Message-
> From: Rebecca Cran 
> Sent: Monday, December 18, 2023 1:37 PM
> To: devel@edk2.groups.io; Chang, Abner 
> Subject: Re: [edk2-devel] Copyright for an individual contributor
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On 12/17/23 20:01, Chang, Abner via groups.io wrote:
> >
> > [AMD Official Use Only - General]
> >
> >
> > Hi all,
> >
> > How do we have the copyright for the contribution from an individual?
> > I don’t see the formatting defined in edk2 C coding standard. Is the
> > below format ok?
> >
> > Copyright (c) 2023, Contributor 
> >
>
> I think to follow the style guide, it should have a "" at the end,
> though most files with copyrights from individuals don't have that.
>
>
> --
>
> Rebecca Cran

--- End Message ---


Re: [edk2-devel] [PATCH v4 12/37] UefiCpuPkg: Add CpuMmuLib.h to UefiCpuPkg

2023-12-18 Thread Chao Li

Hi Ray,

For the GetMemoryRegionAttributes, here are some of my plans:


Thanks,
Chao
On 2023/12/14 10:53, Chao Li wrote:

Hi Ray,

For you two comments:

BTY, can you review the other UefiCpuPkg patches in this series?

On 2023/12/13 下午1:17, Ni, Ray wrote:

Chao,
Thanks for providing such a cleaner lib API.
Only 2 comments in below:


+
+#define EFI_MEMORY_CACHETYPE_MASK  (EFI_MEMORY_UC  | \
+    EFI_MEMORY_WC  | \
+    EFI_MEMORY_WT  | \
+    EFI_MEMORY_WB  | \
+    EFI_MEMORY_UCE   \
+    )

1. Why do you need to define the EFI_MEMORY_CACHETYPE_MASK here?
Can you just mention that the following APIs only return 5 bits: 
UC/WC/WT/WB/UCE

without defining the EFI_MEMORY_CACHETYPE_MASK?
Agree, I will remove this definition in V5 and if someone uses this 
macro, it will be private.



+
+typedef struct {
+  EFI_PHYSICAL_ADDRESS    PhysicalBase;
+  EFI_VIRTUAL_ADDRESS VirtualBase;
+  UINTN   Length;
+  UINTN   Attributes;
+} MEMORY_REGION_DESCRIPTOR;
+
+/**
+  Finds the length and memory properties of the memory region
corresponding to the specified base address.
+
+  @param[in]  BaseAddress    To find the base address of the memory
region.
+  @param[in]  EndAddress To find the end address of the memory
region.
+  @param[out]  RegionLength    The length of the memory region
found.
+  @param[out]  RegionAttributes    Properties of the memory region
found.
+
+  @retval  EFI_SUCCESS    The corresponding memory area was
successfully found
+   EFI_NOT_FOUND    No memory area found
+**/
+EFI_STATUS
+EFIAPI
+GetMemoryRegionAttributes (
+  IN UINTN  BaseAddress,
+  IN UINTN  EndAddress,
+  OUT    UINTN  *RegionLength,
+  OUT    UINTN  *RegionAttributes
+  );

2. If the actual memory ranges are as follows:
[0 - 1M, UC]
[1M - 1G, WB]

What's the result of following call:
a. GetMemoryRegionAttributes (512KB, 1MB)
b. GetMemoryRegionAttributes (512KB, 2MB)
Yes, if the given memory region has two or more types of attributes, 
this API may return the first attribute, I should design this API 
again, thanks.


For this API, I think there may be two options:

*Plan A:*

It will return all of the attributes and lengths located in the region. 
We need to return a pointer to a structure that records the attributes 
and length of each part.


*Plan B:*

It only returns the attribute and length of the first part, leaving it 
up to the caller to decide to look for the next part.



I'm leaning toward plan B, what do you think?
















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




Re: [edk2-devel] Copyright for an individual contributor

2023-12-18 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hmm, ok, thanks Rebecca.
So that would be:
Copyright (c) FIRST - LAST, Contributor  

Thanks
Abner


> -Original Message-
> From: Rebecca Cran 
> Sent: Monday, December 18, 2023 1:37 PM
> To: devel@edk2.groups.io; Chang, Abner 
> Subject: Re: [edk2-devel] Copyright for an individual contributor
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> On 12/17/23 20:01, Chang, Abner via groups.io wrote:
> >
> > [AMD Official Use Only - General]
> >
> >
> > Hi all,
> >
> > How do we have the copyright for the contribution from an individual?
> > I don’t see the formatting defined in edk2 C coding standard. Is the
> > below format ok?
> >
> > Copyright (c) 2023, Contributor 
> >
>
> I think to follow the style guide, it should have a "" at the end,
> though most files with copyrights from individuals don't have that.
>
>
> --
>
> Rebecca Cran



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




[edk2-devel] [edk2-redfish-client][PATCH v2 3/3] RedfishClientPkg: fix access to unitialized variable.

2023-12-18 Thread Mike Maslenkin
It is possible that at the time of accessing to AsciiLocation pointer
the memory is not allocated.

Also gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) emits a warning for
this case:

RedfishFeatureUtilityLib.c:1889:37: error: 'AsciiLocation' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
   *Location = StrAsciiToUnicode (AsciiLocation);

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
Reviewed-by: Nickle Wang 

---
 .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c| 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 0f0b050d7eba..01c054ae3b70 100644
--- 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -1856,7 +1856,8 @@ GetEtagAndLocation (
   }
 
   if (Location != NULL) {
-*Location = NULL;
+*Location = NULL;
+AsciiLocation = NULL;
 
 if (*(Response->StatusCode) == HTTP_STATUS_200_OK) {
   Header = HttpFindHeader (Response->HeaderCount, Response->Headers, 
HTTP_HEADER_LOCATION);
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH v2 2/3] RedfishClientPkg: fix typo in EfiRestJsonStructureProtocolIsReady

2023-12-18 Thread Mike Maslenkin
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
Reviewed-by: Nickle Wang 

---
 RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c 
b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
index 8b9bdc313832..85dc546120e2 100644
--- a/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
+++ b/RedfishClientPkg/Features/Bios/v1_0_9/Dxe/BiosDxe.c
@@ -562,7 +562,7 @@ EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  
mRedfishConfigHandler = {
 **/
 VOID
 EFIAPI
-EfiRestJasonStructureProtocolIsReady (
+EfiRestJsonStructureProtocolIsReady (
   IN  EFI_EVENT  Event,
   IN  VOID   *Context
   )
@@ -829,7 +829,7 @@ RedfishResourceEntryPoint (
   EfiCreateProtocolNotifyEvent (
 ,
 TPL_CALLBACK,
-EfiRestJasonStructureProtocolIsReady,
+EfiRestJsonStructureProtocolIsReady,
 NULL,
 
 );
-- 
2.32.0 (Apple Git-132)



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




[edk2-devel] [edk2-redfish-client][PATCH v2 0/3] change method for provisioning + minor fixes

2023-12-18 Thread Mike Maslenkin
This patch set contains minor fixes.

diff from v1:
 original patch 4/4 with change related to BIOS resources provisioning removed.

PR: https://github.com/tianocore/edk2-redfish-client/pull/64

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nickle Wang 
Signed-off-by: Mike Maslenkin 



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




[edk2-devel] [edk2-redfish-client][PATCH v2 1/3] RedfishClientPkg: add check for NULL pointer to avoid ASSERT

2023-12-18 Thread Mike Maslenkin
Initially RedfishPlatformConfigGetConfigureLang could return success
even if ConfigureLangList is empty. After fixing this condition,
RedfishPlatformConfigGetConfigureLang returns an error, but this doesn't
help to avoid ASSERT because the error path is the same as for non-empty
list.

Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Signed-off-by: Mike Maslenkin 
Reviewed-by: Nickle Wang 
---
 .../RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
index 4cb7621c25c4..0f0b050d7eba 100644
--- 
a/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
+++ 
b/RedfishClientPkg/Library/RedfishFeatureUtilityLib/RedfishFeatureUtilityLib.c
@@ -3118,7 +3118,9 @@ LeaveFunction:
 FreePool (ConfigureLangBuffer);
   }
 
-  FreePool (ConfigureLangList);
+  if (ConfigureLangList != NULL) {
+FreePool (ConfigureLangList);
+  }
 
   *NumberOfValues = (UINT32)ListCount;
   return FirstEmptyPropKeyValueList;
-- 
2.32.0 (Apple Git-132)



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




Re: [edk2-devel] [PATCH v1 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

2023-12-18 Thread Heinrich Schuchardt

On 12/15/23 00:39, Stuart Yoder wrote:

From: Joseph Hemann 


Please, provide commit messages.



Signed-off-by: Joseph Hemann 
Signed-off-by: Stuart Yoder 
---
  uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 179 
  1 file changed, 179 insertions(+)

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h 
b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index ..659c61a741e7
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,179 @@
+/** @file
+
+  Copyright 2006 - 2016 Unified EFI, Inc.
+  Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Inc. All rights reserved.
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD 
License
+  which accompanies this distribution.  The full text of the license may be 
found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+  TCG2.h
+
+Abstract:
+
+  EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID\
+   {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 
0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x0001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x0002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x0004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x0008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x0010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x0001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x0002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;


EFI_PHYSICAL_ADDRESS already is used in edk2-test. We should avoid 
duplicate definitions.


This type is not TCG2 specific and hence should be defined in a 
different include.


Best regards

Heinrich


+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+  UINT8 Major;
+  UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+  UINT8 Size;
+  EFI_TCG2_VERSION StructureVersion;
+  EFI_TCG2_VERSION ProtocolVersion;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+  EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+  BOOLEAN TPMPresentFlag;
+  UINT16 MaxCommandSize;
+  UINT16 MaxResponseSize;
+  UINT32 ManufacturerID;
+  UINT32 NumberOfPcrBanks;
+  EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+  OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+  OUT BOOLEAN *EventLogTruncated
+);
+
+// all structs except EFI_TCG2_BOOT_SERVICE_CAPABILITY are packed
+#pragma pack(1)
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+  UINT32 HeaderSize;
+  UINT16 HeaderVersion;
+  TCG_PCRINDEX PCRIndex;
+  TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+  UINT32 Size;
+  EFI_TCG2_EVENT_HEADER Header;
+  UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT64 Flags,
+  IN EFI_PHYSICAL_ADDRESS DataToHash,
+  IN UINT64 DataToHashLen,
+  IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 InputParameterBlockSize,
+  IN UINT8 *InputParameterBlock,
+  IN UINT32 OutputParameterBlockSize,
+  IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+  IN EFI_TCG2_PROTOCOL *This,
+  OUT UINT32 *OperationPresent,
+  OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+  EFI_TCG2_GET_CAPABILITY GetCapability;
+  EFI_TCG2_GET_EVENT_LOG GetEventLog;
+  EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+  EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+  EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+  EFI_TCG2_SET_ACTIVE_PCR_BANKS 

[edk2-devel] Cancelled Event: Tools, CI, Code base construction meeting series - Monday, January 1, 2024 #cal-cancelled

2023-12-18 Thread Group Notification
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:CANCELLED
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
LAST-MODIFIED:20230911T053111Z
TZURL:https://www.tzurl.org/zoneinfo-outlook/America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZNAME:PDT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
DTSTART:19700308T02
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:PST
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
DTSTART:19701101T02
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:2148596 
UID:rvop.1647284497725488626.j...@groups.io
DTSTAMP:20231218T223226Z
ORGANIZER;CN=devel@edk2.groups.io Group:mailto:devel@edk2.groups.io
DTSTART:20240102T003000Z
DTEND:20240102T013000Z
SUMMARY:Tools\, CI\, Code base construction meeting series
DESCRIPTION:TianoCore community\,\n\nMicrosoft and Intel will be hosting 
 a series of open meetings to discuss build\, CI\, tools\, and other relat
 ed topics. If you are interested\, have ideas/opinions please join us. Th
 ese meetings will be Monday 4:30pm Pacific Time on Microsoft Teams.\n\nMS
  Teams Link in following discussion:\n* https://github.com/tianocore/edk2
 /discussions/2614\n\nAnyone is welcome to join.\n\n* tianocore/edk2: EDK 
 II (github.com)\n* tianocore/edk2-basetools: EDK II BaseTools Python tool
 s as a PIP module (github.com) https://github.com/tianocore/edk2-basetool
 s\n* tianocore/edk2-pytool-extensions: Extensions to the edk2 build syste
 m allowing for a more robust and plugin based build system and tool execu
 tion environment (github.com) https://github.com/tianocore/edk2-pytool-ex
 tensions\n* tianocore/edk2-pytool-library: Python library package that su
 pports UEFI development (github.com) https://github.com/tianocore/edk2-py
 tool-library\n\nMS Teams Browser Clients\n* https://docs.microsoft.com/en
 -us/microsoftteams/get-clients?tabs=Windows#browser-client
LOCATION:https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZDI2ZDg4N
 mMtMjI1My00MzI5LWFmYjAtMGQyNjUzNTBjZGYw%40thread.v2/0?context=%7b%22Tid%2
 2%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%2223af6561-
 6e1c-450d-b917-d9d674eb3cb6%22%7d
SEQUENCE:1
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


[edk2-devel] Cancelled Event: Tools, CI, Code base construction meeting series - Monday, December 25, 2023 #cal-cancelled

2023-12-18 Thread Group Notification
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Groups.io Inc//Groups.io Calendar//EN
METHOD:CANCELLED
REFRESH-INTERVAL;VALUE=DURATION:PT1H
X-PUBLISHED-TTL:PT1H
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
LAST-MODIFIED:20230911T053111Z
TZURL:https://www.tzurl.org/zoneinfo-outlook/America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZNAME:PDT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
DTSTART:19700308T02
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:PST
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
DTSTART:19701101T02
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
X-GIOIDS:Event:2144472 
UID:rvop.1647284497725488626.j...@groups.io
DTSTAMP:20231218T223210Z
ORGANIZER;CN=devel@edk2.groups.io Group:mailto:devel@edk2.groups.io
DTSTART:20231226T003000Z
DTEND:20231226T013000Z
SUMMARY:Tools\, CI\, Code base construction meeting series
DESCRIPTION:TianoCore community\,\n\nMicrosoft and Intel will be hosting 
 a series of open meetings to discuss build\, CI\, tools\, and other relat
 ed topics. If you are interested\, have ideas/opinions please join us. Th
 ese meetings will be Monday 4:30pm Pacific Time on Microsoft Teams.\n\nMS
  Teams Link in following discussion:\n* https://github.com/tianocore/edk2
 /discussions/2614\n\nAnyone is welcome to join.\n\n* tianocore/edk2: EDK 
 II (github.com)\n* tianocore/edk2-basetools: EDK II BaseTools Python tool
 s as a PIP module (github.com) https://github.com/tianocore/edk2-basetool
 s\n* tianocore/edk2-pytool-extensions: Extensions to the edk2 build syste
 m allowing for a more robust and plugin based build system and tool execu
 tion environment (github.com) https://github.com/tianocore/edk2-pytool-ex
 tensions\n* tianocore/edk2-pytool-library: Python library package that su
 pports UEFI development (github.com) https://github.com/tianocore/edk2-py
 tool-library\n\nMS Teams Browser Clients\n* https://docs.microsoft.com/en
 -us/microsoftteams/get-clients?tabs=Windows#browser-client
LOCATION:https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZDI2ZDg4N
 mMtMjI1My00MzI5LWFmYjAtMGQyNjUzNTBjZGYw%40thread.v2/0?context=%7b%22Tid%2
 2%3a%2272f988bf-86f1-41af-91ab-2d7cd011db47%22%2c%22Oid%22%3a%2223af6561-
 6e1c-450d-b917-d9d674eb3cb6%22%7d
SEQUENCE:1
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR


invite.ics
Description: application/ics


Re: [edk2-devel] [PATCH v2] MdeModulePkg/UefiBootManagerLib: Signal ReadyToBoot on platform recovery

2023-12-18 Thread Ard Biesheuvel
Hello all,

Same question again. Could we please make some progress on this?

Full thread here:
https://openfw.io/edk2-devel/20231031173700.647004-1-ngo...@fedoraproject.org/

If nobody objects, I will assume that the change is acceptable and
merge it by the end of the week.

Thanks,
Ard.



On Tue, 12 Dec 2023 at 09:11, Ard Biesheuvel  wrote:
>
> (cc Mike, Leif)
>
> On Thu, 7 Dec 2023 at 08:40, Ard Biesheuvel  wrote:
> >
> > (cc Liming)
> >
> > On Thu, 7 Dec 2023 at 05:48, Neal Gompa  wrote:
> > >
> > > On Fri, Nov 24, 2023 at 6:36 PM Neal Gompa  wrote:
> > > >
> > > > On Thu, Nov 2, 2023 at 6:35 AM Laszlo Ersek  wrote:
> > > > >
> > > > > On 10/31/23 23:27, Jeremy Linton wrote:
> > > > > > On 10/31/23 12:37, Neal Gompa via groups.io wrote:
> > > > > >> From: Neal Gompa 
> > > > > >>
> > > > > >> Currently, the ReadyToBoot event is only signaled when a formal 
> > > > > >> Boot
> > > > > >> Manager option is executed (in BmBoot.c -> EfiBootManagerBoot ()).
> > > > > >>
> > > > > >> However, the introduction of Platform Recovery in UEFI 2.5 makes it
> > > > > >> necessary to signal ReadyToBoot when a Platform Recovery boot 
> > > > > >> loader
> > > > > >> runs because otherwise it may lead to the execution of a boot 
> > > > > >> loader
> > > > > >> that has similar requirements to a regular one that is not launched
> > > > > >> as a Boot Manager option.
> > > > > >>
> > > > > >> This is especially critical to ensuring that the graphical console
> > > > > >> is actually usable during platform recovery, as some platforms do
> > > > > >> rely on the ConsolePrefDxe driver, which only performs console
> > > > > >> initialization after ReadyToBoot is triggered.
> > > > > >>
> > > > > >> This patch fixes that behavior by calling 
> > > > > >> EfiSignalEventReadyToBoot ()
> > > > > >> in EfiBootManagerProcessLoadOption () when invoking platform 
> > > > > >> recovery,
> > > > > >> which is the function that sets up the platform recovery boot 
> > > > > >> process.
> > > > > >>
> > > > > >> The expected behavior has been clarified in the UEFI 2.10 
> > > > > >> specification
> > > > > >> to explicitly indicate this behavior is required for correct 
> > > > > >> operation.
> > > > > >>
> > > > > >> This is a rebased version of the patch originally written by Pete 
> > > > > >> Batard.
> > > > > >
> > > > > > Took me a bit to swap in that whole conversation again, and recheck 
> > > > > > the
> > > > > > spec's and code paths, but this all looks fine to me and should 
> > > > > > allow
> > > > > > the PFTF build to drop the similar patch from Pete that has been 
> > > > > > carried
> > > > > > downstream for the past couple years.
> > > > > >
> > > > > > As for testing the previous patch has been in the field for a couple
> > > > > > years now and i'm not aware of it causing any issues. The additional
> > > > > > restriction of limiting it to platform recovery logically makes 
> > > > > > sense,
> > > > > > and as far as I can see shouldn't cause any problems.
> > > > > >
> > > > > > So,
> > > > > >
> > > > > > Reviewed-by: Jeremy Linton 
> > > > > >
> > > > > >
> > > > > > As a PS: I also went to check the ready to boot behavior for 
> > > > > > OsRecovery
> > > > > > and realized that apparently none of that support was ever merged?
> > > > >
> > > > > What else is there, outside of this patch, in need of upstreaming?
> > > > >
> > > > > > That seems a bit of an oversight since its been in the spec for a 
> > > > > > few years now.
> > > > >
> > > > > "ready-to-boot for OsRecovery" is new in UEFI 2.10 (according to the
> > > > > commit message), which is quite recent ("Aug 29, 2022").
> > > > >
> > > > > I couldn't find the Mantis ticket in the Revision History (for 2.10) 
> > > > > though.
> > > > >
> > > >
> > > > Is there anything else holding up committing this patch? Jeremy and
> > > > you reviewed it earlier in the month...
> > > >
> > >
> > > Friendly ping again? It's been a month now...
> > >
> >
> > Apologies for the delay - Liming, can we progress with this?
>
> Can we please make some progress with this? This has been in limbo for
> far too long.
>
> Thanks,


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




Re: [edk2-devel] Clarification on LoadFile2 Protocol Installation for Network Boot Devices

2023-12-18 Thread Saloni Kasbekar
Hi Siva,

“The EFI_LOAD_FILE2_PROTOCOL is a simple protocol used to obtain files from 
arbitrary devices that are not boot
options”
“The EFI_LOAD_FILE_PROTOCOL is used for devices that do not directly support 
file systems. Network devices
commonly boot in this model where the image is materialized without the need of 
a file system.”

Based on the above statements, I believe the Network stack is fine using the 
current EFI_LOAD_FILE_PROTOCOL and not the EFI_LOAD_FILE2_PROTOCOL as they are 
currently loaded as boot options. We currently do install the 
EFI_LOAD_FILE_PROTOCOL within the Network stack. Eg -
  //
  // Create a child handle for the HTTP boot and install DevPath and Load file 
protocol on it.
  //
  CopyMem (>Ip6Nic->LoadFile, , sizeof 
(Private->LoadFile));
  Status = gBS->InstallMultipleProtocolInterfaces (
  >Ip6Nic->Controller,
  ,
  >Ip6Nic->LoadFile,
  ,
  Private->Ip6Nic->DevicePath,
  NULL
  );

Maybe we need to update #18 to include Network devices?

Thanks,
Saloni

From: devel@edk2.groups.io  On Behalf Of Sivaraman Nainar 
via groups.io
Sent: Friday, December 15, 2023 3:29 AM
To: devel@edk2.groups.io; Clark-williams, Zachary 
; Kasbekar, Saloni 
Cc: Natalya Kalistratova ; Dhanaraj V ; 
Santhosh Kumar V ; GengYou Zhou (周庚佑) 

Subject: [edk2-devel] reg: Clarification on LoadFile2 Protocol Installation for 
Network Boot Devices

Hello ZClarkWilliams:

Could you please help to clarify if NetworkStack MUST install the LoadFile2 
Protocol or not. With reference to the below spec item, the LoadFile2 protocol 
must be implemented.

In one of the BIOS environment, the Setup Browser Locates the LoadFile2 
instance of Network Boot Device and it not found as it not installed by the 
current NetworkPkg.

Can you please comment if there is any reason behind not installing during the 
HTTP Boot.
“UEFI SPEC
2.6.3 Driver-Specific Elements There are a number of UEFI elements that can be 
added or removed depending on the features that a specific driver requires. 
Drivers can be implemented by platform firmware developers to support buses and 
devices in a specific platform. Drivers can also be implemented by add-in card 
vendors for devices that might be integrated into the platform hardware or 
added to a platform through an expansion slot. The following list includes 
possible driver features, and the UEFI elements that are required for each 
feature type:

  1.  If a driver is written for a boot device that is not a block-oriented 
device, a file system-based device, or a console device, then the 
EFI_LOAD_FILE2_PROTOCOL must be implemented.
“

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



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




[edk2-devel] [PATCH v4 4/4] DynamicTablesPkg: AML Code generation to invoke a method

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Adds API to generate AML code to invoke/call another
method. Also provides ability to pass arguments of
type integer, string, ArgObj or LocalObj.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
---
 .../Include/Library/AmlLib/AmlLib.h   |  94 
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 221 +-
 2 files changed, 314 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index eb8740692f..5e6a6fde21 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -101,6 +101,53 @@ typedef enum {
   AmlAddressRangeMax  = 4
 } AML_MEMORY_ATTRIBUTES_MTP;
 
+/** Method parameter types
+
+  Possible values are:
+0 - AmlMethodParamTypeInteger
+1 - AmlMethodParamTypeString
+2 - AmlMethodParamTypeArg
+3 - AmlMethodParamTypeLocal
+
+  @par Reference(s)
+  - ACPI 6.5, s20.2.5 "Term Objects Encoding"
+
+**/
+typedef enum {
+  AmlMethodParamTypeInteger = 0,
+  AmlMethodParamTypeString  = 1,
+  AmlMethodParamTypeArg = 2,
+  AmlMethodParamTypeLocal   = 3
+} AML_METHOD_PARAM_TYPE;
+
+/** structure to hold AML method parameter types
+  Type  -   Type of parameter
+  Data  -   holds data of parameter
+if Type is AmlMethodParamTypeInteger
+  then Data is of type Integer to hold integer value.
+if Type is AmlMethodParamTypeString
+  then Data contains null terminated string.
+If Type is AmlMethodParamTypeArg
+  then Data contains the Argument number,
+  0 to 6 are supported value.
+If Type is AmlMethodParamTypeLocal
+  then Data contains the Local variable number,
+  0 to 7 are supported value.
+  DataSize - for future use
+**/
+typedef struct {
+  AML_METHOD_PARAM_TYPEType;
+
+  union {
+UINT8 Arg;
+UINT8 Local;
+UINT64Integer;
+VOID  *Buffer;
+  } Data;
+
+  UINTNDataSize;
+} AML_METHOD_PARAM;
+
 /** Parse the definition block.
 
   The function parses the whole AML blob. It starts with the ACPI DSDT/SSDT
@@ -1693,4 +1740,51 @@ AmlAddNameStringToNamedPackage (
   IN AML_OBJECT_NODE_HANDLE  NamedNode
   );
 
+/** AML code generation to invoke/call another method.
+
+  This method is subset implementation of MethodInvocation
+  defined in the ACPI specification 6.5,
+  section 20.2.5 "Term Objects Encoding".
+  Added integer, string, ArgObj and LocalObj support.
+
+  Example 1:
+AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode);
+is equivalent of the following ASL code:
+  MET0 ();
+
+  Example 2:
+AML_METHOD_PARAM  Param[4];
+Param[0].Data.Integer = 0x100;
+Param[0].Type = AmlMethodParamTypeInteger;
+Param[1].Data.Buffer = "TEST";
+Param[1].Type = AmlMethodParamTypeString;
+Param[2].Data.Arg = 0;
+Param[2].Type = AmlMethodParamTypeArg;
+Param[3].Data.Local = 2;
+Param[3].Type = AmlMethodParamTypeLocal;
+AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
+
+is equivalent of the following ASL code:
+  MET0 (0x100, "TEST", Arg0, Local2);
+
+  @param [in] MethodNameString  Method name to be called/invoked.
+  @param [in] NumArgs   Number of arguments to be passed,
+0 to 7 are permissible values.
+  @param [in] Parameter contains the parameter data.
+  @param [in] ParentNodeset ParentNode as the parent
+of the node created.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+ **/
+EFI_STATUS
+EFIAPI
+AmlCodeGenInvokeMethod (
+  IN  CONST CHAR8 *MethodNameString,
+  INUINT8 NumArgs,
+  INAML_METHOD_PARAM  *Parameters   OPTIONAL,
+  INAML_NODE_HANDLE   ParentNode
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a6db34fb97..3565a4dd58 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -2,6 +2,7 @@
   AML Code Generation.
 
   Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString (
   Status = AmlCreateDataNode (
  EAmlNodeDataTypeRaw,
  (CONST UINT8 *)String,
- StrSize (String),
+ (UINT32)StrSize (String),
  
  );
   if (EFI_ERROR (Status)) {
@@ -3849,3 +3850,221 @@ exit_handler:
 
   return Status;
 }
+
+/** AML code generation to invoke/call another 

[edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the parameters of AmlCodeGenRdWordBusNumber() to
UINT16 to generate word bus number.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h   | 10 +-
 .../Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 5e340b94ce..eb8740692f 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -714,11 +714,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 60fe69ba6d..46243f981c 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -848,11 +848,11 @@ AmlCodeGenRdWordBusNumber (
   INBOOLEAN IsMinFixed,
   INBOOLEAN IsMaxFixed,
   INBOOLEAN IsPosDecode,
-  INUINT32 AddressGranularity,
-  INUINT32 AddressMinimum,
-  INUINT32 AddressMaximum,
-  INUINT32 AddressTranslation,
-  INUINT32 RangeLength,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
   INUINT8 ResourceSourceIndex,
   IN  CONST CHAR8 *ResourceSource,
   INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
-- 
2.34.1



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




[edk2-devel] [PATCH v4 3/4] DynamicTablesPkg: Corrects function pointer typedef of AML_PARSE_FUNCTION

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Corrects the function pointer typedef AML_PARSE_FUNCTION,
otherwise some compiler like VS2019 gives error.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c 
b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
index 8e584d4930..d3a51a94c7 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/Parser/AmlParser.c
@@ -100,8 +100,7 @@ AmlParseStream (
 **/
 typedef
 EFI_STATUS
-EFIAPI
-(*AML_PARSE_FUNCTION) (
+(EFIAPI *AML_PARSE_FUNCTION)(
   IN  CONST AML_NODE_HEADER   *Node,
   INAML_PARSE_FORMAT  ExpectedFormat,
   IN  OUT   AML_STREAM*FStream,
-- 
2.34.1



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




[edk2-devel] [PATCH v4 1/4] DynamicTablesPkg: AML Code generation for word I/O ranges

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

Add helper functions to generate AML resource data
for word I/O.

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Pierre Gondois 
---
 .../Include/Library/AmlLib/AmlLib.h   | 65 ++
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   | 88 +++
 2 files changed, 153 insertions(+)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 71e8539b30..5e340b94ce 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -2,6 +2,7 @@
   AML Lib.
 
   Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -724,6 +725,70 @@ AmlCodeGenRdWordBusNumber (
   OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
   );
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data elements of the NameOpNode.
+ In such case NameOpNode must be defined by a the "Name ()" ASL statement
+ and initially contain a "ResourceTemplate ()".
+   - returned through the NewRdNode parameter.
+
+  @param [in]  IsResourceConsumer   ResourceUsage parameter.
+  @param [in]  IsMinFixed   Minimum address is fixed.
+  @param [in]  IsMaxFixed   Maximum address is fixed.
+  @param [in]  IsPosDecode  Decode parameter
+  @param [in]  IsaRangesPossible values are:
+ 0-Reserved
+ 1-NonISAOnly
+ 2-ISAOnly
+ 3-EntireRange
+  @param [in]  AddressGranularity   Address granularity.
+  @param [in]  AddressMinimum   Minimum address.
+  @param [in]  AddressMaximum   Maximum address.
+  @param [in]  AddressTranslation   Address translation.
+  @param [in]  RangeLength  Range length.
+  @param [in]  ResourceSourceIndex  Resource Source index.
+Not supported. Must be 0.
+  @param [in]  ResourceSource   Resource Source.
+Not supported. Must be NULL.
+  @param [in]  IsDenseTranslation   TranslationDensity parameter.
+  @param [in]  IsTypeStatic TranslationType parameter.
+  @param [in]  NameOpNode   NameOp object node defining a named object.
+If provided, append the new resource data
+node to the list of resource data elements
+of this node.
+  @param [out] NewRdNodeIf provided and success,
+contain the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESCould not allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCodeGenRdWordIo (
+  INBOOLEAN IsResourceConsumer,
+  INBOOLEAN IsMinFixed,
+  INBOOLEAN IsMaxFixed,
+  INBOOLEAN IsPosDecode,
+  INUINT8 IsaRanges,
+  INUINT16 AddressGranularity,
+  INUINT16 AddressMinimum,
+  INUINT16 AddressMaximum,
+  INUINT16 AddressTranslation,
+  INUINT16 RangeLength,
+  INUINT8 ResourceSourceIndex,
+  IN  CONST CHAR8 *ResourceSource,
+  INBOOLEAN IsDenseTranslation,
+  INBOOLEAN IsTypeStatic,
+  INAML_OBJECT_NODE_HANDLE NameOpNode, OPTIONAL
+  OUT   AML_DATA_NODE_HANDLE*NewRdNode  OPTIONAL
+  );
+
 /** Code generation for the "QWordIO ()" ASL function.
 
   The Resource Data effectively created is a QWord Address Space Resource
diff --git 
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bc1c1d119..60fe69ba6d 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -2,6 +2,7 @@
   AML Resource Data Code Generation.
 
   Copyright (c) 2020 - 2021, Arm Limited. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -878,6 +879,93 @@ AmlCodeGenRdWordBusNumber (
);
 }
 
+/** Code generation for the "WordIO ()" ASL function.
+
+  The Resource Data effectively created is a Word Address Space Resource
+  Data. Cf ACPI 6.5:
+   - s6.4.3.5.3 "Word Address Space Descriptor".
+
+  The created resource data node can be:
+   - appended to the list of resource data 

[edk2-devel] [PATCH v4 0/4] DynamicTablesPkg: Adds WordIO and method invocation ability

2023-12-18 Thread Abdul Lateef Attar via groups.io
From: Abdul Lateef Attar 

PR: https://github.com/tianocore/edk2/pull/5157

V4: delta changes
  Address Pierre's review comments.
  Merged patch 4 & patch 5.
  Also added parameter logic suggested by Pierre.
V3: delta changes
  CI fix and error handling for 
DynamicTablesPkg: Adds API to generate a method with ArgN.
  Added new patch "DynamicTablesPkg: Adds wrapper API 
AmlCodeGenMethodInvokeMethodArgn"
V2:
  Added new API to generate a method which
  invokes another method with argument.
V1:
Code changes to
Add API to generate word I/O ranges.
Correct the parameter to generate word bus number.
Corrects the function pointer typedef

Cc: Pierre Gondois 
Cc: Sami Mujawar 
Cc: Abdul Lateef Attar 

Abdul Lateef Attar (4):
  DynamicTablesPkg: AML Code generation for word I/O ranges
  DynamicTablesPkg: Corrects AmlCodeGenRdWordBusNumber parameters
  DynamicTablesPkg: Corrects function pointer typedef of
AML_PARSE_FUNCTION
  DynamicTablesPkg: AML Code generation to invoke a method

 .../Include/Library/AmlLib/AmlLib.h   | 169 +-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 221 +-
 .../AmlLib/CodeGen/AmlResourceDataCodeGen.c   |  98 +++-
 .../Library/Common/AmlLib/Parser/AmlParser.c  |   3 +-
 4 files changed, 478 insertions(+), 13 deletions(-)

-- 
2.34.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112647): https://edk2.groups.io/g/devel/message/112647
Mute This Topic: https://groups.io/mt/103245322/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 V1 5/5] Platform/ARM/N1Sdp: Enable FaultTolerantWrite Dxe driver for N1Sdp

2023-12-18 Thread Sami Mujawar

Hi Sahil,

As such these changes look good to me. But, we would need to revisit 
this based on my response for Patch 3/5.


Regards,

Sami Mujawar

On 16/11/2023 11:45 am, sahil wrote:

Signed-off-by: sahil 
---
  Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 5 +
  Platform/ARM/N1Sdp/N1SdpPlatform.fdf | 1 +
  2 files changed, 6 insertions(+)

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
index 10fe2db9e1b1..703829bbac99 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
@@ -165,6 +165,10 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20

  


# NOR flash support

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0x18F4

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize|0x0002

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0x18F2

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0x0002

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x18F0

gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0002

  


@@ -227,6 +231,7 @@

NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf

BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

}

+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf

  


# ACPI Support

MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf 
b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
index 4329f892f7c5..17d370a371cf 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
@@ -90,6 +90,7 @@ READ_LOCK_STATUS   = TRUE
INF MdeModulePkg/Universal/Metronome/Metronome.inf

INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf

INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf

+  INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf

INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf

INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf

INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112646): https://edk2.groups.io/g/devel/message/112646
Mute This Topic: https://groups.io/mt/102625038/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 V1 4/5] Platform/ARM/N1Sdp: Persistent storage for N1Sdp

2023-12-18 Thread Sami Mujawar

Hi Sahil,

Please see my response for Patch 3/5.

Regards,

Sami Mujawar

On 16/11/2023 11:45 am, sahil wrote:

Enable persistent storage on QSPI flash device.

Signed-off-by: sahil 
---
  Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 20 ++--
  Platform/ARM/N1Sdp/N1SdpPlatform.fdf |  4 +++-
  2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
index d04b22d3ef51..10fe2db9e1b1 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
@@ -4,7 +4,7 @@
  # This provides platform specific component descriptions and libraries that

  # conform to EFI/Framework standards.

  #

-# Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.

+# Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.

  #

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

  #

@@ -44,6 +44,9 @@
# file explorer library support

FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf

  


+  # NOR flash support

+  NorFlashInfoLib|EmbeddedPkg/Library/NorFlashInfoLib/NorFlashInfoLib.inf

+

  [LibraryClasses.common.SEC]

HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf


MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf

@@ -161,11 +164,9 @@
# ACPI Table Version

gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20

  


-  # Runtime Variable storage

-  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0

-  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE

-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x2000

-  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize|0x2800

+  # NOR flash support

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase|0x18F0

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize|0x0002

  


  


  #

@@ -197,6 +198,12 @@
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800F

}

  


+  # NOR flash support

+  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf {

+  

+  
NorFlashPlatformLib|Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf

+  }

+

# Architectural Protocols

ArmPkg/Drivers/CpuDxe/CpuDxe.inf

ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

@@ -217,6 +224,7 @@
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {

  

NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf

+  
NULL|EmbeddedPkg/Library/NvVarStoreFormattedLib/NvVarStoreFormattedLib.inf

BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf

}

  


diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf 
b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
index e5e24ea50294..4329f892f7c5 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
@@ -1,7 +1,7 @@
  ## @file

  #  FDF file of N1Sdp

  #

-#  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.

+#  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.

  #

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

  ##

@@ -140,6 +140,8 @@ READ_LOCK_STATUS   = TRUE
INF ArmPkg/Drivers/GenericWatchdogDxe/GenericWatchdogDxe.inf

INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf

  


+  INF Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf

+

INF Platform/ARM/Drivers/BootMonFs/BootMonFs.inf

INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf

  




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112645): https://edk2.groups.io/g/devel/message/112645
Mute This Topic: https://groups.io/mt/102625037/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 V1 3/5] Platform/ARM/N1Sdp: NOR flash Dxe Driver for N1Sdp

2023-12-18 Thread Sami Mujawar

Hi Sahil,

Where can I find the documentation for Cadence QSPI? Can you add a link 
to the relevant file headers, please?


Also, this patch is duplicating a lot of the code in 
edk2-platforms\Platform\ARM\Drivers\NorFlashDxe and I have already 
spotted some new bugs in this patch.


Have you considered splitting the NorFlashDxe to introduce a 
NorFlashDeviceLib that implements the specifics for the respective flash?


i.e. NorFlashDxe links with NorFlashDeviceLib and the platforms can 
specify the respective NorFlashDeviceLib instances.


NorFlashDeviceLib|Platform/Arm/Library/P30NorFlashDeviceLib/P30NorFlashDeviceLib.inf

NorFlashDeviceLib|Platform/Arm/Library/CadenceQspiNorFlashDeviceLib/CadenceQspiNorFlashDeviceLib.inf

Regards,

Sami Mujawar

On 16/11/2023 11:45 am, sahil wrote:

Add NOR flash DXE driver, this brings up NV storage on
QSPI's flash device using FVB protocol.

Signed-off-by: sahil 
---
  Platform/ARM/N1Sdp/N1SdpPlatform.dec |5 +-
  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf |   72 ++
  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiReg.h   |   33 +
  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlash.h |  491 +
  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.c   |  409 
  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlash.c | 1100 

  Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/NorFlashFvb.c  |  647 

  7 files changed, 2756 insertions(+), 1 deletion(-)

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dec 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
index 16937197b8e8..67b5f4c871b6 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.dec
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
@@ -1,7 +1,7 @@
  ## @file

  #  Describes the N1Sdp configuration.

  #

-#  Copyright (c) 2021, ARM Limited. All rights reserved.

+#  Copyright (c) 2021-2023, ARM Limited. All rights reserved.

  #

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

  ##

@@ -89,3 +89,6 @@
# unmapped reserved region results in a DECERR response.

#

gArmN1SdpTokenSpaceGuid.PcdCsComponentSize|0x1000|UINT32|0x0049

+

+  # Base address of Cadence QSPI controller configuration registers

+  
gArmN1SdpTokenSpaceGuid.PcdCadenceQspiDxeRegBaseAddress|0x1C0C|UINT32|0x004A

diff --git a/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf 
b/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf
new file mode 100644
index ..62a4944c95db
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiDxe.inf
@@ -0,0 +1,72 @@
+## @file

+#  NOR flash DXE

+#

+#  Copyright (c) 2023, ARM Limited. All rights reserved.

+#

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

+#

+##

+

+[Defines]

+  INF_VERSION= 0x0001001B

+  BASE_NAME  = CadenceQspiDxe

+  FILE_GUID  = CC8A9713-4442-4A6C-B389-8B46490A0641

+  MODULE_TYPE= DXE_RUNTIME_DRIVER

+  VERSION_STRING = 0.1

+  ENTRY_POINT= NorFlashInitialise

+

+[Sources]

+  CadenceQspiDxe.c

+  CadenceQspiReg.h

+  NorFlash.c

+  NorFlash.h

+  NorFlashFvb.c

+

+[Packages]

+  EmbeddedPkg/EmbeddedPkg.dec

+  MdeModulePkg/MdeModulePkg.dec

+  MdePkg/MdePkg.dec

+  Platform/ARM/ARM.dec

+  Platform/ARM/N1Sdp/N1SdpPlatform.dec

+

+[LibraryClasses]

+  BaseLib

+  BaseMemoryLib

+  DebugLib

+  DevicePathLib

+  DxeServicesTableLib

+  HobLib

+  IoLib

+  MemoryAllocationLib

+  NorFlashInfoLib

+  NorFlashPlatformLib

+  TimerLib

+  UefiBootServicesTableLib

+  UefiDriverEntryPoint

+  UefiLib

+  UefiRuntimeLib

+  UefiRuntimeServicesTableLib

+

+[Guids]

+  gEdkiiNvVarStoreFormattedGuid

+  gEfiAuthenticatedVariableGuid

+  gEfiEventVirtualAddressChangeGuid

+  gEfiSystemNvDataFvGuid

+  gEfiVariableGuid

+  gEfiGlobalVariableGuid

+

+[Protocols]

+  gEfiDevicePathProtocolGuid

+  gEfiFirmwareVolumeBlockProtocolGuid

+

+[FixedPcd]

+  gArmN1SdpTokenSpaceGuid.PcdCadenceQspiDxeRegBaseAddress

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

+

+[Depex]

+  gEfiCpuArchProtocolGuid

diff --git a/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiReg.h 
b/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiReg.h
new file mode 100644
index ..535e6d738d31
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/CadenceQspiDxe/CadenceQspiReg.h
@@ -0,0 +1,33 @@
+/** @file

+

+  Copyright (c) 2023, ARM Limited. All rights reserved.

+

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

+

+**/

+

+#ifndef CADENCE_QSPI_REG_H_

+#define CADENCE_QSPI_REG_H_

+

+// QSPI 

Re: [edk2-devel] [edk2-platforms][PATCH V1 2/5] Silicon/ARM/NeoverseN1Soc: NOR flash library for N1Sdp

2023-12-18 Thread Sami Mujawar

Hi Sahil,

Please find my feedback marked inline as [SAMI].

With those fixed,

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar

On 16/11/2023 11:45 am, sahil wrote:

Add NOR flash library, this library provides APIs for getting the list
of NOR flash devices on the platform.

Signed-off-by: sahil
---
  Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf | 36 
++
  Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c   | 52 

  2 files changed, 88 insertions(+)

diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf 
b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf
new file mode 100644
index ..14f81125c4e1
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.inf
@@ -0,0 +1,36 @@
+## @file

+#  NOR flash lib for ARM Neoverse N1 platform.

+#

+#  Copyright (c) 2023, ARM Limited. All rights reserved.

+#

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

+#

+##

+

+[Defines]

+  INF_VERSION= 0x0001001B

+  BASE_NAME  = NorFlashNeoverseN1SocLib

+  FILE_GUID  = 7006fcf1-a585-4272-92e3-b286b1dff5bb

+  MODULE_TYPE= DXE_DRIVER

+  VERSION_STRING = 1.0

+  LIBRARY_CLASS  = NorFlashPlatformLib


[SAMI] Since this library class is NorFlashPlatformLib, you need to 
implement NorFlashPlatformInitialization().


A platform may not need to do anything in 
NorFlashPlatformInitialization() and just return success.


[/SAMI]



+

+[Sources.common]

+  NorFlashLib.c

+

+[Packages]

+  MdeModulePkg/MdeModulePkg.dec

+  MdePkg/MdePkg.dec

+  Platform/ARM/ARM.dec

+  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec

+

+[LibraryClasses]

+  BaseLib

+  DebugLib

+  IoLib

+

+[FixedPcd]

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase

+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize

diff --git a/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c 
b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c
new file mode 100644
index ..a508d7d77373
--- /dev/null
+++ b/Silicon/ARM/NeoverseN1Soc/Library/NorFlashLib/NorFlashLib.c
@@ -0,0 +1,52 @@
+/** @file

+*  NOR flash lib for ARM Neoverse N1 platform

+*

+*  Copyright (c) 2023, ARM Limited. All rights reserved.

+*

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

+*

+**/

+

+#include 

+#include 

+#include 

+#include 

+#include 

+

+#define FW_ENV_REGION_BASE  FixedPcdGet32 (PcdFlashNvStorageVariableBase)

+#define FW_ENV_REGION_SIZE  (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +   
\

+  FixedPcdGet32 
(PcdFlashNvStorageFtwWorkingSize) + \

+  FixedPcdGet32 
(PcdFlashNvStorageFtwSpareSize))

[SAMI] Please limit line length to 80 characters. Also run uncrustify.


+

+STATIC NOR_FLASH_DESCRIPTION  mNorFlashDevices[] = {

+  {

+/// Environment variable region

+NEOVERSEN1SOC_SCP_QSPI_AHB_BASE,///< device base

+FW_ENV_REGION_BASE, ///< region base

+FW_ENV_REGION_SIZE, ///< region size

+SIZE_4KB,   ///< block size

+  },

+};

+

+/**

+  Get NOR flash region info

+

+  @param[out]NorFlashDevicesNOR flash regions info.

+  @param[out]Count  number of flash instance.

+

+  @retvalEFI_SUCCESSSuccess.

[SAMI] EFI_INVALID_PARAMETER ?


+**/

+EFI_STATUS

+NorFlashPlatformGetDevices (

+  OUT NOR_FLASH_DESCRIPTION  **NorFlashDevices,

+  OUT UINT32 *Count

+  )

+{

+  if ((NorFlashDevices == NULL) || (Count == NULL)) {

+return EFI_INVALID_PARAMETER;

+  }

+

+  *NorFlashDevices = mNorFlashDevices;

+  *Count   = ARRAY_SIZE (mNorFlashDevices);

+  return EFI_SUCCESS;

+}




-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112642): https://edk2.groups.io/g/devel/message/112642
Mute This Topic: https://groups.io/mt/102625034/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 V1 1/5] Silicon/ARM/NeoverseN1Soc: Enable SCP QSPI flash region

2023-12-18 Thread Sami Mujawar

Hi Sahil,

Please see my response inline marked [SAMI].

Regards,

Sami Mujawar

On 16/11/2023 11:45 am, sahil via groups.io wrote:

Enable SCP QSPI flash region access by adding it in the PlatformLibMem

Signed-off-by: sahil 
---
  Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h  |  6 +-
  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c | 10 --
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h 
b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
index 097160c7e2d1..92b8c9c45775 100644
--- a/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
+++ b/Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h
@@ -1,6 +1,6 @@
  /** @file

  *

-* Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.

+* Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.

  *

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

  *

@@ -41,6 +41,10 @@
  #define NEOVERSEN1SOC_EXP_PERIPH_BASE0   0x1C00

  #define NEOVERSEN1SOC_EXP_PERIPH_BASE0_SZ0x130

  


+// SCP QSPI flash device

+#define NEOVERSEN1SOC_SCP_QSPI_AHB_BASE  0x1800

+#define NEOVERSEN1SOC_SCP_QSPI_AHB_SZ0x200


[SAMI] Can you elaborate what is meant by 'SCP', please? Does this mean 
the flash is shared by SCP and AP? It would be good to clarify that in 
the commit message.


Also, if you can add a reference to the relevant document in the file 
header it would be of great help.


[/SAMI]



+

  // Base address to a structure of type NEOVERSEN1SOC_PLAT_INFO which is

  // pre-populated by a earlier boot stage

  #define NEOVERSEN1SOC_PLAT_INFO_STRUCT_BASE  
(NEOVERSEN1SOC_NON_SECURE_SRAM_BASE + \

diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c 
b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
index 9e8a1efc557d..eb099953fe29 100644
--- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c
@@ -1,6 +1,6 @@
  /** @file

  


-  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.

+  Copyright (c) 2018 - 2023, ARM Limited. All rights reserved.

  


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

  


@@ -13,7 +13,7 @@
  #include 

  


  // The total number of descriptors, including the final "end-of-table" 
descriptor.

-#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 19

+#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 20

  


  /**

Returns the Virtual Memory Map of the platform.

@@ -184,6 +184,12 @@ ArmPlatformGetVirtualMemoryMap (
VirtualMemoryTable[Index].Length  = 
NEOVERSEN1SOC_EXP_PERIPH_BASE0_SZ;

VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

  


+  // SCP QSPI flash device

+  VirtualMemoryTable[++Index].PhysicalBase  = NEOVERSEN1SOC_SCP_QSPI_AHB_BASE;

+  VirtualMemoryTable[Index].VirtualBase = NEOVERSEN1SOC_SCP_QSPI_AHB_BASE;

+  VirtualMemoryTable[Index].Length  = NEOVERSEN1SOC_SCP_QSPI_AHB_SZ;

+  VirtualMemoryTable[Index].Attributes  = 
ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;

+

if (PlatInfo->MultichipMode == 1) {

  //Remote DDR (2GB)

  VirtualMemoryTable[++Index].PhysicalBase  = PcdGet64 (PcdExtMemorySpace) +




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




Re: [edk2-devel] TlsDxe skips most cipher suites, failing to negotiate a HTTPS connections

2023-12-18 Thread CrossedCarpet
Solved it! Found a OpensslLibFull.inf that accepts more ciphers. Thank you!


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




[edk2-devel] TlsDxe skips most cipher suites, failing to negotiate a HTTPS connections

2023-12-18 Thread CrossedCarpet
Greetings!
I have been investigating a TLS_HANDSHAKE_ERROR in QEMU running Ovmf caused by 
an HTTPS call which, upon closer inspection with WireShark, has been tracked 
down to the cipher suite negotiated being too restrictive.
Enabling additional debugging messages shows them being skipped in TlsConfig.c, 
only 13 being accepted:

TlsDxe:TlsSetCipherList: skipping CipherId=0x1303
TlsDxe:TlsSetCipherList: skipping CipherId=0xC02C
TlsDxe:TlsSetCipherList: skipping CipherId=0xC030
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCA9
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCA8
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAA
TlsDxe:TlsSetCipherList: skipping CipherId=0xC02B
TlsDxe:TlsSetCipherList: skipping CipherId=0xC02F
TlsDxe:TlsSetCipherList: skipping CipherId=0xC024
TlsDxe:TlsSetCipherList: skipping CipherId=0xC028
TlsDxe:TlsSetCipherList: skipping CipherId=0xC023
TlsDxe:TlsSetCipherList: skipping CipherId=0xC027
TlsDxe:TlsSetCipherList: skipping CipherId=0xC00A
TlsDxe:TlsSetCipherList: skipping CipherId=0xC014
TlsDxe:TlsSetCipherList: skipping CipherId=0xC009
TlsDxe:TlsSetCipherList: skipping CipherId=0xC013
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AD
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AB
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAE
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAD
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAC
TlsDxe:TlsSetCipherList: skipping CipherId=0x00A9
TlsDxe:TlsSetCipherList: skipping CipherId=0xCCAB
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AC
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AA
TlsDxe:TlsSetCipherList: skipping CipherId=0x00A8
TlsDxe:TlsSetCipherList: skipping CipherId=0xC038
TlsDxe:TlsSetCipherList: skipping CipherId=0xC036
TlsDxe:TlsSetCipherList: skipping CipherId=0xC021
TlsDxe:TlsSetCipherList: skipping CipherId=0xC020
TlsDxe:TlsSetCipherList: skipping CipherId=0x00B7
TlsDxe:TlsSetCipherList: skipping CipherId=0x00B3
TlsDxe:TlsSetCipherList: skipping CipherId=0x0095
TlsDxe:TlsSetCipherList: skipping CipherId=0x0091
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AF
TlsDxe:TlsSetCipherList: skipping CipherId=0x008D
TlsDxe:TlsSetCipherList: skipping CipherId=0xC037
TlsDxe:TlsSetCipherList: skipping CipherId=0xC035
TlsDxe:TlsSetCipherList: skipping CipherId=0xC01E
TlsDxe:TlsSetCipherList: skipping CipherId=0xC01D
TlsDxe:TlsSetCipherList: skipping CipherId=0x00B6
TlsDxe:TlsSetCipherList: skipping CipherId=0x00B2
TlsDxe:TlsSetCipherList: skipping CipherId=0x0094
TlsDxe:TlsSetCipherList: skipping CipherId=0x0090
TlsDxe:TlsSetCipherList: skipping CipherId=0x00AE
TlsDxe:TlsSetCipherList: skipping CipherId=0x008C
TlsDxe:TlsSetCipherList: CipherString={
TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA
-AES128-GCM-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-S
HA:DHE-RSA-AES128-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-
SHA256:AES256-SHA:AES128-SHA

Following OvmfPkg's README, I have tried to no avail feeding my host's 
ciphersuite to QEMU with the command:
export LC_ALL=C
openssl ciphers -V \
| sed -r -n \
-e 's/^ *0x([0-9A-F]{2}),0x([0-9A-F]{2}) - .*$/x\1 x\2/p' \
| xargs -r -- printf -- '%b' > ciphers.bin

In TlsSetCipherList I can see them being filtered based on the 
OpensslCipherStack variable.
I have tried diving down into the source code to learn where this variable is 
being initialized but it's not yet obvious to me.
Is this related to our OpenSSL port?
Any idea on how I can proceed with a fix?

Example website that accepts the connection:
- https://httpbin.org/get
Example website that fails to connect:
- https://www.toptal.com/developers/postbin/

Grateful for your attention,
C.C.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112640): https://edk2.groups.io/g/devel/message/112640
Mute This Topic: https://groups.io/mt/103240785/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 v1] MinPlatformPkg: Support SecFspWrapperPlatformSecLib in X64

2023-12-18 Thread Ashraf Ali S
Reviewed-by:  S, Ashraf Ali 

Thanks.,
S, Ashraf Ali

-Original Message-
From: Kuo, Ted  
Sent: Monday, December 18, 2023 9:33 AM
To: devel@edk2.groups.io
Cc: Chaganty, Rangasai V ; Chiu, Chasel 
; Desimone, Nathaniel L 
; Dong, Eric ; S, Ashraf 
Ali ; Duggapu, Chinni B ; 
Gao, Liming 
Subject: [edk2-devel][edk2-platforms][PATCH v1] MinPlatformPkg: Support 
SecFspWrapperPlatformSecLib in X64

https://bugzilla.tianocore.org/show_bug.cgi?id=4623
1.Added PeiCoreEntry.nasm, SecEntry.nasm and Stack.nasm for X64.
2.Made changes in common file to support both IA32 and X64.
3.Added the PCDs below for FSP-T UPD revsions and X64 feature.
 - PcdFspWrapperResetVectorInFsp
 - PcdFspWrapperBfvforResetVectorInFsp
 - PcdFsptUpdHeaderRevision
 - PcdFsptArchUpdHeaderRevision

Cc: Sai Chaganty 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Eric Dong 
Cc: Ashraf Ali S 
Cc: Chinni B Duggapu 
Cc: Liming Gao 
Signed-off-by: Ted Kuo 
---
 .../SecFspWrapperPlatformSecLib/FsptCoreUpd.h |  25 +-
 .../Ia32/SecEntry.nasm|   4 +-
 .../SecFspWrapperPlatformSecLib.inf   |  12 +-
 .../SecGetPerformance.c   |  11 +-
 .../SecPlatformInformation.c  |   8 +-
 .../SecRamInitData.c  |  56 -
 .../X64/PeiCoreEntry.nasm | 224 ++
 .../X64/SecEntry.nasm | 214 +
 .../X64/Stack.nasm|  72 ++
 .../Ia32 => Include}/Fsp.h|   4 +-
 .../Intel/MinPlatformPkg/MinPlatformPkg.dec   |  21 ++
 11 files changed, 629 insertions(+), 22 deletions(-)  create mode 100644 
Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/X64/PeiCoreEntry.nasm
 create mode 100644 
Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/X64/SecEntry.nasm
 create mode 100644 
Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/X64/Stack.nasm
 rename 
Platform/Intel/MinPlatformPkg/{FspWrapper/Library/SecFspWrapperPlatformSecLib/Ia32
 => Include}/Fsp.h (86%)

diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/FsptCoreUpd.h
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/FsptCoreUpd.h
index 7c0f605b92..7c4ddc09a8 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/FsptCoreUpd.h
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
+++ formSecLib/FsptCoreUpd.h
@@ -1,6 +1,6 @@
 /** @file -Copyright (c) 2017, Intel Corporation. All rights 
reserved.+Copyright (c) 2017 - 2023, Intel Corporation. All rights 
reserved. SPDX-License-Identifier: BSD-2-Clause-Patent  **/@@ -10,6 +10,28 
@@ SPDX-License-Identifier: BSD-2-Clause-Patent
  #pragma pack(1) +#if defined (MDE_CPU_X64)+/** Fsp T Core UPD+**/+typedef 
struct {++/** Offset 0x0040+**/+  EFI_PHYSICAL_ADDRESS
MicrocodeRegionBase;++/** Offset 0x0048+**/+  UINT64  
MicrocodeRegionSize;++/** Offset 0x0050+**/+  EFI_PHYSICAL_ADDRESS
CodeRegionBase;++/** Offset 0x0058+**/+  UINT64  
CodeRegionSize;+} FSPT_CORE_UPD;+#else /** Fsp T Core UPD **/ typedef struct 
{@@ -34,6 +56,7 @@ typedef struct {
 **/   UINT8   Reserved[16]; } FSPT_CORE_UPD;+#endif  
#pragma pack() diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/Ia32/SecEntry.nasm
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/Ia32/SecEntry.nasm
index 7f6d771e41..de44066a20 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/Ia32/SecEntry.nasm
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
+++ formSecLib/Ia32/SecEntry.nasm
@@ -1,6 +1,6 @@
 
;-- 
;-; Copyright (c) 2019, Intel Corporation. All rights reserved.+; Copyright 
(c) 2019 - 2023, Intel Corporation. All rights reserved. ; 
SPDX-License-Identifier: BSD-2-Clause-Patent ; Module Name: ;@@ -13,7 +13,7 @@  
; 
;-- 
-#include "Fsp.h"+#include   SECTION .text diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
index 2e0d67eae4..99a04cc264 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlat
+++ formSecLib/SecFspWrapperPlatformSecLib.inf
@@ -1,7 +1,7 @@
 ## @file #  Provide FSP wrapper platform sec related function. #-#  Copyright 
(c) 2017 - 2021, Intel Corporation. All rights reserved.+#  Copyright (c) 
2017 - 2023, Intel Corporation. All rights 

Re: [edk2-devel] [PATCH v4 4/8] UefiCpuPkg: Implements SmmCpuSyncLib library instance

2023-12-18 Thread Ni, Ray
> +  ///
> +  /// Indicate CPUs entered SMM after lock door.
> +  ///
> +  UINTN  LockedCpuCount;

1. It's not "LockedCpuCount". It's "ArrivedCpuCountUponLock".
  Comments can be:
Before the door is locked, CpuCount stores the arrived CPU count.
After the door is locked, CpuCount is set to -1 indicating the door is 
locked. ArrivedCpuCpuntUponLock stores the arrived CPU count then.


> +/**
> +  Performs an atomic compare exchange operation to get semaphore.
> +  The compare exchange operation must be performed using MP safe
> +  mechanisms.
> +
> +  @param[in,out]  SemIN:  32-bit unsigned integer
> + OUT: original integer - 1 if Sem is not locked.
> + OUT: original integer if Sem is locked
> (MAX_UINT32).
> +
> +  @retval Original integer - 1 if Sem is not locked.
> +  Original integer if Sem is locked (MAX_UINT32).

2. Can just say "MAX_UINT32 if Sem is locked".


> +  //
> +  // Calculate total semaphore size
> +  //
> +  CacheLineSize = GetSpinLockProperties ();
> +  OneSemSize= ALIGN_VALUE (sizeof (SMM_CPU_SYNC_SEMAPHORE),
> CacheLineSize);

3. I prefer:
  OneSemSize = GetSpinLockProperties ();
  ASSERT (sizeof (SMM_CPU_SYNC_SEMAPHORE) <= OneSemSize);


> +
> +  Status = SafeUintnAdd (1, NumberOfCpus, );

4. ok:) you are checking if NumberOfCpus + 1 could exceed MAX_UINTN. Fine to me.

> +
> +  //
> +  // Assign CPU Semaphore pointer
> +  //
> +  CpuSem = (*Context)->CpuSem;
> +  for (CpuIndex = 0; CpuIndex < NumberOfCpus; CpuIndex++) {
> +CpuSem->Run  = (SMM_CPU_SYNC_SEMAPHORE *)SemAddr;
> +*CpuSem->Run = 0;
> +
> +CpuSem++;
> +SemAddr += OneSemSize;

5. SafeIntLib was used earlier to make sure no integer overflow.
  But "SemAddr += OneSemSize" is simply ignoring the danger of integer overflow.
  I agree (NumberOfCpus + 1) * OneSemSize shouldn't cause integer overflow when 
code runs to here.
  But initial value of SemAddr is not zero. It's still possible the SemAddr + 
(NumberOfCpus+1)*OneSemSize causes integer overflow.
  I am ok if you don't fix it as I don't believe the integer overflow could 
happen in 5 years.



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




Re: [edk2-devel] [PATCH v4 0/4] StandaloneMmCore finds drivers in uncompressed inner fv.

2023-12-18 Thread Xu, Wei6
Thanks Ray,

The PR is updated with "Reviewed-by" added. 
https://github.com/tianocore/edk2/pull/5004

BR,
Wei
-Original Message-
From: Ni, Ray  
Sent: Monday, December 18, 2023 1:02 PM
To: Xu, Wei6 ; devel@edk2.groups.io
Cc: Laszlo Ersek ; Ard Biesheuvel 
; Sami Mujawar 
Subject: RE: [edk2-devel] [PATCH v4 0/4] StandaloneMmCore finds drivers in 
uncompressed inner fv.

Reviewed-by: Ray Ni 

Can you kindly update the PR to add the Reviewed-by? I can help to set "push" 
label after that.

Thanks,
Ray
> -Original Message-
> From: Xu, Wei6 
> Sent: Monday, December 18, 2023 9:37 AM
> To: devel@edk2.groups.io; Xu, Wei6 
> Cc: Laszlo Ersek ; Ard Biesheuvel 
> ; Sami Mujawar ; Ni, 
> Ray 
> Subject: RE: [edk2-devel] [PATCH v4 0/4] StandaloneMmCore finds 
> drivers in uncompressed inner fv.
> 
> This patch series already got "reviewed-by" from Laszlo. Could anyone 
> help to merge the changes? Thanks a lot.
> 
> Thanks Laszlo for reviewing the patches.
> 
> BR,
> Wei
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Xu, 
> Wei6
> Sent: Monday, November 6, 2023 3:53 PM
> To: devel@edk2.groups.io
> Cc: Xu, Wei6 ; Laszlo Ersek ; 
> Ard Biesheuvel ; Sami Mujawar 
> ; Ni, Ray 
> Subject: [edk2-devel] [PATCH v4 0/4] StandaloneMmCore finds drivers in 
> uncompressed inner fv.
> 
> V1:
> This patch is to fix the issue that StandaloneMmCore fails to detect 
> uncompressed inner FV.
> PR: https://github.com/tianocore/edk2/pull/4943
> 
> V2:
> Based on V1, fix some other issues
> 1. Add Missing object size checks before casting pointers to header types
>   a. InnerFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)SectionData;
>  This is introduced in V1, add the size check on SectionDataSize 
> against EFI_FIRMWARE_VOLUME_HEADER
>   b. Section = (EFI_COMMON_SECTION_HEADER *)(FileHeader + 1);
>  Use FfsFindSection instead of FfsFindSectionData to avoid pointer 
> casting.
> 2. Fix potential memory leak issue that ScratchBuffer is not freed 
> when page allocation for DstBuffer fails.
> PR: https://github.com/tianocore/edk2/pull/4965
> 
> V3:
> 1. Separate patch per individual issue fix on patch V2.
> 2. Fix one more issue: Limit FwVol encapsulation section recursion in 
> MmCoreFfsFindMmDriver().
> PR: https://github.com/tianocore/edk2/pull/4975
> 
> V4:
> Patch (1/4): Move the declaration of MmCoreFfsFindMmDriver() from 
> source file to the header file "StandaloneMmCore.h"
> Patch (2/4): Handle the case that ExtractGuidedSectionDecode()'s 
> decoded buffer is identical to the data in InputSection Patch (3/4): 
> Fix the issue 'Section
> + 1' migth be a wrong address for InnerFvHeader if Section is
> EFI_COMMON_SECTION_HEADER2.
> Patch (4/4): 'Continue' if an EFI_SECTION_FIRMWARE_VOLUME_IMAGE is 
> found, do not look for an EFI_SECTION_GUID_DEFINED again.
> PR: https://github.com/tianocore/edk2/pull/5004
> 
> For the recursion logic improvement, Let's do it in other patch set in 
> future after this patch is committed.
> 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Sami Mujawar 
> Cc: Ray Ni 
> 
> Wei6 Xu (4):
>   StandaloneMmPkg/Core: Limit FwVol encapsulation section recursion
>   StandaloneMmPkg/Core: Fix potential memory leak issue
>   StandaloneMmPkg/Core: Fix issue that offset calculation might be wrong
>   StandaloneMmPkg/Core: Fix the failure to find uncompressed inner FV
> 
>  StandaloneMmPkg/Core/Dispatcher.c |  5 --
>  StandaloneMmPkg/Core/FwVol.c  | 88
> +--
>  StandaloneMmPkg/Core/StandaloneMmCore.c   |  7 +-
>  StandaloneMmPkg/Core/StandaloneMmCore.h   | 26 +++
>  StandaloneMmPkg/Core/StandaloneMmCore.inf |  3 +
>  StandaloneMmPkg/StandaloneMmPkg.dec   |  5 ++
>  6 files changed, 103 insertions(+), 31 deletions(-)
> 
> --
> 2.29.2.windows.2
> 
> 
> 
> 
> 



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