Re: [edk2-devel] [PATCH V3 3/5] RedfishPkg: Create RestEx child on selected interface

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

Thanks Minh,

Reviewed-by: Abner Chang 

> -Original Message-
> From: minhnampere 
> Sent: Friday, May 5, 2023 2:46 PM
> To: devel@edk2.groups.io
> Cc: patc...@amperecomputing.com; Chang, Abner
> ; nick...@nvidia.com; ig...@ami.com;
> n...@os.amperecomputing.com; tinhngu...@os.amperecomputing.com; Vu
> Nguyen ; Minh Nguyen
> ; Nick Ramirez
> 
> Subject: [PATCH V3 3/5] RedfishPkg: Create RestEx child on selected
> interface
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> From: Vu Nguyen 
> 
> When a MAC address matching interface is found, a RestEx child will be
> created to provide the Redfish communication on that interface.
> Currently, It will try to locate all RestEx binding services and choose the 
> first
> satisfied instance without taking care about current selected interface. This
> might raise an issue on the system with multiple network devices that the
> RestEx child was installed on wrong interface.
> 
> Signed-off-by: Minh Nguyen 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nick Ramirez 
> ---
>  RedfishPkg/Include/Library/RestExLib.h |   3 +
>  RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c | 153 --
> --
>  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c |   1 +
>  3 files changed, 63 insertions(+), 94 deletions(-)
> 
> diff --git a/RedfishPkg/Include/Library/RestExLib.h
> b/RedfishPkg/Include/Library/RestExLib.h
> index bc4e4ca6caa7..2c32c3684cf4 100644
> --- a/RedfishPkg/Include/Library/RestExLib.h
> +++ b/RedfishPkg/Include/Library/RestExLib.h
> @@ -2,6 +2,7 @@
>This library provides help functions for REST EX Protocol.
> 
>(C) Copyright 2020 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -20,6 +21,7 @@
>This function allows the caller to create child handle for specific
>REST server.
> 
> +  @param[in]  Controller   The controller handle used of selected
> interface.
>@param[in]  ImageThe image handle used to open service.
>@param[in]  AccessMode   Access mode of REST server.
>@param[in]  ConfigType   Underlying configuration to communicate
> with REST server.
> @@ -32,6 +34,7 @@
>  **/
>  EFI_STATUS
>  RestExLibCreateChild (
> +  IN EFI_HANDLE   Controller,
>IN EFI_HANDLE   Image,
>IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
>IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
> diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
> b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
> index d9acad24dec1..0b3ae2755e86 100644
> --- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
> +++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
> @@ -2,6 +2,7 @@
>This library provides help functions for REST EX Protocol.
> 
>(C) Copyright 2020 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -9,6 +10,7 @@
> 
>  #include 
>  #include 
> +#include 
>  #include   #include 
> #include 
> @@ -21,6 +23,7 @@
>This function allows the caller to create child handle for specific
>REST server.
> 
> +  @param[in]  Controller   The controller handle used of selected
> interface.
>@param[in]  ImageThe image handle used to open service.
>@param[in]  AccessMode   Access mode of REST server.
>@param[in]  ConfigType   Underlying configuration to communicate
> with REST server.
> @@ -33,6 +36,7 @@
>  **/
>  EFI_STATUS
>  RestExLibCreateChild (
> +  IN EFI_HANDLE   Controller,
>IN EFI_HANDLE   Image,
>IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
>IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
> @@ -41,8 +45,6 @@ RestExLibCreateChild (
>)
>  {
>EFI_STATUSStatus;
> -  UINTN NoBuffer;
> -  EFI_HANDLE*Handle;
>EFI_HANDLEChildHandle;
>EFI_REST_EX_PROTOCOL  *RestEx;
>EFI_REST_EX_SERVICE_INFO  *RestExServiceInfo; @@ -59,116 +61,79 @@
> RestExLibCreateChild (
>}
> 
>*ChildInstanceHandle = NULL;
> -  //
> -  // Locate all REST EX binding service.
> -  //
> -  Handle   = NULL;
> -  NoBuffer = 0;
> -  Status   = gBS->LocateHandleBuffer (
> -ByProtocol,
> -&gEfiRestExServiceBindingProtocolGuid,
> -NULL,
> -&NoBuffer,
> -&Handle
> -);
> -  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
> +
> +  ChildHandle = NULL;
> +  Status = NetLibCreateServiceChild (
> + Controller,
> + Image,
> + &gEfiRestExServ

Re: [edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

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

Hi Minh,
Please add my RB for 3/5 in commit message and push to 
minhnampere:Adding_necessary_changes_for_RedfishPkg again.   I will check the 
PR and merge it once it passes CI.

Thank for your contribution.
Abner

> -Original Message-
> From: minhnampere 
> Sent: Friday, May 5, 2023 2:46 PM
> To: devel@edk2.groups.io
> Cc: patc...@amperecomputing.com; Chang, Abner
> ; nick...@nvidia.com; ig...@ami.com;
> n...@os.amperecomputing.com; tinhngu...@os.amperecomputing.com;
> minhnampere 
> Subject: [PATCH V3 0/5] Adding necessary changes for RedfishPkg
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> This patchset adds necessary changes for RedfishPkg to avoid some
> unexpected cases and fix compilation.
> 
> Changes since v3:
>  + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
> Changes since v2:
>  + Added "Cc:" to maintainers in commit message.
>  + Corrected patch format subject prefix.
> Changes since v1:
>  + Removed redundant change and change the commit message for more
> precise in PATCH 2/5.
> 
> Nhi Pham (1):
>   RedfishPkg: Add missing newline character
> 
> Vu Nguyen (4):
>   RedfishPkg: Correct variable type to prevent memory corruption
>   RedfishPkg: Fix condition checking of error status
>   RedfishPkg: Create RestEx child on selected interface
>   RedfishPkg: Fix compile issue on Linux
> 
>  RedfishPkg/Include/Library/RestExLib.h   |   3 +
>  RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
>  RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
>  RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153 
> 
> 
>  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
>  RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
>  6 files changed, 73 insertions(+), 98 deletions(-)
> 
> --
> 2.39.0


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




回复: [edk2-devel] [PATCH v6 08/16] Add GCC and GCCNOLTO toolchains to tools_def.txt and update packages

2023-05-05 Thread gaoliming via groups.io
Jiewen:
  As Rebecca describes, IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc GCC49 tool 
chain adds -flto option to enable link-time optimization. 
  So, new GCCNOLTO also copies this option. QemuFspPkg.dsc is in IntelFsp2Pkg. 
Fsp2Pkg maintainer may give the answer why adds -flto option for GCC49.

Rebecca:
  This patch makes the changes cross the different packages. So, it may bring 
the confuse to the different package maintainers. Can these changes be 
separated for the different packages?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Rebecca Cran
> 发送时间: 2023年5月5日 10:12
> 收件人: Yao, Jiewen ; Gao, Liming
> ; devel@edk2.groups.io; Wang, Jian J
> ; Lu, Xiaoyu1 ; Jiang, Guomin
> ; 'Andrew Fish' ; Ni, Ray
> ; Chiu, Chasel ; Desimone,
> Nathaniel L ; Zeng, Star
> 
> 主题: Re: [edk2-devel] [PATCH v6 08/16] Add GCC and GCCNOLTO toolchains
> to tools_def.txt and update packages
> 
> If you look at the entire block, GCC49 also has -flto, so since GCCNOLTO
> is a copy of GCC49, that's why it has -flto:
> 
> 
> # Append build options for EDK and EDKII drivers (= is Append, == is
> Replace)
># Enable link-time optimization when building with GCC49 or GCCNOLTO
>*_GCC49_IA32_CC_FLAGS = -flto
>*_GCC49_IA32_DLINK_FLAGS = -flto
>*_GCCNOLTO_IA32_CC_FLAGS = -flto
>*_GCCNOLTO_IA32_DLINK_FLAGS = -flto
>*_GCC5_IA32_CC_FLAGS = -fno-pic
>*_GCC5_IA32_DLINK_FLAGS = -no-pie
>*_GCC5_IA32_ASLCC_FLAGS = -fno-pic
>*_GCC5_IA32_ASLDLINK_FLAGS = -no-pie
>*_GCC_IA32_CC_FLAGS = -fno-pic
>*_GCC_IA32_DLINK_FLAGS = -no-pie
>*_GCC_IA32_ASLCC_FLAGS = -fno-pic
>*_GCC_IA32_ASLDLINK_FLAGS = -no-pie
> 
> Hopefully we can remove the flag in future, but since it's in
> IntelFsp2Pkg/Tools/Tests/QemuFspPkg.dsc and not a main .dsc file I'm not
> sure it's very important.
> 
> 
> --
> 
> Rebecca Cran
> 
> 
> On 5/4/23 20:02, Yao, Jiewen wrote:
> > Thanks Liming.
> >
> > I am not sure below change is expected or not. Please feedback if possible.
> Thank you!
> >
> >> Why we add "-flto" for "NOLTO" ?
>  +  *_GCCNOLTO_IA32_CC_FLAGS = -flto
>  +  *_GCCNOLTO_IA32_DLINK_FLAGS = -flto
> >
> >> -Original Message-
> >> From: gaoliming 
> >> Sent: Friday, May 5, 2023 10:00 AM
> >> To: devel@edk2.groups.io; rebe...@bsdio.com; Yao, Jiewen
> >> ; Wang, Jian J ; Lu,
> Xiaoyu1
> >> ; Jiang, Guomin ;
> 'Andrew
> >> Fish' ; Ni, Ray ; Chiu, Chasel
> >> ; Desimone, Nathaniel L
> >> ; Zeng, Star 
> >> Subject: 回复: [edk2-devel] [PATCH v6 08/16] Add GCC and GCCNOLTO
> >> toolchains to tools_def.txt and update packages
> >>
> >> Rebecca:
> >>I understand this change is to add GCC and GCCNOLTO toolchain. GCC
> is
> >> same to GCC5, GCCNOLTO is same to GCC49. So, new tool chain copies the
> >> same changes from origin one. Right?
> >>
> >> Thanks
> >> Liming
> >>> -邮件原件-
> >>> 发件人: devel@edk2.groups.io  代表 Rebecca
> >> Cran
> >>> 发送时间: 2023年5月2日 22:23
> >>> 收件人: Yao, Jiewen ; devel@edk2.groups.io;
> >> Wang,
> >>> Jian J ; Lu, Xiaoyu1 ;
> Jiang,
> >>> Guomin ; Andrew Fish ; Ni,
> >> Ray
> >>> ; Chiu, Chasel ; Desimone,
> >>> Nathaniel L ; Zeng, Star
> >>> 
> >>> 主题: Re: [edk2-devel] [PATCH v6 08/16] Add GCC and GCCNOLTO
> >> toolchains
> >>> to tools_def.txt and update packages
> >>>
> >>> On 5/2/23 00:35, Yao, Jiewen wrote:
>  Have you evaluated size impact with this new compiler option?
> Especially
> >>> crypto library.
>  Bigger? Smaller?
> >>> The increase in size when we disable LTO doesn't seem too bad:
> >>>
> >>> With LTO:
> >>>
> >>> -rwxrwxr-x 1 bcran bcran   13M May  2 08:11
> >>> CryptoDxe_41A491D1-A972-468B-A299-DABF415A43B7.debug
> >>> -rwxrwxr-x 1 bcran bcran   13M May  2 08:11
> >>> CryptoDxe_AA83B296-F6EA-447F-B013-E80E98629CF8.debug
> >>> -rwxrwxr-x 1 bcran bcran   11M May  2 08:11
> >>> CryptoDxe_9FBDAD27-910C-4229-9EFF-A93BB5FE18C6.debug
> >>> -rwxrwxr-x 1 bcran bcran   11M May  2 08:11
> >>> CryptoDxe_ADD6D05A-52A2-437B-98E7-DBFDA89352CD.debug
> >>> -rwxrwxr-x 1 bcran bcran  8.5M May  2 08:11
> >>> CryptoSmm_C1760694-AB3A-4532-8C6D-52D8F86EB1AA.debug
> >>> -rwxrwxr-x 1 bcran bcran  8.3M May  2 08:11
> >>> CryptoSmm_1930CE7E-6598-48ED-8AB1-EBE7E85EC254.debug
> >>> -rwxrwxr-x 1 bcran bcran  8.0M May  2 08:11
> >>> CryptoPei_A10827AD-7598-4955-B661-52EE2B62B057.debug
> >>> -rwxrwxr-x 1 bcran bcran  7.8M May  2 08:11
> >>> CryptoPei_D51FCE59-6860-49C0-9B35-984470735D17.debug
> >>> -rwxrwxr-x 1 bcran bcran  7.0M May  2 08:11
> >>> BaseCryptLibUnitTestShell.debug
> >>> -rwxrwxr-x 1 bcran bcran  7.0M May  2 08:11
> >>> CryptoSmm_828959D3-CEA6-4B79-B1FC-5AFA0D7F2144.debug
> >>> -rwxrwxr-x 1 bcran bcran  6.9M May  2 08:11
> >>> CryptoDxe_31C17C54-325D-47D5-8622-888098F10E44.debug
> >>> -rwxrwxr-x 1 bcran bcran  6.7M May  2 08:11
> >>> CryptoSmm_E4D7D1E3-E886-4412-A442-EFD6F2502DD3.debug
> >>> -rwxrwxr-x 1 bcran bcran  6.7M May  2 08:11
> >>> CryptoSmm_1A1C9E13-5722-4636-AB73-31328EDE8BAF.debug
> >>> -rwxrwxr-x 1 bcran bcran  6.5M May  2 08:11
> >>> CryptoPei_DCC9CB49-

Re: [edk2-devel] [PATCH] MdePkg/BasePeCoffLib: Deal with broken debug directories

2023-05-05 Thread Ard Biesheuvel
On Fri, 5 May 2023 at 03:56, Michael Kubacki
 wrote:
>
> Acked-by: Michael Kubacki 
>

Merged as #4340

Thanks all


> On 5/4/2023 10:47 AM, Ard Biesheuvel wrote:
> > Older versions of GenFw put the wrong value in the debug directory size
> > field in the PE/COFF header: instead of putting the combined size of all
> > the entries, it puts the size of the only entry it creates, but adds the
> > size of the NB10 payload that the entry points to. This confuses the
> > loader now that we started using additional debug directory entries to
> > describe DLL characteristics.
> >
> > GenFw was fixed in commit 60e85a39fe49071, but the binaries that were
> > generated with it still need to be supported.
> >
> > So let's detect this condition, and check whether the size of the debug
> > directory is consistent with the NB10 payload: if we should expect
> > additional directory entries where we observe the NB10 payload, the size
> > field is clearly wrong, and we can break from the loop.
> >
> > BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4425
> > Signed-off-by: Ard Biesheuvel 
> > ---
> >   MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 14 ++
> >   1 file changed, 14 insertions(+)
> >
> > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c 
> > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > index 4b71176a0c7c2ed0..27f8526370fa3859 100644
> > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c
> > @@ -585,6 +585,7 @@ PeCoffLoaderGetImageInfo (
> > UINTNSize;
> >
> > UINTNReadSize;
> >
> > UINTNIndex;
> >
> > +  UINTNNextIndex;
> >
> > UINTNDebugDirectoryEntryRva;
> >
> > UINTNDebugDirectoryEntryFileOffset;
> >
> > UINTNSectionHeaderOffset;
> >
> > @@ -755,6 +756,19 @@ PeCoffLoaderGetImageInfo (
> > ImageContext->ImageSize += DebugEntry.SizeOfData;
> >
> >   }
> >
> >
> >
> > +//
> >
> > +// Implementations of GenFw before commit 60e85a39fe49071 will
> >
> > +// concatenate the debug directory entry and the codeview 
> > entry,
> >
> > +// and erroneously put the combined size into the debug 
> > directory
> >
> > +// entry's size field. If this is the case, no other relevant
> >
> > +// directory entries can exist, and we can terminate here.
> >
> > +//
> >
> > +NextIndex = Index + sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
> >
> > +if ((NextIndex < DebugDirectoryEntry->Size) &&
> >
> > +(DebugEntry.FileOffset == (DebugDirectoryEntryFileOffset + 
> > NextIndex))) {
> >
> > +  break;
> >
> > +}
> >
> > +
> >
> >   continue;
> >
> > }
> >
> >
> >
>
>
> 
>
>


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




Re: [edk2-devel] [PATCH v6 08/16] Add GCC and GCCNOLTO toolchains to tools_def.txt and update packages

2023-05-05 Thread Rebecca Cran
On Fri, May 5, 2023, at 1:41 AM, gaoliming via groups.io wrote:
> Rebecca:
>   This patch makes the changes cross the different packages. So, it may 
> bring the confuse to the different package maintainers. Can these 
> changes be separated for the different packages?
>

Yes, I can send the changes that haven’t had reviews yet as new separate 
patches.

And to avoid further delay and reduce confusion, I can merge the patches which 
have already been reviewed.

Rebecca


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




Re: [edk2-devel] [RFC PATCH v1 00/30] Support for Arm CCA guest firmware

2023-05-05 Thread Jean-Philippe Brucker
On Thu, May 04, 2023 at 05:36:32PM +0200, Ard Biesheuvel wrote:
> On Thu, 4 May 2023 at 17:13, Jean-Philippe Brucker
>  wrote:
> >
> > Hello,
> >
> > On Tue, Apr 25, 2023 at 05:03:58PM +0100, Sami Mujawar wrote:
> > > We are happy to announce an early RFC version of the Arm Confidential
> > > Compute Architecture (CCA) support for the Kvmtool guest firmware.
> > > The intention is to seek early feedback in the following areas:
> > >  * Integration of the Arm CCA in ArmVirtPkg
> > >  * Generalise the operations wherever possible with other Confidential
> > >Compute solutions and Virtual Machine Managers (VMMs)
> >
> > Experimental support for ArmVirtQemu is available at [1]. Most of it
> > simply includes Sami's libraries into ArmVirtQemu, but there are a few
> > things specific to QEMU, one of which I still haven't figured out.
> >
> > The early debug support in PEI is problematic. A realm must access the
> > emulated serial port through unprotected Intermediate Physical Address
> > (IPA aka GPA) which is the upper half of the IPA space. The IPA address
> > must have the most significant bit set. Once the MMU is enabled and
> > ArmCcaConfigureMmio() runs, the page tables point to the right IPA so
> > there is no problem. Before that however, EarlyFdtPL011SerialPortLib would
> > need to access the device using the unprotected IPA address. So far I
> > haven't managed to implement this, so the early serial debug is just
> > disabled.
> >
> 
> Did you spot the changes I made recently for booting at EL1 with hard
> coded [initial] page tables in flash? It seems to me that mapping the
> serial port in there shouldn't be that hard.

Ah I did but I had misunderstood your change, it does set a TTBR right at
the beginning in ArmPlatformPeiBootAction. Although we can't hardcode the
serial port mapping (because its address in a Realm depends on the IPA
width which varies across VM configurations), I can probably patch it
early enough.

Thanks,
Jean


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




[edk2-devel] Request to open an bugzilla's account

2023-05-05 Thread Dongyan Qian
Hi Liming,

 please help me to open a bugzilla account.  




Thanks

Dongyan

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




[edk2-devel] [PATCH v3 0/2] OvmfPkg: move two include files to Include/Fdf

2023-05-05 Thread Gerd Hoffmann
v3:
 - rebase to latest master
v2:
 - rebase to latest master

Gerd Hoffmann (2):
  OvmfPkg: move OvmfTpmPei.fdf.inc to Include/Fdf
  OvmfPkg: move OvmfTpmDxe.fdf.inc to Include/Fdf

 OvmfPkg/AmdSev/AmdSevX64.fdf | 4 ++--
 OvmfPkg/CloudHv/CloudHvX64.fdf   | 4 ++--
 OvmfPkg/OvmfPkgIa32.fdf  | 4 ++--
 OvmfPkg/OvmfPkgIa32X64.fdf   | 4 ++--
 OvmfPkg/OvmfPkgX64.fdf   | 4 ++--
 OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc | 0
 OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc | 0
 7 files changed, 10 insertions(+), 10 deletions(-)
 rename OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc (100%)
 rename OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc (100%)

-- 
2.40.1



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




[edk2-devel] [PATCH v3 1/2] OvmfPkg: move OvmfTpmPei.fdf.inc to Include/Fdf

2023-05-05 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/AmdSev/AmdSevX64.fdf | 2 +-
 OvmfPkg/CloudHv/CloudHvX64.fdf   | 2 +-
 OvmfPkg/OvmfPkgIa32.fdf  | 2 +-
 OvmfPkg/OvmfPkgIa32X64.fdf   | 2 +-
 OvmfPkg/OvmfPkgX64.fdf   | 2 +-
 OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc | 0
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc (100%)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
index 5fb3b5d27632..25e446013cd4 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
@@ -162,7 +162,7 @@ [FV.PEIFV]
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 INF  OvmfPkg/AmdSev/SecretPei/SecretPei.inf
 
-!include OvmfPkg/OvmfTpmPei.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
 
 

 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf
index 0d13d4066d27..62d048bce181 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.fdf
+++ b/OvmfPkg/CloudHv/CloudHvX64.fdf
@@ -168,7 +168,7 @@ [FV.PEIFV]
 !endif
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
-!include OvmfPkg/OvmfTpmPei.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 15a25f1be5e5..63b9ef5d9674 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -172,7 +172,7 @@ [FV.PEIFV]
 !endif
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
-!include OvmfPkg/OvmfTpmPei.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 138cbd382d4e..36eb28c34f89 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -172,7 +172,7 @@ [FV.PEIFV]
 !endif
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
-!include OvmfPkg/OvmfTpmPei.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 4f24051ae994..d9ecc837295a 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -188,7 +188,7 @@ [FV.PEIFV]
 INF  UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 INF  FILE_GUID = $(UP_CPU_PEI_GUID) UefiCpuPkg/CpuMpPei/CpuMpPei.inf
 
-!include OvmfPkg/OvmfTpmPei.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfTpmPei.fdf.inc b/OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmPei.fdf.inc
rename to OvmfPkg/Include/Fdf/OvmfTpmPei.fdf.inc
-- 
2.40.1



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




[edk2-devel] [PATCH v3 2/2] OvmfPkg: move OvmfTpmDxe.fdf.inc to Include/Fdf

2023-05-05 Thread Gerd Hoffmann
Signed-off-by: Gerd Hoffmann 
---
 OvmfPkg/AmdSev/AmdSevX64.fdf | 2 +-
 OvmfPkg/CloudHv/CloudHvX64.fdf   | 2 +-
 OvmfPkg/OvmfPkgIa32.fdf  | 2 +-
 OvmfPkg/OvmfPkgIa32X64.fdf   | 2 +-
 OvmfPkg/OvmfPkgX64.fdf   | 2 +-
 OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc | 0
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc (100%)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.fdf b/OvmfPkg/AmdSev/AmdSevX64.fdf
index 25e446013cd4..fec08468d3e0 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.fdf
+++ b/OvmfPkg/AmdSev/AmdSevX64.fdf
@@ -316,7 +316,7 @@ [FV.DXEFV]
 #
 # TPM support
 #
-!include OvmfPkg/OvmfTpmDxe.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
 
 

 
diff --git a/OvmfPkg/CloudHv/CloudHvX64.fdf b/OvmfPkg/CloudHv/CloudHvX64.fdf
index 62d048bce181..72de7bcdad66 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.fdf
+++ b/OvmfPkg/CloudHv/CloudHvX64.fdf
@@ -343,7 +343,7 @@ [FV.DXEFV]
 #
 # TPM support
 #
-!include OvmfPkg/OvmfTpmDxe.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 63b9ef5d9674..c9c938439759 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -372,7 +372,7 @@ [FV.DXEFV]
 #
 # TPM support
 #
-!include OvmfPkg/OvmfTpmDxe.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
 
 !if $(LOAD_X64_ON_IA32_ENABLE) == TRUE
 INF  OvmfPkg/CompatImageLoaderDxe/CompatImageLoaderDxe.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 36eb28c34f89..f52219e0c26d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -379,7 +379,7 @@ [FV.DXEFV]
 #
 # TPM support
 #
-!include OvmfPkg/OvmfTpmDxe.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index d9ecc837295a..00c7f8849fb8 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -413,7 +413,7 @@ [FV.DXEFV]
 #
 # TPM support
 #
-!include OvmfPkg/OvmfTpmDxe.fdf.inc
+!include OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
 
 

 
diff --git a/OvmfPkg/OvmfTpmDxe.fdf.inc b/OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
similarity index 100%
rename from OvmfPkg/OvmfTpmDxe.fdf.inc
rename to OvmfPkg/Include/Fdf/OvmfTpmDxe.fdf.inc
-- 
2.40.1



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




[edk2-devel] [PATCH v2] MinPlatformPkg: Update ACPI 6.5 definition

2023-05-05 Thread Chen, Aryeh
From: Aryeh Chen 

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

Update ACPI 6.5 definition on MinPlatformPkg

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 
Cc: Liming Gao 
Cc: Eric Dong 
Cc: Jiewen Yao 
Cc: Ankit Sinha

Signed-off-by: Aryeh Chen 
---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c   
   | 154 ++--
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/Facs/Facs.c  
   |   8 +-
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/Fadt/Fadt.c  
   |  46 +++---
 Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/Hpet/Hpet.c  
   |   4 +-
 Platform/Intel/MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.c   
   |   2 +-
 Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpi.c
   | 154 ++--
 
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckAcpiMadt.c 
  | 150 +--
 
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckDmaProtection.c
  |   4 +-
 
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckTcgTrustedBoot.c
 |   2 +-
 
Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c
   |   2 +-
 10 files changed, 263 insertions(+), 263 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c 
b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
index e967031a3b..2f2c96f907 100644
--- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
+++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c
@@ -27,9 +27,9 @@ typedef struct {
 // Define Union of IO APIC & Local APIC structure;
 //
 typedef union {
-  EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_STRUCTURE   AcpiLocalApic;
-  EFI_ACPI_6_3_IO_APIC_STRUCTUREAcpiIoApic;
-  EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_STRUCTURE AcpiLocalx2Apic;
+  EFI_ACPI_6_5_PROCESSOR_LOCAL_APIC_STRUCTURE   AcpiLocalApic;
+  EFI_ACPI_6_5_IO_APIC_STRUCTUREAcpiIoApic;
+  EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC_STRUCTURE AcpiLocalx2Apic;
   struct {
 UINT8 Type;
 UINT8 Length;
@@ -38,8 +38,8 @@ typedef union {
 
 #pragma pack()
 
-extern EFI_ACPI_6_3_FIRMWARE_ACPI_CONTROL_STRUCTURE Facs;
-extern EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLEFadt;
+extern EFI_ACPI_6_5_FIRMWARE_ACPI_CONTROL_STRUCTURE Facs;
+extern EFI_ACPI_6_5_FIXED_ACPI_DESCRIPTION_TABLEFadt;
 extern EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER Hpet;
 extern EFI_ACPI_WSMT_TABLE Wsmt;
 
@@ -92,16 +92,16 @@ AppendCpuMapTableEntry (
   )
 {
   EFI_STATUSStatus;
-  EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_STRUCTURE   *LocalApicPtr;
-  EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_STRUCTURE *LocalX2ApicPtr;
+  EFI_ACPI_6_5_PROCESSOR_LOCAL_APIC_STRUCTURE   *LocalApicPtr;
+  EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC_STRUCTURE *LocalX2ApicPtr;
   UINT8 Type;
 
   Status = EFI_SUCCESS;
   Type = ((ACPI_APIC_STRUCTURE_PTR *)ApicPtr)->AcpiApicCommon.Type;
-  LocalApicPtr = (EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_STRUCTURE 
*)(&((ACPI_APIC_STRUCTURE_PTR *)ApicPtr)->AcpiLocalApic);
-  LocalX2ApicPtr = (EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC_STRUCTURE 
*)(&((ACPI_APIC_STRUCTURE_PTR *)ApicPtr)->AcpiLocalx2Apic);
+  LocalApicPtr = (EFI_ACPI_6_5_PROCESSOR_LOCAL_APIC_STRUCTURE 
*)(&((ACPI_APIC_STRUCTURE_PTR *)ApicPtr)->AcpiLocalApic);
+  LocalX2ApicPtr = (EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC_STRUCTURE 
*)(&((ACPI_APIC_STRUCTURE_PTR *)ApicPtr)->AcpiLocalx2Apic);
 
-  if(Type == EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC) {
+  if(Type == EFI_ACPI_6_5_PROCESSOR_LOCAL_APIC) {
 if(!mX2ApicEnabled) {
   LocalApicPtr->Flags= 
(UINT8)CpuApicIdOrderTable[LocalApicCounter].Flags;
   LocalApicPtr->ApicId   = 
(UINT8)CpuApicIdOrderTable[LocalApicCounter].ApicId;
@@ -112,7 +112,7 @@ AppendCpuMapTableEntry (
   LocalApicPtr->AcpiProcessorUid = (UINT8)0xFF;
   Status = EFI_UNSUPPORTED;
 }
-  } else if(Type == EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC) {
+  } else if(Type == EFI_ACPI_6_5_PROCESSOR_LOCAL_X2APIC) {
 if(mX2ApicEnabled) {
   LocalX2ApicPtr->Flags= 
(UINT8)CpuApicIdOrderTable[LocalApicCounter].Flags;
   LocalX2ApicPtr->X2ApicId = 
CpuApicIdOrderTable[LocalApicCounter].ApicId;
@@ -215,17 +215,17 @@ typedef struct {
 } STRUCTURE_HEADER;
 
 STRUCTURE_HEADER mMadtStructureTable[] = {
-  {EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC,  sizeof 
(EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC_STRUCTURE)},
-  {EFI_ACPI_6_3_IO_APIC,   sizeof 
(EFI_ACPI_6_3_IO_APIC_STRUCTURE)},
-  {EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE, sizeof 
(EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE)},
-  {EFI_ACPI_6_3_NON_MASKABLE_INTERRUPT_SOURCE, sizeof 
(EFI_ACPI_6_3_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE)},
-  {EFI_ACPI_6_3_LOCAL_APIC_NMI,sizeof 
(EFI_ACPI_6_3_LOCAL_APIC_NMI_STRUCTURE)},
-  {EFI_ACPI_6_3_LOCAL_APIC_ADDR

[edk2-devel] [PATCH v1 00/11] DynamicTablesPkg: Enable _PSD/_CPC generation using SCMI

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The SCMI performance protocol allows to query the Operating Performance
Points (OPPs) available for each performance domain. Each OPP has a
specific frequency/power consumption/performance.

On Device Tree (DT) based platforms, the SCMI protocol is directly available
from the OS.
On ACPI based platforms, the _PSD objects allows to identify CPUs belonging
to the same performance domain. CPUs belonging to the same performance
domain have the same frequency. The _CPC object allows to describe/control
the performance level/frequency of a CPU (i.e. its frequency).

This patchset:
- Add support for 'DescribeFastchannel' SCMI performance protocol
- Add a object to the DynamicTablesPkg to describe the PSD information
- Allows to generate _PSD objects in the SsdtCpuTopologyGenerator
- Add a ArmScmiInfoLib library populating DynamicTablesPkg CPC objects,
  relying on the SCMI protocol to fetch the relevant information

A patchset for Juno-r2 platforms will be submitted to demonstrate
this functionality.

Pierre Gondois (11):
  ArmPkg/ArmScmiDxe: Rename PERFORMANCE_PROTOCOL_VERSION
  ArmPkg/ArmScmiDxe: Add PERFORMANCE_DESCRIBE_FASTCHANNEL support
  MdePkg/Acpi64: Add _PSD/_CPC/State Coordination Types macros
  DynamicTablesPkg: Use new CPC revision macro
  DynamicTablesPkg: Rename AmlCpcInfo.h to AcpiObjects.h
  DynamicTablesPkg: Add CM_ARM_PSD_INFO object
  DynamicTablesPkg: Add PsdToken field to CM_ARM_GICC_INFO object
  DynamicTablesPkg: Add AmlCreatePsdNode() to generate _PSD
  DynamicTablesPkg: Generate _PSD in SsdtCpuTopologyGenerator
  DynamicTablesPkg: Add ArmScmiInfoLib
  DynamicTablesPkg: Remove check for _CPC field

 .../ArmScmiDxe/ScmiPerformanceProtocol.c  |  80 -
 .../Protocol/ArmScmiPerformanceProtocol.h | 101 +-
 DynamicTablesPkg/DynamicTables.dsc.inc|   1 +
 DynamicTablesPkg/DynamicTablesPkg.dec |   3 +
 DynamicTablesPkg/DynamicTablesPkg.dsc |   1 +
 .../Include/{AmlCpcInfo.h => AcpiObjects.h}   |  20 ++
 .../Include/ArmNameSpaceObjects.h |  19 +-
 .../Include/Library/AmlLib/AmlLib.h   |  37 ++-
 .../Include/Library/ArmScmiInfoLib.h  |  33 ++
 .../SsdtCpuTopologyGenerator.c|  98 +-
 .../Library/ArmScmiInfoLib/ArmScmiInfoLib.c   | 294 ++
 .../Library/ArmScmiInfoLib/ArmScmiInfoLib.inf |  31 ++
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 211 -
 .../ConfigurationManagerObjectParser.c|  14 +-
 MdePkg/Include/IndustryStandard/Acpi64.h  |  25 +-
 15 files changed, 935 insertions(+), 33 deletions(-)
 rename DynamicTablesPkg/Include/{AmlCpcInfo.h => AcpiObjects.h} (88%)
 create mode 100644 DynamicTablesPkg/Include/Library/ArmScmiInfoLib.h
 create mode 100644 DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.c
 create mode 100644 DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.inf

-- 
2.25.1



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




[edk2-devel] [PATCH v1 01/11] ArmPkg/ArmScmiDxe: Rename PERFORMANCE_PROTOCOL_VERSION

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Rename PERFORMANCE_PROTOCOL_VERSION to reflect the different
versions of the protocol. The macro is neither used in edk2 nor
in edk2-platforms.

Signed-off-by: Pierre Gondois 
---
 .../Include/Protocol/ArmScmiPerformanceProtocol.h   | 13 -
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h 
b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
index 7e548e4765c2..8e8e05d5a5f6 100644
--- a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
+++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
@@ -1,12 +1,12 @@
 /** @file
 
-  Copyright (c) 2017-2021, Arm Limited. All rights reserved.
+  Copyright (c) 2017-2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
-  System Control and Management Interface V1.0
-http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
-DEN0056A_System_Control_and_Management_Interface.pdf
+  System Control and Management Interface, latest version:
+  - https://developer.arm.com/documentation/den0056/latest/
+
 **/
 
 #ifndef ARM_SCMI_PERFORMANCE_PROTOCOL_H_
@@ -14,7 +14,10 @@
 
 #include 
 
-#define PERFORMANCE_PROTOCOL_VERSION  0x1
+/// Arm Scmi performance protocol versions.
+#define PERFORMANCE_PROTOCOL_VERSION_V1  0x1
+#define PERFORMANCE_PROTOCOL_VERSION_V2  0x2
+#define PERFORMANCE_PROTOCOL_VERSION_V3  0x3
 
 #define ARM_SCMI_PERFORMANCE_PROTOCOL_GUID  { \
   0x9b8ba84, 0x3dd3, 0x49a6, {0xa0, 0x5a, 0x31, 0x34, 0xa5, 0xf0, 0x7b, 0xad} \
-- 
2.25.1



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




[edk2-devel] [PATCH v1 02/11] ArmPkg/ArmScmiDxe: Add PERFORMANCE_DESCRIBE_FASTCHANNEL support

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The PERFORMANCE_DESCRIBE_FASTCHANNEL Scmi command is available
since SCMI v2.0 and allows to query information about the supported
fast-channels of the Scmi performance protocol.
Add support for this command.

Signed-off-by: Pierre Gondois 
---
 .../ArmScmiDxe/ScmiPerformanceProtocol.c  | 80 +++--
 .../Protocol/ArmScmiPerformanceProtocol.h | 90 ---
 2 files changed, 155 insertions(+), 15 deletions(-)

diff --git a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c 
b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
index 0f89808fbdf9..1d87339209fd 100644
--- a/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
+++ b/ArmPkg/Drivers/ArmScmiDxe/ScmiPerformanceProtocol.c
@@ -1,12 +1,12 @@
 /** @file
 
-  Copyright (c) 2017-2021, Arm Limited. All rights reserved.
+  Copyright (c) 2017-2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
-  System Control and Management Interface V1.0
-http://infocenter.arm.com/help/topic/com.arm.doc.den0056a/
-DEN0056A_System_Control_and_Management_Interface.pdf
+  System Control and Management Interface, latest version:
+  - https://developer.arm.com/documentation/den0056/latest/
+
 **/
 
 #include 
@@ -416,6 +416,75 @@ PerformanceLevelGet (
   return EFI_SUCCESS;
 }
 
+/** Discover the attributes of the FastChannel for the specified
+performance domain and the specified message.
+
+  @param[in]  ThisA Pointer to SCMI_PERFORMANCE_PROTOCOL Instance.
+  @param[in]  DomainIdIdentifier for the performance domain.
+  @param[in]  MessageId   Message Id of the FastChannel to discover.
+  Must be one of:
+   - PERFORMANCE_LIMITS_SET
+   - PERFORMANCE_LIMITS_GET
+   - PERFORMANCE_LEVEL_SET
+   - PERFORMANCE_LEVEL_GET
+  @param[out] FastChannel If success, contains the FastChannel description.
+
+  @retval EFI_SUCCESS Performance level got successfully.
+  @retval EFI_DEVICE_ERRORSCP returns an SCMI error.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_TIMEOUT Time out.
+  @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+DescribeFastchannel (
+  IN  SCMI_PERFORMANCE_PROTOCOL *This,
+  IN  UINT32DomainId,
+  IN  SCMI_MESSAGE_ID_PERFORMANCE   MessageId,
+  OUT SCMI_PERFORMANCE_FASTCHANNEL  *FastChannel
+  )
+{
+  EFI_STATUSStatus;
+  SCMI_COMMAND  Cmd;
+  UINT32PayloadLength;
+  UINT32*ReturnValues;
+  UINT32*MessageParams;
+
+  if ((This == NULL)  ||
+  (FastChannel == NULL))
+  {
+return EFI_INVALID_PARAMETER;
+  }
+
+  Status = ScmiCommandGetPayload (&MessageParams);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  *MessageParams++ = DomainId;
+  *MessageParams   = MessageId;
+
+  Cmd.ProtocolId = ScmiProtocolIdPerformance;
+  Cmd.MessageId  = ScmiMessageIdPerformanceDescribeFastchannel;
+  PayloadLength  = sizeof (DomainId) + sizeof (MessageId);
+
+  Status = ScmiCommandExecute (
+ &Cmd,
+ &PayloadLength,
+ &ReturnValues
+ );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  CopyMem (
+FastChannel,
+ReturnValues,
+sizeof (SCMI_PERFORMANCE_FASTCHANNEL)
+);
+
+  return Status;
+}
+
 // Instance of the SCMI performance management protocol.
 STATIC CONST SCMI_PERFORMANCE_PROTOCOL  PerformanceProtocol = {
   PerformanceGetVersion,
@@ -425,7 +494,8 @@ STATIC CONST SCMI_PERFORMANCE_PROTOCOL  PerformanceProtocol 
= {
   PerformanceLimitsSet,
   PerformanceLimitsGet,
   PerformanceLevelSet,
-  PerformanceLevelGet
+  PerformanceLevelGet,
+  DescribeFastchannel,
 };
 
 /** Initialize performance management protocol and install on a given Handle.
diff --git a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h 
b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
index 8e8e05d5a5f6..088182945a06 100644
--- a/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
+++ b/ArmPkg/Include/Protocol/ArmScmiPerformanceProtocol.h
@@ -14,7 +14,7 @@
 
 #include 
 
-/// Arm Scmi performance protocol versions.
+/// Arm SCMI performance protocol versions.
 #define PERFORMANCE_PROTOCOL_VERSION_V1  0x1
 #define PERFORMANCE_PROTOCOL_VERSION_V2  0x2
 #define PERFORMANCE_PROTOCOL_VERSION_V3  0x3
@@ -79,6 +79,56 @@ typedef struct {
   UINT32RangeMin;
 } SCMI_PERFORMANCE_LIMITS;
 
+/// Doorbell Support bit.
+#define SCMI_PERF_FC_ATTRIB_HAS_DOORBELL  BIT0
+
+/// Performance protocol describe fastchannel
+typedef struct {
+  /// Attributes.
+  UINT32Attributes;
+
+  /// Rate limit.
+  UINT32RateLimit;
+
+  /// Lower 32 bits of the FastChannel address.
+  UINT32ChanAddrLow;
+
+  /// Higher 32 bits of the FastChannel address.
+  UINT32ChanAddrHigh;
+
+  /// Size of the FastChannel in bytes.
+  UINT32ChanSize;
+
+  /// Lower 32 bits 

[edk2-devel] [PATCH v1 03/11] MdePkg/Acpi64: Add _PSD/_CPC/State Coordination Types macros

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Add macros for:
- _PSD version
- _CPC version
- C-state/T-state/P-state Coordination Types

These objects were present in previous ACPI specification version,
but are only added to the latest availbable version (6.4).

Signed-off-by: Pierre Gondois 
---
 MdePkg/Include/IndustryStandard/Acpi64.h | 25 +++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h 
b/MdePkg/Include/IndustryStandard/Acpi64.h
index 575ca0430c13..e3c128d7548d 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -2,7 +2,7 @@
   ACPI 6.4 definitions from the ACPI Specification Revision 6.4 Jan, 2021.
 
   Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
-  Copyright (c) 2019 - 2021, ARM Ltd. All rights reserved.
+  Copyright (c) 2019 - 2023, Arm Ltd. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -17,6 +17,29 @@
 //
 #pragma pack(1)
 
+///
+/// C-state/T-state/P-state Coordination Types
+/// Cf. s8.3 Power, Performance, and Throttling State Dependencies
+///
+#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ALL  0xFC
+#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ANY  0xFD
+#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_HW_ALL  0xFE
+
+///
+/// _PSD Revision
+/// Cf. s8.4.6.5 _PSD (P-State Dependency)
+///
+#define EFI_ACPI_6_4_AML_PSD_REVISION_V0  0
+
+///
+/// _CPC Revision
+/// Cf. s8.4.7.1 _CPC (Continuous Performance Control)
+///
+#define EFI_ACPI_6_4_AML_CPC_REVISION_V0  0
+#define EFI_ACPI_6_4_AML_CPC_REVISION_V1  1
+#define EFI_ACPI_6_4_AML_CPC_REVISION_V2  2
+#define EFI_ACPI_6_4_AML_CPC_REVISION_V3  3
+
 ///
 /// ACPI 6.4 Generic Address Space definition
 ///
-- 
2.25.1



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




[edk2-devel] [PATCH v1 04/11] DynamicTablesPkg: Use new CPC revision macro

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Make use of the newly added CPC revision macro.

Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 0b223379fa4b..0d1b959b74a5 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3083,7 +3083,7 @@ AmlCreateCpcNode (
   }
 
   // Revision 3 per ACPI 6.4 specification
-  if (CpcInfo->Revision == 3) {
+  if (CpcInfo->Revision == EFI_ACPI_6_4_AML_CPC_REVISION_V3) {
 // NumEntries 23 per ACPI 6.4 specification
 NumberOfEntries = 23;
   } else {
-- 
2.25.1



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




[edk2-devel] [PATCH v1 05/11] DynamicTablesPkg: Rename AmlCpcInfo.h to AcpiObjects.h

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The DynamicTables framework uses the AmlLib to generate some
Aml objects. It is done by using structured known by both
frameworks, e.g. the AML_CPC_INFO/CM_ARM_CPC_INFO structures.

To prepare adding similar structures (e.g. representing _PSD
information), rename AmlCpcInfo.h to AcpiObjects.h. This new
file will contain all the structures used by the AmlLib and
the DynamicTables framework.

Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/{AmlCpcInfo.h => AcpiObjects.h}| 0
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h  | 2 +-
 DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h| 2 +-
 DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c | 2 +-
 4 files changed, 3 insertions(+), 3 deletions(-)
 rename DynamicTablesPkg/Include/{AmlCpcInfo.h => AcpiObjects.h} (100%)

diff --git a/DynamicTablesPkg/Include/AmlCpcInfo.h 
b/DynamicTablesPkg/Include/AcpiObjects.h
similarity index 100%
rename from DynamicTablesPkg/Include/AmlCpcInfo.h
rename to DynamicTablesPkg/Include/AcpiObjects.h
diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 19098609de4b..8199882f69fe 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -13,7 +13,7 @@
 #ifndef ARM_NAMESPACE_OBJECTS_H_
 #define ARM_NAMESPACE_OBJECTS_H_
 
-#include 
+#include 
 #include 
 
 #pragma pack(1)
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index 9210c5091548..d1426b43fad3 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -36,7 +36,7 @@
   @}
 */
 
-#include 
+#include 
 #include 
 
 #ifndef AML_HANDLE
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 0d1b959b74a5..2147c152f484 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -11,7 +11,7 @@
 #include 
 
 #include 
-#include 
+#include 
 #include 
 #include 
 #include 
-- 
2.25.1



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




[edk2-devel] [PATCH v1 06/11] DynamicTablesPkg: Add CM_ARM_PSD_INFO object

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Add an object describing _PSD information, cf. ACPI 6.4,
s8.4.5.5 _PSD (P-State Dependency).
Also add the corresponding CmObjParser.

Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/AcpiObjects.h| 20 +++
 .../Include/ArmNameSpaceObjects.h | 12 ++-
 .../ConfigurationManagerObjectParser.c| 11 ++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Include/AcpiObjects.h 
b/DynamicTablesPkg/Include/AcpiObjects.h
index 8981c229544a..d3c23d8d4f2b 100644
--- a/DynamicTablesPkg/Include/AcpiObjects.h
+++ b/DynamicTablesPkg/Include/AcpiObjects.h
@@ -1,6 +1,7 @@
 /** @file
 
   Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -119,6 +120,25 @@ typedef struct AmlCpcInfo {
   UINT32NominalFrequencyInteger;
 } AML_CPC_INFO;
 
+/** A structure that describes a
+P-State Dependency (PSD) Info.
+
+  Cf. ACPI 6.4, s8.4.5.5 _PSD (P-State Dependency).
+*/
+typedef struct AmlPsdInfo {
+  /// Revision.
+  UINT8 Revision;
+
+  /// Domain Id.
+  UINT32Domain;
+
+  /// Coordination type.
+  UINT32CoordType;
+
+  /// Number of processors belonging to the Domain.
+  UINT32NumProc;
+} AML_PSD_INFO;
+
 #pragma pack()
 
 #endif //AML_CPC_INFO_H_
diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 8199882f69fe..ddd17fa45b1e 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -1,6 +1,6 @@
 /** @file
 
-  Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -71,6 +71,7 @@ typedef enum ArmObjectID {
   EArmObjPccSubspaceType3Info, ///< 46 - Pcc 
Subspace Type 3 Info
   EArmObjPccSubspaceType4Info, ///< 47 - Pcc 
Subspace Type 4 Info
   EArmObjPccSubspaceType5Info, ///< 48 - Pcc 
Subspace Type 5 Info
+  EArmObjPsdInfo,  ///< 49 - 
P-State Dependency (PSD) Info
   EArmObjMax
 } EARM_OBJECT_ID;
 
@@ -1297,6 +1298,15 @@ typedef struct CmArmPccSubspaceType5Info {
   PCC_MAILBOX_REGISTER_INFOErrorStatusReg;
 } CM_ARM_PCC_SUBSPACE_TYPE5_INFO;
 
+/** A structure that describes a
+P-State Dependency (PSD) Info.
+
+Cf. ACPI 6.4, s8.4.5.5 _PSD (P-State Dependency).
+
+ID: EArmObjPsdInfo
+*/
+typedef AML_PSD_INFO CM_ARM_PSD_INFO;
+
 #pragma pack()
 
 #endif // ARM_NAMESPACE_OBJECTS_H_
diff --git 
a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
 
b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
index 99d6032510a5..c8c2554a9f44 100644
--- 
a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
+++ 
b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
@@ -637,6 +637,15 @@ STATIC CONST CM_OBJ_PARSER  
CmArmPccSubspaceType5InfoParser[] = {
 ARRAY_SIZE (CmArmMailboxRegisterInfoParser) },
 };
 
+/** A parser for EArmObjPsdInfo.
+*/
+STATIC CONST CM_OBJ_PARSER  CmArmPsdInfoParser[] = {
+  { "Revision",  1, "0x%llx", NULL },
+  { "DomainId",  4, "0x%x",   NULL },
+  { "CoordType", 4, "0x%x",   NULL },
+  { "NumProc",   4, "0x%x",   NULL },
+};
+
 /** A parser for Arm namespace objects.
 */
 STATIC CONST CM_OBJ_PARSER_ARRAY  ArmNamespaceObjectParser[] = {
@@ -733,6 +742,8 @@ STATIC CONST CM_OBJ_PARSER_ARRAY  
ArmNamespaceObjectParser[] = {
 ARRAY_SIZE (CmArmPccSubspaceType34InfoParser) },
   { "EArmObjPccSubspaceType5Info", CmArmPccSubspaceType5InfoParser,
 ARRAY_SIZE (CmArmPccSubspaceType5InfoParser) },
+  { "EArmObjCpcInfo",  CmArmPsdInfoParser,
+ARRAY_SIZE (CmArmPsdInfoParser) },
   { "EArmObjMax",  NULL,   
   0},
 };
 
-- 
2.25.1



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




[edk2-devel] [PATCH v1 07/11] DynamicTablesPkg: Add PsdToken field to CM_ARM_GICC_INFO object

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The _PSD object (cf. ACPI 6.4, s8.4.5.5 _PSD (P-State Dependency)
allows to describe CPU's power state dependencies. Add a PsdToken
field to the CM_ARM_GICC_INFO object so that interdependent CPUs
can reference the same CM_ARM_PSD_INFO object.

Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/Include/ArmNameSpaceObjects.h   | 5 +
 .../Common/TableHelperLib/ConfigurationManagerObjectParser.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index ddd17fa45b1e..2a0ebe24bd04 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -204,6 +204,11 @@ typedef struct CmArmGicCInfo {
   i.e. a token referencing a CM_ARM_CPC_INFO object.
   */
   CM_OBJECT_TOKENCpcToken;
+
+  /** Optional field: Reference Token for the Psd info of this processor.
+  i.e. a token referencing a CM_ARM_PSD_INFO object.
+  */
+  CM_OBJECT_TOKENPsdToken;
 } CM_ARM_GICC_INFO;
 
 /** A structure that describes the
diff --git 
a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
 
b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
index c8c2554a9f44..05c49dffc6f6 100644
--- 
a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
+++ 
b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
@@ -59,7 +59,8 @@ STATIC CONST CM_OBJ_PARSER  CmArmGicCInfoParser[] = {
   { "ProximityDomain",   4,"0x%x",   NULL 
},
   { "ClockDomain",   4,"0x%x",   NULL 
},
   { "AffinityFlags", 4,"0x%x",   NULL 
},
-  { "CpcToken",  sizeof (CM_OBJECT_TOKEN), "0x%p",   NULL }
+  { "CpcToken",  sizeof (CM_OBJECT_TOKEN), "0x%p",   NULL 
},
+  { "PsdToken",  sizeof (CM_OBJECT_TOKEN), "0x%p",   NULL 
},
 };
 
 /** A parser for EArmObjGicDInfo.
@@ -742,7 +743,7 @@ STATIC CONST CM_OBJ_PARSER_ARRAY  
ArmNamespaceObjectParser[] = {
 ARRAY_SIZE (CmArmPccSubspaceType34InfoParser) },
   { "EArmObjPccSubspaceType5Info", CmArmPccSubspaceType5InfoParser,
 ARRAY_SIZE (CmArmPccSubspaceType5InfoParser) },
-  { "EArmObjCpcInfo",  CmArmPsdInfoParser,
+  { "EArmObjPsdInfo",  CmArmPsdInfoParser,
 ARRAY_SIZE (CmArmPsdInfoParser) },
   { "EArmObjMax",  NULL,   
   0},
 };
-- 
2.25.1



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




[edk2-devel] [PATCH v1 08/11] DynamicTablesPkg: Add AmlCreatePsdNode() to generate _PSD

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Add AmlCreatePsdNode() to the AmlLib to generate _PSD objects.
_PSD objects allow to describe 'performance control, P-state
or CPPC, logical processor dependency', Cf. ACPI 6.4,
s8.4.5.5 _PSD (P-State Dependency).

Signed-off-by: Pierre Gondois 
---
 .../Include/Library/AmlLib/AmlLib.h   |  35 +++-
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 188 +-
 2 files changed, 221 insertions(+), 2 deletions(-)

diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h 
b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
index d1426b43fad3..bbb9e965468c 100644
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
@@ -1,7 +1,7 @@
 /** @file
   AML Lib.
 
-  Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+  Copyright (c) 2019 - 2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -1390,4 +1390,37 @@ AmlCreateCpcNode (
   OUT AML_OBJECT_NODE_HANDLE  *NewCpcNode   OPTIONAL
   );
 
+/** Create a _PSD node.
+
+  Creates and optionally adds the following node
+   Name(_PSD, Package()
+   {
+NumEntries,  // Integer
+Revision,// Integer
+Domain,  // Integer
+CoordType,   // Integer
+NumProc, // Integer
+  })
+
+  Cf. ACPI 6.4, s8.4.6.5 _PSD (P-State Dependency)
+
+  @ingroup CodeGenApis
+
+  @param [in]  PsdInfo  PsdInfo object
+  @param [in]  ParentNode   If provided, set ParentNode as the parent
+of the node created.
+  @param [out] NewPsdNode   If success and provided, contains the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCreatePsdNode (
+  IN  AML_PSD_INFO*PsdInfo,
+  IN  AML_NODE_HANDLE ParentNodeOPTIONAL,
+  OUT AML_OBJECT_NODE_HANDLE  *NewPsdNode   OPTIONAL
+  );
+
 #endif // AML_LIB_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index 2147c152f484..a82edab35647 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -1,7 +1,7 @@
 /** @file
   AML Code Generation.
 
-  Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.
+  Copyright (c) 2020 - 2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 **/
@@ -3325,3 +3325,189 @@ error_handler:
   AmlDeleteTree ((AML_NODE_HANDLE)CpcNode);
   return Status;
 }
+
+/** Create a _PSD node.
+
+  Creates and optionally adds the following node
+   Name(_PSD, Package()
+   {
+NumEntries,  // Integer
+Revision,// Integer
+Domain,  // Integer
+CoordType,   // Integer
+NumProc, // Integer
+  })
+
+  Cf. ACPI 6.4, s8.4.6.5 _PSD (P-State Dependency)
+
+  @ingroup CodeGenApis
+
+  @param [in]  PsdInfo  PsdInfo object
+  @param [in]  ParentNode   If provided, set ParentNode as the parent
+of the node created.
+  @param [out] NewPsdNode   If success and provided, contains the created node.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+EFI_STATUS
+EFIAPI
+AmlCreatePsdNode (
+  IN  AML_PSD_INFO*PsdInfo,
+  IN  AML_NODE_HANDLE ParentNodeOPTIONAL,
+  OUT AML_OBJECT_NODE_HANDLE  *NewPsdNode   OPTIONAL
+  )
+{
+  EFI_STATUS  Status;
+  AML_OBJECT_NODE_HANDLE  PsdNode;
+  AML_OBJECT_NODE_HANDLE  PsdPackage;
+  AML_OBJECT_NODE_HANDLE  IntegerNode;
+  UINT32  NumberOfEntries;
+
+  if ((PsdInfo == NULL) ||
+  ((ParentNode == NULL) && (NewPsdNode == NULL)))
+  {
+Status = EFI_INVALID_PARAMETER;
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  // Revision 3 per ACPI 6.4 specification
+  if (PsdInfo->Revision == EFI_ACPI_6_4_AML_PSD_REVISION_V0) {
+// NumEntries 5 per ACPI 6.4 specification
+NumberOfEntries = 5;
+  } else {
+Status = EFI_INVALID_PARAMETER;
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  if (((PsdInfo->CoordType != EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ALL) &&
+   (PsdInfo->CoordType != EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ANY) &&
+   (PsdInfo->CoordType != EFI_ACPI_6_4_AML_STATE_COORD_TYPE_HW_ALL)) ||
+  (PsdInfo->NumProc == 0))
+  {
+Status = EFI_INVALID_PARAMETER;
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  Status = AmlCodeGenNamePackage ("_PSD", NULL, &PsdNode);
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  // Get the Package object node of the _PSD node,
+  // which is the 2nd fixed argument (i.e. index 1).
+  PsdPackage = (AML_OBJECT_NODE

[edk2-devel] [PATCH v1 09/11] DynamicTablesPkg: Generate _PSD in SsdtCpuTopologyGenerator

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Make use of the newly added AmlCreatePsdNode() to generate
_PSD objects.

_PSD objects allow to describe 'performance control, P-state
or CPPC, logical processor dependency', Cf. ACPI 6.4,
s8.4.5.5 _PSD (P-State Dependency).

Signed-off-by: Pierre Gondois 
---
 .../SsdtCpuTopologyGenerator.c| 98 ++-
 1 file changed, 97 insertions(+), 1 deletion(-)

diff --git 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
index 6fb131b66482..9cebf57e8a46 100644
--- 
a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
+++ 
b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSsdtCpuTopologyLibArm/SsdtCpuTopologyGenerator.c
@@ -1,7 +1,7 @@
 /** @file
   SSDT Cpu Topology Table Generator.
 
-  Copyright (c) 2021, Arm Limited. All rights reserved.
+  Copyright (c) 2021 - 2023, Arm Limited. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
   @par Reference(s):
@@ -35,6 +35,7 @@ Requirements:
   - EArmObjProcHierarchyInfo (OPTIONAL) along with
   - EArmObjCmRef (OPTIONAL)
   - EArmObjLpiInfo (OPTIONAL)
+  - EArmObjPsdInfo (OPTIONAL)
 */
 
 /** This macro expands to a function that retrieves the GIC
@@ -86,6 +87,16 @@ GET_OBJECT_LIST (
   CM_ARM_CPC_INFO
   );
 
+/**
+  This macro expands to a function that retrieves the PSD
+  information from the Configuration Manager.
+*/
+GET_OBJECT_LIST (
+  EObjNameSpaceArm,
+  EArmObjPsdInfo,
+  CM_ARM_PSD_INFO
+  );
+
 /** Initialize the TokenTable.
 
   One entry should be allocated for each CM_ARM_PROC_HIERARCHY_INFO
@@ -239,6 +250,75 @@ WriteAslName (
   return EFI_SUCCESS;
 }
 
+/** Create and add an _PSD Node to Cpu Node.
+
+  For instance, transform an AML node from:
+  Device (C002)
+  {
+  Name (_UID, 2)
+  Name (_HID, "ACPI0007")
+  }
+
+  To:
+  Device (C002)
+  {
+  Name (_UID, 2)
+  Name (_HID, "ACPI0007")
+  Name (_PSD, Package()
+  {
+NumEntries,  // Integer
+Revision,// Integer
+Domain,  // Integer
+CoordType,   // Integer
+NumProcessors,   // Integer
+  })
+  }
+
+  @param [in]  Generator  The SSDT Cpu Topology generator.
+  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager
+  Protocol Interface.
+  @param [in]  GicCInfo   Pointer to the CM_ARM_GICC_INFO object
+  describing the Cpu.
+  @param [in]  Node   CPU Node to which the _CPC node is
+  attached.
+
+  @retval EFI_SUCCESS The function completed successfully.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_OUT_OF_RESOURCESFailed to allocate memory.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+CreateAmlPsdNode (
+  IN  ACPI_CPU_TOPOLOGY_GENERATOR *Generator,
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  *CONST  CfgMgrProtocol,
+  IN  CM_ARM_GICC_INFO*GicCInfo,
+  IN  AML_OBJECT_NODE_HANDLE  *Node
+  )
+{
+  EFI_STATUS   Status;
+  CM_ARM_PSD_INFO  *PsdInfo;
+
+  Status = GetEArmObjPsdInfo (
+ CfgMgrProtocol,
+ GicCInfo->PsdToken,
+ &PsdInfo,
+ NULL
+ );
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+
+  Status = AmlCreatePsdNode (
+ PsdInfo,
+ Node,
+ NULL
+ );
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
 /** Create and add an _CPC Node to Cpu Node.
 
   For instance, transform an AML node from:
@@ -684,6 +764,14 @@ CreateAmlCpuFromProcHierarchy (
 }
   }
 
+  if (GicCInfo->PsdToken != CM_NULL_TOKEN) {
+Status = CreateAmlPsdNode (Generator, CfgMgrProtocol, GicCInfo, CpuNode);
+if (EFI_ERROR (Status)) {
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+  }
+
   // If a CPC info is associated with the
   // GicCinfo, create an _CPC method returning them.
   if (GicCInfo->CpcToken != CM_NULL_TOKEN) {
@@ -1126,6 +1214,14 @@ CreateTopologyFromGicC (
   break;
 }
 
+if (GicCInfo->PsdToken != CM_NULL_TOKEN) {
+  Status = CreateAmlPsdNode (Generator, CfgMgrProtocol, GicCInfo, CpuNode);
+  if (EFI_ERROR (Status)) {
+ASSERT_EFI_ERROR (Status);
+return Status;
+  }
+}
+
 // If a CPC info is associated with the
 // GicCinfo, create an _CPC method returning them.
 if (GicCInfo->CpcToken != CM_NULL_TOKEN) {
-- 
2.25.1



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

[edk2-devel] [PATCH v1 10/11] DynamicTablesPkg: Add ArmScmiInfoLib

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The SCP holds some power information that could be advertised
through the _CPC object. The communication with the SCP is done
through SCMI protocols (c.f. ArmScmiDxe).

Use the SCMI protocols to query information and feed it to
the DynamicTablesPkg.

Signed-off-by: Pierre Gondois 
---
 DynamicTablesPkg/DynamicTables.dsc.inc|   1 +
 DynamicTablesPkg/DynamicTablesPkg.dec |   3 +
 DynamicTablesPkg/DynamicTablesPkg.dsc |   1 +
 .../Include/Library/ArmScmiInfoLib.h  |  33 ++
 .../Library/ArmScmiInfoLib/ArmScmiInfoLib.c   | 294 ++
 .../Library/ArmScmiInfoLib/ArmScmiInfoLib.inf |  31 ++
 6 files changed, 363 insertions(+)
 create mode 100644 DynamicTablesPkg/Include/Library/ArmScmiInfoLib.h
 create mode 100644 DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.c
 create mode 100644 DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.inf

diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc 
b/DynamicTablesPkg/DynamicTables.dsc.inc
index 9d4312c4e87d..be40ebc4b472 100644
--- a/DynamicTablesPkg/DynamicTables.dsc.inc
+++ b/DynamicTablesPkg/DynamicTables.dsc.inc
@@ -15,6 +15,7 @@ [BuildOptions]
 [LibraryClasses.common]
   AcpiHelperLib|DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
   AmlLib|DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
+  ArmScmiInfoLib|DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.inf
   
SsdtPcieSupportLib|DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.inf
   
SsdtSerialPortFixupLib|DynamicTablesPkg/Library/Common/SsdtSerialPortFixupLib/SsdtSerialPortFixupLib.inf
   
TableHelperLib|DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf
diff --git a/DynamicTablesPkg/DynamicTablesPkg.dec 
b/DynamicTablesPkg/DynamicTablesPkg.dec
index cfbcbb9569f1..26498e5fec53 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dec
+++ b/DynamicTablesPkg/DynamicTablesPkg.dec
@@ -42,6 +42,9 @@ [LibraryClasses]
   ##  @libraryclass  Defines a set of SMBIOS string helper methods.
   SmbiosStringTableLib|Include/Library/SmbiosStringTableLib.h
 
+  ##  @libraryclass  Defines a set of APIs to populate CmObj using SCMI.
+  ArmScmiInfoLib|Include/Library/ArmScmiInfoLib.h
+
 [Protocols]
   # Configuration Manager Protocol GUID
   gEdkiiConfigurationManagerProtocolGuid = { 0xd85a4835, 0x5a82, 0x4894, { 
0xac, 0x2, 0x70, 0x6f, 0x43, 0xd5, 0x97, 0x8e } }
diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc 
b/DynamicTablesPkg/DynamicTablesPkg.dsc
index bd5084a9008f..6ea86c9efdb0 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dsc
+++ b/DynamicTablesPkg/DynamicTablesPkg.dsc
@@ -39,6 +39,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
   PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
 
 [Components.common]
+  DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.inf
   DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelperLib.inf
   DynamicTablesPkg/Library/Common/AmlLib/AmlLib.inf
   DynamicTablesPkg/Library/Common/SsdtPcieSupportLib/SsdtPcieSupportLib.inf
diff --git a/DynamicTablesPkg/Include/Library/ArmScmiInfoLib.h 
b/DynamicTablesPkg/Include/Library/ArmScmiInfoLib.h
new file mode 100644
index ..8d3fb31df13c
--- /dev/null
+++ b/DynamicTablesPkg/Include/Library/ArmScmiInfoLib.h
@@ -0,0 +1,33 @@
+/** @file
+  Arm SCMI Info Library.
+
+  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef ARM_SCMI_INFO_LIB_H_
+#define ARM_SCMI_INFO_LIB_H_
+
+#include 
+
+/** Populate a AML_CPC_INFO object based on SCMI information.
+
+  @param[in]  DomainIdIdentifier for the performance domain.
+  @param[out] CpcInfo If success, this structure was populated from
+  information queried to the SCP.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_DEVICE_ERRORDevice error.
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
+  @retval EFI_TIMEOUT Time out.
+  @retval EFI_UNSUPPORTED Unsupported.
+**/
+EFI_STATUS
+EFIAPI
+ArmScmiInfoGetFastChannel (
+  IN  UINT32DomainId,
+  OUT AML_CPC_INFO  *CpcInfo
+  );
+
+#endif // ARM_SCMI_INFO_LIB_H_
diff --git a/DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.c 
b/DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.c
new file mode 100644
index ..c23bff63bb6f
--- /dev/null
+++ b/DynamicTablesPkg/Library/ArmScmiInfoLib/ArmScmiInfoLib.c
@@ -0,0 +1,294 @@
+/** @file
+  Arm SCMI Info Library.
+
+  Copyright (c) 2022 - 2023, Arm Limited. All rights reserved.
+
+  Arm Functional Fixed Hardware Specification:
+  - https://developer.arm.com/documentation/den0048/latest/
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/** Arm FFH registers
+
+  Cf. Arm Functional Fixed Hardware Specification
+  s3.2 Performance management and Collaborative Processor Performance Control
+*/
+#define ARM_FFH

[edk2-devel] [PATCH v1 11/11] DynamicTablesPkg: Remove check for _CPC field

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

When generating _CPC objects, some fields are mandatory.
Some fields cannot be supported by a the Juno platform, which is used
to test the _CPC generation. Therefore, don't prevent from generating
_CPC objects if the fields below are missing, and let the OS handle
the missing information.

_CPC fields that are exempted from checks:
- PerformanceLimitedRegister
- ReferencePerformanceCounterRegister
- DeliveredPerformanceCounterRegister

Signed-off-by: Pierre Gondois 
---
 .../Common/AmlLib/CodeGen/AmlCodeGen.c| 19 +++
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c 
b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
index a82edab35647..c585784b095b 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
@@ -3091,6 +3091,11 @@ AmlCreateCpcNode (
 return EFI_INVALID_PARAMETER;
   }
 
+  // The following fields are theoretically mandatory, but not supported
+  // by some platforms. Don't check them:
+  // - PerformanceLimitedRegister
+  // - ReferencePerformanceCounterRegister
+  // - DeliveredPerformanceCounterRegister
   if ((IsNullGenericAddress (&CpcInfo->HighestPerformanceBuffer) &&
(CpcInfo->HighestPerformanceInteger == 0)) ||
   (IsNullGenericAddress (&CpcInfo->NominalPerformanceBuffer) &&
@@ -3099,13 +3104,19 @@ AmlCreateCpcNode (
(CpcInfo->LowestNonlinearPerformanceInteger == 0)) ||
   (IsNullGenericAddress (&CpcInfo->LowestPerformanceBuffer) &&
(CpcInfo->LowestPerformanceInteger == 0)) ||
-  IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister) ||
-  IsNullGenericAddress (&CpcInfo->ReferencePerformanceCounterRegister) ||
-  IsNullGenericAddress (&CpcInfo->DeliveredPerformanceCounterRegister) ||
-  IsNullGenericAddress (&CpcInfo->PerformanceLimitedRegister))
+  IsNullGenericAddress (&CpcInfo->DesiredPerformanceRegister))
   {
 ASSERT (0);
 return EFI_INVALID_PARAMETER;
+  } else if ((IsNullGenericAddress (&CpcInfo->HighestPerformanceBuffer) &&
+  (CpcInfo->HighestPerformanceInteger == 0)) ||
+ (IsNullGenericAddress (&CpcInfo->NominalPerformanceBuffer) &&
+  (CpcInfo->NominalPerformanceInteger == 0)))
+  {
+DEBUG ((
+  DEBUG_WARN,
+  "Missing Reference|Delivered performance field in _CPC object\n"
+  ));
   }
 
   CpcPackage = NULL;
-- 
2.25.1



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




[edk2-devel] [PATCH v1 0/3] Platform/ARM: Enable _CPC/_PSD generation on Juno-r2

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

A recent patchset [1] allows the generation of _PSD/_CPC ACPI objects by
querying the relevant information through the SCMI protocol.
- The _PSD object describes to which performance domain a CPU belongs.
  CPUs in the same performance domain have the same frequency.
- The _CPC object describes an interface to control the performance level
  of a CPU (i.e. its frequency).

Demonstrate the _PSD/_CPC generation functionality on Juno-r2 platforms.

In order to work, the SCP must describe performance levels on a unified
scale (i.e. not as frequencies). The following performance level values
where used for testing:
- little CPUs OPPs: [181, 322, 383] * 1000
- big CPUs OPPs: [512, 833, 1024] * 1024

[1] https://edk2.groups.io/g/devel/message/104115

Pierre Gondois (3):
  Platform/ARM: Juno: Fix typo
  Platform/ARM: Juno: Generate _PSD objects
  Platform/ARM: Juno: Generate _CPC objects for JunoR2

 .../ConfigurationManager.c| 339 +-
 .../ConfigurationManager.h|  34 +-
 .../ConfigurationManagerDxe.inf   |   1 +
 3 files changed, 359 insertions(+), 15 deletions(-)

-- 
2.25.1



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




[edk2-devel] [PATCH v1 1/3] Platform/ARM: Juno: Fix typo

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

Fix a typo.

Signed-off-by: Pierre Gondois 
---
 .../ConfigurationManagerDxe/ConfigurationManager.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index 48f0fd370f07..e374d62dfb95 100644
--- 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -993,7 +993,7 @@ GetGicCInfo (
   return EFI_NOT_FOUND;
 }
 
-/** Return Lpi State Infor.
+/** Return Lpi State Info.
 
   @param [in]  This   Pointer to the Configuration Manager 
Protocol.
   @param [in]  CmObjectId The Object ID of the CM object requested
-- 
2.25.1



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




[edk2-devel] [PATCH v1 2/3] Platform/ARM: Juno: Generate _PSD objects

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The SsdtCpuTopologyGenerator can generate _PSD objects.
Add _PSD information and handling to the Configuration Manager
to generate them.

Signed-off-by: Pierre Gondois 
---
 .../ConfigurationManager.c| 100 --
 .../ConfigurationManager.h|  24 -
 2 files changed, 113 insertions(+), 11 deletions(-)

diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index e374d62dfb95..2b881e61be50 100644
--- 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -1,7 +1,7 @@
 /** @file
   Configuration Manager Dxe
 
-  Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
+  Copyright (c) 2017 - 2023, Arm Limited. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -129,12 +129,12 @@ EDKII_PLATFORM_REPOSITORY_INFO 
ArmJunoPlatformRepositoryInfo = {
  GIC_ENTRY (CPUInterfaceNumber, Mpidr, PmuIrq, VGicIrq, EnergyEfficiency)
   */
   {
-GICC_ENTRY (0, GET_MPID (0, 0), 34, 25, 1),
-GICC_ENTRY (1, GET_MPID (0, 1), 38, 25, 1),
-GICC_ENTRY (2, GET_MPID (1, 0), 50, 25, 0),
-GICC_ENTRY (3, GET_MPID (1, 1), 54, 25, 0),
-GICC_ENTRY (4, GET_MPID (1, 2), 58, 25, 0),
-GICC_ENTRY (5, GET_MPID (1, 3), 62, 25, 0)
+GICC_ENTRY (0, GET_MPID (0, 0), 34, 25, 1, REFERENCE_TOKEN 
(PsdInfo[PSD_BIG_DOMAIN_ID])),
+GICC_ENTRY (1, GET_MPID (0, 1), 38, 25, 1, REFERENCE_TOKEN 
(PsdInfo[PSD_BIG_DOMAIN_ID])),
+GICC_ENTRY (2, GET_MPID (1, 0), 50, 25, 0, REFERENCE_TOKEN 
(PsdInfo[PSD_LITTLE_DOMAIN_ID])),
+GICC_ENTRY (3, GET_MPID (1, 1), 54, 25, 0, REFERENCE_TOKEN 
(PsdInfo[PSD_LITTLE_DOMAIN_ID])),
+GICC_ENTRY (4, GET_MPID (1, 2), 58, 25, 0, REFERENCE_TOKEN 
(PsdInfo[PSD_LITTLE_DOMAIN_ID])),
+GICC_ENTRY (5, GET_MPID (1, 3), 62, 25, 0, REFERENCE_TOKEN 
(PsdInfo[PSD_LITTLE_DOMAIN_ID])),
   },
 
   // GIC Distributor Info
@@ -733,7 +733,29 @@ EDKII_PLATFORM_REPOSITORY_INFO 
ArmJunoPlatformRepositoryInfo = {
   {
 { REFERENCE_TOKEN (LpiInfo[1]) },
 { REFERENCE_TOKEN (LpiInfo[2]) },
-  }
+  },
+  { // Power domains
+{ // 0: big cores
+  // Revision
+  EFI_ACPI_6_4_AML_PSD_REVISION_V0,
+  // Domain
+  PSD_BIG_DOMAIN_ID,
+  // CoordType
+  EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ANY,
+  // NumProc
+  2,
+},
+{ // 1: little cores
+  // Revision
+  EFI_ACPI_6_4_AML_PSD_REVISION_V0,
+  // Domain
+  PSD_LITTLE_DOMAIN_ID,
+  // CoordType
+  EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ANY,
+  // NumProc
+  4,
+},
+  },
 };
 
 /** A helper function for returning the Configuration Manager Objects.
@@ -1141,6 +1163,55 @@ GetPciInterruptMapInfo (
   return EFI_NOT_FOUND;
 }
 
+/** Return Psd Info.
+
+  @param [in]  This   Pointer to the Configuration Manager 
Protocol.
+  @param [in]  CmObjectId The Object ID of the CM object requested
+  @param [in]  SearchTokenA unique token for identifying the requested
+  CM_ARM_PCI_INTERRUPT_MAP_INFO object.
+  @param [in, out] CmObject   Pointer to the Configuration Manager Object
+  descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
+  @retval EFI_NOT_FOUND   The required object information is not found.
+**/
+EFI_STATUS
+EFIAPI
+GetPsdInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN   SearchToken,
+  IN  OUT   CM_OBJ_DESCRIPTOR * CONST CmObject
+  )
+{
+  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
+  UINT32TotalObjCount;
+  UINT32ObjIndex;
+
+  if ((This == NULL) || (CmObject == NULL)) {
+ASSERT (This != NULL);
+ASSERT (CmObject != NULL);
+return EFI_INVALID_PARAMETER;
+  }
+
+  PlatformRepo = This->PlatRepoInfo;
+
+  TotalObjCount = ARRAY_SIZE (PlatformRepo->PsdInfo);
+
+  for (ObjIndex = 0; ObjIndex < TotalObjCount; ObjIndex++) {
+if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->PsdInfo[ObjIndex]) {
+  CmObject->ObjectId = CmObjectId;
+  CmObject->Size = sizeof (PlatformRepo->PsdInfo[ObjIndex]);
+  CmObject->Data = (VOID*)&PlatformRepo->PsdInfo[ObjIndex];
+  CmObject->Count = 1;
+  return EFI_SUCCESS;
+}
+  }
+
+  return EFI_SUCCESS;
+}
+
 /** Return a list of Configuration Manager object references pointed to by the
 given input token.
 
@@ -1537,6 +1608,19 @@ GetArmNameSpaceObject (
  );
   break;
 
+case EArmObjPsdInfo:
+

[edk2-devel] [PATCH v1 3/3] Platform/ARM: Juno: Generate _CPC objects for JunoR2

2023-05-05 Thread PierreGondois
From: Pierre Gondois 

The SsdtCpuTopologyGenerator can generate _CPC objects.
This is done by querying the SCP for the relevant performance
state information through SCMI. CM_ARM_CPC_INFO are then populated
and used to generate _CPC objects in the Ssdt Cpu topology.

Use the ArmScmiInfoLib and add the handling to generate _CPC
information.

Note that using _CPC is only possible if SCP is correctly tuned
to advertise performance levels on an abstract and unified scale.
A basic check is done to prevent the _CPC generation otherwise.

The following performance level values where used for testing:
- little CPUs OPPs: [181, 322, 383] * 1000
- big CPUs OPPs: [512, 833, 1024] * 1024

Signed-off-by: Pierre Gondois 
---
 .../ConfigurationManager.c| 237 +-
 .../ConfigurationManager.h|  10 +
 .../ConfigurationManagerDxe.inf   |   1 +
 3 files changed, 245 insertions(+), 3 deletions(-)

diff --git 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
index 2b881e61be50..971efc17c8f7 100644
--- 
a/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
+++ 
b/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -756,6 +757,8 @@ EDKII_PLATFORM_REPOSITORY_INFO 
ArmJunoPlatformRepositoryInfo = {
   4,
 },
   },
+  { // CPC info, dynamically populated.
+  },
 };
 
 /** A helper function for returning the Configuration Manager Objects.
@@ -1212,6 +1215,60 @@ GetPsdInfo (
   return EFI_SUCCESS;
 }
 
+/** Return Cpc Info.
+
+  @param [in]  This   Pointer to the Configuration Manager 
Protocol.
+  @param [in]  CmObjectId The Object ID of the CM object requested
+  @param [in]  SearchTokenA unique token for identifying the requested
+  CM_ARM_PCI_INTERRUPT_MAP_INFO object.
+  @param [in, out] CmObject   Pointer to the Configuration Manager Object
+  descriptor describing the requested Object.
+
+  @retval EFI_SUCCESS Success.
+  @retval EFI_INVALID_PARAMETER   A parameter is invalid.
+  @retval EFI_NOT_FOUND   The required object information is not found.
+**/
+EFI_STATUS
+EFIAPI
+GetCpcInfo (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  IN  CONST CM_OBJECT_ID  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN   SearchToken,
+  IN  OUT   CM_OBJ_DESCRIPTOR * CONST CmObject
+  )
+{
+  EDKII_PLATFORM_REPOSITORY_INFO  * PlatformRepo;
+  UINT32TotalObjCount;
+  UINT32ObjIndex;
+
+  if ((This == NULL) || (CmObject == NULL)) {
+ASSERT (This != NULL);
+ASSERT (CmObject != NULL);
+return EFI_INVALID_PARAMETER;
+  }
+
+  PlatformRepo = This->PlatRepoInfo;
+
+  if (PlatformRepo->JunoRevision != JUNO_REVISION_R2) {
+/* Only support _CPC generation on Juno R2 for now. */
+return EFI_UNSUPPORTED;
+  }
+
+  TotalObjCount = ARRAY_SIZE (PlatformRepo->CpcInfo);
+
+  for (ObjIndex = 0; ObjIndex < TotalObjCount; ObjIndex++) {
+if (SearchToken == (CM_OBJECT_TOKEN)&PlatformRepo->CpcInfo[ObjIndex]) {
+  CmObject->ObjectId = CmObjectId;
+  CmObject->Size = sizeof (PlatformRepo->CpcInfo[ObjIndex]);
+  CmObject->Data = (VOID*)&PlatformRepo->CpcInfo[ObjIndex];
+  CmObject->Count = 1;
+  return EFI_SUCCESS;
+}
+  }
+
+  return EFI_SUCCESS;
+}
+
 /** Return a list of Configuration Manager object references pointed to by the
 given input token.
 
@@ -1621,6 +1678,19 @@ GetArmNameSpaceObject (
  );
   break;
 
+case EArmObjCpcInfo:
+  Status = HandleCmObjectRefByToken (
+ This,
+ CmObjectId,
+ PlatformRepo->CpcInfo,
+ sizeof (PlatformRepo->CpcInfo),
+ ARRAY_SIZE (PlatformRepo->CpcInfo),
+ Token,
+ GetCpcInfo,
+ CmObject
+ );
+  break;
+
 default: {
   Status = EFI_NOT_FOUND;
   DEBUG ((
@@ -1776,6 +1846,150 @@ EDKII_CONFIGURATION_MANAGER_PROTOCOL 
ArmJunoPlatformConfigManagerProtocol = {
   &ArmJunoPlatformRepositoryInfo
 };
 
+/** Clear Cpc information.
+
+  If populating _CPC information fails, remove GicC tokens pointing
+  to Cpc CmObj to avoid creating corrupted _CPC objects.
+
+  @param [in] PlatformRepo   Platfom Info repository.
+
+  @retval EFI_SUCCESS   Success.
+**/
+STATIC
+EFI_STATUS
+EFIAPI
+ClearCpcInfo (
+  EDKII_PLATFORM_REPOSITORY_INFO  *PlatformRepo
+  )
+{
+  CM_ARM_GICC_INFO  *GicCInfo;
+
+  GicCInfo = (CM_ARM_GICC_INFO*)&PlatformRepo->GicCInfo;
+
+  GicCInfo[0].CpcToken = 

Re: [edk2-devel] [PATCH v3 0/2] OvmfPkg: move two include files to Include/Fdf

2023-05-05 Thread Yao, Jiewen
Reviewed-by: Jiewen Yao 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Friday, May 5, 2023 7:06 PM
> To: devel@edk2.groups.io
> Cc: Pawel Polawski ; Oliver Steffen
> ; Gerd Hoffmann 
> Subject: [edk2-devel] [PATCH v3 0/2] OvmfPkg: move two include files to
> Include/Fdf
> 
> v3:
>  - rebase to latest master
> v2:
>  - rebase to latest master
> 
> Gerd Hoffmann (2):
>   OvmfPkg: move OvmfTpmPei.fdf.inc to Include/Fdf
>   OvmfPkg: move OvmfTpmDxe.fdf.inc to Include/Fdf
> 
>  OvmfPkg/AmdSev/AmdSevX64.fdf | 4 ++--
>  OvmfPkg/CloudHv/CloudHvX64.fdf   | 4 ++--
>  OvmfPkg/OvmfPkgIa32.fdf  | 4 ++--
>  OvmfPkg/OvmfPkgIa32X64.fdf   | 4 ++--
>  OvmfPkg/OvmfPkgX64.fdf   | 4 ++--
>  OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc | 0
>  OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc | 0
>  7 files changed, 10 insertions(+), 10 deletions(-)
>  rename OvmfPkg/{ => Include/Fdf}/OvmfTpmDxe.fdf.inc (100%)
>  rename OvmfPkg/{ => Include/Fdf}/OvmfTpmPei.fdf.inc (100%)
> 
> --
> 2.40.1
> 
> 
> 
> 
> 



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




[edk2-devel] [PATCH 1/1] CryptoPkg: Delete CLANG35 and CLANG38 build flags; add CLANGDWARF flags

2023-05-05 Thread Rebecca Cran
Since CLANG35 and CLANG38 toolchains have been deleted from
tools_def.template, delete the build flags for them from CryptoPkg.

Since CLANGDWARF has replaced CLANG38, add build flags for it to the
CryptoPkg .inf files.

Signed-off-by: Rebecca Cran 
---
 CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf | 3 +--
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  | 3 +--
 CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  | 3 +--
 CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  | 3 +--
 CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  | 3 +--
 CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf | 3 +--
 CryptoPkg/Library/OpensslLib/OpensslLib.inf | 3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf| 3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   | 3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibFull.inf | 3 +--
 CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf| 3 +--
 11 files changed, 11 insertions(+), 22 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
index 5be1724f0852..07b984869629 100644
--- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
@@ -110,8 +110,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index 66261138a00b..d10c83b53c09 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -97,8 +97,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
index 07dbc0e7a8bd..56b4f7306d30 100644
--- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
@@ -106,8 +106,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
index 4ad59b7bbc59..e7801b24c9a0 100644
--- a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
@@ -81,8 +81,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
 
   XCODE:*_*_*_CC_FLAGS = -std=c99
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index ab1993087167..109e08377a2d 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -105,6 +105,5 @@ [BuildOptions]
 
   XCODE:*_*_*_CC_FLAGS = -mmmx -msse -std=c99
 
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
diff --git a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
index 80261794470f..c3d1d61e59c5 100644
--- a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
@@ -78,8 +78,7 @@ [BuildOptions]
   #
   # suppress the following warnings so we do not break the build with 
warnings-as-errors:
   #
-  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
-  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
+  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-types
   GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-pointer-t

Re: [edk2-devel] [PATCH v1 1/3] MdeModulePkg/Bus/Usb/UsbNetwork/UsbRndis: Add USB RNDIS devices support

2023-05-05 Thread Rebecca Cran

On 4/20/23 21:27, RichardHo [何明忠] via groups.io wrote:


This driver provides UEFI driver for USB RNDIS device

Signed-off-by: Richard Ho 
Cc: Andrew Fish 
Cc: Leif Lindholm 
Cc: Michael D Kinney 
Cc: Michael Kubacki 
Cc: Zhiguang Liu 
Cc: Liming Gao 
Cc: Hao A Wu 
Cc: Ray Ni 



R: Rebecca Cran 


Should that have been 'Reviewed-by' instead of 'R' which isn't a valid tag?


--
Rebecca Cran




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




Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged.

2023-05-05 Thread Michael Brown

On 03/05/2023 08:19, Gerd Hoffmann wrote:

OVMF can't guarantee that the ASSERT() doesn't happen.  Misbehaving
EFI applications can trigger this.  So log a warning instead and try
to continue.

Reproducer: Fetch windows 11 22H2 iso image, boot it in qemu with OVMF.

Traced to BootServices->Stall() being called with IPL=TPL_HIGH_LEVEL
and Interrupts /enabled/ while windows is booting.

Cc: Michael Brown 
Cc: Laszlo Ersek 
Signed-off-by: Gerd Hoffmann 
---
  OvmfPkg/Library/NestedInterruptTplLib/Tpl.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c 
b/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
index e19d98878eb7..fdd7d15c4ba8 100644
--- a/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
+++ b/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
@@ -39,7 +39,9 @@ NestedInterruptRaiseTPL (
//
ASSERT (GetInterruptState () == FALSE);
InterruptedTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
-  ASSERT (InterruptedTPL < TPL_HIGH_LEVEL);
+  if (InterruptedTPL >= TPL_HIGH_LEVEL) {
+DEBUG ((DEBUG_WARN, "%a: Called at IPL %d\n", __func__, InterruptedTPL));
+  }
  
return InterruptedTPL;

  }


While https://bugzilla.redhat.com/show_bug.cgi?id=2189136 continues to 
track the underlying Windows bug that leads to this assertion being 
triggered: I suspect that this patch will allow people to boot these 
buggy versions of Windows in OVMF, and I don't think it will make things 
any worse.


I would probably suggest changing DEBUG_WARN to DEBUG_ERROR since this 
represents a serious invariant violation being detected.  With that change:


  Reviewed-by: Michael Brown 

Thanks,

Michael



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




Re: [edk2-devel] [PATCH v5 02/10] MdePkg: don't set visibility to hidden

2023-05-05 Thread Rebecca Cran

Gerd,


Does this series need rework following this discussion, or is it ready 
to merge?



--

Rebecca Cran


On 4/21/23 01:46, Marvin Häuser wrote:



On 21. Apr 2023, at 09:21, Ard Biesheuvel  wrote:

On Fri, 21 Apr 2023 at 08:49, Gerd Hoffmann  wrote:


On Fri, Apr 21, 2023 at 06:01:11AM +, Marvin Häuser wrote:



On 21. Apr 2023, at 06:45, Gerd Hoffmann  wrote:

Not needed any more on modern toolchains, they are better
in not creating a GOT without this trick.


Hi Gerd,

Thanks! Just out of interest, how did you test this and what were 
the results?


Patch #1, adding a linker script assert as suggested by ard, then:

* compile + test on my local workstation (fedora 37, gcc 12).
* run CI
* compile on some older distros:
  - rhel-8 (gcc 8)
  - ubuntu-18.04 (gcc 7)



I just realized that on x86, GenFw has some code to deal with GOT
entries if they are emitted. I'm not sure how often that gets
exercised, given our prior use of hidden visibility, but at least the
GOT entries should be covered by relocations if they exist.

*However*, one thing we are not taking into account is the fact that
relaxations are not usually reflected in the relocations emitted by
the compiler when using --emit-relocs. So we might end up with
occurrences like the below (taken from the Linux kernel but the idea
is the same)

82fa59d5:   4c 8d 0d 24 66 88 ff    lea 
   -0x7799dc(%rip),%r9
 82fa59d8: R_X86_64_REX_GOTPCRELX 
   level4_kernel_pgt-0x4

82fa59dc:   49 8d 69 67 lea    0x67(%r9),%rbp
82fa59e0:   4c 8d 15 19 76 88 ff    lea 
   -0x7789e7(%rip),%r10
 82fa59e3: R_X86_64_REX_GOTPCRELX 
   level3_kernel_pgt-0x4


So here, the GOT loads have been relaxed into LEA instructions, but
GenFw will decode the immediate and assume it points to the GOT entry
rather than the variable itself, and happily emit a PE relocation for
it.

So it would be better to ASSERT() on non-empty GOT, and ignore such
GOTPCREL relocations instead of attempting to relocate the GOT entries
they (used to) refer to.


Hmm, we’ve been toying with using only PIE relocs for X64 for a bit 
and finally merged it into master, so far no issues:

https://github.com/acidanthera/audk/commit/92bb32130bcd0c35e48bdc308a18e5bc74cbaa42
https://github.com/acidanthera/audk/commit/42988773a06f9d6bf345fcbe82c1082ff1cfa2af

In fact (I *did not* confirm this, it’s only a report I got), it seems 
to fix something regarding the stack protector. I’d not be surprised 
if there are edge-cases where -q does not get all necessary relocs 
when PIE is enabled.


Best regards,
Marvin



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




Re: [edk2-devel] [PATCH 1/1] CryptoPkg: Delete CLANG35 and CLANG38 build flags; add CLANGDWARF flags

2023-05-05 Thread Yao, Jiewen
Acked-by: Jiewen Yao 

> -Original Message-
> From: Rebecca Cran 
> Sent: Friday, May 5, 2023 9:43 PM
> To: devel@edk2.groups.io; Yao, Jiewen ; Wang,
> Jian J ; Lu, Xiaoyu1 ; Jiang,
> Guomin 
> Cc: Rebecca Cran 
> Subject: [PATCH 1/1] CryptoPkg: Delete CLANG35 and CLANG38 build flags;
> add CLANGDWARF flags
> 
> Since CLANG35 and CLANG38 toolchains have been deleted from
> tools_def.template, delete the build flags for them from CryptoPkg.
> 
> Since CLANGDWARF has replaced CLANG38, add build flags for it to the
> CryptoPkg .inf files.
> 
> Signed-off-by: Rebecca Cran 
> ---
>  CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf | 3 +--
>  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf  | 3 +--
>  CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf  | 3 +--
>  CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf  | 3 +--
>  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf  | 3 +--
>  CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf | 3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf | 3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLibAccel.inf| 3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf   | 3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLibFull.inf | 3 +--
>  CryptoPkg/Library/OpensslLib/OpensslLibFullAccel.inf| 3 +--
>  11 files changed, 11 insertions(+), 22 deletions(-)
> 
> diff --git a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> index 5be1724f0852..07b984869629 100644
> --- a/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/BaseCryptLib.inf
> @@ -110,8 +110,7 @@ [BuildOptions]
>#
># suppress the following warnings so we do not break the build with
> warnings-as-errors:
>#
> -  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> -  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
>GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> 
>XCODE:*_*_*_CC_FLAGS = -std=c99
> diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> index 66261138a00b..d10c83b53c09 100644
> --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> @@ -97,8 +97,7 @@ [BuildOptions]
>#
># suppress the following warnings so we do not break the build with
> warnings-as-errors:
>#
> -  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> -  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
>GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> 
>XCODE:*_*_*_CC_FLAGS = -std=c99
> diff --git a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> index 07dbc0e7a8bd..56b4f7306d30 100644
> --- a/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/RuntimeCryptLib.inf
> @@ -106,8 +106,7 @@ [BuildOptions]
>#
># suppress the following warnings so we do not break the build with
> warnings-as-errors:
>#
> -  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> -  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
>GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> 
>XCODE:*_*_*_CC_FLAGS = -std=c99
> diff --git a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> index 4ad59b7bbc59..e7801b24c9a0 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/SecCryptLib.inf
> @@ -81,8 +81,7 @@ [BuildOptions]
>#
># suppress the following warnings so we do not break the build with
> warnings-as-errors:
>#
> -  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> -  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
>GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> 
>XCODE:*_*_*_CC_FLAGS = -std=c99
> diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> index ab1993087167..109e08377a2d 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> @@ -105,6 +105,5 @@ [BuildOptions]
> 
>XCODE:*_*_*_CC_FLAGS = -mmmx -msse -std=c99
> 
> -  GCC:*_CLANG35_*_CC_FLAGS = -std=c99
> -  GCC:*_CLANG38_*_CC_FLAGS = -std=c99
> +  GCC:*_CLANGDWARF_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
>GCC:*_CLANGPDB_*_CC_FLAGS = -std=c99 -Wno-error=incompatible-
> pointer-types
> diff --git a/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/UnitTestHostBaseCryptLib.inf
> in

Re: [edk2-devel] [PATCH v3 3/3] OvmfPkg/Bhyve: install ACPI tables from memory

2023-05-05 Thread Rebecca Cran

On 5/3/23 01:32, Corvin Köhne wrote:


diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
index d0d2712c5662..465b81ffcd51 100644
--- a/OvmfPkg/Bhyve/BhyveX64.dsc
+++ b/OvmfPkg/Bhyve/BhyveX64.dsc
@@ -341,6 +341,7 @@ [LibraryClasses.common.UEFI_DRIVER]
PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
  
  [LibraryClasses.common.DXE_DRIVER]

+  AcpiPlatformLib|OvmfPkg/Library/AcpiPlatformLib/DxeAcpiPlatformLib.inf


That file doesn't exist. There's 
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf and 
OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf .



--
Rebecca Cran



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




[edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread Minh Nguyen via groups.io
This patchset adds necessary changes for RedfishPkg to avoid some unexpected 
cases and fix compilation.

Changes since v3:
 + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
 + Added "Cc:" to maintainers in commit message.
 + Corrected patch format subject prefix.
Changes since v1:
 + Removed redundant change and change the commit message for more precise in 
PATCH 2/5.

Nhi Pham (1):
  RedfishPkg: Add missing newline character

Vu Nguyen (4):
  RedfishPkg: Correct variable type to prevent memory corruption
  RedfishPkg: Fix condition checking of error status
  RedfishPkg: Create RestEx child on selected interface
  RedfishPkg: Fix compile issue on Linux

 RedfishPkg/Include/Library/RestExLib.h   |   3 +
 RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
 RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
 RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153 

 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
 RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
 6 files changed, 73 insertions(+), 98 deletions(-)

-- 
2.39.0



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




[edk2-devel] [PATCH V3 2/5] RedfishPkg: Fix condition checking of error status

2023-05-05 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

This change fixes condition checking of error status, the condition
should be compared with TRUE status to be identical with an error message.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 583c6f78e19c..a247bfed9e34 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -5,6 +5,7 @@
   (C) Copyright 2021 Hewlett Packard Enterprise Development LP
   Copyright (c) 2022, AMD Incorporated. All rights reserved.
   Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -926,7 +927,7 @@ AddAndSignalNewRedfishService (
 }
 
 Status = gBS->SignalEvent (Instance->DiscoverToken->Event);
-if (!EFI_ERROR (Status)) {
+if (EFI_ERROR (Status)) {
   DEBUG ((DEBUG_ERROR, "%a:No event to signal!\n", __func__));
 }
   }
-- 
2.39.0



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




[edk2-devel] [PATCH V3 4/5] RedfishPkg: Add missing newline character

2023-05-05 Thread Minh Nguyen via groups.io
From: Nhi Pham 

This adds a missing newline character to make the error log
readable in case the module is failed.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c 
b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 45fc6e2182bc..c4fa59193a2f 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -8,6 +8,7 @@
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
   Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
   Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -59,7 +60,7 @@ RedfishCreateSmbiosTable42 (
   Status = RedfishPlatformHostInterfaceDeviceDescriptor (&DeviceType, 
&DeviceDescriptor);
   if (EFI_ERROR (Status)) {
 if (Status == EFI_NOT_FOUND) {
-  DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is 
provided on this platform.", __func__));
+  DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is 
provided on this platform.\n", __func__));
   return EFI_NOT_FOUND;
 }
 
-- 
2.39.0



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




[edk2-devel] [PATCH V3 1/5] RedfishPkg: Correct variable type to prevent memory corruption

2023-05-05 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

Id will be casted by CoreOpenProtocol, declare this variable with a
wrong type might result in the corruption of other local variables.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h 
b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
index 4a9e9f7b81a4..6b94e5814c43 100644
--- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
+++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
@@ -3,6 +3,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -84,7 +85,7 @@ struct _RESTEX_SERVICE {
   //
   EFI_HANDLE  HttpChildHandle;
 
-  UINT32  Id;
+  UINT32  *Id;
 
   EFI_REST_EX_SERVICE_INFORestExServiceInfo;
 };
-- 
2.39.0



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




[edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on Linux

2023-05-05 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

It requires a fixed size array to store the content of device path PCD.
Add the array size to solve this issue.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Abner Chang 
---
 RedfishPkg/Include/Pcd/RestExServiceDevicePath.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h 
b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
index 91b1198297c2..57fc199f61f2 100644
--- a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
+++ b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
@@ -4,6 +4,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -14,6 +15,8 @@
 
 #include 
 
+#define MAX_DEVICE_PATH_NODE  40
+
 typedef enum {
   DEVICE_PATH_MATCH_MAC_NODE = 1,
   DEVICE_PATH_MATCH_PCI_NODE = 2,
@@ -32,7 +35,7 @@ typedef struct {
   //
0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
   //0x7f,0xff,0x04,0x00}
   //
-  EFI_DEVICE_PATH_PROTOCOLDevicePath[];
+  EFI_DEVICE_PATH_PROTOCOL  DevicePath[MAX_DEVICE_PATH_NODE];
 } REST_EX_SERVICE_DEVICE_PATH_DATA;
 
 #endif
-- 
2.39.0



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




[edk2-devel] [PATCH V3 3/5] RedfishPkg: Create RestEx child on selected interface

2023-05-05 Thread Minh Nguyen via groups.io
From: Vu Nguyen 

When a MAC address matching interface is found, a RestEx child will be
created to provide the Redfish communication on that interface.
Currently, It will try to locate all RestEx binding services and choose
the first satisfied instance without taking care about current selected
interface. This might raise an issue on the system with multiple network
devices that the RestEx child was installed on wrong interface.

Siigned-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
---
 RedfishPkg/Include/Library/RestExLib.h |   3 +
 RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c | 153 
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c |   1 +
 3 files changed, 63 insertions(+), 94 deletions(-)

diff --git a/RedfishPkg/Include/Library/RestExLib.h 
b/RedfishPkg/Include/Library/RestExLib.h
index bc4e4ca6caa7..2c32c3684cf4 100644
--- a/RedfishPkg/Include/Library/RestExLib.h
+++ b/RedfishPkg/Include/Library/RestExLib.h
@@ -2,6 +2,7 @@
   This library provides help functions for REST EX Protocol.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -20,6 +21,7 @@
   This function allows the caller to create child handle for specific
   REST server.
 
+  @param[in]  Controller   The controller handle used of selected 
interface.
   @param[in]  ImageThe image handle used to open service.
   @param[in]  AccessMode   Access mode of REST server.
   @param[in]  ConfigType   Underlying configuration to communicate 
with REST server.
@@ -32,6 +34,7 @@
 **/
 EFI_STATUS
 RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
   IN EFI_HANDLE   Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c 
b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
index d9acad24dec1..0b3ae2755e86 100644
--- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
+++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
@@ -2,6 +2,7 @@
   This library provides help functions for REST EX Protocol.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -9,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +23,7 @@
   This function allows the caller to create child handle for specific
   REST server.
 
+  @param[in]  Controller   The controller handle used of selected 
interface.
   @param[in]  ImageThe image handle used to open service.
   @param[in]  AccessMode   Access mode of REST server.
   @param[in]  ConfigType   Underlying configuration to communicate 
with REST server.
@@ -33,6 +36,7 @@
 **/
 EFI_STATUS
 RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
   IN EFI_HANDLE   Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
@@ -41,8 +45,6 @@ RestExLibCreateChild (
   )
 {
   EFI_STATUSStatus;
-  UINTN NoBuffer;
-  EFI_HANDLE*Handle;
   EFI_HANDLEChildHandle;
   EFI_REST_EX_PROTOCOL  *RestEx;
   EFI_REST_EX_SERVICE_INFO  *RestExServiceInfo;
@@ -59,116 +61,79 @@ RestExLibCreateChild (
   }
 
   *ChildInstanceHandle = NULL;
-  //
-  // Locate all REST EX binding service.
-  //
-  Handle   = NULL;
-  NoBuffer = 0;
-  Status   = gBS->LocateHandleBuffer (
-ByProtocol,
-&gEfiRestExServiceBindingProtocolGuid,
-NULL,
-&NoBuffer,
-&Handle
-);
-  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+
+  ChildHandle = NULL;
+  Status = NetLibCreateServiceChild (
+ Controller,
+ Image,
+ &gEfiRestExServiceBindingProtocolGuid,
+ &ChildHandle
+ );
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: Failed to create service child - %r \n",
+  __func__,
+  Status
+  ));
 return Status;
   }
-
-  Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
-  if (Handle == NULL) {
-return EFI_OUT_OF_RESOURCES;
-  }
-
-  Status = gBS->LocateHandleBuffer (
-  ByProtocol,
-  &gEfiRestExServiceBindingProtocolGuid,
+  Status = gBS->OpenProtocol (
+  ChildHandle,
+  &gEfiRestExProtocolGuid,
+  (VOID **)&RestEx,
+  Image,
   NULL,
-  &NoBuffer,
-  &Handle
+  EFI_OPEN_PROTOCOL_GET_PROTOCOL
   

[edk2-devel] [PATCH] UefiPayloadPkg:Add YAML support version configuration

2023-05-05 Thread kasimx . liu
From: KasimX Liu 

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

To record the default value of SpecRevision and Revision.

add '-st' command of input YAML setting file

Cc: Guo Dong 
Cc: Ray Ni 
Cc: James Lu 
Cc: Gua Guo 
Signed-off-by: KasimX Liu 
---
 UefiPayloadPkg/Settings/UplSettings.yaml | 11 ++
 UefiPayloadPkg/UniversalPayloadBuild.py  | 28 ++--
 2 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 UefiPayloadPkg/Settings/UplSettings.yaml

diff --git a/UefiPayloadPkg/Settings/UplSettings.yaml 
b/UefiPayloadPkg/Settings/UplSettings.yaml
new file mode 100644
index 00..959170ae76
--- /dev/null
+++ b/UefiPayloadPkg/Settings/UplSettings.yaml
@@ -0,0 +1,11 @@
+## @file
+# Set shell variable EDK_TOOL_PATH to this folder
+#
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+{
+  'SpecRevision': '0x0070',
+  'Revision': '0x010105'
+}
diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py 
b/UefiPayloadPkg/UniversalPayloadBuild.py
index 416946a431..a32c76a2da 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -13,6 +13,7 @@ import sys
 from   ctypes import *
 from Tools.ElfFv import ReplaceFv
 sys.dont_write_bytecode = True
+import re
 
 class UPLD_INFO_HEADER(LittleEndianStructure):
 _pack_ = 1
@@ -153,6 +154,18 @@ def main():
 
 return int('0x{0:02x}{1:02x}'.format(Major, Minor), 0)
 
+def GetUplVerFile(Argument):
+  FilePath = open(os.path.abspath(Argument), 'r')
+  FileControl = FilePath.read()
+  SpecRevision = ""
+  Revision = ""
+  Rule1 = r"\{\n*.+: *'(?P.+)', *.+: '(?P.+)'\n\}"
+  ModuleObjs = re.finditer(Rule1, FileControl, re.I|re.S)
+  for ModeObj in ModuleObjs:
+SpecRevision = ModeObj.group("SpecRevision")
+Revision = ModeObj.group("Revision")
+  return SpecRevision, Revision
+
 def Validate32BitInteger (Argument):
 try:
 Value = int (Argument, 0)
@@ -184,14 +197,25 @@ def main():
 parser.add_argument('-i', '--ImageId', type=str, help='Specify payload ID 
(16 bytes maximal).', default ='UEFI')
 parser.add_argument('-q', '--Quiet', action='store_true', help='Disable 
all build messages except FATAL ERRORS.')
 parser.add_argument("-p", "--pcd", action="append")
-parser.add_argument("-s", "--SpecRevision", type=ValidateSpecRevision, 
default ='0.7', help='Indicates compliance with a revision of this 
specification in the BCD format.')
-parser.add_argument("-r", "--Revision", type=Validate32BitInteger, default 
='0x010105', help='Revision of the Payload binary. 
Major.Minor.Revision.Build')
+group1 = parser.add_mutually_exclusive_group()
+arg_a = group1.add_argument('-st',"--Settings",type=GetUplVerFile, 
default="UefiPayloadPkg\\Settings\\UplSettings.yaml", help='Get the 
UplSettings.yaml')
+group1.add_argument('-s', "--SpecRevision", type=ValidateSpecRevision, 
default ='0.7', help='Indicates compliance with a revision of this 
specification in the BCD format.')
+group2 = parser.add_mutually_exclusive_group()
+group2.add_argument('-r', "--Revision", type=Validate32BitInteger, default 
='0x010105', help='Revision of the Payload binary. 
Major.Minor.Revision.Build')
+group2._group_actions.append(arg_a)
+
 parser.add_argument("-o", "--ProducerId", default ='INTEL', help='A 
null-terminated OEM-supplied string that identifies the payload producer (16 
bytes maximal).')
 parser.add_argument("-e", "--BuildEntryOnly", action='store_true', 
help='Build UniversalPayload Entry file')
 parser.add_argument("-pb", "--PreBuildUplBinary", default=None, 
help='Specify the UniversalPayload file')
 parser.add_argument("-sk", "--SkipBuild", action='store_true', help='Skip 
UniversalPayload build')
 parser.add_argument("-af", "--AddFv", type=ValidateAddFv, action='append', 
help='Add or replace specific FV into payload, Ex: uefi_fv=XXX.fv')
 args = parser.parse_args()
+SpecRevision, Revision= args.Settings
+if SpecRevision != args.SpecRevision:
+args.SpecRevision = SpecRevision
+if Revision != args.Revision:
+args.Revision = Revision
+print(args)
 
 MultiFvList = []
 UniversalPayloadBinary = args.PreBuildUplBinary
-- 
2.39.1.windows.1



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




Re: [edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread Minh Nguyen

Hi Abner,

 Here you are: #4338 

Thanks,

Minh Nguyen

On 5/5/2023 12:45 PM, Chang, Abner wrote:

[EXTERNAL EMAIL NOTICE: This email originated from an external sender. Please 
be mindful of safe email handling and proprietary information protection 
practices.]


[AMD Official Use Only - General]

Ok, because the patch in email always has format problem when apply the patch, 
plus I can't get the patch from group.io; could you please create a PR on your 
Github thus I can review patches from there.
Just let me know the PR # after you creating it.

Thanks
Abner


-Original Message-
From: Minh Nguyen
Sent: Friday, May 5, 2023 1:35 PM
To: Chang, Abner; Minh Nguyen
;devel@edk2.groups.io
Cc:patc...@amperecomputing.com;nick...@nvidia.com;ig...@ami.com;
n...@os.amperecomputing.com;tinhngu...@os.amperecomputing.com
Subject: Re: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Abner,

   Yes, me too. I have sent the email tomiki.deme...@intel.com  for checking
it.

Thanks,

Minh Nguyen

On 5/5/2023 12:03 PM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Minh,
I don't know why however I can't see V3 patch set on group.io. Can you see

those patches on group.io?

Abner


-Original Message-
From: Minh Nguyen
Sent: Friday, May 5, 2023 11:58 AM
To:devel@edk2.groups.io
Cc:patc...@amperecomputing.com; Chang, Abner

;

nick...@nvidia.com;ig...@ami.com;n...@os.amperecomputing.com;
tinhngu...@os.amperecomputing.com;
Minh Nguyen
Subject: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


This patchset adds necessary changes for RedfishPkg to avoid some
unexpected cases and fix compilation.

Changes since v3:
   + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
   + Added "Cc:" to maintainers in commit message.
   + Corrected patch format subject prefix.
Changes since v1:
   + Removed redundant change and change the commit message for more
precise in PATCH 2/5.

Nhi Pham (1):
RedfishPkg: Add missing newline character

Vu Nguyen (4):
RedfishPkg: Correct variable type to prevent memory corruption
RedfishPkg: Fix condition checking of error status
RedfishPkg: Create RestEx child on selected interface
RedfishPkg: Fix compile issue on Linux

   RedfishPkg/Include/Library/RestExLib.h   |   3 +
   RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
   RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
   RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153




   RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
   RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
   6 files changed, 73 insertions(+), 98 deletions(-)

--
2.39.0



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




[edk2-devel] [PATCH V3 1/5] RedfishPkg: Correct variable type to prevent memory corruption

2023-05-05 Thread minhnampere via groups.io
From: Vu Nguyen 

Id will be casted by CoreOpenProtocol, declare this variable with a
wrong type might result in the corruption of other local variables.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h 
b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
index 4a9e9f7b81a4..6b94e5814c43 100644
--- a/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
+++ b/RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
@@ -3,6 +3,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -84,7 +85,7 @@ struct _RESTEX_SERVICE {
   //
   EFI_HANDLE  HttpChildHandle;
 
-  UINT32  Id;
+  UINT32  *Id;
 
   EFI_REST_EX_SERVICE_INFORestExServiceInfo;
 };
-- 
2.39.0



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




[edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread minhnampere via groups.io
This patchset adds necessary changes for RedfishPkg to avoid some unexpected 
cases and fix compilation.

Changes since v3:
 + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
 + Added "Cc:" to maintainers in commit message.
 + Corrected patch format subject prefix.
Changes since v1:
 + Removed redundant change and change the commit message for more precise in 
PATCH 2/5.

Nhi Pham (1):
  RedfishPkg: Add missing newline character

Vu Nguyen (4):
  RedfishPkg: Correct variable type to prevent memory corruption
  RedfishPkg: Fix condition checking of error status
  RedfishPkg: Create RestEx child on selected interface
  RedfishPkg: Fix compile issue on Linux

 RedfishPkg/Include/Library/RestExLib.h   |   3 +
 RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
 RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
 RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153 

 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
 RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
 6 files changed, 73 insertions(+), 98 deletions(-)

-- 
2.39.0



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




Re: [edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread Minh Nguyen

Hi Abner,

 Yes, me too. I have sent the email to miki.deme...@intel.com for 
checking it.


Thanks,

Minh Nguyen

On 5/5/2023 12:03 PM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Minh,
I don't know why however I can't see V3 patch set on group.io. Can you see 
those patches on group.io?

Abner


-Original Message-
From: Minh Nguyen 
Sent: Friday, May 5, 2023 11:58 AM
To: devel@edk2.groups.io
Cc: patc...@amperecomputing.com; Chang, Abner
; nick...@nvidia.com; ig...@ami.com;
n...@os.amperecomputing.com; tinhngu...@os.amperecomputing.com;
Minh Nguyen 
Subject: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


This patchset adds necessary changes for RedfishPkg to avoid some
unexpected cases and fix compilation.

Changes since v3:
  + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
  + Added "Cc:" to maintainers in commit message.
  + Corrected patch format subject prefix.
Changes since v1:
  + Removed redundant change and change the commit message for more
precise in PATCH 2/5.

Nhi Pham (1):
   RedfishPkg: Add missing newline character

Vu Nguyen (4):
   RedfishPkg: Correct variable type to prevent memory corruption
   RedfishPkg: Fix condition checking of error status
   RedfishPkg: Create RestEx child on selected interface
   RedfishPkg: Fix compile issue on Linux

  RedfishPkg/Include/Library/RestExLib.h   |   3 +
  RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
  RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
  RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153 


  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
  RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
  6 files changed, 73 insertions(+), 98 deletions(-)

--
2.39.0



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




[edk2-devel] [PATCH V3 3/5] RedfishPkg: Create RestEx child on selected interface

2023-05-05 Thread minhnampere via groups.io
From: Vu Nguyen 

When a MAC address matching interface is found, a RestEx child will be
created to provide the Redfish communication on that interface.
Currently, It will try to locate all RestEx binding services and choose
the first satisfied instance without taking care about current selected
interface. This might raise an issue on the system with multiple network
devices that the RestEx child was installed on wrong interface.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
---
 RedfishPkg/Include/Library/RestExLib.h |   3 +
 RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c | 153 
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c |   1 +
 3 files changed, 63 insertions(+), 94 deletions(-)

diff --git a/RedfishPkg/Include/Library/RestExLib.h 
b/RedfishPkg/Include/Library/RestExLib.h
index bc4e4ca6caa7..2c32c3684cf4 100644
--- a/RedfishPkg/Include/Library/RestExLib.h
+++ b/RedfishPkg/Include/Library/RestExLib.h
@@ -2,6 +2,7 @@
   This library provides help functions for REST EX Protocol.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -20,6 +21,7 @@
   This function allows the caller to create child handle for specific
   REST server.
 
+  @param[in]  Controller   The controller handle used of selected 
interface.
   @param[in]  ImageThe image handle used to open service.
   @param[in]  AccessMode   Access mode of REST server.
   @param[in]  ConfigType   Underlying configuration to communicate 
with REST server.
@@ -32,6 +34,7 @@
 **/
 EFI_STATUS
 RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
   IN EFI_HANDLE   Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c 
b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
index d9acad24dec1..0b3ae2755e86 100644
--- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
+++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
@@ -2,6 +2,7 @@
   This library provides help functions for REST EX Protocol.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -9,6 +10,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -21,6 +23,7 @@
   This function allows the caller to create child handle for specific
   REST server.
 
+  @param[in]  Controller   The controller handle used of selected 
interface.
   @param[in]  ImageThe image handle used to open service.
   @param[in]  AccessMode   Access mode of REST server.
   @param[in]  ConfigType   Underlying configuration to communicate 
with REST server.
@@ -33,6 +36,7 @@
 **/
 EFI_STATUS
 RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
   IN EFI_HANDLE   Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
@@ -41,8 +45,6 @@ RestExLibCreateChild (
   )
 {
   EFI_STATUSStatus;
-  UINTN NoBuffer;
-  EFI_HANDLE*Handle;
   EFI_HANDLEChildHandle;
   EFI_REST_EX_PROTOCOL  *RestEx;
   EFI_REST_EX_SERVICE_INFO  *RestExServiceInfo;
@@ -59,116 +61,79 @@ RestExLibCreateChild (
   }
 
   *ChildInstanceHandle = NULL;
-  //
-  // Locate all REST EX binding service.
-  //
-  Handle   = NULL;
-  NoBuffer = 0;
-  Status   = gBS->LocateHandleBuffer (
-ByProtocol,
-&gEfiRestExServiceBindingProtocolGuid,
-NULL,
-&NoBuffer,
-&Handle
-);
-  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+
+  ChildHandle = NULL;
+  Status = NetLibCreateServiceChild (
+ Controller,
+ Image,
+ &gEfiRestExServiceBindingProtocolGuid,
+ &ChildHandle
+ );
+  if (EFI_ERROR (Status)) {
+DEBUG ((
+  DEBUG_ERROR,
+  "%a: Failed to create service child - %r \n",
+  __func__,
+  Status
+  ));
 return Status;
   }
-
-  Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
-  if (Handle == NULL) {
-return EFI_OUT_OF_RESOURCES;
-  }
-
-  Status = gBS->LocateHandleBuffer (
-  ByProtocol,
-  &gEfiRestExServiceBindingProtocolGuid,
+  Status = gBS->OpenProtocol (
+  ChildHandle,
+  &gEfiRestExProtocolGuid,
+  (VOID **)&RestEx,
+  Image,
   NULL,
-  &NoBuffer,
-  &Handle
+  EFI_OPEN_PROTOCOL_GET_PROTOCOL
   )

Re: [edk2-devel] [PATCH v10 7/9] UefiCpuPkg: Implements MmSaveStateLib for Ovmf

2023-05-05 Thread Attar, AbdulLateef (Abdul Lateef) via groups.io
[AMD Official Use Only - General]

Thanks Gerd, for the inputs. I'll drop the patch and submit the new version.

-AbduL

-Original Message-
From: Gerd Hoffmann 
Sent: 04 May 2023 14:13
To: Attar, AbdulLateef (Abdul Lateef) 
Cc: devel@edk2.groups.io; Attar, AbdulLateef (Abdul Lateef) 
; Grimes, Paul ; Chang, Abner 
; Eric Dong ; Ray Ni 
; Rahul Kumar ; Ard Biesheuvel 
; Jiewen Yao ; Jordan Justen 

Subject: Re: [PATCH v10 7/9] UefiCpuPkg: Implements MmSaveStateLib for Ovmf

Caution: This message originated from an External Source. Use proper caution 
when opening attachments, clicking links, or responding.


On Thu, May 04, 2023 at 12:09:19PM +0530, Abdul Lateef Attar wrote:
> From: Abdul Lateef Attar 
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182
>
> Implements MmSaveStateLib library interfaces to read and write save
> state registers for Ovmf/Qemu.

Not needed, ovmf can use AmdMmSaveStateLib

take care,
  Gerd



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




[edk2-devel] [PATCH V3 2/5] RedfishPkg: Fix condition checking of error status

2023-05-05 Thread minhnampere via groups.io
From: Vu Nguyen 

This change fixes condition checking of error status, the condition
should be compared with TRUE status to be identical with an error message.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c 
b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
index 0900a2479e7b..14702748813b 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
@@ -5,6 +5,7 @@
   (C) Copyright 2021 Hewlett Packard Enterprise Development LP
   Copyright (c) 2022, AMD Incorporated. All rights reserved.
   Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -926,7 +927,7 @@ AddAndSignalNewRedfishService (
 }
 
 Status = gBS->SignalEvent (Instance->DiscoverToken->Event);
-if (!EFI_ERROR (Status)) {
+if (EFI_ERROR (Status)) {
   DEBUG ((DEBUG_ERROR, "%a:No event to signal!\n", __func__));
 }
   }
-- 
2.39.0



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




Re: [edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread Minh Nguyen

Hi Abner,

 While they're checking this issue, they recommend me to re-send v3 so 
I just sent it, you can also use the PR to review at the same time.


Thanks,

Minh Nguyen.

On 5/5/2023 1:01 PM, Minh Nguyen wrote:


Hi Abner,

 Here you are: #4338 

Thanks,

Minh Nguyen

On 5/5/2023 12:45 PM, Chang, Abner wrote:

[EXTERNAL EMAIL NOTICE: This email originated from an external sender. Please 
be mindful of safe email handling and proprietary information protection 
practices.]


[AMD Official Use Only - General]

Ok, because the patch in email always has format problem when apply the patch, 
plus I can't get the patch from group.io; could you please create a PR on your 
Github thus I can review patches from there.
Just let me know the PR # after you creating it.

Thanks
Abner


-Original Message-
From: Minh Nguyen
Sent: Friday, May 5, 2023 1:35 PM
To: Chang, Abner; Minh Nguyen
;devel@edk2.groups.io
Cc:patc...@amperecomputing.com;nick...@nvidia.com;ig...@ami.com;
n...@os.amperecomputing.com;tinhngu...@os.amperecomputing.com
Subject: Re: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


Hi Abner,

   Yes, me too. I have sent the email tomiki.deme...@intel.com  for checking
it.

Thanks,

Minh Nguyen

On 5/5/2023 12:03 PM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Minh,
I don't know why however I can't see V3 patch set on group.io. Can you see

those patches on group.io?

Abner


-Original Message-
From: Minh Nguyen
Sent: Friday, May 5, 2023 11:58 AM
To:devel@edk2.groups.io
Cc:patc...@amperecomputing.com; Chang, Abner

;

nick...@nvidia.com;ig...@ami.com;n...@os.amperecomputing.com;
tinhngu...@os.amperecomputing.com;
Minh Nguyen
Subject: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


This patchset adds necessary changes for RedfishPkg to avoid some
unexpected cases and fix compilation.

Changes since v3:
   + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
   + Added "Cc:" to maintainers in commit message.
   + Corrected patch format subject prefix.
Changes since v1:
   + Removed redundant change and change the commit message for more
precise in PATCH 2/5.

Nhi Pham (1):
RedfishPkg: Add missing newline character

Vu Nguyen (4):
RedfishPkg: Correct variable type to prevent memory corruption
RedfishPkg: Fix condition checking of error status
RedfishPkg: Create RestEx child on selected interface
RedfishPkg: Fix compile issue on Linux

   RedfishPkg/Include/Library/RestExLib.h   |   3 +
   RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
   RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
   RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153




   RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
   RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
   6 files changed, 73 insertions(+), 98 deletions(-)

--
2.39.0



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




[edk2-devel] [PATCH V3 4/5] RedfishPkg: Add missing newline character

2023-05-05 Thread minhnampere via groups.io
From: Nhi Pham 

This adds a missing newline character to make the error log
readable in case the module is failed.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Nickle Wang 
---
 RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c 
b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
index 45fc6e2182bc..c4fa59193a2f 100644
--- a/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
+++ b/RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
@@ -8,6 +8,7 @@
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
   Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
   Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -59,7 +60,7 @@ RedfishCreateSmbiosTable42 (
   Status = RedfishPlatformHostInterfaceDeviceDescriptor (&DeviceType, 
&DeviceDescriptor);
   if (EFI_ERROR (Status)) {
 if (Status == EFI_NOT_FOUND) {
-  DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is 
provided on this platform.", __func__));
+  DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is 
provided on this platform.\n", __func__));
   return EFI_NOT_FOUND;
 }
 
-- 
2.39.0



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




[edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on Linux

2023-05-05 Thread minhnampere via groups.io
From: Vu Nguyen 

It requires a fixed size array to store the content of device path PCD.
Add the array size to solve this issue.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
Reviewed-by: Abner Chang 
---
 RedfishPkg/Include/Pcd/RestExServiceDevicePath.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h 
b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
index 91b1198297c2..57fc199f61f2 100644
--- a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
+++ b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
@@ -4,6 +4,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -14,6 +15,8 @@
 
 #include 
 
+#define MAX_DEVICE_PATH_NODE  40
+
 typedef enum {
   DEVICE_PATH_MATCH_MAC_NODE = 1,
   DEVICE_PATH_MATCH_PCI_NODE = 2,
@@ -32,7 +35,7 @@ typedef struct {
   //
0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
   //0x7f,0xff,0x04,0x00}
   //
-  EFI_DEVICE_PATH_PROTOCOLDevicePath[];
+  EFI_DEVICE_PATH_PROTOCOL  DevicePath[MAX_DEVICE_PATH_NODE];
 } REST_EX_SERVICE_DEVICE_PATH_DATA;
 
 #endif
-- 
2.39.0



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




Re: [edk2-devel] [PATCH V3 0/5] Adding necessary changes for RedfishPkg

2023-05-05 Thread Minh Nguyen

Hi Abner,

 I've updated. Thanks for your review.

Thanks,

Minh Nguyen

On 5/5/2023 2:38 PM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Minh,
Please add my RB for 3/5 in commit message and push to 
minhnampere:Adding_necessary_changes_for_RedfishPkg again.   I will check the 
PR and merge it once it passes CI.

Thank for your contribution.
Abner


-Original Message-
From: minhnampere 
Sent: Friday, May 5, 2023 2:46 PM
To: devel@edk2.groups.io
Cc: patc...@amperecomputing.com; Chang, Abner
; nick...@nvidia.com; ig...@ami.com;
n...@os.amperecomputing.com; tinhngu...@os.amperecomputing.com;
minhnampere 
Subject: [PATCH V3 0/5] Adding necessary changes for RedfishPkg

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


This patchset adds necessary changes for RedfishPkg to avoid some
unexpected cases and fix compilation.

Changes since v3:
  + Replaced __FUNCTION__ with __func__ to be more C11 compliant.
Changes since v2:
  + Added "Cc:" to maintainers in commit message.
  + Corrected patch format subject prefix.
Changes since v1:
  + Removed redundant change and change the commit message for more
precise in PATCH 2/5.

Nhi Pham (1):
   RedfishPkg: Add missing newline character

Vu Nguyen (4):
   RedfishPkg: Correct variable type to prevent memory corruption
   RedfishPkg: Fix condition checking of error status
   RedfishPkg: Create RestEx child on selected interface
   RedfishPkg: Fix compile issue on Linux

  RedfishPkg/Include/Library/RestExLib.h   |   3 +
  RedfishPkg/Include/Pcd/RestExServiceDevicePath.h |   5 +-
  RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h|   3 +-
  RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c   | 153 


  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c   |   4 +-
  RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c |   3 +-
  6 files changed, 73 insertions(+), 98 deletions(-)

--
2.39.0



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




Re: [edk2-devel] [PATCH V2 3/5] RedfishPkg: Create RestEx child on selected interface

2023-05-05 Thread Minh Nguyen

Hi Abner,

 I have checked in my system and it works fines when using 
RedfishConfigHandlerDriver.


 I also updated new patches, could you please help me to check it?

Thanks,

Minh Nguyen

On 5/4/2023 3:26 PM, Minh Nguyen wrote:

Hi Abner,

 Let me check in my system and will give the confirmation to you.


Thanks,

Minh Nguyen

On 5/4/2023 3:00 PM, Chang, Abner wrote:

[AMD Official Use Only - General]

Hi Minh, please check my comment inline,


-Original Message-
From: Minh Nguyen 
Sent: Thursday, May 4, 2023 12:20 PM
To: devel@edk2.groups.io
Cc: patc...@amperecomputing.com; Chang, Abner
; nick...@nvidia.com; ig...@ami.com;
n...@os.amperecomputing.com; Vu Nguyen
; Minh Nguyen
; Nick Ramirez

Subject: [PATCH V2 3/5] RedfishPkg: Create RestEx child on selected
interface

Caution: This message originated from an External Source. Use proper
caution when opening attachments, clicking links, or responding.


From: Vu Nguyen 

When a MAC address matching interface is found, a RestEx child will be
created to provide the Redfish communication on that interface.
Currently, It will try to locate all RestEx binding services and 
choose the first
satisfied instance without taking care about current selected 
interface. This
might raise an issue on the system with multiple network devices 
that the

RestEx child was installed on wrong interface.

Signed-off-by: Minh Nguyen 
Cc: Abner Chang 
Cc: Igor Kulchytskyy 
Cc: Nick Ramirez 
---
  RedfishPkg/Include/Library/RestExLib.h |   3 +
  RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c | 153 
--

--
  RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c |   1 +
  3 files changed, 63 insertions(+), 94 deletions(-)

diff --git a/RedfishPkg/Include/Library/RestExLib.h
b/RedfishPkg/Include/Library/RestExLib.h
index bc4e4ca6caa7..2c32c3684cf4 100644
--- a/RedfishPkg/Include/Library/RestExLib.h
+++ b/RedfishPkg/Include/Library/RestExLib.h
@@ -2,6 +2,7 @@
    This library provides help functions for REST EX Protocol.

    (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.

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

@@ -20,6 +21,7 @@
    This function allows the caller to create child handle for specific
    REST server.

+  @param[in]  Controller   The controller handle used of 
selected

interface.
    @param[in]  Image    The image handle used to open 
service.

    @param[in]  AccessMode   Access mode of REST server.
    @param[in]  ConfigType   Underlying configuration to 
communicate

with REST server.
@@ -32,6 +34,7 @@
  **/
  EFI_STATUS
  RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
    IN EFI_HANDLE   Image,
    IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
    IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
diff --git a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
index d9acad24dec1..6002be93c54e 100644
--- a/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
+++ b/RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
@@ -2,6 +2,7 @@
    This library provides help functions for REST EX Protocol.

    (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.

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

@@ -9,6 +10,7 @@

  #include 
  #include 
+#include 
  #include   #include 
#include 
@@ -21,6 +23,7 @@
    This function allows the caller to create child handle for specific
    REST server.

+  @param[in]  Controller   The controller handle used of 
selected

interface.
    @param[in]  Image    The image handle used to open 
service.

    @param[in]  AccessMode   Access mode of REST server.
    @param[in]  ConfigType   Underlying configuration to 
communicate

with REST server.
@@ -33,6 +36,7 @@
  **/
  EFI_STATUS
  RestExLibCreateChild (
+  IN EFI_HANDLE   Controller,
    IN EFI_HANDLE   Image,
    IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
    IN EFI_REST_EX_CONFIG_TYPE  ConfigType,
@@ -41,8 +45,6 @@ RestExLibCreateChild (
    )
  {
    EFI_STATUS    Status;
-  UINTN NoBuffer;
-  EFI_HANDLE    *Handle;
    EFI_HANDLE    ChildHandle;
    EFI_REST_EX_PROTOCOL  *RestEx;
    EFI_REST_EX_SERVICE_INFO  *RestExServiceInfo; @@ -59,116 +61,79 @@
RestExLibCreateChild (
    }

    *ChildInstanceHandle = NULL;
-  //
-  // Locate all REST EX binding service.
-  //
-  Handle   = NULL;
-  NoBuffer = 0;
-  Status   = gBS->LocateHandleBuffer (
-    ByProtocol,
- &gEfiRestExServiceBindingProtocolGuid,
-    NULL,
-    &NoBuffer,
-    &Handle
-    );
-  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+
+  ChildHandle = NULL;
+  Sta

[edk2-devel] [Patch 1/1] MdeModulePkg/CapsuleApp: Add EFIAPI to CompareFileNameInAlphabet()

2023-05-05 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4446

CompareFileNameInAlphabet() is passed as a function pointer
parameter and typecast to type SORT_COMPARE that is declared
with EFIAPI.  Add EFIAPI to CompareFileNameInAlphabet() to match
SORT_COMPARE type.

Cc: Jian J Wang 
Cc: Liming Gao 
Cc: Guomin Jiang 
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
index 26ad60ce592e..7605153e972b 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
@@ -632,6 +632,7 @@ SplitFileNameExtension (
 
 **/
 INTN
+EFIAPI
 CompareFileNameInAlphabet (
   IN VOID  *Left,
   IN VOID  *Right
-- 
2.40.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104138): https://edk2.groups.io/g/devel/message/104138
Mute This Topic: https://groups.io/mt/98710234/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 v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged.

2023-05-05 Thread Laszlo Ersek
On 5/5/23 16:10, Michael Brown wrote:
> On 03/05/2023 08:19, Gerd Hoffmann wrote:
>> OVMF can't guarantee that the ASSERT() doesn't happen.  Misbehaving
>> EFI applications can trigger this.  So log a warning instead and try
>> to continue.
>>
>> Reproducer: Fetch windows 11 22H2 iso image, boot it in qemu with OVMF.
>>
>> Traced to BootServices->Stall() being called with IPL=TPL_HIGH_LEVEL
>> and Interrupts /enabled/ while windows is booting.
>>
>> Cc: Michael Brown 
>> Cc: Laszlo Ersek 
>> Signed-off-by: Gerd Hoffmann 
>> ---
>>   OvmfPkg/Library/NestedInterruptTplLib/Tpl.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
>> b/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
>> index e19d98878eb7..fdd7d15c4ba8 100644
>> --- a/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
>> +++ b/OvmfPkg/Library/NestedInterruptTplLib/Tpl.c
>> @@ -39,7 +39,9 @@ NestedInterruptRaiseTPL (
>>     //
>>     ASSERT (GetInterruptState () == FALSE);
>>     InterruptedTPL = gBS->RaiseTPL (TPL_HIGH_LEVEL);
>> -  ASSERT (InterruptedTPL < TPL_HIGH_LEVEL);
>> +  if (InterruptedTPL >= TPL_HIGH_LEVEL) {
>> +    DEBUG ((DEBUG_WARN, "%a: Called at IPL %d\n", __func__,
>> InterruptedTPL));
>> +  }
>>       return InterruptedTPL;
>>   }
> 
> While https://bugzilla.redhat.com/show_bug.cgi?id=2189136 continues to
> track the underlying Windows bug that leads to this assertion being
> triggered: I suspect that this patch will allow people to boot these
> buggy versions of Windows in OVMF, and I don't think it will make things
> any worse.
> 
> I would probably suggest changing DEBUG_WARN to DEBUG_ERROR since this
> represents a serious invariant violation being detected.  With that change:
> 
>   Reviewed-by: Michael Brown 

I don't like the patch. For two reasons:

(1) It papers over the actual issue. The problem should be fixed where
it is, if possible.

(2) With the patch applied, NestedInterruptRaiseTPL() can return
TPL_HIGH_LEVEL (as "InterruptedTPL"). Consequently,
TimerInterruptHandler() [OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c]
may pass TPL_HIGH_LEVEL back to NestedInterruptRestoreTPL(), as
"InterruptedTPL".

I believe that this in turn may invalidate at least one comment in
NestedInterruptRestoreTPL():

//
// Call RestoreTPL() to allow event notifications to be
// dispatched.  This will implicitly re-enable interrupts.
//
gBS->RestoreTPL (InterruptedTPL);

Restoring TPL_HIGH_LEVEL does not re-enable interrupts -- nominally anyways.


I wouldn't like OVMF to stick with yet another workaround / yet more
internal inconsistency. We should just wait until fixed Windows
installer media gets released.

Here's an alternative:

(a) Make LocalApicTimerDxe Xen-specific again. It's only the OVMF Xen
platform that really *needs* NestedInterruptTplLib. (Don't get me wrong:
NestedInterruptTplLib is technically correct in all circumstances, but
in practice it happens to be too strict.)

(b) For the non-Xen OVMF platforms, re-create a LocalApicTimerDxe
variant that effectively has commits a086f4a63bc0 and a24fbd606125
reverted. (We should keep 9bf473da4c1d.) This returns us to
pre-239b50a86370 status -- that is, a timer interrupt handler that (a)
does not try to be smart about nested interrupts, therefore one that is
much simpler, and (b) is more tolerant of the Windows / cdboot.efi spec
violation, (c) is vulnerable to the timer interrupt storm seen on Xen,
but will never run on Xen. (Only the OVMF Xen platform is supposed to be
launched on Xen.)

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104158): https://edk2.groups.io/g/devel/message/104158
Mute This Topic: https://groups.io/mt/98656860/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] purpose of EFI_LOCK

2023-05-05 Thread Laszlo Ersek
Hi Andrew,

thank you! The background / paragraph on the naming helps!

Cheers,
Laszlo

On 5/4/23 20:01, Andrew (EFI) Fish wrote:
> Laszlo,
> 
> Hope you are doing well! Sorry to top post but I’m just commenting on
> the big picture, not answering your specific questions yet.
> 
> The Wiki definition of lock  is something like: In computer science
> locks are a mechanism that enforces limits on access to a resource when
> there is the possibility for contention between threads of execution. I
> think the key point here is “threads of execution” is not threads….
> 
> UEFI is single threaded with a cooperative event model. There is no
> scheduler and an event blocks all forward progress of any event at the
> same or lower TPL. The protocol services have defined TPL Restrictions
> [1] so that is possible to implement locking. In the context of EFI
> raising the TPL blocks any “threads of execution” (events) that could
> preempt the running code from contending with a critical section. 
> 
> Lets thing about what would happen if you use an atomic primitive as a
> lock in EFI. Let’s say the app is installing a protocol so the DXE Core
> has the protocol database locked. Any event that fired in that window
> would not be able to call any UEFI Boot Service that was related to
> protocols and expect it to succeed. If the event blocked on the lock,
> the system is dead locked. If the the lock was tested and failed that
> basically means it would be normal for any UEFI service to fail in
> events and event code needed to coded to deal with that. Basically the
> even could we need to defer to a future time the event gets signaled. I
> think think this quickly devolves in the event code having to implement
> a simple scheduler for its set. Thus making locks raise the TPL is just
> better for everyone. 
> 
> Not that we have always been good at naming things, but in the context
> of EFI a Lock is best implemented as raising TPL so we made an up level
> look API to make that clear to people, and to help educate people how
> locks should be implemented in EFI.
> 
> This is old, but it is a good sumarry of why we did not want BIOS
> programmers dealing with threads 20+ years ago when we designed EFI. 
> 
> 
> preview.png
> threads 
> PDF Document · 107 KB
> 
> 
> 
> 
> 
> [1]
> https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html#tpl-restrictions
>  
> 
> 
> Thanks,
> 
> Andrew Fish
> 
>> On May 4, 2023, at 1:45 AM, Laszlo Ersek  wrote:
>>
>> Hi,
>>
>> what benefit does EFI_LOCK add, over direct gBS->RaiseTPL() and
>> gBS->RestoreTPL() calls?
>>
>> Considering just the two APIs EfiAcquireLock() and EfiReleaseLock():
>>
>> - The "Lock" field (effectively, lock status field) is useless; it is
>> only written to, never read (outside of ASSERT()s)
>>
>> - The "OwnerTpl" and "Tpl" fields are just convenience storage for the
>> new TPL we raise to, and the old TPL we restore.
>>
>> Considering the EfiAcquireLockOrFail() API as well:
>>
>> - This does read the "Lock" (lock status) field, and if it is
>> EfiLockAcquired, the RaiseTPL() call is refused. So the idea here seems
>> to be to ensure a *strict* rise in the TPL. Namely, the RaiseTPL() in
>> EfiAcquireLockOrFail() would still succeed after the RaiseTPL() in
>> EfiAcquireLock() -- it is valid to "raise" the TPL to the current TPL
>> --, but the lock status check prevents that.
>>
>> - However (#1), this same "strict" raise would be possible by just
>> calling RaiseTPL() again, and comparing the returned old TPL against the
>> TPL we've just set as new. If the old TPL is strictly lower, then we've
>> just "acquired the lock", otherwise we've "already been holding" the
>> lock. So, from this perspective, EfiAcquireLockOrFail() doesn't add much.
>>
>> - Furthermore (#2), if another agent raised the TPL already, but didn't
>> use our particlar EFI_LOCK object to do that, then the status stored in
>> "EFI_LOCK.Lock" will not be able to track anything.
>>
>> So what is EFI_LOCK good for?
>>
>> Effectively I'm disturbed by the *name* "EFI_LOCK". A lock (or mutex) is
>> supposed to protect some shared resource. If two agents access the
>> resource without first acquiring the lock, there's trouble. Therefore
>> the resource itself becomes qualified as "requiring protection by the
>> lock, at all times". However, the "current TPL" is *not* a resource like
>> that. It's a UEFI spec level concept; the RaiseTPL and RestoreTPL boot
>> services are available to any agents; those agents are *not* required to
>> go through any kind of extra mutual exclusion.
>>
>> I've also considered that maybe EFI_LOCK could provide some protection
>> against inadvertently *lowering* the TPL via RaiseTPL() (which is
>> undefined beha

Re: [edk2-devel] purpose of EFI_LOCK

2023-05-05 Thread vincent zimmer
Random and tl;dr fun friday fact.
You can see the efi locks replaced w/ spinlocks in
https://github.com/tianocore/edk2-staging/tree/MpNetworkStack to
support the use case described in
https://uefi.org/sites/default/files/resources/7_Maciej%20Vincent_INTEL_network%20stack%20performance.pdf.
These changes along w/ a bespoke threading protocol allow for running
efi networking code across all cores and still be able to interact w/
an enlightened dxe core. We didn't push forward to standardize for
various reasons, such as folks pursuing an alternate solution to the
original problem statement (e.g., LinuxBoot for datacenter network
provisioning) and the huge legacy app compat we'd face. So it's
'possible', just as you 'could' have i/o device interrupt service
routines (isr) w/ their own 'device' tpl's between notify and high
(see "firmware interrupts"
https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html#tpl-usage)
if you were to expose the appropriate registration and dispatch
interface from the core. I don't think we put anything in staging or
elsewhere public w/ isr examples, though, and I expect trying to
retrofit after 2+ decades would face similar app compat issues w/
folks who already curate their own proprietary device interrupt sol'n.
Vincent

On Fri, May 5, 2023 at 12:59 PM Laszlo Ersek  wrote:
>
> Hi Andrew,
>
> thank you! The background / paragraph on the naming helps!
>
> Cheers,
> Laszlo
>
> On 5/4/23 20:01, Andrew (EFI) Fish wrote:
> > Laszlo,
> >
> > Hope you are doing well! Sorry to top post but I’m just commenting on
> > the big picture, not answering your specific questions yet.
> >
> > The Wiki definition of lock  is something like: In computer science
> > locks are a mechanism that enforces limits on access to a resource when
> > there is the possibility for contention between threads of execution. I
> > think the key point here is “threads of execution” is not threads….
> >
> > UEFI is single threaded with a cooperative event model. There is no
> > scheduler and an event blocks all forward progress of any event at the
> > same or lower TPL. The protocol services have defined TPL Restrictions
> > [1] so that is possible to implement locking. In the context of EFI
> > raising the TPL blocks any “threads of execution” (events) that could
> > preempt the running code from contending with a critical section.
> >
> > Lets thing about what would happen if you use an atomic primitive as a
> > lock in EFI. Let’s say the app is installing a protocol so the DXE Core
> > has the protocol database locked. Any event that fired in that window
> > would not be able to call any UEFI Boot Service that was related to
> > protocols and expect it to succeed. If the event blocked on the lock,
> > the system is dead locked. If the the lock was tested and failed that
> > basically means it would be normal for any UEFI service to fail in
> > events and event code needed to coded to deal with that. Basically the
> > even could we need to defer to a future time the event gets signaled. I
> > think think this quickly devolves in the event code having to implement
> > a simple scheduler for its set. Thus making locks raise the TPL is just
> > better for everyone.
> >
> > Not that we have always been good at naming things, but in the context
> > of EFI a Lock is best implemented as raising TPL so we made an up level
> > look API to make that clear to people, and to help educate people how
> > locks should be implemented in EFI.
> >
> > This is old, but it is a good sumarry of why we did not want BIOS
> > programmers dealing with threads 20+ years ago when we designed EFI.
> >
> >
> > preview.png
> > threads 
> > PDF Document · 107 KB
> > 
> >
> > 
> >
> >
> > [1]
> > https://uefi.org/specs/UEFI/2.10/07_Services_Boot_Services.html#tpl-restrictions
> >  
> > 
> >
> > Thanks,
> >
> > Andrew Fish
> >
> >> On May 4, 2023, at 1:45 AM, Laszlo Ersek  wrote:
> >>
> >> Hi,
> >>
> >> what benefit does EFI_LOCK add, over direct gBS->RaiseTPL() and
> >> gBS->RestoreTPL() calls?
> >>
> >> Considering just the two APIs EfiAcquireLock() and EfiReleaseLock():
> >>
> >> - The "Lock" field (effectively, lock status field) is useless; it is
> >> only written to, never read (outside of ASSERT()s)
> >>
> >> - The "OwnerTpl" and "Tpl" fields are just convenience storage for the
> >> new TPL we raise to, and the old TPL we restore.
> >>
> >> Considering the EfiAcquireLockOrFail() API as well:
> >>
> >> - This does read the "Lock" (lock status) field, and if it is
> >> EfiLockAcquired, the RaiseTPL() call is refused. So the idea here seems
> >> to be to ensure a *strict* rise in the TPL. Namely, the RaiseTPL() in
> >> EfiAcquireLockOrFail() would still succeed after the Rais

Re: [edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on Linux

2023-05-05 Thread Pedro Falcato
On Fri, May 5, 2023 at 6:12 PM Minh Nguyen via groups.io
 wrote:
>
> From: Vu Nguyen 
>
> It requires a fixed size array to store the content of device path PCD.
> Add the array size to solve this issue.
>
> Signed-off-by: Minh Nguyen 
> Cc: Abner Chang 
> Cc: Igor Kulchytskyy 
> Cc: Nick Ramirez 
> Reviewed-by: Abner Chang 
> ---
>  RedfishPkg/Include/Pcd/RestExServiceDevicePath.h | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h 
> b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> index 91b1198297c2..57fc199f61f2 100644
> --- a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> +++ b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> @@ -4,6 +4,7 @@
>
>Copyright (c) 2019, Intel Corporation. All rights reserved.
>(C) Copyright 2020 Hewlett Packard Enterprise Development LP
> +  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
>
>  SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -14,6 +15,8 @@
>
>  #include 
>
> +#define MAX_DEVICE_PATH_NODE  40
> +
>  typedef enum {
>DEVICE_PATH_MATCH_MAC_NODE = 1,
>DEVICE_PATH_MATCH_PCI_NODE = 2,
> @@ -32,7 +35,7 @@ typedef struct {
>//
> 0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
>//0x7f,0xff,0x04,0x00}
>//
> -  EFI_DEVICE_PATH_PROTOCOLDevicePath[];
> +  EFI_DEVICE_PATH_PROTOCOL  DevicePath[MAX_DEVICE_PATH_NODE];
>  } REST_EX_SERVICE_DEVICE_PATH_DATA;

This doesn't work (changes the meaning) and may possibly break ABI.

What error do you get? What compiler?

C99 flexible array members have been well defined and well supported
for maybe 20 years in GCC (https://godbolt.org/z/9qxKar4f6)

-- 
Pedro


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




Re: [edk2-devel] [PATCH v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged.

2023-05-05 Thread Michael Brown

On 05/05/2023 19:56, Laszlo Ersek wrote:

I don't like the patch. For two reasons:

(1) It papers over the actual issue. The problem should be fixed where
it is, if possible.


Agreed, but (as you have shown in 
https://bugzilla.redhat.com/show_bug.cgi?id=2189136) the bug lies in 
Windows code rather than in EDK2 code.  If the goal is to allow these 
buggy Windows builds to still be used with OVMF, then the only option is 
to paper over the issue.  We should do this only if it can be proven 
safe to do so, of course.



(2) With the patch applied, NestedInterruptRaiseTPL() can return
TPL_HIGH_LEVEL (as "InterruptedTPL"). Consequently,
TimerInterruptHandler() [OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c]
may pass TPL_HIGH_LEVEL back to NestedInterruptRestoreTPL(), as
"InterruptedTPL".

I believe that this in turn may invalidate at least one comment in
NestedInterruptRestoreTPL():

 //
 // Call RestoreTPL() to allow event notifications to be
 // dispatched.  This will implicitly re-enable interrupts.
 //
 gBS->RestoreTPL (InterruptedTPL);

Restoring TPL_HIGH_LEVEL does not re-enable interrupts -- nominally anyways.


I agree that the comment is invalidated, but as far as I can tell the 
logic remains safe.


I will put together a patch to update the comments in 
NestedInterruptTplLib to address the possibility of an interrupt 
occurring (illegally) at TPL_HIGH_LEVEL.



(a) Make LocalApicTimerDxe Xen-specific again. It's only the OVMF Xen
platform that really *needs* NestedInterruptTplLib. (Don't get me wrong:
NestedInterruptTplLib is technically correct in all circumstances, but
in practice it happens to be too strict.)

(b) For the non-Xen OVMF platforms, re-create a LocalApicTimerDxe
variant that effectively has commits a086f4a63bc0 and a24fbd606125
reverted. (We should keep 9bf473da4c1d.) This returns us to
pre-239b50a86370 status -- that is, a timer interrupt handler that (a)
does not try to be smart about nested interrupts, therefore one that is
much simpler, and (b) is more tolerant of the Windows / cdboot.efi spec
violation, (c) is vulnerable to the timer interrupt storm seen on Xen,
but will never run on Xen. (Only the OVMF Xen platform is supposed to be
launched on Xen.)


I'm less keen on this because it reduces the runtime exposure of a very 
complex piece of code, and will effectively cause that code to become 
unmaintained.


It's also satisfying (to me) that NestedInterruptTplLib provides a 
provable upper bound on stack consumption due to interrupts, which can't 
be guaranteed by the simpler pre-239b50a86370 scheme.


Could we defer judgement until after I've fully reasoned through (and 
documented) how NestedInterruptTplLib will work in the presence of 
interrupts occurring at TPL_HIGH_LEVEL?


Thanks,

Michael



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104162): https://edk2.groups.io/g/devel/message/104162
Mute This Topic: https://groups.io/mt/98656860/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 5/5] RedfishPkg: Fix compile issue on Linux

2023-05-05 Thread Michael D Kinney
I agree that flexible array members are a good way to define this.

The consumer needs to allocate extra space for the flexible array member.

If the size of the device path is known, then the allocation can be the exact 
size needed.

sizeof(REST_EX_SERVICE_DEVICE_PATH_DATA) + DevicePathSize(DevicePath)

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Pedro
> Falcato
> Sent: Friday, May 5, 2023 3:57 PM
> To: devel@edk2.groups.io; minhnguy...@os.amperecomputing.com
> Cc: patc...@amperecomputing.com; abner.ch...@amd.com;
> nick...@nvidia.com; ig...@ami.com; n...@os.amperecomputing.com;
> tinhngu...@os.amperecomputing.com; Vu Nguyen
> ; Nick Ramirez
> 
> Subject: Re: [edk2-devel] [PATCH V3 5/5] RedfishPkg: Fix compile issue on
> Linux
> 
> On Fri, May 5, 2023 at 6:12 PM Minh Nguyen via groups.io
>  wrote:
> >
> > From: Vu Nguyen 
> >
> > It requires a fixed size array to store the content of device path PCD.
> > Add the array size to solve this issue.
> >
> > Signed-off-by: Minh Nguyen 
> > Cc: Abner Chang 
> > Cc: Igor Kulchytskyy 
> > Cc: Nick Ramirez 
> > Reviewed-by: Abner Chang 
> > ---
> >  RedfishPkg/Include/Pcd/RestExServiceDevicePath.h | 5 -
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> > index 91b1198297c2..57fc199f61f2 100644
> > --- a/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> > +++ b/RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
> > @@ -4,6 +4,7 @@
> >
> >Copyright (c) 2019, Intel Corporation. All rights reserved.
> >(C) Copyright 2020 Hewlett Packard Enterprise Development LP
> > +  Copyright (c) 2023, Ampere Computing LLC. All rights reserved.
> >
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -14,6 +15,8 @@
> >
> >  #include 
> >
> > +#define MAX_DEVICE_PATH_NODE  40
> > +
> >  typedef enum {
> >DEVICE_PATH_MATCH_MAC_NODE = 1,
> >DEVICE_PATH_MATCH_PCI_NODE = 2,
> > @@ -32,7 +35,7 @@ typedef struct {
> >//
> 0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00
> ,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
> 0,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
> >//0x7f,0xff,0x04,0x00}
> >//
> > -  EFI_DEVICE_PATH_PROTOCOLDevicePath[];
> > +  EFI_DEVICE_PATH_PROTOCOL  DevicePath[MAX_DEVICE_PATH_NODE];
> >  } REST_EX_SERVICE_DEVICE_PATH_DATA;
> 
> This doesn't work (changes the meaning) and may possibly break ABI.
> 
> What error do you get? What compiler?
> 
> C99 flexible array members have been well defined and well supported
> for maybe 20 years in GCC (https://godbolt.org/z/9qxKar4f6)
> 
> --
> Pedro
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104163): https://edk2.groups.io/g/devel/message/104163
Mute This Topic: https://groups.io/mt/98710278/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 v2 1/1] OvmfPkg/NestedInterruptTplLib: replace ASSERT() with a warning logged.

2023-05-05 Thread Ard Biesheuvel
On Sat, 6 May 2023 at 01:27, Michael Brown  wrote:
>
> On 05/05/2023 19:56, Laszlo Ersek wrote:
> > I don't like the patch. For two reasons:
> >
> > (1) It papers over the actual issue. The problem should be fixed where
> > it is, if possible.
>
> Agreed, but (as you have shown in
> https://bugzilla.redhat.com/show_bug.cgi?id=2189136) the bug lies in
> Windows code rather than in EDK2 code.  If the goal is to allow these
> buggy Windows builds to still be used with OVMF, then the only option is
> to paper over the issue.  We should do this only if it can be proven
> safe to do so, of course.
>
> > (2) With the patch applied, NestedInterruptRaiseTPL() can return
> > TPL_HIGH_LEVEL (as "InterruptedTPL"). Consequently,
> > TimerInterruptHandler() [OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c]
> > may pass TPL_HIGH_LEVEL back to NestedInterruptRestoreTPL(), as
> > "InterruptedTPL".
> >
> > I believe that this in turn may invalidate at least one comment in
> > NestedInterruptRestoreTPL():
> >
> >  //
> >  // Call RestoreTPL() to allow event notifications to be
> >  // dispatched.  This will implicitly re-enable interrupts.
> >  //
> >  gBS->RestoreTPL (InterruptedTPL);
> >
> > Restoring TPL_HIGH_LEVEL does not re-enable interrupts -- nominally anyways.
>
> I agree that the comment is invalidated, but as far as I can tell the
> logic remains safe.
>
> I will put together a patch to update the comments in
> NestedInterruptTplLib to address the possibility of an interrupt
> occurring (illegally) at TPL_HIGH_LEVEL.
>
> > (a) Make LocalApicTimerDxe Xen-specific again. It's only the OVMF Xen
> > platform that really *needs* NestedInterruptTplLib. (Don't get me wrong:
> > NestedInterruptTplLib is technically correct in all circumstances, but
> > in practice it happens to be too strict.)
> >
> > (b) For the non-Xen OVMF platforms, re-create a LocalApicTimerDxe
> > variant that effectively has commits a086f4a63bc0 and a24fbd606125
> > reverted. (We should keep 9bf473da4c1d.) This returns us to
> > pre-239b50a86370 status -- that is, a timer interrupt handler that (a)
> > does not try to be smart about nested interrupts, therefore one that is
> > much simpler, and (b) is more tolerant of the Windows / cdboot.efi spec
> > violation, (c) is vulnerable to the timer interrupt storm seen on Xen,
> > but will never run on Xen. (Only the OVMF Xen platform is supposed to be
> > launched on Xen.)
>
> I'm less keen on this because it reduces the runtime exposure of a very
> complex piece of code, and will effectively cause that code to become
> unmaintained.
>
> It's also satisfying (to me) that NestedInterruptTplLib provides a
> provable upper bound on stack consumption due to interrupts, which can't
> be guaranteed by the simpler pre-239b50a86370 scheme.
>
> Could we defer judgement until after I've fully reasoned through (and
> documented) how NestedInterruptTplLib will work in the presence of
> interrupts occurring at TPL_HIGH_LEVEL?
>

Would it be feasible for our firmware implementation to disable the
timer interrupt at the timer end as well?

E.g.,

RaiseTPL(HIGH)::

CLI
disarm timer


RestoreTPL::


re-arm timer
STI


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




回复: [edk2-devel] [Patch 1/1] MdeModulePkg/CapsuleApp: Add EFIAPI to CompareFileNameInAlphabet()

2023-05-05 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Michael D
> Kinney
> 发送时间: 2023年5月6日 1:10
> 收件人: devel@edk2.groups.io
> 抄送: Jian J Wang ; Liming Gao
> ; Guomin Jiang 
> 主题: [edk2-devel] [Patch 1/1] MdeModulePkg/CapsuleApp: Add EFIAPI to
> CompareFileNameInAlphabet()
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4446
> 
> CompareFileNameInAlphabet() is passed as a function pointer
> parameter and typecast to type SORT_COMPARE that is declared
> with EFIAPI.  Add EFIAPI to CompareFileNameInAlphabet() to match
> SORT_COMPARE type.
> 
> Cc: Jian J Wang 
> Cc: Liming Gao 
> Cc: Guomin Jiang 
> Signed-off-by: Michael D Kinney 
> ---
>  MdeModulePkg/Application/CapsuleApp/CapsuleDump.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> index 26ad60ce592e..7605153e972b 100644
> --- a/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> +++ b/MdeModulePkg/Application/CapsuleApp/CapsuleDump.c
> @@ -632,6 +632,7 @@ SplitFileNameExtension (
> 
>  **/
>  INTN
> +EFIAPI
>  CompareFileNameInAlphabet (
>IN VOID  *Left,
>IN VOID  *Right
> --
> 2.40.1.windows.1
> 
> 
> 
> 
> 





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




[edk2-devel] 回复: [PATCH v1 03/11] MdePkg/Acpi64: Add _PSD/_CPC/State Coordination Types macros

2023-05-05 Thread gaoliming via groups.io
Pierre:

> -邮件原件-
> 发件人: pierre.gond...@arm.com 
> 发送时间: 2023年5月5日 21:17
> 收件人: devel@edk2.groups.io
> 抄送: Ard Biesheuvel ; Leif Lindholm
> ; Sami Mujawar ; Michael D
> Kinney ; Liming Gao
> ; Zhiguang Liu 
> 主题: [PATCH v1 03/11] MdePkg/Acpi64: Add _PSD/_CPC/State Coordination
> Types macros
> 
> From: Pierre Gondois 
> 
> Add macros for:
> - _PSD version
> - _CPC version
> - C-state/T-state/P-state Coordination Types
> 
> These objects were present in previous ACPI specification version,
> but are only added to the latest availbable version (6.4).
> 
> Signed-off-by: Pierre Gondois 
> ---
>  MdePkg/Include/IndustryStandard/Acpi64.h | 25
> +++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h
> b/MdePkg/Include/IndustryStandard/Acpi64.h
> index 575ca0430c13..e3c128d7548d 100644
> --- a/MdePkg/Include/IndustryStandard/Acpi64.h
> +++ b/MdePkg/Include/IndustryStandard/Acpi64.h
> @@ -2,7 +2,7 @@
>ACPI 6.4 definitions from the ACPI Specification Revision 6.4 Jan,
2021.
> 
>Copyright (c) 2017 - 2022, Intel Corporation. All rights reserved.
> -  Copyright (c) 2019 - 2021, ARM Ltd. All rights reserved.
> +  Copyright (c) 2019 - 2023, Arm Ltd. All rights reserved.
> 
I see other source files all use ARM Ltd. Is it required to be updated to
Arm Ltd?

Thanks
Liming
>SPDX-License-Identifier: BSD-2-Clause-Patent
>  **/
> @@ -17,6 +17,29 @@
>  //
>  #pragma pack(1)
> 
> +///
> +/// C-state/T-state/P-state Coordination Types
> +/// Cf. s8.3 Power, Performance, and Throttling State Dependencies
> +///
> +#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ALL  0xFC
> +#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_SW_ANY  0xFD
> +#define EFI_ACPI_6_4_AML_STATE_COORD_TYPE_HW_ALL  0xFE
> +
> +///
> +/// _PSD Revision
> +/// Cf. s8.4.6.5 _PSD (P-State Dependency)
> +///
> +#define EFI_ACPI_6_4_AML_PSD_REVISION_V0  0
> +
> +///
> +/// _CPC Revision
> +/// Cf. s8.4.7.1 _CPC (Continuous Performance Control)
> +///
> +#define EFI_ACPI_6_4_AML_CPC_REVISION_V0  0
> +#define EFI_ACPI_6_4_AML_CPC_REVISION_V1  1
> +#define EFI_ACPI_6_4_AML_CPC_REVISION_V2  2
> +#define EFI_ACPI_6_4_AML_CPC_REVISION_V3  3
> +
>  ///
>  /// ACPI 6.4 Generic Address Space definition
>  ///
> --
> 2.25.1





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




[edk2-devel] [Patch 1/1] BaseTools/Conf: Align CLANGDWARF and CLANGPDB warning overrides

2023-05-05 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4447

Fix build error related to use of DEBUG_CODE_BEGIN() and
DEBUG_CODE_END(). CLANGPDB requires extra warning disables
for use of DebugLib.h macros.  This change aligns the warning
disables between CLANGDWARF and CLANGPDB.

Cc: Rebecca Cran 
Cc: Liming Gao 
Cc: Bob Feng 
Cc: Yuwei Chen 
Signed-off-by: Michael D Kinney 
---
 BaseTools/Conf/tools_def.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 1b3a9e7a540a..0e49d8c3b999 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -1753,7 +1753,7 @@ DEFINE CLANGPDB_X64_PREFIX   = ENV(CLANG_BIN)
 DEFINE CLANGPDB_IA32_TARGET  = -target i686-unknown-windows-gnu
 DEFINE CLANGPDB_X64_TARGET   = -target x86_64-unknown-windows-gnu
 
-DEFINE CLANGPDB_WARNING_OVERRIDES= -Wno-parentheses-equality 
-Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare 
-Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
-Wno-unknown-warning-option -Wno-microsoft-enum-forward-reference
+DEFINE CLANGPDB_WARNING_OVERRIDES= -Wno-parentheses-equality 
-Wno-tautological-compare -Wno-tautological-constant-out-of-range-compare 
-Wno-empty-body -Wno-unused-const-variable -Wno-varargs 
-Wno-unknown-warning-option -Wno-unused-but-set-variable 
-Wno-unused-const-variable -Wno-unaligned-access 
-Wno-microsoft-enum-forward-reference
 DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS) 
DEF(CLANGPDB_WARNING_OVERRIDES) -fno-stack-protector -funsigned-char 
-ftrap-function=undefined_behavior_has_been_optimized_away_by_clang 
-Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas 
-Wno-incompatible-library-redeclaration -Wno-null-dereference 
-mno-implicit-float -mms-bitfields -mno-stack-arg-probe -nostdlib -nostdlibinc 
-fseh-exceptions
 
 ###
-- 
2.40.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104167): https://edk2.groups.io/g/devel/message/104167
Mute This Topic: https://groups.io/mt/98719448/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 1/1] BaseTools/Conf: Add quotes to ADDDEBUGFLAG in tools_def.txt

2023-05-05 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4448

Update tools_def.txt to add quotes around the file target in
OBJCOPY_ADDDEBUGFLAGS for compatibility with GCC like tool
chains used on Windows.

Cc: Rebecca Cran 
Cc: Liming Gao 
Cc: Bob Feng 
Cc: Yuwei Chen 
Signed-off-by: Michael D Kinney 
---
 BaseTools/Conf/tools_def.template | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Conf/tools_def.template 
b/BaseTools/Conf/tools_def.template
index 1b3a9e7a540a..535dda1d5d99 100755
--- a/BaseTools/Conf/tools_def.template
+++ b/BaseTools/Conf/tools_def.template
@@ -731,9 +731,9 @@ NOOPT_VS2019_AARCH64_DLINK_FLAGS   = /NOLOGO /NODEFAULTLIB 
/IGNORE:4001 /OPT:REF
 *_*_*_OBJCOPY_FLAGS = objcopy not needed for
 *_*_*_SYMRENAME_PATH= echo
 *_*_*_SYMRENAME_FLAGS   = Symbol renaming not needed for
-DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
+DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
 RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
-NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
+NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG = 
--add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
 *_*_*_OBJCOPY_STRIPFLAG= --strip-unneeded -R .eh_frame
 *_*_*_DTC_FLAGS= -H epapr
 *_*_*_DTCPP_PATH   = DEF(DTCPP_BIN)
-- 
2.40.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104168): https://edk2.groups.io/g/devel/message/104168
Mute This Topic: https://groups.io/mt/98719526/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] [edk2-platforms:PATCH V1] MinPlatformPkg/SaveMemoryConfig: Support NVS Data compression.

2023-05-05 Thread Raghava Gudla
Around 50KB "FspNonVolatileStorageHob" data can be compressed to
approximately 3 KB which can save NVRAM space and enhance life
of the SPI part by decreasing the number of reclaim cycles needed.

This patch added support to compress "FspNonVolatileStorageHob" data
before saving to NVRAM.

A PcdEnableCompressFspNvsHob is introduced to enable/disable this
feature per platform usage.

Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Isaac Oram 

Signed-off-by: Raghava Gudla 
---
 .../SaveMemoryConfig/SaveMemoryConfig.c   | 34 +++
 .../SaveMemoryConfig/SaveMemoryConfig.inf |  6 +++-
 .../Include/Dsc/CoreCommonLib.dsc |  1 +
 .../Intel/MinPlatformPkg/MinPlatformPkg.dec   |  5 +++
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c 
b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
index 0215e8eed..8aa935b54 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
+++ 
b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c
@@ -21,6 +21,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /**
   This is the standard EFI driver point that detects whether there is a
@@ -45,6 +47,9 @@ SaveMemoryConfigEntryPoint (
   UINTN DataSize;
   UINTN BufferSize;
   BOOLEAN   DataIsIdentical;
+  VOID  *CompressedData;
+  UINT64CompressedSize;
+  UINTN CompressedAllocationPages;
 
   DataSize= 0;
   BufferSize  = 0;
@@ -73,6 +78,35 @@ SaveMemoryConfigEntryPoint (
 }
   }
 
+  if (PcdGetBool (PcdEnableCompressFspNvsHob) == 1) {
+CompressedData= NULL;
+CompressedSize= 0;
+CompressedAllocationPages = 0;
+
+DEBUG ((DEBUG_INFO, "compressing mem config nvs variable\n"));
+if (DataSize > 0) {
+  CompressedAllocationPages = EFI_SIZE_TO_PAGES (DataSize);
+  CompressedData = AllocatePages (CompressedAllocationPages);
+  if (CompressedData == NULL) {
+DEBUG ((DEBUG_ERROR, "[%a] - Failed to allocate compressed data 
buffer.\n", __func__));
+ASSERT_EFI_ERROR (EFI_OUT_OF_RESOURCES);
+return EFI_OUT_OF_RESOURCES;
+  }
+
+  CompressedSize = EFI_PAGES_TO_SIZE (CompressedAllocationPages);
+  Status = Compress (HobData, DataSize, CompressedData, &CompressedSize);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "[%a] - failed to compress data. Status = %r\n", 
__func__, Status));
+ASSERT_EFI_ERROR (Status);
+FreePool(CompressedData);
+return Status;
+  } else {
+HobData  = CompressedData;
+DataSize = (UINTN) CompressedSize;
+  }
+}
+  }
+
   if (HobData != NULL) {
 DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataLength:%d\n", DataSize));
 DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr   : 0x%x\n", HobData));
diff --git 
a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
 
b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
index 61e85a658..77920d031 100644
--- 
a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
+++ 
b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
@@ -26,6 +26,7 @@
   LargeVariableReadLib
   LargeVariableWriteLib
   BaseLib
+  CompressLib
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -45,6 +46,9 @@
   gFspNonVolatileStorageHob2Guid## CONSUMES
   gFspNvsBufferVariableGuid ## PRODUCES
 
+[Pcd]
+  gMinPlatformPkgTokenSpaceGuid.PcdEnableCompressFspNvsHob
+
 [Depex]
   gEfiVariableArchProtocolGuidAND
-  gEfiVariableWriteArchProtocolGuid
\ No newline at end of file
+  gEfiVariableWriteArchProtocolGuid
diff --git a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc 
b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
index 5ce21cf31..dfe7d836d 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
+++ b/Platform/Intel/MinPlatformPkg/Include/Dsc/CoreCommonLib.dsc
@@ -147,6 +147,7 @@
   BmpSupportLib|MdeModulePkg/Library/BaseBmpSupportLib/BaseBmpSupportLib.inf
   
LargeVariableReadLib|MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableReadLib.inf
   
LargeVariableWriteLib|MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.inf
+  CompressLib|MinPlatformPkg/Library/CompressLib/CompressLib.inf
 
   #
   # CryptLib
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec 
b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
index 784abb828..e21d55fb3 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -348,6 +348,11 @@
   gMinPlatformPkgTokenSpaceGuid.PcdFadtFlags|0x86A5|UINT32|0x9027
   gMinPlatformPkgTokenSpaceGuid.PcdFadtMajorVersion|0x06|UINT8|0x9030
   

回复: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to ADDDEBUGFLAG in tools_def.txt

2023-05-05 Thread gaoliming via groups.io
Mike:
  Do you mean $(DEBUG_DIR)/$(MODULE_NAME).debug file path may have space on
windows OS? Does the workspace directory include the space?

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Michael D
> Kinney
> 发送时间: 2023年5月6日 10:47
> 收件人: devel@edk2.groups.io
> 抄送: Rebecca Cran ; Liming Gao
> ; Bob Feng ; Yuwei Chen
> 
> 主题: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> ADDDEBUGFLAG in tools_def.txt
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4448
> 
> Update tools_def.txt to add quotes around the file target in
> OBJCOPY_ADDDEBUGFLAGS for compatibility with GCC like tool
> chains used on Windows.
> 
> Cc: Rebecca Cran 
> Cc: Liming Gao 
> Cc: Bob Feng 
> Cc: Yuwei Chen 
> Signed-off-by: Michael D Kinney 
> ---
>  BaseTools/Conf/tools_def.template | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 1b3a9e7a540a..535dda1d5d99 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -731,9 +731,9 @@ NOOPT_VS2019_AARCH64_DLINK_FLAGS   =
> /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
>  *_*_*_OBJCOPY_FLAGS = objcopy not needed for
>  *_*_*_SYMRENAME_PATH= echo
>  *_*_*_SYMRENAME_FLAGS   = Symbol renaming not needed for
> -DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> +DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
>  RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
> -NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> +NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
>  *_*_*_OBJCOPY_STRIPFLAG= --strip-unneeded -R .eh_frame
>  *_*_*_DTC_FLAGS= -H epapr
>  *_*_*_DTCPP_PATH   = DEF(DTCPP_BIN)
> --
> 2.40.1.windows.1
> 
> 
> 
> 
> 





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




回复: [edk2-devel] [Patch 1/1] BaseTools/Conf: Align CLANGDWARF and CLANGPDB warning overrides

2023-05-05 Thread gaoliming via groups.io
Reviewed-by: Liming Gao 

> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 Michael D
> Kinney
> 发送时间: 2023年5月6日 10:38
> 收件人: devel@edk2.groups.io
> 抄送: Rebecca Cran ; Liming Gao
> ; Bob Feng ; Yuwei Chen
> 
> 主题: [edk2-devel] [Patch 1/1] BaseTools/Conf: Align CLANGDWARF and
> CLANGPDB warning overrides
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4447
> 
> Fix build error related to use of DEBUG_CODE_BEGIN() and
> DEBUG_CODE_END(). CLANGPDB requires extra warning disables
> for use of DebugLib.h macros.  This change aligns the warning
> disables between CLANGDWARF and CLANGPDB.
> 
> Cc: Rebecca Cran 
> Cc: Liming Gao 
> Cc: Bob Feng 
> Cc: Yuwei Chen 
> Signed-off-by: Michael D Kinney 
> ---
>  BaseTools/Conf/tools_def.template | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/BaseTools/Conf/tools_def.template
> b/BaseTools/Conf/tools_def.template
> index 1b3a9e7a540a..0e49d8c3b999 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -1753,7 +1753,7 @@ DEFINE CLANGPDB_X64_PREFIX   =
> ENV(CLANG_BIN)
>  DEFINE CLANGPDB_IA32_TARGET  = -target
> i686-unknown-windows-gnu
>  DEFINE CLANGPDB_X64_TARGET   = -target
> x86_64-unknown-windows-gnu
> 
> -DEFINE CLANGPDB_WARNING_OVERRIDES=
> -Wno-parentheses-equality -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
> -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
> -Wno-microsoft-enum-forward-reference
> +DEFINE CLANGPDB_WARNING_OVERRIDES=
> -Wno-parentheses-equality -Wno-tautological-compare
> -Wno-tautological-constant-out-of-range-compare -Wno-empty-body
> -Wno-unused-const-variable -Wno-varargs -Wno-unknown-warning-option
> -Wno-unused-but-set-variable -Wno-unused-const-variable
> -Wno-unaligned-access -Wno-microsoft-enum-forward-reference
>  DEFINE CLANGPDB_ALL_CC_FLAGS = DEF(GCC48_ALL_CC_FLAGS)
> DEF(CLANGPDB_WARNING_OVERRIDES) -fno-stack-protector
> -funsigned-char
> -ftrap-function=undefined_behavior_has_been_optimized_away_by_clang
> -Wno-address -Wno-shift-negative-value -Wno-unknown-pragmas
> -Wno-incompatible-library-redeclaration -Wno-null-dereference
> -mno-implicit-float -mms-bitfields -mno-stack-arg-probe -nostdlib
-nostdlibinc
> -fseh-exceptions
> 
>  ###
> --
> 2.40.1.windows.1
> 
> 
> 
> 
> 





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




[edk2-devel] [PATCH v11 0/8] Adds AmdSmmCpuFeaturesLib and MmSaveStateLib

2023-05-05 Thread Abdul Lateef Attar via groups.io
PR: https://github.com/tianocore/edk2/pull/4341

V11: Delta changes
Drop the OVMF implementation of MmSaveStateLib
V10: Delta changes:
  Addressed review comments from Abner.
V9: Delta changes:
  Addressed review comments.
  Rename to MmSaveStateLib.
  Also rename SMM_ defines to MM_.
  Implemented OVMF MmSaveStateLib.
  Removes SmmCpuFeaturesReadSaveStateRegister and 
SmmCpuFeaturesWriteSaveStateRegister
  function interface.
V8 delta changes:
   Addressed review comments from Abner,
   Fix the whitespace error.
   Seperate the Ovmf changes to another patch
V7 delta changes:
   Adds SmmSmramSaveStateLib for Intel processor.
   Integrate SmmSmramSaveStateLib library.
V6 delta changes:
   Addressed review comments for Ray NI.
   removed unnecessary EFIAPI.
V5 delta changes:
   rebase to master branch.
   updated Reviewed-by
V4 delta changes:
  rebase to master branch.
  added reviewed-by.
V3 delta changes:
  Addressed review comments from Abner chang.
  Re-arranged patch order.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Cc: Abdul Lateef Attar 

Abdul Lateef Attar (8):
  MdePkg: Adds AMD SMRAM save state map
  UefiCpuPkg: Adds MmSaveStateLib library class
  UefiCpuPkg: Implements MmSaveStateLib library instance
  UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code
  UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family
  UefiCpuPkg: Implements MmSaveStateLib for Intel
  UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister
  OvmfPkg: Uses MmSaveStateLib library

 UefiCpuPkg/UefiCpuPkg.dec |   4 +
 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   3 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 UefiCpuPkg/UefiCpuPkg.dsc |  14 +
 .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  28 +
 .../MmSaveStateLib/IntelMmSaveStateLib.inf|  28 +
 .../AmdSmmCpuFeaturesLib.inf  |  38 +
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   2 +
 .../Include/Register/Amd/SmramSaveStateMap.h  | 194 +
 UefiCpuPkg/Include/Library/MmSaveStateLib.h   |  70 ++
 .../Include/Library/SmmCpuFeaturesLib.h   |  52 --
 .../Library/MmSaveStateLib/MmSaveState.h  | 102 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 309 +++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 413 ++
 .../MmSaveStateLib/MmSaveStateCommon.c| 138 
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 387 +
 .../IntelSmmCpuFeaturesLib.c  |  70 ++
 .../SmmCpuFeaturesLibCommon.c | 128 ---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c|  11 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c| 500 +---
 MdePkg/MdePkg.ci.yaml |   4 +-
 24 files changed, 1812 insertions(+), 1508 deletions(-)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 create mode 100644 
UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 create mode 100644 MdePkg/Include/Register/Amd/SmramSaveStateMap.h
 create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveStateCommon.c
 create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c

-- 
2.25.1



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




[edk2-devel] [PATCH v11 2/8] UefiCpuPkg: Adds MmSaveStateLib library class

2023-05-05 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Adds MmSaveStateLib Library class in UefiCpuPkg.dec.
Adds function declaration header file.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dec   |  4 ++
 UefiCpuPkg/Include/Library/MmSaveStateLib.h | 70 +
 2 files changed, 74 insertions(+)
 create mode 100644 UefiCpuPkg/Include/Library/MmSaveStateLib.h

diff --git a/UefiCpuPkg/UefiCpuPkg.dec b/UefiCpuPkg/UefiCpuPkg.dec
index d31c3b127c0b..1f1b10e702bf 100644
--- a/UefiCpuPkg/UefiCpuPkg.dec
+++ b/UefiCpuPkg/UefiCpuPkg.dec
@@ -2,6 +2,7 @@
 # This Package provides UEFI compatible CPU modules and libraries.
 #
 # Copyright (c) 2007 - 2023, Intel Corporation. All rights reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -60,6 +61,9 @@ [LibraryClasses.IA32, LibraryClasses.X64]
   ##  @libraryclass  Provides function for manipulating x86 paging structures.
   CpuPageTableLib|Include/Library/CpuPageTableLib.h
 
+  ## @libraryclass   Provides functions for manipulating smram savestate 
registers.
+  MmSaveStateLib|Include/Library/MmSaveStateLib.h
+
 [Guids]
   gUefiCpuPkgTokenSpaceGuid  = { 0xac05bf33, 0x995a, 0x4ed4, { 0xaa, 0xb8, 
0xef, 0x7a, 0xe8, 0xf, 0x5c, 0xb0 }}
   gMsegSmramGuid = { 0x5802bce4, 0x, 0x4e33, { 0xa1, 0x30, 
0xeb, 0xad, 0x27, 0xf0, 0xe4, 0x39 }}
diff --git a/UefiCpuPkg/Include/Library/MmSaveStateLib.h 
b/UefiCpuPkg/Include/Library/MmSaveStateLib.h
new file mode 100644
index ..1c82facb6841
--- /dev/null
+++ b/UefiCpuPkg/Include/Library/MmSaveStateLib.h
@@ -0,0 +1,70 @@
+/** @file
+Library that provides service to read/write CPU specific smram save state 
registers.
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MM_SAVE_STATE_LIB_H_
+#define MM_SAVE_STATE_LIB_H_
+
+#include 
+#include 
+
+/**
+  Read a save state register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  MM Save State register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the Save State register.
+The value must be between 0 and the NumberOfCpus field 
in
+the System Management System Table (SMST).
+  @param[in]  Register  The MM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value read
+from the save state.
+
+  @retval EFI_SUCCESS   The register was read from Save State.
+  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
+  @retval EFI_NOT_FOUND If desired Register not found.
+**/
+EFI_STATUS
+EFIAPI
+MmSaveStateReadRegister (
+  IN  UINTN   CpuIndex,
+  IN  EFI_MM_SAVE_STATE_REGISTER  Register,
+  IN  UINTN   Width,
+  OUT VOID*Buffer
+  );
+
+/**
+  Writes a save state register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
+  MM save state register.
+
+  @param[in] CpuIndex  The index of the CPU to write the MM Save State.  The
+   value must be between 0 and the NumberOfCpus field in
+   the System Management System Table (SMST).
+  @param[in] Register  The MM Save State register to write.
+  @param[in] Width The number of bytes to write to the CPU save state.
+  @param[in] BufferUpon entry, this holds the new CPU register value.
+
+  @retval EFI_SUCCESS   The register was written to Save State.
+  @retval EFI_INVALID_PARAMTER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support writing 
Register.
+  @retval EFI_NOT_FOUND If desired Register not found.
+**/
+EFI_STATUS
+EFIAPI
+MmSaveStateWriteRegister (
+  IN UINTN   CpuIndex,
+  IN EFI_MM_SAVE_STATE_REGISTER  Register,
+  IN UINTN   Width,
+  IN CONST VOID  *Buffer
+  );
+
+#endif
-- 
2.25.1



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




[edk2-devel] [PATCH v11 1/8] MdePkg: Adds AMD SMRAM save state map

2023-05-05 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Adds an SMM SMRAM save-state map for AMD processors.
SMRAM save state maps for the AMD processor family are now supported.

Save state map structure is added based on
AMD64 Architecture Programmer's Manual, Volume 2, Section 10.2.

The AMD legacy save state map for 32-bit architecture is defined.
The AMD64 save state map for 64-bit architecture is defined. 

Also added Amd/SmramSaveStateMap.h to IgnoreFiles of EccCheck,
because structures defined in this file are derived from
Intel/SmramSaveStateMap.h.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
Reviewed-by: Michael D Kinney 
---
 .../Include/Register/Amd/SmramSaveStateMap.h  | 194 ++
 MdePkg/MdePkg.ci.yaml |   4 +-
 2 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 MdePkg/Include/Register/Amd/SmramSaveStateMap.h

diff --git a/MdePkg/Include/Register/Amd/SmramSaveStateMap.h 
b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
new file mode 100644
index ..0607d2a19145
--- /dev/null
+++ b/MdePkg/Include/Register/Amd/SmramSaveStateMap.h
@@ -0,0 +1,194 @@
+/** @file
+  AMD SMRAM Save State Map Definitions.
+
+  SMRAM Save State Map definitions based on contents of the
+AMD64 Architecture Programmer Manual:
+Volume 2, System Programming, Section 10.2 SMM Resources
+
+  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved .
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef AMD_SMRAM_SAVE_STATE_MAP_H_
+#define AMD_SMRAM_SAVE_STATE_MAP_H_
+
+///
+/// Default SMBASE address
+///
+#define SMM_DEFAULT_SMBASE  0x3
+
+///
+/// Offset of SMM handler from SMBASE
+///
+#define SMM_HANDLER_OFFSET  0x8000
+
+// SMM-Revision Identifier for AMD64 Architecture.
+#define AMD_SMM_MIN_REV_ID_X64  0x30064
+
+#pragma pack (1)
+
+///
+/// 32-bit SMRAM Save State Map
+///
+typedef struct {
+  // Padded an extra 0x200 bytes to match Intel/EDK2
+  UINT8 Reserved[0x200]; // fc00h
+  // AMD Save State area starts @ 0xfe00
+  UINT8 Reserved1[0xf8]; // fe00h
+  UINT32SMBASE;  // fef8h
+  UINT32SMMRevId;// fefch
+  UINT16IORestart;   // ff00h
+  UINT16AutoHALTRestart; // ff02h
+  UINT8 Reserved2[0x84]; // ff04h
+  UINT32GDTBase; // ff88h
+  UINT64Reserved3;   // ff8ch
+  UINT32IDTBase; // ff94h
+  UINT8 Reserved4[0x10]; // ff98h
+  UINT32_ES; // ffa8h
+  UINT32_CS; // ffach
+  UINT32_SS; // ffb0h
+  UINT32_DS; // ffb4h
+  UINT32_FS; // ffb8h
+  UINT32_GS; // ffbch
+  UINT32LDTBase; // ffc0h
+  UINT32_TR; // ffc4h
+  UINT32_DR7;// ffc8h
+  UINT32_DR6;// ffcch
+  UINT32_EAX;// ffd0h
+  UINT32_ECX;// ffd4h
+  UINT32_EDX;// ffd8h
+  UINT32_EBX;// ffdch
+  UINT32_ESP;// ffe0h
+  UINT32_EBP;// ffe4h
+  UINT32_ESI;// ffe8h
+  UINT32_EDI;// ffech
+  UINT32_EIP;// fff0h
+  UINT32_EFLAGS; // fff4h
+  UINT32_CR3;// fff8h
+  UINT32_CR0;// fffch
+} AMD_SMRAM_SAVE_STATE_MAP32;
+
+///
+/// 64-bit SMRAM Save State Map
+///
+typedef struct {
+  // Padded an extra 0x200 bytes to match Intel/EDK2
+  UINT8 Reserved[0x200]; // fc00h
+  // AMD Save State area starts @ 0xfe00
+  UINT16_ES;  // fe00h
+  UINT16_ESAttributes;// fe02h
+  UINT32_ESLimit; // fe04h
+  UINT64_ESBase;  // fe08h
+
+  UINT16_CS;  // fe10h
+  UINT16_CSAttributes;// fe12h
+  UINT32_CSLimit; // fe14h
+  UINT64_CSBase;  // fe18h
+
+  UINT16_SS;  // fe20h
+  UINT16_SSAttributes;// fe22h
+  UINT32_SSLimit; // fe24h
+  UINT64_SSBase;  // fe28h
+
+  UINT16_DS;  // fe30h
+  UINT16_DSAttributes;// fe32h
+  UINT32_DSLimit; // fe34h
+  UINT64_DSBase;  // fe38h
+
+  UINT16_FS;  // fe40h
+  UINT16_FSAttributes;// fe42h
+  UINT32_FSLimit; // fe44h
+  UINT64_FSBase;  // fe48h
+
+  UINT16_GS;  // fe50h
+  UINT16_GSAttributes;// fe52h
+  UINT32_GSLimit; // fe54h
+  UINT64_GSBase;  // fe58h
+
+  UINT32_GDTRReserved1;   // fe60h
+  UINT16_GDTRLimit;   // fe64h
+  UINT16_GDTRReserved2;   // fe66h
+  // UINT64  _GDTRBase;// fe68h
+  UINT32_GDTRBaseLoDword;
+  UINT32_GDTRBaseHiDword;
+
+  UINT16_LDTR;// fe70h
+  UINT16_LDTRAttributes;  // fe72h
+  UINT32_LDTRL

[edk2-devel] [PATCH v11 4/8] UefiCpuPkg/SmmCpuFeaturesLib: Restructure arch-dependent code

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

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

moves Intel-specific code to the arch-dependent file.
Other processor families might have different
implementation of these functions.
Hence, moving out of the common file.

Cc: Abner Chang 
Cc: Paul Grimes 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 .../IntelSmmCpuFeaturesLib.c  | 128 ++
 .../SmmCpuFeaturesLibCommon.c | 128 --
 2 files changed, 128 insertions(+), 128 deletions(-)

diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
index 1a2c706fa1f1..8f382b60266c 100644
--- a/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c
@@ -417,3 +417,131 @@ SmmCpuFeaturesSetSmmRegister (
 AsmWriteMsr64 (SMM_FEATURES_LIB_SMM_FEATURE_CONTROL, Value);
   }
 }
+
+/**
+  This function updates the SMRAM save state on the currently executing CPU
+  to resume execution at a specific address after an RSM instruction.  This
+  function must evaluate the SMRAM save state to determine the execution mode
+  the RSM instruction resumes and update the resume execution address with
+  either NewInstructionPointer32 or NewInstructionPoint.  The auto HALT restart
+  flag in the SMRAM save state must always be cleared.  This function returns
+  the value of the instruction pointer from the SMRAM save state that was
+  replaced.  If this function returns 0, then the SMRAM save state was not
+  modified.
+
+  This function is called during the very first SMI on each CPU after
+  SmmCpuFeaturesInitializeProcessor() to set a flag in normal execution mode
+  to signal that the SMBASE of each CPU has been updated before the default
+  SMBASE address is used for the first SMI to the next CPU.
+
+  @param[in] CpuIndex The index of the CPU to hook.  The value
+  must be between 0 and the NumberOfCpus
+  field in the System Management System 
Table
+  (SMST).
+  @param[in] CpuState Pointer to SMRAM Save State Map for the
+  currently executing CPU.
+  @param[in] NewInstructionPointer32  Instruction pointer to use if resuming to
+  32-bit execution mode from 64-bit SMM.
+  @param[in] NewInstructionPointerInstruction pointer to use if resuming to
+  same execution mode as SMM.
+
+  @retval 0This function did modify the SMRAM save state.
+  @retval > 0  The original instruction pointer value from the SMRAM save state
+   before it was replaced.
+**/
+UINT64
+EFIAPI
+SmmCpuFeaturesHookReturnFromSmm (
+  IN UINTN CpuIndex,
+  IN SMRAM_SAVE_STATE_MAP  *CpuState,
+  IN UINT64NewInstructionPointer32,
+  IN UINT64NewInstructionPointer
+  )
+{
+  return 0;
+}
+
+/**
+  Read an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  SMM Save Sate register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
+value must be between 0 and the NumberOfCpus field in
+the System Management System Table (SMST).
+  @param[in]  Register  The SMM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value read
+from the save state.
+
+  @retval EFI_SUCCESS   The register was read from Save State.
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
+  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
+
+**/
+EFI_STATUS
+EFIAPI
+SmmCpuFeaturesReadSaveStateRegister (
+  IN  UINTNCpuIndex,
+  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
+  IN  UINTNWidth,
+  OUT VOID *Buffer
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Writes an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
+  SMM Save Sate register.
+
+  @param[in] CpuIndex  The index of the CPU to write the SMM Save State.  The
+   value must be between 0 and the NumberOfCpus field in
+   the System Management System Table (SMST).
+  @param[in] Register  The SMM Save State register to write.
+  @param[in] Width The number of bytes to write to the CPU save state.
+  @param[in] BufferUpon entry, this holds the new CPU register value.
+
+  @retval EFI_SUCCESS   The regis

[edk2-devel] [PATCH v11 3/8] UefiCpuPkg: Implements MmSaveStateLib library instance

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

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

Implements MmSaveStateLib Library class for
AMD cpu family.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 

Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   3 +
 .../MmSaveStateLib/AmdMmSaveStateLib.inf  |  28 ++
 .../Library/MmSaveStateLib/MmSaveState.h  | 102 ++
 .../Library/MmSaveStateLib/AmdMmSaveState.c   | 309 ++
 .../MmSaveStateLib/MmSaveStateCommon.c| 138 
 5 files changed, 580 insertions(+)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveState.c
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/MmSaveStateCommon.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 593c11cc7482..8b0cb02a80e8 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -2,6 +2,7 @@
 #  UefiCpuPkg Package
 #
 #  Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -99,6 +100,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [LibraryClasses.common.MM_STANDALONE]
   
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
@@ -182,6 +184,7 @@ [Components.IA32, Components.X64]
 
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
+  UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [Components.X64]
   
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf 
b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
new file mode 100644
index ..426eb87a4d1f
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
@@ -0,0 +1,28 @@
+## @file
+# MM Smram save state service lib.
+#
+# This is MM Smram save state service lib that provide service to read and
+# save savestate area registers.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = AmdMmSaveStateLib
+  FILE_GUID  = FB7D0A60-E8D4-4EFA-90AA-B357BC569879
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmSaveStateLib
+
+[Sources]
+  MmSaveState.h
+  MmSaveStateCommon.c
+  AmdMmSaveState.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h 
b/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
new file mode 100644
index ..80b10450013b
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/MmSaveState.h
@@ -0,0 +1,102 @@
+/** @file
+  SMRAM Save State Map header file.
+
+  Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef MM_SAVESTATE_H_
+#define MM_SAVESTATE_H_
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// EFER register LMA bit
+#define LMA  BIT10
+
+// Macro used to simplify the lookup table entries of type 
CPU_MM_SAVE_STATE_REGISTER_RANGE
+#define MM_REGISTER_RANGE(Start, End)  { Start, End, End - Start + 1 }
+
+#define MM_SAVE_STATE_REGISTER_MAX_INDEX  2
+
+// Structure used to describe a range of registers
+typedef struct {
+  EFI_MM_SAVE_STATE_REGISTERStart;
+  EFI_MM_SAVE_STATE_REGISTEREnd;
+  UINTN Length;
+} CPU_MM_SAVE_STATE_REGISTER_RANGE;
+
+// Structure used to build a lookup table to retrieve the widths and offsets
+// associated with each supported EFI_MM_SAVE_STATE_REGISTER value
+
+typedef struct {
+  UINT8  Width32;
+  UINT8  Width64;
+  UINT16 Offset32;
+  UINT16 Offset64Lo;
+  UINT16 Offset64Hi;
+  BOOLEANWriteable;
+} CPU_MM_SAVE_STATE_LOOKUP_ENTRY;
+
+/**
+  Returns LMA value of the Processor.
+
+  @param[in]  CpuIndex  Specifies the zero-based index of the CPU save state.
+
+  @retval UINT8 returns LMA bit value.
+**/
+UINT8
+EFIAPI
+MmSaveStateGetRegisterLma (
+  IN UINTN  CpuIndex
+  );
+
+/**
+  Read information from the CPU s

[edk2-devel] [PATCH v11 5/8] UefiCpuPkg: Implements SmmCpuFeaturesLib for AMD Family

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

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

Implements interfaces to read and write save state
registers of AMD's processor family.
Initializes processor SMMADDR and MASK depends
on PcdSmrrEnable flag.
Program or corrects the IP once control returns from SMM.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   7 +
 .../AmdSmmCpuFeaturesLib.inf  |  38 ++
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  | 445 ++
 3 files changed, 490 insertions(+)
 create mode 100644 
UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 create mode 100644 UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 8b0cb02a80e8..6e29850bed17 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -169,6 +169,12 @@ [Components.IA32, Components.X64]
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
   }
+  UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
+
+  FILE_GUID = B7242C74-BD21-49EE-84B4-07162E8C080D
+
+  
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
+  }
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
   UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
@@ -185,6 +191,7 @@ [Components.IA32, Components.X64]
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
   UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 
 [Components.X64]
   
UefiCpuPkg/Library/CpuExceptionHandlerLib/UnitTest/DxeCpuExceptionHandlerLibUnitTest.inf
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
new file mode 100644
index ..fcf6514443d1
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
@@ -0,0 +1,38 @@
+## @file
+#  The CPU specific programming for PiSmmCpuDxeSmm module.
+#
+#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = SmmCpuFeaturesLib
+  MODULE_UNI_FILE= SmmCpuFeaturesLib.uni
+  FILE_GUID  = 5849E964-78EC-428E-8CBD-848A7E359134
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = SmmCpuFeaturesLib
+  CONSTRUCTOR= SmmCpuFeaturesLibConstructor
+
+[Sources]
+  SmmCpuFeaturesLib.c
+  SmmCpuFeaturesLibCommon.c
+  AmdSmmCpuFeaturesLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  PcdLib
+  MemoryAllocationLib
+  DebugLib
+  MmSaveStateLib
+
+[FeaturePcd]
+  gUefiCpuPkgTokenSpaceGuid.PcdSmrrEnable   ## CONSUMES
+  gUefiCpuPkgTokenSpaceGuid.PcdSmmFeatureControlEnable  ## CONSUMES
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c 
b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
new file mode 100644
index ..1473f0a51fe2
--- /dev/null
+++ b/UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c
@@ -0,0 +1,445 @@
+/** @file
+Implementation specific to the SmmCpuFeatureLib library instance
+for AMD based platforms.
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+// EFER register LMA bit
+#define LMA  BIT10
+
+// Machine Specific Registers (MSRs)
+#define SMMADDR_ADDRESS  0xC0010112ul
+#define SMMMASK_ADDRESS  0xC0010113ul
+#define EFER_ADDRESS 0XC080ul
+
+// The mode of the CPU at the time an SMI occurs
+STATIC UINT8  mSmmSaveStateRegisterLma;
+
+/**
+  Read an SMM Save State register on the target processor.  If this function
+  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
+  SMM Save Sate register.
+
+  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
+value must be between 0 and the NumberOfCpus field in
+the System Management System Table (SMST).
+  @param[in]  Register  The SMM Save State register to read.
+  @param[in]  Width The number of bytes to read from the CPU save state.
+  @param[out] BufferUpon return, this holds the CPU register value read
+

[edk2-devel] [PATCH v11 6/8] UefiCpuPkg: Implements MmSaveStateLib for Intel

2023-05-05 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Implements MmSaveStateLib library interfaces
to read and write save state
registers for Intel processor family.

Moves Intel and AMD common functionality to common area.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/UefiCpuPkg.dsc |   4 +
 .../MmSaveStateLib/IntelMmSaveStateLib.inf|  28 ++
 .../Library/MmSaveStateLib/IntelMmSaveState.c | 413 ++
 3 files changed, 445 insertions(+)
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 create mode 100644 UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c

diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 6e29850bed17..401550209af9 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -101,6 +101,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
   MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
 
 [LibraryClasses.common.MM_STANDALONE]
   
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
@@ -168,12 +169,14 @@ [Components.IA32, Components.X64]
   FILE_GUID = D1D74FE9-7A4E-41D3-A0B3-67F13AD34D94
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
   }
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
 
   FILE_GUID = B7242C74-BD21-49EE-84B4-07162E8C080D
 
   
SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
   UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
   UefiCpuPkg/ResetVector/Vtf0/Bin/ResetVector.inf
@@ -191,6 +194,7 @@ [Components.IA32, Components.X64]
   
UnitTestResultReportLib|UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.inf
   }
   UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
+  UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
   UefiCpuPkg/Library/SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.inf
 
 [Components.X64]
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf 
b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
new file mode 100644
index ..a07515f7dfa6
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveStateLib.inf
@@ -0,0 +1,28 @@
+## @file
+# SMM Smram save state service lib.
+#
+# This is SMM Smram save state service lib that provide service to read and
+# save savestate area registers.
+#
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 1.29
+  BASE_NAME  = IntelMmSaveStateLib
+  FILE_GUID  = 37E8137B-9F74-4250-8951-7A970A3C39C0
+  MODULE_TYPE= DXE_SMM_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = MmSaveStateLib
+
+[Sources]
+  MmSaveState.h
+  MmSaveStateCommon.c
+  IntelMmSaveState.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiCpuPkg/UefiCpuPkg.dec
diff --git a/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c 
b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
new file mode 100644
index ..d7e31af5275a
--- /dev/null
+++ b/UefiCpuPkg/Library/MmSaveStateLib/IntelMmSaveState.c
@@ -0,0 +1,413 @@
+/** @file
+Provides services to access SMRAM Save State Map
+
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "MmSaveState.h"
+#include 
+#include 
+#include 
+
+#define MM_SAVE_STATE_REGISTER_SMMREVID_INDEX1
+#define MM_SAVE_STATE_REGISTER_IOMISC_INDEX  2
+#define MM_SAVE_STATE_REGISTER_IOMEMADDR_INDEX   3
+#define INTEL_SMM_SAVE_STATE_REGISTER_MAX_INDEX  4
+
+///
+/// Macro used to simplify the lookup table entries of type 
CPU_MM_SAVE_STATE_LOOKUP_ENTRY
+///
+#define MM_CPU_OFFSET(Field)  OFFSET_OF (SMRAM_SAVE_STATE_MAP, Field)
+
+///
+/// Lookup table used to retrieve the widths and offsets associated with each
+/// supported EFI_MM_SAVE_STATE_REGISTER value
+///
+CONST CPU_MM_SAVE_STATE_LOOKUP_ENTRY  mCpuWidthOffset[] = {
+  { 0, 0, 0, 0,  
0,  FALSE }, //  Reserved
+
+  //
+  // Internally defined CPU Save State Registers. Not defined in PI SMM CPU 
Protocol.
+  //
+  { 4, 4, MM_CPU_OFFSET (x86.SMMRevId),  MM_CPU_O

[edk2-devel] [PATCH v11 8/8] OvmfPkg: Uses MmSaveStateLib library

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

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

Uses new MmSaveStateLib library instance.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Abdul Lateef Attar 
---
 OvmfPkg/OvmfPkgIa32.dsc   |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc|   3 +
 OvmfPkg/OvmfPkgX64.dsc|   1 +
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.c | 767 --
 4 files changed, 5 insertions(+), 767 deletions(-)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index e333b8b41803..86fc9f6174b2 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -972,6 +972,7 @@ [Components]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 25974230a27e..da5fd7042f4f 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -4,6 +4,7 @@
 #  Copyright (c) 2006 - 2023, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
+#  Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -444,6 +445,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
   
SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezvousLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
 
 [LibraryClasses.common.SMM_CORE]
   PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -990,6 +992,7 @@ [Components.X64]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index c1762ffca445..ae706a5099c5 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -1066,6 +1066,7 @@ [Components]
 
   
SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
   SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf
+  MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
   }
 
   #
diff --git a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c 
b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
index a009123dae88..4c354bafe42f 100644
--- a/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
+++ b/OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
@@ -578,773 +578,6 @@ SmmCpuFeaturesSetSmmRegister (
   ASSERT (FALSE);
 }
 
-///
-/// Macro used to simplify the lookup table entries of type
-/// CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
-///
-#define SMM_CPU_OFFSET(Field)  OFFSET_OF (QEMU_SMRAM_SAVE_STATE_MAP, Field)
-
-///
-/// Macro used to simplify the lookup table entries of type
-/// CPU_SMM_SAVE_STATE_REGISTER_RANGE
-///
-#define SMM_REGISTER_RANGE(Start, End)  { Start, End, End - Start + 1 }
-
-///
-/// Structure used to describe a range of registers
-///
-typedef struct {
-  EFI_SMM_SAVE_STATE_REGISTERStart;
-  EFI_SMM_SAVE_STATE_REGISTEREnd;
-  UINTN  Length;
-} CPU_SMM_SAVE_STATE_REGISTER_RANGE;
-
-///
-/// Structure used to build a lookup table to retrieve the widths and offsets
-/// associated with each supported EFI_SMM_SAVE_STATE_REGISTER value
-///
-
-#define SMM_SAVE_STATE_REGISTER_FIRST_INDEX  1
-
-typedef struct {
-  UINT8  Width32;
-  UINT8  Width64;
-  UINT16 Offset32;
-  UINT16 Offset64Lo;
-  UINT16 Offset64Hi;
-  BOOLEANWriteable;
-} CPU_SMM_SAVE_STATE_LOOKUP_ENTRY;
-
-///
-/// Table used by GetRegisterIndex() to convert an EFI_SMM_SAVE_STATE_REGISTER
-/// value to an index into a table of type CPU_SMM_SAVE_STATE_LOOKUP_ENTRY
-///
-STATIC CONST CPU_SMM_SAVE_STATE_REGISTER_RANGE  mSmmCpuRegisterRanges[] = {
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_GDTBASE,
-EFI_SMM_SAVE_STATE_REGISTER_LDTINFO
-),
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_ES,
-EFI_SMM_SAVE_STATE_REGISTER_RIP
-),
-  SMM_REGISTER_RANGE (
-EFI_SMM_SAVE_STATE_REGISTER_RFLAGS,
-EFI_SMM_SAVE_STATE_REGISTER_CR4
-),
-  { (EFI_SMM_SAVE_STATE_REGISTER)0, (EFI_SMM_SAVE_STATE_REGISTER)0,0 }
-};
-
-///
-/// Lookup table used to retrieve the widths and offsets associated with each
-/// supported EFI_SMM_SAVE_STATE_REGISTER value
-///
-STATIC CON

[edk2-devel] [PATCH v11 7/8] UefiCpuPkg: Removes SmmCpuFeaturesReadSaveStateRegister

2023-05-05 Thread Abdul Lateef Attar via groups.io
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4182

Removes SmmCpuFeaturesReadSaveStateRegister and 
SmmCpuFeaturesWirteSaveStateRegister
function from SmmCpuFeaturesLib library.

MmSaveStateLib library replaces the functionality of the above
functions.
Platform old/new need to use MmSaveStateLib library to read/write save
state registers.
Current implementation supports Intel and AMD.

Cc: Paul Grimes 
Cc: Abner Chang 
Cc: Eric Dong 
Cc: Ray Ni 
Cc: Rahul Kumar 
Cc: Gerd Hoffmann 
Cc: Ard Biesheuvel 
Cc: Jiewen Yao 
Cc: Jordan Justen 
Signed-off-by: Abdul Lateef Attar 
Reviewed-by: Abner Chang 
---
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf  |   2 +
 .../Include/Library/SmmCpuFeaturesLib.h   |  52 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h|  56 +-
 .../SmmCpuFeaturesLib/AmdSmmCpuFeaturesLib.c  |  58 --
 .../IntelSmmCpuFeaturesLib.c  |  58 --
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c|  11 +-
 UefiCpuPkg/PiSmmCpuDxeSmm/SmramSaveState.c| 500 +-
 7 files changed, 9 insertions(+), 728 deletions(-)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
index 158e05e2646c..bd83b4afab26 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
@@ -6,6 +6,7 @@
 #
 # Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
 # Copyright (c) 2017, AMD Incorporated. All rights reserved.
+# Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -97,6 +98,7 @@ [LibraryClasses]
   ReportStatusCodeLib
   SmmCpuFeaturesLib
   PeCoffGetEntryPointLib
+  MmSaveStateLib
 
 [Protocols]
   gEfiSmmAccess2ProtocolGuid   ## CONSUMES
diff --git a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h 
b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
index 52160c7145ba..733f0d03ebaa 100644
--- a/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
+++ b/UefiCpuPkg/Include/Library/SmmCpuFeaturesLib.h
@@ -324,58 +324,6 @@ SmmCpuFeaturesSetSmmRegister (
   IN UINT64Value
   );
 
-/**
-  Read an SMM Save State register on the target processor.  If this function
-  returns EFI_UNSUPPORTED, then the caller is responsible for reading the
-  SMM Save Sate register.
-
-  @param[in]  CpuIndex  The index of the CPU to read the SMM Save State.  The
-value must be between 0 and the NumberOfCpus field in
-the System Management System Table (SMST).
-  @param[in]  Register  The SMM Save State register to read.
-  @param[in]  Width The number of bytes to read from the CPU save state.
-  @param[out] BufferUpon return, this holds the CPU register value read
-from the save state.
-
-  @retval EFI_SUCCESS   The register was read from Save State.
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
-  @retval EFI_UNSUPPORTED   This function does not support reading 
Register.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesReadSaveStateRegister (
-  IN  UINTNCpuIndex,
-  IN  EFI_SMM_SAVE_STATE_REGISTER  Register,
-  IN  UINTNWidth,
-  OUT VOID *Buffer
-  );
-
-/**
-  Writes an SMM Save State register on the target processor.  If this function
-  returns EFI_UNSUPPORTED, then the caller is responsible for writing the
-  SMM Save Sate register.
-
-  @param[in] CpuIndex  The index of the CPU to write the SMM Save State.  The
-   value must be between 0 and the NumberOfCpus field in
-   the System Management System Table (SMST).
-  @param[in] Register  The SMM Save State register to write.
-  @param[in] Width The number of bytes to write to the CPU save state.
-  @param[in] BufferUpon entry, this holds the new CPU register value.
-
-  @retval EFI_SUCCESS   The register was written to Save State.
-  @retval EFI_INVALID_PARAMETER  Buffer is NULL.
-  @retval EFI_UNSUPPORTED   This function does not support writing 
Register.
-**/
-EFI_STATUS
-EFIAPI
-SmmCpuFeaturesWriteSaveStateRegister (
-  IN UINTNCpuIndex,
-  IN EFI_SMM_SAVE_STATE_REGISTER  Register,
-  IN UINTNWidth,
-  IN CONST VOID   *Buffer
-  );
-
 /**
   This function is hook point called after the gEfiSmmReadyToLockProtocolGuid
   notification is completely processed.
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h 
b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index a5c2bdd971ca..106808b08e17 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -3,6 +3,7 @@ Agent Module to load other modules to deploy SMM Entry Vector 
for X86 CPU.
 
 Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
 Copyright (c) 2017, AMD Incorporated. All rights reserved.
+Copyright (C) 2023 Advanced Micro Devices, Inc. All rights r

Re: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to ADDDEBUGFLAG in tools_def.txt

2023-05-05 Thread Michael D Kinney
The issue I saw was a mix of / and \ in the file path.  On Windows $(DEBUG_DIR) 
would
Have '\' in path and then a '/' before $(MODULE_NAME).  Without the quotes, this
would generate an error.  With quotes, it would get the full filename correct.

On Linux, only '/' are used for the whole path and everything works with and
Without quotes.

Mike

> -Original Message-
> From: gaoliming 
> Sent: Friday, May 5, 2023 8:01 PM
> To: devel@edk2.groups.io; Kinney, Michael D 
> Cc: 'Rebecca Cran' ; Feng, Bob C
> ; Chen, Christine 
> Subject: 回复: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> ADDDEBUGFLAG in tools_def.txt
> 
> Mike:
>   Do you mean $(DEBUG_DIR)/$(MODULE_NAME).debug file path may have
> space on
> windows OS? Does the workspace directory include the space?
> 
> Thanks
> Liming
> > -邮件原件-
> > 发件人: devel@edk2.groups.io  代表 Michael D
> > Kinney
> > 发送时间: 2023年5月6日 10:47
> > 收件人: devel@edk2.groups.io
> > 抄送: Rebecca Cran ; Liming Gao
> > ; Bob Feng ; Yuwei
> Chen
> > 
> > 主题: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> > ADDDEBUGFLAG in tools_def.txt
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4448
> >
> > Update tools_def.txt to add quotes around the file target in
> > OBJCOPY_ADDDEBUGFLAGS for compatibility with GCC like tool
> > chains used on Windows.
> >
> > Cc: Rebecca Cran 
> > Cc: Liming Gao 
> > Cc: Bob Feng 
> > Cc: Yuwei Chen 
> > Signed-off-by: Michael D Kinney 
> > ---
> >  BaseTools/Conf/tools_def.template | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/BaseTools/Conf/tools_def.template
> > b/BaseTools/Conf/tools_def.template
> > index 1b3a9e7a540a..535dda1d5d99 100755
> > --- a/BaseTools/Conf/tools_def.template
> > +++ b/BaseTools/Conf/tools_def.template
> > @@ -731,9 +731,9 @@ NOOPT_VS2019_AARCH64_DLINK_FLAGS   =
> > /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
> >  *_*_*_OBJCOPY_FLAGS = objcopy not needed for
> >  *_*_*_SYMRENAME_PATH= echo
> >  *_*_*_SYMRENAME_FLAGS   = Symbol renaming not needed for
> > -DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> > --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> > +DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> > --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
> >  RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
> > -NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> > --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> > +NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> > --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
> >  *_*_*_OBJCOPY_STRIPFLAG= --strip-unneeded -R .eh_frame
> >  *_*_*_DTC_FLAGS= -H epapr
> >  *_*_*_DTCPP_PATH   = DEF(DTCPP_BIN)
> > --
> > 2.40.1.windows.1
> >
> >
> >
> > 
> >
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104181): https://edk2.groups.io/g/devel/message/104181
Mute This Topic: https://groups.io/mt/98720453/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 1/1] BaseTools/Conf: Add quotes to ADDDEBUGFLAG in tools_def.txt

2023-05-05 Thread gaoliming via groups.io
Mike:
  I also see GCC_DLINK2_FLAGS_COMMON option uses / as the file path. Does it 
bring the same problem in Windows OS?

DEFINE GCC_DLINK2_FLAGS_COMMON = 
-Wl,--script=$(EDK_TOOLS_PATH)/Scripts/GccBase.lds 

Thanks
Liming
> -邮件原件-
> 发件人: Kinney, Michael D 
> 发送时间: 2023年5月6日 12:55
> 收件人: Gao, Liming ; devel@edk2.groups.io
> 抄送: 'Rebecca Cran' ; Feng, Bob C
> ; Chen, Christine ; Kinney,
> Michael D 
> 主题: RE: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> ADDDEBUGFLAG in tools_def.txt
> 
> The issue I saw was a mix of / and \ in the file path.  On Windows
> $(DEBUG_DIR) would
> Have '\' in path and then a '/' before $(MODULE_NAME).  Without the
> quotes, this
> would generate an error.  With quotes, it would get the full filename correct.
> 
> On Linux, only '/' are used for the whole path and everything works with and
> Without quotes.
> 
> Mike
> 
> > -Original Message-
> > From: gaoliming 
> > Sent: Friday, May 5, 2023 8:01 PM
> > To: devel@edk2.groups.io; Kinney, Michael D
> 
> > Cc: 'Rebecca Cran' ; Feng, Bob C
> > ; Chen, Christine 
> > Subject: 回复: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> > ADDDEBUGFLAG in tools_def.txt
> >
> > Mike:
> >   Do you mean $(DEBUG_DIR)/$(MODULE_NAME).debug file path may
> have
> > space on
> > windows OS? Does the workspace directory include the space?
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Michael
> D
> > > Kinney
> > > 发送时间: 2023年5月6日 10:47
> > > 收件人: devel@edk2.groups.io
> > > 抄送: Rebecca Cran ; Liming Gao
> > > ; Bob Feng ; Yuwei
> > Chen
> > > 
> > > 主题: [edk2-devel] [Patch 1/1] BaseTools/Conf: Add quotes to
> > > ADDDEBUGFLAG in tools_def.txt
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4448
> > >
> > > Update tools_def.txt to add quotes around the file target in
> > > OBJCOPY_ADDDEBUGFLAGS for compatibility with GCC like tool
> > > chains used on Windows.
> > >
> > > Cc: Rebecca Cran 
> > > Cc: Liming Gao 
> > > Cc: Bob Feng 
> > > Cc: Yuwei Chen 
> > > Signed-off-by: Michael D Kinney 
> > > ---
> > >  BaseTools/Conf/tools_def.template | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/BaseTools/Conf/tools_def.template
> > > b/BaseTools/Conf/tools_def.template
> > > index 1b3a9e7a540a..535dda1d5d99 100755
> > > --- a/BaseTools/Conf/tools_def.template
> > > +++ b/BaseTools/Conf/tools_def.template
> > > @@ -731,9 +731,9 @@ NOOPT_VS2019_AARCH64_DLINK_FLAGS   =
> > > /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF
> > >  *_*_*_OBJCOPY_FLAGS = objcopy not needed for
> > >  *_*_*_SYMRENAME_PATH= echo
> > >  *_*_*_SYMRENAME_FLAGS   = Symbol renaming not
> needed for
> > > -DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> > > --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> > > +DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG =
> > > --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
> > >  RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
> > > -NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> > > --add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
> > > +NOOPT_*_*_OBJCOPY_ADDDEBUGFLAG =
> > > --add-gnu-debuglink="$(DEBUG_DIR)/$(MODULE_NAME).debug"
> > >  *_*_*_OBJCOPY_STRIPFLAG= --strip-unneeded
> -R .eh_frame
> > >  *_*_*_DTC_FLAGS= -H epapr
> > >  *_*_*_DTCPP_PATH   = DEF(DTCPP_BIN)
> > > --
> > > 2.40.1.windows.1
> > >
> > >
> > >
> > > 
> > >
> >
> >





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104182): https://edk2.groups.io/g/devel/message/104182
Mute This Topic: https://groups.io/mt/98720784/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] ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.

2023-05-05 Thread gaoliming via groups.io
Giri:
  I create PR https://github.com/tianocore/edk2/pull/4350 to merge this
patch. But, Open CI reports the below issue. Please help fix them. 

ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 9004
ERROR - *For comment line with '///< ... text ...' format, if it is used, it
should be after the code section
ERROR - *file:
//__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
andsLib/SmbiosView/PrintInfo.c
ERROR - *Line number: 139
ERROR - *
ERROR - 
ERROR - EFI coding style error
ERROR - *Error code: 9004
ERROR - *For comment line with '///< ... text ...' format, if it is used, it
should be after the code section
ERROR - *file:
//__w/1/s/Build/.pytool/Plugin/EccCheck/ShellPkg/Library/UefiShellDebug1Comm
andsLib/SmbiosView/PrintInfo.c
ERROR - *Line number: 224
ERROR - *

Thanks
Liming
> -邮件原件-
> 发件人: devel@edk2.groups.io  代表 gaoliming via
> groups.io
> 发送时间: 2023年5月4日 15:57
> 收件人: 'Giri Mudusuru' ; devel@edk2.groups.io
> 抄送: 'Michael D Kinney' ; 'Zhiguang Liu'
> ; 'Andrew Fish' 
> 主题: [edk2-devel] 回复: [PATCH 2/2]
> ShellPkg/UefiShellDebug1CommandsLib: Replace hardcoded SMBIOS strings.
> 
> Reviewed-by: Liming Gao 
> 
> > -邮件原件-
> > 发件人: Giri Mudusuru 
> > 发送时间: 2023年4月29日 2:53
> > 收件人: devel@edk2.groups.io
> > 抄送: Giri Mudusuru ; Michael D Kinney
> > ; Liming Gao ;
> > Zhiguang Liu ; Andrew Fish 
> > 主题: [PATCH 2/2] ShellPkg/UefiShellDebug1CommandsLib: Replace
> > hardcoded SMBIOS strings.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3805
> >
> > Replace hardcoded SMBIOS Anchor string and size with defines.
> >
> > Fix buffer overflow as described below.
> >
> > Smbios64BitPrintEPSInfo () is coded like:
> > UINT8  Anchor[5];
> >
> > MemToString (Anchor, SmbiosTable->AnchorString, 5);
> >
> > But the definition of MemToString()
> >   Copy Length of Src buffer to Dest buffer,
> >   add a NULL termination to Dest buffer.
> >
> > So Anchor needs to be +1 the size of the SMBIOS Anchor string `_SM3_`.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Cc: Zhiguang Liu 
> > Cc: Andrew Fish 
> > Signed-off-by: Giri Mudusuru 
> > ---
> >  .../UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c| 9
> +
> >  .../UefiShellDebug1CommandsLib/SmbiosView/SmbiosView.c   | 9
> > +
> >  2 files changed, 10 insertions(+), 8 deletions(-)
> >
> > diff --git
> > a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > index 1811cf0c44..dd190b006f 100644
> > ---
> a/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > +++
> > b/ShellPkg/Library/UefiShellDebug1CommandsLib/SmbiosView/PrintInfo.c
> > @@ -5,6 +5,7 @@
> >Copyright (c) 1985 - 2022, American Megatrends International LLC.
> >
> >(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
> >
> >(C) Copyright 2015-2019 Hewlett Packard Enterprise Development
> > LP
> >
> > +  Copyright (c) 2023 Apple Inc. All rights reserved.
> >
> >SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >
> >
> >  **/
> >
> > @@ -135,7 +136,7 @@ SmbiosPrintEPSInfo (
> >IN  UINT8 Option
> >
> >)
> >
> >  {
> >
> > -  UINT8  Anchor[5];
> >
> > +  UINT8  Anchor[SMBIOS_ANCHOR_STRING_LENGTH + 1]; ///<
> Including
> > terminating NULL character
> >
> >UINT8  InAnchor[6];
> >
> >
> >
> >if (SmbiosTable == NULL) {
> >
> > @@ -149,7 +150,7 @@ SmbiosPrintEPSInfo (
> >
> >
> >if (Option >= SHOW_NORMAL) {
> >
> >  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ENTRY_POINT_SIGN),
> > gShellDebug1HiiHandle);
> >
> > -MemToString (Anchor, SmbiosTable->AnchorString, 4);
> >
> > +MemToString (Anchor, SmbiosTable->AnchorString,
> > SMBIOS_ANCHOR_STRING_LENGTH);
> >
> >  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> > Anchor);
> >
> >  ShellPrintHiiEx (
> >
> >-1,
> >
> > @@ -220,7 +221,7 @@ Smbios64BitPrintEPSInfo (
> >IN  UINT8 Option
> >
> >)
> >
> >  {
> >
> > -  UINT8  Anchor[5];
> >
> > +  UINT8  Anchor[SMBIOS_3_0_ANCHOR_STRING_LENGTH + 1]; ///<
> > Including terminating NULL character
> >
> >
> >
> >if (SmbiosTable == NULL) {
> >
> >  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_SMBIOSTABLE_NULL),
> > gShellDebug1HiiHandle);
> >
> > @@ -234,7 +235,7 @@ Smbios64BitPrintEPSInfo (
> >if (Option >= SHOW_NORMAL) {
> >
> >  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_64_BIT_ENTRY_POINT_SIGN),
> > gShellDebug1HiiHandle);
> >
> >
> >
> > -MemToString (Anchor, SmbiosTable->AnchorString, 5);
> >
> > +MemToString (Anchor, SmbiosTable->AnchorString,
> > SMBIOS_3_0_ANCHOR_STRING_LENGTH);
> >
> >  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> > (STR_SMBIOSVIEW_PRINTINFO_ANCHOR_STR), gShellDebug1HiiHandle,
> > Anchor);
> >
> >
> >
> >