Re: [edk2-devel] [PATCH 0/4] Put APs in 64 bit long-mode before booting to OS.

2022-12-19 Thread Ni, Ray
Reviewed-by: Ray Ni 

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yuanhao Xie
> Sent: Tuesday, December 20, 2022 5:40 AM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH 0/4] Put APs in 64 bit long-mode before booting 
> to OS.
> 
> 
> Yuanhao Xie (4):
>   UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
>   UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.
>   OvmfPkg: Add CpuPageTableLib required by MpInitLib.
>   UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.
> 
>  OvmfPkg/AmdSev/AmdSevX64.dsc  |   3 +-
>  OvmfPkg/CloudHv/CloudHvX64.dsc|   1 +
>  OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   4 +-
>  OvmfPkg/Microvm/MicrovmX64.dsc|   3 +-
>  OvmfPkg/OvmfPkgIa32X64.dsc|   1 +
>  OvmfPkg/OvmfPkgX64.dsc|   2 +
>  OvmfPkg/OvmfXen.dsc   |   3 +-
>  UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf |   7 +-
>  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   | 129 ++---
>  .../Library/MpInitLib/Ia32/CreatePageTable.c  |  27 +++
>  UefiCpuPkg/Library/MpInitLib/MpEqu.inc|   2 +
>  UefiCpuPkg/Library/MpInitLib/MpLib.h  |  46 -
>  UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm  | 169 +
>  .../Library/MpInitLib/X64/CreatePageTable.c   |  75 
>  UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 176 --
>  UefiCpuPkg/UefiCpuPkg.dsc |   1 +
>  UefiPayloadPkg/UefiPayloadPkg.dsc |   1 +
>  17 files changed, 430 insertions(+), 220 deletions(-)
>  create mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c
>  create mode 100644 UefiCpuPkg/Library/MpInitLib/X64/CreatePageTable.c
> 
> --
> 2.36.1.windows.1
> 
> 
> 
> 
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97617): https://edk2.groups.io/g/devel/message/97617
Mute This Topic: https://groups.io/mt/95754112/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] OvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei

2022-12-19 Thread Gerd Hoffmann
On Mon, Dec 19, 2022 at 04:36:20PM +, Anthony PERARD via groups.io wrote:
> From: Anthony PERARD 
> 
> Copy the function BuildPlatformInfoHob() from OvmfPkg/PlatformPei.
> 
> QemuFwCfgLib expect this HOB to be present, or fails to do anything.
> InternalQemuFwCfgIsAvailable() from QemuFwCfgPeiLib module will not
> check if the HOB is actually present for example and try to use a NULL
> pointer.
> 
> Fixes: cda98df16228 ("OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + 
> mQemuFwCfgDmaSupported")
> Signed-off-by: Anthony PERARD 

Reviewed-by: Gerd Hoffmann 

You might also consider moving global variables to the PlatformInfoHob
or use PlatformInitLib functions instead of your own copy or both.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97616): https://edk2.groups.io/g/devel/message/97616
Mute This Topic: https://groups.io/mt/95768201/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] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning

2022-12-19 Thread Gerd Hoffmann
  Hi,

> > Well, the OS can write directly to flash, bypassing the firmware.  It
> > can update secure boot efi variables without the firmware enforcing the
> > usual restrictions (KEK signature being required for db/dbx updates
> > etc).
> 
> [Jiewen] I would say: It is the typical use case. But not the only use case.
> Typically, the BIOS shall configure the flash to prevent OS directly to 
> flash, with SMM in this case. I do not disagree.
> That feature fully really on the hardware (on a real platform) or VMM (on a 
> virtual platform).
> 
> However, in confidential computing use case, the flash is controlled by the 
> untrusted entity - VMM.
> It is *impossible* to lock down the flash, even with SMM enabled. That is 
> because the VMM is also emulating SMM.
> To rely on an untrusted entity (VMM) to provide security protection (e.g. 
> SMM) is meaningless.

In the confidential computing use case there is no flash in the first
place.  At least for the cases where the processor not the VMM manages
guest memory (i.e SEV-SNP and TDX) the qemu patches I've seen so far
handle it that way.

That configuration goes into the (3a) bucket.  No flash (and no other
place to store any state which survives reboot -> stateless).  Guest
starts with a fixed varstore coming from the firmware rom.

> The best way we can do is to enable measured boot together with secure
> boot.

measured boot can be used to attest the VM actually runs the
configuration it is supposed to run.  That is independent from secure
boot, even though it is possible to combine the two and in that case
also measure secure boot configuration.

Works in both confidential and non-confidential VMs.

> In summary, Secure boot in CC cannot resist the policy override,
> but Measured boot in CC will detect such override, and mitigate such threat.
> That is fine, because it is meaningless to enable CC without measured boot.

If you don't want trust the VMM, then yes, measured boot is required to
make sure the VMM actually started the VM the way it is supposed to be
started.

For attacks against the guest OS there isn't that much of a difference
between CC and non-CC guests.  I think in both cases the (hacked) guest
OS can't change the secure boot configuration.  Even in case the guest
OS manages to modify the varstore the firmware will never use the
modification.  For non-confidential guests the firmware will initialize
the varstore with the pristine copy from firmware rom on reset.  For CC
guests there is no reset in the first place (reset requires the VMM
changing guest state), you can only kill and restart the VM, which will
likewise start with pristine varstore state.

> > I don't see how "secure boot without SMM" is easier to understand than
> > "stateless".
> 
> [Jiewen] "stateless" is a new term introduced in this patch. Not in UEFI 
> spec, nor in EDKII.
> If you want to use it, please define it clearly. At least, I don't understand.

"stateless" == no persistent variable store, i.e. no flash.

> >  It also is x64-specific.
> 
> [Jiewen] I don't understand why it is x64-specific.

SMM is x86-specific, that's why I don't like the term "secure boot
without SMM".

> > > 4) What is the purpose of "Log a warning" ?
> > > Is that to tell people, DON'T DO IT?
> > 
> > Yes.
> 
> [Jiewen] Disagree. It can work together with measured boot in CC use case.
> If you really really want to add something, you should also check if CC is 
> enabled.

See above.  CC runs without flash anyway so no warning in that case.

> > In 2022-08 and older the world is relatively simple.  We have
> > three possible build configurations
> > 
> >   (1) SECURE_BOOT_ENABLE=FALSE SMM_REQUIRE=FALSE
> >   Build without secure boot support.
> > 
> >   (2) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=TRUE
> >   Build with secure boot support, secure.
> > 
> >   (3) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=FALSE
> >   Build with secure boot support, not secure.
> > 
> > Linux Distributions typically provide builds for (1) and (2),
> > so (3) existing isn't much of a problem in practice because
> > people typically don't compile edk2 by themself.
> 
> [Jiewen] Above description is based upon assumption that SMM is trusted.

Yes.

> It is TRUE in non-CC use case.  However, the assumption is wrong in CC
> use case, because VMM is untrusted and SMM might colluder.  The VMM
> may fake the flash lock in SMM, and allow OS to bypass the flash
> protection.  Following your logic, I would say: even with SMM, it is
> still not secure.

Not sure what you are trying to tell me.  In CC mode SMM is not
supported in the first place, so your argument doesn't make sense to me.

> > In 2022-11 the (3) case is splitted into two:
> > 
> >   (3a) build being used with ROM (or r/o flash):
> >-> this is the new "stateless secure boot" mode.
> >   (3b) build being used with writable flash:
> >-> insecure configuration.
> 
> [Jiewen] If you want to use term "stateless", please define it.

"stateless" 

