Date   

Re: [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

Abner Chang
 

Thanks Liming, could you please also give the reviewed-by.

 

Hi Ard, also need your reviewed-by for ArmPkg. Then this changes could be upstream and finished.

Thanks

Abner

 

 

From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of gaoliming
Sent: Friday, October 8, 2021 11:14 AM
To: Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>; 'edk2-devel-groups-io' <devel@edk2.groups.io>; ardb@...
Cc: 'Ard Biesheuvel' <ardb+tianocore@...>; 'Leif Lindholm' <leif@...>; 'Sami Mujawar' <sami.mujawar@...>; 'Jiewen Yao' <jiewen.yao@...>; 'Jordan Justen' <jordan.l.justen@...>; 'Gerd Hoffmann' <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; 'Sunil V L' <sunilvl@...>; 'Zhiguang Liu' <zhiguang.liu@...>; 'Michael D Kinney' <michael.d.kinney@...>
Subject: 回复: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

Ard and Abner:

 I am OK to add these three PCDs PcdPciMmio32Translation, PcdPciMmio64Translation, PcdPciIoTranslation to MdePkg.

 

Thanks

Liming

发件人: Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
发送时间: 2021106 17:27
收件人: edk2-devel-groups-io <devel@edk2.groups.io>; ardb@...; Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
抄送: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
主题: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

Hi Ard,

I realized there is a problem if we duplicate ArmPkg defined PCD to under OvmfPkg (e.g. PcdPciIoTranslate PCD) when I was duplicating this PCD to OvmfPkg.

FdtPciProducerLib is relocated to OvmfPkg/Fdt and uses PcdPciIoTranslate PCD declared with OvmfPkg namespace. FdtPciProducerLib is also used by both ArmVirtPkg  and RiscVVirtPkg.

ArmVirtPkg uses ArmPciCpuIoDxe provided by ArmPkg however PcdPciIoTranslate used by ArmPciCpuIoDxe  is declared with ArmPkg namespace.

I think this results in the problem because PcdPciIoTranslate(s) that are referred by ArmPkg and ArmVirtPkg come from two different namespaces, right? Unless ArmPciCpuIoDxe uses the one declared in OvmfPkg, but I don't think we want to do this.

Thought? Otherwise, we should still keep the original patch that relocates these PCDs under MdePkg.

 

Thanks

Abner

 

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Abner Chang <abner.chang@...>
Sent: Tuesday, October 5, 2021 11:00 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>; ardb@... <ardb@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
Subject: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

Hi Ard,

This way reduces the impact of MdePkg. We can try it.

 

Thanks

Abner

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Ard Biesheuvel <ardb@...>
Sent: Tuesday, October 5, 2021 5:30 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
Subject: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

On Thu, 30 Sept 2021 at 03:43, Abner Chang <abner.chang@...> wrote:
>
> In V3: Address comments on V2.
> In V2: Remove HPE license on the files that just moved around or
>        the changes in the file are just code removal.
>
> edk2 BZ #: 3665
> edk2 platform corresponding changes will be submitted after
> this pactch set is reviewed.
>
> This pacthes set is to migrate some modules from ArmVirtPkg
> to under OvmfPkg for the upcoming RiscVVirtPkg that can leverage
> those modules without the dependency with Arm*Pkg.
>
> The modules moved from ArmVirtPkg to OvmfPkg are,
> - FdtClientDxe
> - PciPcdProducerLib
> - HighMemDxe
> - QemuFwCfgLib
> - FdtPciHostBridgeLib
> - VirtioFdtDxe
>
> Below PCDs are moved to under MdePkg and leverage by RiscVVirtPkg.
> This change also remove the dependency on ArmPkg of OvmfPkg.
> - PcdPciIoTranslation
> - PcdPciIoTranslation
> - PcdPciMmio32(64)Translation
>
> Signed-off-by: Abner Chang <abner.chang@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Leif Lindholm <leif@...>
> Cc: Sami Mujawar <sami.mujawar@...>
> Cc: Jiewen Yao <jiewen.yao@...>
> Cc: Jordan Justen <jordan.l.justen@...>
> Cc: Gerd Hoffmann <kraxel@...>
> Cc: Daniel Schaefer <daniel.schaefer@...>
> Cc: Sunil V L <sunilvl@...>
> Cc: Liming Gao <gaoliming@...>
> Cc: Zhiguang Liu <zhiguang.liu@...>
> Cc: Michael D Kinney <michael.d.kinney@...>
>
> Abner Chang (12):
>   ArmVirtPkg/FdtClintDxe: Move FdtClientDxe to EmbeddedPkg
>   MdePkg: Add PcdPciIoTranslation PCD
>   ArmPkg: Use PcdPciIoTranslation PCD from MdePkg
>   ArmVirtPkg/FdtPciPcdProducerLib: Relocate PciPcdProducerLib to OvmfPkg
>   ArmVirtPkg/HighMemDxe: Relocate HighMemDxe to OvmfPkg
>   OvmfPkg/HighMemDxe: Add RISC-V in the supported arch.
>   ArmVirtPkg/QemuFwCfgLib: Relocate QemuFwCfgLib to OvmfPkg
>   OvmfPkg/QemuFwCfgLibMMIO: Add RISC-V arch support
>   MdePkg: Add PcdPciMmio32(64)Translation PCDs
>   ArmVirtPkg/FdtPciHostBridgeLib: Relocate FdtPciHostBridgeLib to
>     OvmfPkg/Fdt
>   OvmfPkg/FdtPciHostBridgeLib: Add RISC-V in the supported arch.
>   ArmVirtPkg/VirtioFdtDxe: Relocate VirtioFdtDxe to OvmfPkg/Fdt
>

Hello all,

These patches look ok to me, but I wonder if the MdePkg maintainers
are happy taking these PCD declaration changes. Translations for PCIe
are typically defined per host bridge, and I would rather move away
from using PCDs for this entirely than 'promote' them by carrying them
in MdePkg.

As this issue is somewhat orthogonal to what Abner is trying to fix,
perhaps it is better to avoid MdePkg changes for now, and just
duplicate these PCDs into OvmfPkg. This is reasonable, given that we
know that QEMU only exposes a single host bridge.

The one in ArmPkg can hopefully be removed and replaced with something
that is more appropriate.


>  ArmPkg/ArmPkg.dec                             | 15 ++++++--------
>  ArmVirtPkg/ArmVirtPkg.dec                     |  3 ---
>  EmbeddedPkg/EmbeddedPkg.dec                   |  1 +
>  MdePkg/MdePkg.dec                             | 12 +++++++++++
>  ArmVirtPkg/ArmVirtCloudHv.dsc                 | 18 ++++++++---------
>  ArmVirtPkg/ArmVirtKvmTool.dsc                 | 18 ++++++++---------
>  ArmVirtPkg/ArmVirtQemu.dsc                    | 20 +++++++++----------
>  ArmVirtPkg/ArmVirtQemuKernel.dsc              | 20 +++++++++----------
>  ArmVirtPkg/ArmVirtXen.dsc                     |  2 +-
>  EmbeddedPkg/EmbeddedPkg.dsc                   |  1 +
>  ArmVirtPkg/ArmVirtCloudHv.fdf                 |  6 +++---
>  ArmVirtPkg/ArmVirtKvmTool.fdf                 |  6 +++---
>  ArmVirtPkg/ArmVirtXen.fdf                     |  2 +-
>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc          |  6 +++---
>  .../ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf       |  2 +-
>  .../ArmVirtGicArchLib/ArmVirtGicArchLib.inf   |  1 +
>  .../ArmVirtPL031FdtClientLib.inf              |  1 +
>  .../ArmVirtPsciResetSystemLib.inf             |  1 +
>  .../ArmVirtTimerFdtClientLib.inf              |  1 +
>  .../KvmtoolRtcFdtClientLib.inf                |  1 +
>  .../NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf |  1 +
>  .../NorFlashQemuLib/NorFlashQemuLib.inf       |  1 +
>  .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |  1 +
>  ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.inf        |  1 +
>  .../Drivers}/FdtClientDxe/FdtClientDxe.inf    |  1 -
>  .../FdtPciHostBridgeLib.inf                   | 11 +++++-----
>  .../FdtPciPcdProducerLib.inf                  |  5 ++---
>  .../Fdt}/HighMemDxe/HighMemDxe.inf            |  7 ++++---
>  .../Fdt}/VirtioFdtDxe/VirtioFdtDxe.inf        |  2 +-
>  .../Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf |  6 +++---
>  .../Include/Protocol/FdtClient.h              |  0
>  .../Drivers}/FdtClientDxe/FdtClientDxe.c      |  0
>  .../FdtPciHostBridgeLib/FdtPciHostBridgeLib.c |  0
>  .../FdtPciPcdProducerLib.c                    |  0
>  .../Fdt}/HighMemDxe/HighMemDxe.c              |  3 ++-
>  .../Fdt}/VirtioFdtDxe/VirtioFdtDxe.c          |  0
>  .../Library/QemuFwCfgLib/QemuFwCfgLibMmio.c   |  7 ++++---
>  Maintainers.txt                               |  6 ++++++
>  38 files changed, 106 insertions(+), 83 deletions(-)
>  rename {ArmVirtPkg => EmbeddedPkg/Drivers}/FdtClientDxe/FdtClientDxe.inf (92%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf (77%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf (87%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/HighMemDxe/HighMemDxe.inf (83%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/VirtioFdtDxe/VirtioFdtDxe.inf (92%)
>  rename ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf => OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf (86%)
>  rename {ArmVirtPkg => EmbeddedPkg}/Include/Protocol/FdtClient.h (100%)
>  rename {ArmVirtPkg => EmbeddedPkg/Drivers}/FdtClientDxe/FdtClientDxe.c (100%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c (100%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c (100%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/HighMemDxe/HighMemDxe.c (95%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/VirtioFdtDxe/VirtioFdtDxe.c (100%)
>  rename ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c => OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c (93%)
>
> --
> 2.17.1
>
>
>
>
>
>




回复: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

gaoliming
 

Ard and Abner:

 I am OK to add these three PCDs PcdPciMmio32Translation, PcdPciMmio64Translation, PcdPciIoTranslation to MdePkg.

 

Thanks

Liming

发件人: Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
发送时间: 2021106 17:27
收件人: edk2-devel-groups-io <devel@edk2.groups.io>; ardb@...; Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
抄送: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
主题: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

Hi Ard,

I realized there is a problem if we duplicate ArmPkg defined PCD to under OvmfPkg (e.g. PcdPciIoTranslate PCD) when I was duplicating this PCD to OvmfPkg.

FdtPciProducerLib is relocated to OvmfPkg/Fdt and uses PcdPciIoTranslate PCD declared with OvmfPkg namespace. FdtPciProducerLib is also used by both ArmVirtPkg  and RiscVVirtPkg.

ArmVirtPkg uses ArmPciCpuIoDxe provided by ArmPkg however PcdPciIoTranslate used by ArmPciCpuIoDxe  is declared with ArmPkg namespace.

I think this results in the problem because PcdPciIoTranslate(s) that are referred by ArmPkg and ArmVirtPkg come from two different namespaces, right? Unless ArmPciCpuIoDxe uses the one declared in OvmfPkg, but I don't think we want to do this.

Thought? Otherwise, we should still keep the original patch that relocates these PCDs under MdePkg.

 

Thanks

Abner

 

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Abner Chang <abner.chang@...>
Sent: Tuesday, October 5, 2021 11:00 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>; ardb@... <ardb@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
Subject: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

Hi Ard,

This way reduces the impact of MdePkg. We can try it.

 

Thanks

Abner

 


From: devel@edk2.groups.io <devel@edk2.groups.io> on behalf of Ard Biesheuvel <ardb@...>
Sent: Tuesday, October 5, 2021 5:30 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>; Chang, Abner (HPS SW/FW Technologist) <abner.chang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>; Leif Lindholm <leif@...>; Sami Mujawar <sami.mujawar@...>; Jiewen Yao <jiewen.yao@...>; Jordan Justen <jordan.l.justen@...>; Gerd Hoffmann <kraxel@...>; Schaefer, Daniel <daniel.schaefer@...>; Sunil V L <sunilvl@...>; Liming Gao <gaoliming@...>; Zhiguang Liu <zhiguang.liu@...>; Michael D Kinney <michael.d.kinney@...>
Subject: Re: [edk2-devel] [PATCH V3 00/12] Migrate ArmVirtPkg modules to OvmfPkg

 

On Thu, 30 Sept 2021 at 03:43, Abner Chang <abner.chang@...> wrote:
>
> In V3: Address comments on V2.
> In V2: Remove HPE license on the files that just moved around or
>        the changes in the file are just code removal.
>
> edk2 BZ #: 3665
> edk2 platform corresponding changes will be submitted after
> this pactch set is reviewed.
>
> This pacthes set is to migrate some modules from ArmVirtPkg
> to under OvmfPkg for the upcoming RiscVVirtPkg that can leverage
> those modules without the dependency with Arm*Pkg.
>
> The modules moved from ArmVirtPkg to OvmfPkg are,
> - FdtClientDxe
> - PciPcdProducerLib
> - HighMemDxe
> - QemuFwCfgLib
> - FdtPciHostBridgeLib
> - VirtioFdtDxe
>
> Below PCDs are moved to under MdePkg and leverage by RiscVVirtPkg.
> This change also remove the dependency on ArmPkg of OvmfPkg.
> - PcdPciIoTranslation
> - PcdPciIoTranslation
> - PcdPciMmio32(64)Translation
>
> Signed-off-by: Abner Chang <abner.chang@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Leif Lindholm <leif@...>
> Cc: Sami Mujawar <sami.mujawar@...>
> Cc: Jiewen Yao <jiewen.yao@...>
> Cc: Jordan Justen <jordan.l.justen@...>
> Cc: Gerd Hoffmann <kraxel@...>
> Cc: Daniel Schaefer <daniel.schaefer@...>
> Cc: Sunil V L <sunilvl@...>
> Cc: Liming Gao <gaoliming@...>
> Cc: Zhiguang Liu <zhiguang.liu@...>
> Cc: Michael D Kinney <michael.d.kinney@...>
>
> Abner Chang (12):
>   ArmVirtPkg/FdtClintDxe: Move FdtClientDxe to EmbeddedPkg
>   MdePkg: Add PcdPciIoTranslation PCD
>   ArmPkg: Use PcdPciIoTranslation PCD from MdePkg
>   ArmVirtPkg/FdtPciPcdProducerLib: Relocate PciPcdProducerLib to OvmfPkg
>   ArmVirtPkg/HighMemDxe: Relocate HighMemDxe to OvmfPkg
>   OvmfPkg/HighMemDxe: Add RISC-V in the supported arch.
>   ArmVirtPkg/QemuFwCfgLib: Relocate QemuFwCfgLib to OvmfPkg
>   OvmfPkg/QemuFwCfgLibMMIO: Add RISC-V arch support
>   MdePkg: Add PcdPciMmio32(64)Translation PCDs
>   ArmVirtPkg/FdtPciHostBridgeLib: Relocate FdtPciHostBridgeLib to
>     OvmfPkg/Fdt
>   OvmfPkg/FdtPciHostBridgeLib: Add RISC-V in the supported arch.
>   ArmVirtPkg/VirtioFdtDxe: Relocate VirtioFdtDxe to OvmfPkg/Fdt
>

Hello all,

These patches look ok to me, but I wonder if the MdePkg maintainers
are happy taking these PCD declaration changes. Translations for PCIe
are typically defined per host bridge, and I would rather move away
from using PCDs for this entirely than 'promote' them by carrying them
in MdePkg.

As this issue is somewhat orthogonal to what Abner is trying to fix,
perhaps it is better to avoid MdePkg changes for now, and just
duplicate these PCDs into OvmfPkg. This is reasonable, given that we
know that QEMU only exposes a single host bridge.

The one in ArmPkg can hopefully be removed and replaced with something
that is more appropriate.


>  ArmPkg/ArmPkg.dec                             | 15 ++++++--------
>  ArmVirtPkg/ArmVirtPkg.dec                     |  3 ---
>  EmbeddedPkg/EmbeddedPkg.dec                   |  1 +
>  MdePkg/MdePkg.dec                             | 12 +++++++++++
>  ArmVirtPkg/ArmVirtCloudHv.dsc                 | 18 ++++++++---------
>  ArmVirtPkg/ArmVirtKvmTool.dsc                 | 18 ++++++++---------
>  ArmVirtPkg/ArmVirtQemu.dsc                    | 20 +++++++++----------
>  ArmVirtPkg/ArmVirtQemuKernel.dsc              | 20 +++++++++----------
>  ArmVirtPkg/ArmVirtXen.dsc                     |  2 +-
>  EmbeddedPkg/EmbeddedPkg.dsc                   |  1 +
>  ArmVirtPkg/ArmVirtCloudHv.fdf                 |  6 +++---
>  ArmVirtPkg/ArmVirtKvmTool.fdf                 |  6 +++---
>  ArmVirtPkg/ArmVirtXen.fdf                     |  2 +-
>  ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc          |  6 +++---
>  .../ArmPciCpuIo2Dxe/ArmPciCpuIo2Dxe.inf       |  2 +-
>  .../ArmVirtGicArchLib/ArmVirtGicArchLib.inf   |  1 +
>  .../ArmVirtPL031FdtClientLib.inf              |  1 +
>  .../ArmVirtPsciResetSystemLib.inf             |  1 +
>  .../ArmVirtTimerFdtClientLib.inf              |  1 +
>  .../KvmtoolRtcFdtClientLib.inf                |  1 +
>  .../NorFlashKvmtoolLib/NorFlashKvmtoolLib.inf |  1 +
>  .../NorFlashQemuLib/NorFlashQemuLib.inf       |  1 +
>  .../XenAcpiPlatformDxe/XenAcpiPlatformDxe.inf |  1 +
>  ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.inf        |  1 +
>  .../Drivers}/FdtClientDxe/FdtClientDxe.inf    |  1 -
>  .../FdtPciHostBridgeLib.inf                   | 11 +++++-----
>  .../FdtPciPcdProducerLib.inf                  |  5 ++---
>  .../Fdt}/HighMemDxe/HighMemDxe.inf            |  7 ++++---
>  .../Fdt}/VirtioFdtDxe/VirtioFdtDxe.inf        |  2 +-
>  .../Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf |  6 +++---
>  .../Include/Protocol/FdtClient.h              |  0
>  .../Drivers}/FdtClientDxe/FdtClientDxe.c      |  0
>  .../FdtPciHostBridgeLib/FdtPciHostBridgeLib.c |  0
>  .../FdtPciPcdProducerLib.c                    |  0
>  .../Fdt}/HighMemDxe/HighMemDxe.c              |  3 ++-
>  .../Fdt}/VirtioFdtDxe/VirtioFdtDxe.c          |  0
>  .../Library/QemuFwCfgLib/QemuFwCfgLibMmio.c   |  7 ++++---
>  Maintainers.txt                               |  6 ++++++
>  38 files changed, 106 insertions(+), 83 deletions(-)
>  rename {ArmVirtPkg => EmbeddedPkg/Drivers}/FdtClientDxe/FdtClientDxe.inf (92%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf (77%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciPcdProducerLib/FdtPciPcdProducerLib.inf (87%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/HighMemDxe/HighMemDxe.inf (83%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/VirtioFdtDxe/VirtioFdtDxe.inf (92%)
>  rename ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.inf => OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.inf (86%)
>  rename {ArmVirtPkg => EmbeddedPkg}/Include/Protocol/FdtClient.h (100%)
>  rename {ArmVirtPkg => EmbeddedPkg/Drivers}/FdtClientDxe/FdtClientDxe.c (100%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciHostBridgeLib/FdtPciHostBridgeLib.c (100%)
>  rename {ArmVirtPkg/Library => OvmfPkg/Fdt}/FdtPciPcdProducerLib/FdtPciPcdProducerLib.c (100%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/HighMemDxe/HighMemDxe.c (95%)
>  rename {ArmVirtPkg => OvmfPkg/Fdt}/VirtioFdtDxe/VirtioFdtDxe.c (100%)
>  rename ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c => OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibMmio.c (93%)
>
> --
> 2.17.1
>
>
>
>
>
>





回复: [PATCH] MdeModulePkg/Core/Dxe: Add lock protection in CoreLocateHandleBuffer()

gaoliming
 

Reviewed-by: Liming Gao <gaoliming@...>

-----邮件原件-----
发件人: Bi, Dandan <dandan.bi@...>
发送时间: 2021年10月8日 9:40
收件人: Ma, Hua <hua.ma@...>; devel@edk2.groups.io
抄送: Wang, Jian J <jian.j.wang@...>; Liming Gao
<gaoliming@...>
主题: RE: [PATCH] MdeModulePkg/Core/Dxe: Add lock protection in
CoreLocateHandleBuffer()

Reviewed-by: Dandan Bi <dandan.bi@...>



Thanks,
Dandan

-----Original Message-----
From: Ma, Hua <hua.ma@...>
Sent: Wednesday, September 29, 2021 1:49 PM
To: devel@edk2.groups.io
Cc: Ma, Hua <hua.ma@...>; Wang, Jian J <jian.j.wang@...>;
Liming Gao <gaoliming@...>; Bi, Dandan
<dandan.bi@...>
Subject: [PATCH] MdeModulePkg/Core/Dxe: Add lock protection in
CoreLocateHandleBuffer()

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

Currently, CoreLocateHandleBuffer() follows three steps:
1) get the size of protocol database firstly
2) allocate the buffer based on the size
3) get the protocol database into the buffer There is no lock protection
for
the whole three steps. If a new protocol added in step 2) by other task,
e.g.
(event timer handle USB device hotplug). The size of protocol database
may
be increased and cannot fit into the previous buffer in step 3). The
protocol
database cannot be returned successfully, EFI_BUFFER_TOO_SMALL error
will be returned.

This patch adds the lock to protect the whole three steps.
It can make sure the correct protocol database be returned.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Cc: Dandan Bi <dandan.bi@...>
Signed-off-by: Hua Ma <hua.ma@...>
---
MdeModulePkg/Core/Dxe/Hand/Locate.c | 64
+++++++++++++++++++++++------
1 file changed, 51 insertions(+), 13 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Locate.c
b/MdeModulePkg/Core/Dxe/Hand/Locate.c
index be17f4cbc3..4987c046c6 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Locate.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Locate.c
@@ -86,7 +86,8 @@ CoreGetNextLocateByProtocol (


/**
- Locates the requested handle(s) and returns them in Buffer.
+ Internal function for locating the requested handle(s) and returns
them
in
Buffer.
+ The caller should already have acquired the ProtocolLock.

@param SearchType The type of search to perform to
locate the
handles @@ -104,8 +105,7 @@
CoreGetNextLocateByProtocol (

**/
EFI_STATUS
-EFIAPI
-CoreLocateHandle (
+InternalCoreLocateHandle (
IN EFI_LOCATE_SEARCH_TYPE SearchType,
IN EFI_GUID *Protocol OPTIONAL,
IN VOID *SearchKey OPTIONAL,
@@ -143,11 +143,6 @@ CoreLocateHandle (
ResultBuffer = (IHANDLE **) Buffer;
Status = EFI_SUCCESS;

- //
- // Lock the protocol database
- //
- CoreAcquireProtocolLock ();
-
//
// Get the search function based on type
//
@@ -190,7 +185,6 @@ CoreLocateHandle (
}

if (EFI_ERROR(Status)) {
- CoreReleaseProtocolLock ();
return Status;
}

@@ -247,10 +241,47 @@ CoreLocateHandle (
}
}

- CoreReleaseProtocolLock ();
return Status;
}

+/**
+ Locates the requested handle(s) and returns them in Buffer.
+
+ @param SearchType The type of search to perform to
locate the
+ handles
+ @param Protocol The protocol to search for
+ @param SearchKey Dependant on SearchType
+ @param BufferSize On input the size of Buffer. On
output the
+ size of data returned.
+ @param Buffer The buffer to return the results in
+
+ @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer
size is
+ returned in BufferSize.
+ @retval EFI_INVALID_PARAMETER Invalid parameter
+ @retval EFI_SUCCESS Successfully found the requested
handle(s)
and
+ returns them in Buffer.
+
+**/
+EFI_STATUS
+EFIAPI
+CoreLocateHandle (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID *Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_HANDLE *Buffer
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+ Status = InternalCoreLocateHandle(SearchType, Protocol, SearchKey,
+BufferSize, Buffer);
+ CoreReleaseProtocolLock ();
+ return Status;
+}


/**
@@ -610,7 +641,6 @@ Done:
return Status;
}

-
/**
Function returns an array of handles that support the requested
protocol
in a buffer allocated from pool. This is a version of
CoreLocateHandle()
@@
-657,7 +687,12 @@ CoreLocateHandleBuffer (
BufferSize = 0;
*NumberHandles = 0;
*Buffer = NULL;
- Status = CoreLocateHandle (
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock();
+ Status = InternalCoreLocateHandle (
SearchType,
Protocol,
SearchKey,
@@ -674,15 +709,17 @@ CoreLocateHandleBuffer (
if (Status != EFI_INVALID_PARAMETER) {
Status = EFI_NOT_FOUND;
}
+ CoreReleaseProtocolLock ();
return Status;
}

*Buffer = AllocatePool (BufferSize);
if (*Buffer == NULL) {
+ CoreReleaseProtocolLock ();
return EFI_OUT_OF_RESOURCES;
}

- Status = CoreLocateHandle (
+ Status = InternalCoreLocateHandle (
SearchType,
Protocol,
SearchKey,
@@ -695,6 +732,7 @@ CoreLocateHandleBuffer (
*NumberHandles = 0;
}

+ CoreReleaseProtocolLock ();
return Status;
}

--
2.32.0.windows.2


[edk2-platforms: PATCH 9/9] WhitleySiliconPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl=
atformLib.c | 35 +++++++++--------------------------
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPl=
atformLib.inf | 3 ++-
2 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/=
FspWrapperPlatformLib.c b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrappe=
rPlatformLib/FspWrapperPlatformLib.c
index a6196a78b0..95a1f2a33c 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.c
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.c
@@ -13,7 +13,7 @@
#include <Library/HobLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/LargeVariableReadLib.h>=0D
-=0D
+#include <Library/PeiLib.h>=0D
#include <FspmUpd.h>=0D
#include <Guid/PlatformInfo.h>=0D
#include <Ppi/UpiPolicyPpi.h>=0D
@@ -24,39 +24,22 @@ GetFspNvsBuffer (
)=0D
{=0D
EFI_STATUS Status;=0D
- UINTN FspNvsBufferSize;=0D
- VOID *FspNvsBufferPtr;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
=0D
FspNvsBufferPtr =3D NULL;=0D
FspNvsBufferSize =3D 0;=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageHob=
Guid, &FspNvsBufferSize, NULL);=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- DEBUG ((DEBUG_INFO, "FspNvsBuffer Size =3D %d\n", FspNvsBufferSize));=
=0D
- FspNvsBufferPtr =3D AllocateZeroPool (FspNvsBufferSize);=0D
- if (FspNvsBufferPtr =3D=3D NULL) {=0D
- DEBUG ((DEBUG_ERROR, "Error: Cannot create FspNvsBuffer, out of memo=
ry!\n"));=0D
- ASSERT (FALSE);=0D
- return NULL;=0D
- }=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorageH=
obGuid, &FspNvsBufferSize, FspNvsBufferPtr);=0D
- if (EFI_ERROR (Status)) {=0D
- DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variab=
le Status: %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- return NULL;=0D
- }=0D
-=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
return FspNvsBufferPtr;=0D
-=0D
- } else if (Status =3D=3D EFI_NOT_FOUND) {=0D
- DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
} else {=0D
- DEBUG ((DEBUG_ERROR, "Error: Unable to read FspNvsBuffer UEFI variable=
Status: %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
-=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
return NULL;=0D
}=0D
=0D
+=0D
+}=0D
+=0D
VOID=0D
EFIAPI=0D
UpdateFspmUpdData (=0D
diff --git a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/=
FspWrapperPlatformLib.inf b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrap=
perPlatformLib/FspWrapperPlatformLib.inf
index 3e80ea670c..6ee15ea55f 100644
--- a/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.inf
+++ b/Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrap=
perPlatformLib.inf
@@ -58,11 +58,12 @@
=0D
[Guids]=0D
gEfiPlatformInfoGuid=0D
- gFspNonVolatileStorageHobGuid=0D
+ gFspNvsBufferVariableGuid # CONSUMES=0D
=0D
[LibraryClasses]=0D
PeiServicesLib=0D
LargeVariableReadLib=0D
+ PeiLib=0D
=0D
[Pcd]=0D
gIntelFsp2PkgTokenSpaceGuid.PcdTemporaryRamBase ## CONSUMES=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 8/9] WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

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

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c =
| 29 +++++++++++++++++++++++------
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.in=
f | 4 +++-
Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc =
| 1 +
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3=
NvramSave.c b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S=
3NvramSave.c
index 709c7ad479..ddca492a5a 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.c
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.c
@@ -7,6 +7,7 @@
**/=0D
=0D
#include "S3NvramSave.h"=0D
+#include <Guid/FspNonVolatileStorageHob2.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/LargeVariableReadLib.h>=0D
#include <Library/LargeVariableWriteLib.h>=0D
@@ -80,21 +81,37 @@ SaveFspNonVolatileStorageHob (
Status =3D EFI_SUCCESS;=0D
=0D
DEBUG ((DEBUG_INFO, "Saving FSP / MRC Training Data\n"));=0D
- GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ //=0D
+ // Firstly check version2 FspNvsHob.=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);=0D
if (GuidHob !=3D NULL) {=0D
- HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
- DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ HobData =3D (VOID *) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHo=
b)->NvsDataPtr;=0D
+ DataSize =3D ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsD=
ataLength;=0D
+ } else {=0D
+ //=0D
+ // Fall back to version1 FspNvsHob=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ if (GuidHob !=3D NULL) {=0D
+ HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
+ DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ }=0D
+ }=0D
+ if (HobData !=3D NULL) {=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.Size: %d\n", DataSize));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr: 0x%x\n", HobData));=0D
if (DataSize > 0) {=0D
=0D
//=0D
// Check if the presently saved data is identical to the data given =
by MRC/FSP=0D
//=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStorag=
eHobGuid, &FspNvsBufferSize, NULL);=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariable=
Guid, &FspNvsBufferSize, NULL);=0D
if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
if (FspNvsBufferSize =3D=3D DataSize) {=0D
VariableData =3D AllocatePool (FspNvsBufferSize);=0D
if (VariableData !=3D NULL) {=0D
- Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNonVolatile=
StorageHobGuid, &FspNvsBufferSize, VariableData);=0D
+ Status =3D GetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVa=
riableGuid, &FspNvsBufferSize, VariableData);=0D
if (!EFI_ERROR (Status) && (FspNvsBufferSize =3D=3D DataSize) =
&& (0 =3D=3D CompareMem (HobData, VariableData, DataSize))) {=0D
DataIsIdentical =3D TRUE;=0D
}=0D
@@ -105,7 +122,7 @@ SaveFspNonVolatileStorageHob (
Status =3D EFI_SUCCESS;=0D
=0D
if (!DataIsIdentical) {=0D
- Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNonVolatileStor=
ageHobGuid, TRUE, DataSize, HobData);=0D
+ Status =3D SetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariab=
leGuid, TRUE, DataSize, HobData);=0D
ASSERT_EFI_ERROR (Status);=0D
DEBUG ((DEBUG_INFO, "Saved size of FSP / MRC Training Data: 0x%x\n=
", DataSize));=0D
} else {=0D
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3=
NvramSave.inf b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave=
/S3NvramSave.inf
index e62baa24c4..a77125cf44 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.inf
+++ b/Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSa=
ve.inf
@@ -43,7 +43,9 @@
LargeVariableWriteLib=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid # CONSUMES=0D
+ gFspNonVolatileStorageHobGuid # CONSUMES=0D
+ gFspNonVolatileStorageHob2Guid # CONSUMES=0D
+ gFspNvsBufferVariableGuid # PRODUCES=0D
=0D
[Pcd]=0D
gEfiCpRcPkgTokenSpaceGuid.PcdPeiSyshostMemorySize=0D
diff --git a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc b/Platform/=
Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
index dc3dd0e026..87165103bf 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
+++ b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
@@ -637,6 +637,7 @@
=0D
[LibraryClasses.Common]=0D
DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in=
f=0D
+ PeiLib|MinPlatformPkg/Library/PeiLib/PeiLib.inf=0D
=0D
[Components.IA32]=0D
UefiCpuPkg/SecCore/SecCore.inf=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 7/9] WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---=
------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSili=
conPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---=
------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSili=
conPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 4 ++--
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc =
| 3 +++
Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc =
| 3 +++
6 files changed, 34 insertions(+), 107 deletions(-)

diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiS=
iliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/Whiskeyl=
akeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscU=
pdUpdateLib.c
index a341a58930..ab35bc3f8f 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -17,11 +17,9 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
-#include <Ppi/ReadOnlyVariable2.h>=0D
#include <Guid/MemoryOverwriteControl.h>=0D
#include <PchAccess.h>=0D
=0D
@@ -44,55 +42,18 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
- }=0D
-=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ } else {=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
}=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
=0D
return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Lib=
rary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel=
/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdate=
LibFsp/PeiFspMiscUpdUpdateLib.c
index 145deb5de3..381ef232ea 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -18,11 +18,9 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
-#include <Ppi/ReadOnlyVariable2.h>=0D
#include <Guid/MemoryOverwriteControl.h>=0D
#include <PchAccess.h>=0D
#include <Platform.h>=0D
@@ -46,54 +44,17 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
- }=0D
-=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ } else {=0D
+ DEBUG ((DEBUG_INFO, "Cannot create FSP NVS Buffer, UEFI variable does =
not exist (this is likely a first boot)\n"));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D NULL;=0D
}=0D
=0D
FspmUpd->FspmConfig.TsegSize =3D FixedPcdGet32 (PcdTsegSize=
);=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiS=
iliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/=
WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/Pei=
SiliconPolicyUpdateLibFsp.inf
index 2c90d0cb94..362dc2c995 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconP=
olicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# Provide FSP wrapper platform related function.=0D
#=0D
#=0D
-# Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -82,7 +82,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
PchGbeLib=0D
@@ -132,7 +131,7 @@
gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Lib=
rary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platfo=
rm/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPoli=
cyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 529c2f1253..1a664b1327 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# FSP silicon policy updates for the Up Xtreme board.=0D
#=0D
#=0D
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -136,7 +136,7 @@
gWhiskeylakeOpenBoardPkgTokenSpaceGuid.PcdBoardBomId=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.d=
sc b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
index ee2aedd978..9d08dc3fe4 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
#######################################=0D
PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookL=
ib.inf=0D
=0D
+[LibraryClasses.Common.SEC]=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
+=0D
[LibraryClasses.IA32.SEC]=0D
#######################################=0D
# Platform Package=0D
diff --git a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoa=
rdPkg.dsc b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoar=
dPkg.dsc
index b69cc8deb0..8d25b818ee 100644
--- a/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.d=
sc
+++ b/Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.d=
sc
@@ -142,6 +142,9 @@
#######################################=0D
PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookL=
ib.inf=0D
=0D
+[LibraryClasses.Common.SEC]=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
+=0D
[LibraryClasses.IA32.SEC]=0D
#######################################=0D
# Platform Package=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 6/9] TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Sai Chaganty <rangasai.v.chaganty@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Heng Luo <heng.luo@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLi=
b/PeiFspPolicyInitLib.c | 21 ++++++++++++++++++---
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLi=
b/PeiFspPolicyInitLib.inf | 1 +
Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc =
| 3 +++
3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFsp=
PolicyInitLib/PeiFspPolicyInitLib.c b/Platform/Intel/TigerlakeOpenBoardPkg/=
FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c
index fc523e93d1..938b74e5d8 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.c
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.c
@@ -9,7 +9,9 @@
#include <Library/FspWrapperApiLib.h>=0D
#include <Library/BaseMemoryLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/PeiLib.h>=0D
#include <Ppi/FspmArchConfigPpi.h>=0D
+#include <PolicyUpdateMacro.h>=0D
=0D
VOID=0D
EFIAPI=0D
@@ -70,9 +72,11 @@ SiliconPolicyDonePreMem(
)=0D
{=0D
EFI_STATUS Status;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
#if FixedPcdGet8(PcdFspModeSelection) =3D=3D 0=0D
- FSPM_ARCH_CONFIG_PPI *FspmArchConfigPpi;=0D
- EFI_PEI_PPI_DESCRIPTOR *FspmArchConfigPpiDesc;=0D
+ FSPM_ARCH_CONFIG_PPI *FspmArchConfigPpi;=0D
+ EFI_PEI_PPI_DESCRIPTOR *FspmArchConfigPpiDesc;=0D
=0D
FspmArchConfigPpi =3D (FSPM_ARCH_CONFIG_PPI *) AllocateZeroPool (sizeof =
(FSPM_ARCH_CONFIG_PPI));=0D
if (FspmArchConfigPpi =3D=3D NULL) {=0D
@@ -80,7 +84,6 @@ SiliconPolicyDonePreMem(
return EFI_OUT_OF_RESOURCES;=0D
}=0D
FspmArchConfigPpi->Revision =3D 1;=0D
- FspmArchConfigPpi->NvsBufferPtr =3D NULL;=0D
FspmArchConfigPpi->BootLoaderTolumSize =3D 0;=0D
=0D
FspmArchConfigPpiDesc =3D (EFI_PEI_PPI_DESCRIPTOR *) AllocateZeroPool (s=
izeof (EFI_PEI_PPI_DESCRIPTOR));=0D
@@ -98,6 +101,18 @@ SiliconPolicyDonePreMem(
ASSERT_EFI_ERROR (Status);=0D
#endif=0D
=0D
+ //=0D
+ // Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
+ //=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));=
=0D
+ UPDATE_POLICY (((FSPM_UPD *) FspmUpd)->FspmArchUpd.NvsBufferPtr, FspmA=
rchConfigPpi->NvsBufferPtr, FspNvsBufferPtr);=0D
+ }=0D
+=0D
//=0D
// Install Policy Ready PPI=0D
// While installed, RC assumes the Policy is ready and finalized. So ple=
ase=0D
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFsp=
PolicyInitLib/PeiFspPolicyInitLib.inf b/Platform/Intel/TigerlakeOpenBoardPk=
g/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf
index 708fbac08f..0236ae45ae 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.inf
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyI=
nitLib/PeiFspPolicyInitLib.inf
@@ -181,3 +181,4 @@
gTianoLogoGuid ## CONSUMES=0D
gCnviConfigGuid ## CONSUMES=0D
gHdAudioPreMemConfigGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
diff --git a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPk=
g.dsc b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
index 1adf634034..451492f984 100644
--- a/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
GpioCheckConflictLib|$(PLATFORM_SI_PACKAGE)/IpBlock/Gpio/Library/BaseGpi=
oCheckConflictLibNull/BaseGpioCheckConflictLibNull.inf=0D
!endif=0D
=0D
+[LibraryClasses.Common.SEC]=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
+=0D
[LibraryClasses.IA32.SEC]=0D
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLib/Sec=
TestPointCheckLib.inf=0D
TestPointCheckLib|$(PLATFORM_PACKAGE)/Test/Library/TestPointCheckLibNull=
/TestPointCheckLibNull.inf=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 5/9] KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 ++++++++++----=
-----------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSilicon=
PolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++-----=
---------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSilicon=
PolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
4 files changed, 22 insertions(+), 33 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li=
brary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Inte=
l/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpda=
teLibFsp/PeiFspMiscUpdUpdateLib.c
index d8aff1960f..699f4297fa 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -38,25 +37,21 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
-=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
// Set the DISB bit in PCH (DRAM Initialization Scratchpad Bit - GEN_P=
MCON_A[23]),=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar=
y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Intel/Ka=
bylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/Pe=
iSiliconPolicyUpdateLib.c
index 2dce9be63c..22aadc0221 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -398,8 +398,8 @@ SiliconPolicyUpdatePreMem (
SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig;=0D
MEMORY_CONFIG_NO_CRC *MemConfigNoCrc;=0D
VOID *Buffer;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 SpdAddressTable[4];=0D
=0D
DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));=0D
@@ -430,18 +430,13 @@ SiliconPolicyUpdatePreMem (
// Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI a=
dded in FSP 2.1, hence=0D
// the platform specific S3DataPtr must be used instead.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHob=
Guid - %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- if (!EFI_ERROR (Status)) {=0D
- MiscPeiPreMemConfig->S3DataPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVaria=
bleGuid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGu=
id - %r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize=
));=0D
+ MiscPeiPreMemConfig->S3DataPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Li=
brary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platf=
orm/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPo=
licyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index f8bec0c852..dacec18cd9 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# Provide FSP wrapper platform related function.=0D
#=0D
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -80,7 +80,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
CpuMailboxLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
@@ -141,7 +140,7 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Librar=
y/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/Intel/=
KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/=
PeiSiliconPolicyUpdateLib.inf
index 5c2da68bf9..4b30ba02ea 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -50,7 +50,7 @@
gHsioPciePreMemConfigGuid ## CONSUMES=0D
gHsioSataPreMemConfigGuid ## CONSUMES=0D
gSaMiscPeiPreMemConfigGuid ## CONSUMES=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
=0D
[Pcd]=0D
gSiPkgTokenSpaceGuid.PcdPeiMinMemorySize=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 4/9] KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Jeremy Soller <jeremy@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSilic=
onPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 ++++++++++------=
--------
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSilic=
onPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc =
| 3 +++
3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/=
KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLi=
bFsp/PeiFspMiscUpdUpdateLib.c
index 9d6c0176f6..2158eb299f 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2019 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -16,7 +16,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -38,24 +37,21 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platfor=
m/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicy=
UpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index 463455c90b..ceefe7639e 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/Pei=
SiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# FSP wrapper silicon policy update library.=0D
#=0D
-# Copyright (c) 2019 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2019 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -81,7 +81,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
CpuMailboxLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
@@ -138,7 +137,7 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.ds=
c b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
index 7f276d3512..299c7f18cd 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
+++ b/Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc
@@ -141,6 +141,9 @@
PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookL=
ib.inf=0D
SiliconPolicyUpdateLib|$(PROJECT)/FspWrapper/Library/PeiSiliconPolicyUpd=
ateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf=0D
=0D
+[LibraryClasses.Common.SEC]=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
+=0D
[LibraryClasses.IA32.SEC]=0D
#######################################=0D
# Edk2 Packages=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 3/9] KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for FspNvsHob

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Benjamin Doron <benjamin.doron00@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 +++++++++=
+--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++=
--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/P=
eiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 7 ++++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSi=
liconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
4 files changed, 24 insertions(+), 32 deletions(-)

diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp=
er/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform=
/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSilicon=
PolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
index d8413d284e..a9b7e446c8 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -1,7 +1,7 @@
/** @file=0D
Implementation of Fsp Misc UPD Initialization.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -11,7 +11,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>=0D
#include <Library/PciLib.h>=0D
#include <Library/PeiLib.h>=0D
-=0D
#include <FspEas.h>=0D
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
@@ -34,24 +33,21 @@ PeiFspMiscUpdUpdatePreMem (
{=0D
EFI_STATUS Status;=0D
UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 MorControl;=0D
VOID *MorControlPtr;=0D
=0D
//=0D
// Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHobGuid=
- %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ VariableSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &VariableSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", VariableSize));=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
+ }=0D
=0D
if (FspmUpd->FspmArchUpd.NvsBufferPtr !=3D NULL) {=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L=
ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c b/Platform/Int=
el/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUp=
dateLib/PeiSiliconPolicyUpdateLib.c
index c9dfb17e0a..3764f7c3ac 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c
@@ -431,8 +431,8 @@ SiliconPolicyUpdatePreMem (
SA_MISC_PEI_PREMEM_CONFIG *MiscPeiPreMemConfig;=0D
MEMORY_CONFIG_NO_CRC *MemConfigNoCrc;=0D
VOID *Buffer;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
UINT8 SpdAddressTable[4];=0D
=0D
DEBUG((DEBUG_INFO, "\nUpdating Policy in Pre-Mem\n"));=0D
@@ -463,18 +463,13 @@ SiliconPolicyUpdatePreMem (
// Note: AmberLake FSP does not implement the FSPM_ARCH_CONFIG_PPI a=
dded in FSP 2.1, hence=0D
// the platform specific S3DataPtr must be used instead.=0D
//=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D PeiGetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- &MemorySavedData,=0D
- &VariableSize=0D
- );=0D
- DEBUG ((DEBUG_INFO, "Get L\"MemoryConfig\" gFspNonVolatileStorageHob=
Guid - %r\n", Status));=0D
- DEBUG ((DEBUG_INFO, "MemoryConfig Size - 0x%x\n", VariableSize));=0D
- if (!EFI_ERROR (Status)) {=0D
- MiscPeiPreMemConfig->S3DataPtr =3D MemorySavedData;=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVaria=
bleGuid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGu=
id - %r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize=
));=0D
+ MiscPeiPreMemConfig->S3DataPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
//=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapp=
er/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/=
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/Pe=
iSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
index e4a657c5f1..eac9344b0a 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Libr=
ary/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -1,7 +1,7 @@
## @file=0D
# Provide FSP wrapper platform related function.=0D
#=0D
-# Copyright (c) 2017 - 2020 Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021 Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -74,7 +74,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
SiPolicyLib=0D
PeiLib=0D
=0D
@@ -134,9 +133,11 @@
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdAudioConnector=0D
=0D
gKabylakeOpenBoardPkgTokenSpaceGuid.PcdGraphicsVbtGuid=0D
+ gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress=0D
+ gKabylakeOpenBoardPkgTokenSpaceGuid.PcdRootPort4ClkInfo=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
diff --git a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/L=
ibrary/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf b/Platform/I=
ntel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicy=
UpdateLib/PeiSiliconPolicyUpdateLib.inf
index 0a8cf91b07..4dcc000186 100644
--- a/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
+++ b/Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/=
PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf
@@ -52,7 +52,7 @@
gHsioPciePreMemConfigGuid ## CONSUMES=0D
gHsioSataPreMemConfigGuid ## CONSUMES=0D
gSaMiscPeiPreMemConfigGuid ## CONSUMES=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gIoApicConfigGuid ## CONSUMES=0D
gHpetPreMemConfigGuid ## CONSUMES=0D
gLockDownConfigGuid=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 2/9] CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.

Chiu, Chasel
 

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

To simplify the implementation the variable Name/GUID has been
changed to "FspNvsBuffer" and gFspNvsBufferVariableGuid
regardless it stores the data from FSP_NON_VOLATILE_STORAGE_HOB2
or FSP_NON_VOLATILE_STORAGE_HOB.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@...>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUp=
dateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++++------------=
-------------------------------------
Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc =
| 3 +++
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUp=
dateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
3 files changed, 19 insertions(+), 52 deletions(-)

diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c b/Platform/Intel/CometlakeO=
penBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUp=
dateLib.c
index 7dbdfa7c16..9e8606ada9 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c
@@ -2,7 +2,7 @@
Implementation of Fsp Misc UPD Initialization.=0D
=0D
=0D
- Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+ Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
**/=0D
=0D
@@ -17,7 +17,6 @@
#include <FspmUpd.h>=0D
#include <FspsUpd.h>=0D
=0D
-#include <Library/MemoryAllocationLib.h>=0D
#include <Library/DebugLib.h>=0D
#include <Library/DebugPrintErrorLevelLib.h>=0D
#include <Library/PciLib.h>=0D
@@ -44,55 +43,21 @@ PeiFspMiscUpdUpdatePreMem (
)=0D
{=0D
EFI_STATUS Status;=0D
- EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariableServices;=0D
- UINTN VariableSize;=0D
- VOID *MemorySavedData;=0D
-=0D
- Status =3D PeiServicesLocatePpi (=0D
- &gEfiPeiReadOnlyVariable2PpiGuid,=0D
- 0,=0D
- NULL,=0D
- (VOID **) &VariableServices=0D
- );=0D
- if (EFI_ERROR (Status)) {=0D
- ASSERT_EFI_ERROR (Status);=0D
- return Status;=0D
+ UINTN FspNvsBufferSize;=0D
+ VOID *FspNvsBufferPtr;=0D
+=0D
+ //=0D
+ // Initialize S3 Data variable (S3DataPtr). It may be used for warm and =
fast boot paths.=0D
+ //=0D
+ FspNvsBufferPtr =3D NULL;=0D
+ FspNvsBufferSize =3D 0;=0D
+ Status =3D PeiGetLargeVariable (L"FspNvsBuffer", &gFspNvsBufferVariableG=
uid, &FspNvsBufferPtr, &FspNvsBufferSize);=0D
+ if (Status =3D=3D EFI_SUCCESS) {=0D
+ DEBUG ((DEBUG_INFO, "Get L\"FspNvsBuffer\" gFspNvsBufferVariableGuid -=
%r\n", Status));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsBuffer Size - 0x%x\n", FspNvsBufferSize));=
=0D
+ FspmUpd->FspmArchUpd.NvsBufferPtr =3D FspNvsBufferPtr;=0D
}=0D
=0D
- VariableSize =3D 0;=0D
- MemorySavedData =3D NULL;=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
- MemorySavedData =3D AllocatePool (VariableSize);=0D
- if (MemorySavedData =3D=3D NULL) {=0D
- ASSERT (MemorySavedData !=3D NULL);=0D
- return EFI_OUT_OF_RESOURCES;=0D
- }=0D
-=0D
- DEBUG ((DEBUG_INFO, "VariableSize is 0x%x\n", VariableSize));=0D
- Status =3D VariableServices->GetVariable (=0D
- VariableServices,=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
- NULL,=0D
- &VariableSize,=0D
- MemorySavedData=0D
- );=0D
- if (Status =3D=3D EFI_SUCCESS) {=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
- } else {=0D
- DEBUG ((DEBUG_ERROR, "Fail to retrieve Variable:\"MemoryConfig\" gMe=
moryConfigVariableGuid, Status =3D %r\n", Status));=0D
- ASSERT_EFI_ERROR (Status);=0D
- }=0D
- }=0D
- FspmUpd->FspmArchUpd.NvsBufferPtr =3D MemorySavedData;=0D
=0D
return EFI_SUCCESS;=0D
}=0D
diff --git a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPk=
g.dsc b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
index 44a1bd54d6..d63ff263c1 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
+++ b/Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc
@@ -142,6 +142,9 @@
#######################################=0D
PlatformHookLib|$(PROJECT)/Library/BasePlatformHookLib/BasePlatformHookL=
ib.inf=0D
=0D
+[LibraryClasses.Common.SEC]=0D
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVaria=
bleReadLibNull.inf=0D
+=0D
[LibraryClasses.IA32.SEC]=0D
#######################################=0D
# Platform Package=0D
diff --git a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSil=
iconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf b/Platform/Intel/Co=
metlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSili=
conPolicyUpdateLibFsp.inf
index c842b7eef6..94776603c4 100644
--- a/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
+++ b/Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPol=
icyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf
@@ -2,7 +2,7 @@
# Provide FSP wrapper platform related function.=0D
#=0D
#=0D
-# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>=
=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -82,7 +82,6 @@
PchInfoLib=0D
PchHsioLib=0D
PchPcieRpLib=0D
- MemoryAllocationLib=0D
DebugPrintErrorLevelLib=0D
SiPolicyLib=0D
PchGbeLib=0D
@@ -132,7 +131,7 @@
gCometlakeOpenBoardPkgTokenSpaceGuid.PcdMrcSpdAddressTable3=0D
=0D
[Guids]=0D
- gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## CONSUMES=0D
gTianoLogoGuid ## CONSUMES=0D
gEfiMemoryOverwriteControlDataGuid=0D
=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 1/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

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

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>
---
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig=
.c | 39 ++++++++++++++++++++++++++++-----------
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c =
| 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
+++-
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig=
.inf | 5 ++++-
Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h =
| 33 ++++++++++++++++++++++++++++++++-
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf =
| 4 +++-
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec =
| 1 +
6 files changed, 136 insertions(+), 15 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save=
MemoryConfig.c b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/=
SaveMemoryConfig.c
index 41ed2550bd..92a0fe56f5 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.c
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.c
@@ -2,7 +2,7 @@
This is the driver that locates the MemoryConfigurationData HOB, if it=0D
exists, and saves the data to nvRAM.=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -17,6 +17,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>=0D
#include <Library/BaseMemoryLib.h>=0D
#include <Protocol/VariableLock.h>=0D
+#include <Guid/FspNonVolatileStorageHob2.h>=0D
=0D
/**=0D
This is the standard EFI driver point that detects whether there is a=0D
@@ -50,11 +51,27 @@ SaveMemoryConfigEntryPoint (
//=0D
// Search for the Memory Configuration GUID HOB. If it is not present, =
then=0D
// there's nothing we can do. It may not exist on the update path.=0D
+ // Firstly check version2 FspNvsHob.=0D
//=0D
- GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHob2Guid);=0D
if (GuidHob !=3D NULL) {=0D
- HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
- DataSize =3D GET_GUID_HOB_DATA_SIZE(GuidHob);=0D
+ HobData =3D (VOID *) ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHo=
b)->NvsDataPtr;=0D
+ DataSize =3D ((FSP_NON_VOLATILE_STORAGE_HOB2 *) (UINTN) GuidHob)->NvsD=
ataLength;=0D
+ } else {=0D
+ //=0D
+ // Fall back to version1 FspNvsHob=0D
+ //=0D
+ GuidHob =3D GetFirstGuidHob (&gFspNonVolatileStorageHobGuid);=0D
+ if (GuidHob !=3D NULL) {=0D
+ HobData =3D GET_GUID_HOB_DATA (GuidHob);=0D
+ DataSize =3D GET_GUID_HOB_DATA_SIZE (GuidHob);=0D
+ }=0D
+ }=0D
+=0D
+ if (HobData !=3D NULL) {=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataLength:%d\n", DataSize));=0D
+ DEBUG ((DEBUG_INFO, "FspNvsHob.NvsDataPtr : 0x%x\n", HobData));=0D
+=0D
if (DataSize > 0) {=0D
//=0D
// Use the HOB to save Memory Configuration Data=0D
@@ -65,8 +82,8 @@ SaveMemoryConfigEntryPoint (
return EFI_UNSUPPORTED;=0D
}=0D
Status =3D gRT->GetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
+ L"FspNvsBuffer",=0D
+ &gFspNvsBufferVariableGuid,=0D
NULL,=0D
&BufferSize,=0D
VariableData=0D
@@ -80,8 +97,8 @@ SaveMemoryConfigEntryPoint (
}=0D
=0D
Status =3D gRT->GetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
+ L"FspNvsBuffer",=0D
+ &gFspNvsBufferVariableGuid,=0D
NULL,=0D
&BufferSize,=0D
VariableData=0D
@@ -90,8 +107,8 @@ SaveMemoryConfigEntryPoint (
=0D
if ( (EFI_ERROR(Status)) || BufferSize !=3D DataSize || 0 !=3D Compa=
reMem (HobData, VariableData, DataSize)) {=0D
Status =3D gRT->SetVariable (=0D
- L"MemoryConfig",=0D
- &gFspNonVolatileStorageHobGuid,=0D
+ L"FspNvsBuffer",=0D
+ &gFspNvsBufferVariableGuid,=0D
(EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERV=
ICE_ACCESS),=0D
DataSize,=0D
HobData=0D
@@ -106,7 +123,7 @@ SaveMemoryConfigEntryPoint (
//=0D
Status =3D gBS->LocateProtocol(&gEdkiiVariableLockProtocolGuid, NULL=
, (VOID **)&VariableLock);=0D
if (!EFI_ERROR(Status)) {=0D
- Status =3D VariableLock->RequestToLock(VariableLock, L"MemoryConfi=
g", &gFspNonVolatileStorageHobGuid);=0D
+ Status =3D VariableLock->RequestToLock(VariableLock, L"FspNvsBuffe=
r", &gFspNvsBufferVariableGuid);=0D
ASSERT_EFI_ERROR(Status);=0D
}=0D
=0D
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c b/Platfo=
rm/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
index 96dfd588dc..9e92387761 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
/** @file=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -9,6 +9,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>=0D
#include <Library/PeiServicesLib.h>=0D
#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/LargeVariableReadLib.h>=0D
#include <Ppi/ReadOnlyVariable2.h>=0D
=0D
/**=0D
@@ -108,6 +109,72 @@ PeiGetVariable (
return Status;=0D
}=0D
=0D
+/**=0D
+ Returns the status whether get the large variable success. When variable=
size=0D
+ is bigger than single UEFI variable size limit, The variable will be sav=
ed in=0D
+ multiple UEFI variables. This function retrieves such large variable thr=
ough the=0D
+ ReadOnlyVariable2 PPI GetVariable().=0D
+ The returned buffer is allocated using AllocatePage() to support > 64KB =
and this=0D
+ buffer cannot be Free().=0D
+=0D
+ If Name is NULL, then ASSERT().=0D
+ If Guid is NULL, then ASSERT().=0D
+ If Value is NULL, then ASSERT().=0D
+=0D
+ @param[in] Name The pointer to a Null-terminated Unicode string.=0D
+ @param[in] Guid The pointer to an EFI_GUID structure=0D
+ @param[out] Value The buffer point saved the variable info.=0D
+ @param[out] Size The buffer size of the variable.=0D
+=0D
+ @return EFI_OUT_OF_RESOURCES Allocate buffer failed.=0D
+ @return EFI_SUCCESS Find the specified variable.=0D
+ @return Others Errors Return errors from call to gRT->GetVar=
iable.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+PeiGetLargeVariable (=0D
+ IN CHAR16 *Name,=0D
+ IN EFI_GUID *Guid,=0D
+ OUT VOID **Value,=0D
+ OUT UINTN *Size OPTIONAL=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ UINTN VariableSize;=0D
+ VOID *VariableData;=0D
+=0D
+ ASSERT (Name !=3D NULL);=0D
+ ASSERT (Guid !=3D NULL);=0D
+ ASSERT (Value !=3D NULL);=0D
+=0D
+ VariableSize =3D 0;=0D
+ VariableData =3D NULL;=0D
+ Status =3D GetLargeVariable (Name, Guid, &VariableSize, NULL);=0D
+ if (Status =3D=3D EFI_BUFFER_TOO_SMALL) {=0D
+ VariableData =3D AllocatePages (EFI_SIZE_TO_PAGES (VariableSize));=0D
+ if (VariableData =3D=3D NULL) {=0D
+ DEBUG ((DEBUG_ERROR, "Error: Cannot create VariableData, out of memo=
ry!\n"));=0D
+ ASSERT (FALSE);=0D
+ return EFI_OUT_OF_RESOURCES;=0D
+ }=0D
+ Status =3D GetLargeVariable (Name, Guid, &VariableSize, VariableData);=
=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "Error: Unable to read UEFI variable Status: %r=
\n", Status));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ return Status;=0D
+ }=0D
+ if (Value !=3D NULL) {=0D
+ *Value =3D VariableData;=0D
+ }=0D
+ if (Size !=3D NULL) {=0D
+ *Size =3D VariableSize;=0D
+ }=0D
+ return EFI_SUCCESS;=0D
+ }=0D
+ return Status;=0D
+}=0D
+=0D
EFI_PEI_FILE_HANDLE=0D
InternalGetFfsHandleFromAnyFv (=0D
IN CONST EFI_GUID *NameGuid=0D
diff --git a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/Save=
MemoryConfig.inf b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfi=
g/SaveMemoryConfig.inf
index 0c8689a6f6..eac0880504 100644
--- a/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.inf
+++ b/Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryC=
onfig.inf
@@ -1,7 +1,7 @@
### @file=0D
# Component information file for SaveMemoryConfig module=0D
#=0D
-# Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -28,6 +28,7 @@
MdePkg/MdePkg.dec=0D
MdeModulePkg/MdeModulePkg.dec=0D
IntelFsp2Pkg/IntelFsp2Pkg.dec=0D
+ MinPlatformPkg/MinPlatformPkg.dec=0D
=0D
[Sources]=0D
SaveMemoryConfig.c=0D
@@ -39,6 +40,8 @@
=0D
[Guids]=0D
gFspNonVolatileStorageHobGuid ## CONSUMES=0D
+ gFspNonVolatileStorageHob2Guid ## CONSUMES=0D
+ gFspNvsBufferVariableGuid ## PRODUCES=0D
=0D
[Depex]=0D
gEfiVariableArchProtocolGuid AND=0D
diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h b/Platf=
orm/Intel/MinPlatformPkg/Include/Library/PeiLib.h
index d8b1a47c58..86ffb378ec 100644
--- a/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
+++ b/Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h
@@ -1,6 +1,6 @@
/** @file=0D
=0D
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -38,6 +38,37 @@ PeiGetVariable (
OUT UINTN *Size=0D
);=0D
=0D
+/**=0D
+ Returns the status whether get the large variable success. When variable=
size=0D
+ is bigger than single UEFI variable size limit, The variable will be sav=
ed in=0D
+ multiple UEFI variables. This function retrieves such large variable thr=
ough the=0D
+ ReadOnlyVariable2 PPI GetVariable().=0D
+ The returned buffer is allocated using AllocatePage() to support > 64KB =
and this=0D
+ buffer cannot be Free().=0D
+=0D
+ If Name is NULL, then ASSERT().=0D
+ If Guid is NULL, then ASSERT().=0D
+ If Value is NULL, then ASSERT().=0D
+=0D
+ @param[in] Name The pointer to a Null-terminated Unicode string.=0D
+ @param[in] Guid The pointer to an EFI_GUID structure=0D
+ @param[out] Value The buffer point saved the variable info.=0D
+ @param[out] Size The buffer size of the variable.=0D
+=0D
+ @return EFI_OUT_OF_RESOURCES Allocate buffer failed.=0D
+ @return EFI_SUCCESS Find the specified variable.=0D
+ @return Others Errors Return errors from call to gRT->GetVar=
iable.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+PeiGetLargeVariable (=0D
+ IN CHAR16 *Name,=0D
+ IN EFI_GUID *Guid,=0D
+ OUT VOID **Value,=0D
+ OUT UINTN *Size OPTIONAL=0D
+ );=0D
+=0D
/**=0D
Finds the file in any FV and gets file Address and Size=0D
=0D
diff --git a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf b/Plat=
form/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
index 7e740172a0..bd57cf7870 100644
--- a/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
+++ b/Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf
@@ -1,7 +1,7 @@
## @file=0D
# Component information file for Board Init Test Library=0D
#=0D
-# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>=0D
+# Copyright (c) 2017 - 2021, Intel Corporation. All rights reserved.<BR>=0D
#=0D
# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
#=0D
@@ -20,9 +20,11 @@
PeiServicesLib=0D
MemoryAllocationLib=0D
DebugLib=0D
+ LargeVariableReadLib=0D
=0D
[Packages]=0D
MdePkg/MdePkg.dec=0D
+ MinPlatformPkg/MinPlatformPkg.dec=0D
=0D
[Sources]=0D
PeiLib.c=0D
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec b/Platform/In=
tel/MinPlatformPkg/MinPlatformPkg.dec
index bcb42f0ef9..d6e80a66ce 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec
@@ -50,6 +50,7 @@
gBdsEventBeforeConsoleAfterTrustedConsoleGuid =3D {0x51e49ff5, 0x28a9, =
0x4159, { 0xac, 0x8a, 0xb8, 0xc4, 0x88, 0xa7, 0xfd, 0xee}}=0D
gBdsEventBeforeConsoleBeforeEndOfDxeGuid =3D {0xfcf26e41, 0xbda6, =
0x4633, { 0xb5, 0x73, 0xd4, 0xb8, 0x0e, 0x6d, 0xd0, 0x78}}=0D
gBdsEventAfterConsoleReadyBeforeBootOptionGuid =3D {0x8eb3d5dc, 0xf4e7, =
0x4b57, { 0xa9, 0xe7, 0x27, 0x39, 0x10, 0xf2, 0x18, 0x9f}}=0D
+ gFspNvsBufferVariableGuid =3D {0x9c7715cd, 0x8d66, =
0x4d2a, { 0x90, 0x0d, 0x01, 0x45, 0x9a, 0x57, 0x59, 0x6b}}=0D
=0D
[LibraryClasses]=0D
=0D
--=20
2.28.0.windows.1


[edk2-platforms: PATCH 0/9] MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.

Chiu, Chasel
 

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

Implementation should search FSP_NON_VOLATILE_STORAGE_HOB2 firstly
and only search FSP_NON_VOLATILE_STORAGE_HOB when former one is not found.

Also added PeiGetLargeVariable () to support the scenarios where the
variable data size is bigger than a single variable size limit.

Cc: Isaac Oram <isaac.w.oram@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...>
Cc: Heng Luo <heng.luo@...>
Cc: Jeremy Soller <jeremy@...>
Cc: Benjamin Doron <benjamin.doron00@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Deepika Kethi Reddy <deepika.kethi.reddy@...>
Cc: Kathappan Esakkithevar <kathappan.esakkithevar@...>
Cc: Liming Gao <gaoliming@...>
Cc: Eric Dong <eric.dong@...>
Signed-off-by: Chasel Chiu <chasel.chiu@...>

Chasel Chiu (9):
MinPlatformPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
CometlakeOpenBoardPkg: Use same variable name for FspNvsHob.
KabylakeOpenBoardPkg/AspireVn7Dash572G:Use same variable name for
FspNvsHob
KabylakeOpenBoardPkg/GalagoPro3: Use same variable name for FspNvsHob.
KabylakeOpenBoardPkg/KabylakeRvp3: Use same variable name for
FspNvsHob.
TigerlakeOpenBoardPkg: Use same variable name for FspNvsHob.
WhiskeylakeOpenBoardPkg: Use same variable name for FspNvsHob.
WhitleyOpenBoardPkg: Support FSP 2.3 FSP_NON_VOLATILE_STORAGE_HOB2.
WhitleySiliconPkg: Use same variable name for FspNvsHob.

Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++++-------------------------------------------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 ++++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 24 ++++++++++--------------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 25 ++++++++++---------------
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.c | 23 +++++++++--------------
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.c | 39 ++++++++++++++++++++++++++++-----------
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.c | 21 ++++++++++++++++++---
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---------------------------------------------------
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiFspMiscUpdUpdateLib.c | 63 ++++++++++++---------------------------------------------------
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.c | 29 +++++++++++++++++++++++------
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.c | 35 +++++++++--------------------------
Platform/Intel/CometlakeOpenBoardPkg/CometlakeURvp/OpenBoardPkg.dsc | 3 +++
Platform/Intel/CometlakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 7 ++++---
Platform/Intel/KabylakeOpenBoardPkg/AspireVn7Dash572G/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/GalagoPro3/OpenBoardPkg.dsc | 3 +++
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/KabylakeOpenBoardPkg/KabylakeRvp3/Policy/Library/PeiSiliconPolicyUpdateLib/PeiSiliconPolicyUpdateLib.inf | 2 +-
Platform/Intel/MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf | 5 ++++-
Platform/Intel/MinPlatformPkg/Include/Library/PeiLib.h | 33 ++++++++++++++++++++++++++++++++-
Platform/Intel/MinPlatformPkg/Library/PeiLib/PeiLib.inf | 4 +++-
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec | 1 +
Platform/Intel/TigerlakeOpenBoardPkg/FspWrapper/Library/PeiFspPolicyInitLib/PeiFspPolicyInitLib.inf | 1 +
Platform/Intel/TigerlakeOpenBoardPkg/TigerlakeURvp/OpenBoardPkg.dsc | 3 +++
Platform/Intel/WhiskeylakeOpenBoardPkg/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 5 ++---
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/FspWrapper/Library/PeiSiliconPolicyUpdateLibFsp/PeiSiliconPolicyUpdateLibFsp.inf | 4 ++--
Platform/Intel/WhiskeylakeOpenBoardPkg/UpXtreme/OpenBoardPkg.dsc | 3 +++
Platform/Intel/WhiskeylakeOpenBoardPkg/WhiskeylakeURvp/OpenBoardPkg.dsc | 3 +++
Platform/Intel/WhitleyOpenBoardPkg/Platform/Dxe/S3NvramSave/S3NvramSave.inf | 4 +++-
Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc | 1 +
Silicon/Intel/WhitleySiliconPkg/Library/FspWrapperPlatformLib/FspWrapperPlatformLib.inf | 3 ++-
34 files changed, 310 insertions(+), 293 deletions(-)

--
2.28.0.windows.1


Event: TianoCore Community Meeting - APAC/NAMO - 10/07/2021 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Community Meeting - APAC/NAMO

When:
10/07/2021
7:30pm to 8:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZWNiZWM1MzgtNWEzMy00MTgwLTgwNjAtNWQ1ZWUwZmQzNjVh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Soumya Guptha

View Event

Description:

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 119 132 712 6

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,494156131#   United States, Sacramento

Phone Conference ID: 494 156 131#

Find a local number | Reset PIN

Learn More | Meeting options


回复: 回复: [edk2-devel] Python2.7 is not working with the EDK2 build system

gaoliming
 

Cole:
Here is the error message https://edk2.groups.io/g/devel/message/80068?p=,,,20,0,0,0::recentpostdate%252Fsticky,,python,20,2,0,85296733

Yes, Python27 has been end of life. But, Edk2 has not announced to drop Python27 support. So, if someone meets with python27 issue, we need to response them.

Now, I think we can give the proposal to drop Python27 support in Edk2 project.

Thanks
Liming

-----邮件原件-----
发件人: Cole Robinson <crobinso@...>
发送时间: 2021年10月6日 0:48
收件人: gaoliming <gaoliming@...>; devel@edk2.groups.io;
Sunny.Wang@...; 'Feng, Bob C' <bob.c.feng@...>; 'Chen,
Christine' <yuwei.chen@...>
抄送: 'Sami Mujawar' <Sami.Mujawar@...>; 'Samer El-Haj-Mahmoud'
<Samer.El-Haj-Mahmoud@...>; 'Gerd Hoffmann' <kraxel@...>
主题: Re: 回复: [edk2-devel] Python2.7 is not working with the EDK2 build
system

On 9/6/21 9:18 PM, gaoliming wrote:
Bob:

Yes. Python3 is the formal support. We recommend user to use Python3.
But, if user meets the issue in Python2, user can still report the issue
in BaseTools. Its priority may be low. For this case, it is the
regression issue caused by the recent change. The patch owner is also
identified. So, I suggest the patch owner to follow up and enhance his
patch.
Sorry for the delayed response, I was on paternity leave since August.

I haven't seen the actual error in this thread. Is there a clear python
error being thrown? Maybe the fix is simple but I can't

But as mentioned elsewhere, python2 has been End of Life since Jan 1
2020, over 1.5 years ago. It's going to become increasingly difficult to
keep code working on python2 and latest python3.

- Cole


回复: [edk2-devel] [PATCH v7 1/1] MdePkg/BaseLib: Add QuickSort function on BaseLib

gaoliming
 

Kuo:
I suggest to move SORT_COMPARE definition from
MdeModulePkg\Include\Library\SortLib.h to MdePkg\Include\Library\BaseLib.h,
and then let SortLib.h include BaseLib.h.

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 IanX Kuo
发送时间: 2021年10月8日 8:27
收件人: devel@edk2.groups.io
抄送: amy.chan@...; ray.ni@...; IanX Kuo
<ianx.kuo@...>; Michael D Kinney <michael.d.kinney@...>;
Liming Gao <gaoliming@...>; Zhiguang Liu
<zhiguang.liu@...>
主题: [edk2-devel] [PATCH v7 1/1] MdePkg/BaseLib: Add QuickSort function
on BaseLib

From: IanX Kuo <ianx.kuo@...>

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

Add QuickSort function into BaseLib

Cc: Ray Ni <ray.ni@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Signed-off-by: IanX Kuo <ianx.kuo@...>
---
MdePkg/Include/Library/BaseLib.h | 49 ++++++++
MdePkg/Library/BaseLib/BaseLib.inf | 1 +
MdePkg/Library/BaseLib/QuickSort.c | 116
++++++++++++++++++
.../Library/BaseLib/UnitTestHostBaseLib.inf | 3 +-
4 files changed, 168 insertions(+), 1 deletion(-)
create mode 100644 MdePkg/Library/BaseLib/QuickSort.c

diff --git a/MdePkg/Include/Library/BaseLib.h
b/MdePkg/Include/Library/BaseLib.h
index 2452c1d92e..0ae0f4e6af 100644
--- a/MdePkg/Include/Library/BaseLib.h
+++ b/MdePkg/Include/Library/BaseLib.h
@@ -2856,6 +2856,55 @@ RemoveEntryList (
//

// Math Services

//

+/**

+ Prototype for comparison function for any two element types.

+

+ @param[in] Buffer1 The pointer to first buffer.

+ @param[in] Buffer2 The pointer to second buffer.

+

+ @retval 0 Buffer1 equal to Buffer2.

+ @return <0 Buffer1 is less than Buffer2.

+ @return >0 Buffer1 is greater than
Buffer2.

+**/

+typedef

+INTN

+(EFIAPI *BASE_SORT_COMPARE)(

+ IN CONST VOID *Buffer1,

+ IN CONST VOID *Buffer2

+ );

+

+/**

+ This function is identical to perform QuickSort,

+ except that is uses the pre-allocated buffer so the in place sorting
does not
need to

+ allocate and free buffers constantly.

+

+ Each element must be equal sized.

+

+ if BufferToSort is NULL, then ASSERT.

+ if CompareFunction is NULL, then ASSERT.

+ if BufferOneElement is NULL, then ASSERT.

+ if ElementSize is < 1, then ASSERT.

+

+ if Count is < 2 then perform no action.

+

+ @param[in, out] BufferToSort on call a Buffer of (possibly sorted)
elements

+ on return a buffer of sorted
elements

+ @param[in] Count the number of elements in the
buffer to sort

+ @param[in] ElementSize Size of an element in bytes

+ @param[in] CompareFunction The function to call to perform the
comparison

+ of any 2 elements

+ @param[out] BufferOneElement Caller provided buffer whose size
equals to ElementSize.

+ It's used by QuickSort() for
swapping in sorting.

+**/

+VOID

+EFIAPI

+QuickSort (

+ IN OUT VOID *BufferToSort,

+ IN CONST UINTN Count,

+ IN CONST UINTN ElementSize,

+ IN BASE_SORT_COMPARE CompareFunction,

+ OUT VOID *BufferOneElement

+ );



/**

Shifts a 64-bit integer left between 0 and 63 bits. The low bits are
filled

diff --git a/MdePkg/Library/BaseLib/BaseLib.inf
b/MdePkg/Library/BaseLib/BaseLib.inf
index 6efa5315b6..cebda3b210 100644
--- a/MdePkg/Library/BaseLib/BaseLib.inf
+++ b/MdePkg/Library/BaseLib/BaseLib.inf
@@ -32,6 +32,7 @@
SwapBytes16.c

LongJump.c

SetJump.c

+ QuickSort.c

RShiftU64.c

RRotU64.c

RRotU32.c

diff --git a/MdePkg/Library/BaseLib/QuickSort.c
b/MdePkg/Library/BaseLib/QuickSort.c
new file mode 100644
index 0000000000..a825c072b0
--- /dev/null
+++ b/MdePkg/Library/BaseLib/QuickSort.c
@@ -0,0 +1,116 @@
+/** @file

+ Math worker functions.

+

+ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>

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

+

+**/

+

+#include "BaseLibInternals.h"

+

+/**

+ This function is identical to perform QuickSort,

+ except that is uses the pre-allocated buffer so the in place sorting
does not
need to

+ allocate and free buffers constantly.

+

+ Each element must be equal sized.

+

+ if BufferToSort is NULL, then ASSERT.

+ if CompareFunction is NULL, then ASSERT.

+ if BufferOneElement is NULL, then ASSERT.

+ if ElementSize is < 1, then ASSERT.

+

+ if Count is < 2 then perform no action.

+

+ @param[in, out] BufferToSort on call a Buffer of (possibly sorted)
elements

+ on return a buffer of sorted
elements

+ @param[in] Count the number of elements in the
buffer to sort

+ @param[in] ElementSize Size of an element in bytes

+ @param[in] CompareFunction The function to call to perform the
comparison

+ of any 2 elements

+ @param[out] BufferOneElement Caller provided buffer whose size
equals to ElementSize.

+ It's used by QuickSort() for
swapping in sorting.

+**/

+VOID

+EFIAPI

+QuickSort (

+ IN OUT VOID *BufferToSort,

+ IN CONST UINTN Count,

+ IN CONST UINTN ElementSize,

+ IN BASE_SORT_COMPARE CompareFunction,

+ OUT VOID *BufferOneElement

+ )

+{

+ VOID *Pivot;

+ UINTN LoopCount;

+ UINTN NextSwapLocation;

+

+ ASSERT (BufferToSort != NULL);

+ ASSERT (CompareFunction != NULL);

+ ASSERT (BufferOneElement != NULL);

+ ASSERT (ElementSize >= 1);

+

+ if (Count < 2) {

+ return;

+ }

+

+ NextSwapLocation = 0;

+

+ //

+ // pick a pivot (we choose last element)

+ //

+ Pivot = ((UINT8*) BufferToSort + ((Count - 1) * ElementSize));

+

+ //

+ // Now get the pivot such that all on "left" are below it

+ // and everything "right" are above it

+ //

+ for (LoopCount = 0; LoopCount < Count -1; LoopCount++) {

+ //

+ // if the element is less than or equal to the pivot

+ //

+ if (CompareFunction ((VOID*) ((UINT8*) BufferToSort + ((LoopCount) *
ElementSize)), Pivot) <= 0){

+ //

+ // swap

+ //

+ CopyMem (BufferOneElement, (UINT8*) BufferToSort +
(NextSwapLocation * ElementSize), ElementSize);

+ CopyMem ((UINT8*) BufferToSort + (NextSwapLocation *
ElementSize), (UINT8*) BufferToSort + ((LoopCount) * ElementSize),
ElementSize);

+ CopyMem ((UINT8*) BufferToSort + ((LoopCount)*ElementSize),
BufferOneElement, ElementSize);

+

+ //

+ // increment NextSwapLocation

+ //

+ NextSwapLocation++;

+ }

+ }

+ //

+ // swap pivot to it's final position (NextSwapLocation)

+ //

+ CopyMem (BufferOneElement, Pivot, ElementSize);

+ CopyMem (Pivot, (UINT8*) BufferToSort + (NextSwapLocation *
ElementSize), ElementSize);

+ CopyMem ((UINT8*) BufferToSort + (NextSwapLocation * ElementSize),
BufferOneElement, ElementSize);

+

+ //

+ // Now recurse on 2 partial lists. neither of these will have the
'pivot'
element

+ // IE list is sorted left half, pivot element, sorted right half...

+ //

+ if (NextSwapLocation >= 2) {

+ QuickSort (

+ BufferToSort,

+ NextSwapLocation,

+ ElementSize,

+ CompareFunction,

+ BufferOneElement

+ );

+ }

+

+ if ((Count - NextSwapLocation - 1) >= 2) {

+ QuickSort (

+ (UINT8 *)BufferToSort + (NextSwapLocation + 1) * ElementSize,

+ Count - NextSwapLocation - 1,

+ ElementSize,

+ CompareFunction,

+ BufferOneElement

+ );

+ }

+}

diff --git a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
index eae1a7158d..d09bd12bef 100644
--- a/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
+++ b/MdePkg/Library/BaseLib/UnitTestHostBaseLib.inf
@@ -1,7 +1,7 @@
## @file

# Base Library implementation for use with host based unit tests.

#

-# Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.<BR>

+# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>

# Portions copyright (c) 2008 - 2009, Apple Inc. All rights
reserved.<BR>

# Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>

# Copyright (c) 2020, Hewlett Packard Enterprise Development LP. All
rights reserved.<BR>

@@ -33,6 +33,7 @@
SwapBytes16.c

LongJump.c

SetJump.c

+ QuickSort.c

RShiftU64.c

RRotU64.c

RRotU32.c

--
2.30.0.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#81615): https://edk2.groups.io/g/devel/message/81615
Mute This Topic: https://groups.io/mt/86159728/4905953
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub
[gaoliming@...]
-=-=-=-=-=-=


Event: TianoCore Community Meeting - APAC/NAMO - 10/07/2021 #cal-reminder

devel@edk2.groups.io Calendar <noreply@...>
 

Reminder: TianoCore Community Meeting - APAC/NAMO

When:
10/07/2021
7:30pm to 8:30pm
(UTC-07:00) America/Los Angeles

Where:
https://teams.microsoft.com/l/meetup-join/19%3ameeting_ZWNiZWM1MzgtNWEzMy00MTgwLTgwNjAtNWQ1ZWUwZmQzNjVh%40thread.v2/0?context=%7b%22Tid%22%3a%2246c98d88-e344-4ed4-8496-4ed7712e255d%22%2c%22Oid%22%3a%22b286b53a-1218-4db3-bfc9-3d4c5aa7669e%22%7d

Organizer: Soumya Guptha

View Event

Description:

Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 119 132 712 6

Alternate VTC dialing instructions

Or call in (audio only)

+1 916-245-6934,,494156131#   United States, Sacramento

Phone Conference ID: 494 156 131#

Find a local number | Reset PIN

Learn More | Meeting options


回复: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory aggregator/device type mismatch

gaoliming
 

Samer:
Thanks for your information. I agree this change. Reviewed-by: Liming Gao <gaoliming@...>

Thanks
Liming

-----邮件原件-----
发件人: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
发送时间: 2021年10月8日 9:45
收件人: devel@edk2.groups.io; gaoliming@...; Christopher
Jones <Christopher.Jones@...>
抄送: michael.d.kinney@...; zhiguang.liu@...; Sami Mujawar
<Sami.Mujawar@...>; Ben Adderson <Ben.Adderson@...>;
Akanksha Jain <Akanksha.Jain2@...>; Matteo Carlini
<Matteo.Carlini@...>; nd <nd@...>; Samer El-Haj-Mahmoud
<Samer.El-Haj-Mahmoud@...>
主题: RE: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory
aggregator/device type mismatch

We did investigate this in the BZ, and the conclusion was it is safer to update
the code to match the spec. The only OS implementation we have seen so far
is in Linux, and it uses the spec defined values (although for limited usage).
See https://bugzilla.tianocore.org/show_bug.cgi?id=3579




-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
gaoliming via groups.io
Sent: Thursday, October 7, 2021 9:26 PM
To: devel@edk2.groups.io; Christopher Jones
<Christopher.Jones@...>
Cc: michael.d.kinney@...; zhiguang.liu@...; Sami Mujawar
<Sami.Mujawar@...>; Ben Adderson <Ben.Adderson@...>;
Akanksha Jain <Akanksha.Jain2@...>; Matteo Carlini
<Matteo.Carlini@...>; nd <nd@...>
Subject: 回复: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory
aggregator/device type mismatch

Jones:
Do you know what impact will be introduced by this change?

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Chris
Jones
发送时间: 2021年10月6日 18:12
收件人: devel@edk2.groups.io
抄送: michael.d.kinney@...; gaoliming@...;
zhiguang.liu@...; Sami.Mujawar@...;
Ben.Adderson@...;
Akanksha.Jain2@...; Matteo.Carlini@...; nd@...
主题: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory
aggregator/device type mismatch

Bugzilla: 3578 (https://bugzilla.tianocore.org/show_bug.cgi?id=3579)

Since the Common Memory Device (formerly Memory Aggregator Device)
was
introduced in ACPI 5.0, the edk2 type values have not matched the
values defined in the ACPI specification.

Fix this discrepancy by aligning the code to match the specification.

Signed-off-by: Chris Jones <christopher.jones@...>
---
MdePkg/Include/IndustryStandard/Acpi50.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi51.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi60.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi61.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi62.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi63.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi64.h | 6 +++---
7 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi50.h
b/MdePkg/Include/IndustryStandard/Acpi50.h
index
31a47e6a2c4276d5b1ad7b834af84844090b64c5..83d787c7650cf649fe3d2e1
2e7983bae86a2a114 100644
--- a/MdePkg/Include/IndustryStandard/Acpi50.h
+++ b/MdePkg/Include/IndustryStandard/Acpi50.h
@@ -996,9 +996,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi51.h
b/MdePkg/Include/IndustryStandard/Acpi51.h
index
fc28ffa18fc6a22e52fda88fade6ad80b2817cc3..5fbf7c99f1f7d6ca9109f198bd
3f25f12bd47961 100644
--- a/MdePkg/Include/IndustryStandard/Acpi51.h
+++ b/MdePkg/Include/IndustryStandard/Acpi51.h
@@ -951,9 +951,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi60.h
b/MdePkg/Include/IndustryStandard/Acpi60.h
index
5dcd73b6f1ec4bccc7fdae7d56c2963ab58764f9..eba4248e1d5733d21973f0d
ac2286e02238a0aae 100644
--- a/MdePkg/Include/IndustryStandard/Acpi60.h
+++ b/MdePkg/Include/IndustryStandard/Acpi60.h
@@ -966,9 +966,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h
b/MdePkg/Include/IndustryStandard/Acpi61.h
index
8626833a794dfb4a6f19d459d5214c6caefdbbee..7a776020baa8f3ee7b6f05fe
e336225ab6589ce0 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -966,9 +966,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h
b/MdePkg/Include/IndustryStandard/Acpi62.h
index
1b2704e98e3703a4405075247432ec842e45021b..33a0a0f21959df8b64803e
972ab19f0c0ab1619e 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1078,9 +1078,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h
b/MdePkg/Include/IndustryStandard/Acpi63.h
index
b281b30155e90eba5169dc39bde9a3379e3b7005..3b1426af27ea4ebada1a1
2e99ce958bb288ad931 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1040,9 +1040,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h
b/MdePkg/Include/IndustryStandard/Acpi64.h
index
3a91302f8c0e71d4951d27aac35322073219c836..8346d83f1249045497b602
907b94fbb2b495cd56 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1075,9 +1075,9 @@ typedef struct {
///
/// Memory Device Type.
///
-#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_MEMORY_CONTROLLER
0x2
-#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_DIMM
0x3
+#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_MEMORY_CONTROLLER
0x1
+#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_DIMM
0x2
#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_VENDOR_SPECIFIC_TYPE
0xFF

///
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")










Re: [PATCH v1 1/1] MdePkg: Fix ACPI memory aggregator/device type mismatch

Samer El-Haj-Mahmoud
 

We did investigate this in the BZ, and the conclusion was it is safer to update the code to match the spec. The only OS implementation we have seen so far is in Linux, and it uses the spec defined values (although for limited usage). See https://bugzilla.tianocore.org/show_bug.cgi?id=3579

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
gaoliming via groups.io
Sent: Thursday, October 7, 2021 9:26 PM
To: devel@edk2.groups.io; Christopher Jones
<Christopher.Jones@...>
Cc: michael.d.kinney@...; zhiguang.liu@...; Sami Mujawar
<Sami.Mujawar@...>; Ben Adderson <Ben.Adderson@...>;
Akanksha Jain <Akanksha.Jain2@...>; Matteo Carlini
<Matteo.Carlini@...>; nd <nd@...>
Subject: 回复: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory
aggregator/device type mismatch

Jones:
Do you know what impact will be introduced by this change?

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Chris Jones
发送时间: 2021年10月6日 18:12
收件人: devel@edk2.groups.io
抄送: michael.d.kinney@...; gaoliming@...;
zhiguang.liu@...; Sami.Mujawar@...;
Ben.Adderson@...;
Akanksha.Jain2@...; Matteo.Carlini@...; nd@...
主题: [edk2-devel] [PATCH v1 1/1] MdePkg: Fix ACPI memory
aggregator/device type mismatch

Bugzilla: 3578 (https://bugzilla.tianocore.org/show_bug.cgi?id=3579)

Since the Common Memory Device (formerly Memory Aggregator Device)
was
introduced in ACPI 5.0, the edk2 type values have not matched the
values defined in the ACPI specification.

Fix this discrepancy by aligning the code to match the specification.

Signed-off-by: Chris Jones <christopher.jones@...>
---
MdePkg/Include/IndustryStandard/Acpi50.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi51.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi60.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi61.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi62.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi63.h | 6 +++---
MdePkg/Include/IndustryStandard/Acpi64.h | 6 +++---
7 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/Acpi50.h
b/MdePkg/Include/IndustryStandard/Acpi50.h
index
31a47e6a2c4276d5b1ad7b834af84844090b64c5..83d787c7650cf649fe3d2e1
2e7983bae86a2a114 100644
--- a/MdePkg/Include/IndustryStandard/Acpi50.h
+++ b/MdePkg/Include/IndustryStandard/Acpi50.h
@@ -996,9 +996,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_5_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi51.h
b/MdePkg/Include/IndustryStandard/Acpi51.h
index
fc28ffa18fc6a22e52fda88fade6ad80b2817cc3..5fbf7c99f1f7d6ca9109f198bd
3f25f12bd47961 100644
--- a/MdePkg/Include/IndustryStandard/Acpi51.h
+++ b/MdePkg/Include/IndustryStandard/Acpi51.h
@@ -951,9 +951,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_5_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi60.h
b/MdePkg/Include/IndustryStandard/Acpi60.h
index
5dcd73b6f1ec4bccc7fdae7d56c2963ab58764f9..eba4248e1d5733d21973f0d
ac2286e02238a0aae 100644
--- a/MdePkg/Include/IndustryStandard/Acpi60.h
+++ b/MdePkg/Include/IndustryStandard/Acpi60.h
@@ -966,9 +966,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_0_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi61.h
b/MdePkg/Include/IndustryStandard/Acpi61.h
index
8626833a794dfb4a6f19d459d5214c6caefdbbee..7a776020baa8f3ee7b6f05fe
e336225ab6589ce0 100644
--- a/MdePkg/Include/IndustryStandard/Acpi61.h
+++ b/MdePkg/Include/IndustryStandard/Acpi61.h
@@ -966,9 +966,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_1_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi62.h
b/MdePkg/Include/IndustryStandard/Acpi62.h
index
1b2704e98e3703a4405075247432ec842e45021b..33a0a0f21959df8b64803e
972ab19f0c0ab1619e 100644
--- a/MdePkg/Include/IndustryStandard/Acpi62.h
+++ b/MdePkg/Include/IndustryStandard/Acpi62.h
@@ -1078,9 +1078,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_2_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi63.h
b/MdePkg/Include/IndustryStandard/Acpi63.h
index
b281b30155e90eba5169dc39bde9a3379e3b7005..3b1426af27ea4ebada1a1
2e99ce958bb288ad931 100644
--- a/MdePkg/Include/IndustryStandard/Acpi63.h
+++ b/MdePkg/Include/IndustryStandard/Acpi63.h
@@ -1040,9 +1040,9 @@ typedef struct {
///
/// Memory Aggregator Device Type
///
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x2
-#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x3
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_MEMORY_C
ONTROLLER 0x1
+#define
EFI_ACPI_6_3_PMMT_MEMORY_AGGREGATOR_DEVICE_TYPE_DIMM
0x2

///
/// Socket Memory Aggregator Device Structure.
diff --git a/MdePkg/Include/IndustryStandard/Acpi64.h
b/MdePkg/Include/IndustryStandard/Acpi64.h
index
3a91302f8c0e71d4951d27aac35322073219c836..8346d83f1249045497b602
907b94fbb2b495cd56 100644
--- a/MdePkg/Include/IndustryStandard/Acpi64.h
+++ b/MdePkg/Include/IndustryStandard/Acpi64.h
@@ -1075,9 +1075,9 @@ typedef struct {
///
/// Memory Device Type.
///
-#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_SOCKET
0x1
-#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_MEMORY_CONTROLLER
0x2
-#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_DIMM
0x3
+#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_SOCKET
0x0
+#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_MEMORY_CONTROLLER
0x1
+#define EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_DIMM
0x2
#define
EFI_ACPI_6_4_PMTT_MEMORY_DEVICE_TYPE_VENDOR_SPECIFIC_TYPE
0xFF

///
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")










Re: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The SMI to handle the user authentication should be unregister before booting to OS

Dandan Bi
 

Reviewed-by: Dandan Bi <dandan.bi@...>



Thanks,
Dandan

-----Original Message-----
From: Shi, Hao <hao.shi@...>
Sent: Tuesday, September 28, 2021 10:09 AM
To: devel@edk2.groups.io
Cc: Shi, Hao <hao.shi@...>; Bi, Dandan <dandan.bi@...>;
Liming Gao <gaoliming@...>
Subject: [PATCH] UserAuthFeaturePkg/UserAuthenticationDxeSmm: The
SMI to handle the user authentication should be unregister before booting
to OS

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

Register SmmExitBootServices and SmmLegacyBoot callback function to
unregister this handler.

Signed-off-by: Hao Shi <hao.shi@...>
Cc: Dandan Bi <dandan.bi@...>
Cc: Liming Gao <gaoliming@...>
---
.../UserAuthenticationSmm.c | 39 +++++++++++++++++--
.../UserAuthenticationSmm.inf | 2 +
2 files changed, 38 insertions(+), 3 deletions(-)

diff --git
a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.c
b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.c
index 07e834eb..3d66010b 100644
---
a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.c
+++
b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
+++ DxeSmm/UserAuthenticationSmm.c
@@ -13,6 +13,7 @@ UINTN mAdminPasswordTryCount = 0;

BOOLEAN mNeedReVerify = TRUE;
BOOLEAN mPasswordVerified = FALSE;
+EFI_HANDLE mSmmHandle = NULL;

/**
Verify if the password is correct.
@@ -612,6 +613,30 @@ EXIT:
return EFI_SUCCESS;
}

+/**
+ Performs Exit Boot Services UserAuthentication actions
+
+ @param[in] Protocol Points to the protocol's unique identifier.
+ @param[in] Interface Points to the interface instance.
+ @param[in] Handle The handle on which the interface was installed.
+
+ @retval EFI_SUCCESS Notification runs successfully.
+**/
+EFI_STATUS
+EFIAPI
+UaExitBootServices (
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
+ )
+{
+ DEBUG ((DEBUG_INFO, "Unregister User Authentication Smi\n"));
+
+ gSmst->SmiHandlerUnRegister(mSmmHandle);
+
+ return EFI_SUCCESS;
+}
+
/**
Main entry for this driver.

@@ -629,10 +654,11 @@ PasswordSmmInit (
)
{
EFI_STATUS Status;
- EFI_HANDLE SmmHandle;
EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock;
CHAR16
PasswordHistoryName[sizeof(USER_AUTHENTICATION_VAR_NAME)/sizeof(
CHAR16) + 5];
UINTN Index;
+ EFI_EVENT ExitBootServicesEvent;
+ EFI_EVENT LegacyBootEvent;

ASSERT (PASSWORD_HASH_SIZE == SHA256_DIGEST_SIZE);
ASSERT (PASSWORD_HISTORY_CHECK_COUNT < 0xFFFF); @@ -657,13
+683,20 @@ PasswordSmmInit (
ASSERT_EFI_ERROR (Status);
}

- SmmHandle = NULL;
- Status = gSmst->SmiHandlerRegister (SmmPasswordHandler,
&gUserAuthenticationGuid, &SmmHandle);
+ Status = gSmst->SmiHandlerRegister (SmmPasswordHandler,
+ &gUserAuthenticationGuid, &mSmmHandle);
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
return Status;
}

+ //
+ // Register for SmmExitBootServices and SmmLegacyBoot notification.
+ //
+ Status = gSmst->SmmRegisterProtocolNotify
+ (&gEdkiiSmmExitBootServicesProtocolGuid, UaExitBootServices,
+ &ExitBootServicesEvent); ASSERT_EFI_ERROR (Status); Status =
+ gSmst->SmmRegisterProtocolNotify (&gEdkiiSmmLegacyBootProtocolGuid,
+ UaExitBootServices, &LegacyBootEvent); ASSERT_EFI_ERROR (Status);
+
if (IsPasswordCleared()) {
DEBUG ((DEBUG_INFO, "IsPasswordCleared\n"));
SavePasswordToVariable (&gUserAuthenticationGuid, NULL, 0); diff --git
a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.inf
b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.inf
index 0b33b194..d73a2fe2 100644
---
a/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthenticationDx
eSmm/UserAuthenticationSmm.inf
+++
b/Features/Intel/UserInterface/UserAuthFeaturePkg/UserAuthentication
+++ DxeSmm/UserAuthenticationSmm.inf
@@ -48,6 +48,8 @@
[Protocols]
gEdkiiVariableLockProtocolGuid ## CONSUMES
gEfiSmmVariableProtocolGuid ## CONSUMES
+ gEdkiiSmmExitBootServicesProtocolGuid ## CONSUMES
+ gEdkiiSmmLegacyBootProtocolGuid ## CONSUMES

[Depex]
gEfiSmmVariableProtocolGuid AND gEfiVariableWriteArchProtocolGuid
--
2.31.1.windows.1

9361 - 9380 of 90922