Re: [edk2-devel] [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore in some cases

2022-12-19 Thread joeyli via groups.io
Hi Jiewen,

Sorry for I didn't create tiano CI on github in time. And thanks for your
help to merge my patch. 

I will create tiano CI in next time after getting our Review-by tag.

Thanks!
Joey Lee

On Sat, Dec 17, 2022 at 03:17:42AM +, Yao, Jiewen via groups.io wrote:
> Thanks for the fix.
> Reviewed-by: Jiewen Yao 
> 
> Question: Have you run tiano CI by yourself, before submit the patch?
> 
> 
> 
> > -Original Message-
> > From: Lee, Chun-Yi 
> > Sent: Thursday, December 15, 2022 10:27 PM
> > To: devel@edk2.groups.io
> > Cc: Xu, Min M ; Gerd Hoffmann
> > ; Yao, Jiewen ; Tom Lendacky
> > ; James Bottomley ;
> > Aktas, Erdem ; Lee, Chun-Yi 
> > Subject: [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity checking failed 
> > of
> > NvVarStore in some cases
> > 
> > In the commit 4f173db8b4 "OvmfPkg/PlatformInitLib: Add functions for
> > EmuVariableNvStore", it introduced a PlatformValidateNvVarStore() function
> > for checking the integrity of NvVarStore.
> > 
> > In some cases when the VariableHeader->StartId is VARIABLE_DATA, the
> > VariableHeader->State is not just one of the four primary states:
> > VAR_IN_DELETED_TRANSITION, VAR_DELETED, VAR_HEADER_VALID_ONLY,
> > VAR_ADDED.
> > The state may combined two or three states, e.g.
> > 
> > 0x3C = (VAR_IN_DELETED_TRANSITION & VAR_ADDED) & VAR_DELETED
> > or
> > 0x3D = VAR_ADDED & VAR_DELETED
> > 
> > When the variable store has those variables, system booting/rebooting will
> > hangs in a ASSERT:
> > 
> > NvVarStore Variable header State was invalid.
> > ASSERT
> > /mnt/working/source_code-
> > git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819):
> > ((BOOLEAN)(0==1))
> > 
> > Adding more log to UpdateVariable() and PlatformValidateNvVarStore(), we
> > saw some variables which have 0x3C or 0x3D state in store.
> > e.g.
> > 
> > UpdateVariable(), VariableName=BootOrder
> > L1871, State=003F   <-- VAR_ADDED
> > State &= VAR_DELETED=003D
> > FlushHobVariableToFlash(), VariableName=BootOrder
> > ...
> > UpdateVariable(), VariableName=InitialAttemptOrder
> > L1977, State=003F
> > State &= VAR_IN_DELETED_TRANSITION=003E
> > L2376, State=003E
> > State &= VAR_DELETED=003C
> > FlushHobVariableToFlash(), VariableName=InitialAttemptOrder
> > ...
> > UpdateVariable(), VariableName=ConIn
> > L1977, State=003F
> > State &= VAR_IN_DELETED_TRANSITION=003E
> > L2376, State=003E
> > State &= VAR_DELETED=003C
> > FlushHobVariableToFlash(), VariableName=ConIn
> > ...
> > 
> > So, only allowing the four primary states is not enough. This patch changes
> > the falid states list (Follow Jiewen Yao's suggestion):
> > 
> > 1. VAR_HEADER_VALID_ONLY (0x7F)
> > - Header added (*)
> > 2. VAR_ADDED (0x3F)
> > - Header + data added
> > 3. VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
> > - marked as deleted, but still valid, before new data is added. (*)
> > 4. VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
> > - deleted, after new data is added.
> > 5. VAR_ADDED & VAR_DELETED (0x3D)
> > - deleted directly, without new data.
> > (*) means to support surprise shutdown.
> > 
> > And removed (VAR_IN_DELETED_TRANSITION) and (VAR_DELETED) because
> > they are
> > invalid states.
> > 
> > v2:
> > Follow Jiewen Yao's suggestion to add the following valid states:
> > VAR_ADDED & VAR_DELETED (0x3D)
> > VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
> > VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED
> > (0x3C)
> > and removed the following invalid states:
> > VAR_IN_DELETED_TRANSITION
> > VAR_DELETED
> > 
> > Signed-off-by: "Lee, Chun-Yi" 
> > ---
> >  OvmfPkg/Library/PlatformInitLib/Platform.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c
> > b/OvmfPkg/Library/PlatformInitLib/Platform.c
> > index 77f22de046..6963c47e0b 100644
> > --- a/OvmfPkg/Library/PlatformInitLib/Platform.c
> > +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c
> > @@ -702,10 +702,11 @@ PlatformValidateNvVarStore (
> > 
> >VariableOffset = NvVarStoreHeader->Size - sizeof
> > (VARIABLE_STORE_HEADER);
> >  } else {
> > -  if (!((VariableHeader->State == VAR_IN_DELETED_TRANSITION) ||
> > -(VariableHeader->State == VAR_DELETED) ||
> > -(VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
> > -(VariableHeader->State == VAR_ADDED)))
> > +  if (!((VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
> > +   (VariableHeader->State == VAR_ADDED) ||
> > +   (VariableHeader->State == (VAR_ADDED & VAR_DELETED)) ||
> > +   (VariableHeader->State == (VAR_ADDED &
> > VAR_IN_DELETED_TRANSITION)) ||
> > +   (VariableHeader->State == (VAR_ADDED &
> > VAR_IN_DELETED_TRANSITION & VAR_DELETED
> >{
> >  DEBUG ((DEBUG_ERROR, "NvVarStore Variable header State was
> > invalid.\n"));
> >  return FALSE;
> > --
> > 2.35.3
> 
> 
> 
> 
> 

Re: [edk2-devel] [PATCH V3 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang

Regards,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Tuesday, December 20, 2022 2:42 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH V3 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

External email: Use caution opening links or attachments


From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..4361bd4170e 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatfor
+++ mHostInterfaceLib.c
@@ -3,6 +3,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (

   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID  **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
--
2.37.1.windows.1



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




Re: [edk2-devel] [PATCH V3 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang

Thanks,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Tuesday, December 20, 2022 2:41 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH V3 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI 
notification

External email: Use caution opening links or attachments


From: Abner Chang 

For some use cases, Redfish host interface table relies on the certain EFI 
protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the SMBIOS type 42h 
record at driver entry point. This patch adds the mechanism in Redfish host 
interface DXE driver to listen to EFI protocol installed by platform library 
that indicates the necessary information is ready for building SMBIOS 42h 
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 28 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 73 ++-
 3 files changed, 121 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..22a8f9283cb 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8   *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,25 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID  **InformationReadinessGuid
+  );
+
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..40642469c9a 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8   *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (  {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  

[edk2-devel] [PATCH V3 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..4361bd4170e 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID  **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
-- 
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97611): https://edk2.groups.io/g/devel/message/97611
Mute This Topic: https://groups.io/mt/95781613/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] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 28 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 73 ++-
 3 files changed, 121 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..22a8f9283cb 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.
 
-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8   *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );
 
@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.
 
   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,25 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );
 
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID  **InformationReadinessGuid
+  );
+
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..40642469c9a 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8   *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (
 {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS 

Re: [edk2-devel] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Nickle Wang via groups.io
Hi Abner,

I found another bug as below.

+  if (Status == EFI_UNSUPPORTED || EFI_ALREADY_STARTED) {
+Status = RedfishCreateSmbiosTable42 ();  

Second condition check miss "Status ==" and RedfishCreateSmbiosTable42() is 
always called in driver entry.

Thanks,
Nickle

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Nickle Wang via 
groups.io
Sent: Monday, December 19, 2022 11:11 PM
To: abner.ch...@amd.com; devel@edk2.groups.io
Cc: Igor Kulchytskyy 
Subject: Re: [edk2-devel] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: 
Platform Redfish HI notification

External email: Use caution opening links or attachments


Thanks for addressing my comment.

Reviewed-by: Nickle Wang

Regards,
Nickle

-Original Message-
From: abner.ch...@amd.com 
Sent: Monday, December 19, 2022 10:51 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI 
notification

External email: Use caution opening links or attachments


From: Abner Chang 

For some use cases, Redfish host interface table relies on the certain EFI 
protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the SMBIOS type 42h 
record at driver entry point. This patch adds the mechanism in Redfish host 
interface DXE driver to listen to EFI protocol installed by platform library 
that indicates the necessary information is ready for building SMBIOS 42h 
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 71 ++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 

Re: [edk2-devel] [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore in some cases

2022-12-19 Thread Yao, Jiewen
Merged https://github.com/tianocore/edk2/pull/3797 with minor format fix.

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yao,
> Jiewen
> Sent: Saturday, December 17, 2022 11:18 AM
> To: Lee, Chun-Yi ; devel@edk2.groups.io
> Cc: Xu, Min M ; Gerd Hoffmann
> ; Tom Lendacky ; James
> Bottomley ; Aktas, Erdem ;
> Lee, Chun-Yi 
> Subject: Re: [edk2-devel] [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity
> checking failed of NvVarStore in some cases
> 
> Thanks for the fix.
> Reviewed-by: Jiewen Yao 
> 
> Question: Have you run tiano CI by yourself, before submit the patch?
> 
> 
> 
> > -Original Message-
> > From: Lee, Chun-Yi 
> > Sent: Thursday, December 15, 2022 10:27 PM
> > To: devel@edk2.groups.io
> > Cc: Xu, Min M ; Gerd Hoffmann
> > ; Yao, Jiewen ; Tom
> Lendacky
> > ; James Bottomley ;
> > Aktas, Erdem ; Lee, Chun-Yi 
> > Subject: [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity checking failed 
> > of
> > NvVarStore in some cases
> >
> > In the commit 4f173db8b4 "OvmfPkg/PlatformInitLib: Add functions for
> > EmuVariableNvStore", it introduced a PlatformValidateNvVarStore()
> function
> > for checking the integrity of NvVarStore.
> >
> > In some cases when the VariableHeader->StartId is VARIABLE_DATA, the
> > VariableHeader->State is not just one of the four primary states:
> > VAR_IN_DELETED_TRANSITION, VAR_DELETED, VAR_HEADER_VALID_ONLY,
> > VAR_ADDED.
> > The state may combined two or three states, e.g.
> >
> > 0x3C = (VAR_IN_DELETED_TRANSITION & VAR_ADDED) & VAR_DELETED
> > or
> > 0x3D = VAR_ADDED & VAR_DELETED
> >
> > When the variable store has those variables, system booting/rebooting will
> > hangs in a ASSERT:
> >
> > NvVarStore Variable header State was invalid.
> > ASSERT
> > /mnt/working/source_code-
> > git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819):
> > ((BOOLEAN)(0==1))
> >
> > Adding more log to UpdateVariable() and PlatformValidateNvVarStore(),
> we
> > saw some variables which have 0x3C or 0x3D state in store.
> > e.g.
> >
> > UpdateVariable(), VariableName=BootOrder
> > L1871, State=003F   <-- VAR_ADDED
> > State &= VAR_DELETED=003D
> > FlushHobVariableToFlash(), VariableName=BootOrder
> > ...
> > UpdateVariable(), VariableName=InitialAttemptOrder
> > L1977, State=003F
> > State &= VAR_IN_DELETED_TRANSITION=003E
> > L2376, State=003E
> > State &= VAR_DELETED=003C
> > FlushHobVariableToFlash(), VariableName=InitialAttemptOrder
> > ...
> > UpdateVariable(), VariableName=ConIn
> > L1977, State=003F
> > State &= VAR_IN_DELETED_TRANSITION=003E
> > L2376, State=003E
> > State &= VAR_DELETED=003C
> > FlushHobVariableToFlash(), VariableName=ConIn
> > ...
> >
> > So, only allowing the four primary states is not enough. This patch changes
> > the falid states list (Follow Jiewen Yao's suggestion):
> >
> > 1. VAR_HEADER_VALID_ONLY (0x7F)
> > - Header added (*)
> > 2. VAR_ADDED (0x3F)
> > - Header + data added
> > 3. VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
> > - marked as deleted, but still valid, before new data is added. (*)
> > 4. VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
> > - deleted, after new data is added.
> > 5. VAR_ADDED & VAR_DELETED (0x3D)
> > - deleted directly, without new data.
> > (*) means to support surprise shutdown.
> >
> > And removed (VAR_IN_DELETED_TRANSITION) and (VAR_DELETED)
> because
> > they are
> > invalid states.
> >
> > v2:
> > Follow Jiewen Yao's suggestion to add the following valid states:
> > VAR_ADDED & VAR_DELETED (0x3D)
> > VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
> > VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED
> > (0x3C)
> > and removed the following invalid states:
> > VAR_IN_DELETED_TRANSITION
> > VAR_DELETED
> >
> > Signed-off-by: "Lee, Chun-Yi" 
> > ---
> >  OvmfPkg/Library/PlatformInitLib/Platform.c | 9 +
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c
> > b/OvmfPkg/Library/PlatformInitLib/Platform.c
> > index 77f22de046..6963c47e0b 100644
> > --- a/OvmfPkg/Library/PlatformInitLib/Platform.c
> > +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c
> > @@ -702,10 +702,11 @@ PlatformValidateNvVarStore (
> >
> >VariableOffset = NvVarStoreHeader->Size - sizeof
> > (VARIABLE_STORE_HEADER);
> >  } else {
> > -  if (!((VariableHeader->State == VAR_IN_DELETED_TRANSITION) ||
> > -(VariableHeader->State == VAR_DELETED) ||
> > -(VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
> > -(VariableHeader->State == VAR_ADDED)))
> > +  if (!((VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
> > +   (VariableHeader->State == VAR_ADDED) ||
> > +   (VariableHeader->State == (VAR_ADDED & VAR_DELETED)) ||
> > +   (VariableHeader->State == (VAR_ADDED &
> > VAR_IN_DELETED_TRANSITION)) ||
> > +   (VariableHeader->State == (VAR_ADDED &
> > 

Re: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the DynamicEX PCDs

2022-12-19 Thread Guo, Gua
@jdzh...@kunluntech.com.cn

It’s checked in by below PR.
UefiPayloadPkg: Define default values for the DynamicEX PCDs by gguo11837463 · 
Pull Request #3798 · tianocore/edk2 
(github.com)

Thanks,
Gua
From: Guo, Gua
Sent: Tuesday, December 20, 2022 9:25 AM
To: devel@edk2.groups.io; jdzh...@kunluntech.com.cn; Lu, James 

Subject: RE: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the 
DynamicEX PCDs

@Lu, James

Could you help us to add push label on it ?
UefiPayloadPkg: Define default values for the DynamicEX PCDs by jiadingzhang · 
Pull Request #3792 · tianocore/edk2 
(github.com)

The change purpose is for resolving ECC issue.

@jdzh...@kunluntech.com.cn
Thanks for the change.

Thanks,
Gua

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Jiading Zhang
Sent: Monday, December 19, 2022 8:56 PM
To: Guo; Guo, Gua mailto:gua@intel.com>>; 
devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the 
DynamicEX PCDs

Hi.
  I commit a PR again, and the PR passed all the test.

https://github.com/tianocore/edk2/pull/3792/commits

Thanks!



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97607): https://edk2.groups.io/g/devel/message/97607
Mute This Topic: https://groups.io/mt/94949814/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 01/14] PrmPkg: Fix new typos reported

2022-12-19 Thread Ankit Sinha
Hi Michael,

There is a typo that got missed in one of the modified comments. In file 
"b/PrmPkg/Include/Library/PrmModuleDiscoveryLib.h":

-  Each PRM Module discovered is placed into a linked list so the list can br 
processsed in the future.
+  Each PRM Module discovered is placed into a linked list so the list can br 
processed in the future.

'br' should change to 'be'

Thank you,
Ankit

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael
> Kubacki
> Sent: Wednesday, December 14, 2022 2:53 PM
> To: devel@edk2.groups.io
> Cc: Michael Kubacki ; Desimone, Nathaniel
> L ; Sinha, Ankit 
> Subject: [edk2-devel] [PATCH v3 01/14] PrmPkg: Fix new typos reported
> 
> From: Michael Kubacki 
> 
> The SpellCheck plugin began reporting new typos that were previously
> missed. This change fixes those typos.
> 
> Cc: Michael Kubacki 
> Cc: Nate DeSimone 
> Cc: Ankit Sinha 
> Signed-off-by: Michael Kubacki 
> ---
>  PrmPkg/Application/PrmInfo/PrmInfo.c
> | 2 +-
>  PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.c
> | 2 +-
>  PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
> | 2 +-
> 
> UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestU
> efiBootServicesTableLibImage.c| 2 +-
> 
> UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestU
> efiBootServicesTableLibProtocol.c | 2 +-
>  PrmPkg/Include/Library/PrmModuleDiscoveryLib.h
> | 2 +-
>  PrmPkg/PrmLoaderDxe/PrmAcpiTable.h
> | 4 ++--
>  PrmPkg/PrmPkg.ci.yaml
> | 9
> +
> 
> UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestU
> efiBootServicesTableLib.h | 4 ++--
>  9 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/PrmPkg/Application/PrmInfo/PrmInfo.c
> b/PrmPkg/Application/PrmInfo/PrmInfo.c
> index 0cde2fad3b4b..178d4810f498 100644
> --- a/PrmPkg/Application/PrmInfo/PrmInfo.c
> +++ b/PrmPkg/Application/PrmInfo/PrmInfo.c
> @@ -148,7 +148,7 @@ PrintMmioRuntimeRangeInfo (
>Gathers the PRM handler (and by extension module) information
> discovered on this system.
> 
>This function must be called to build up the discovered context for other
> functions in the application. The
> -  function will optionally print results as determed by the value of the
> PrintInformation parameter.
> +  function will optionally print results as determined by the value of the
> PrintInformation parameter.
> 
>@param[in] PrintInformation   Indicates whether to print 
> information
> as discovered in the function.
> 
> diff --git
> a/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.
> c
> b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.
> c
> index e6bea47bc583..34373effd4cd 100644
> ---
> a/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.
> c
> +++
> b/PrmPkg/Library/DxePrmModuleDiscoveryLib/DxePrmModuleDiscoveryLib.
> c
> @@ -149,7 +149,7 @@ IsAddressInMmram (
>  /**
>Discovers all PRM Modules loaded during boot.
> 
> -  Each PRM Module discovered is placed into a linked list so the list can br
> processsed in the future.
> +  Each PRM Module discovered is placed into a linked list so the list can br
> processed in the future.
> 
>@param[out]   ModuleCount   An optional pointer parameter 
> that, if
> provided, is set to the number
>of PRM modules discovered.
> diff --git a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
> b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
> index 5a223d783d80..7b0042f133ef 100644
> --- a/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
> +++ b/PrmPkg/PrmLoaderDxe/PrmLoaderDxe.c
> @@ -295,7 +295,7 @@ PublishPrmAcpiTable (
>time of this function invocation.
> 
>The main responsibilities of the PRM Loader are executed from this
> function which include 3 phases:
> -1.) Disover PRM Modules - Find all PRM modules loaded during DXE
> dispatch and insert a PRM Module
> +1.) Discover PRM Modules - Find all PRM modules loaded during DXE
> + dispatch and insert a PRM Module
>  Context entry into a linked list to be handed off to phase 2.
>  2.) Process PRM Modules - Build a GUID to PRM handler mapping for each
> module that is described in the
>  PRM ACPI table so the OS can resolve a PRM Handler GUID to the
> corresponding PRM Handler physical address.
> diff --git
> a/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTest
> UefiBootServicesTableLibImage.c
> b/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTest
> UefiBootServicesTableLibImage.c
> index 144cc33e25c0..7c1c4b854b65 100644
> ---
> a/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTest
> UefiBootServicesTableLibImage.c
> +++ b/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/Unit
> +++ TestUefiBootServicesTableLibImage.c
> @@ -130,7 +130,7 @@ UnitTestExit (
>@retval EFI_SUCCESS The image has 

Re: [edk2-devel] [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value

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

Ah ok, that would be good.

Thanks
Abner

> -Original Message-
> From: Wu, Hao A 
> Sent: Tuesday, December 20, 2022 11:03 AM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context
> value
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Thanks,
> 
> For this patch "MdeModulePkg/XhciPei: Unlinked XhciPei memory block",
> my take is that there will also be an updated version, right?
> If this is the case, could you help to send out a single 3-patch series for 
> them
> instead of sending 3 separated patches? Thanks in advance.
> 
> Best Regards,
> Hao Wu
> 
> > -Original Message-
> > From: Chang, Abner 
> > Sent: Tuesday, December 20, 2022 10:45 AM
> > To: Wu, Hao A ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Kirkendall, Garrett 
> > Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's
> > Context value
> >
> > [AMD Official Use Only - General]
> >
> > Hi Hao,
> > That is the uncrustify check error. I already fixed it at "[PATCH V3]
> > MdeModulePkg/Usb: Read a large number of blocks."
> >
> > Also, these three patches are passed the CI test.
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2Ftianocore%2Fedk2%2Fpull%2F3794=05%7C01%7CAbner.Ch
> ang%40a
> >
> md.com%7C187600a1cd0942afb7b708dae236cbf5%7C3dd8961fe4884e608e11
> a82d99
> >
> 4e183d%7C0%7C0%7C638071022231599779%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC
> >
> 4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%
> 7C%7C%
> >
> 7C=AqFmywwFq9wJmix13UNfBDdT84wtFK%2BH8THRa7iYcm4%3D
> eserved=0
> >
> > Thanks
> > Abner
> >
> > > -Original Message-
> > > From: Wu, Hao A 
> > > Sent: Monday, December 12, 2022 11:27 AM
> > > To: Chang, Abner ; devel@edk2.groups.io
> > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > > ; Kirkendall, Garrett 
> > > Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's
> > > Context value
> > >
> > > Caution: This message originated from an External Source. Use proper
> > > caution when opening attachments, clicking links, or responding.
> > >
> > >
> > > For the 3 patches:
> > > [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
> > [PATCH
> > > V2] MdeModulePkg/Usb: Read a large number of blocks [PATCH V3]
> > > MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value
> > >
> > > I found that they will cause CI failures:
> > >
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> > >
> >
> ub.com%2Ftianocore%2Fedk2%2Fpull%2F3749data=05%7C01%7Cabn
> > >
> >
> er.chang%40amd.com%7Cfe921dc0e08b4cdf30a208dadbf0cb8c%7C3dd8961
> > f
> > >
> > e4884e608e11a82d994e183d%7C0%7C0%7C638064124508360013%7CUnkno
> > w
> > >
> >
> n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> > >
> WwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=0iQKJ3X3IJv1CSqe
> > > mjTWyT1hlYvqGZsYPAdwXEi%2B%2FZ4%3Dreserved=0
> > > Could you help to update them and help to ensure they can pass the CI
> test?
> > > Thanks in advance.
> > >
> > > Best Regards,
> > > Hao Wu
> > >
> > > > -Original Message-
> > > > From: abner.ch...@amd.com 
> > > > Sent: Saturday, December 10, 2022 11:08 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: kuei-hung@amd.com; Wu, Hao A ; Ni,
> Ray
> > > > ; Garrett Kirkendall
> > > > ; Abner Chang
> 
> > > > Subject: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's
> > > > Context value
> > > >
> > > > From: Abner Chang 
> > > >
> > > > In V3: Add AMD copyright.
> > > > In V2: Remove the signed-off-by: Abner Chang.
> > > >
> > > > Initialize XHCI DCI slot's context entries value.
> > > >
> > > > Signed-off-by: Kuei-Hung Lin 
> > > > Cc: Hao A Wu 
> > > > Cc: Ray Ni 
> > > > Cc: Garrett Kirkendall 
> > > > Cc: Abner Chang 
> > > > ---
> > > >  MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 7 +++
> > > > MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 7 +++
> > > >  2 files changed, 14 insertions(+)
> > > >
> > > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > > index 13b0400e83d..f08722905f3 100644
> > > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > > @@ -4,6 +4,7 @@
> > > >
> > > >  Copyright (c) 2011 - 2020, Intel Corporation. All rights
> > > > reserved.  Copyright (c) Microsoft Corporation.
> > > > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > > > +reserved.
> > > >  SPDX-License-Identifier: BSD-2-Clause-Patent
> > > >
> > > >  **/
> > > > @@ -2807,6 +2808,9 @@ XhcInitializeEndpointContext (
> > > >MaxDci = 0;
> > > >
> > > >NumEp = IfDesc->NumEndpoints;
> > > > +  if (NumEp == 0) {
> > > > +MaxDci = 1;
> > > > +  }
> > > >
> > > >

Re: [edk2-devel] [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value

2022-12-19 Thread Wu, Hao A
Thanks,

For this patch "MdeModulePkg/XhciPei: Unlinked XhciPei memory block", my take 
is that there will also be an updated version, right?
If this is the case, could you help to send out a single 3-patch series for 
them instead of sending 3 separated patches? Thanks in advance.

Best Regards,
Hao Wu

> -Original Message-
> From: Chang, Abner 
> Sent: Tuesday, December 20, 2022 10:45 AM
> To: Wu, Hao A ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context
> value
> 
> [AMD Official Use Only - General]
> 
> Hi Hao,
> That is the uncrustify check error. I already fixed it at "[PATCH V3]
> MdeModulePkg/Usb: Read a large number of blocks."
> 
> Also, these three patches are passed the CI test.
> https://github.com/tianocore/edk2/pull/3794
> 
> Thanks
> Abner
> 
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Monday, December 12, 2022 11:27 AM
> > To: Chang, Abner ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Kirkendall, Garrett 
> > Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's
> > Context value
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > For the 3 patches:
> > [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block
> [PATCH
> > V2] MdeModulePkg/Usb: Read a large number of blocks [PATCH V3]
> > MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value
> >
> > I found that they will cause CI failures:
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> >
> ub.com%2Ftianocore%2Fedk2%2Fpull%2F3749data=05%7C01%7Cabn
> >
> er.chang%40amd.com%7Cfe921dc0e08b4cdf30a208dadbf0cb8c%7C3dd8961
> f
> >
> e4884e608e11a82d994e183d%7C0%7C0%7C638064124508360013%7CUnkno
> w
> >
> n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> > WwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=0iQKJ3X3IJv1CSqe
> > mjTWyT1hlYvqGZsYPAdwXEi%2B%2FZ4%3Dreserved=0
> > Could you help to update them and help to ensure they can pass the CI test?
> > Thanks in advance.
> >
> > Best Regards,
> > Hao Wu
> >
> > > -Original Message-
> > > From: abner.ch...@amd.com 
> > > Sent: Saturday, December 10, 2022 11:08 PM
> > > To: devel@edk2.groups.io
> > > Cc: kuei-hung@amd.com; Wu, Hao A ; Ni, Ray
> > > ; Garrett Kirkendall ;
> > > Abner Chang 
> > > Subject: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's
> > > Context value
> > >
> > > From: Abner Chang 
> > >
> > > In V3: Add AMD copyright.
> > > In V2: Remove the signed-off-by: Abner Chang.
> > >
> > > Initialize XHCI DCI slot's context entries value.
> > >
> > > Signed-off-by: Kuei-Hung Lin 
> > > Cc: Hao A Wu 
> > > Cc: Ray Ni 
> > > Cc: Garrett Kirkendall 
> > > Cc: Abner Chang 
> > > ---
> > >  MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 7 +++
> > > MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 7 +++
> > >  2 files changed, 14 insertions(+)
> > >
> > > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > index 13b0400e83d..f08722905f3 100644
> > > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > > @@ -4,6 +4,7 @@
> > >
> > >  Copyright (c) 2011 - 2020, Intel Corporation. All rights
> > > reserved.  Copyright (c) Microsoft Corporation.
> > > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > > +reserved.
> > >  SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > >  **/
> > > @@ -2807,6 +2808,9 @@ XhcInitializeEndpointContext (
> > >MaxDci = 0;
> > >
> > >NumEp = IfDesc->NumEndpoints;
> > > +  if (NumEp == 0) {
> > > +MaxDci = 1;
> > > +  }
> > >
> > >EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> > >for (EpIndex = 0; EpIndex < NumEp; EpIndex++) { @@ -3006,6
> > > +3010,9 @@ XhcInitializeEndpointContext64 (
> > >MaxDci = 0;
> > >
> > >NumEp = IfDesc->NumEndpoints;
> > > +  if (NumEp == 0) {
> > > +MaxDci = 1;
> > > +  }
> > >
> > >EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> > >for (EpIndex = 0; EpIndex < NumEp; EpIndex++) { diff --git
> > > a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > > b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > > index cc597a43717..8400c90f7ad 100644
> > > --- a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > > +++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > > @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid
> based
> > on
> > > gPeiUsbControllerPpiGuid  which is used to enable recovery function
> > > from USB Drivers.
> > >
> > >  Copyright (c) 2014 - 2017, Intel Corporation. All rights
> > > reserved.
> > > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > > +reserved.
> > >
> > >  SPDX-License-Identifier: BSD-2-Clause-Patent
> > >
> > > @@ -1752,6 +1753,9 @@ XhcPeiSetConfigCmd (
> > >  }
> > >
> > >  NumEp = 

Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto functions

2022-12-19 Thread Yao, Jiewen
Hi Mike
You are right. I missed that part.

Hi Judah
Would you please file another patch to update DSC file, to make it align with 
readme?

Thank you
Yao, Jiewen

> -Original Message-
> From: Kinney, Michael D 
> Sent: Tuesday, December 20, 2022 9:55 AM
> To: devel@edk2.groups.io; Yao, Jiewen ; Vang,
> Judah 
> Cc: Wang, Jian J ; Xiaoyu Lu ;
> Jiang, Guomin ; Mistry, Nishant C
> ; Kinney, Michael D
> 
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> functions
> 
> Hi Jiewen,
> 
> I noticed that this patch is missing the update to the table in ReadMe.md to
> show the new PEI and SMM crypto services enabled by default in *CryptLib
> library instances.
> 
> https://github.com/tianocore/edk2/tree/master/CryptoPkg#supported-
> cryptographic-families-and-services
> 
> It did update the recommended PCD settings at the end of the
> ReadMe, but missed the update to CryptoPkg.dsc file to actually
> enable the PEI and SMM services in the Crypto Drivers.
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Yao,
> Jiewen
> > Sent: Monday, December 19, 2022 5:40 PM
> > To: Vang, Judah ; devel@edk2.groups.io
> > Cc: Wang, Jian J ; Xiaoyu Lu
> ; Jiang, Guomin ;
> > Mistry, Nishant C 
> > Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> functions
> >
> > Just merged - https://github.com/tianocore/edk2/pull/3796
> >
> >
> > > -Original Message-
> > > From: Vang, Judah 
> > > Sent: Tuesday, December 20, 2022 8:44 AM
> > > To: devel@edk2.groups.io; Vang, Judah 
> > > Cc: Yao, Jiewen ; Wang, Jian J
> > > ; Xiaoyu Lu ; Jiang,
> Guomin
> > > ; Mistry, Nishant C
> 
> > > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable
> crypto
> > > functions
> > >
> > > Hi Jiewen,
> > >
> > > Has this patch been merged?
> > > This is an important change for the UEFI Protected Variable feature.
> > >
> > > Judah
> > >
> > > -Original Message-
> > > From: devel@edk2.groups.io  On Behalf Of
> Judah
> > > Vang
> > > Sent: Monday, November 7, 2022 2:16 PM
> > > To: devel@edk2.groups.io
> > > Cc: Yao, Jiewen ; Wang, Jian J
> > > ; Xiaoyu Lu ; Jiang,
> Guomin
> > > ; Mistry, Nishant C
> 
> > > Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> > > functions
> > >
> > > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3992
> > >
> > > V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
> > > Update Readme.md
> > >
> > > Cc: Jiewen Yao 
> > > Cc: Jian J Wang 
> > > Cc: Xiaoyu Lu 
> > > Cc: Guomin Jiang 
> > > Cc: Nishant C Mistry 
> > > Signed-off-by: Jian J Wang 
> > > Signed-off-by: Nishant C Mistry 
> > > Signed-off-by: Judah Vang 
> > > ---
> > >  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |  2 +-
> > > CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |  2 +-
> > >  CryptoPkg/Readme.md| 27 +++-
> > >  3 files changed, 17 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > > b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > > index b1629647f9c6..ee5f3cd5d4b6 100644
> > > --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > > +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > > @@ -43,7 +43,7 @@ [Sources]
> > >Hash/CryptParallelHashNull.c
> > >Hmac/CryptHmac.c
> > >Kdf/CryptHkdf.c
> > > -  Cipher/CryptAesNull.c
> > > +  Cipher/CryptAes.c
> > >Cipher/CryptAeadAesGcmNull.c
> > >Pk/CryptRsaBasic.c
> > >Pk/CryptRsaExtNull.c
> > > diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > > b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > > index 0af7a3f96e8f..cc5a53ca92cd 100644
> > > --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > > +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > > @@ -43,7 +43,7 @@ [Sources]
> > >Hash/CryptCShake256.c
> > >Hash/CryptParallelHash.c
> > >Hmac/CryptHmac.c
> > > -  Kdf/CryptHkdfNull.c
> > > +  Kdf/CryptHkdf.c
> > >Cipher/CryptAes.c
> > >Cipher/CryptAeadAesGcmNull.c
> > >Pk/CryptRsaBasic.c
> > > diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md index
> > > 067465b8eb7d..cb072db72397 100644
> > > --- a/CryptoPkg/Readme.md
> > > +++ b/CryptoPkg/Readme.md
> > > @@ -447,18 +447,20 @@ and CryptoSmm modules.
> > >   Common PEI PcdCryptoServiceFamilyEnable Settings
> > >
> > >  ```
> > > -
> > >
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.F
> > > amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > > -
> > >
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.F
> > > amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > > -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family
> > > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > > -
> > >
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family
> > > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > > -
> > >
> 

Re: [edk2-devel] [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value

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

Hi Hao,
That is the uncrustify check error. I already fixed it at "[PATCH V3] 
MdeModulePkg/Usb: Read a large number of blocks."

Also, these three patches are passed the CI test.
https://github.com/tianocore/edk2/pull/3794

Thanks
Abner

> -Original Message-
> From: Wu, Hao A 
> Sent: Monday, December 12, 2022 11:27 AM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context
> value
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> For the 3 patches:
> [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block [PATCH
> V2] MdeModulePkg/Usb: Read a large number of blocks [PATCH V3]
> MdeModulePkg/Xhci: Initial XHCI DCI slot's Context value
> 
> I found that they will cause CI failures:
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith
> ub.com%2Ftianocore%2Fedk2%2Fpull%2F3749data=05%7C01%7Cabn
> er.chang%40amd.com%7Cfe921dc0e08b4cdf30a208dadbf0cb8c%7C3dd8961f
> e4884e608e11a82d994e183d%7C0%7C0%7C638064124508360013%7CUnknow
> n%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1ha
> WwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=0iQKJ3X3IJv1CSqe
> mjTWyT1hlYvqGZsYPAdwXEi%2B%2FZ4%3Dreserved=0
> Could you help to update them and help to ensure they can pass the CI test?
> Thanks in advance.
> 
> Best Regards,
> Hao Wu
> 
> > -Original Message-
> > From: abner.ch...@amd.com 
> > Sent: Saturday, December 10, 2022 11:08 PM
> > To: devel@edk2.groups.io
> > Cc: kuei-hung@amd.com; Wu, Hao A ; Ni, Ray
> > ; Garrett Kirkendall ;
> > Abner Chang 
> > Subject: [PATCH V3] MdeModulePkg/Xhci: Initial XHCI DCI slot's Context
> > value
> >
> > From: Abner Chang 
> >
> > In V3: Add AMD copyright.
> > In V2: Remove the signed-off-by: Abner Chang.
> >
> > Initialize XHCI DCI slot's context entries value.
> >
> > Signed-off-by: Kuei-Hung Lin 
> > Cc: Hao A Wu 
> > Cc: Ray Ni 
> > Cc: Garrett Kirkendall 
> > Cc: Abner Chang 
> > ---
> >  MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 7 +++
> > MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c | 7 +++
> >  2 files changed, 14 insertions(+)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > index 13b0400e83d..f08722905f3 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > +++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
> > @@ -4,6 +4,7 @@
> >
> >  Copyright (c) 2011 - 2020, Intel Corporation. All rights
> > reserved.  Copyright (c) Microsoft Corporation.
> > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > +reserved.
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> >  **/
> > @@ -2807,6 +2808,9 @@ XhcInitializeEndpointContext (
> >MaxDci = 0;
> >
> >NumEp = IfDesc->NumEndpoints;
> > +  if (NumEp == 0) {
> > +MaxDci = 1;
> > +  }
> >
> >EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> >for (EpIndex = 0; EpIndex < NumEp; EpIndex++) { @@ -3006,6 +3010,9
> > @@ XhcInitializeEndpointContext64 (
> >MaxDci = 0;
> >
> >NumEp = IfDesc->NumEndpoints;
> > +  if (NumEp == 0) {
> > +MaxDci = 1;
> > +  }
> >
> >EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> >for (EpIndex = 0; EpIndex < NumEp; EpIndex++) { diff --git
> > a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > index cc597a43717..8400c90f7ad 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > +++ b/MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
> > @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based
> on
> > gPeiUsbControllerPpiGuid  which is used to enable recovery function
> > from USB Drivers.
> >
> >  Copyright (c) 2014 - 2017, Intel Corporation. All rights
> > reserved.
> > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > +reserved.
> >
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -1752,6 +1753,9 @@ XhcPeiSetConfigCmd (
> >  }
> >
> >  NumEp = IfDesc->NumEndpoints;
> > +if ((NumEp == 0) && (MaxDci == 0)) {
> > +  MaxDci = 1;
> > +}
> >
> >  EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> >  for (EpIndex = 0; EpIndex < NumEp; EpIndex++) { @@ -1974,6
> > +1978,9 @@ XhcPeiSetConfigCmd64 (
> >  }
> >
> >  NumEp = IfDesc->NumEndpoints;
> > +if ((NumEp == 0) && (MaxDci == 0)) {
> > +  MaxDci = 1;
> > +}
> >
> >  EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
> >  for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
> > --
> > 2.37.1.windows.1


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

[edk2-devel] [PATCH V3] MdeModulePkg/Usb: Read a large number of blocks

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

In V3: Address Uncrustify check errors.
In V2: Add AMD copyright.

Changes to allow reading blocks that greater than 65535 sectors.

Signed-off-by: Kuei-Hung Lin 
Cc: Hao A Wu 
Cc: Ray Ni 
Cc: Garrett Kirkendall 
Cc: Abner Chang 
Cc: Jiangang He 
---
 MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c | 25 +++
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c 
b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
index 422ac5fec99..5111e4579e2 100644
--- a/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
+++ b/MdeModulePkg/Bus/Usb/UsbBotPei/PeiAtapi.c
@@ -2,6 +2,7 @@
 Pei USB ATAPI command implementations.
 
 Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
+Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -382,14 +383,14 @@ PeiUsbRead10 (
   ATAPI_PACKET_COMMAND  Packet;
   ATAPI_READ10_CMD  *Read10Packet;
   UINT16MaxBlock;
-  UINT16BlocksRemaining;
-  UINT16SectorCount;
+  UINT32BlocksRemaining;
+  UINT32SectorCount;
   UINT32Lba32;
   UINT32BlockSize;
   UINT32ByteCount;
   VOID  *PtrBuffer;
   EFI_STATUSStatus;
-  UINT16TimeOut;
+  UINT32TimeOut;
 
   //
   // prepare command packet for the Inquiry Packet Command.
@@ -401,16 +402,13 @@ PeiUsbRead10 (
 
   BlockSize = (UINT32)PeiBotDevice->Media.BlockSize;
 
-  MaxBlock= (UINT16)(65535 / BlockSize);
-  BlocksRemaining = (UINT16)NumberOfBlocks;
+  MaxBlock = (UINT16)(MAX_UINT16 / BlockSize);
+  ASSERT (NumberOfBlocks < MAX_UINT32);
+  BlocksRemaining = (UINT32)NumberOfBlocks;
 
   Status = EFI_SUCCESS;
   while (BlocksRemaining > 0) {
-if (BlocksRemaining <= MaxBlock) {
-  SectorCount = BlocksRemaining;
-} else {
-  SectorCount = MaxBlock;
-}
+SectorCount = MIN (BlocksRemaining, MaxBlock);
 
 //
 // fill the Packet data structure
@@ -435,7 +433,7 @@ PeiUsbRead10 (
 
 ByteCount = SectorCount * BlockSize;
 
-TimeOut = (UINT16)(SectorCount * 2000);
+TimeOut = SectorCount * 2000;
 
 //
 // send command packet
@@ -448,16 +446,17 @@ PeiUsbRead10 (
(VOID *)PtrBuffer,
ByteCount,
EfiUsbDataIn,
-   TimeOut
+   (UINT16)MIN (TimeOut, MAX_UINT16)
);
 
 if (Status != EFI_SUCCESS) {
   return Status;
 }
 
+ASSERT (Lba32 <= (MAX_UINT32-SectorCount));
 Lba32  += SectorCount;
 PtrBuffer   = (UINT8 *)PtrBuffer + SectorCount * BlockSize;
-BlocksRemaining = (UINT16)(BlocksRemaining - SectorCount);
+BlocksRemaining = BlocksRemaining - SectorCount;
   }
 
   return Status;
-- 
2.37.1.windows.1



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




Re: [edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes

2022-12-19 Thread Michael D Kinney
Judah,

This was the feedback that I have back on 10/24/22 that was not incorporated 
into
the CryptoPkg patches before they were merged today by Jiewen.

Please generate an additional patch series to address (1) and (2).

Mike

> -Original Message-
> From: Kinney, Michael D 
> Sent: Monday, October 24, 2022 10:22 AM
> To: devel@edk2.groups.io; Vang, Judah ; Kinney, Michael 
> D 
> Subject: RE: [edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes
> 
> Hi Judah,
> 
> There was an update to CryptoPkg pushed yesterday.
> 
> 1) There is a CryptoPkg/Readme.md with tables and DSC content for services 
> that are
>enabled in each phase.  I think that needs updates too for the AES and KDF 
> features.
> 2) The CryptoPkg.dsc file has recommended settings for PEI, DXE, SMM.  I think
>they need to be updated for the AES and KDF features.
> 3) It looks like the SHA1 disable caused a build break.  I would like to see 
> the
>standard package builds for EDK II CI be updated to cover the failure case 
> so
>we know that this case is covered in the future.  It looks like the 
> default is
>for SHA1 enabled and the build break is when define for SHA1 disabled is
>asserted.
> 4) There is an overlap between the defines to deprecate MD5 and SH1 and the
>structured PCD that allows those services to be disabled in the Crypto
>Protocol/PPI.  The defines to deprecate MD5 and SH1 extend into the 
> BaseCryptLib
>instance implementations such that a call to those services when static 
> linking
>will generate a build error instead of a runtime ASSERT().  Which behavior 
> do
>you prefer?
> 
> Best regards,
> 
> Mike
> 
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Judah Vang
> > Sent: Monday, October 24, 2022 9:42 AM
> > To: devel@edk2.groups.io
> > Subject: [edk2-devel] [PATCH V1 0/2] CryptoPkg bug fixes
> >
> > https://bugzilla.tianocore.org/show_bug.cgi?id=3991
> > https://bugzilla.tianocore.org/show_bug.cgi?id=3992
> >
> > There is a #define to deprecate Sha1 functions but not
> > all the Sha1 function are wrapped around this #define causing
> > a build error. The fix is to wrap all Sha1 functions with
> > the #define.
> >
> > Need crypto AES to be supported for PEI phase and need
> > crypto KDF to be supported for SMM phase.
> >
> > Judah Vang (2):
> >   CryptoPkg: Sha1 functions causing build errors
> >   CryptoPkg: Need to enable crypto functions
> >
> >  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf|  2 +-
> >  CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf|  2 +-
> >  CryptoPkg/Library/BaseHashApiLib/BaseHashApiLib.c | 14 +-
> >  3 files changed, 15 insertions(+), 3 deletions(-)
> >
> > --
> > 2.35.1.windows.2
> >
> >
> >
> > 
> >



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




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

2022-12-19 Thread Group Notification
*Reminder: TianoCore Bug Triage - APAC / NAMO*

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

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

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

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

*Description:*

TianoCore Bug Triage - APAC / NAMO

Hosted by Liming Gao



Microsoft Teams meeting

*Join on your computer or mobile app*

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

*Join with a video conferencing device*

te...@conf.intel.com

Video Conference ID: 116 062 094 0

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

*Or call in (audio only)*

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

Phone Conference ID: 774 638 21#

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

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


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




Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto functions

2022-12-19 Thread Michael D Kinney
Hi Jiewen,

I noticed that this patch is missing the update to the table in ReadMe.md to
show the new PEI and SMM crypto services enabled by default in *CryptLib
library instances.

https://github.com/tianocore/edk2/tree/master/CryptoPkg#supported-cryptographic-families-and-services

It did update the recommended PCD settings at the end of the 
ReadMe, but missed the update to CryptoPkg.dsc file to actually
enable the PEI and SMM services in the Crypto Drivers.

Mike

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Yao, Jiewen
> Sent: Monday, December 19, 2022 5:40 PM
> To: Vang, Judah ; devel@edk2.groups.io
> Cc: Wang, Jian J ; Xiaoyu Lu ; 
> Jiang, Guomin ;
> Mistry, Nishant C 
> Subject: Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto 
> functions
> 
> Just merged - https://github.com/tianocore/edk2/pull/3796
> 
> 
> > -Original Message-
> > From: Vang, Judah 
> > Sent: Tuesday, December 20, 2022 8:44 AM
> > To: devel@edk2.groups.io; Vang, Judah 
> > Cc: Yao, Jiewen ; Wang, Jian J
> > ; Xiaoyu Lu ; Jiang, Guomin
> > ; Mistry, Nishant C 
> > Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> > functions
> >
> > Hi Jiewen,
> >
> > Has this patch been merged?
> > This is an important change for the UEFI Protected Variable feature.
> >
> > Judah
> >
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Judah
> > Vang
> > Sent: Monday, November 7, 2022 2:16 PM
> > To: devel@edk2.groups.io
> > Cc: Yao, Jiewen ; Wang, Jian J
> > ; Xiaoyu Lu ; Jiang, Guomin
> > ; Mistry, Nishant C 
> > Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> > functions
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3992
> >
> > V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
> > Update Readme.md
> >
> > Cc: Jiewen Yao 
> > Cc: Jian J Wang 
> > Cc: Xiaoyu Lu 
> > Cc: Guomin Jiang 
> > Cc: Nishant C Mistry 
> > Signed-off-by: Jian J Wang 
> > Signed-off-by: Nishant C Mistry 
> > Signed-off-by: Judah Vang 
> > ---
> >  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |  2 +-
> > CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |  2 +-
> >  CryptoPkg/Readme.md| 27 +++-
> >  3 files changed, 17 insertions(+), 14 deletions(-)
> >
> > diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > index b1629647f9c6..ee5f3cd5d4b6 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> > @@ -43,7 +43,7 @@ [Sources]
> >Hash/CryptParallelHashNull.c
> >Hmac/CryptHmac.c
> >Kdf/CryptHkdf.c
> > -  Cipher/CryptAesNull.c
> > +  Cipher/CryptAes.c
> >Cipher/CryptAeadAesGcmNull.c
> >Pk/CryptRsaBasic.c
> >Pk/CryptRsaExtNull.c
> > diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > index 0af7a3f96e8f..cc5a53ca92cd 100644
> > --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> > @@ -43,7 +43,7 @@ [Sources]
> >Hash/CryptCShake256.c
> >Hash/CryptParallelHash.c
> >Hmac/CryptHmac.c
> > -  Kdf/CryptHkdfNull.c
> > +  Kdf/CryptHkdf.c
> >Cipher/CryptAes.c
> >Cipher/CryptAeadAesGcmNull.c
> >Pk/CryptRsaBasic.c
> > diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md index
> > 067465b8eb7d..cb072db72397 100644
> > --- a/CryptoPkg/Readme.md
> > +++ b/CryptoPkg/Readme.md
> > @@ -447,18 +447,20 @@ and CryptoSmm modules.
> >   Common PEI PcdCryptoServiceFamilyEnable Settings
> >
> >  ```
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.F
> > amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.F
> > amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family
> > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family
> > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family
> > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family
> > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family
> > | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Pk
> > cs1Verify| TRUE
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.N
> > ew| TRUE
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Fr
> > ee   | TRUE
> > -
> > gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Se
> > tKey | TRUE
> > -
> > 

Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto functions

2022-12-19 Thread Yao, Jiewen
Just merged - https://github.com/tianocore/edk2/pull/3796


> -Original Message-
> From: Vang, Judah 
> Sent: Tuesday, December 20, 2022 8:44 AM
> To: devel@edk2.groups.io; Vang, Judah 
> Cc: Yao, Jiewen ; Wang, Jian J
> ; Xiaoyu Lu ; Jiang, Guomin
> ; Mistry, Nishant C 
> Subject: RE: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> functions
> 
> Hi Jiewen,
> 
> Has this patch been merged?
> This is an important change for the UEFI Protected Variable feature.
> 
> Judah
> 
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Judah
> Vang
> Sent: Monday, November 7, 2022 2:16 PM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen ; Wang, Jian J
> ; Xiaoyu Lu ; Jiang, Guomin
> ; Mistry, Nishant C 
> Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto
> functions
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3992
> 
> V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
> Update Readme.md
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Xiaoyu Lu 
> Cc: Guomin Jiang 
> Cc: Nishant C Mistry 
> Signed-off-by: Jian J Wang 
> Signed-off-by: Nishant C Mistry 
> Signed-off-by: Judah Vang 
> ---
>  CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |  2 +-
> CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |  2 +-
>  CryptoPkg/Readme.md| 27 +++-
>  3 files changed, 17 insertions(+), 14 deletions(-)
> 
> diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> index b1629647f9c6..ee5f3cd5d4b6 100644
> --- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
> @@ -43,7 +43,7 @@ [Sources]
>Hash/CryptParallelHashNull.c
>Hmac/CryptHmac.c
>Kdf/CryptHkdf.c
> -  Cipher/CryptAesNull.c
> +  Cipher/CryptAes.c
>Cipher/CryptAeadAesGcmNull.c
>Pk/CryptRsaBasic.c
>Pk/CryptRsaExtNull.c
> diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> index 0af7a3f96e8f..cc5a53ca92cd 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> +++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
> @@ -43,7 +43,7 @@ [Sources]
>Hash/CryptCShake256.c
>Hash/CryptParallelHash.c
>Hmac/CryptHmac.c
> -  Kdf/CryptHkdfNull.c
> +  Kdf/CryptHkdf.c
>Cipher/CryptAes.c
>Cipher/CryptAeadAesGcmNull.c
>Pk/CryptRsaBasic.c
> diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md index
> 067465b8eb7d..cb072db72397 100644
> --- a/CryptoPkg/Readme.md
> +++ b/CryptoPkg/Readme.md
> @@ -447,18 +447,20 @@ and CryptoSmm modules.
>   Common PEI PcdCryptoServiceFamilyEnable Settings
> 
>  ```
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.F
> amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.F
> amily   | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Pk
> cs1Verify| TRUE
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.N
> ew| TRUE
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Fr
> ee   | TRUE
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Se
> tKey | TRUE
> -
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.P
> kcs5HashPassword | TRUE
> +
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.F
> amily| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.F
> amily| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +
> gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family
> | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
> +  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Family
> | 

Re: [edk2-devel] [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD

2022-12-19 Thread Guo, Gua
The goal reduce macro requirement to build UniversalPayloadBuild.py.

For UPL: UefiPayloadPkg dynamic to set PCD based on UPL defined HOB.

For PPL: These PCDs on PPL (Booloader) will keep on FixedAtBuild and generate 
HOB data.

So the change is move these PCD have compatibility FixedAtBuild only to 
FixedAtBuild + Dynamic.

Thanks,
Gua Guo

-Original Message-
From: Ni, Ray  
Sent: Monday, December 19, 2022 3:43 PM
To: Liu, KasimX ; devel@edk2.groups.io
Cc: Dong, Guo ; Lu, James ; Guo, Gua 

Subject: RE: [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD

The initial goal was to remove dynamic PCD dependency from bootloader.
Is that still the goal?
If yes, maybe depending on dynamic PCD is not a good idea.

Thanks,
Ray

> -Original Message-
> From: Liu, KasimX 
> Sent: Monday, December 19, 2022 3:40 PM
> To: devel@edk2.groups.io
> Cc: Liu, KasimX ; Dong, Guo 
> ; Ni, Ray ; Lu, James 
> ; Guo, Gua 
> Subject: [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD
> 
> From: KasimX Liu 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4193
> 
> In order to remove RTC_INDEX/RTC_TARGET from the UplBuild macro 
> list,change the RTC_INDEX /RTC_TARGET type from PcdsFixedAtBuild to 
> PcdsDynamicEx
> 
> Cc: Guo Dong 
> Cc: Ray Ni 
> Cc: James Lu 
> Cc: Gua Guo 
> Signed-off-by: KasimX Liu 
> ---
>  PcAtChipsetPkg/PcAtChipsetPkg.dec | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec 
> b/PcAtChipsetPkg/PcAtChipsetPkg.dec
> index ed2d95550b..a53ca777e8 100644
> --- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
> +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
> @@ -84,6 +84,14 @@
># @Prompt RTC Target Register address
> 
>
> gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0|UINT64|0x
> 0023
> 
> 
> 
> +  ## Specifies RTC Index Register address in I/O space.
> 
> +  # @Prompt RTC Index Register address
> 
> +  
> + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x0
> + 01E
> 
> +
> 
> +  ## Specifies RTC Target Register address in I/O space.
> 
> +  # @Prompt RTC Target Register address
> 
> +  
> + gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x
> + 001F
> 
> +
> 
>  [PcdsFixedAtBuild, PcdsPatchableInModule]
> 
>## Defines the ACPI register set base address.
> 
>#  The invalid 0x is as its default value. It must be configured to 
> the real value.
> 
> @@ -146,14 +154,6 @@
># @Prompt Initial value for Register_D in RTC.
> 
>
> gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterD|0x00|UINT8|0
> x001D
> 
> 
> 
> -  ## Specifies RTC Index Register address in I/O space.
> 
> -  # @Prompt RTC Index Register address
> 
> -  
> gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001
> E
> 
> -
> 
> -  ## Specifies RTC Target Register address in I/O space.
> 
> -  # @Prompt RTC Target Register address
> 
> -  
> gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x00
> 1F
> 
> -
> 
>## RTC Update Timeout Value(microsecond).
> 
># @Prompt RTC Update Timeout Value.
> 
>
> gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|10|UIN
> T32|0x0020
> 
> --
> 2.32.0.windows.2



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




Re: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.

2022-12-19 Thread Guo, Gua
Acked-by: Gua Guo  

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Yuanhao Xie
Sent: Tuesday, December 20, 2022 5:40 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required 
by MpInitLib.

Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg.

Signed-off-by: Yuanhao Xie 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 723a50a422..05d53a85d0 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -340,6 +340,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
-- 
2.36.1.windows.1








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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the DynamicEX PCDs

2022-12-19 Thread Guo, Gua
@Lu, James

Could you help us to add push label on it ?
UefiPayloadPkg: Define default values for the DynamicEX PCDs by jiadingzhang · 
Pull Request #3792 · tianocore/edk2 
(github.com)

The change purpose is for resolving ECC issue.

@jdzh...@kunluntech.com.cn
Thanks for the change.

Thanks,
Gua

From: devel@edk2.groups.io  On Behalf Of Jiading Zhang
Sent: Monday, December 19, 2022 8:56 PM
To: Guo; Guo, Gua ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the 
DynamicEX PCDs

Hi.
  I commit a PR again, and the PR passed all the test.

https://github.com/tianocore/edk2/pull/3792/commits

Thanks!



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




Re: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto functions

2022-12-19 Thread Judah Vang
Hi Jiewen,

Has this patch been merged?
This is an important change for the UEFI Protected Variable feature.

Judah

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Judah Vang
Sent: Monday, November 7, 2022 2:16 PM
To: devel@edk2.groups.io
Cc: Yao, Jiewen ; Wang, Jian J ; 
Xiaoyu Lu ; Jiang, Guomin ; 
Mistry, Nishant C 
Subject: [edk2-devel] [PATCH v1 1/1] CryptoPkg: Need to enable crypto functions

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

V1: Enable CryptAes for PEI phase. Enable CryptHkdf for SMM phase.
Update Readme.md

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Cc: Nishant C Mistry 
Signed-off-by: Jian J Wang 
Signed-off-by: Nishant C Mistry 
Signed-off-by: Judah Vang 
---
 CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf |  2 +-  
CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf |  2 +-
 CryptoPkg/Readme.md| 27 +++-
 3 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
index b1629647f9c6..ee5f3cd5d4b6 100644
--- a/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/PeiCryptLib.inf
@@ -43,7 +43,7 @@ [Sources]
   Hash/CryptParallelHashNull.c
   Hmac/CryptHmac.c
   Kdf/CryptHkdf.c
-  Cipher/CryptAesNull.c
+  Cipher/CryptAes.c
   Cipher/CryptAeadAesGcmNull.c
   Pk/CryptRsaBasic.c
   Pk/CryptRsaExtNull.c
diff --git a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf 
b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
index 0af7a3f96e8f..cc5a53ca92cd 100644
--- a/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
+++ b/CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
@@ -43,7 +43,7 @@ [Sources]
   Hash/CryptCShake256.c
   Hash/CryptParallelHash.c
   Hmac/CryptHmac.c
-  Kdf/CryptHkdfNull.c
+  Kdf/CryptHkdf.c
   Cipher/CryptAes.c
   Cipher/CryptAeadAesGcmNull.c
   Pk/CryptRsaBasic.c
diff --git a/CryptoPkg/Readme.md b/CryptoPkg/Readme.md index 
067465b8eb7d..cb072db72397 100644
--- a/CryptoPkg/Readme.md
+++ b/CryptoPkg/Readme.md
@@ -447,18 +447,20 @@ and CryptoSmm modules.
  Common PEI PcdCryptoServiceFamilyEnable Settings
 
 ```
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family 
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family   
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family  
| PCD_CRYPTO_SERVICE_ENABLE_FAMILY
-  
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Pkcs1Verify
| TRUE
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.New
| TRUE
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Free   
| TRUE
-  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.SetKey 
| TRUE
-  
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Pkcs.Services.Pkcs5HashPassword
 | TRUE
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.HmacSha384.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha1.Family 
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha256.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha384.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sha512.Family   
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Sm3.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Aes.Family  
 | PCD_CRYPTO_SERVICE_ENABLE_FAMILY
+  
gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Pkcs1Verify
 | TRUE
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.New
 | TRUE
+  gEfiCryptoPkgTokenSpaceGuid.PcdCryptoServiceFamilyEnable.Rsa.Services.Free   
 | TRUE
+  

[edk2-devel] [PATCH v2] PcAtChipsetPkg: Move RTC PCD to dynamic PCD

2022-12-19 Thread kasimx . liu
From: KasimX Liu 

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

In order to remove RTC_INDEX/RTC_TARGET from
the UplBuild macro list,change the RTC_INDEX
/RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx

Cc: Guo Dong 
Cc: Ray Ni 
Cc: James Lu 
Cc: Gua Guo 
Signed-off-by: KasimX Liu 
---
 PcAtChipsetPkg/PcAtChipsetPkg.dec | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec 
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index ed2d95550b..a53ca777e8 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -84,6 +84,14 @@
   # @Prompt RTC Target Register address
   gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0|UINT64|0x0023
 
+  ## Specifies RTC Index Register address in I/O space.
+  # @Prompt RTC Index Register address
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E
+
+  ## Specifies RTC Target Register address in I/O space.
+  # @Prompt RTC Target Register address
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F
+
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Defines the ACPI register set base address.
   #  The invalid 0x is as its default value. It must be configured to the 
real value.
@@ -146,14 +154,6 @@
   # @Prompt Initial value for Register_D in RTC.
   
gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterD|0x00|UINT8|0x001D
 
-  ## Specifies RTC Index Register address in I/O space.
-  # @Prompt RTC Index Register address
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E
-
-  ## Specifies RTC Target Register address in I/O space.
-  # @Prompt RTC Target Register address
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F
-
   ## RTC Update Timeout Value(microsecond).
   # @Prompt RTC Update Timeout Value.
   
gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|10|UINT32|0x0020
-- 
2.32.0.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97590): https://edk2.groups.io/g/devel/message/97590
Mute This Topic: https://groups.io/mt/95760949/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] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2

2022-12-19 Thread Tuan Phan
On Fri, Dec 16, 2022 at 4:06 PM Kinney, Michael D <
michael.d.kin...@intel.com> wrote:

> If that intrinsic is specific to RISCV, then should CompilerHelper.c go
> into a RiscV64 subdir?
>
> Mike
>
>
Hi Mike,
While this intrinsic is not specific to RISCV,  it is needed due to the GCC
for RISCV64 does not generate internal implementation, requiring external
link with libgcc/compile-rt. It can happen to other platforms or future GCC
toolchain if it decides to move __ctzdi2 to libgcc.
If you think it is better to put it in the RiscV64 subdir for now, I am
good with it.

Tuan,

> -Original Message-
> > From: Tuan Phan 
> > Sent: Friday, December 16, 2022 10:48 AM
> > Cc: devel@edk2.groups.io; suni...@ventanamicro.com; Kinney, Michael D <
> michael.d.kin...@intel.com>; Yao, Jiewen
> > ; Wang, Jian J ; Lu,
> Xiaoyu1 ; Jiang, Guomin
> > ; Tuan Phan 
> > Subject: [PATCH v2] CryptoPkg/IntrinsicLib: RiscV: Provide
> implementation of memcpy and __ctzdi2
> >
> > The RiscV toolchain doesn't provide __ctzdi2 implementation when
> > compiled with -nostdlib that needed by openssl library.
> > So adding the implementation of __ctzdi2.
> >
> > Forcing to use CopyMem of EDK2 as memcpy buildin disabled for RiscV
> > with -fno-builtin-memcpy flag.
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4103
> > Signed-off-by: Tuan Phan 
> > Acked-by: Sunil V L 
> > ---
> > V2:
> > - Add license header.
> > - Add REF to the bugzilla.
> >
> >  .../Library/IntrinsicLib/CompilerHelper.c | 42 +++
> >  .../Library/IntrinsicLib/IntrinsicLib.inf |  6 ++-
> >  2 files changed, 47 insertions(+), 1 deletion(-)
> >  create mode 100644 CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
> >
> > diff --git a/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
> b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
> > new file mode 100644
> > index ..3844fd14ae66
> > --- /dev/null
> > +++ b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
> > @@ -0,0 +1,42 @@
> > +/** @file
> > +  Implement functions that not available when compiled with -nostdlib.
> > +
> > +  Copyright (c) 2022, Ventana Micro Systems Inc. All Rights
> Reserved.
> > +  SPDX-License-Identifier: BSD-2-Clause-Patent
> > +
> > +**/
> > +
> > +unsigned int
> > +__ctzdi2 (unsigned long long x)
> > +{
> > +  unsigned int ret = 0;
> > +
> > +  if (!x) {
> > +return 64;
> > +  }
> > +  if (!(x & 0x)) {
> > +x >>= 32;
> > +ret |= 32;
> > +  }
> > +  if (!(x & 0x)) {
> > +x >>= 16;
> > +ret |= 16;
> > +  }
> > +  if (!(x & 0xff)) {
> > +x >>= 8;
> > +ret |= 8;
> > +  }
> > +  if (!(x & 0xf)) {
> > +x >>= 4;
> > +ret |= 4;
> > +  }
> > +  if (!(x & 0x3)) {
> > +x >>= 2;
> > +ret |= 2;
> > +  }
> > +  if (!(x & 0x1)) {
> > +x >>= 1;
> > +ret |= 1;
> > +  }
> > +  return ret;
> > +}
> > diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> > index 86e74b57b109..6796b39b07cf 100644
> > --- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> > +++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
> > @@ -18,7 +18,7 @@
> >  #
> >
> >  # The following information is for reference only and not required by
> the build tools.
> >
> >  #
> >
> > -#  VALID_ARCHITECTURES   = IA32 X64
> >
> > +#  VALID_ARCHITECTURES   = IA32 X64 RISCV64
> >
> >  #
> >
> >
> >
> >  [Sources]
> >
> > @@ -43,6 +43,10 @@
> >  [Sources.X64]
> >
> >CopyMem.c
> >
> >
> >
> > +[Sources.RISCV64]
> >
> > +  CopyMem.c
> >
> > +  CompilerHelper.c
> >
> > +
> >
> >  [Packages]
> >
> >MdePkg/MdePkg.dec
> >
> >
> >
> > --
> > 2.25.1
>
>


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




[edk2-devel] [PATCH v2] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV

2022-12-19 Thread marsx . lin
From: MarsX Lin 

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

Since UefiPayload had supported multiple fv,
move bdsdxe.inf to new firmware volume and
modify the script of UniversalPayloadPkgBuild.py to
support bdsdxe fv in elf file

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: MarsX Lin 
---
 UefiPayloadPkg/UefiPayloadPkg.fdf   | 27 +++-
 UefiPayloadPkg/UniversalPayloadBuild.py | 12 +
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 9c9e2f2741..94ba922244 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -59,8 +59,33 @@ INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
 FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
 SECTION FV_IMAGE = DXEFV
 }
+FILE FV_IMAGE = FBE6C1E3-2F80-4770-88B0-494186E3346F {
+SECTION FV_IMAGE = BDSFV
+}
 
 

+[FV.BDSFV]
+FvNameGuid = CA5590AF-9558-4822-B5EA-BE2E876CD3EC
+BlockSize  = $(FD_BLOCK_SIZE)
+FvForceRebase  = FALSE
+FvAlignment= 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED  = TRUE
+STICKY_WRITE   = TRUE
+LOCK_CAP   = TRUE
+LOCK_STATUS= TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP  = TRUE
+WRITE_STATUS   = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS  = TRUE
+READ_DISABLED_CAP  = TRUE
+READ_ENABLED_CAP   = TRUE
+READ_STATUS= TRUE
+READ_LOCK_CAP  = TRUE
+READ_LOCK_STATUS   = TRUE
+
+INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.DXEFV]
 FvNameGuid = 8063C21A-8E58-4576-95CE-089E87975D23
@@ -106,7 +131,7 @@ INF CryptoPkg/Driver/CryptoDxe.inf
 INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 !endif
 INF UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+
 INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
 INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
 INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py 
b/UefiPayloadPkg/UniversalPayloadBuild.py
index 50a5950e7c..6d62b8b20f 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -67,7 +67,8 @@ def BuildUniversalPayload(Args, MacroList):
 
 EntryModuleInf = 
os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf")
 DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")
-FvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/DXEFV.Fv"))
+DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/DXEFV.Fv"))
+BdsFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/BDSFV.Fv"))
 PayloadReportPath = os.path.join(BuildDir, "UefiUniversalPayload.txt")
 ModuleReportPath = os.path.join(BuildDir, "UefiUniversalPayloadEntry.txt")
 UpldInfoFile = os.path.join(BuildDir, "UniversalPayloadInfo.bin")
@@ -119,21 +120,22 @@ def BuildUniversalPayload(Args, MacroList):
 #
 # Copy the DXEFV as a section in elf format Universal Payload entry.
 #
-remove_section = '"{}" -I {} -O {} --remove-section .upld_info 
--remove-section .upld.uefi_fv {}'.format (
+remove_section = '"{}" -I {} -O {} --remove-section .upld_info 
--remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
EntryOutputDir
)
-add_section= '"{}" -I {} -O {} --add-section .upld_info={} 
--add-section .upld.uefi_fv={} {}'.format (
+add_section= '"{}" -I {} -O {} --add-section .upld_info={} 
--add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
UpldInfoFile,
-   FvOutputDir,
+   DxeFvOutputDir,
+   BdsFvOutputDir,
EntryOutputDir
)
-set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 
--set-section-alignment .upld.uefi_fv=16 {}'.format (
+set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=16 
--set-section-alignment .upld.uefi_fv=16 --set-section-alignment 
.upld.bds_fv=16 {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
-- 
2.33.0.windows.2



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

Re: [edk2-devel] [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

2022-12-19 Thread He, Jiangang via groups.io
[AMD Official Use Only - General]

UsbHcFreeMemBlock()->IoMmuFreeBuffer()->mIoMmu->FreeBuffer(), which may end up 
calling PeiFreePages() depending on gEdkiiIoMmuPpiGuid implementation. Surely 
both will work since UsbHcFreeMemPool() can't be interrupted by any service 
call to use the memory just freed. Just for good coding practice reason, I pick 
the one aligning with XhciDxe.

Thanks,
Jiangang
-Original Message-
From: Wu, Hao A 
Sent: Monday, December 19, 2022 12:40 AM
To: He, Jiangang ; Chang, Abner ; 
devel@edk2.groups.io
Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray 
; Zeng, Star ; Sun, Zhikai 
; Kirkendall, Garrett 
Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

[AMD Official Use Only - General]

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


Hello,

My take is that unlike in DXE, the UsbHcFreeMemBlock() implementation in PEI 
phase does not perform freeing the memory.

So I think both the solution:
* Provided at 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%7CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126779782%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=uJMNyYXMU22UZNjrKtDetyD2BqrvkualuorPZHAV3wg%3D=0,
 which aligns with EhciPei
* Mentioned at the end of your previous reply, which aligns with XhciDxe should 
work fine.

I will leave it to you for the final decision.

Best Regards,
Hao Wu

> -Original Message-
> From: He, Jiangang 
> Sent: Friday, December 16, 2022 12:48 AM
> To: Chang, Abner ; Wu, Hao A
> ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett
> 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
>
> [AMD Official Use Only - General]
>
> Yes, it is the same issue discussed in
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2
> .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%7CJiang
> ang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961fe4884e60
> 8e11a82d994e183d%7C0%7C0%7C638070288126936018%7CUnknown%7CTWFpbGZsb3d8
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3
> 000%7C%7C%7C=58j41QJxKbrQenhyZKYO4dxYj3Sat2kJejQGioZhtu4%3D
> rved=0
>
> MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c
>
>   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
> // UsbHcUnlinkMemBlock (Pool->Head, Block);
> UsbHcFreeMemBlock (Pool, Block);
>   }
> Block = Pool->Head->Next never change without calling
> UsbHcUnlinkMemBlock (Pool->Head, Block), therefore dead loop.
>
> Our proposed fix came from dxe version of the equivalent file
> MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two routine call
> order (Now I think it is incorrect as clarified below).
>   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
> UsbHcFreeMemBlock (Pool, Block);
> UsbHcUnlinkMemBlock (Pool->Head, Block);
>   }
>
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2.groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%7CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126936018%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=58j41QJxKbrQenhyZKYO4dxYj3Sat2kJejQGioZhtu4%3D=0
>  proposed fix:
>
>   for (Block = Pool->Head->Next; Block != NULL; Block = Block ->Next) {
> // UsbHcUnlinkMemBlock (Pool->Head, Block);
> UsbHcFreeMemBlock (Pool, Block);
>   }
>
> I think it again, both proposals have problem of reading memory
> content in the buffer that has just been freed.
>
>   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
>  UsbHcUnlinkMemBlock (Pool->Head, Block);
> UsbHcFreeMemBlock (Pool, Block);
>   }
> is right solution and matches dxe version of UsbHcMem.c.
>
> Thanks,
> Jiangang
>
> -Original Message-
> From: Chang, Abner 
> Sent: Wednesday, December 14, 2022 8:12 PM
> To: Wu, Hao A ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett
> ; He, Jiangang 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
>
> [AMD Official Use Only - General]
>
> Hi Jiangang,
> Could you please provide the context of this patch?
>
> Thanks
> Abner
>
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Monday, December 12, 2022 11:27 AM
> > To: Chang, Abner ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Zeng, Star ; Sun, Zhikai
> > ; Kirkendall, Garrett
> > 
> > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei
> > memory block
> >
> > Caution: This message 

[edk2-devel] [PATCH] UefiPayloadPkg: Move bdsdxe.inf from DXEFV to BDSFV

2022-12-19 Thread marsx . lin
From: MarsX Lin 

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

Since UefiPayload had supported multiple fv,
move bdsdxe.inf to new firmware volume and
modify the script of UniversalPayloadPkgBuild.py to
support bdsdxe fv in elf file

Cc: Guo Dong 
Cc: Ray Ni 
Cc: Sean Rhodes 
Cc: James Lu 
Cc: Gua Guo 

Signed-off-by: MarsX Lin 
---
 UefiPayloadPkg/UefiPayloadPkg.fdf   | 27 -
 UefiPayloadPkg/UniversalPayloadBuild.py | 12 ++-
 2 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 9c9e2f2741..94ba922244 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -59,8 +59,33 @@ INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
 FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
 SECTION FV_IMAGE = DXEFV
 }
+FILE FV_IMAGE = FBE6C1E3-2F80-4770-88B0-494186E3346F {
+SECTION FV_IMAGE = BDSFV
+}
 
 

+[FV.BDSFV]
+FvNameGuid = CA5590AF-9558-4822-B5EA-BE2E876CD3EC
+BlockSize  = $(FD_BLOCK_SIZE)
+FvForceRebase  = FALSE
+FvAlignment= 16
+ERASE_POLARITY = 1
+MEMORY_MAPPED  = TRUE
+STICKY_WRITE   = TRUE
+LOCK_CAP   = TRUE
+LOCK_STATUS= TRUE
+WRITE_DISABLED_CAP = TRUE
+WRITE_ENABLED_CAP  = TRUE
+WRITE_STATUS   = TRUE
+WRITE_LOCK_CAP = TRUE
+WRITE_LOCK_STATUS  = TRUE
+READ_DISABLED_CAP  = TRUE
+READ_ENABLED_CAP   = TRUE
+READ_STATUS= TRUE
+READ_LOCK_CAP  = TRUE
+READ_LOCK_STATUS   = TRUE
+
+INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
 
 [FV.DXEFV]
 FvNameGuid = 8063C21A-8E58-4576-95CE-089E87975D23
@@ -106,7 +131,7 @@ INF CryptoPkg/Driver/CryptoDxe.inf
 INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
 !endif
 INF UefiCpuPkg/CpuDxe/CpuDxe.inf
-INF MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
+
 INF RuleOverride = UI MdeModulePkg/Application/UiApp/UiApp.inf
 INF MdeModulePkg/Application/BootManagerMenuApp/BootManagerMenuApp.inf
 INF PcAtChipsetPkg/HpetTimerDxe/HpetTimerDxe.inf
diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py 
b/UefiPayloadPkg/UniversalPayloadBuild.py
index 50a5950e7c..f242b039b4 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -67,7 +67,8 @@ def BuildUniversalPayload(Args, MacroList):
 
 EntryModuleInf = 
os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf")
 DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")
-FvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/DXEFV.Fv"))
+DxeFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/DXEFV.Fv"))
+BdsFvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, 
ToolChain), os.path.normpath("FV/BDSFV.Fv"))
 PayloadReportPath = os.path.join(BuildDir, "UefiUniversalPayload.txt")
 ModuleReportPath = os.path.join(BuildDir, "UefiUniversalPayloadEntry.txt")
 UpldInfoFile = os.path.join(BuildDir, "UniversalPayloadInfo.bin")
@@ -119,21 +120,22 @@ def BuildUniversalPayload(Args, MacroList):
 #
 # Copy the DXEFV as a section in elf format Universal Payload entry.
 #
-remove_section = '"{}" -I {} -O {} --remove-section .upld_info 
--remove-section .upld.uefi_fv {}'.format (
+remove_section = '"{}" -I {} -O {} --remove-section .upld_info 
--remove-section .upld.uefi_fv --remove-section .upld.bds_fv {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
EntryOutputDir
)
-add_section= '"{}" -I {} -O {} --add-section .upld_info={} 
--add-section .upld.uefi_fv={} {}'.format (
+add_section= '"{}" -I {} -O {} --add-section .upld_info={} 
--add-section .upld.uefi_fv={} --add-section .upld.bds_fv={} {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
UpldInfoFile,
-   FvOutputDir,
+   DxeFvOutputDir,
+   BdsFvOutputDir,
EntryOutputDir
)
-set_section= '"{}" -I {} -O {} --set-section-alignment .upld_info=4 
--set-section-alignment .upld.uefi_fv=16 {}'.format (
+set_section= '"{}" -I {} -O {} --set-section-alignment 
.upld.upld_info=4 --set-section-alignment .upld.uefi_fv=16 
--set-section-alignment .upld.bds_fv=16 {}'.format (
LlvmObjcopyPath,
ObjCopyFlag,
ObjCopyFlag,
-- 
2.33.0.windows.2



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

Re: [edk2-devel] [PATCH v2] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2

2022-12-19 Thread Tuan Phan
On Fri, Dec 16, 2022 at 5:59 PM Pedro Falcato 
wrote:

> On Sat, Dec 17, 2022 at 12:06 AM Michael D Kinney <
> michael.d.kin...@intel.com> wrote:
>
>> If that intrinsic is specific to RISCV, then should CompilerHelper.c go
>> into a RiscV64 subdir?
>
>
> Mike and Tuan,
>
> Two comments:
> 1) __ctzdi2 is not riscv specific and is a part of the standard functions
> provided by libgcc/compiler-rt (read: the compiler can call it as it
> pleases)
>
> > Forcing to use CopyMem of EDK2 as memcpy buildin disabled for RiscV
>> > with -fno-builtin-memcpy flag.
>>
>
> 2) Using -fno-builtin-memcpy doesn't stop GCC/clang from trying to call
> memcpy (see https://godbolt.org/z/xYsYEq6En for an example). In fact,
> fno-builtin-memcpy will call memcpy more,
> as GCC stops assuming normal behavior from memcpy and generates calls
> instead of e.g inlining memcpy code.
> GCC and clang require memcpy, memmove, memset and memcmp (with standard C
> library behavior) to compile code. AFAIK no option can change this.
> GCC and clang also require libgcc/compiler-rt (although getting around
> this is saner and way more reliable, done in e.g operating system kernels
> such as linux itself).
>
> The only way to reliably generate code with GCC/clang is to have the
> CompilerIntrinsicsLib as a dependency for every platform compiled with GCC
> (or have BaseTools inject that).
>
> I actually ran into this issue a few weeks back when trying to add
> security features (https://github.com/heatd/edk2/commits/toolchain-fixes).
> Can we properly fix this?
>
> It would not be a problem if libgcc/compiler-rt can be linked during the
build process. With the -nostdlib flag enforced for most targets, each
module needs to explicitly link libgcc in INF if want to use the
compiler-rt functions. I am not sure what is the best way to do it unless
we remove -nostdlib or enforce linking libgcc with BaseTools.

Tuan

> Pedro
>


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




Re: [edk2-devel] [PATCH 1/1] BaseTools: Fix IA32 UINT64 alignment for CLANG toolchains

2022-12-19 Thread Marvin Häuser
Revised version of last year’s https://edk2.groups.io/g/devel/message/79670
Initially caught by last year‘s https://edk2.groups.io/g/devel/message/79318
But now caught *yet again*, independently, via bugs during development.

Cc stewards so this issue finally gets some attention. Might need validation of 
already shipped code, who knows.

Best regards,
Marvin

> On 16. Dec 2022, at 20:54, Pedro Falcato  wrote:
> 
> 
> PS: it's worth noting that at this moment in time, due to this, the CLANG 
> toolchains are very broken as they break the UEFI spec and are silently 
> incompatible with modules compiled in both GCC and MSVC.
> 
> Fixing this should be top priority.
> 
> Pedro


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




[edk2-devel] [PATCH v2] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2

2022-12-19 Thread Tuan Phan
The RiscV toolchain doesn't provide __ctzdi2 implementation when
compiled with -nostdlib that needed by openssl library.
So adding the implementation of __ctzdi2.

Forcing to use CopyMem of EDK2 as memcpy buildin disabled for RiscV
with -fno-builtin-memcpy flag.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4103
Signed-off-by: Tuan Phan 
Acked-by: Sunil V L 
---
V2:
- Add license header.
- Add REF to the bugzilla.

 .../Library/IntrinsicLib/CompilerHelper.c | 42 +++
 .../Library/IntrinsicLib/IntrinsicLib.inf |  6 ++-
 2 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 CryptoPkg/Library/IntrinsicLib/CompilerHelper.c

diff --git a/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c 
b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
new file mode 100644
index ..3844fd14ae66
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
@@ -0,0 +1,42 @@
+/** @file
+  Implement functions that not available when compiled with -nostdlib.
+
+  Copyright (c) 2022, Ventana Micro Systems Inc. All Rights Reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+unsigned int
+__ctzdi2 (unsigned long long x)
+{
+  unsigned int ret = 0;
+
+  if (!x) {
+return 64;
+  }
+  if (!(x & 0x)) {
+x >>= 32;
+ret |= 32;
+  }
+  if (!(x & 0x)) {
+x >>= 16;
+ret |= 16;
+  }
+  if (!(x & 0xff)) {
+x >>= 8;
+ret |= 8;
+  }
+  if (!(x & 0xf)) {
+x >>= 4;
+ret |= 4;
+  }
+  if (!(x & 0x3)) {
+x >>= 2;
+ret |= 2;
+  }
+  if (!(x & 0x1)) {
+x >>= 1;
+ret |= 1;
+  }
+  return ret;
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf 
b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
index 86e74b57b109..6796b39b07cf 100644
--- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -18,7 +18,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64
+#  VALID_ARCHITECTURES   = IA32 X64 RISCV64
 #
 
 [Sources]
@@ -43,6 +43,10 @@
 [Sources.X64]
   CopyMem.c
 
+[Sources.RISCV64]
+  CopyMem.c
+  CompilerHelper.c
+
 [Packages]
   MdePkg/MdePkg.dec
 
-- 
2.25.1



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




Re: [edk2-devel] [edk2-platforms][PATCH v2 03/11] Ext4Pkg: Fix global buffer overflow in Ext4ReadDir

2022-12-19 Thread Marvin Häuser
On 12. Dec 2022, at 15:46, Savva Mitrofanov  wrote:
> 
> Directory entry structure can contain name_len bigger than size of "."
> or "..", that's why CompareMem in such cases leads to global buffer
> overflow. So there are two problems. The first is that statement doesn't
> check cases when name_len != 0 but > 2 and the second is that we passing
> big Length to CompareMem routine.
> The correct way here is to check that name_len <= 2 and check for
> null-terminator presence
> 
> Cc: Marvin Häuser 
> Cc: Pedro Falcato 
> Cc: Vitaly Cheptsov 
> Fixes: e55f0527dde48a5f139c1b8f35acc4e6b59dd794
> Signed-off-by: Savva Mitrofanov 
> ---
> Features/Ext4Pkg/Ext4Dxe/Directory.c | 8 +++-
> 1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/Features/Ext4Pkg/Ext4Dxe/Directory.c 
> b/Features/Ext4Pkg/Ext4Dxe/Directory.c
> index 8b8fce568e43..ffc0e8043076 100644
> --- a/Features/Ext4Pkg/Ext4Dxe/Directory.c
> +++ b/Features/Ext4Pkg/Ext4Dxe/Directory.c
> @@ -491,11 +491,9 @@ Ext4ReadDir (
> 
> // Entry.name_len may be 0 if it's a nameless entry, like an unused entry
> // or a checksum at the end of the directory block.
> -// memcmp (and CompareMem) return 0 when the passed length is 0.
> -
> -IsDotOrDotDot = Entry.name_len != 0 &&
> -(CompareMem (Entry.name, ".", Entry.name_len) == 0 ||
> - CompareMem (Entry.name, "..", Entry.name_len) == 0);
> +IsDotOrDotDot = Entry.name_len <= 2 &&
> +((Entry.name[0] == '.') &&
> + (Entry.name[1] == '.' || Entry.name[1] == '\0'));

This is definitely borked, names do not need to be 0-terminated. So this may 
cause OOB if Entry.name_len == 1 and Entry.name[0] == '.' and also may yield a 
false negative.

> 
> // When inode = 0, it's unused.
> ShouldSkip = Entry.inode == 0 || IsDotOrDotDot;
> -- 
> 2.38.1
> 



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97584): https://edk2.groups.io/g/devel/message/97584
Mute This Topic: https://groups.io/mt/95622331/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] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

2022-12-19 Thread He, Jiangang via groups.io
[AMD Official Use Only - General]

Yes, it is the same issue discussed in 
https://edk2.groups.io/g/devel/topic/92833071#92165

MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c

  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
// UsbHcUnlinkMemBlock (Pool->Head, Block);
UsbHcFreeMemBlock (Pool, Block);
  }
Block = Pool->Head->Next never change without calling UsbHcUnlinkMemBlock 
(Pool->Head, Block), therefore dead loop.

Our proposed fix came from dxe version of the equivalent file 
MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two routine call order (Now 
I think it is incorrect as clarified below).
  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
UsbHcFreeMemBlock (Pool, Block);
UsbHcUnlinkMemBlock (Pool->Head, Block);
  }

https://edk2.groups.io/g/devel/topic/92833071#92165 proposed fix:

  for (Block = Pool->Head->Next; Block != NULL; Block = Block ->Next) {
// UsbHcUnlinkMemBlock (Pool->Head, Block);
UsbHcFreeMemBlock (Pool, Block);
  }

I think it again, both proposals have problem of reading memory content in the 
buffer that has just been freed.

  for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
 UsbHcUnlinkMemBlock (Pool->Head, Block);
UsbHcFreeMemBlock (Pool, Block);
  }
is right solution and matches dxe version of UsbHcMem.c.

Thanks,
Jiangang

-Original Message-
From: Chang, Abner 
Sent: Wednesday, December 14, 2022 8:12 PM
To: Wu, Hao A ; devel@edk2.groups.io
Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray 
; Zeng, Star ; Sun, Zhikai 
; Kirkendall, Garrett ; He, 
Jiangang 
Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

[AMD Official Use Only - General]

Hi Jiangang,
Could you please provide the context of this patch?

Thanks
Abner

> -Original Message-
> From: Wu, Hao A 
> Sent: Monday, December 12, 2022 11:27 AM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett
> 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> Sorry for a question, may I know what issue was met that leads to the
> proposed patch?
> Could you help to check if it is related with the topic discussed in
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2
> .gr
> oups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165data=05%7C01%7
> Cabner.chang%40amd.com%7Ccac49c2820e741b8c48a08dadbf0cc24%7C3dd8
> 961fe4884e608e11a82d994e183d%7C0%7C0%7C638064124512265992%7CUnk
> nown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1h
> aWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7Csdata=z1Q7NRxN4GMA%2
> FBxYd2D7Gnkc3aTD23mRnwNF3H5wE0k%3Dreserved=0? Thanks in advance.
>
> Best Regards,
> Hao Wu
>
> > -Original Message-
> > From: abner.ch...@amd.com 
> > Sent: Saturday, December 10, 2022 11:13 PM
> > To: devel@edk2.groups.io
> > Cc: kuei-hung@amd.com; Wu, Hao A ; Ni, Ray
> > ; Garrett Kirkendall ;
> > Abner Chang 
> > Subject: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> > block
> >
> > From: Abner Chang 
> >
> > In V2: Add AMD copyright.
> >
> > Unlink the XhciPei memory block when it has been freed.
> >
> > Signed-off-by: Kuei-Hung Lin 
> > Cc: Hao A Wu 
> > Cc: Ray Ni 
> > Cc: Garrett Kirkendall 
> > Cc: Abner Chang 
> > ---
> >  MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c | 29
> > -
> >  1 file changed, 28 insertions(+), 1 deletion(-)
> >
> > diff --git a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> > b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> > index c64b38fcfc8..39ba31b0913 100644
> > --- a/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> > +++ b/MdeModulePkg/Bus/Pci/XhciPei/UsbHcMem.c
> > @@ -3,6 +3,7 @@ PEIM to produce gPeiUsb2HostControllerPpiGuid based
> > on gPeiUsbControllerPpiGuid  which is used to enable recovery
> > function from USB Drivers.
> >
> >  Copyright (c) 2014 - 2016, Intel Corporation. All rights
> > reserved.
> > +Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> > +reserved.
> >
> >  SPDX-License-Identifier: BSD-2-Clause-Patent
> >
> > @@ -365,6 +366,32 @@ UsbHcInitMemPool (
> >return Pool;
> >  }
> >
> > +/**
> > +  Unlink the memory block from the pool's list.
> > +
> > +  @param  Head   The block list head of the memory's pool.
> > +  @param  BlockToUnlink  The memory block to unlink.
> > +
> > +**/
> > +VOID
> > +UsbHcUnlinkMemBlock (
> > +  IN USBHC_MEM_BLOCK  *Head,
> > +  IN USBHC_MEM_BLOCK  *BlockToUnlink
> > +  )
> > +{
> > +  USBHC_MEM_BLOCK  *Block;
> > +
> > +  ASSERT ((Head != NULL) && (BlockToUnlink != NULL));
> > +
> > +  for (Block = Head; Block != NULL; Block = Block->Next) {
> > +if (Block->Next == BlockToUnlink) {
> > +  Block->Next = BlockToUnlink->Next;
> > +  BlockToUnlink->Next = NULL;
> > +  

[edk2-devel] [PATCH v2] OvmfPkg/PlatformInitLib: Fix integrity checking failed of NvVarStore in some cases

2022-12-19 Thread Lee, Chun-Yi
In the commit 4f173db8b4 "OvmfPkg/PlatformInitLib: Add functions for
EmuVariableNvStore", it introduced a PlatformValidateNvVarStore() function
for checking the integrity of NvVarStore.

In some cases when the VariableHeader->StartId is VARIABLE_DATA, the
VariableHeader->State is not just one of the four primary states:
VAR_IN_DELETED_TRANSITION, VAR_DELETED, VAR_HEADER_VALID_ONLY, VAR_ADDED.
The state may combined two or three states, e.g.

0x3C = (VAR_IN_DELETED_TRANSITION & VAR_ADDED) & VAR_DELETED
or
0x3D = VAR_ADDED & VAR_DELETED

When the variable store has those variables, system booting/rebooting will
hangs in a ASSERT:

NvVarStore Variable header State was invalid.
ASSERT
/mnt/working/source_code-git/edk2/OvmfPkg/Library/PlatformInitLib/Platform.c(819):
((BOOLEAN)(0==1))

Adding more log to UpdateVariable() and PlatformValidateNvVarStore(), we
saw some variables which have 0x3C or 0x3D state in store.
e.g.

UpdateVariable(), VariableName=BootOrder
L1871, State=003F   <-- VAR_ADDED
State &= VAR_DELETED=003D
FlushHobVariableToFlash(), VariableName=BootOrder
...
UpdateVariable(), VariableName=InitialAttemptOrder
L1977, State=003F
State &= VAR_IN_DELETED_TRANSITION=003E
L2376, State=003E
State &= VAR_DELETED=003C
FlushHobVariableToFlash(), VariableName=InitialAttemptOrder
...
UpdateVariable(), VariableName=ConIn
L1977, State=003F
State &= VAR_IN_DELETED_TRANSITION=003E
L2376, State=003E
State &= VAR_DELETED=003C
FlushHobVariableToFlash(), VariableName=ConIn
...

So, only allowing the four primary states is not enough. This patch changes
the falid states list (Follow Jiewen Yao's suggestion):

1. VAR_HEADER_VALID_ONLY (0x7F)
- Header added (*)
2. VAR_ADDED (0x3F)
- Header + data added
3. VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E)
- marked as deleted, but still valid, before new data is added. (*)
4. VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
- deleted, after new data is added.
5. VAR_ADDED & VAR_DELETED (0x3D)
- deleted directly, without new data.
(*) means to support surprise shutdown.

And removed (VAR_IN_DELETED_TRANSITION) and (VAR_DELETED) because they are
invalid states.

v2:
Follow Jiewen Yao's suggestion to add the following valid states:
VAR_ADDED & VAR_DELETED (0x3D)
VAR_ADDED & VAR_IN_DELETED_TRANSITION (0x3E) 
VAR_ADDED & VAR_IN_DELETED_TRANSITION & VAR_DELETED (0x3C)
and removed the following invalid states:
VAR_IN_DELETED_TRANSITION
VAR_DELETED

Signed-off-by: "Lee, Chun-Yi" 
---
 OvmfPkg/Library/PlatformInitLib/Platform.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c 
b/OvmfPkg/Library/PlatformInitLib/Platform.c
index 77f22de046..6963c47e0b 100644
--- a/OvmfPkg/Library/PlatformInitLib/Platform.c
+++ b/OvmfPkg/Library/PlatformInitLib/Platform.c
@@ -702,10 +702,11 @@ PlatformValidateNvVarStore (
 
   VariableOffset = NvVarStoreHeader->Size - sizeof (VARIABLE_STORE_HEADER);
 } else {
-  if (!((VariableHeader->State == VAR_IN_DELETED_TRANSITION) ||
-(VariableHeader->State == VAR_DELETED) ||
-(VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
-(VariableHeader->State == VAR_ADDED)))
+  if (!((VariableHeader->State == VAR_HEADER_VALID_ONLY) ||
+   (VariableHeader->State == VAR_ADDED) ||
+   (VariableHeader->State == (VAR_ADDED & VAR_DELETED)) ||
+   (VariableHeader->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION)) 
||
+   (VariableHeader->State == (VAR_ADDED & VAR_IN_DELETED_TRANSITION & 
VAR_DELETED
   {
 DEBUG ((DEBUG_ERROR, "NvVarStore Variable header State was 
invalid.\n"));
 return FALSE;
-- 
2.35.3



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




[edk2-devel] [PATCH] CryptoPkg/IntrinsicLib: RiscV: Provide implementation of memcpy and __ctzdi2

2022-12-19 Thread Tuan Phan
The RiscV toolchain doesn't provide __ctzdi2 implementation when
compiled with -nostdlib that needed by openssl library when EC 
enabled. So adding the simple implementation of __ctzdi2.

Forcing to use CopyMem of EDK2 as builtin memcpy disabled for RiscV
with -fno-builtin-memcpy flag.

Signed-off-by: Tuan Phan 
---
 .../Library/IntrinsicLib/CompilerHelper.c | 41 +++
 .../Library/IntrinsicLib/IntrinsicLib.inf |  6 ++-
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 CryptoPkg/Library/IntrinsicLib/CompilerHelper.c

diff --git a/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c 
b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
new file mode 100644
index ..9e700a11ed17
--- /dev/null
+++ b/CryptoPkg/Library/IntrinsicLib/CompilerHelper.c
@@ -0,0 +1,41 @@
+/** @file
+  Implement functions that not available when compiled with -nostdlib flag.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+unsigned int
+__ctzdi2 (unsigned long long x)
+{
+  unsigned int ret = 0;
+
+  if (!x) {
+return 64;
+  }
+  if (!(x & 0x)) {
+x >>= 32;
+ret |= 32;
+  }
+  if (!(x & 0x)) {
+x >>= 16;
+ret |= 16;
+  }
+  if (!(x & 0xff)) {
+x >>= 8;
+ret |= 8;
+  }
+  if (!(x & 0xf)) {
+x >>= 4;
+ret |= 4;
+  }
+  if (!(x & 0x3)) {
+x >>= 2;
+ret |= 2;
+  }
+  if (!(x & 0x1)) {
+x >>= 1;
+ret |= 1;
+  }
+  return ret;
+}
diff --git a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf 
b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
index 86e74b57b109..6796b39b07cf 100644
--- a/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
+++ b/CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf
@@ -18,7 +18,7 @@
 #
 # The following information is for reference only and not required by the 
build tools.
 #
-#  VALID_ARCHITECTURES   = IA32 X64
+#  VALID_ARCHITECTURES   = IA32 X64 RISCV64
 #
 
 [Sources]
@@ -43,6 +43,10 @@
 [Sources.X64]
   CopyMem.c
 
+[Sources.RISCV64]
+  CopyMem.c
+  CompilerHelper.c
+
 [Packages]
   MdePkg/MdePkg.dec
 
-- 
2.25.1



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




[edk2-devel] [PATCH] UefiPayloadPkg: Remove RTC_INDEX/TARGET from UplBuild macro list

2022-12-19 Thread kasimx . liu
From: KasimX Liu 

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

In order to remove RTC_INDEX/RTC_TARGET from
the UplBuild macro list,change the RTC_INDEX
/RTC_TARGET type from PcdsFixedAtBuild to PcdsDynamicEx

Cc: Guo Dong 
Cc: Ray Ni 
Cc: James Lu 
Cc: Gua Guo 
Signed-off-by: KasimX Liu 
---
 PcAtChipsetPkg/PcAtChipsetPkg.dec | 16 
 UefiPayloadPkg/UefiPayloadPkg.dsc |  5 +++--
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dec 
b/PcAtChipsetPkg/PcAtChipsetPkg.dec
index ed2d95550b..a53ca777e8 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dec
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dec
@@ -84,6 +84,14 @@
   # @Prompt RTC Target Register address
   gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister64|0x0|UINT64|0x0023
 
+  ## Specifies RTC Index Register address in I/O space.
+  # @Prompt RTC Index Register address
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E
+
+  ## Specifies RTC Target Register address in I/O space.
+  # @Prompt RTC Target Register address
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F
+
 [PcdsFixedAtBuild, PcdsPatchableInModule]
   ## Defines the ACPI register set base address.
   #  The invalid 0x is as its default value. It must be configured to the 
real value.
@@ -146,14 +154,6 @@
   # @Prompt Initial value for Register_D in RTC.
   
gPcAtChipsetPkgTokenSpaceGuid.PcdInitialValueRtcRegisterD|0x00|UINT8|0x001D
 
-  ## Specifies RTC Index Register address in I/O space.
-  # @Prompt RTC Index Register address
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|0x70|UINT8|0x001E
-
-  ## Specifies RTC Target Register address in I/O space.
-  # @Prompt RTC Target Register address
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|0x71|UINT8|0x001F
-
   ## RTC Update Timeout Value(microsecond).
   # @Prompt RTC Update Timeout Value.
   
gPcAtChipsetPkgTokenSpaceGuid.PcdRealTimeClockUpdateTimeout|10|UINT32|0x0020
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 723a50a422..82cff41780 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -471,8 +471,6 @@
 !endif
 
 [PcdsPatchableInModule.X64]
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)
-  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)
 !if $(NETWORK_DRIVER_ENABLE) == TRUE
   gEfiNetworkPkgTokenSpaceGuid.PcdAllowHttpConnections|TRUE
 !endif
@@ -579,6 +577,9 @@
   gUefiCpuPkgTokenSpaceGuid.PcdSevEsIsEnabled|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration|TRUE
 
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)
+  gPcAtChipsetPkgTokenSpaceGuid.PcdRtcTargetRegister|$(RTC_TARGET_REGISTER)
+
 

 #
 # Components Section - list of all EDK II Modules needed by this Platform.
-- 
2.32.0.windows.2



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




[edk2-devel] Now: Tools, CI, Code base construction meeting series - Monday, December 19, 2022 #cal-notice

2022-12-19 Thread Group Notification
*Tools, CI, Code base construction meeting series*

*When:*
Monday, December 19, 2022
4:30pm to 5:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://github.com/tianocore/edk2/discussions/2614

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

MS Teams Browser Clients * 
https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


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




Re: [edk2-devel] [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

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

I will send the update according to the discussion.

Thanks
Abner


> -Original Message-
> From: Wu, Hao A 
> Sent: Tuesday, December 20, 2022 8:27 AM
> To: He, Jiangang ; Chang, Abner
> ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
> 
> [AMD Official Use Only - General]
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Thanks.
> You are right. I agree with you that aligning with XhciDxe is a better 
> resolution.
> 
> Best Regards,
> Hao Wu
> 
> > -Original Message-
> > From: He, Jiangang 
> > Sent: Tuesday, December 20, 2022 6:54 AM
> > To: Wu, Hao A ; Chang, Abner
> > ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Zeng, Star ; Sun, Zhikai
> > ; Kirkendall, Garrett
> > 
> > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei
> memory
> > block
> >
> > [AMD Official Use Only - General]
> >
> > UsbHcFreeMemBlock()->IoMmuFreeBuffer()->mIoMmu->FreeBuffer(),
> which
> > may end up calling PeiFreePages() depending on gEdkiiIoMmuPpiGuid
> > implementation. Surely both will work since UsbHcFreeMemPool() can't
> > be interrupted by any service call to use the memory just freed. Just
> > for good coding practice reason, I pick the one aligning with XhciDxe.
> >
> > Thanks,
> > Jiangang
> > -Original Message-
> > From: Wu, Hao A 
> > Sent: Monday, December 19, 2022 12:40 AM
> > To: He, Jiangang ; Chang, Abner
> > ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Zeng, Star ; Sun, Zhikai
> > ; Kirkendall, Garrett
> > 
> > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei
> memory
> > block
> >
> > [AMD Official Use Only - General]
> >
> > Caution: This message originated from an External Source. Use proper
> > caution when opening attachments, clicking links, or responding.
> >
> >
> > Hello,
> >
> > My take is that unlike in DXE, the UsbHcFreeMemBlock() implementation
> > in PEI phase does not perform freeing the memory.
> >
> > So I think both the solution:
> > * Provided at
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2
> > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%
> 7
> > CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d
> > d8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126779782%7C
> >
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJB
> T
> >
> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=uJMNyYXMU22
> > UZNjrKtDetyD2BqrvkualuorPZHAV3wg%3D=0, which aligns with
> > EhciPei
> > * Mentioned at the end of your previous reply, which aligns with
> > XhciDxe should work fine.
> >
> > I will leave it to you for the final decision.
> >
> > Best Regards,
> > Hao Wu
> >
> > > -Original Message-
> > > From: He, Jiangang 
> > > Sent: Friday, December 16, 2022 12:48 AM
> > > To: Chang, Abner ; Wu, Hao A
> > > ; devel@edk2.groups.io
> > > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > > ; Zeng, Star ; Sun, Zhikai
> > > ; Kirkendall, Garrett
> > > 
> > > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei
> > > memory block
> > >
> > > [AMD Official Use Only - General]
> > >
> > > Yes, it is the same issue discussed in
> > >
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2
> > > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01
> > %7CJiang
> > >
> > ang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961f
> > e4884e60
> > >
> > 8e11a82d994e183d%7C0%7C0%7C638070288126936018%7CUnknown%7CT
> > WFpbGZsb3d8
> > >
> >
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> > D%7C3
> > >
> >
> 000%7C%7C%7C=58j41QJxKbrQenhyZKYO4dxYj3Sat2kJejQGioZhtu4%
> 3
> > D
> > > rved=0
> > >
> > > MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c
> > >
> > >   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head-
> >Next) {
> > > // UsbHcUnlinkMemBlock (Pool->Head, Block);
> > > UsbHcFreeMemBlock (Pool, Block);
> > >   }
> > > Block = Pool->Head->Next never change without calling
> > > UsbHcUnlinkMemBlock (Pool->Head, Block), therefore dead loop.
> > >
> > > Our proposed fix came from dxe version of the equivalent file
> > > MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two
> routine
> > call
> > > order (Now I think it is incorrect as clarified below).
> > >   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head-
> >Next) {
> > > UsbHcFreeMemBlock (Pool, Block);
> > > UsbHcUnlinkMemBlock (Pool->Head, Block);
> > >   }
> > >
> > >
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk
> 2
> > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%
> 7
> > CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d
> > 

Re: [edk2-devel] [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory block

2022-12-19 Thread Wu, Hao A
Thanks.
You are right. I agree with you that aligning with XhciDxe is a better 
resolution.

Best Regards,
Hao Wu

> -Original Message-
> From: He, Jiangang 
> Sent: Tuesday, December 20, 2022 6:54 AM
> To: Wu, Hao A ; Chang, Abner
> ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
> 
> [AMD Official Use Only - General]
> 
> UsbHcFreeMemBlock()->IoMmuFreeBuffer()->mIoMmu->FreeBuffer(), which
> may end up calling PeiFreePages() depending on gEdkiiIoMmuPpiGuid
> implementation. Surely both will work since UsbHcFreeMemPool() can't be
> interrupted by any service call to use the memory just freed. Just for good
> coding practice reason, I pick the one aligning with XhciDxe.
> 
> Thanks,
> Jiangang
> -Original Message-
> From: Wu, Hao A 
> Sent: Monday, December 19, 2022 12:40 AM
> To: He, Jiangang ; Chang, Abner
> ; devel@edk2.groups.io
> Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> ; Zeng, Star ; Sun, Zhikai
> ; Kirkendall, Garrett 
> Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> block
> 
> [AMD Official Use Only - General]
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Hello,
> 
> My take is that unlike in DXE, the UsbHcFreeMemBlock() implementation in
> PEI phase does not perform freeing the memory.
> 
> So I think both the solution:
> * Provided at
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2
> .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%7
> CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d
> d8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126779782%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=uJMNyYXMU22
> UZNjrKtDetyD2BqrvkualuorPZHAV3wg%3D=0, which aligns with
> EhciPei
> * Mentioned at the end of your previous reply, which aligns with XhciDxe
> should work fine.
> 
> I will leave it to you for the final decision.
> 
> Best Regards,
> Hao Wu
> 
> > -Original Message-
> > From: He, Jiangang 
> > Sent: Friday, December 16, 2022 12:48 AM
> > To: Chang, Abner ; Wu, Hao A
> > ; devel@edk2.groups.io
> > Cc: Lin, Kuei-Hung (Timothy) ; Ni, Ray
> > ; Zeng, Star ; Sun, Zhikai
> > ; Kirkendall, Garrett
> > 
> > Subject: RE: [PATCH V2] MdeModulePkg/XhciPei: Unlinked XhciPei memory
> > block
> >
> > [AMD Official Use Only - General]
> >
> > Yes, it is the same issue discussed in
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2
> > .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01
> %7CJiang
> >
> ang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3dd8961f
> e4884e60
> >
> 8e11a82d994e183d%7C0%7C0%7C638070288126936018%7CUnknown%7CT
> WFpbGZsb3d8
> >
> eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3
> D%7C3
> >
> 000%7C%7C%7C=58j41QJxKbrQenhyZKYO4dxYj3Sat2kJejQGioZhtu4%3
> D
> > rved=0
> >
> > MdeModulePkg\Bus\Pci\XhciPei\UsbHcMem.c
> >
> >   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
> > // UsbHcUnlinkMemBlock (Pool->Head, Block);
> > UsbHcFreeMemBlock (Pool, Block);
> >   }
> > Block = Pool->Head->Next never change without calling
> > UsbHcUnlinkMemBlock (Pool->Head, Block), therefore dead loop.
> >
> > Our proposed fix came from dxe version of the equivalent file
> > MdeModulePkg\Bus\Pci\XhciDxe\UsbHcMem.c but swapped two routine
> call
> > order (Now I think it is incorrect as clarified below).
> >   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
> > UsbHcFreeMemBlock (Pool, Block);
> > UsbHcUnlinkMemBlock (Pool->Head, Block);
> >   }
> >
> >
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fedk2
> .groups.io%2Fg%2Fdevel%2Ftopic%2F92833071%2392165=05%7C01%7
> CJiangang.He%40amd.com%7C528424aa303f4a2c9b1808dae18be036%7C3d
> d8961fe4884e608e11a82d994e183d%7C0%7C0%7C638070288126936018%7C
> Unknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBT
> iI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C=58j41QJxKbrQen
> hyZKYO4dxYj3Sat2kJejQGioZhtu4%3D=0 proposed fix:
> >
> >   for (Block = Pool->Head->Next; Block != NULL; Block = Block ->Next) {
> > // UsbHcUnlinkMemBlock (Pool->Head, Block);
> > UsbHcFreeMemBlock (Pool, Block);
> >   }
> >
> > I think it again, both proposals have problem of reading memory
> > content in the buffer that has just been freed.
> >
> >   for (Block = Pool->Head->Next; Block != NULL; Block = Pool->Head->Next) {
> >  UsbHcUnlinkMemBlock (Pool->Head, Block);
> > UsbHcFreeMemBlock (Pool, Block);
> >   }
> > is right solution and matches dxe version of UsbHcMem.c.
> >
> > Thanks,
> > Jiangang
> >
> > -Original Message-
> > From: Chang, Abner 
> > Sent: Wednesday, December 14, 2022 8:12 PM
> > To: Wu, Hao A ; 

[edk2-devel] Event: Tools, CI, Code base construction meeting series - Monday, December 19, 2022 #cal-reminder

2022-12-19 Thread Group Notification
*Reminder: Tools, CI, Code base construction meeting series*

*When:*
Monday, December 19, 2022
4:30pm to 5:30pm
(UTC-08:00) America/Los Angeles

*Where:*
https://github.com/tianocore/edk2/discussions/2614

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

*Description:*

TianoCore community,

Microsoft and Intel will be hosting a series of open meetings to discuss build, 
CI, tools, and other related topics. If you are interested, have ideas/opinions 
please join us. These meetings will be Monday 4:30pm Pacific Time on Microsoft 
Teams.

MS Teams Link in following discussion: * 
https://github.com/tianocore/edk2/discussions/2614

Anyone is welcome to join.

* tianocore/edk2: EDK II (github.com)
* tianocore/edk2-basetools: EDK II BaseTools Python tools as a PIP module 
(github.com) https://github.com/tianocore/edk2-basetools
* tianocore/edk2-pytool-extensions: Extensions to the edk2 build system 
allowing for a more robust and plugin based build system and tool execution 
environment (github.com) https://github.com/tianocore/edk2-pytool-extensions
* tianocore/edk2-pytool-library: Python library package that supports UEFI 
development (github.com) https://github.com/tianocore/edk2-pytool-library

MS Teams Browser Clients * 
https://docs.microsoft.com/en-us/microsoftteams/get-clients?tabs=Windows#browser-client


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




[edk2-devel] [PATCH 4/4] UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.

2022-12-19 Thread Yuanhao Xie
Add CpuPageTableLib required by MpInitLib in UefiPayloadPkg.

Signed-off-by: Yuanhao Xie 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 723a50a422..05d53a85d0 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -340,6 +340,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
 !if $(PERFORMANCE_MEASUREMENT_ENABLE)
   PerformanceLib|MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
-- 
2.36.1.windows.1



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




[edk2-devel] [PATCH 3/4] OvmfPkg: Add CpuPageTableLib required by MpInitLib.

2022-12-19 Thread Yuanhao Xie
Add CpuPageTableLib required by MpInitLib in OvmfPkg.

Signed-off-by: Yuanhao Xie 
---
 OvmfPkg/AmdSev/AmdSevX64.dsc | 3 ++-
 OvmfPkg/CloudHv/CloudHvX64.dsc   | 1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc | 4 +++-
 OvmfPkg/Microvm/MicrovmX64.dsc   | 3 ++-
 OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
 OvmfPkg/OvmfPkgX64.dsc   | 2 ++
 OvmfPkg/OvmfXen.dsc  | 3 ++-
 7 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc
index e0b04d6734..b92c6154b2 100644
--- a/OvmfPkg/AmdSev/AmdSevX64.dsc
+++ b/OvmfPkg/AmdSev/AmdSevX64.dsc
@@ -3,7 +3,7 @@
 #  virtual machine remote attestation and secret injection
 #
 #  Copyright (c) 2020 James Bottomley, IBM Corporation.
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -352,6 +352,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   
QemuLoadImageLib|OvmfPkg/Library/GenericQemuLoadImageLib/GenericQemuLoadImageLib.inf
diff --git a/OvmfPkg/CloudHv/CloudHvX64.dsc b/OvmfPkg/CloudHv/CloudHvX64.dsc
index 4fe7cb5f1b..4d7107fd19 100644
--- a/OvmfPkg/CloudHv/CloudHvX64.dsc
+++ b/OvmfPkg/CloudHv/CloudHvX64.dsc
@@ -403,6 +403,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index 3458926515..ea538fd783 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
 #
@@ -313,6 +313,7 @@
   
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
   LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxDxeLib.inf
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
@@ -577,6 +578,7 @@
 
   UefiCpuPkg/CpuDxe/CpuDxe.inf {
 
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   #
   # Directly use DxeMpInitLib. It depends on DxeMpInitLibMpDepLib which
   # checks the Protocol of gEfiMpInitLibMpDepProtocolGuid.
diff --git a/OvmfPkg/Microvm/MicrovmX64.dsc b/OvmfPkg/Microvm/MicrovmX64.dsc
index 93d4cf3da2..b04c8e6936 100644
--- a/OvmfPkg/Microvm/MicrovmX64.dsc
+++ b/OvmfPkg/Microvm/MicrovmX64.dsc
@@ -1,7 +1,7 @@
 ## @file
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform
 #
-#  Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.
 #  (C) Copyright 2016 Hewlett Packard Enterprise Development LP
 #  Copyright (c) Microsoft Corporation.
 #
@@ -402,6 +402,7 @@
   PciLib|MdePkg/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
   PciPcdProducerLib|OvmfPkg/Fdt/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf
   
PciExpressLib|OvmfPkg/Library/BaseCachingPciExpressLib/BaseCachingPciExpressLib.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
   QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/DxeQemuFwCfgS3LibFwCfg.inf
   QemuLoadImageLib|OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index aca292ce83..894ce1867d 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -414,6 +414,7 @@
   DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
 !endif
   PciLib|OvmfPkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf
+  CpuPageTableLib|UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableLib.inf
   

[edk2-devel] [PATCH 2/4] UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.

2022-12-19 Thread Yuanhao Xie
During the finalization of Mp initialization before booting into the OS,
 depending on whether Mwait is supported or not, AsmRelocateApLoop
 places Aps in MWAIT-loop or HLT-loop.

Since paging is necessary for long mode, the original implementation of
moving APs to 32-bit was to disable paging to ensure that the booting
does not crash.

The current modification creates a page table in reserved memory,
avoiding switching modes and reclaiming memory by OS. This modification
is only for 64 bit mode.

More specifically, we keep the AMD logic as the original code flow,
extract and update the Intel-related code, where the APs would stay
in 64-bit, and run in a Mwait or Hlt loop until the OS wake them up.

Signed-off-by: Ray Ni 
Signed-off-by: Yuanhao Xie 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf |   7 +-
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   |  85 -
 .../Library/MpInitLib/Ia32/CreatePageTable.c  |  27 +++
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  19 +-
 .../Library/MpInitLib/X64/CreatePageTable.c   |  75 
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 171 +++---
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 7 files changed, 185 insertions(+), 200 deletions(-)
 create mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c
 create mode 100644 UefiCpuPkg/Library/MpInitLib/X64/CreatePageTable.c

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf 
b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
index cd07de3a3c..8c8b81d933 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf
@@ -1,7 +1,7 @@
 ## @file
 #  MP Initialize Library instance for DXE driver.
 #
-#  Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
+#  Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -24,9 +24,11 @@
 [Sources.IA32]
   Ia32/AmdSev.c
   Ia32/MpFuncs.nasm
+  Ia32/CreatePageTable.c
 
 [Sources.X64]
   X64/AmdSev.c
+  X64/CreatePageTable.c
   X64/MpFuncs.nasm
 
 [Sources.common]
@@ -57,6 +59,9 @@
   CcExitLib
   MicrocodeLib
 
+[LibraryClasses.X64]
+  CpuPageTableLib
+
 [Protocols]
   gEfiTimerArchProtocolGuid ## SOMETIMES_CONSUMES
 
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 445e0853d2..1f98a459b6 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -16,6 +16,7 @@
 #include 
 #include 
 
+#include 
 #include 
 
 #define  AP_SAFE_STACK_SIZE  128
@@ -28,6 +29,7 @@ volatile BOOLEAN  mStopCheckAllApsStatus   = TRUE;
 VOID  *mReservedApLoopFunc = NULL;
 UINTN mReservedTopOfApStack;
 volatile UINT32   mNumberToFinish = 0;
+UINTN mApPageTable;
 
 //
 // Begin wakeup buffer allocation below 0x88000
@@ -407,12 +409,9 @@ RelocateApLoop (
 AsmRelocateApLoopFunc (
   MwaitSupport,
   CpuMpData->ApTargetCState,
-  CpuMpData->PmCodeSegment,
   StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
   (UINTN),
-  CpuMpData->Pm16CodeSegment,
-  CpuMpData->SevEsAPBuffer,
-  CpuMpData->WakeupBuffer
+  mApPageTable
   );
   }
 
@@ -477,7 +476,6 @@ InitMpGlobalData (
   )
 {
   EFI_STATUS   Status;
-  EFI_PHYSICAL_ADDRESS Address;
   UINTNApSafeBufferSize;
   UINTNIndex;
   EFI_GCD_MEMORY_SPACE_DESCRIPTOR  MemDesc;
@@ -545,60 +543,45 @@ InitMpGlobalData (
   // Allocating it in advance since memory services are not available in
   // Exit Boot Services callback function.
   //
-  ApSafeBufferSize = EFI_PAGES_TO_SIZE (
-   EFI_SIZE_TO_PAGES (
- CpuMpData->AddressMap.RelocateApLoopFuncSize
- )
-   );
-  Address = BASE_4GB - 1;
-  Status  = gBS->AllocatePages (
-   AllocateMaxAddress,
-   EfiReservedMemoryType,
-   EFI_SIZE_TO_PAGES (ApSafeBufferSize),
-   
-   );
-  ASSERT_EFI_ERROR (Status);
-
-  mReservedApLoopFunc = (VOID *)(UINTN)Address;
-  ASSERT (mReservedApLoopFunc != NULL);
-
-  //
-  // Make sure that the buffer memory is executable if NX protection is enabled
-  // for EfiReservedMemoryType.
-  //
-  // TODO: Check EFI_MEMORY_XP bit set or not once it's available in DXE GCD
-  //   service.
+  // ++
+  // | Ap Loop|
+  // ++
+  // | Stack * N  |
+  // ++ (low address)
   //
-  Status = gDS->GetMemorySpaceDescriptor (Address, );
-  if (!EFI_ERROR (Status)) {
-gDS->SetMemorySpaceAttributes (
-   Address,
-   ApSafeBufferSize,
-   MemDesc.Attributes & (~EFI_MEMORY_XP)
-   );
-  }
-
   ApSafeBufferSize = EFI_PAGES_TO_SIZE (
EFI_SIZE_TO_PAGES (
 

[edk2-devel] [PATCH 1/4] UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd

2022-12-19 Thread Yuanhao Xie
AsmRelocateApLoop is replicated for future Intel Logic Extraction,
further brings AP into 64-bit, and enables paging.

Signed-off-by: Yuanhao Xie 
---
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   |  52 +++---
 UefiCpuPkg/Library/MpInitLib/MpEqu.inc|   2 +
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  27 +++
 UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm  | 169 ++
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm |   5 +
 5 files changed, 235 insertions(+), 20 deletions(-)

diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index a84e9e33ba..445e0853d2 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -1,7 +1,7 @@
 /** @file
   MP initialize support functions for DXE phase.
 
-  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.
+  Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -378,32 +378,44 @@ RelocateApLoop (
   IN OUT VOID  *Buffer
   )
 {
-  CPU_MP_DATA   *CpuMpData;
-  BOOLEAN   MwaitSupport;
-  ASM_RELOCATE_AP_LOOP  AsmRelocateApLoopFunc;
-  UINTN ProcessorNumber;
-  UINTN StackStart;
+  CPU_MP_DATA   *CpuMpData;
+  BOOLEAN   MwaitSupport;
+  ASM_RELOCATE_AP_LOOP  AsmRelocateApLoopFunc;
+  ASM_RELOCATE_AP_LOOP_AMD  AsmRelocateApLoopFuncAmd;
+  UINTN ProcessorNumber;
+  UINTN StackStart;
 
   MpInitLibWhoAmI ();
   CpuMpData= GetCpuMpData ();
   MwaitSupport = IsMwaitSupport ();
-  if (CpuMpData->UseSevEsAPMethod) {
-StackStart = CpuMpData->SevEsAPResetStackStart;
+  if (StandardSignatureIsAuthenticAMD ()) {
+StackStart   = CpuMpData->UseSevEsAPMethod ? 
CpuMpData->SevEsAPResetStackStart : mReservedTopOfApStack;
+AsmRelocateApLoopFuncAmd = 
(ASM_RELOCATE_AP_LOOP_AMD)(UINTN)mReservedApLoopFunc;
+AsmRelocateApLoopFuncAmd (
+  MwaitSupport,
+  CpuMpData->ApTargetCState,
+  CpuMpData->PmCodeSegment,
+  StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
+  (UINTN),
+  CpuMpData->Pm16CodeSegment,
+  CpuMpData->SevEsAPBuffer,
+  CpuMpData->WakeupBuffer
+  );
   } else {
-StackStart = mReservedTopOfApStack;
+StackStart= mReservedTopOfApStack;
+AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc;
+AsmRelocateApLoopFunc (
+  MwaitSupport,
+  CpuMpData->ApTargetCState,
+  CpuMpData->PmCodeSegment,
+  StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
+  (UINTN),
+  CpuMpData->Pm16CodeSegment,
+  CpuMpData->SevEsAPBuffer,
+  CpuMpData->WakeupBuffer
+  );
   }
 
-  AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc;
-  AsmRelocateApLoopFunc (
-MwaitSupport,
-CpuMpData->ApTargetCState,
-CpuMpData->PmCodeSegment,
-StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
-(UINTN),
-CpuMpData->Pm16CodeSegment,
-CpuMpData->SevEsAPBuffer,
-CpuMpData->WakeupBuffer
-);
   //
   // It should never reach here
   //
diff --git a/UefiCpuPkg/Library/MpInitLib/MpEqu.inc 
b/UefiCpuPkg/Library/MpInitLib/MpEqu.inc
index ebadcc6fb3..ea202d4aef 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpEqu.inc
+++ b/UefiCpuPkg/Library/MpInitLib/MpEqu.inc
@@ -26,6 +26,8 @@ struc MP_ASSEMBLY_ADDRESS_MAP
   .RendezvousFunnelSize  CTYPE_UINTN 1
   .RelocateApLoopFuncAddress CTYPE_UINTN 1
   .RelocateApLoopFuncSizeCTYPE_UINTN 1
+  .RelocateApLoopFuncAddressAmd  CTYPE_UINTN 1
+  .RelocateApLoopFuncSizeAmd CTYPE_UINTN 1
   .ModeTransitionOffset  CTYPE_UINTN 1
   .SwitchToRealNoNxOffsetCTYPE_UINTN 1
   .SwitchToRealPM16ModeOffsetCTYPE_UINTN 1
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index f5086e497e..1102003a93 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -179,6 +179,8 @@ typedef struct {
   UINTNRendezvousFunnelSize;
   UINT8*RelocateApLoopFuncAddress;
   UINTNRelocateApLoopFuncSize;
+  UINT8*RelocateApLoopFuncAddressAmd;
+  UINTNRelocateApLoopFuncSizeAmd;
   UINTNModeTransitionOffset;
   UINTNSwitchToRealNoNxOffset;
   UINTNSwitchToRealPM16ModeOffset;
@@ -346,6 +348,31 @@ typedef
 
 extern EFI_GUID  mCpuInitMpLibHobGuid;
 
+/**
+  Assembly code to place AP into safe loop mode for Amd.
+  Place AP into targeted C-State if MONITOR is supported, otherwise
+  place AP into hlt state.
+  Place AP in protected mode if the current is long mode. Due to AP maybe
+  wakeup by some hardware event. It could avoid accessing page table that
+  may not available during booting to OS.
+  @param[in] MwaitSupportTRUE indicates MONITOR is supported.
+ FALSE indicates MONITOR is not supported.
+  @param[in] ApTargetCState  Target 

[edk2-devel] [PATCH 0/4] Put APs in 64 bit long-mode before booting to OS.

2022-12-19 Thread Yuanhao Xie


Yuanhao Xie (4):
  UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
  UefiCpuPkg: Has APs in 64 bit long-mode before booting to OS.
  OvmfPkg: Add CpuPageTableLib required by MpInitLib.
  UefiPayloadPkg: Add CpuPageTableLib required by MpInitLib.

 OvmfPkg/AmdSev/AmdSevX64.dsc  |   3 +-
 OvmfPkg/CloudHv/CloudHvX64.dsc|   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc  |   4 +-
 OvmfPkg/Microvm/MicrovmX64.dsc|   3 +-
 OvmfPkg/OvmfPkgIa32X64.dsc|   1 +
 OvmfPkg/OvmfPkgX64.dsc|   2 +
 OvmfPkg/OvmfXen.dsc   |   3 +-
 UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf |   7 +-
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   | 129 ++---
 .../Library/MpInitLib/Ia32/CreatePageTable.c  |  27 +++
 UefiCpuPkg/Library/MpInitLib/MpEqu.inc|   2 +
 UefiCpuPkg/Library/MpInitLib/MpLib.h  |  46 -
 UefiCpuPkg/Library/MpInitLib/X64/AmdSev.nasm  | 169 +
 .../Library/MpInitLib/X64/CreatePageTable.c   |  75 
 UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 176 --
 UefiCpuPkg/UefiCpuPkg.dsc |   1 +
 UefiPayloadPkg/UefiPayloadPkg.dsc |   1 +
 17 files changed, 430 insertions(+), 220 deletions(-)
 create mode 100644 UefiCpuPkg/Library/MpInitLib/Ia32/CreatePageTable.c
 create mode 100644 UefiCpuPkg/Library/MpInitLib/X64/CreatePageTable.c

-- 
2.36.1.windows.1



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




Re: [edk2-devel] [PATCH] BaseTools: Generate deps for Arm targets

2022-12-19 Thread Jake Garver via groups.io
Resend with BaseTools maintainers CC'd.

Hi, folks.  Is there interest in accepting this change?  Any comments?

Thanks,
Jake

From: Jake Garver 
Sent: Monday, December 19, 2022 11:36 AM
To: devel@edk2.groups.io ; Jeff Brasen 
; Ashish Singhal 
Subject: Re: [PATCH] BaseTools: Generate deps for Arm targets

Hi, folks.  Is there interest in accepting this change?  Any comments?

Thanks,
Jake

From: Jake Garver 
Sent: Thursday, December 8, 2022 11:22 AM
To: devel@edk2.groups.io ; Jeff Brasen 
; Ashish Singhal 
Cc: Jake Garver 
Subject: [PATCH] BaseTools: Generate deps for Arm targets

Prior to this change, deps were not generated for Arm and AARCH64
libraries when MODULE_TYPE was BASE, SEC, PEI_CORE, or PIEM. That
resulted in bad incremental builds.

Signed-off-by: Jake Garver 
Reviewed-by: Jeff Brasen 
---
 BaseTools/Conf/build_rule.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index af4819de92..ec83638144 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -145,7 +145,7 @@
 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj

 
-"$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
+"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) 
${src}

 [C-Header-File]
 
--
2.17.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97570): https://edk2.groups.io/g/devel/message/97570
Mute This Topic: https://groups.io/mt/95541348/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] OvmfPkg/OvmfXen: Build platform info HOB in XenPlatformPei

2022-12-19 Thread Anthony PERARD via groups.io
From: Anthony PERARD 

Copy the function BuildPlatformInfoHob() from OvmfPkg/PlatformPei.

QemuFwCfgLib expect this HOB to be present, or fails to do anything.
InternalQemuFwCfgIsAvailable() from QemuFwCfgPeiLib module will not
check if the HOB is actually present for example and try to use a NULL
pointer.

Fixes: cda98df16228 ("OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + 
mQemuFwCfgDmaSupported")
Signed-off-by: Anthony PERARD 
---
 OvmfPkg/XenPlatformPei/Platform.h |  1 +
 OvmfPkg/XenPlatformPei/Platform.c | 20 
 2 files changed, 21 insertions(+)

diff --git a/OvmfPkg/XenPlatformPei/Platform.h 
b/OvmfPkg/XenPlatformPei/Platform.h
index 039af50ffa32..7b4de128e713 100644
--- a/OvmfPkg/XenPlatformPei/Platform.h
+++ b/OvmfPkg/XenPlatformPei/Platform.h
@@ -12,6 +12,7 @@
 #define _PLATFORM_PEI_H_INCLUDED_
 
 #include 
+#include 
 
 VOID
 AddIoMemoryBaseSizeHob (
diff --git a/OvmfPkg/XenPlatformPei/Platform.c 
b/OvmfPkg/XenPlatformPei/Platform.c
index 2d97a41ca78e..6c1886c158b5 100644
--- a/OvmfPkg/XenPlatformPei/Platform.c
+++ b/OvmfPkg/XenPlatformPei/Platform.c
@@ -17,6 +17,7 @@
 //
 // The Library classes this module consumes
 //
+#include 
 #include 
 #include 
 #include 
@@ -409,6 +410,20 @@ DebugDumpCmos (
   }
 }
 
+EFI_HOB_PLATFORM_INFO *
+BuildPlatformInfoHob (
+  VOID
+  )
+{
+  EFI_HOB_PLATFORM_INFO  PlatformInfoHob;
+  EFI_HOB_GUID_TYPE  *GuidHob;
+
+  ZeroMem (, sizeof PlatformInfoHob);
+  BuildGuidDataHob (, , sizeof 
(EFI_HOB_PLATFORM_INFO));
+  GuidHob = GetFirstGuidHob ();
+  return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);
+}
+
 /**
   Perform Platform PEI initialization.
 
@@ -429,6 +444,11 @@ InitializeXenPlatform (
 
   DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
 
+  //
+  // Platform Info HOB used by QemuFw libraries
+  //
+  BuildPlatformInfoHob ();
+
   DebugDumpCmos ();
 
   if (!XenDetect ()) {
-- 
Anthony PERARD



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




Re: [edk2-devel] [PATCH] BaseTools: Generate deps for Arm targets

2022-12-19 Thread Jake Garver via groups.io
Hi, folks.  Is there interest in accepting this change?  Any comments?

Thanks,
Jake

From: Jake Garver 
Sent: Thursday, December 8, 2022 11:22 AM
To: devel@edk2.groups.io ; Jeff Brasen 
; Ashish Singhal 
Cc: Jake Garver 
Subject: [PATCH] BaseTools: Generate deps for Arm targets

Prior to this change, deps were not generated for Arm and AARCH64
libraries when MODULE_TYPE was BASE, SEC, PEI_CORE, or PIEM. That
resulted in bad incremental builds.

Signed-off-by: Jake Garver 
Reviewed-by: Jeff Brasen 
---
 BaseTools/Conf/build_rule.template | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Conf/build_rule.template 
b/BaseTools/Conf/build_rule.template
index af4819de92..ec83638144 100755
--- a/BaseTools/Conf/build_rule.template
+++ b/BaseTools/Conf/build_rule.template
@@ -145,7 +145,7 @@
 $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj

 
-"$(CC)" $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) ${src}
+"$(CC)" $(DEPS_FLAGS) $(CC_FLAGS) $(CC_XIPFLAGS) -c -o ${dst} $(INC) 
${src}

 [C-Header-File]
 
--
2.17.1



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




Re: [edk2-devel] [PATCH V2 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang

Regards,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Monday, December 19, 2022 10:52 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH V2 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

External email: Use caution opening links or attachments


From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..c51f76a6185 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatfor
+++ mHostInterfaceLib.c
@@ -3,6 +3,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (

   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
--
2.37.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97567): https://edk2.groups.io/g/devel/message/97567
Mute This Topic: https://groups.io/mt/95766053/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/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Nickle Wang via groups.io
Thanks for addressing my comment.

Reviewed-by: Nickle Wang

Regards,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Monday, December 19, 2022 10:51 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI 
notification

External email: Use caution opening links or attachments


From: Abner Chang 

For some use cases, Redfish host interface table relies on the certain EFI 
protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the SMBIOS type 42h 
record at driver entry point. This patch adds the mechanism in Redfish host 
interface DXE driver to listen to EFI protocol installed by platform library 
that indicates the necessary information is ready for building SMBIOS 42h 
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 71 ++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterf
+++ aceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights 
+ reserved.

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

@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (  {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  

Re: [edk2-devel] [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

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

It could be removed by accident, V2 is sent.

Thanks
Abner
> -Original Message-
> From: Nickle Wang 
> Sent: Monday, December 19, 2022 10:39 PM
> To: Chang, Abner ; devel@edk2.groups.io
> Cc: Igor Kulchytskyy 
> Subject: RE: [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI
> notification
> 
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
> 
> 
> Hi Abner,
> 
> @@ -119,7 +123,7 @@ RedfishCreateSmbiosTable42 (
>  } else {
>NewProtocolRecords = ReallocatePool (CurrentProtocolsDataLength,
> NewProtocolsDataLength, (VOID *)ProtocolRecords);
>if (NewProtocolRecords == NULL) {
> -DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host
> interface protocol data.", __FUNCTION__));
> +DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish
> + host interface protocol data."));
> 
> I think we need "__FUNCTION__" above. Not sure why you remove it but "%a"
> relies on it.
> 
> Thanks,
> Nickle
> 
> -Original Message-
> From: abner.ch...@amd.com 
> Sent: Monday, December 19, 2022 10:17 PM
> To: devel@edk2.groups.io
> Cc: Nickle Wang ; Igor Kulchytskyy 
> Subject: [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI
> notification
> 
> External email: Use caution opening links or attachments
> 
> 
> From: Abner Chang 
> 
> For some use cases, Redfish host interface table relies on the certain EFI
> protocols installation at the driver connection.
> Redfish host interface DXE driver is not able to build the SMBIOS type 42h 
> record
> at driver entry point. This patch adds the mechanism in Redfish host interface
> DXE driver to listen to EFI protocol installed by platform library that 
> indicates the
> necessary information is ready for building SMBIOS 42h record.
> 
> Signed-off-by: Abner Chang 
> Cc: Nickle Wang 
> Cc: Igor Kulchytskyy 
> ---
>  .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
>  .../PlatformHostInterfaceLibNull.c| 26 ++-
>  .../RedfishHostInterfaceDxe.c | 73 ++-
>  3 files changed, 119 insertions(+), 7 deletions(-)
> 
> diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
> b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
> index 8d8389b9647..fa9f2d64eea 100644
> --- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
> +++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
> @@ -2,6 +2,7 @@
>Definitinos of RedfishHostInterfaceDxe driver.
> 
>(C) Copyright 2020 Hewlett Packard Enterprise Development LP
> +  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights
> + reserved.
> 
>SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> @@ -19,7 +20,7 @@
>  /**
>Get platform Redfish host interface device descriptor.
> 
> -  @param[in] DeviceType Pointer to retrieve device type.
> +  @param[out] DeviceTypePointer to retrieve device type.
>@param[out] DeviceDescriptor  Pointer to retrieve
> REDFISH_INTERFACE_DATA, caller has to free
>  this memory using FreePool().
>@retval EFI_SUCCESS Device descriptor is returned successfully in
> DeviceDescriptor.
> @@ -28,7 +29,7 @@
>  **/
>  EFI_STATUS
>  RedfishPlatformHostInterfaceDeviceDescriptor (
> -  IN UINT8*DeviceType,
> +  OUT UINT8*DeviceType,
>OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
>);
> 
> @@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
>@param[in, out] ProtocolRecord  Pointer to retrieve the first or the next
> protocol record.
>caller has to free the new protocol record 
> returned from
>this function using FreePool().
> -  param[in] IndexOfProtocolData   The index of protocol data.
> +  @param[in] IndexOfProtocolData  The index of protocol data.
> 
>@retval EFI_SUCCESS Protocol records are all returned.
>@retval EFI_NOT_FOUND   No more protocol records.
> @@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
>IN UINT8  IndexOfProtocolData
>);
> 
> +/**
> +  Get the EFI protocol GUID installed by platform library which
> +  indicates the necessary information is ready for building
> +  SMBIOS 42h record.
> +
> +  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
> +GUID.
> +
> +  @retval EFI_SUCCESS  Notification is required for building up
> +   SMBIOS type 42h record.
> +  @retval EFI_UNSUPPORTED  Notification is not required for building up
> +   SMBIOS type 42h record.
> +  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
> +  @retval Others   Other errors.
> +**/
> +
> +EFI_STATUS
> 

[edk2-devel] [PATCH V2 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
Reviewed-by: Nickle Wang 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..c51f76a6185 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
-- 
2.37.1.windows.1



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




[edk2-devel] [PATCH V2 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 71 ++-
 3 files changed, 118 insertions(+), 6 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.
 
-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );
 
@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.
 
   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );
 
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (
 {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval 

Re: [edk2-devel] [PATCH 1/1] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning

2022-12-19 Thread Yao, Jiewen



> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Gerd
> Hoffmann
> Sent: Monday, December 19, 2022 4:53 PM
> To: Yao, Jiewen 
> Cc: devel@edk2.groups.io; Justen, Jordan L ; Ard
> Biesheuvel ; Oliver Steffen
> ; Pawel Polawski 
> Subject: Re: [edk2-devel] [PATCH 1/1]
> OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning
> 
> On Sat, Dec 17, 2022 at 03:10:25AM +, Yao, Jiewen wrote:
> > Hi Gerd
> > I would like to clarify a couple of things:
> >
> > 1) "Using these builds with writable flash is not secure."
> >
> > Whenever we say "secure" or "not secure", we need align the threat model
> at first.
> > What component is trusted? Which is not trusted? Who is adversary? With
> which capability? Under which attack scenario?
> 
> Well, the OS can write directly to flash, bypassing the firmware.  It
> can update secure boot efi variables without the firmware enforcing the
> usual restrictions (KEK signature being required for db/dbx updates
> etc).

[Jiewen] I would say: It is the typical use case. But not the only use case.
Typically, the BIOS shall configure the flash to prevent OS directly to flash, 
with SMM in this case. I do not disagree.
That feature fully really on the hardware (on a real platform) or VMM (on a 
virtual platform).

However, in confidential computing use case, the flash is controlled by the 
untrusted entity - VMM.
It is *impossible* to lock down the flash, even with SMM enabled. That is 
because the VMM is also emulating SMM.
To rely on an untrusted entity (VMM) to provide security protection (e.g. SMM) 
is meaningless.

The best way we can do is to enable measured boot together with secure boot.
As such, no matter how VMM or untrusted OS modifies the SecureBoot variable, it 
will be recorded by measured boot mechanism and detected in attestation later.
In summary, Secure boot in CC cannot resist the policy override, but Measured 
boot in CC will detect such override, and mitigate such threat.
That is fine, because it is meaningless to enable CC without measured boot.


> 
> > If we are going to say something like that, we need a full description. Just
> saying: "not secure" is not enough.
> 
> We simply don't get the protection secure boot is supposed to provide.
> 
> > 3) What is definition of "stateless secure boot configuration" ?
> > What does you mean "stateless"? Do you mean "SMM_REQUIRE=FALSE" or
> something else?
> 
> "stateless" means we don't have persistent efi variables.
> 
> > Then why not call it as simple as "secure boot without SMM" ?
> > I don't understand how "SMM_REQUIRE=FALSE" will contribute "stateless".
> 
> Secure boot in OVMF in 2022-08 + older requires flash memory as efi
> variables storage and SMM mode support to enforce all efi variable
> updates being handled by the firmware.
> 
> Starting with 2022-11 it is also possible to use secure boot without SNN
> mode and with the emulated variable store in RAM.  Min added that for
> IntelTdx.  The firmware can't enforce variable update rules in that
> case, but that is compensated by initializing the emulated variable
> store content with a pristine copy from ROM on each boot.  So the OS can
> tamper with the efi variables, but it can't attack the system that way
> because any changes done are wiped on reset, before the firmware looks
> at those variables again when checking efi binary signatures.  This also
> means any regular efi variable updates (like setting Boot* variables on
> install) are wiped on reset too.  This is where the term "stateless"
> comes from.
> 
> I don't see how "secure boot without SMM" is easier to understand than
> "stateless".

[Jiewen] "stateless" is a new term introduced in this patch. Not in UEFI spec, 
nor in EDKII.
If you want to use it, please define it clearly. At least, I don't understand.

>  It also is x64-specific.

[Jiewen] I don't understand why it is x64-specific.

>  But the idea to give up variable
> persistence to get secure boot support without processor support for a
> separate privilege level can work on other platforms too.  ArmVirt for
> example could get secure boot support that way without depending on
> TrustZone.



> 
> > 4) What is the purpose of "Log a warning" ?
> > Is that to tell people, DON'T DO IT?
> 
> Yes.

[Jiewen] Disagree. It can work together with measured boot in CC use case.
If you really really want to add something, you should also check if CC is 
enabled.

> 
> Maybe it's better to refuse to boot in that case, 
[Jiewen] You may refuse in non-CC case. But it is legal in CC case.

> a warning in
> a logfile is easily missed.
[Jiewen] Yes, that is why I don't like WARNING in log.
I think we had better describe it in readme.

> 
> In 2022-08 and older the world is relatively simple.  We have
> three possible build configurations
> 
>   (1) SECURE_BOOT_ENABLE=FALSE SMM_REQUIRE=FALSE
>   Build without secure boot support.
> 
>   (2) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=TRUE
>   Build with secure boot 

Re: [edk2-devel] [PATCH 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Nickle Wang via groups.io
Reviewed-by: Nickle Wang

Regards,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Monday, December 19, 2022 10:17 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

External email: Use caution opening links or attachments


From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..c51f76a6185 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -3,6 +3,7 @@

   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

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

@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (

   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
--
2.37.1.windows.1



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




Re: [edk2-devel] [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Nickle Wang via groups.io
Hi Abner,

@@ -119,7 +123,7 @@ RedfishCreateSmbiosTable42 (
 } else {
   NewProtocolRecords = ReallocatePool (CurrentProtocolsDataLength, 
NewProtocolsDataLength, (VOID *)ProtocolRecords);
   if (NewProtocolRecords == NULL) {
-DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host 
interface protocol data.", __FUNCTION__));
+DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host 
interface protocol data."));

I think we need "__FUNCTION__" above. Not sure why you remove it but "%a" 
relies on it.

Thanks,
Nickle

-Original Message-
From: abner.ch...@amd.com  
Sent: Monday, December 19, 2022 10:17 PM
To: devel@edk2.groups.io
Cc: Nickle Wang ; Igor Kulchytskyy 
Subject: [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI 
notification

External email: Use caution opening links or attachments


From: Abner Chang 

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 73 ++-
 3 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

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

@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.

-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );

@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.

   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );

+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib

   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.

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

@@ -23,7 

[edk2-devel] [PATCH 2/2] EmulatorPkg/RedfishHostInterface: Add NULL function

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

Add NULL function
RedfishPlatformHostInterfaceNotification that returns
EFI_UNSUPPORTED.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../RedfishPlatformHostInterfaceLib.c | 24 +++
 1 file changed, 24 insertions(+)

diff --git 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
index 3f053307a62..c51f76a6185 100644
--- 
a/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
+++ 
b/EmulatorPkg/Library/RedfishPlatformHostInterfaceLib/RedfishPlatformHostInterfaceLib.c
@@ -3,6 +3,7 @@
 
   Copyright (c) 2019, Intel Corporation. All rights reserved.
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -544,3 +545,26 @@ RedfishPlatformHostInterfaceConstructor (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  )
+{
+  return EFI_UNSUPPORTED;
+}
-- 
2.37.1.windows.1



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




[edk2-devel] [PATCH 1/2] RedfishPkg/RedfishHostInterface: Platform Redfish HI notification

2022-12-19 Thread Chang, Abner via groups.io
From: Abner Chang 

For some use cases, Redfish host interface table relies on
the certain EFI protocols installation at the driver connection.
Redfish host interface DXE driver is not able to build the
SMBIOS type 42h record at driver entry point. This patch adds
the mechanism in Redfish host interface DXE driver to listen
to EFI protocol installed by platform library that indicates
the necessary information is ready for building SMBIOS 42h
record.

Signed-off-by: Abner Chang 
Cc: Nickle Wang 
Cc: Igor Kulchytskyy 
---
 .../Include/Library/RedfishHostInterfaceLib.h | 27 ++-
 .../PlatformHostInterfaceLibNull.c| 26 ++-
 .../RedfishHostInterfaceDxe.c | 73 ++-
 3 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h 
b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
index 8d8389b9647..fa9f2d64eea 100644
--- a/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
+++ b/RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
@@ -2,6 +2,7 @@
   Definitinos of RedfishHostInterfaceDxe driver.
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -19,7 +20,7 @@
 /**
   Get platform Redfish host interface device descriptor.
 
-  @param[in] DeviceType Pointer to retrieve device type.
+  @param[out] DeviceTypePointer to retrieve device type.
   @param[out] DeviceDescriptor  Pointer to retrieve REDFISH_INTERFACE_DATA, 
caller has to free
 this memory using FreePool().
   @retval EFI_SUCCESS Device descriptor is returned successfully in 
DeviceDescriptor.
@@ -28,7 +29,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   );
 
@@ -40,7 +41,7 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
   @param[in, out] ProtocolRecord  Pointer to retrieve the first or the next 
protocol record.
   caller has to free the new protocol record 
returned from
   this function using FreePool().
-  param[in] IndexOfProtocolData   The index of protocol data.
+  @param[in] IndexOfProtocolData  The index of protocol data.
 
   @retval EFI_SUCCESS Protocol records are all returned.
   @retval EFI_NOT_FOUND   No more protocol records.
@@ -52,4 +53,24 @@ RedfishPlatformHostInterfaceProtocolData (
   IN UINT8  IndexOfProtocolData
   );
 
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval EFI_ALREADY_STARTED  Platform host information is already ready.
+  @retval Others   Other errors.
+**/
+
+EFI_STATUS
+RedfishPlatformHostInterfaceNotification (
+  OUT EFI_GUID **InformationReadinessGuid
+  );
 #endif
diff --git 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
index b30f9e37a4d..f83f5418d47 100644
--- 
a/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
+++ 
b/RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
@@ -2,6 +2,7 @@
   NULL instace of RedfishPlatformHostInterfaceLib
 
   (C) Copyright 2020 Hewlett Packard Enterprise Development LP
+  Copyright (C) 2022 Advanced Micro Devices, Inc. All rights reserved.
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -23,7 +24,7 @@
 **/
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8*DeviceType,
+  OUT UINT8*DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   )
 {
@@ -51,3 +52,26 @@ RedfishPlatformHostInterfaceProtocolData (
 {
   return EFI_NOT_FOUND;
 }
+
+/**
+  Get the EFI protocol GUID installed by platform library which
+  indicates the necessary information is ready for building
+  SMBIOS 42h record.
+
+  @param[out] InformationReadinessGuid  Pointer to retrive the protocol
+GUID.
+
+  @retval EFI_SUCCESS  Notification is required for building up
+   SMBIOS type 42h record.
+  @retval EFI_UNSUPPORTED  Notification is not required for building up
+   SMBIOS type 42h record.
+  @retval 

Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow for specified CPU names

2022-12-19 Thread Sami Mujawar
Merged as 05da2d24b08b..5fb3f5723a1e

Thanks.

Regards,

Sami Mujawar


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




Re: [edk2-devel] [PATCH] UefiPayloadPkg: Define default values for the DynamicEX PCDs

2022-12-19 Thread Jiading Zhang
Hi.
I commit a PR again, and the PR passed all the test.

https://github.com/tianocore/edk2/pull/3792/commits

Thanks!


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




Re: [edk2-devel] [PATCH] DynamicTablesPkg: Allow for specified CPU names

2022-12-19 Thread Sami Mujawar
Hi Jeff,

I think we can go ahead with this patch for now. We can revisit this with any 
modifications should we have any other requirement that needs addressing.

Reviewed-by: Sami Mujawar 

Regards,

Sami Mujawar


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97555): https://edk2.groups.io/g/devel/message/97555
Mute This Topic: https://groups.io/mt/94869322/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] OvmfPkg/QemuFlashFvbServicesRuntimeDxe: add security warning

2022-12-19 Thread Gerd Hoffmann
On Sat, Dec 17, 2022 at 03:10:25AM +, Yao, Jiewen wrote:
> Hi Gerd
> I would like to clarify a couple of things:
> 
> 1) "Using these builds with writable flash is not secure."
> 
> Whenever we say "secure" or "not secure", we need align the threat model at 
> first.
> What component is trusted? Which is not trusted? Who is adversary? With which 
> capability? Under which attack scenario? 

Well, the OS can write directly to flash, bypassing the firmware.  It
can update secure boot efi variables without the firmware enforcing the
usual restrictions (KEK signature being required for db/dbx updates
etc).

> If we are going to say something like that, we need a full description. Just 
> saying: "not secure" is not enough.

We simply don't get the protection secure boot is supposed to provide.

> 3) What is definition of "stateless secure boot configuration" ?
> What does you mean "stateless"? Do you mean "SMM_REQUIRE=FALSE" or something 
> else?

"stateless" means we don't have persistent efi variables.

> Then why not call it as simple as "secure boot without SMM" ?
> I don't understand how "SMM_REQUIRE=FALSE" will contribute "stateless".

Secure boot in OVMF in 2022-08 + older requires flash memory as efi
variables storage and SMM mode support to enforce all efi variable
updates being handled by the firmware.

Starting with 2022-11 it is also possible to use secure boot without SNN
mode and with the emulated variable store in RAM.  Min added that for
IntelTdx.  The firmware can't enforce variable update rules in that
case, but that is compensated by initializing the emulated variable
store content with a pristine copy from ROM on each boot.  So the OS can
tamper with the efi variables, but it can't attack the system that way
because any changes done are wiped on reset, before the firmware looks
at those variables again when checking efi binary signatures.  This also
means any regular efi variable updates (like setting Boot* variables on
install) are wiped on reset too.  This is where the term "stateless"
comes from.

I don't see how "secure boot without SMM" is easier to understand than
"stateless".  It also is x64-specific.  But the idea to give up variable
persistence to get secure boot support without processor support for a
separate privilege level can work on other platforms too.  ArmVirt for
example could get secure boot support that way without depending on
TrustZone.

> 4) What is the purpose of "Log a warning" ?
> Is that to tell people, DON'T DO IT?

Yes.

Maybe it's better to refuse to boot in that case, a warning in
a logfile is easily missed.

In 2022-08 and older the world is relatively simple.  We have
three possible build configurations

  (1) SECURE_BOOT_ENABLE=FALSE SMM_REQUIRE=FALSE
  Build without secure boot support.

  (2) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=TRUE
  Build with secure boot support, secure.

  (3) SECURE_BOOT_ENABLE=TRUE SMM_REQUIRE=FALSE
  Build with secure boot support, not secure.

Linux Distributions typically provide builds for (1) and (2),
so (3) existing isn't much of a problem in practice because
people typically don't compile edk2 by themself.

In 2022-11 the (3) case is splitted into two:

  (3a) build being used with ROM (or r/o flash):
   -> this is the new "stateless secure boot" mode.
  (3b) build being used with writable flash:
   -> insecure configuration.

Now the same build can be secure or not depending on
runtime configuration.  So this patch tries to catch
(3b) with a runtime check.

take care,
  Gerd



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