Re: [edk2-devel] [PATCH v3 8/8] MdeModulePkg: Use SecureBootVariableLib in PlatformVarCleanupLib.

2021-06-22 Thread Sunny Wang
Hi Greg,
Why can't we make AuthVariableLib support DXE_DRIVER?

Best Regards,
Sunny Wang

-Original Message-
From: Grzegorz Bernacki 
Sent: Monday, June 21, 2021 5:59 PM
To: devel@edk2.groups.io; Grzegorz Bernacki 
Cc: gaolim...@byosoft.com.cn; l...@nuviainc.com; ardb+tianoc...@kernel.org; 
Samer El-Haj-Mahmoud ; Sunny Wang 
; Marcin Wojtas ; upstr...@semihalf.com; 
Yao, Jiewen ; Wang, Jian J ; Xu, 
Min M ; Laszlo Ersek ; Sami Mujawar 
; af...@apple.com; ray...@intel.com; 
jordan.l.jus...@intel.com; rebe...@bsdio.com; gre...@freebsd.org; Thomas 
Abraham ; chasel.c...@intel.com; 
nathaniel.l.desim...@intel.com; eric.d...@intel.com; 
michael.d.kin...@intel.com; zailiang@intel.com; yi.q...@intel.com; 
gra...@nuviainc.com; Radosław Biernacki ; Pete Batard 

Subject: Re: [edk2-devel] [PATCH v3 8/8] MdeModulePkg: Use 
SecureBootVariableLib in PlatformVarCleanupLib.

Hi,

I moved CreateTimeBasedPayload() to AuthVariableLib, but then I cannot
use it in SecureBootConfigDxe, cause AuthVariableLib does not support
DXE_DRIVER.
So:
- having that function only in AuthVariableLib does not work
- having that function only in SecureBootVariableLib, causes a lot of
changes in platform DSCs files and also causes MdeModulePkg to be
depended on SecurityPkg

Right now I tend to roll back the changes related to
CreateTimeBasedPayload() and just let the modules to have its own copy
of that function. What do you think?
thanks,
greg

pt., 18 cze 2021 o 10:03 Grzegorz Bernacki via groups.io
 napisał(a):
>
> Hi,
>
> Thanks for the comment, I will move that function to AuthVariableLib.
> greg
>
> czw., 17 cze 2021 o 04:35 gaoliming  napisał(a):
> >
> > Grzegorz:
> >   MdeModulePkg is generic base package. It should not depend on SecurityPkg.
> >
> >   I agree CreateTimeBasedPayload() is the generic API. It can be shared in
> > the different modules.
> >   I propose to add it into MdeModulePkg AuthVariableLib.
> >
> > Thanks
> > Liming
> > > -邮件原件-
> > > 发件人: devel@edk2.groups.io  代表 Grzegorz
> > > Bernacki
> > > 发送时间: 2021年6月14日 17:43
> > > 收件人: devel@edk2.groups.io
> > > 抄送: l...@nuviainc.com; ardb+tianoc...@kernel.org;
> > > samer.el-haj-mahm...@arm.com; sunny.w...@arm.com;
> > > m...@semihalf.com; upstr...@semihalf.com; jiewen@intel.com;
> > > jian.j.w...@intel.com; min.m...@intel.com; ler...@redhat.com;
> > > sami.muja...@arm.com; af...@apple.com; ray...@intel.com;
> > > jordan.l.jus...@intel.com; rebe...@bsdio.com; gre...@freebsd.org;
> > > thomas.abra...@arm.com; chasel.c...@intel.com;
> > > nathaniel.l.desim...@intel.com; gaolim...@byosoft.com.cn;
> > > eric.d...@intel.com; michael.d.kin...@intel.com; zailiang@intel.com;
> > > yi.q...@intel.com; gra...@nuviainc.com; r...@semihalf.com; p...@akeo.ie;
> > > Grzegorz Bernacki 
> > > 主题: [edk2-devel] [PATCH v3 8/8] MdeModulePkg: Use
> > > SecureBootVariableLib in PlatformVarCleanupLib.
> > >
> > > This commits removes CreateTimeBasedPayload() function from
> > > PlatformVarCleanupLib and uses exactly the same function from
> > > SecureBootVariableLib.
> > >
> > > Signed-off-by: Grzegorz Bernacki 
> > > ---
> > >  MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf |
> > > 2 +
> > >  MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
> > > |  1 +
> > >  MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
> > > | 84 
> > >  3 files changed, 3 insertions(+), 84 deletions(-)
> > >
> > > diff --git
> > > a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
> > > b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
> > > index 8d5db826a0..493d03e1d8 100644
> > > ---
> > > a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
> > > +++
> > > b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatformVarCleanupLib.inf
> > > @@ -34,6 +34,7 @@
> > >  [Packages]
> > >MdePkg/MdePkg.dec
> > >MdeModulePkg/MdeModulePkg.dec
> > > +  SecurityPkg/SecurityPkg.dec
> > >
> > >  [LibraryClasses]
> > >UefiBootServicesTableLib
> > > @@ -44,6 +45,7 @@
> > >PrintLib
> > >MemoryAllocationLib
> > >HiiLib
> > > +  SecureBootVariableLib
> > >
> > >  [Guids]
> > >gEfiIfrTianoGuid  ## SOMETIMES_PRODUCES   ##
> > > GUID
> > > diff --git a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
> > > b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
> > > index c809a7086b..94fbc7d2a4 100644
> > > --- a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
> > > +++ b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanup.h
> > > @@ -18,6 +18,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >
> > >  #include 
> > >  #include 
> > > diff --git
> > > a/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
> > > b/MdeModulePkg/Library/PlatformVarCleanupLib/PlatVarCleanupLib.c
> > > index 3875d614bb..204f1e00ad 100644
> > > --- 

[edk2-devel] [Patch V2 2/2] UefiPayloadPkg: consume the BootManagerMenuFile HOB

2021-06-22 Thread duntan
Consume the BootManagerMenuFile HOB in PlatformBootManagerLib
This Lib is in UefiPayloadPkg

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 

Signed-off-by: DunTan 
---
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c  | 52 

 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  5 
-
 UefiPayloadPkg/UefiPayloadPkg.dsc|  2 
+-
 3 files changed, 57 insertions(+), 2 deletions(-)

diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
index fce48d26a1..c4d317fa9e 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
@@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include "PlatformBootManager.h"
 #include "PlatformConsole.h"
 #include 
+#include 
+#include 
 
 UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCOL  
*mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;
 
@@ -286,3 +288,53 @@ PlatformBootManagerUnableToBoot (
   return;
 }
 
+/**
+  Get/update PcdBootManagerMenuFile from GUID HOB which will be assigned in 
bootloader.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The entry point is executed successfully.
+  @retval other Some error occurs.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformBootManagerLibConstructor (
+  IN EFI_HANDLEImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+)
+{
+  EFI_STATUS   Status;
+  UINTNSize;
+  VOID *GuidHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
+  UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU  *BootManagerMenuFile;
+
+  GuidHob = GetFirstGuidHob ();
+
+  if (GuidHob == NULL) {
+//
+// If the HOB is not create, the default value of PcdBootManagerMenuFile 
will be used.
+//
+return EFI_SUCCESS;
+  }
+
+  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA 
(GuidHob);
+  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE 
(GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+return EFI_NOT_FOUND;
+  }
+  if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) 
{
+BootManagerMenuFile = (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) 
GET_GUID_HOB_DATA (GuidHob);
+if (BootManagerMenuFile->Header.Length < 
UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, 
FileName)) {
+  return EFI_NOT_FOUND;
+}
+Size = sizeof (BootManagerMenuFile->FileName);
+Status = PcdSetPtrS (PcdBootManagerMenuFile, , 
>FileName);
+ASSERT_EFI_ERROR (Status);
+  } else {
+return EFI_NOT_FOUND;
+  }
+
+  return EFI_SUCCESS;
+}
diff --git 
a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 600a535282..9c4a9da943 100644
--- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -13,7 +13,7 @@
   MODULE_TYPE= DXE_DRIVER
   VERSION_STRING = 1.0
   LIBRARY_CLASS  = PlatformBootManagerLib|DXE_DRIVER
-
+  CONSTRUCTOR= PlatformBootManagerLibConstructor
 
 #
 # The following information is for reference only and not required by the 
build tools.
@@ -46,9 +46,11 @@
   HiiLib
   PrintLib
   PlatformHookLib
+  HobLib
 
 [Guids]
   gEfiEndOfDxeEventGroupGuid
+  gEdkiiBootManagerMenuFileGuid
 
 [Protocols]
   gEfiGenericMemTestProtocolGuid  ## CONSUMES
@@ -70,3 +72,4 @@
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
   gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 21b360256b..e46b867d30 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -289,7 +289,6 @@
 !endif
   gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable|TRUE
-  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
 
 
 !if $(SOURCE_DEBUG_ENABLE)
@@ -297,6 +296,7 @@
 !endif
 
 [PcdsPatchableInModule.common]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 
0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7
   

[edk2-devel] [Patch V2 1/2] UefiPayloadPkg: Add new structure for BootManagerMenuFile HOB

2021-06-22 Thread duntan
Add new structure for BootManagerMenuFile HOB in UefiPayloadPkg

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 

Signed-off-by: DunTan 
---
 UefiPayloadPkg/Include/Guid/BootManagerMenu.h | 27 +++
 UefiPayloadPkg/UefiPayloadPkg.dec |  3 +++
 2 files changed, 30 insertions(+)

diff --git a/UefiPayloadPkg/Include/Guid/BootManagerMenu.h 
b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
new file mode 100644
index 00..d17cdf3084
--- /dev/null
+++ b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
@@ -0,0 +1,27 @@
+/** @file
+  Define the structure for the Boot Manager Menu File.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
+#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
+
+#include 
+#include 
+
+#pragma pack (1)
+
+typedef struct {
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER   Header;
+  GUID   FileName;
+} UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU;
+
+#pragma pack()
+
+#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION 1
+
+extern GUID gEdkiiBootManagerMenuFileGuid;
+#endif
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec 
b/UefiPayloadPkg/UefiPayloadPkg.dec
index 105e1f5a1c..d2b2dbeb25 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -29,6 +29,9 @@
   #
   gBmpImageGuid   = { 0x878AC2CC, 0x5343, 0x46F2, { 
0xB5, 0x63, 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }
 
+  ##include/Guid/BootManagerMenu.h
+  gEdkiiBootManagerMenuFileGuid = { 0xdf939333, 0x42fc, 0x4b2a, { 0xa5, 0x9e, 
0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }}
+
   gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 
0x89, 0xc4, 0x29, 0x4, 0x33}}
   gUefiAcpiBoardInfoGuid   = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 
0xf1, 0x10, 0x6, 0xd9, 0xf}}
   gUefiSerialPortInfoGuid  = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 
0x8d, 0x62, 0xde, 0x87, 0xf1 } }
-- 
2.31.1.windows.1



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




[edk2-devel] [Patch V2 0/2] Add new structure for BootManagerMenuFile HOB and consume it

2021-06-22 Thread duntan
Add new structure for BootManagerMenuFile HOB
Consume the BootManagerMenuFile HOB

duntan (2):
  UefiPayloadPkg: Add new structure for BootManagerMenuFile HOB
  UefiPayloadPkg: consume the BootManagerMenuFile HOB

 UefiPayloadPkg/Include/Guid/BootManagerMenu.h| 27 
+++
 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c  | 52 

 UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  5 
-
 UefiPayloadPkg/UefiPayloadPkg.dec|  3 
+++
 UefiPayloadPkg/UefiPayloadPkg.dsc|  2 
+-
 5 files changed, 87 insertions(+), 2 deletions(-)
 create mode 100644 UefiPayloadPkg/Include/Guid/BootManagerMenu.h

-- 
2.31.1.windows.1



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




[edk2-devel] [Patch V2 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in UefiPayloadPkg

2021-06-22 Thread Zhiguang Liu
This PCD will be consumed by Universal Payload

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index c0de7fc734..35d714a6f9 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -362,6 +362,7 @@
 

 
 [PcdsDynamicExDefault]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationChange|FALSE
   gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg

2021-06-22 Thread Zhiguang Liu
To install ACPI SDT protocol, define PcdInstallAcpiSdtProtocol as TRUE.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 85055e9091..c0de7fc734 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -290,6 +290,8 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
+  ## This PCD specified whether ACPI SDT protocol is installed.
+  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
 
 [PcdsFixedAtBuild]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x1
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices

2021-06-22 Thread Zhiguang Liu
Some boot loader may already reserve MMIO/IO resource for IOAPIC and HPET,
so remove the assert when reserve MMIO/IO resource for IOAPIC and HPET

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c 
b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
index ffd3427fb3..04e968a232 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
@@ -41,13 +41,12 @@ ReserveResourceInGcd (
 );
 if (EFI_ERROR (Status)) {
   DEBUG ((
-DEBUG_ERROR,
+DEBUG_WARN,
 "Failed to add memory space :0x%lx 0x%lx\n",
 BaseAddress,
 Length
 ));
 }
-ASSERT_EFI_ERROR (Status);
 Status = gDS->AllocateMemorySpace (
 EfiGcdAllocateAddress,
 GcdType,
@@ -57,14 +56,20 @@ ReserveResourceInGcd (
 ImageHandle,
 NULL
 );
-ASSERT_EFI_ERROR (Status);
   } else {
 Status = gDS->AddIoSpace (
 GcdType,
 BaseAddress,
 Length
 );
-ASSERT_EFI_ERROR (Status);
+if (EFI_ERROR (Status)) {
+  DEBUG ((
+DEBUG_WARN,
+"Failed to add IO space :0x%lx 0x%lx\n",
+BaseAddress,
+Length
+));
+}
 Status = gDS->AllocateIoSpace (
 EfiGcdAllocateAddress,
 GcdType,
@@ -74,7 +79,6 @@ ReserveResourceInGcd (
 ImageHandle,
 NULL
 );
-ASSERT_EFI_ERROR (Status);
   }
   return Status;
 }
@@ -106,11 +110,9 @@ BlDxeEntryPoint (
   //
   // Report MMIO/IO Resources
   //
-  Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 
0xFEC0, SIZE_4KB, 0, ImageHandle); // IOAPIC
-  ASSERT_EFI_ERROR (Status);
+  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC0, 
SIZE_4KB, 0, ImageHandle); // IOAPIC
 
-  Status = ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 
0xFED0, SIZE_1KB, 0, ImageHandle); // HPET
-  ASSERT_EFI_ERROR (Status);
+  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED0, 
SIZE_1KB, 0, ImageHandle); // HPET
 
   //
   // Find the frame buffer information and update PCDs
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 10/12] UefiPayloadPkg: Add macro to disable some drivers

2021-06-22 Thread Zhiguang Liu
V2:
Change DISABLE_VARIABLE to EMU_VARIABLE_ENABLE

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++-
 UefiPayloadPkg/UefiPayloadPkg.fdf |  7 +++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index 155aea4bc4..85055e9091 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -87,6 +87,12 @@
   #
   DEFINE SHELL_TYPE   = BUILD_SHELL
 
+  #
+  # Disable features
+  #
+  DEFINE EMU_VARIABLE_ENABLE   = FALSE
+  DEFINE DISABLE_RESET_SYSTEM  = FALSE
+
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
   GCC:*_UNIXGCC_*_CC_FLAGS   = -DMDEPKG_NDEBUG
@@ -431,10 +437,13 @@
   MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
   MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
   
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+!if $(DISABLE_RESET_SYSTEM) == FALSE
   MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+!if $(EMU_VARIABLE_ENABLE) == FALSE
   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
-
+!endif
   #
   # Following are the DXE drivers
   #
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index 6073f9c1b4..4d186692da 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -105,9 +105,16 @@ INF 
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
 INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
 INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
 INF 
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
+
+!if $(DISABLE_RESET_SYSTEM) == FALSE
 INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
+!endif
+
 INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
+
+!if $(EMU_VARIABLE_ENABLE) == FALSE
 INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
+!endif
 
 INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
 INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc

2021-06-22 Thread Zhiguang Liu
Add a new macro "UNIVERSAL_PAYLOAD" to build Universal Payload.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadPkg.dsc | 22 ++
 UefiPayloadPkg/UefiPayloadPkg.fdf |  3 ++-
 2 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc 
b/UefiPayloadPkg/UefiPayloadPkg.dsc
index e3d669a6d6..155aea4bc4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -196,7 +196,11 @@
   TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
   ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf
   
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPortLib16550.inf
+!if $(UNIVERSAL_PAYLOAD) == TRUE
+  
PlatformHookLib|UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
+!else
   PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.inf
+!endif
   
PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
   IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
 
@@ -213,10 +217,12 @@
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
 !endif
   
PlatformSupportLib|UefiPayloadPkg/Library/PlatformSupportLibNull/PlatformSupportLibNull.inf
-!if $(BOOTLOADER) == "COREBOOT"
-  BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
-!else
-  BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+!if $(UNIVERSAL_PAYLOAD) == FALSE
+  !if $(BOOTLOADER) == "COREBOOT"
+BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
+  !else
+BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+  !endif
 !endif
 
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
@@ -383,10 +389,18 @@
 
 !if "IA32" in $(ARCH)
   [Components.IA32]
+  !if $(UNIVERSAL_PAYLOAD) == TRUE
+UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+  !else
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+  !endif
 !else
   [Components.X64]
+  !if $(UNIVERSAL_PAYLOAD) == TRUE
+UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+  !else
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+  !endif
 !endif
 
 [Components.X64]
diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf 
b/UefiPayloadPkg/UefiPayloadPkg.fdf
index ed7fbcaddb..6073f9c1b4 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.fdf
+++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
@@ -52,8 +52,9 @@ READ_STATUS= TRUE
 READ_LOCK_CAP  = TRUE
 READ_LOCK_STATUS   = TRUE
 
+!if $(UNIVERSAL_PAYLOAD) == FALSE
 INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
-
+!endif
 FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
 SECTION FV_IMAGE = DXEFV
 }
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 07/12] UefiPayloadPkg: Fix up UPL Pcd database

2021-06-22 Thread Zhiguang Liu
V1:
Edk2 bootloader will pass the pei pcd database, and UPL also contain a
PCD database.
Dxe PCD driver has the assumption that the two PCD database can be
catenated and the local token number should be successive。
This patch will manually fix up the UPL PCD database to meet that
assumption.
V2:
Update the function comments

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 19 
---
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 45 
+
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 57 
+
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  2 ++
 UefiPayloadPkg/UefiPayloadPkg.dec |  2 ++
 UefiPayloadPkg/UefiPayloadPkg.dsc |  1 +
 6 files changed, 119 insertions(+), 7 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c 
b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index f5d70c59f8..0b6cb47cd0 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -114,20 +114,23 @@ LoadPeCoffImage (
 }

 

 /**

-  This function searchs a given file type within a valid FV.

+  This function searchs a given file type with a given Guid within a valid FV.

+  If input Guid is NULL, will locate the first section having the given file 
type

 

   @param FvHeaderA pointer to firmware volume header that contains the 
set of files

  to be searched.

   @param FileTypeFile type to be searched.

+  @param GuidWill ignore if it is NULL.

   @param FileHeader  A pointer to the discovered file, if successful.

 

   @retval EFI_SUCCESSSuccessfully found FileType

   @retval EFI_NOT_FOUND  File type can't be found.

 **/

 EFI_STATUS

-FvFindFile (

+FvFindFileByTypeGuid (

   IN  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,

   IN  EFI_FV_FILETYPE FileType,

+  IN  EFI_GUID*Guid   OPTIONAL,

   OUT EFI_FFS_FILE_HEADER **FileHeader

   )

 {

@@ -171,8 +174,10 @@ FvFindFile (
 // Look for file type

 //

 if (File->Type == FileType) {

-  *FileHeader = File;

-  return EFI_SUCCESS;

+  if (Guid == NULL || CompareGuid(>Name, Guid)) {

+*FileHeader = File;

+return EFI_SUCCESS;

+  }

 }

   }

 

@@ -266,7 +271,7 @@ LoadDxeCore (
   //

   // DXE FV is inside Payload FV. Here find DXE FV from Payload FV

   //

-  Status = FvFindFile (PayloadFv, EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, 
);

+  Status = FvFindFileByTypeGuid (PayloadFv, 
EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, NULL, );

   if (EFI_ERROR (Status)) {

 return Status;

   }

@@ -283,7 +288,7 @@ LoadDxeCore (
   //

   // Find DXE core file from DXE FV

   //

-  Status = FvFindFile (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, );

+  Status = FvFindFileByTypeGuid (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, NULL, 
);

   if (EFI_ERROR (Status)) {

 return Status;

   }

@@ -330,7 +335,7 @@ UniversalLoadDxeCore (
   //

   // Find DXE core file from DXE FV

   //

-  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, );

+  Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL, 
);

   if (EFI_ERROR (Status)) {

 return Status;

   }

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index dff7b6b87f..331724c687 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -35,6 +35,7 @@
 #include 

 #include 

 #include 

+#include 

 

 #define LEGACY_8259_MASK_REGISTER_MASTER  0x21

 #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1

@@ -159,4 +160,48 @@ HandOffToDxeCore (
   IN EFI_PEI_HOB_POINTERS   HobList

   );

 

+EFI_STATUS

+FixUpPcdDatabase (

+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv

+  );

+

+/**

+  This function searchs a given section type within a valid FFS file.

+

+  @param  FileHeaderA pointer to the file header that contains the 
set of sections to

+be searched.

+  @param  SearchTypeThe value of the section type to search.

+  @param  SectionData   A pointer to the discovered section, if 
successful.

+

+  @retval EFI_SUCCESS   The section was found.

+  @retval EFI_NOT_FOUND The section was not found.

+

+**/

+EFI_STATUS

+FileFindSection (

+  IN EFI_FFS_FILE_HEADER*FileHeader,

+  IN EFI_SECTION_TYPE   SectionType,

+  OUT VOID  **SectionData

+  );

+

+/**

+  This function searchs a given file type with a given Guid within a valid FV.

+  If input Guid is NULL, will locate the first section having the given file 
type

+

+  @param FvHeaderA pointer to firmware volume 

[edk2-devel] [Patch V2 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload

2021-06-22 Thread Zhiguang Liu
>From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information,
and get the Dxe Core from the FV.
Also, make sure if there are muliple FV hob, the FV hob pointing to this FV
will be the first in the hob list.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 47 
+++
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 17 
+
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 44 
++--
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  1 +
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c |  4 ++--
 5 files changed, 109 insertions(+), 4 deletions(-)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c 
b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
index de9dbb0b0e..f5d70c59f8 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
@@ -305,3 +305,50 @@ LoadDxeCore (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Find DXE core from FV and build DXE core HOBs.
+
+  @param[in]   DxeFv The FV where to find the DXE core.
+  @param[out]  DxeCoreEntryPoint DXE core entry point
+
+  @retval EFI_SUCCESSIf it completed successfully.
+  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
+  )
+{
+  EFI_STATUS  Status;
+  EFI_FFS_FILE_HEADER *FileHeader;
+  VOID*PeCoffImage;
+  EFI_PHYSICAL_ADDRESSImageAddress;
+  UINT64  ImageSize;
+
+  //
+  // Find DXE core file from DXE FV
+  //
+  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, );
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID 
**));
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  //
+  // Get DXE core info
+  //
+  Status = LoadPeCoffImage (PeCoffImage, , , 
DxeCoreEntryPoint);
+  if (EFI_ERROR (Status)) {
+return Status;
+  }
+
+  BuildModuleHob (>Name, ImageAddress, EFI_SIZE_TO_PAGES ((UINT32) 
ImageSize) * EFI_PAGE_SIZE, *DxeCoreEntryPoint);
+
+  return EFI_SUCCESS;
+}
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 1ad7a37023..dff7b6b87f 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #define LEGACY_8259_MASK_REGISTER_MASTER  0x21
 #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1
@@ -127,6 +129,21 @@ LoadDxeCore (
   OUT PHYSICAL_ADDRESS*DxeCoreEntryPoint
   );
 
+/**
+  Find DXE core from FV and build DXE core HOBs.
+
+  @param[in]   DxeFv The FV where to find the DXE core.
+  @param[out]  DxeCoreEntryPoint DXE core entry point
+
+  @retval EFI_SUCCESSIf it completed successfully.
+  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
+**/
+EFI_STATUS
+UniversalLoadDxeCore (
+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
+  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
+  );
+
 /**
Transfers control to DxeCore.
 
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
index 66e87bcb9b..9d59454486 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -179,7 +179,8 @@ FindAnotherHighestBelow4GResourceDescriptor (
 **/
 EFI_STATUS
 BuildHobs (
-  IN UINTN BootloaderParameter
+  IN  UINTN   BootloaderParameter,
+  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
   )
 {
   EFI_PEI_HOB_POINTERS Hob;
@@ -190,6 +191,10 @@ BuildHobs (
   EFI_PHYSICAL_ADDRESS MemoryTop;
   EFI_HOB_RESOURCE_DESCRIPTOR  *PhitResourceHob;
   EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
+  UNIVERSAL_PAYLOAD_EXTRA_DATA *ExtraData;
+  UINT8*GuidHob;
+  EFI_HOB_FIRMWARE_VOLUME  *FvHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
 
   Hob.Raw = (UINT8 *) BootloaderParameter;
   MinimalNeededSize = FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
@@ -254,6 +259,10 @@ BuildHobs (
   // From now on, mHobList will point to the new Hob range.
   //
 
+  //
+  // Create an empty FvHob for the DXE FV that contains DXE core.
+  //
+  BuildFvHob ((EFI_PHYSICAL_ADDRESS) 0, 0);
   //
   // Since payload created new Hob, move all hobs except PHIT from boot loader 
hob list.
   //
@@ -265,6 +274,29 @@ BuildHobs (
 Hob.Raw = GET_NEXT_HOB (Hob);
   }
 
+  //
+  // Get DXE FV location
+  //
+  GuidHob = GetFirstGuidHob();
+  ASSERT (GuidHob != 

[edk2-devel] [Patch V2 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload

2021-06-22 Thread Zhiguang Liu
This patch create the UniversalPayload Entry based on the UefiPayload
Entry. It implements the logic to find a proper memory range to create the
new Hob and migrate the Hobs from Bootloader.
To make the change history clear, the logic to get the DxeCore will be in
the next patch.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 311 
+++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  91 
+++
 2 files changed, 402 insertions(+)

diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
new file mode 100644
index 00..66e87bcb9b
--- /dev/null
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
@@ -0,0 +1,311 @@
+/** @file
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "UefiPayloadEntry.h"
+
+#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT  
   | \
+   EFI_RESOURCE_ATTRIBUTE_INITIALIZED  
   | \
+   EFI_RESOURCE_ATTRIBUTE_TESTED   
   | \
+   EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED   
   | \
+   EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED  
   | \
+   
EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
+   
EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED | \
+   EFI_RESOURCE_ATTRIBUTE_16_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_32_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_64_BIT_IO
   | \
+   EFI_RESOURCE_ATTRIBUTE_PERSISTENT   
   )
+
+#define TESTED_MEMORY_ATTRIBUTES  (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+   EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+   EFI_RESOURCE_ATTRIBUTE_TESTED  )
+
+extern VOID  *mHobList;
+
+/**
+  Add HOB into HOB list
+
+  @param[in]  HobThe HOB to be added into the HOB list.
+**/
+VOID
+AddNewHob (
+  IN EFI_PEI_HOB_POINTERS*Hob
+  )
+{
+  EFI_PEI_HOB_POINTERSNewHob;
+
+  if (Hob->Raw == NULL) {
+return;
+  }
+  NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header->HobLength);
+
+  if (NewHob.Header != NULL) {
+CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header->HobLength - 
sizeof (EFI_HOB_GENERIC_HEADER));
+  }
+}
+
+/**
+  Found the Resource Descriptor HOB that contains a range
+
+  @param[in] Base   Memory start address
+  @param[in] TopMemory Top.
+
+  @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindResourceDescriptorByRange (
+  VOID  *HobList,
+  EFI_PHYSICAL_ADDRESS  Base,
+  EFI_PHYSICAL_ADDRESS  Top
+  )
+{
+  EFI_PEI_HOB_POINTERS Hob;
+  EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
+
+  for (Hob.Raw = (UINT8 *) HobList; !END_OF_HOB_LIST(Hob); Hob.Raw = 
GET_NEXT_HOB(Hob)) {
+//
+// Skip all HOBs except Resource Descriptor HOBs
+//
+if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+  continue;
+}
+
+//
+// Skip Resource Descriptor HOBs that do not describe tested system memory
+//
+ResourceHob = Hob.ResourceDescriptor;
+if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
+  continue;
+}
+if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) != 
TESTED_MEMORY_ATTRIBUTES) {
+  continue;
+}
+
+//
+// Skip Resource Descriptor HOBs that do not contain the PHIT range 
EfiFreeMemoryBottom..EfiFreeMemoryTop
+//
+if (Base < ResourceHob->PhysicalStart) {
+  continue;
+}
+if (Top > (ResourceHob->PhysicalStart + ResourceHob->ResourceLength)) {
+  continue;
+}
+return ResourceHob;
+  }
+  return NULL;
+}
+
+/**
+  Find the highest below 4G memory resource descriptor, except the input 
Resource Descriptor.
+
+  @param[in] HobList Hob start address
+  @param[in] MinimalNeededSize   Minimal needed size.
+  @param[in] ExceptResourceHob   Ignore this Resource Descriptor.
+
+  @return The pointer to the Resource Descriptor HOB.
+**/
+EFI_HOB_RESOURCE_DESCRIPTOR *
+FindAnotherHighestBelow4GResourceDescriptor (
+  IN VOID   

[edk2-devel] [Patch V2 04/12] UefiPayloadPkg: Update the function definition of HobConstructor

2021-06-22 Thread Zhiguang Liu
Update the function defination of HobConstructor to align the Phit Hob
structure.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c| 26 
+-
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c |  5 +
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 16 
 3 files changed, 22 insertions(+), 25 deletions(-)

diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c 
b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
index 23a749edf1..768c3db770 100644
--- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
+++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
@@ -39,14 +39,14 @@ GetHobList (
 /**
   Build a Handoff Information Table HOB
 
-  This function initialize a HOB region from EfiMemoryBegin with length
-  EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+  This function initialize a HOB region from EfiMemoryBegin to
+  EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
   be inside the HOB region.
 
-  @param[in] EfiMemoryBegin   Total memory start address
-  @param[in] EfiMemoryLength  Total memory length reported in handoff HOB.
-  @param[in] EfiFreeMemoryBottom  Free memory start address
-  @param[in] EfiFreeMemoryTop Free memory end address.
+  @param[in] EfiMemoryBottom   Total memory start address
+  @param[in] EfiMemoryTop  Total memory end address.
+  @param[in] EfiFreeMemoryBottom   Free memory start address
+  @param[in] EfiFreeMemoryTop  Free memory end address.
 
   @return   The pointer to the handoff HOB table.
 
@@ -54,8 +54,8 @@ GetHobList (
 EFI_HOB_HANDOFF_INFO_TABLE*
 EFIAPI
 HobConstructor (
-  IN VOID   *EfiMemoryBegin,
-  IN UINTN  EfiMemoryLength,
+  IN VOID   *EfiMemoryBottom,
+  IN VOID   *EfiMemoryTop,
   IN VOID   *EfiFreeMemoryBottom,
   IN VOID   *EfiFreeMemoryTop
   )
@@ -77,11 +77,11 @@ HobConstructor (
   Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
   Hob->BootMode= BOOT_WITH_FULL_CONFIGURATION;
 
-  Hob->EfiMemoryTop= (UINTN)EfiMemoryBegin + EfiMemoryLength;
-  Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
-  Hob->EfiFreeMemoryTop= (UINTN)EfiFreeMemoryTop;
-  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
-  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
+  Hob->EfiMemoryTop= (EFI_PHYSICAL_ADDRESS) EfiMemoryTop;
+  Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS) EfiMemoryBottom;
+  Hob->EfiFreeMemoryTop= (EFI_PHYSICAL_ADDRESS) EfiFreeMemoryTop;
+  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1);
+  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
 
   mHobList = Hob;
   return Hob;
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 19d2a8d3bd..ed956c447c 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -561,7 +561,6 @@ PayloadEntry (
   PHYSICAL_ADDRESS  DxeCoreEntryPoint;
   EFI_HOB_HANDOFF_INFO_TABLE*HandoffHobTable;
   UINTN MemBase;
-  UINTN MemSize;
   UINTN HobMemBase;
   UINTN HobMemTop;
   EFI_PEI_HOB_POINTERS  Hob;
@@ -580,9 +579,7 @@ PayloadEntry (
   HobMemBase = ALIGN_VALUE (MemBase + PcdGet32 (PcdPayloadFdMemSize), 
SIZE_1MB);
   HobMemTop  = HobMemBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
 
-  // DXE core assumes the memory below HOB region could be used, so include 
the FV region memory into HOB range.
-  MemSize= HobMemTop - MemBase;
-  HandoffHobTable = HobConstructor ((VOID *)MemBase, MemSize, (VOID 
*)HobMemBase, (VOID *)HobMemTop);
+  HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID *)HobMemBase, 
(VOID *)HobMemTop);
 
   // Build HOB based on information from Bootloader
   Status = BuildHobFromBl ();
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h 
b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 5a1b37be16..1ad7a37023 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -93,14 +93,14 @@ UpdateStackHob (
 /**
   Build a Handoff Information Table HOB
 
-  This function initialize a HOB region from EfiMemoryBegin with length
-  EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
+  This function initialize a HOB region from EfiMemoryBegin to
+  EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop should
   be inside the HOB region.
 
-  @param[in] EfiMemoryBegin   Total memory start address
-  @param[in] EfiMemoryLength  Total memory length reported in handoff HOB.
-  @param[in] EfiFreeMemoryBottom  Free memory start address
-  @param[in] EfiFreeMemoryTop Free memory end address.
+  

[edk2-devel] [Patch V2 00/12] Enable Universal Payload in UefiPayloadPkg

2021-06-22 Thread Zhiguang Liu
This whole patch set will enable some basic feature of Universal Payload
in UefiPayloadPkg.

V2:
Modify the 1st, 7th, 10th patch according to the comments.

Zhiguang Liu (12):
  UefiPayloadPkg: Add HobLib for UniversalPayload
  MdeModulePkg: Add new structure for the Universal Payload Serial Port
Info
  UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload
  UefiPayloadPkg: Update the function definition of HobConstructor
  UefiPayloadPkg: Create separate Payload Entry for UniversalPayload
  UefiPayloadPkg: Get and enter DxeCore for Universal Payload
  UefiPayloadPkg: Fix up UPL Pcd database
  UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc
  UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for
devices
  UefiPayloadPkg: Add macro to disable some drivers
  UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in
UefiPayloadPkg
  UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in
UefiPayloadPkg

 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h |  
30 ++
 MdeModulePkg/MdeModulePkg.dec  |   
3 +++
 UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c |  
20 +++-
 UefiPayloadPkg/Include/Library/DxeHobListLib.h |  
27 +++
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf |  
36 
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni |  
16 
 UefiPayloadPkg/Library/DxeHobLib/HobLib.c  | 
597 
+
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c   |  
66 ++
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf |  
35 +++
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c   |  
20 
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf |  
28 
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c|  
28 ++--
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf   |   
2 +-
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c   |  
82 
++
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf |  
41 +
 UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c  |  
64 ++--
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c |   
5 +
 UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h |  
78 
++
 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c| 
408 

 UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf  |  
94 
++
 UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c  |   
4 ++--
 UefiPayloadPkg/UefiPayloadPkg.dec  |   
2 ++
 UefiPayloadPkg/UefiPayloadPkg.dsc  |  
52 +++-
 UefiPayloadPkg/UefiPayloadPkg.fdf  |  
10 +-
 24 files changed, 1694 insertions(+), 54 deletions(-)
 create mode 100644 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
 create mode 100644 UefiPayloadPkg/Include/Library/DxeHobListLib.h
 create mode 100644 

[edk2-devel] [Patch V2 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload

2021-06-22 Thread Zhiguang Liu
Add a new separate PlatformHookLib for Universal Payload to consume Guid
Hob gUniversalPayloadSerialPortInfoGuid to get serial port information

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Reviewed-by: Guo Dong 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c   | 
82 
++
 UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf | 
41 +
 2 files changed, 123 insertions(+)

diff --git 
a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c 
b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
new file mode 100644
index 00..6705f29505
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.c
@@ -0,0 +1,82 @@
+/** @file
+  Platform Hook Library instance for UART device.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+  Performs platform specific initialization required for the CPU to access
+  the hardware associated with a SerialPortLib instance.  This function does
+  not initialize the serial port hardware itself.  Instead, it initializes
+  hardware devices that are required for the CPU to access the serial port
+  hardware.  This function may be called more than once.
+
+  @retval RETURN_SUCCESS   The platform specific initialization succeeded.
+  @retval RETURN_DEVICE_ERROR  The platform specific initialization could not 
be completed.
+
+**/
+RETURN_STATUS
+EFIAPI
+PlatformHookSerialPortInitialize (
+  VOID
+  )
+{
+  RETURN_STATUS   Status;
+  UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO  *SerialPortInfo;
+  UINT8   *GuidHob;
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER*GenericHeader;
+
+  GuidHob = GetFirstGuidHob ();
+  if (GuidHob == NULL) {
+return EFI_NOT_FOUND;
+  }
+
+  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *) GET_GUID_HOB_DATA 
(GuidHob);
+  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE 
(GuidHob)) || (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) {
+return EFI_NOT_FOUND;
+  }
+
+  if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
+SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *) GET_GUID_HOB_DATA 
(GuidHob);
+if (GenericHeader->Length < UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD 
(UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
+  //
+  // Return if can't find the Serial Port Info Hob with enough length
+  //
+  return EFI_NOT_FOUND;
+}
+
+Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet32S (PcdSerialRegisterStride, 
SerialPortInfo->RegisterStride);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+Status = PcdSet64S (PcdUartDefaultBaudRate, SerialPortInfo->BaudRate);
+if (RETURN_ERROR (Status)) {
+  return Status;
+}
+
+return RETURN_SUCCESS;
+  }
+
+  return EFI_NOT_FOUND;
+}
diff --git 
a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf 
b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
new file mode 100644
index 00..41e05ddf54
--- /dev/null
+++ b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.inf
@@ -0,0 +1,41 @@
+## @file
+#  Platform Hook Library instance for UART device for Universal Payload.
+#
+#  Copyright (c) 2021, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = PlatformHookLib
+  FILE_GUID  = 807E05AB-9411-429F-97F0-FE425BF6B094
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = PlatformHookLib
+  CONSTRUCTOR= PlatformHookSerialPortInitialize
+
+[Sources]
+  PlatformHookLib.c
+
+[LibraryClasses]
+  PcdLib
+  BaseLib
+  HobLib
+  DxeHobListLib
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  UefiPayloadPkg/UefiPayloadPkg.dec
+
+[Guids]
+  gUniversalPayloadSerialPortInfoGuid
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseMmio ## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase## PRODUCES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdSerialBaudRate## PRODUCES
+  

[edk2-devel] [Patch V2 02/12] MdeModulePkg: Add new structure for the Universal Payload Serial Port Info

2021-06-22 Thread Zhiguang Liu
Add Universal Payload Serial Port Info definition header file according to
Universal Payload's documentation as below:
https://universalpayload.github.io/documentation/

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Ray Ni 
Reviewed-by: Hao A Wu 
Signed-off-by: Zhiguang Liu 
---
 MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h | 30 
++
 MdeModulePkg/MdeModulePkg.dec  |  3 +++
 2 files changed, 33 insertions(+)

diff --git a/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h 
b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
new file mode 100644
index 00..87181f7634
--- /dev/null
+++ b/MdeModulePkg/Include/UniversalPayload/SerialPortInfo.h
@@ -0,0 +1,30 @@
+/** @file
+  This file defines the structure for serial port info.
+
+  Copyright (c) 2021, Intel Corporation. All rights reserved.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+  @par Revision Reference:
+- Universal Payload Specification 0.75 
(https://universalpayload.github.io/documentation/)
+**/
+
+#ifndef UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
+
+#include 
+
+#pragma pack(1)
+typedef struct {
+  UNIVERSAL_PAYLOAD_GENERIC_HEADER   Header;
+  BOOLEANUseMmio;
+  UINT8  RegisterStride;
+  UINT32 BaudRate;
+  EFI_PHYSICAL_ADDRESS   RegisterBase;
+} UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO;
+#pragma pack()
+
+#define UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION 1
+
+extern GUID gUniversalPayloadSerialPortInfoGuid;
+
+#endif //  UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 10602a8f79..ad84421cf3 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -422,6 +422,9 @@
   ## Include/UniversalPayload/ExtraData.h
   gUniversalPayloadExtraDataGuid = {0x15a5baf6, 0x1c91, 0x467d, {0x9d, 0xfb, 
0x31, 0x9d, 0x17, 0x8d, 0x4b, 0xb4}}
 
+  ## Include/UniversalPayload/SerialPortInfo.h
+  gUniversalPayloadSerialPortInfoGuid = { 0xaa7e190d, 0xbe21, 0x4409, { 0x8e, 
0x67, 0xa2, 0xcd, 0xf, 0x61, 0xe1, 0x70 } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
-- 
2.30.0.windows.2



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




[edk2-devel] [Patch V2 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload

2021-06-22 Thread Zhiguang Liu
V1:
For payload entry, use PayloadEntryHobLib as HobLib and payload entry
should initialize hob base.
For DxeCore, use new added DxeHobLib as HobLib, and DxeCore will
initialize hob base.
For Dxe Driver, use new added DxeHobLib as HobLib, and use DxeHobListLib
to initialize hob base.

V2:
Remove the UefiLib since it won't be needed.
Adding a new library DxeHobLib + DxeHobListLib instead of using the
DxeHobLib.inf in MdePkg is because the constructor needed be separated
from DxeHobLib.
If not, when building UefiPayloadPkg, the dependency chain is as below:
DebugLib -> SerialPortLib -> PlatformHookLib -> HobLib -> DebugLib
Each library has a constructor, and this becomes a constructor circle.
To break the circle, separate the constructor from the HobLib as a new
DxeHobListLib, which won't depend on DebugLib.

Cc: Maurice Ma 
Cc: Guo Dong 
Cc: Benjamin You 
Signed-off-by: Ray Ni 
Signed-off-by: Zhiguang Liu 
---
 UefiPayloadPkg/Include/Library/DxeHobListLib.h   |  27 
+++
 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf   |  36 

 UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni   |  16 

 UefiPayloadPkg/Library/DxeHobLib/HobLib.c| 597 
+
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c |  66 
++
 UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf   |  35 
+++
 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c |  20 

 UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf   |  28 

 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c  |   2 +-
 UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf |   2 +-
 UefiPayloadPkg/UefiPayloadPkg.dsc|  15 
+++
 11 files changed, 838 insertions(+), 6 deletions(-)

diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h 
b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
new file mode 100644
index 00..7e9b23f6d7
--- /dev/null
+++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
@@ -0,0 +1,27 @@
+/** @file
+  Provides a service to retrieve a pointer to the start of HOB list.
+  Only available to DXE module types.
+
+  This library does not contain any functions or macros.  It simply exports a 
global
+  pointer to the start of HOB list as defined in the Platform Initialization 
Driver
+  Execution Environment Core Interface Specification.  The library constructor 
must
+  initialize this global pointer to the start of HOB list, so it is available 
at the
+  module's entry point.  Since there is overhead in looking up the pointer to 
the start
+  of HOB list, only those modules that actually require access to the HOB list
+  should use this library.
+
+Copyright (c) 2021, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef __DXE_HOB_LIST_LIB_H__
+#define __DXE_HOB_LIST_LIB_H__
+
+///
+/// Cache copy of the start of HOB list
+///
+extern VOID  *gHobList;
+
+#endif
+
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf 
b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
new file mode 100644
index 00..ff334a0d41
--- /dev/null
+++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
@@ -0,0 +1,36 @@
+## @file
+# HOB Library implementation for Payload Phase.
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = DxeHobLib
+  MODULE_UNI_FILE= DxeHobLib.uni
+  FILE_GUID  = 1a15b8b3-3e8a-4698-87b9-65aad9993b52
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = HobLib|DXE_DRIVER DXE_RUNTIME_DRIVER 
SMM_CORE DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+#
+#  VALID_ARCHITECTURES   = IA32 X64 EBC
+#
+
+[Sources]
+  HobLib.c
+
+
+[Packages]
+  MdePkg/MdePkg.dec
+  UefiPayloadPkg/UefiPayloadPkg.dec
+
+
+[LibraryClasses]
+  BaseMemoryLib
+  DebugLib
+  DxeHobListLib
diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni 

Re: [edk2-rfc] [edk2-devel] RFC: design review for TDVF in OVMF

2021-06-22 Thread Min Xu
On 06/22/2021 9:35 PM, Laszlo wrote: 
> 
> For example, as I stated earlier, "OvmfPkg/AcpiPlatformDxe" is a driver where
> I'd like to see zero changes, for either SEV or TDX. If the TD Mailbox 
> location has
> to be reported to the OS via the MADT, and QEMU cannot (or must not)
> populate that field in the MADT, then a separate, TDX-specific edk2 driver 
> should
> locate the MADT (installed technically by "OvmfPkg/AcpiPlatformDxe", earlier),
> and update the field.
> 
We have updated the design of AcpiPlatformDxe. Please see the slides in below 
link.
https://edk2.groups.io/g/devel/files/Designs/2021/0611/TDVF_Design_Review-AcpiPlatformDxe.pptx

Because MailboxAddress in MADT table is determined in runtime in Tdx, so we 
separate the update of the MADT table in TdxDxe driver and keep AcpiPlatformDxe 
clean
and shim.
>
>
> Thanks,
> Laszlo
> 
Thanks
Min


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




Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add new structure for BootManagerMenuFile HOB

2021-06-22 Thread Ni, Ray
I agree. We can use gEdkiiBootManagerMenuFileGuid.

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Guo Dong
Sent: Wednesday, June 23, 2021 6:58 AM
To: Tan, Dun ; devel@edk2.groups.io
Cc: Ma, Maurice ; You, Benjamin 
Subject: Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add new structure for 
BootManagerMenuFile HOB


+  gUniversalPayloadBootManagerMenuFileGuid

Had better rename this guid to remove "UniversalPayload" from the name since 
this guid is not defined in universal payload specification. 

Thanks,
Guo
> -Original Message-
> From: Tan, Dun 
> Sent: Monday, June 21, 2021 1:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo 
> ; You, Benjamin ; Tan, Dun 
> 
> Subject: [PATCH 1/2] UefiPayloadPkg: Add new structure for 
> BootManagerMenuFile HOB
> 
> Add new structure for BootManagerMenuFile HOB in UefiPayloadPkg
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> 
> Signed-off-by: DunTan 
> ---
>  UefiPayloadPkg/Include/Guid/BootManagerMenu.h | 27
> +++
>  UefiPayloadPkg/UefiPayloadPkg.dec |  3 +++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> new file mode 100644
> index 00..10fb874640
> --- /dev/null
> +++ b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> @@ -0,0 +1,27 @@
> +/** @file
> +  Define the structure for the Boot Manager Menu File.
> +
> +Copyright (c) 2021, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
> +#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
> +
> +#include 
> +#include 
> +
> +#pragma pack (1)
> +
> +typedef struct {
> +  UNIVERSAL_PAYLOAD_GENERIC_HEADER   Header;
> +  GUID   FileName;
> +} UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU;
> +
> +#pragma pack()
> +
> +#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION 1
> +
> +extern GUID gUniversalPayloadBootManagerMenuFileGuid;
> +#endif
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
> b/UefiPayloadPkg/UefiPayloadPkg.dec
> index 105e1f5a1c..850592976d 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
> @@ -29,6 +29,9 @@
>#
>gBmpImageGuid   = { 0x878AC2CC, 0x5343, 0x46F2, { 
> 0xB5, 0x63,
> 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }
> 
> +  ##include/Guid/BootManagerMenu.h
> +  gUniversalPayloadBootManagerMenuFileGuid = { 0xdf939333, 0x42fc,
> 0x4b2a, { 0xa5, 0x9e, 0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }}
> +
>gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 
> 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}}
>gUefiAcpiBoardInfoGuid   = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e,
> 0xf1, 0x10, 0x6, 0xd9, 0xf}}
>gUefiSerialPortInfoGuid  = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 
> 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } }
> --
> 2.31.1.windows.1








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




Re: [edk2-devel] [edk2-platforms] [PATCH V1 0/2] Support for TiogaPass Platform and Override generic PciBus Driver with

2021-06-22 Thread Oram, Isaac W
Series Reviewed-by:  isaac.w.o...@intel.com

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Nate DeSimone
Sent: Wednesday, June 16, 2021 5:52 PM
To: devel@edk2.groups.io
Cc: KARPAGAVINAYAGAM, MANICKAVASAKAM 
Subject: [edk2-devel] FW: [edk2-platforms] [PATCH V1 0/2] Support for TiogaPass 
Platform and Override generic PciBus Driver with

Hi Everyone,

It seems like Manic is having issues sending his patch series to the mailing 
list. I will forward it to the list on Manic's behalf while he gets these 
issues sorted out with his email system.

Thanks,
Nate

-Original Message-
From: manickavasakam karpagavinayagam  
Sent: Wednesday, June 16, 2021 2:44 PM
To: devel@edk2.groups.io
Cc: Oram, Isaac W ; Desimone, Nathaniel L 
; fel...@ami.com; DOPPALAPUDI, HARIKRISHNA 
; Jha, Manish ; Bobroff, Zachary 
; KARPAGAVINAYAGAM, MANICKAVASAKAM 
Subject: [edk2-platforms] [PATCH V1 0/2] Support for TiogaPass Platform and 
Override generic PciBus Driver with

Add BoardTiogaPass packages to support TiogaPass Platform Enabled Network, 
ISCSI,IPMI, SMBIOS, Performance Measurement Remove AST2500 UEFI option ROM 
driver from PurleyOpenBoardPkg
AST2500 UEFI option ROM move to edk2-non-osi ASpeedGopBinPkg Update copyright 
headers

manickavasakam karpagavinayagam (2):
  PurleyOpenBoardPkg : Support for TiogaPass Platform
  PurleyOpenBoardPkg : Override generic PciBus Driver with Platform
specific instance of PciBus driver.

 .../IpmiFeaturePkg/GenericIpmi/Dxe/IpmiInit.c |8 +-
 .../Acpi/BoardAcpiDxe/AmlOffsetTable.c|  453 +-
 .../Acpi/BoardAcpiDxe/BoardAcpiDxeDsdt.c  |3 +
 .../BoardTiogaPass/CoreDxeInclude.dsc |  168 +
 .../BoardTiogaPass/CoreUefiBootInclude.fdf|   82 +
 .../BoardTiogaPass/GitEdk2MinTiogaPass.bat|   93 +
 .../BasePlatformHookLib/BasePlatformHookLib.c |  389 +
 .../BasePlatformHookLib.inf   |   36 +
 .../BoardAcpiLib/DxeBoardAcpiTableLib.c   |   36 +
 .../BoardAcpiLib/DxeBoardAcpiTableLib.inf |   40 +
 .../BoardAcpiLib/DxeTiogaPassAcpiTableLib.c   |   53 +
 .../BoardAcpiLib/SmmBoardAcpiEnableLib.c  |   62 +
 .../BoardAcpiLib/SmmBoardAcpiEnableLib.inf|   41 +
 .../BoardAcpiLib/SmmSiliconAcpiEnableLib.c|  120 +
 .../BoardAcpiLib/SmmTiogaPassAcpiEnableLib.c  |   37 +
 .../Library/BoardInitLib/AllLanesEparam.c |   44 +
 .../Library/BoardInitLib/GpioTable.c  |  296 +
 .../Library/BoardInitLib/IioBifur.c   |   70 +
 .../BoardInitLib/PeiBoardInitPostMemLib.c |   46 +
 .../BoardInitLib/PeiBoardInitPostMemLib.inf   |   37 +
 .../BoardInitLib/PeiBoardInitPreMemLib.c  |  112 +
 .../BoardInitLib/PeiBoardInitPreMemLib.inf|   69 +
 .../Library/BoardInitLib/PeiTiogaPassDetect.c |   28 +
 .../BoardInitLib/PeiTiogaPassInitLib.h|   18 +
 .../BoardInitLib/PeiTiogaPassInitPostMemLib.c |   86 +
 .../BoardInitLib/PeiTiogaPassInitPreMemLib.c  |  638 ++
 .../Library/BoardInitLib/UsbOC.c  |   46 +
 .../Library/PeiReportFvLib/PeiReportFvLib.c   |  138 +
 .../Library/PeiReportFvLib/PeiReportFvLib.inf |   51 +
 .../BoardTiogaPass/OpenBoardPkg.dsc   |  245 +
 .../BoardTiogaPass/OpenBoardPkg.fdf   |  600 ++
 .../BoardTiogaPass/PlatformPkgBuildOption.dsc |   84 +
 .../BoardTiogaPass/PlatformPkgConfig.dsc  |   58 +
 .../BoardTiogaPass/PlatformPkgPcd.dsc |  392 ++
 .../BoardTiogaPass/StructureConfig.dsc| 6236 +
 .../BoardTiogaPass/__init__.py|0
 .../PurleyOpenBoardPkg/BoardTiogaPass/bld.bat |  139 +
 .../BoardTiogaPass/build_board.py |  195 +
 .../BoardTiogaPass/build_config.cfg   |   34 +
 .../BoardTiogaPass/logo.txt   |   10 +
 .../BoardTiogaPass/postbuild.bat  |   96 +
 .../BoardTiogaPass/prebuild.bat   |  213 +
 .../Ipmi/Library/IpmiLibKcs/IpmiLibKcs.inf|   10 +-
 .../IpmiPlatformHookLib.inf   |6 +-
 .../Include/Guid/PchRcVariable.h  |6 +
 .../Include/Guid/SetupVariable.h  |   15 +-
 .../Intel/PurleyOpenBoardPkg/OpenBoardPkg.dec |1 +
 .../Bus/Pci/PciBusDxe/ComponentName.c |  170 +
 .../Bus/Pci/PciBusDxe/ComponentName.h |  146 +
 .../MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.c   |  460 ++
 .../MdeModulePkg/Bus/Pci/PciBusDxe/PciBus.h   |  396 ++
 .../Bus/Pci/PciBusDxe/PciBusDxe.inf   |  112 +
 .../Bus/Pci/PciBusDxe/PciBusDxe.uni   |   16 +
 .../Bus/Pci/PciBusDxe/PciBusDxeExtra.uni  |   14 +
 .../Bus/Pci/PciBusDxe/PciCommand.c|  267 +
 .../Bus/Pci/PciBusDxe/PciCommand.h|  232 +
 .../Bus/Pci/PciBusDxe/PciDeviceSupport.c  | 1056 +++
 .../Bus/Pci/PciBusDxe/PciDeviceSupport.h  |  266 +
 .../Bus/Pci/PciBusDxe/PciDriverOverride.c |  188 +
 .../Bus/Pci/PciBusDxe/PciDriverOverride.h |   83 +
 .../Bus/Pci/PciBusDxe/PciEnumerator.c | 2210 ++
 .../Bus/Pci/PciBusDxe/PciEnumerator.h |  515 ++
 

Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Ashish Kalra via groups.io
Hello Tom,

On Tue, Jun 22, 2021 at 05:47:48PM -0500, Tom Lendacky wrote:
> On 6/21/21 8:56 AM, Ashish Kalra wrote:
> > From: Ashish Kalra 
> > 
> > Add SEV and SEV-ES hypercall abstraction library to support SEV Page
> > encryption/deceryption status hypercalls for SEV and SEV-ES guests.
> 
> Does this have to be a new library? It's just a single function and so I
> would think it could live in the BaseMemEncryptSevLib library where the
> change to the c-bit is being done anyway.
> 

Actually i like this approach, instead of adding a new library.

Again, IIRC we had discussed this internally and then decided to
create a new hypercall library similar to Xen, with reference to 
the email copied below :

...
Xen has support under Ovmf for a Xen hypercall library
(OvmfPkg/Library/XenHypercallLib). Take a look at that and maybe create
something similar for KVM.
...

Thanks,
Ashish


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




Re: [edk2-devel] [PATCH v2 5/6] MdeModulePkg: SmmLockBoxDxeLib: Updated MessageLength calculation

2021-06-22 Thread Wu, Hao A
> -Original Message-
> From: Kun Qin 
> Sent: Friday, June 18, 2021 5:03 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Wu, Hao A ;
> Dong, Eric ; Ni, Ray 
> Subject: [PATCH v2 5/6] MdeModulePkg: SmmLockBoxDxeLib: Updated
> MessageLength calculation
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398
> 
> This change replaced the calculation of communication buffer size from
> explicitly adding the size of each member with the OFFSET macro function.
> This will make the structure field defition change transparent to
> consumers.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Eric Dong 
> Cc: Ray Ni 
> 
> Signed-off-by: Kun Qin 
> ---
> 
> Notes:
> v2:
> - Newly added in v2
> 
>  MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c | 23
> ++--
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
> b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
> index 2cbffe889e1f..66fbe4dd961c 100644
> --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
> +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.c
> @@ -79,8 +79,7 @@ LockBoxGetSmmCommBuffer (
>  return mLockBoxSmmCommBuffer;
>}
> 
> -  MinimalSizeNeeded = sizeof (EFI_GUID) +
> -  sizeof (UINTN) +
> +  MinimalSizeNeeded = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER,
> Data) +
>MAX (sizeof (EFI_SMM_LOCK_BOX_PARAMETER_SAVE),
> MAX (sizeof
> (EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES),
>  MAX (sizeof 
> (EFI_SMM_LOCK_BOX_PARAMETER_UPDATE),
> @@ -142,7 +141,7 @@ SaveLockBox (
>EFI_SMM_COMMUNICATION_PROTOCOL  *SmmCommunication;
>EFI_SMM_LOCK_BOX_PARAMETER_SAVE *LockBoxParameterSave;
>EFI_SMM_COMMUNICATE_HEADER  *CommHeader;
> -  UINT8   TempCommBuffer[sizeof(EFI_GUID) + 
> sizeof(UINTN) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)];
> +  UINT8   TempCommBuffer[OFFSET_OF
> (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE)];
>UINT8   *CommBuffer;
>UINTN   CommSize;
> 
> @@ -182,7 +181,7 @@ SaveLockBox (
>//
>// Send command
>//
> -  CommSize = sizeof(EFI_GUID) + sizeof(UINTN) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE);
> +  CommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SAVE);
>Status = SmmCommunication->Communicate (
> SmmCommunication,
> [0],
> @@ -224,7 +223,7 @@ SetLockBoxAttributes (
>EFI_SMM_COMMUNICATION_PROTOCOL*SmmCommunication;
>EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES
> *LockBoxParameterSetAttributes;
>EFI_SMM_COMMUNICATE_HEADER*CommHeader;
> -  UINT8 TempCommBuffer[sizeof(EFI_GUID) +
> sizeof(UINTN) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)];
> +  UINT8 TempCommBuffer[OFFSET_OF
> (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES)];
>UINT8 *CommBuffer;
>UINTN CommSize;
> 
> @@ -264,7 +263,7 @@ SetLockBoxAttributes (
>//
>// Send command
>//
> -  CommSize = sizeof(EFI_GUID) + sizeof(UINTN) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES);
> +  CommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_SET_ATTRIBUTES);
>Status = SmmCommunication->Communicate (
> SmmCommunication,
> [0],
> @@ -314,7 +313,7 @@ UpdateLockBox (
>EFI_SMM_COMMUNICATION_PROTOCOL*SmmCommunication;
>EFI_SMM_LOCK_BOX_PARAMETER_UPDATE *LockBoxParameterUpdate;
>EFI_SMM_COMMUNICATE_HEADER*CommHeader;
> -  UINT8 TempCommBuffer[sizeof(EFI_GUID) + 
> sizeof(UINTN)
> + sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)];
> +  UINT8 TempCommBuffer[OFFSET_OF
> (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE)];
>UINT8 *CommBuffer;
>UINTN CommSize;
> 
> @@ -355,7 +354,7 @@ UpdateLockBox (
>//
>// Send command
>//
> -  CommSize = sizeof(EFI_GUID) + sizeof(UINTN) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE);
> +  CommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) +
> sizeof(EFI_SMM_LOCK_BOX_PARAMETER_UPDATE);
>Status = SmmCommunication->Communicate (
> SmmCommunication,
> [0],
> @@ -403,7 +402,7 @@ RestoreLockBox (
>EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
>EFI_SMM_LOCK_BOX_PARAMETER_RESTORE *LockBoxParameterRestore;
>EFI_SMM_COMMUNICATE_HEADER 

Re: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo: Updated MessageLength calculation

2021-06-22 Thread Wu, Hao A
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Kun Qin
> Sent: Friday, June 18, 2021 5:03 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Wu, Hao A ;
> Dong, Eric ; Ni, Ray 
> Subject: [edk2-devel] [PATCH v2 4/6] MdeModulePkg: SmiHandlerProfileInfo:
> Updated MessageLength calculation
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398
> 
> This change replaced the calculation of communication buffer size from
> explicitly adding the size of each member with the OFFSET macro function.
> This will make the structure field defition change transparent to consumers.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> Cc: Eric Dong 
> Cc: Ray Ni 
> 
> Signed-off-by: Kun Qin 
> ---
> 
> Notes:
> v2:
> - Updated comments by removing "BZ" tags [Hao]


Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu


> 
>  MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.c
> | 10 --
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> index 4153074b7a80..4bfd5946caba 100644
> ---
> a/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo
> .c
> +++
> b/MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileIn
> +++ fo.c
> @@ -116,7 +116,10 @@ GetSmiHandlerProfileDatabase(
>CommGetInfo->Header.ReturnStatus = (UINT64)-1;
>CommGetInfo->DataSize = 0;
> 
> -  CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader-
> >MessageLength;
> +  //
> +  // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +  //
> +  CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> + (UINTN)CommHeader->MessageLength;
>Status = SmmCommunication->Communicate(SmmCommunication,
> CommBuffer, );
>if (EFI_ERROR(Status)) {
>  Print(L"SmiHandlerProfile: SmmCommunication - %r\n", Status); @@ -
> 149,7 +152,10 @@ GetSmiHandlerProfileDatabase(
>CommGetData->Header.DataLength = sizeof(*CommGetData);
>CommGetData->Header.ReturnStatus = (UINT64)-1;
> 
> -  CommSize = sizeof(EFI_GUID) + sizeof(UINTN) + CommHeader-
> >MessageLength;
> +  //
> +  // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +  //
> +  CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> + (UINTN)CommHeader->MessageLength;
>Buffer = (UINT8 *)CommHeader + CommSize;
>Size -= CommSize;
> 
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 



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




Re: [edk2-devel] [PATCH v2 3/6] MdeModulePkg: MemoryProfileInfo: Updated MessageLength calculation

2021-06-22 Thread Wu, Hao A
> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Kun Qin
> Sent: Friday, June 18, 2021 5:03 PM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J ; Wu, Hao A 
> Subject: [edk2-devel] [PATCH v2 3/6] MdeModulePkg: MemoryProfileInfo:
> Updated MessageLength calculation
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398
> 
> This change replaced the calculation of communication buffer size from
> explicitly adding the size of each member with the OFFSET macro function.
> This will make the structure field defition change transparent to
> consumers.
> 
> Cc: Jian J Wang 
> Cc: Hao A Wu 
> 
> Signed-off-by: Kun Qin 
> ---
> 
> Notes:
> v2:
> - Added a missed case this change should cover [Hao]
> - Removed "BZ" tags from comments [Hao]


Reviewed-by: Hao A Wu 

Best Regards,
Hao Wu


> 
>  MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c | 28
> +++-
>  1 file changed, 21 insertions(+), 7 deletions(-)
> 
> diff --git
> a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
> b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
> index 191c31068545..69f78c090e7c 100644
> --- a/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
> +++
> b/MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.c
> @@ -1140,8 +1140,7 @@ GetSmramProfileData (
>  return Status;
>}
> 
> -  MinimalSizeNeeded = sizeof (EFI_GUID) +
> -  sizeof (UINTN) +
> +  MinimalSizeNeeded = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER,
> Data) +
>MAX (sizeof
> (SMRAM_PROFILE_PARAMETER_GET_PROFILE_INFO),
> MAX (sizeof
> (SMRAM_PROFILE_PARAMETER_GET_PROFILE_DATA_BY_OFFSET),
>  sizeof
> (SMRAM_PROFILE_PARAMETER_RECORDING_STATE)));
> @@ -1190,7 +1189,10 @@ GetSmramProfileData (
>CommRecordingState->Header.ReturnStatus = (UINT64)-1;
>CommRecordingState->RecordingState  =
> MEMORY_PROFILE_RECORDING_DISABLE;
> 
> -  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader-
> >MessageLength;
> +  //
> +  // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +  //
> +  CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> (UINTN)CommHeader->MessageLength;
>Status = SmmCommunication->Communicate (SmmCommunication,
> CommBuffer, );
>if (EFI_ERROR (Status)) {
>  DEBUG ((EFI_D_ERROR, "SmramProfile: SmmCommunication - %r\n",
> Status));
> @@ -1213,7 +1215,10 @@ GetSmramProfileData (
>  CommRecordingState->Header.ReturnStatus = (UINT64)-1;
>  CommRecordingState->RecordingState  =
> MEMORY_PROFILE_RECORDING_DISABLE;
> 
> -CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader-
> >MessageLength;
> +//
> +// The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +//
> +CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> (UINTN)CommHeader->MessageLength;
>  SmmCommunication->Communicate (SmmCommunication, CommBuffer,
> );
>}
> 
> @@ -1230,7 +1235,10 @@ GetSmramProfileData (
>CommGetProfileInfo->Header.ReturnStatus = (UINT64)-1;
>CommGetProfileInfo->ProfileSize = 0;
> 
> -  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader-
> >MessageLength;
> +  //
> +  // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +  //
> +  CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> (UINTN)CommHeader->MessageLength;
>Status = SmmCommunication->Communicate (SmmCommunication,
> CommBuffer, );
>ASSERT_EFI_ERROR (Status);
> 
> @@ -1261,7 +1269,10 @@ GetSmramProfileData (
>CommGetProfileData->Header.DataLength   = sizeof
> (*CommGetProfileData);
>CommGetProfileData->Header.ReturnStatus = (UINT64)-1;
> 
> -  CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader-
> >MessageLength;
> +  //
> +  // The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +  //
> +  CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> (UINTN)CommHeader->MessageLength;
>Buffer = (UINT8 *) CommHeader + CommSize;
>Size -= CommSize;
> 
> @@ -1320,7 +1331,10 @@ GetSmramProfileData (
>  CommRecordingState->Header.ReturnStatus = (UINT64)-1;
>  CommRecordingState->RecordingState  =
> MEMORY_PROFILE_RECORDING_ENABLE;
> 
> -CommSize = sizeof (EFI_GUID) + sizeof (UINTN) + CommHeader-
> >MessageLength;
> +//
> +// The CommHeader->MessageLength contains a definitive value, thus
> UINTN cast is safe here.
> +//
> +CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
> (UINTN)CommHeader->MessageLength;
>  SmmCommunication->Communicate (SmmCommunication, CommBuffer,
> );
>}
> 
> --
> 2.31.1.windows.1
> 
> 
> 
> 
> 



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

Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Brijesh Singh via groups.io



On 6/22/2021 6:20 PM, Ashish Kalra wrote:
> Hello Tom,
> 
> On Tue, Jun 22, 2021 at 05:47:48PM -0500, Tom Lendacky wrote:
> ...
>>> +VOID
>>> +EFIAPI
>>> +SetMemoryEncDecHypercall3 (
>>> +  IN PHYSICAL_ADDRESS PhysicalAddress,
>>> +  IN UINTNPages,
>>> +  IN UINTNMode
>>> +  )
>>> +{
>>> +  if (MemEncryptSevEsIsEnabled ()) {
>>> +MSR_SEV_ES_GHCB_REGISTER  Msr;
>>> +GHCB  *Ghcb;
>>> +BOOLEAN   InterruptState;
>>> +UINT64Status;
>>> +
>>> +Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
>>> +Ghcb = Msr.Ghcb;
>>> +
>>> +VmgInit (Ghcb, );
>>> +
>>> +Ghcb->SaveArea.Rax = KVM_HC_MAP_GPA_RANGE;
>>> +GhcbSetRegValid (Ghcb, GhcbRax);
>>> +Ghcb->SaveArea.Rbx = PhysicalAddress;
>>> +GhcbSetRegValid (Ghcb, GhcbRbx);
>>> +Ghcb->SaveArea.Rcx = Pages;
>>> +GhcbSetRegValid (Ghcb, GhcbRcx);
>>> +Ghcb->SaveArea.Rdx = Mode;
>>> +GhcbSetRegValid (Ghcb, GhcbRdx);
>>> +Ghcb->SaveArea.Cpl = AsmReadCs() & 0x3;
>>> +GhcbSetRegValid (Ghcb, GhcbCpl);
>>> +
>>> +Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);
>>> +if (Status) {
>>> +  DEBUG ((DEBUG_ERROR, "SVM_EXIT_VMMCALL failed %lx\n", Status));
>>> +}
>>> +VmgDone (Ghcb, InterruptState);
>>> +  } else {
>>> +SetMemoryEncDecHypercall3AsmStub (
>>> +  KVM_HC_MAP_GPA_RANGE,
>>> +  PhysicalAddress,
>>> +  Pages,
>>> +  Mode
>>> +  );
>>> +  }
>>> +}
>>
>> You could just issue the VMMCALL and, for SEV-ES, let the VC handler take
>> care of this. You would just have to add some smarts to the VC handler to
>> compare the hypercall number and add the additional register values. You
>> could probably get rid of a level of function calls that way. Thoughts?
>>
> 
> IIRC, we have already discussed this internally. 
> 
> Letting the VC handler do it was making it too complicated to add hooks 
> inside the VmgExitLib, and corresponding updation of MdePkg and UefiCpuPkg
> (as described in the email thread below), and at that time
> Brijesh had suggested the use of this alternative VmgExit() approach.
> 

A lot has changed in the OVMF code since you last submitted the patch.
IIRC, in ES wip patches Tom was implementing the VC handling library
in the EDK2 core. But in the final version, all the VC handling is
done in the OVMF. The EDK2 core provides a Null library that get
override from the OVMF. In other words, you no longer need to
touch the MdePkg and UefiCpuPkg etc for this change.

I agree with Tom that it would be nice if we can add smarts
in the VC handler. My previous comment was mainly focuses around
how you can avoid touching the EDK2 core.


> Email thread copied below :
> 
> ...
> Well, I does not mean that you should literally use VMMCALL instruction 
> instead you use its corresponding VMGEXIT number.
> Something like this:
> 
> Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);
> 
> This way, a #VC will not be kicked in and there is no need to hook anything 
> inside the VmgExitLib. Maybe Tom can correct me if that is not acceptable.
> 
> -Brijesh
> 
>>> I am not able to follow your OVMF patches, could you provide a very high 
>>> level overview of what exactly you are trying to achieve?  Its possible 
>>> that I am missing something fundamental but  why do we care of Hypercall 
>>> inside the bare metal pkg (e.g MdePkg, UefiCpuPkg)? Why we are needing a  
>>> Hob etc ? IMO, a Hypercall implementation should be straight forward like 
>>> what I did the SEV live migration. In case of ES, all you need to use the 
>>> Ghcb instance to save the register values (rax, rbx, rcx etc) then invoke 
>>> vmmcall instruction.
>>
> I need to do this hypercall validation and setup as part of VC# exception's 
> VMMCALL handling,
> i.e, in the VmgExitLib code. I need to use a HOB to store/cache hypercalls 
> invoked during SEC
> and PEI phase and flush them later at DXE IPL phase. As VmgExitLib code is 
> invoked in SEC and
> PEI phases and references MdePkg and UefiCpuPkg, i need to add HypercallLib 
> references in UefiCpuPkg.
> 
> Also, i need to verify if Hypercall library interfaces are being invoked 
> during SEC and/or PEI phase,
> currently i do it by checking PcdOvmfSecGhcbBase and for accessing that i had 
> to add reference to
> it in MdePkg/MdePkg.dec and UefiCpuPkg/UefiCpuPkg.dec, if i can check that 
> the Hypercall library
> interfaces are being invoked in SEC/PEI phase using some other mechanism then 
> i can drop this
> reference to PcdOvmfSecGhcbBase.
> ...
> 
> 
> Thanks,
> Ashish
> 


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




Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Ashish Kalra via groups.io
Hello Tom,

On Tue, Jun 22, 2021 at 05:47:48PM -0500, Tom Lendacky wrote:
...
> > +VOID
> > +EFIAPI
> > +SetMemoryEncDecHypercall3 (
> > +  IN PHYSICAL_ADDRESS PhysicalAddress,
> > +  IN UINTNPages,
> > +  IN UINTNMode
> > +  )
> > +{
> > +  if (MemEncryptSevEsIsEnabled ()) {
> > +MSR_SEV_ES_GHCB_REGISTER  Msr;
> > +GHCB  *Ghcb;
> > +BOOLEAN   InterruptState;
> > +UINT64Status;
> > +
> > +Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);
> > +Ghcb = Msr.Ghcb;
> > +
> > +VmgInit (Ghcb, );
> > +
> > +Ghcb->SaveArea.Rax = KVM_HC_MAP_GPA_RANGE;
> > +GhcbSetRegValid (Ghcb, GhcbRax);
> > +Ghcb->SaveArea.Rbx = PhysicalAddress;
> > +GhcbSetRegValid (Ghcb, GhcbRbx);
> > +Ghcb->SaveArea.Rcx = Pages;
> > +GhcbSetRegValid (Ghcb, GhcbRcx);
> > +Ghcb->SaveArea.Rdx = Mode;
> > +GhcbSetRegValid (Ghcb, GhcbRdx);
> > +Ghcb->SaveArea.Cpl = AsmReadCs() & 0x3;
> > +GhcbSetRegValid (Ghcb, GhcbCpl);
> > +
> > +Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);
> > +if (Status) {
> > +  DEBUG ((DEBUG_ERROR, "SVM_EXIT_VMMCALL failed %lx\n", Status));
> > +}
> > +VmgDone (Ghcb, InterruptState);
> > +  } else {
> > +SetMemoryEncDecHypercall3AsmStub (
> > +  KVM_HC_MAP_GPA_RANGE,
> > +  PhysicalAddress,
> > +  Pages,
> > +  Mode
> > +  );
> > +  }
> > +}
> 
> You could just issue the VMMCALL and, for SEV-ES, let the VC handler take
> care of this. You would just have to add some smarts to the VC handler to
> compare the hypercall number and add the additional register values. You
> could probably get rid of a level of function calls that way. Thoughts?
> 

IIRC, we have already discussed this internally. 

Letting the VC handler do it was making it too complicated to add hooks 
inside the VmgExitLib, and corresponding updation of MdePkg and UefiCpuPkg
(as described in the email thread below), and at that time
Brijesh had suggested the use of this alternative VmgExit() approach.

Email thread copied below :

...
Well, I does not mean that you should literally use VMMCALL instruction instead 
you use its corresponding VMGEXIT number.
Something like this:

Status = VmgExit (Ghcb, SVM_EXIT_VMMCALL, 0, 0);

This way, a #VC will not be kicked in and there is no need to hook anything 
inside the VmgExitLib. Maybe Tom can correct me if that is not acceptable.

-Brijesh

>> I am not able to follow your OVMF patches, could you provide a very high 
>> level overview of what exactly you are trying to achieve?  Its possible that 
>> I am missing something fundamental but  why do we care of Hypercall inside 
>> the bare metal pkg (e.g MdePkg, UefiCpuPkg)? Why we are needing a  Hob etc ? 
>> IMO, a Hypercall implementation should be straight forward like what I did 
>> the SEV live migration. In case of ES, all you need to use the Ghcb instance 
>> to save the register values (rax, rbx, rcx etc) then invoke vmmcall 
>> instruction.
>
I need to do this hypercall validation and setup as part of VC# exception's 
VMMCALL handling,
i.e, in the VmgExitLib code. I need to use a HOB to store/cache hypercalls 
invoked during SEC
and PEI phase and flush them later at DXE IPL phase. As VmgExitLib code is 
invoked in SEC and
PEI phases and references MdePkg and UefiCpuPkg, i need to add HypercallLib 
references in UefiCpuPkg.

Also, i need to verify if Hypercall library interfaces are being invoked during 
SEC and/or PEI phase,
currently i do it by checking PcdOvmfSecGhcbBase and for accessing that i had 
to add reference to
it in MdePkg/MdePkg.dec and UefiCpuPkg/UefiCpuPkg.dec, if i can check that the 
Hypercall library
interfaces are being invoked in SEC/PEI phase using some other mechanism then i 
can drop this
reference to PcdOvmfSecGhcbBase.
...


Thanks,
Ashish



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




Re: [edk2-devel] [PATCH 2/2] UefiPayloadPkg: consume the BootManagerMenuFile HOB

2021-06-22 Thread Guo Dong


Please check the comments below.

> -Original Message-
> From: Tan, Dun 
> Sent: Monday, June 21, 2021 1:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin ; Tan,
> Dun 
> Subject: [PATCH 2/2] UefiPayloadPkg: consume the BootManagerMenuFile
> HOB
> 
> Consume the BootManagerMenuFile HOB in PlatformBootManagerLib
> This Lib is in UefiPayloadPkg
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> 
> Signed-off-by: DunTan 
> ---
>  UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> | 51 +++
> 
> UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.i
> nf |  5 -
>  UefiPayloadPkg/UefiPayloadPkg.dsc|  
> 2 +-
>  3 files changed, 56 insertions(+), 2 deletions(-)
> 
> diff --git
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> index fce48d26a1..afd9664959 100644
> ---
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> +++
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c
> @@ -10,6 +10,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include "PlatformBootManager.h"
>  #include "PlatformConsole.h"
>  #include 
> +#include 
> +#include 
> 
> 
> UNIVERSAL_PAYLOAD_PLATFORM_BOOT_MANAGER_OVERRIDE_PROTOCO
> L  *mUniversalPayloadPlatformBootManagerOverrideInstance = NULL;
> 
> @@ -286,3 +288,52 @@ PlatformBootManagerUnableToBoot (
>return;
>  }
> 
> +/**
> +  Get/update PcdBootManagerMenuFile from GUID HOB which will be
> assigned in bootloader.
> +
> +  @retval EFI_SUCCESS   The entry point is executed successfully.
> +  @retval other Some error occurs.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +PlatformBootManagerLibConstructor (
> +  IN EFI_HANDLEImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +)
> +{
> +  EFI_STATUS   Status;
> +  UINTNSize;
> +  VOID *GuidHob;
> +  UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader;
> +  UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU
> *BootManagerMenuFile;
> +  Status  = EFI_SUCCESS;

It looks the Status initialization was not necessary, please double check and 
remove it.
And please add function parameter description in function comments.




> +  GuidHob = GetFirstGuidHob
> ();
> +  //
> +  // Find the buffer information and update PCDs
> +  //
> +  if (GuidHob == NULL) {
> +//
> +// If the HOB is not create, the default value of PcdBootManagerMenuFile
> will be used.
> +//
> +return EFI_SUCCESS;
> +  }
> +

It is more clear if moving the comment message " Find the buffer information 
and update PCDs"  to here.




> +  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)
> GET_GUID_HOB_DATA (GuidHob);
> +  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) >
> GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length >
> GET_GUID_HOB_DATA_SIZE (GuidHob))) {
> +return EFI_NOT_FOUND;
> +  }
> +  if (GenericHeader->Revision ==
> UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION) {
> +BootManagerMenuFile =
> (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU *) GET_GUID_HOB_DATA
> (GuidHob);
> +if (BootManagerMenuFile->Header.Length <
> UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD
> (UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU, FileName)) {
> +  return EFI_NOT_FOUND;
> +}
> +Size = sizeof (BootManagerMenuFile->FileName);
> +Status = PcdSetPtrS (PcdBootManagerMenuFile, ,
> >FileName);
> +  } else {
> +return EFI_NOT_FOUND;
> +  }
> +
> +  ASSERT_EFI_ERROR (Status);
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi
> b.inf
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi
> b.inf
> index 600a535282..9c4943a0e0 100644
> ---
> a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi
> b.inf
> +++
> b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManagerLi
> b.inf
> @@ -13,7 +13,7 @@
>MODULE_TYPE= DXE_DRIVER
>VERSION_STRING = 1.0
>LIBRARY_CLASS  = PlatformBootManagerLib|DXE_DRIVER
> -
> +  CONSTRUCTOR= PlatformBootManagerLibConstructor
> 
>  #
>  # The following information is for reference only and not required by the
> build tools.
> @@ -46,9 +46,11 @@
>HiiLib
>PrintLib
>PlatformHookLib
> +  HobLib
> 
>  [Guids]
>gEfiEndOfDxeEventGroupGuid
> +  gUniversalPayloadBootManagerMenuFileGuid
> 
>  [Protocols]
>gEfiGenericMemTestProtocolGuid  ## CONSUMES
> @@ -70,3 +72,4 @@
>gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
>gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
>gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> 

Re: [edk2-devel] [PATCH v4 4/4] OvmfPkg/PlatformDxe: Add support for SEV live migration.

2021-06-22 Thread Lendacky, Thomas via groups.io
On 6/21/21 8:57 AM, Ashish Kalra wrote:
> From: Ashish Kalra 
> 
> Detect for KVM hypervisor and check for SEV live migration
> feature support via KVM_FEATURE_CPUID, if detected setup a new
> UEFI enviroment variable to indicate OVMF support for SEV
> live migration.
> 
> Signed-off-by: Ashish Kalra 
> ---
>  OvmfPkg/Include/Guid/MemEncryptLib.h |  20 
>  OvmfPkg/OvmfPkg.dec  |   1 +
>  OvmfPkg/PlatformDxe/AmdSev.c | 108 
>  OvmfPkg/PlatformDxe/Platform.c   |   5 +
>  OvmfPkg/PlatformDxe/Platform.inf |   2 +
>  OvmfPkg/PlatformDxe/PlatformConfig.h |   5 +
>  6 files changed, 141 insertions(+)
> 
> diff --git a/OvmfPkg/Include/Guid/MemEncryptLib.h 
> b/OvmfPkg/Include/Guid/MemEncryptLib.h
> new file mode 100644
> index 00..4c046ba439
> --- /dev/null
> +++ b/OvmfPkg/Include/Guid/MemEncryptLib.h
> @@ -0,0 +1,20 @@
> +/** @file
> +
> +  AMD Memory Encryption GUID, define a new GUID for defining
> +  new UEFI enviroment variables assocaiated with SEV Memory Encryption.
> +
> +  Copyright (c) 2020, AMD Inc. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef __MEMENCRYPT_LIB_H__
> +#define __MEMENCRYPT_LIB_H__
> +
> +#define MEMENCRYPT_GUID \
> +{0x0cf29b71, 0x9e51, 0x433a, {0xa3, 0xb7, 0x81, 0xf3, 0xab, 0x16, 0xb8, 
> 0x75}}
> +
> +extern EFI_GUID gMemEncryptGuid;
> +
> +#endif
> diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
> index 6ae733f6e3..e452dc8494 100644
> --- a/OvmfPkg/OvmfPkg.dec
> +++ b/OvmfPkg/OvmfPkg.dec
> @@ -122,6 +122,7 @@
>gQemuKernelLoaderFsMediaGuid  = {0x1428f772, 0xb64a, 0x441e, 
> {0xb8, 0xc3, 0x9e, 0xbd, 0xd7, 0xf8, 0x93, 0xc7}}
>gGrubFileGuid = {0xb5ae312c, 0xbc8a, 0x43b1, 
> {0x9c, 0x62, 0xeb, 0xb8, 0x26, 0xdd, 0x5d, 0x07}}
>gConfidentialComputingSecretGuid  = {0xadf956ad, 0xe98c, 0x484c, 
> {0xae, 0x11, 0xb5, 0x1c, 0x7d, 0x33, 0x64, 0x47}}
> +  gMemEncryptGuid   = {0x0cf29b71, 0x9e51, 0x433a, 
> {0xa3, 0xb7, 0x81, 0xf3, 0xab, 0x16, 0xb8, 0x75}}
>  
>  [Ppis]
># PPI whose presence in the PPI database signals that the TPM base address
> diff --git a/OvmfPkg/PlatformDxe/AmdSev.c b/OvmfPkg/PlatformDxe/AmdSev.c
> new file mode 100644
> index 00..3dbf17a8cd
> --- /dev/null
> +++ b/OvmfPkg/PlatformDxe/AmdSev.c

Can this be done in OvmfPkg/AmdSevDxe/AmdSevDxe.c or is that too early?

> @@ -0,0 +1,108 @@
> +/**@file
> +  Detect KVM hypervisor support for SEV live migration and if
> +  detected, setup a new UEFI enviroment variable indicating
> +  OVMF support for SEV live migration.
> +
> +  Copyright (c) 2020, Advanced Micro Devices. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +//
> +// The package level header files this module uses
> +//
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define KVM_FEATURE_MIGRATION_CONTROL   17

BIT17

> +
> +/**
> +  Figures out if we are running inside KVM HVM and
> +  KVM HVM supports SEV Live Migration feature.
> +
> +  @retval TRUE   KVM was detected and Live Migration supported
> +  @retval FALSE  KVM was not detected or Live Migration not supported
> +
> +**/
> +BOOLEAN
> +KvmDetectSevLiveMigrationFeature(
> +  VOID
> +  )
> +{
> +  UINT8 Signature[13];
> +  UINT32 mKvmLeaf = 0;
> +  UINT32 RegEax, RegEbx, RegEcx, RegEdx;
> +
> +  Signature[12] = '\0';
> +  for (mKvmLeaf = 0x4000; mKvmLeaf < 0x4001; mKvmLeaf += 0x100) {

What's the reason for the loop? I would think that just checking
0x4000 would be enough, so a comment seems to be warranted.

> +AsmCpuid (mKvmLeaf,
> +  NULL,
> +  (UINT32 *) [0],
> +  (UINT32 *) [4],
> +  (UINT32 *) [8]);
> +
> +if (!AsciiStrCmp ((CHAR8 *) Signature, "KVMKVMKVM\0\0\0")) {
> +  DEBUG ((
> +DEBUG_ERROR,

DEBUG_INFO, it doesn't seem like an error.

> +"%a: KVM Detected, signature = %s\n",
> +__FUNCTION__,
> +Signature
> +));
> +> +  RegEax = 0x4001;

Should this be mKvmLeaf + 1? It is confusing that you may check 0x4100
and then not do 0x4101.

> +  RegEcx = 0;
> +  AsmCpuid (0x4001, , , , );
> +  if (RegEax & (1 << KVM_FEATURE_MIGRATION_CONTROL)) {

This needs to be (assuming BIT17 is used above):

  if ((RegEax & KVM_FEATURE_MIGRATION_CONTROL) != 0) {

You must use an actual comparison if the variable is not a boolean.

> +DEBUG ((
> +  DEBUG_ERROR,
> +  "%a: Live Migration feature supported\n",

DEBUG_INFO again.

> +  __FUNCTION__
> +  ));
> +return TRUE;
> +  }
> +}
> +  }
> +
> +  return FALSE;
> +}
> +
> +/**
> +
> +  Function checks if SEV Live Migration support is available, if present 
> then it sets
> +  a UEFI enviroment variable to be queried later using Runtime services.
> +
> +  **/
> +VOID
> +AmdSevSetConfig(

Kind of a 

Re: [edk2-devel] [PATCH 1/2] UefiPayloadPkg: Add new structure for BootManagerMenuFile HOB

2021-06-22 Thread Guo Dong


+  gUniversalPayloadBootManagerMenuFileGuid

Had better rename this guid to remove "UniversalPayload" from the name since 
this guid is not defined in universal payload specification. 

Thanks,
Guo
> -Original Message-
> From: Tan, Dun 
> Sent: Monday, June 21, 2021 1:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin ; Tan,
> Dun 
> Subject: [PATCH 1/2] UefiPayloadPkg: Add new structure for
> BootManagerMenuFile HOB
> 
> Add new structure for BootManagerMenuFile HOB in UefiPayloadPkg
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> 
> Signed-off-by: DunTan 
> ---
>  UefiPayloadPkg/Include/Guid/BootManagerMenu.h | 27
> +++
>  UefiPayloadPkg/UefiPayloadPkg.dec |  3 +++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> new file mode 100644
> index 00..10fb874640
> --- /dev/null
> +++ b/UefiPayloadPkg/Include/Guid/BootManagerMenu.h
> @@ -0,0 +1,27 @@
> +/** @file
> +  Define the structure for the Boot Manager Menu File.
> +
> +Copyright (c) 2021, Intel Corporation. All rights reserved.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
> +#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_H_
> +
> +#include 
> +#include 
> +
> +#pragma pack (1)
> +
> +typedef struct {
> +  UNIVERSAL_PAYLOAD_GENERIC_HEADER   Header;
> +  GUID   FileName;
> +} UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU;
> +
> +#pragma pack()
> +
> +#define UNIVERSAL_PAYLOAD_BOOT_MANAGER_MENU_REVISION 1
> +
> +extern GUID gUniversalPayloadBootManagerMenuFileGuid;
> +#endif
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec
> b/UefiPayloadPkg/UefiPayloadPkg.dec
> index 105e1f5a1c..850592976d 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dec
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dec
> @@ -29,6 +29,9 @@
>#
>gBmpImageGuid   = { 0x878AC2CC, 0x5343, 0x46F2, { 
> 0xB5, 0x63,
> 0x51, 0xF8, 0x9D, 0xAF, 0x56, 0xBA } }
> 
> +  ##include/Guid/BootManagerMenu.h
> +  gUniversalPayloadBootManagerMenuFileGuid = { 0xdf939333, 0x42fc,
> 0x4b2a, { 0xa5, 0x9e, 0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }}
> +
>gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf,
> 0x89, 0xc4, 0x29, 0x4, 0x33}}
>gUefiAcpiBoardInfoGuid   = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e,
> 0xf1, 0x10, 0x6, 0xd9, 0xf}}
>gUefiSerialPortInfoGuid  = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 
> 0x95,
> 0x8d, 0x62, 0xde, 0x87, 0xf1 } }
> --
> 2.31.1.windows.1



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




Re: [edk2-devel] [PATCH 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol feature in UefiPayloadPkg

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 11/12] UefiPayloadPkg: Add PcdInstallAcpiSdtProtocol
> feature in UefiPayloadPkg
> 
> To install ACPI SDT protocol, define PcdInstallAcpiSdtProtocol as TRUE.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 99b0e49d46..930831d30c 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -290,6 +290,8 @@
>gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode|TRUE
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdConOutGopSupport|TRUE
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdConOutUgaSupport|FALSE
> 
> +  ## This PCD specified whether ACPI SDT protocol is installed.
> 
> +  gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE
> 
> 
> 
>  [PcdsFixedAtBuild]
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x1
> 
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH 12/12] UefiPayloadPkg: Add PcdResetOnMemoryTypeInformationChange in UefiPayloadPkg

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 12/12] UefiPayloadPkg: Add
> PcdResetOnMemoryTypeInformationChange in UefiPayloadPkg
> 
> This PCD will be consumed by Universal Payload
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 930831d30c..f1bf80bc6d 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -362,6 +362,7 @@
> 
> ##
> ##
> 
> 
> 
>  [PcdsDynamicExDefault]
> 
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdResetOnMemoryTypeInformationC
> hange|FALSE
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0
> 
>gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64|0
> 
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0
> 
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH 09/12] UefiPayloadPkg: Remove assert when reserve MMIO/IO resource for devices

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 09/12] UefiPayloadPkg: Remove assert when reserve
> MMIO/IO resource for devices
> 
> Some boot loader may already reserve MMIO/IO resource for IOAPIC and
> HPET,
> so remove the assert when reserve MMIO/IO resource for IOAPIC and HPET
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
> b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
> index ffd3427fb3..04e968a232 100644
> --- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
> +++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.c
> @@ -41,13 +41,12 @@ ReserveResourceInGcd (
>  );
> 
>  if (EFI_ERROR (Status)) {
> 
>DEBUG ((
> 
> -DEBUG_ERROR,
> 
> +DEBUG_WARN,
> 
>  "Failed to add memory space :0x%lx 0x%lx\n",
> 
>  BaseAddress,
> 
>  Length
> 
>  ));
> 
>  }
> 
> -ASSERT_EFI_ERROR (Status);
> 
>  Status = gDS->AllocateMemorySpace (
> 
>  EfiGcdAllocateAddress,
> 
>  GcdType,
> 
> @@ -57,14 +56,20 @@ ReserveResourceInGcd (
>  ImageHandle,
> 
>  NULL
> 
>  );
> 
> -ASSERT_EFI_ERROR (Status);
> 
>} else {
> 
>  Status = gDS->AddIoSpace (
> 
>  GcdType,
> 
>  BaseAddress,
> 
>  Length
> 
>  );
> 
> -ASSERT_EFI_ERROR (Status);
> 
> +if (EFI_ERROR (Status)) {
> 
> +  DEBUG ((
> 
> +DEBUG_WARN,
> 
> +"Failed to add IO space :0x%lx 0x%lx\n",
> 
> +BaseAddress,
> 
> +Length
> 
> +));
> 
> +}
> 
>  Status = gDS->AllocateIoSpace (
> 
>  EfiGcdAllocateAddress,
> 
>  GcdType,
> 
> @@ -74,7 +79,6 @@ ReserveResourceInGcd (
>  ImageHandle,
> 
>  NULL
> 
>  );
> 
> -ASSERT_EFI_ERROR (Status);
> 
>}
> 
>return Status;
> 
>  }
> 
> @@ -106,11 +110,9 @@ BlDxeEntryPoint (
>//
> 
>// Report MMIO/IO Resources
> 
>//
> 
> -  Status = ReserveResourceInGcd (TRUE,
> EfiGcdMemoryTypeMemoryMappedIo, 0xFEC0, SIZE_4KB, 0,
> ImageHandle); // IOAPIC
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> +  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,
> 0xFEC0, SIZE_4KB, 0, ImageHandle); // IOAPIC
> 
> 
> 
> -  Status = ReserveResourceInGcd (TRUE,
> EfiGcdMemoryTypeMemoryMappedIo, 0xFED0, SIZE_1KB, 0,
> ImageHandle); // HPET
> 
> -  ASSERT_EFI_ERROR (Status);
> 
> +  ReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo,
> 0xFED0, SIZE_1KB, 0, ImageHandle); // HPET
> 
> 
> 
>//
> 
>// Find the frame buffer information and update PCDs
> 
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH 08/12] UefiPayloadPkg: Include UniversalPayLoad modules in UefiPayloadPkg.dsc

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 08/12] UefiPayloadPkg: Include UniversalPayLoad modules
> in UefiPayloadPkg.dsc
> 
> Add a new macro "UNIVERSAL_PAYLOAD" to build Universal Payload.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 22 ++
>  UefiPayloadPkg/UefiPayloadPkg.fdf |  3 ++-
>  2 files changed, 20 insertions(+), 5 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index e3d669a6d6..155aea4bc4 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -196,7 +196,11 @@
>TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf
> 
> 
> ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.in
> f
> 
> 
> SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort
> Lib16550.inf
> 
> +!if $(UNIVERSAL_PAYLOAD) == TRUE
> 
> +
> PlatformHookLib|UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib
> /PlatformHookLib.inf
> 
> +!else
> 
> 
> PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib
> .inf
> 
> +!endif
> 
> 
> PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/
> PlatformBootManagerLib.inf
> 
>IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf
> 
> 
> 
> @@ -213,10 +217,12 @@
> 
> DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLi
> bNull.inf
> 
>  !endif
> 
> 
> PlatformSupportLib|UefiPayloadPkg/Library/PlatformSupportLibNull/Platfor
> mSupportLibNull.inf
> 
> -!if $(BOOTLOADER) == "COREBOOT"
> 
> -  BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
> 
> -!else
> 
> -  BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
> 
> +!if $(UNIVERSAL_PAYLOAD) == FALSE
> 
> +  !if $(BOOTLOADER) == "COREBOOT"
> 
> +BlParseLib|UefiPayloadPkg/Library/CbParseLib/CbParseLib.inf
> 
> +  !else
> 
> +BlParseLib|UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
> 
> +  !endif
> 
>  !endif
> 
> 
> 
> 
> DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.
> inf
> 
> @@ -383,10 +389,18 @@
> 
> 
>  !if "IA32" in $(ARCH)
> 
>[Components.IA32]
> 
> +  !if $(UNIVERSAL_PAYLOAD) == TRUE
> 
> +UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> 
> +  !else
> 
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> 
> +  !endif
> 
>  !else
> 
>[Components.X64]
> 
> +  !if $(UNIVERSAL_PAYLOAD) == TRUE
> 
> +UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
> 
> +  !else
> 
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> 
> +  !endif
> 
>  !endif
> 
> 
> 
>  [Components.X64]
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf
> b/UefiPayloadPkg/UefiPayloadPkg.fdf
> index ed7fbcaddb..6073f9c1b4 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.fdf
> +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
> @@ -52,8 +52,9 @@ READ_STATUS= TRUE
>  READ_LOCK_CAP  = TRUE
> 
>  READ_LOCK_STATUS   = TRUE
> 
> 
> 
> +!if $(UNIVERSAL_PAYLOAD) == FALSE
> 
>  INF UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
> 
> -
> 
> +!endif
> 
>  FILE FV_IMAGE = 4E35FD93-9C72-4c15-8C4B-E77F1DB2D793 {
> 
>  SECTION FV_IMAGE = DXEFV
> 
>  }
> 
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal Payload

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 06/12] UefiPayloadPkg: Get and enter DxeCore for Universal
> Payload
> 
> From gUniversalPayloadExtraDataGuid Guid Hob, get the Dxe FV information,
> and get the Dxe Core from the FV.
> Also, make sure if there are muliple FV hob, the FV hob pointing to this FV
> will be the first in the hob list.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 47
> +++
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 17
> +
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 44
> ++--
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  1 +
>  UefiPayloadPkg/UefiPayloadEntry/X64/DxeLoadFunc.c |  4 ++--
>  5 files changed, 109 insertions(+), 4 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> index de9dbb0b0e..f5d70c59f8 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> @@ -305,3 +305,50 @@ LoadDxeCore (
> 
> 
>return EFI_SUCCESS;
> 
>  }
> 
> +
> 
> +/**
> 
> +  Find DXE core from FV and build DXE core HOBs.
> 
> +
> 
> +  @param[in]   DxeFv The FV where to find the DXE core.
> 
> +  @param[out]  DxeCoreEntryPoint DXE core entry point
> 
> +
> 
> +  @retval EFI_SUCCESSIf it completed successfully.
> 
> +  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
> 
> +**/
> 
> +EFI_STATUS
> 
> +UniversalLoadDxeCore (
> 
> +  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
> 
> +  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
> 
> +  )
> 
> +{
> 
> +  EFI_STATUS  Status;
> 
> +  EFI_FFS_FILE_HEADER *FileHeader;
> 
> +  VOID*PeCoffImage;
> 
> +  EFI_PHYSICAL_ADDRESSImageAddress;
> 
> +  UINT64  ImageSize;
> 
> +
> 
> +  //
> 
> +  // Find DXE core file from DXE FV
> 
> +  //
> 
> +  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, );
> 
> +  if (EFI_ERROR (Status)) {
> 
> +return Status;
> 
> +  }
> 
> +
> 
> +  Status = FileFindSection (FileHeader, EFI_SECTION_PE32, (VOID
> **));
> 
> +  if (EFI_ERROR (Status)) {
> 
> +return Status;
> 
> +  }
> 
> +
> 
> +  //
> 
> +  // Get DXE core info
> 
> +  //
> 
> +  Status = LoadPeCoffImage (PeCoffImage, , ,
> DxeCoreEntryPoint);
> 
> +  if (EFI_ERROR (Status)) {
> 
> +return Status;
> 
> +  }
> 
> +
> 
> +  BuildModuleHob (>Name, ImageAddress,
> EFI_SIZE_TO_PAGES ((UINT32) ImageSize) * EFI_PAGE_SIZE,
> *DxeCoreEntryPoint);
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> index e9c3ec3073..35098f5141 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> @@ -33,6 +33,8 @@
>  #include 
> 
>  #include 
> 
>  #include 
> 
> +#include 
> 
> +#include 
> 
> 
> 
>  #define LEGACY_8259_MASK_REGISTER_MASTER  0x21
> 
>  #define LEGACY_8259_MASK_REGISTER_SLAVE   0xA1
> 
> @@ -117,6 +119,21 @@ LoadDxeCore (
>OUT PHYSICAL_ADDRESS*DxeCoreEntryPoint
> 
>);
> 
> 
> 
> +/**
> 
> +  Find DXE core from FV and build DXE core HOBs.
> 
> +
> 
> +  @param[in]   DxeFv The FV where to find the DXE core.
> 
> +  @param[out]  DxeCoreEntryPoint DXE core entry point
> 
> +
> 
> +  @retval EFI_SUCCESSIf it completed successfully.
> 
> +  @retval EFI_NOT_FOUND  If it failed to load DXE FV.
> 
> +**/
> 
> +EFI_STATUS
> 
> +UniversalLoadDxeCore (
> 
> +  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv,
> 
> +  OUT PHYSICAL_ADDRESS   *DxeCoreEntryPoint
> 
> +  );
> 
> +
> 
>  /**
> 
> Transfers control to DxeCore.
> 
> 
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> index 66e87bcb9b..9d59454486 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> @@ -179,7 +179,8 @@ FindAnotherHighestBelow4GResourceDescriptor (
>  **/
> 
>  EFI_STATUS
> 
>  BuildHobs (
> 
> -  IN UINTN BootloaderParameter
> 
> +  IN  UINTN   BootloaderParameter,
> 
> +  OUT EFI_FIRMWARE_VOLUME_HEADER  **DxeFv
> 
>)
> 
>  {
> 
>EFI_PEI_HOB_POINTERS Hob;
> 
> @@ -190,6 +191,10 @@ BuildHobs (
>EFI_PHYSICAL_ADDRESS MemoryTop;
> 
>EFI_HOB_RESOURCE_DESCRIPTOR  *PhitResourceHob;
> 
>EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
> 
> +  

Re: [edk2-devel] [PATCH 05/12] UefiPayloadPkg: Create separate Payload Entry for UniversalPayload

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 05/12] UefiPayloadPkg: Create separate Payload Entry for
> UniversalPayload
> 
> This patch create the UniversalPayload Entry based on the UefiPayload
> Entry. It implements the logic to find a proper memory range to create the
> new Hob and migrate the Hobs from Bootloader.
> To make the change history clear, the logic to get the DxeCore will be in
> the next patch.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 311
> ++
> ++
> ++
> ++
> ++
> +
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  91
> ++
> +
>  2 files changed, 402 insertions(+)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> new file mode 100644
> index 00..66e87bcb9b
> --- /dev/null
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c
> @@ -0,0 +1,311 @@
> +/** @file
> 
> +
> 
> +  Copyright (c) 2021, Intel Corporation. All rights reserved.
> 
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +
> 
> +**/
> 
> +
> 
> +#include "UefiPayloadEntry.h"
> 
> +
> 
> +#define MEMORY_ATTRIBUTE_MASK
> (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_INITIALIZED
>  | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_TESTED 
>  | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 
>  | \
> 
> +   
> EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
> 
> +   
> EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
> 
> +   
> EFI_RESOURCE_ATTRIBUTE_READ_ONLY_PROTECTED |
> \
> 
> +   EFI_RESOURCE_ATTRIBUTE_16_BIT_IO  
>  | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_32_BIT_IO  
>  | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_64_BIT_IO  
>  | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_PERSISTENT 
>  )
> 
> +
> 
> +#define TESTED_MEMORY_ATTRIBUTES
> (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
> 
> +   EFI_RESOURCE_ATTRIBUTE_TESTED  )
> 
> +
> 
> +extern VOID  *mHobList;
> 
> +
> 
> +/**
> 
> +  Add HOB into HOB list
> 
> +
> 
> +  @param[in]  HobThe HOB to be added into the HOB list.
> 
> +**/
> 
> +VOID
> 
> +AddNewHob (
> 
> +  IN EFI_PEI_HOB_POINTERS*Hob
> 
> +  )
> 
> +{
> 
> +  EFI_PEI_HOB_POINTERSNewHob;
> 
> +
> 
> +  if (Hob->Raw == NULL) {
> 
> +return;
> 
> +  }
> 
> +  NewHob.Header = CreateHob (Hob->Header->HobType, Hob->Header-
> >HobLength);
> 
> +
> 
> +  if (NewHob.Header != NULL) {
> 
> +CopyMem (NewHob.Header + 1, Hob->Header + 1, Hob->Header-
> >HobLength - sizeof (EFI_HOB_GENERIC_HEADER));
> 
> +  }
> 
> +}
> 
> +
> 
> +/**
> 
> +  Found the Resource Descriptor HOB that contains a range
> 
> +
> 
> +  @param[in] Base   Memory start address
> 
> +  @param[in] TopMemory Top.
> 
> +
> 
> +  @return The pointer to the Resource Descriptor HOB.
> 
> +**/
> 
> +EFI_HOB_RESOURCE_DESCRIPTOR *
> 
> +FindResourceDescriptorByRange (
> 
> +  VOID  *HobList,
> 
> +  EFI_PHYSICAL_ADDRESS  Base,
> 
> +  EFI_PHYSICAL_ADDRESS  Top
> 
> +  )
> 
> +{
> 
> +  EFI_PEI_HOB_POINTERS Hob;
> 
> +  EFI_HOB_RESOURCE_DESCRIPTOR  *ResourceHob;
> 
> +
> 
> +  for (Hob.Raw = (UINT8 *) HobList; !END_OF_HOB_LIST(Hob); Hob.Raw =
> GET_NEXT_HOB(Hob)) {
> 
> +//
> 
> +// Skip all HOBs except Resource Descriptor HOBs
> 
> +//
> 
> +if (GET_HOB_TYPE (Hob) != EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
> 
> +  continue;
> 
> +}
> 
> +
> 
> +//
> 
> +// Skip Resource Descriptor HOBs that do not describe tested system
> memory
> 
> +//
> 
> +ResourceHob = Hob.ResourceDescriptor;
> 
> +if (ResourceHob->ResourceType != EFI_RESOURCE_SYSTEM_MEMORY) {
> 
> +  continue;
> 
> +}
> 
> +if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) !=
> TESTED_MEMORY_ATTRIBUTES) {
> 
> +  continue;
> 
> +}
> 
> +
> 
> +//
> 
> +

Re: [edk2-devel] [PATCH v4 2/4] OvmfPkg/BaseMemEncryptLib: Support to issue unencrypted hypercall

2021-06-22 Thread Lendacky, Thomas via groups.io
On 6/21/21 8:57 AM, Ashish Kalra wrote:
> From: Brijesh Singh 
> 
> By default all the SEV guest memory regions are considered encrypted,
> if a guest changes the encryption attribute of the page (e.g mark a
> page as decrypted) then notify hypervisor. Hypervisor will need to
> track the unencrypted pages. The information will be used during
> guest live migration, guest page migration and guest debugging.
> 
> Invoke hypercall via the new hypercall library.
> 
> This hypercall is used to notify hypervisor when a page is marked as
> 'decrypted' (i.e C-bit removed).
> 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> 
> Signed-off-by: Brijesh Singh 
> Signed-off-by: Ashish Kalra 
> ---
>  OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf   |  1 +
>  OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf   |  1 +
>  OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c | 22 
> 
>  3 files changed, 24 insertions(+)
> 
> diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf 
> b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
> index f2e162d680..aefcd7c0f7 100644
> --- a/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
> +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
> @@ -49,6 +49,7 @@
>DebugLib
>MemoryAllocationLib
>PcdLib
> +  MemEncryptHypercallLib
>  
>  [FeaturePcd]
>gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
> diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf 
> b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
> index 03a78c32df..7503f56a0b 100644
> --- a/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
> +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
> @@ -49,6 +49,7 @@
>DebugLib
>MemoryAllocationLib
>PcdLib
> +  MemEncryptHypercallLib
>  
>  [FeaturePcd]
>gUefiOvmfPkgTokenSpaceGuid.PcdSmmSmramRequire
> diff --git a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c 
> b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> index c696745f9d..12b3a9fcfb 100644
> --- a/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> +++ b/OvmfPkg/Library/BaseMemEncryptSevLib/X64/PeiDxeVirtualMemory.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "VirtualMemory.h"
>  
> @@ -585,6 +586,9 @@ SetMemoryEncDec (
>UINT64 AddressEncMask;
>BOOLEANIsWpEnabled;
>RETURN_STATUS  Status;
> +  UINTN  Size;
> +  BOOLEANCBitChanged;
> +  PHYSICAL_ADDRESS   OrigPhysicalAddress;
>  
>//
>// Set PageMapLevel4Entry to suppress incorrect compiler/analyzer warnings.
> @@ -636,6 +640,10 @@ SetMemoryEncDec (
>  
>Status = EFI_SUCCESS;
>  
> +  Size = Length;
> +  CBitChanged = FALSE;
> +  OrigPhysicalAddress = PhysicalAddress;
> +
>while (Length != 0)
>{
>  //
> @@ -695,6 +703,7 @@ SetMemoryEncDec (
>));
>  PhysicalAddress += BIT30;
>  Length -= BIT30;
> +CBitChanged = TRUE;
>} else {
>  //
>  // We must split the page
> @@ -749,6 +758,7 @@ SetMemoryEncDec (
>SetOrClearCBit (>Uint64, Mode);
>PhysicalAddress += BIT21;
>Length -= BIT21;
> +  CBitChanged = TRUE;
>  } else {
>//
>// We must split up this page into 4K pages
> @@ -791,6 +801,7 @@ SetMemoryEncDec (
>  SetOrClearCBit (>Uint64, Mode);
>  PhysicalAddress += EFI_PAGE_SIZE;
>  Length -= EFI_PAGE_SIZE;
> +CBitChanged = TRUE;
>}
>  }
>}
> @@ -808,6 +819,17 @@ SetMemoryEncDec (
>//
>CpuFlushTlb();
>  
> +  //
> +  // Notify Hypervisor on C-bit status
> +  //
> +  if (CBitChanged) {
> +SetMemoryEncDecHypercall3 (
> +  OrigPhysicalAddress,
> +  EFI_SIZE_TO_PAGES(Size),
> +  KVM_MAP_GPA_RANGE_ENC_STAT(!Mode)
> +  );
> +  }

Maybe add a comment here that the "Mode" doesn't care whether the change
was for 4k vs 2mb vs 1gb. It is just tracking the total number of pages
changed (should you just remove those #defines for the page sizes then?)
which can be done by calculating everything at the 4k level.

Thanks,
Tom

> +
>  Done:
>//
>// Restore page table write protection, if any.
> 


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




Re: [edk2-devel] [PATCH 10/12] UefiPayloadPkg: Add macro to disable some drivers

2021-06-22 Thread Guo Dong


> +  DEFINE DISABLE_VARIABLE  = FALSE

Could you change this MACRO definition as below to specifically disable EMU 
variable?
 DEFINE EMU_VARIABLE_ENABLE  = FALSE

This way, late we could enable other variable drivers (e.g. SMM variable) in 
UEFI payload.

Thanks,
Guo

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 10/12] UefiPayloadPkg: Add macro to disable some drivers
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadPkg.dsc | 11 ++-
>  UefiPayloadPkg/UefiPayloadPkg.fdf |  7 +++
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc
> b/UefiPayloadPkg/UefiPayloadPkg.dsc
> index 155aea4bc4..99b0e49d46 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.dsc
> +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
> @@ -87,6 +87,12 @@
>#
> 
>DEFINE SHELL_TYPE   = BUILD_SHELL
> 
> 
> 
> +  #
> 
> +  # Disable features
> 
> +  #
> 
> +  DEFINE DISABLE_VARIABLE  = FALSE
> 
> +  DEFINE DISABLE_RESET_SYSTEM  = FALSE
> 
> +
> 
>  [BuildOptions]
> 
>*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> 
>GCC:*_UNIXGCC_*_CC_FLAGS   = -DMDEPKG_NDEBUG
> 
> @@ -431,10 +437,13 @@
>MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
> 
>MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> 
> 
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
> terRuntimeDxe.inf
> 
> +!if $(DISABLE_RESET_SYSTEM) == FALSE
> 
> 
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
> Dxe.inf
> 
> +!endif
> 
> 
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntime
> Dxe.inf
> 
> +!if $(DISABLE_VARIABLE) == FALSE
> 
>MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> 
> -
> 
> +!endif
> 
>#
> 
># Following are the DXE drivers
> 
>#
> 
> diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf
> b/UefiPayloadPkg/UefiPayloadPkg.fdf
> index 6073f9c1b4..3b6adc2cfe 100644
> --- a/UefiPayloadPkg/UefiPayloadPkg.fdf
> +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf
> @@ -105,9 +105,16 @@ INF
> MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
>  INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
> 
>  INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
> 
>  INF
> MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCoun
> terRuntimeDxe.inf
> 
> +
> 
> +!if $(DISABLE_RESET_SYSTEM) == FALSE
> 
>  INF
> MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntime
> Dxe.inf
> 
> +!endif
> 
> +
> 
>  INF
> PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntime
> Dxe.inf
> 
> +
> 
> +!if $(DISABLE_VARIABLE) == FALSE
> 
>  INF
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
> 
> +!endif
> 
> 
> 
>  INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
> 
>  INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
> 
> --
> 2.16.2.windows.1



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




Re: [edk2-devel] [PATCH 07/12] UefiPayloadPkg: Fix up UPL Pcd database

2021-06-22 Thread Guo Dong

Please update the below function description to match the function impl.

+/**

+  Find DXE core from FV and build DXE core HOBs.

+

+  @param[in]   FvBaseFV base to load DXE core from

+  @param[out]  DxeCoreEntryPoint DXE core entry point

+

+  @retval EFI_SUCCESSIf it completed successfully.

+  @retval EFI_NOT_FOUND  If it failed to load DXE FV.

+**/

+EFI_STATUS

+FixUpPcdDatabase (

+  IN  EFI_FIRMWARE_VOLUME_HEADER *DxeFv

+  )


Remove the original one "*FileHeader = File;" since a new one is added in Guid 
check condition.

> @@ -172,7 +175,10 @@ FvFindFile (
>  //
> 
>  if (File->Type == FileType) {
> 
>*FileHeader = File;
> 
> -  return EFI_SUCCESS;
> 
> +  if (Guid == NULL || CompareGuid(>Name, Guid)) {
> 
> +*FileHeader = File;
> 
> +return EFI_SUCCESS;
> 
> +  }

Thanks,
Guo

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 07/12] UefiPayloadPkg: Fix up UPL Pcd database
> 
> Edk2 bootloader will pass the pei pcd database, and UPL also contain a
> PCD database.
> Dxe PCD driver has the assumption that the two PCD database can be
> catenated and the local token number should be successive。
> This patch will manually fix up the UPL PCD database to meet that
> assumption.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c | 18
> --
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h| 45
> +
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.c   | 55
> +++
>  UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf |  2 ++
>  UefiPayloadPkg/UefiPayloadPkg.dec |  2 ++
>  UefiPayloadPkg/UefiPayloadPkg.dsc |  1 +
>  6 files changed, 117 insertions(+), 6 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> index f5d70c59f8..f943a2632c 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/LoadDxeCore.c
> @@ -114,20 +114,23 @@ LoadPeCoffImage (
>  }
> 
> 
> 
>  /**
> 
> -  This function searchs a given file type within a valid FV.
> 
> +  This function searchs a given file type with a given Guid within a valid 
> FV.
> 
> +  If input Guid is NULL, will locate the first section having the given file 
> type
> 
> 
> 
>@param FvHeaderA pointer to firmware volume header that contains
> the set of files
> 
>   to be searched.
> 
>@param FileTypeFile type to be searched.
> 
> +  @param GuidWill ignore if it is NULL.
> 
>@param FileHeader  A pointer to the discovered file, if successful.
> 
> 
> 
>@retval EFI_SUCCESSSuccessfully found FileType
> 
>@retval EFI_NOT_FOUND  File type can't be found.
> 
>  **/
> 
>  EFI_STATUS
> 
> -FvFindFile (
> 
> +FvFindFileByTypeGuid (
> 
>IN  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader,
> 
>IN  EFI_FV_FILETYPE FileType,
> 
> +  IN  EFI_GUID*Guid   OPTIONAL,
> 
>OUT EFI_FFS_FILE_HEADER **FileHeader
> 
>)
> 
>  {
> 
> @@ -172,7 +175,10 @@ FvFindFile (
>  //
> 
>  if (File->Type == FileType) {
> 
>*FileHeader = File;
> 
> -  return EFI_SUCCESS;
> 
> +  if (Guid == NULL || CompareGuid(>Name, Guid)) {
> 
> +*FileHeader = File;
> 
> +return EFI_SUCCESS;
> 
> +  }
> 
>  }
> 
>}
> 
> 
> 
> @@ -266,7 +272,7 @@ LoadDxeCore (
>//
> 
>// DXE FV is inside Payload FV. Here find DXE FV from Payload FV
> 
>//
> 
> -  Status = FvFindFile (PayloadFv,
> EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, );
> 
> +  Status = FvFindFileByTypeGuid (PayloadFv,
> EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE, NULL, );
> 
>if (EFI_ERROR (Status)) {
> 
>  return Status;
> 
>}
> 
> @@ -283,7 +289,7 @@ LoadDxeCore (
>//
> 
>// Find DXE core file from DXE FV
> 
>//
> 
> -  Status = FvFindFile (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE, );
> 
> +  Status = FvFindFileByTypeGuid (DxeCoreFv, EFI_FV_FILETYPE_DXE_CORE,
> NULL, );
> 
>if (EFI_ERROR (Status)) {
> 
>  return Status;
> 
>}
> 
> @@ -330,7 +336,7 @@ UniversalLoadDxeCore (
>//
> 
>// Find DXE core file from DXE FV
> 
>//
> 
> -  Status = FvFindFile (DxeFv, EFI_FV_FILETYPE_DXE_CORE, );
> 
> +  Status = FvFindFileByTypeGuid (DxeFv, EFI_FV_FILETYPE_DXE_CORE, NULL,
> );
> 
>if (EFI_ERROR (Status)) {
> 
>  return Status;
> 
>}
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> index 35098f5141..78a67fa1a5 100644
> --- 

Re: [edk2-devel] [PATCH 04/12] UefiPayloadPkg: Update the function definition of HobConstructor

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 04/12] UefiPayloadPkg: Update the function definition of
> HobConstructor
> 
> Update the function defination of HobConstructor to align the Phit Hob
> structure.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c| 26 +--
> ---
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c |  5 +
>  UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 16 
>  3 files changed, 22 insertions(+), 25 deletions(-)
> 
> diff --git a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
> b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
> index 23a749edf1..768c3db770 100644
> --- a/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
> +++ b/UefiPayloadPkg/Library/PayloadEntryHobLib/Hob.c
> @@ -39,14 +39,14 @@ GetHobList (
>  /**
> 
>Build a Handoff Information Table HOB
> 
> 
> 
> -  This function initialize a HOB region from EfiMemoryBegin with length
> 
> -  EfiMemoryLength. And EfiFreeMemoryBottom and EfiFreeMemoryTop
> should
> 
> +  This function initialize a HOB region from EfiMemoryBegin to
> 
> +  EfiMemoryTop. And EfiFreeMemoryBottom and EfiFreeMemoryTop
> should
> 
>be inside the HOB region.
> 
> 
> 
> -  @param[in] EfiMemoryBegin   Total memory start address
> 
> -  @param[in] EfiMemoryLength  Total memory length reported in handoff
> HOB.
> 
> -  @param[in] EfiFreeMemoryBottom  Free memory start address
> 
> -  @param[in] EfiFreeMemoryTop Free memory end address.
> 
> +  @param[in] EfiMemoryBottom   Total memory start address
> 
> +  @param[in] EfiMemoryTop  Total memory end address.
> 
> +  @param[in] EfiFreeMemoryBottom   Free memory start address
> 
> +  @param[in] EfiFreeMemoryTop  Free memory end address.
> 
> 
> 
>@return   The pointer to the handoff HOB table.
> 
> 
> 
> @@ -54,8 +54,8 @@ GetHobList (
>  EFI_HOB_HANDOFF_INFO_TABLE*
> 
>  EFIAPI
> 
>  HobConstructor (
> 
> -  IN VOID   *EfiMemoryBegin,
> 
> -  IN UINTN  EfiMemoryLength,
> 
> +  IN VOID   *EfiMemoryBottom,
> 
> +  IN VOID   *EfiMemoryTop,
> 
>IN VOID   *EfiFreeMemoryBottom,
> 
>IN VOID   *EfiFreeMemoryTop
> 
>)
> 
> @@ -77,11 +77,11 @@ HobConstructor (
>Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
> 
>Hob->BootMode= BOOT_WITH_FULL_CONFIGURATION;
> 
> 
> 
> -  Hob->EfiMemoryTop= (UINTN)EfiMemoryBegin + EfiMemoryLength;
> 
> -  Hob->EfiMemoryBottom = (UINTN)EfiMemoryBegin;
> 
> -  Hob->EfiFreeMemoryTop= (UINTN)EfiFreeMemoryTop;
> 
> -  Hob->EfiFreeMemoryBottom =
> (EFI_PHYSICAL_ADDRESS)(UINTN)(HobEnd+1);
> 
> -  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS)(UINTN)HobEnd;
> 
> +  Hob->EfiMemoryTop= (EFI_PHYSICAL_ADDRESS) EfiMemoryTop;
> 
> +  Hob->EfiMemoryBottom = (EFI_PHYSICAL_ADDRESS) EfiMemoryBottom;
> 
> +  Hob->EfiFreeMemoryTop= (EFI_PHYSICAL_ADDRESS)
> EfiFreeMemoryTop;
> 
> +  Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN)
> (HobEnd+1);
> 
> +  Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
> 
> 
> 
>mHobList = Hob;
> 
>return Hob;
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> index 8c6f7e326f..4308936d63 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> @@ -382,7 +382,6 @@ PayloadEntry (
>PHYSICAL_ADDRESS  DxeCoreEntryPoint;
> 
>EFI_HOB_HANDOFF_INFO_TABLE*HandoffHobTable;
> 
>UINTN MemBase;
> 
> -  UINTN MemSize;
> 
>UINTN HobMemBase;
> 
>UINTN HobMemTop;
> 
>EFI_PEI_HOB_POINTERS  Hob;
> 
> @@ -401,9 +400,7 @@ PayloadEntry (
>HobMemBase = ALIGN_VALUE (MemBase + PcdGet32
> (PcdPayloadFdMemSize), SIZE_1MB);
> 
>HobMemTop  = HobMemBase + FixedPcdGet32
> (PcdSystemMemoryUefiRegionSize);
> 
> 
> 
> -  // DXE core assumes the memory below HOB region could be used, so
> include the FV region memory into HOB range.
> 
> -  MemSize= HobMemTop - MemBase;
> 
> -  HandoffHobTable = HobConstructor ((VOID *)MemBase, MemSize, (VOID
> *)HobMemBase, (VOID *)HobMemTop);
> 
> +  HobConstructor ((VOID *)MemBase, (VOID *)HobMemTop, (VOID
> *)HobMemBase, (VOID *)HobMemTop);
> 
> 
> 
>// Build HOB based on information from Bootloader
> 
>Status = BuildHobFromBl ();
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> index a4c9da128e..e9c3ec3073 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
> @@ -83,14 

Re: [edk2-devel] [PATCH 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for Universal Payload

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH 03/12] UefiPayloadPkg: Add a separate PlatformHookLib for
> Universal Payload
> 
> Add a new separate PlatformHookLib for Universal Payload to consume Guid
> Hob gUniversalPayloadSerialPortInfoGuid to get serial port information
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Zhiguang Liu 
> ---
> 
> UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.
> c   | 82
> ++
> 
> 
> UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLib.
> inf | 41 +
>  2 files changed, 123 insertions(+)
> 
> diff --git
> a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.c
> b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.c
> new file mode 100644
> index 00..6705f29505
> --- /dev/null
> +++
> b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.c
> @@ -0,0 +1,82 @@
> +/** @file
> 
> +  Platform Hook Library instance for UART device.
> 
> +
> 
> +  Copyright (c) 2021, Intel Corporation. All rights reserved.
> 
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +
> 
> +**/
> 
> +
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +#include 
> 
> +
> 
> +/**
> 
> +  Performs platform specific initialization required for the CPU to access
> 
> +  the hardware associated with a SerialPortLib instance.  This function does
> 
> +  not initialize the serial port hardware itself.  Instead, it initializes
> 
> +  hardware devices that are required for the CPU to access the serial port
> 
> +  hardware.  This function may be called more than once.
> 
> +
> 
> +  @retval RETURN_SUCCESS   The platform specific initialization 
> succeeded.
> 
> +  @retval RETURN_DEVICE_ERROR  The platform specific initialization could
> not be completed.
> 
> +
> 
> +**/
> 
> +RETURN_STATUS
> 
> +EFIAPI
> 
> +PlatformHookSerialPortInitialize (
> 
> +  VOID
> 
> +  )
> 
> +{
> 
> +  RETURN_STATUS   Status;
> 
> +  UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO  *SerialPortInfo;
> 
> +  UINT8   *GuidHob;
> 
> +  UNIVERSAL_PAYLOAD_GENERIC_HEADER*GenericHeader;
> 
> +
> 
> +  GuidHob = GetFirstGuidHob ();
> 
> +  if (GuidHob == NULL) {
> 
> +return EFI_NOT_FOUND;
> 
> +  }
> 
> +
> 
> +  GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)
> GET_GUID_HOB_DATA (GuidHob);
> 
> +  if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) >
> GET_GUID_HOB_DATA_SIZE (GuidHob)) || (GenericHeader->Length >
> GET_GUID_HOB_DATA_SIZE (GuidHob))) {
> 
> +return EFI_NOT_FOUND;
> 
> +  }
> 
> +
> 
> +  if (GenericHeader->Revision ==
> UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO_REVISION) {
> 
> +SerialPortInfo = (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO *)
> GET_GUID_HOB_DATA (GuidHob);
> 
> +if (GenericHeader->Length <
> UNIVERSAL_PAYLOAD_SIZEOF_THROUGH_FIELD
> (UNIVERSAL_PAYLOAD_SERIAL_PORT_INFO, RegisterBase)) {
> 
> +  //
> 
> +  // Return if can't find the Serial Port Info Hob with enough length
> 
> +  //
> 
> +  return EFI_NOT_FOUND;
> 
> +}
> 
> +
> 
> +Status = PcdSetBoolS (PcdSerialUseMmio, SerialPortInfo->UseMmio);
> 
> +if (RETURN_ERROR (Status)) {
> 
> +  return Status;
> 
> +}
> 
> +Status = PcdSet64S (PcdSerialRegisterBase, SerialPortInfo->RegisterBase);
> 
> +if (RETURN_ERROR (Status)) {
> 
> +  return Status;
> 
> +}
> 
> +Status = PcdSet32S (PcdSerialRegisterStride, SerialPortInfo-
> >RegisterStride);
> 
> +if (RETURN_ERROR (Status)) {
> 
> +  return Status;
> 
> +}
> 
> +Status = PcdSet32S (PcdSerialBaudRate, SerialPortInfo->BaudRate);
> 
> +if (RETURN_ERROR (Status)) {
> 
> +  return Status;
> 
> +}
> 
> +Status = PcdSet64S (PcdUartDefaultBaudRate, SerialPortInfo->BaudRate);
> 
> +if (RETURN_ERROR (Status)) {
> 
> +  return Status;
> 
> +}
> 
> +
> 
> +return RETURN_SUCCESS;
> 
> +  }
> 
> +
> 
> +  return EFI_NOT_FOUND;
> 
> +}
> 
> diff --git
> a/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.inf
> b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.inf
> new file mode 100644
> index 00..41e05ddf54
> --- /dev/null
> +++
> b/UefiPayloadPkg/Library/UniversalPayloadPlatformHookLib/PlatformHookLi
> b.inf
> @@ -0,0 +1,41 @@
> +## @file
> 
> +#  Platform Hook Library instance for UART device for Universal Payload.
> 
> +#
> 
> +#  Copyright (c) 2021, Intel Corporation. All rights reserved.
> 
> +#
> 
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +#
> 
> +##
> 
> +
> 
> +[Defines]
> 
> +  INF_VERSION= 0x00010005
> 
> +  BASE_NAME  

Re: [edk2-devel] [PATCH 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload

2021-06-22 Thread Guo Dong


Could you add description why you need add new library DxeHobLib + 
DxeHobListLib for DXE drivers instead of using 
MdePkg/Library/DxeHobLib/DxeHobLib.inf?
And please check if UefiLib is still required for new DxeHobLib since it is 
listed in the INF file.

BTW, it looks there are some comments updated in the HobLib from MdePkg. Maybe 
sync the changes to new Hob.

Thanks,
Guo

> -Original Message-
> From: Liu, Zhiguang 
> Sent: Sunday, June 20, 2021 8:47 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin ; Ni, Ray
> 
> Subject: [PATCH 01/12] UefiPayloadPkg: Add HobLib for UniversalPayload
> 
> For payload entry, use PayloadEntryHobLib as HobLib and payload entry
> should initialize hob base.
> For DxeCore, use new added DxeHobLib as HobLib, and DxeCore will
> initialize hob base.
> For Dxe Driver, use new added DxeHobLib as HobLib, and use DxeHobListLib
> to initialize hob base.
> 
> Cc: Maurice Ma 
> Cc: Guo Dong 
> Cc: Benjamin You 
> Signed-off-by: Ray Ni 
> Signed-off-by: Zhiguang Liu 
> ---
>  UefiPayloadPkg/Include/Library/DxeHobListLib.h   |  27
> +++
>  UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf   |  40
> 
>  UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.uni   |  17
> +
>  UefiPayloadPkg/Library/DxeHobLib/HobLib.c| 597
> ++
> ++
> ++
> ++
> ++
> ++
> ++
> ++
> ++
> ++
> +
>  UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.c |  66
> ++
> 
>  UefiPayloadPkg/Library/DxeHobListLib/DxeHobListLib.inf   |  35
> +++
>  UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.c |  20
> 
>  UefiPayloadPkg/Library/DxeHobListLibNull/DxeHobListLibNull.inf   |  28
> 
>  UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/Hob.c  |   2 +-
>  UefiPayloadPkg/Library/{HobLib => PayloadEntryHobLib}/HobLib.inf |   2 +-
>  UefiPayloadPkg/UefiPayloadPkg.dsc|  15 
> +++
>  11 files changed, 843 insertions(+), 6 deletions(-)
> 
> diff --git a/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> new file mode 100644
> index 00..7e9b23f6d7
> --- /dev/null
> +++ b/UefiPayloadPkg/Include/Library/DxeHobListLib.h
> @@ -0,0 +1,27 @@
> +/** @file
> 
> +  Provides a service to retrieve a pointer to the start of HOB list.
> 
> +  Only available to DXE module types.
> 
> +
> 
> +  This library does not contain any functions or macros.  It simply exports a
> global
> 
> +  pointer to the start of HOB list as defined in the Platform Initialization
> Driver
> 
> +  Execution Environment Core Interface Specification.  The library
> constructor must
> 
> +  initialize this global pointer to the start of HOB list, so it is 
> available at the
> 
> +  module's entry point.  Since there is overhead in looking up the pointer to
> the start
> 
> +  of HOB list, only those modules that actually require access to the HOB 
> list
> 
> +  should use this library.
> 
> +
> 
> +Copyright (c) 2021, Intel Corporation. All rights reserved.
> 
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +
> 
> +**/
> 
> +
> 
> +#ifndef __DXE_HOB_LIST_LIB_H__
> 
> +#define __DXE_HOB_LIST_LIB_H__
> 
> +
> 
> +///
> 
> +/// Cache copy of the start of HOB list
> 
> +///
> 
> +extern VOID  *gHobList;
> 
> +
> 
> +#endif
> 
> +
> 
> diff --git a/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> new file mode 100644
> index 00..a146befd25
> --- /dev/null
> +++ b/UefiPayloadPkg/Library/DxeHobLib/DxeHobLib.inf
> @@ -0,0 +1,40 @@
> +## @file
> 
> +# Instance of HOB Library using HOB list from EFI Configuration Table.
> 
> +#
> 
> +# HOB Library implementation that retrieves the HOB List
> 
> +#  from the System Configuration Table in the EFI System Table.
> 
> +#
> 
> +# Copyright (c) 2021, Intel Corporation. All rights reserved.
> 
> +#
> 
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> 
> +#
> 
> +#
> 
> +##
> 
> +
> 
> +[Defines]
> 
> +  INF_VERSION= 0x00010005
> 
> +  BASE_NAME  = DxeHobLib
> 
> +  MODULE_UNI_FILE= 

Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Lendacky, Thomas via groups.io
On 6/21/21 8:56 AM, Ashish Kalra wrote:
> From: Ashish Kalra 
> 
> Add SEV and SEV-ES hypercall abstraction library to support SEV Page
> encryption/deceryption status hypercalls for SEV and SEV-ES guests.

Does this have to be a new library? It's just a single function and so I
would think it could live in the BaseMemEncryptSevLib library where the
change to the c-bit is being done anyway.

> 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> 
> Signed-off-by: Ashish Kalra 
> ---
>  Maintainers.txt  |   2 +
>  OvmfPkg/Include/Library/MemEncryptHypercallLib.h |  43 
> 
>  OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c |  37 
> +++
>  OvmfPkg/Library/MemEncryptHypercallLib/MemEncryptHypercallLib.inf|  42 
> 
>  OvmfPkg/Library/MemEncryptHypercallLib/X64/AsmHelperStub.nasm|  28 
> ++
>  OvmfPkg/Library/MemEncryptHypercallLib/X64/MemEncryptHypercallLib.c  | 105 
> 
>  OvmfPkg/OvmfPkgIa32.dsc  |   1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc   |   1 +
>  OvmfPkg/OvmfPkgX64.dsc   |   1 +
>  OvmfPkg/OvmfXen.dsc  |   1 +
>  10 files changed, 261 insertions(+)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt
> index ea54e0b7e9..8ecc8464ba 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -449,8 +449,10 @@ F: OvmfPkg/AmdSev/
>  F: OvmfPkg/AmdSevDxe/
>  F: OvmfPkg/Include/Guid/ConfidentialComputingSecret.h
>  F: OvmfPkg/Include/Library/MemEncryptSevLib.h
> +F: OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>  F: OvmfPkg/IoMmuDxe/AmdSevIoMmu.*
>  F: OvmfPkg/Library/BaseMemEncryptSevLib/
> +F: OvmfPkg/Library/MemEncryptHypercallLib/
>  F: OvmfPkg/Library/PlatformBootManagerLibGrub/
>  F: OvmfPkg/Library/VmgExitLib/
>  F: OvmfPkg/PlatformPei/AmdSev.c
> diff --git a/OvmfPkg/Include/Library/MemEncryptHypercallLib.h 
> b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
> new file mode 100644
> index 00..b241a189b6
> --- /dev/null
> +++ b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
> @@ -0,0 +1,43 @@
> +/** @file
> +
> +  Define Secure Encrypted Virtualization (SEV) hypercall library.
> +
> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _MEM_ENCRYPT_HYPERCALL_LIB_H_
> +#define _MEM_ENCRYPT_HYPERCALL_LIB_H_
> +
> +#include 
> +
> +#define KVM_HC_MAP_GPA_RANGE   12
> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_4K0

> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M(1 << 0)

Use the BIT0 define, e.g.:
#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M  BIT0

> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_1G(1 << 1)

BIT1

Also, where are these used? Are they supposed to be part of the "Mode"
parameter, in which case the comment for Mode below is incorrect.

> +#define KVM_MAP_GPA_RANGE_ENC_STAT(n)   ((n) << 4)
> +#define KVM_MAP_GPA_RANGE_ENCRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(1)
> +#define KVM_MAP_GPA_RANGE_DECRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(0)
> +
> +/**
> + This hyercall is used to notify hypervisor when a page is marked as
> + 'decrypted' (i.e C-bit removed).
> +
> + @param[in]   PhysicalAddress   The physical address that is the start 
> address
> +of a memory region.
> + @param[in]   LengthThe length of memory region
> + @param[in]   Mode  SetCBit or ClearCBit
> +
> +**/
> +
> +VOID
> +EFIAPI
> +SetMemoryEncDecHypercall3 (
> +  IN  UINTN PhysicalAddress,
> +  IN  UINTN Length,
> +  IN  UINTN Mode
> +  );
> +
> +#endif
> diff --git 
> a/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c 
> b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
> new file mode 100644
> index 00..2e73d47ee6
> --- /dev/null
> +++ b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
> @@ -0,0 +1,37 @@
> +/** @file
> +
> +  Secure Encrypted Virtualization (SEV) hypercall helper library
> +
> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +
> +/**
> + This hyercall is used to notify hypervisor when a page is marked as
> + 'decrypted' (i.e C-bit removed).
> +
> + @param[in]   PhysicalAddress   The physical address that is the start 
> address
> +of a memory region.
> + @param[in]   LengthThe length of memory region
> + @param[in]   Mode  SetCBit or ClearCBit

This isn't actually SetCBit or ClearCBit based on how I see it used below.

> +
> +**/
> +
> +VOID
> +EFIAPI
> +SetMemoryEncDecHypercall3 (
> +  IN PHYSICAL_ADDRESS PhysicalAddress,
> +  IN UINTNPages,

This doesn't match 

Re: [edk2-devel] [PATCH v4 3/4] OvmfPkg/PlatformPei: Mark SEC GHCB page as unencrypted via hypercall

2021-06-22 Thread Brijesh Singh via groups.io



On 6/21/2021 8:57 AM, Ashish Kalra wrote:
> From: Ashish Kalra 
> 
> Mark the SEC GHCB page (that is mapped as unencrypted in
> ResetVector code) in the hypervisor page status tracking.
> 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> 
Remove this new line.

> Signed-off-by: Ashish Kalra 
> ---
>  OvmfPkg/PlatformPei/AmdSev.c | 10 ++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/OvmfPkg/PlatformPei/AmdSev.c b/OvmfPkg/PlatformPei/AmdSev.c
> index a8bf610022..3f642ecb06 100644
> --- a/OvmfPkg/PlatformPei/AmdSev.c
> +++ b/OvmfPkg/PlatformPei/AmdSev.c
> @@ -15,6 +15,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -52,6 +53,15 @@ AmdSevEsInitialize (
>PcdStatus = PcdSetBoolS (PcdSevEsIsEnabled, TRUE);
>ASSERT_RETURN_ERROR (PcdStatus);
>  
> +  //
> +  // GHCB_BASE setup during reset-vector needs to be marked as
> +  // decrypted in the hypervisor page encryption bitmap.
> +  //
> +  SetMemoryEncDecHypercall3 (FixedPcdGet32 (PcdOvmfSecGhcbBase),
> +EFI_SIZE_TO_PAGES(FixedPcdGet32 (PcdOvmfSecGhcbSize)),
> +KVM_MAP_GPA_RANGE_DECRYPTED
> +);
> +

Typically we should invoke the HC as soon as the page state is changed in the 
PTE.
Why we are notifying it too late? Is this because you are trying to avoid asm 
code
or there is no MSR protocol for VMMCALL NAE ?

I am okay with not notifying in ASM code, but at least we should notify the 
change
during the ES protocol negotiation and before the GHCB is setup. In other words,
do it inside the  SevEsProtocolCheck() [Sec/SecMain.c].

-Brijesh


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




Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Brijesh Singh via groups.io



On 6/22/2021 2:47 PM, Brijesh Singh wrote:
> 
> 
> On 6/21/2021 8:56 AM, Ashish Kalra wrote:
>> From: Ashish Kalra 
>>
>> Add SEV and SEV-ES hypercall abstraction library to support SEV Page
>> encryption/deceryption status hypercalls for SEV and SEV-ES guests.
>>
>> Cc: Jordan Justen 
>> Cc: Laszlo Ersek 
>> Cc: Ard Biesheuvel 
>>
> Remove this newline.
> 
>> Signed-off-by: Ashish Kalra 
>> ---
>>  Maintainers.txt  |   2 +
>>  OvmfPkg/Include/Library/MemEncryptHypercallLib.h |  43 
>> 
>>  OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c |  37 
>> +++
>>  OvmfPkg/Library/MemEncryptHypercallLib/MemEncryptHypercallLib.inf|  42 
>> 
>>  OvmfPkg/Library/MemEncryptHypercallLib/X64/AsmHelperStub.nasm|  28 
>> ++
>>  OvmfPkg/Library/MemEncryptHypercallLib/X64/MemEncryptHypercallLib.c  | 105 
>> 
>>  OvmfPkg/OvmfPkgIa32.dsc  |   1 +
>>  OvmfPkg/OvmfPkgIa32X64.dsc   |   1 +
>>  OvmfPkg/OvmfPkgX64.dsc   |   1 +
>>  OvmfPkg/OvmfXen.dsc  |   1 +
>>  10 files changed, 261 insertions(+)
>>
>> diff --git a/Maintainers.txt b/Maintainers.txt
>> index ea54e0b7e9..8ecc8464ba 100644
>> --- a/Maintainers.txt
>> +++ b/Maintainers.txt
>> @@ -449,8 +449,10 @@ F: OvmfPkg/AmdSev/
>>  F: OvmfPkg/AmdSevDxe/
>>  F: OvmfPkg/Include/Guid/ConfidentialComputingSecret.h
>>  F: OvmfPkg/Include/Library/MemEncryptSevLib.h
>> +F: OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>>  F: OvmfPkg/IoMmuDxe/AmdSevIoMmu.*
>>  F: OvmfPkg/Library/BaseMemEncryptSevLib/
>> +F: OvmfPkg/Library/MemEncryptHypercallLib/
>>  F: OvmfPkg/Library/PlatformBootManagerLibGrub/
>>  F: OvmfPkg/Library/VmgExitLib/
>>  F: OvmfPkg/PlatformPei/AmdSev.c
>> diff --git a/OvmfPkg/Include/Library/MemEncryptHypercallLib.h 
>> b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>> new file mode 100644
>> index 00..b241a189b6
>> --- /dev/null
>> +++ b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>> @@ -0,0 +1,43 @@
>> +/** @file
>> +
>> +  Define Secure Encrypted Virtualization (SEV) hypercall library.
>> +
>> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
>
>2021
> 
>> +
>> +  SPDX-License-Identifier: BSD-2-Clause-Patent
>> +
>> +**/
>> +
>> +#ifndef _MEM_ENCRYPT_HYPERCALL_LIB_H_
>> +#define _MEM_ENCRYPT_HYPERCALL_LIB_H_
>> +
>> +#include 
>> +
>> +#define KVM_HC_MAP_GPA_RANGE   12
>> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_4K0
>> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M(1 << 0)
>> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_1G(1 << 1)
>> +#define KVM_MAP_GPA_RANGE_ENC_STAT(n)   ((n) << 4)
>> +#define KVM_MAP_GPA_RANGE_ENCRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(1)
>> +#define KVM_MAP_GPA_RANGE_DECRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(0)
>> +
>> +/**
>> + This hyercall is used to notify hypervisor when a page is marked as
>> + 'decrypted' (i.e C-bit removed).
>> +
> Looking at the function signature it seems this routine is used for both set
> and clear. Please update the comment accordingly.
> 
> 
>> + @param[in]   PhysicalAddress   The physical address that is the start 
>> address
>> +of a memory region.
>> + @param[in]   LengthThe length of memory region
>> + @param[in]   Mode  SetCBit or ClearCBit
>> +
>> +**/
>> +
>> +VOID
>> +EFIAPI
>> +SetMemoryEncDecHypercall3 (
>> +  IN  UINTN PhysicalAddress,
>> +  IN  UINTN Length,
>> +  IN  UINTN Mode
>> +  );
>> +
>> +#endif
>> diff --git 
>> a/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c 
>> b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
>> new file mode 100644
>> index 00..2e73d47ee6
>> --- /dev/null
>> +++ b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
>> @@ -0,0 +1,37 @@
>> +/** @file
>> +
>> +  Secure Encrypted Virtualization (SEV) hypercall helper library
>> +
>> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
>
>2021
> 
>> +
>> +  SPDX-License-Identifier: BSD-2-Clause-Patent
>> +
>> +**/
>> +
>> +#include 
>> +#include 
>> +#include 
>> +
>> +/**
>> + This hyercall is used to notify hypervisor when a page is marked as
>> + 'decrypted' (i.e C-bit removed).
>> +
>> + @param[in]   PhysicalAddress   The physical address that is the start 
>> address
>> +of a memory region.
>> + @param[in]   LengthThe length of memory region
>> + @param[in]   Mode  SetCBit or ClearCBit
>> +
>> +**/
>> +
>> +VOID
>> +EFIAPI
>> +SetMemoryEncDecHypercall3 (
>> +  IN PHYSICAL_ADDRESS PhysicalAddress,
>> +  IN UINTNPages,
>> +  IN UINTNMode
>> +  )
>> +{

Re: [edk2-devel] [PATCH v4 1/4] OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.

2021-06-22 Thread Brijesh Singh via groups.io



On 6/21/2021 8:56 AM, Ashish Kalra wrote:
> From: Ashish Kalra 
> 
> Add SEV and SEV-ES hypercall abstraction library to support SEV Page
> encryption/deceryption status hypercalls for SEV and SEV-ES guests.
> 
> Cc: Jordan Justen 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> 
Remove this newline.

> Signed-off-by: Ashish Kalra 
> ---
>  Maintainers.txt  |   2 +
>  OvmfPkg/Include/Library/MemEncryptHypercallLib.h |  43 
> 
>  OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c |  37 
> +++
>  OvmfPkg/Library/MemEncryptHypercallLib/MemEncryptHypercallLib.inf|  42 
> 
>  OvmfPkg/Library/MemEncryptHypercallLib/X64/AsmHelperStub.nasm|  28 
> ++
>  OvmfPkg/Library/MemEncryptHypercallLib/X64/MemEncryptHypercallLib.c  | 105 
> 
>  OvmfPkg/OvmfPkgIa32.dsc  |   1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc   |   1 +
>  OvmfPkg/OvmfPkgX64.dsc   |   1 +
>  OvmfPkg/OvmfXen.dsc  |   1 +
>  10 files changed, 261 insertions(+)
> 
> diff --git a/Maintainers.txt b/Maintainers.txt
> index ea54e0b7e9..8ecc8464ba 100644
> --- a/Maintainers.txt
> +++ b/Maintainers.txt
> @@ -449,8 +449,10 @@ F: OvmfPkg/AmdSev/
>  F: OvmfPkg/AmdSevDxe/
>  F: OvmfPkg/Include/Guid/ConfidentialComputingSecret.h
>  F: OvmfPkg/Include/Library/MemEncryptSevLib.h
> +F: OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>  F: OvmfPkg/IoMmuDxe/AmdSevIoMmu.*
>  F: OvmfPkg/Library/BaseMemEncryptSevLib/
> +F: OvmfPkg/Library/MemEncryptHypercallLib/
>  F: OvmfPkg/Library/PlatformBootManagerLibGrub/
>  F: OvmfPkg/Library/VmgExitLib/
>  F: OvmfPkg/PlatformPei/AmdSev.c
> diff --git a/OvmfPkg/Include/Library/MemEncryptHypercallLib.h 
> b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
> new file mode 100644
> index 00..b241a189b6
> --- /dev/null
> +++ b/OvmfPkg/Include/Library/MemEncryptHypercallLib.h
> @@ -0,0 +1,43 @@
> +/** @file
> +
> +  Define Secure Encrypted Virtualization (SEV) hypercall library.
> +
> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
   
   2021

> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#ifndef _MEM_ENCRYPT_HYPERCALL_LIB_H_
> +#define _MEM_ENCRYPT_HYPERCALL_LIB_H_
> +
> +#include 
> +
> +#define KVM_HC_MAP_GPA_RANGE   12
> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_4K0
> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M(1 << 0)
> +#define KVM_MAP_GPA_RANGE_PAGE_SZ_1G(1 << 1)
> +#define KVM_MAP_GPA_RANGE_ENC_STAT(n)   ((n) << 4)
> +#define KVM_MAP_GPA_RANGE_ENCRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(1)
> +#define KVM_MAP_GPA_RANGE_DECRYPTED KVM_MAP_GPA_RANGE_ENC_STAT(0)
> +
> +/**
> + This hyercall is used to notify hypervisor when a page is marked as
> + 'decrypted' (i.e C-bit removed).
> +
Looking at the function signature it seems this routine is used for both set
and clear. Please update the comment accordingly.


> + @param[in]   PhysicalAddress   The physical address that is the start 
> address
> +of a memory region.
> + @param[in]   LengthThe length of memory region
> + @param[in]   Mode  SetCBit or ClearCBit
> +
> +**/
> +
> +VOID
> +EFIAPI
> +SetMemoryEncDecHypercall3 (
> +  IN  UINTN PhysicalAddress,
> +  IN  UINTN Length,
> +  IN  UINTN Mode
> +  );
> +
> +#endif
> diff --git 
> a/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c 
> b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
> new file mode 100644
> index 00..2e73d47ee6
> --- /dev/null
> +++ b/OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
> @@ -0,0 +1,37 @@
> +/** @file
> +
> +  Secure Encrypted Virtualization (SEV) hypercall helper library
> +
> +  Copyright (c) 2020, AMD Incorporated. All rights reserved.
   
   2021

> +
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include 
> +#include 
> +#include 
> +
> +/**
> + This hyercall is used to notify hypervisor when a page is marked as
> + 'decrypted' (i.e C-bit removed).
> +
> + @param[in]   PhysicalAddress   The physical address that is the start 
> address
> +of a memory region.
> + @param[in]   LengthThe length of memory region
> + @param[in]   Mode  SetCBit or ClearCBit
> +
> +**/
> +
> +VOID
> +EFIAPI
> +SetMemoryEncDecHypercall3 (
> +  IN PHYSICAL_ADDRESS PhysicalAddress,
> +  IN UINTNPages,
> +  IN UINTNMode
> +  )
> +{
> +  //
> +  // Memory encryption bit is not accessible in 32-bit mode
> +  //
> +}
> diff --git 
> a/OvmfPkg/Library/MemEncryptHypercallLib/MemEncryptHypercallLib.inf 
> 

Re: [edk2-devel] [PATCH v3] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader memrange parsing

2021-06-22 Thread Guo Dong


Patch pushed @ 
https://github.com/tianocore/edk2/commit/1e5e58d39bb18a127e978d6e46a7454430799e57

> -Original Message-
> From: Patrick Rudolph 
> Sent: Monday, June 21, 2021 1:10 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH v3] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader
> memrange parsing
> 
> Currently several DXE crash due to invalid memory resource settings.
> The PciHostBridgeDxe which expects the MMCONF and PCI Aperature
> to be EfiMemoryMappedIO, but currently those regions are (partly)
> mapped as EfiReservedMemoryType.
> 
> coreboot and slimbootloader provide an e820 compatible memory map,
> which doesn't work well with EDK2 as the e820 spec is missing MMIO regions.
> In e820 'reserved' could either mean "DRAM used by boot firmware" or
> "MMIO
> in use and not detectable by OS".
> 
> Guess Top of lower usable DRAM (TOLUD) by walking the bootloader
> provided
> memory ranges. Memory types of RAM, ACPI and ACPI NVS below 4 GiB are
> used
> to increment TOLUD and reserved memory ranges touching TOLUD at the
> base
> are also assumed to be reserved DRAM, which increment TOLUD.
> 
> Then mark everything reserved below TOLUD as EfiReservedMemoryType
> and
> everything reserved above TOLUD as EfiMemoryMappedIO.
> 
> This fixes assertions seen in PciHostBridgeDxe.
> 
> Signed-off-by: Patrick Rudolph 
> ---
>  .../UefiPayloadEntry/UefiPayloadEntry.c   | 190 +-
>  .../UefiPayloadEntry/UefiPayloadEntry.h   |  10 +
>  2 files changed, 197 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> index 805f5448d9..04c58f776c 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> @@ -7,10 +7,159 @@
> 
> 
>  #include "UefiPayloadEntry.h"
> 
> 
> 
> +STATIC UINT32 mTopOfLowerUsableDram = 0;
> 
> +
> 
>  /**
> 
> Callback function to build resource descriptor HOB
> 
> 
> 
> This function build a HOB based on the memory map entry info.
> 
> +   It creates only EFI_RESOURCE_MEMORY_MAPPED_IO and
> EFI_RESOURCE_MEMORY_RESERVED
> 
> +   resources.
> 
> +
> 
> +   @param MemoryMapEntry Memory map entry info got from
> bootloader.
> 
> +   @param Params A pointer to ACPI_BOARD_INFO.
> 
> +
> 
> +  @retval EFI_SUCCESSSuccessfully build a HOB.
> 
> +  @retval EFI_INVALID_PARAMETER  Invalid parameter provided.
> 
> +**/
> 
> +EFI_STATUS
> 
> +MemInfoCallbackMmio (
> 
> +  IN MEMROY_MAP_ENTRY  *MemoryMapEntry,
> 
> +  IN VOID  *Params
> 
> +  )
> 
> +{
> 
> +  EFI_PHYSICAL_ADDRESS Base;
> 
> +  EFI_RESOURCE_TYPEType;
> 
> +  UINT64   Size;
> 
> +  EFI_RESOURCE_ATTRIBUTE_TYPE  Attribue;
> 
> +  ACPI_BOARD_INFO  *AcpiBoardInfo;
> 
> +
> 
> +  AcpiBoardInfo = (ACPI_BOARD_INFO *)Params;
> 
> +  if (AcpiBoardInfo == NULL) {
> 
> +return EFI_INVALID_PARAMETER;
> 
> +  }
> 
> +
> 
> +  //
> 
> +  // Skip types already handled in MemInfoCallback
> 
> +  //
> 
> +  if (MemoryMapEntry->Type == E820_RAM || MemoryMapEntry->Type ==
> E820_ACPI) {
> 
> +return EFI_SUCCESS;
> 
> +  }
> 
> +
> 
> +  if (MemoryMapEntry->Base == AcpiBoardInfo->PcieBaseAddress) {
> 
> +//
> 
> +// MMCONF is always MMIO
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_MAPPED_IO;
> 
> +  } else if (MemoryMapEntry->Base < mTopOfLowerUsableDram) {
> 
> +//
> 
> +// It's in DRAM and thus must be reserved
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_RESERVED;
> 
> +  } else if ((MemoryMapEntry->Base < 0x1ULL) &&
> (MemoryMapEntry->Base >= mTopOfLowerUsableDram)) {
> 
> +//
> 
> +// It's not in DRAM, must be MMIO
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_MAPPED_IO;
> 
> +  } else {
> 
> +Type = EFI_RESOURCE_MEMORY_RESERVED;
> 
> +  }
> 
> +
> 
> +  Base= MemoryMapEntry->Base;
> 
> +  Size= MemoryMapEntry->Size;
> 
> +
> 
> +  Attribue = EFI_RESOURCE_ATTRIBUTE_PRESENT |
> 
> + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
> 
> + EFI_RESOURCE_ATTRIBUTE_TESTED |
> 
> + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;
> 
> +
> 
> +  BuildResourceDescriptorHob (Type, Attribue,
> (EFI_PHYSICAL_ADDRESS)Base, Size);
> 
> +  DEBUG ((DEBUG_INFO , "buildhob: base = 0x%lx, size = 0x%lx, type =
> 0x%x\n", Base, Size, Type));
> 
> +
> 
> +  if (MemoryMapEntry->Type == E820_UNUSABLE ||
> 
> +MemoryMapEntry->Type == E820_DISABLED) {
> 
> +BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory);
> 
> +  } else if (MemoryMapEntry->Type == E820_PMEM) {
> 
> +BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory);
> 

Re: [edk2-devel] [PATCH] OvmfPkg/Bhyve: clean up TPM_ENABLE remnants

2021-06-22 Thread Laszlo Ersek
On 06/12/21 22:43, Rebecca Cran wrote:
> TPM support hasn't been tested and any lines in the .dsc and .fdf files
> that appear to show support are bogus. Remove them.
> 
> This fixes https://bugzilla.tianocore.org/show_bug.cgi?id=3354 .
> 
> Signed-off-by: Rebecca Cran 
> ---
>  OvmfPkg/Bhyve/BhyveX64.dsc | 64 
>  OvmfPkg/Bhyve/BhyveX64.fdf | 15 -
>  2 files changed, 79 deletions(-)

I'll try to review this patch soon; I'm dealing with the usual post-PTO
email apocalypse.

Thanks,
Laszlo



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




Re: [edk2-devel] [PATCH v3] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader memrange parsing

2021-06-22 Thread Guo Dong


Reviewed-by: Guo Dong 

> -Original Message-
> From: Patrick Rudolph 
> Sent: Monday, June 21, 2021 1:10 AM
> To: devel@edk2.groups.io
> Cc: Ma, Maurice ; Dong, Guo
> ; You, Benjamin 
> Subject: [PATCH v3] UefiPayloadPkg/UefiPayloadEntry: Improve bootloader
> memrange parsing
> 
> Currently several DXE crash due to invalid memory resource settings.
> The PciHostBridgeDxe which expects the MMCONF and PCI Aperature
> to be EfiMemoryMappedIO, but currently those regions are (partly)
> mapped as EfiReservedMemoryType.
> 
> coreboot and slimbootloader provide an e820 compatible memory map,
> which doesn't work well with EDK2 as the e820 spec is missing MMIO regions.
> In e820 'reserved' could either mean "DRAM used by boot firmware" or
> "MMIO
> in use and not detectable by OS".
> 
> Guess Top of lower usable DRAM (TOLUD) by walking the bootloader
> provided
> memory ranges. Memory types of RAM, ACPI and ACPI NVS below 4 GiB are
> used
> to increment TOLUD and reserved memory ranges touching TOLUD at the
> base
> are also assumed to be reserved DRAM, which increment TOLUD.
> 
> Then mark everything reserved below TOLUD as EfiReservedMemoryType
> and
> everything reserved above TOLUD as EfiMemoryMappedIO.
> 
> This fixes assertions seen in PciHostBridgeDxe.
> 
> Signed-off-by: Patrick Rudolph 
> ---
>  .../UefiPayloadEntry/UefiPayloadEntry.c   | 190 +-
>  .../UefiPayloadEntry/UefiPayloadEntry.h   |  10 +
>  2 files changed, 197 insertions(+), 3 deletions(-)
> 
> diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> index 805f5448d9..04c58f776c 100644
> --- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> +++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
> @@ -7,10 +7,159 @@
> 
> 
>  #include "UefiPayloadEntry.h"
> 
> 
> 
> +STATIC UINT32 mTopOfLowerUsableDram = 0;
> 
> +
> 
>  /**
> 
> Callback function to build resource descriptor HOB
> 
> 
> 
> This function build a HOB based on the memory map entry info.
> 
> +   It creates only EFI_RESOURCE_MEMORY_MAPPED_IO and
> EFI_RESOURCE_MEMORY_RESERVED
> 
> +   resources.
> 
> +
> 
> +   @param MemoryMapEntry Memory map entry info got from
> bootloader.
> 
> +   @param Params A pointer to ACPI_BOARD_INFO.
> 
> +
> 
> +  @retval EFI_SUCCESSSuccessfully build a HOB.
> 
> +  @retval EFI_INVALID_PARAMETER  Invalid parameter provided.
> 
> +**/
> 
> +EFI_STATUS
> 
> +MemInfoCallbackMmio (
> 
> +  IN MEMROY_MAP_ENTRY  *MemoryMapEntry,
> 
> +  IN VOID  *Params
> 
> +  )
> 
> +{
> 
> +  EFI_PHYSICAL_ADDRESS Base;
> 
> +  EFI_RESOURCE_TYPEType;
> 
> +  UINT64   Size;
> 
> +  EFI_RESOURCE_ATTRIBUTE_TYPE  Attribue;
> 
> +  ACPI_BOARD_INFO  *AcpiBoardInfo;
> 
> +
> 
> +  AcpiBoardInfo = (ACPI_BOARD_INFO *)Params;
> 
> +  if (AcpiBoardInfo == NULL) {
> 
> +return EFI_INVALID_PARAMETER;
> 
> +  }
> 
> +
> 
> +  //
> 
> +  // Skip types already handled in MemInfoCallback
> 
> +  //
> 
> +  if (MemoryMapEntry->Type == E820_RAM || MemoryMapEntry->Type ==
> E820_ACPI) {
> 
> +return EFI_SUCCESS;
> 
> +  }
> 
> +
> 
> +  if (MemoryMapEntry->Base == AcpiBoardInfo->PcieBaseAddress) {
> 
> +//
> 
> +// MMCONF is always MMIO
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_MAPPED_IO;
> 
> +  } else if (MemoryMapEntry->Base < mTopOfLowerUsableDram) {
> 
> +//
> 
> +// It's in DRAM and thus must be reserved
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_RESERVED;
> 
> +  } else if ((MemoryMapEntry->Base < 0x1ULL) &&
> (MemoryMapEntry->Base >= mTopOfLowerUsableDram)) {
> 
> +//
> 
> +// It's not in DRAM, must be MMIO
> 
> +//
> 
> +Type = EFI_RESOURCE_MEMORY_MAPPED_IO;
> 
> +  } else {
> 
> +Type = EFI_RESOURCE_MEMORY_RESERVED;
> 
> +  }
> 
> +
> 
> +  Base= MemoryMapEntry->Base;
> 
> +  Size= MemoryMapEntry->Size;
> 
> +
> 
> +  Attribue = EFI_RESOURCE_ATTRIBUTE_PRESENT |
> 
> + EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
> 
> + EFI_RESOURCE_ATTRIBUTE_TESTED |
> 
> + EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
> 
> + EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE;
> 
> +
> 
> +  BuildResourceDescriptorHob (Type, Attribue,
> (EFI_PHYSICAL_ADDRESS)Base, Size);
> 
> +  DEBUG ((DEBUG_INFO , "buildhob: base = 0x%lx, size = 0x%lx, type =
> 0x%x\n", Base, Size, Type));
> 
> +
> 
> +  if (MemoryMapEntry->Type == E820_UNUSABLE ||
> 
> +MemoryMapEntry->Type == E820_DISABLED) {
> 
> +BuildMemoryAllocationHob (Base, Size, EfiUnusableMemory);
> 
> +  } else if (MemoryMapEntry->Type == E820_PMEM) {
> 
> +BuildMemoryAllocationHob (Base, Size, EfiPersistentMemory);
> 
> +  }
> 
> +
> 
> +  return EFI_SUCCESS;
> 
> +}
> 
> +
> 
> +
> 
> +/**
> 

Re: [edk2-devel] [PATCH v4 0/4] SEV Live Migration support for OVMF.

2021-06-22 Thread Ashish Kalra via groups.io
Hello Laszlo,

Please see my replies below :

On Tue, Jun 22, 2021 at 07:20:53PM +0200, Laszlo Ersek wrote:
> Hi Ashish,
> 
> (+Dave, +Paolo)
> 
> On 06/21/21 15:56, Ashish Kalra wrote:
> > From: Ashish Kalra 
> > 
> > By default all the SEV guest memory regions are considered encrypted,
> > if a guest changes the encryption attribute of the page (e.g mark a
> > page as decrypted) then notify hypervisor. Hypervisor will need to
> > track the unencrypted pages. The information will be used during
> > guest live migration, guest page migration and guest debugging.
> > 
> > The patch-set adds a new SEV and SEV-ES hypercall abstraction
> > library to support SEV Page encryption/decryption status hypercalls
> > for SEV and SEV-ES guests.
> > 
> > BaseMemEncryptSevLib invokes hypercalls via this new hypercall library.
> > 
> > The patch-set detects if it is running under KVM hypervisor and then
> > checks for SEV live migration feature support via KVM_FEATURE_CPUID,
> > if detected setup a new UEFI enviroment variable to indicate OVMF
> > support for SEV live migration.
> > 
> > A branch containing these patches is available here:
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fashkalra%2Fedk2%2Ftree%2Fsev_live_migration_v4data=04%7C01%7Cashish.kalra%40amd.com%7Ca402470f4cba428feaac08d935a21c79%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792647899814%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=41Jj%2BGNUyEL43UhZgI19iwGcOJcP%2FWg94D8fTopaZxQ%3Dreserved=0
> > 
> > Changes since v3:
> >  - Fix all DSC files under OvmfPkg except X64 to add support for 
> >BaseMemEncryptLib and add NULL instance of BaseMemEncryptLib
> >for 32 bit platforms.
> >  - Add the MemEncryptHypercallLib-related files to Maintainers.txt,
> >in section "OvmfPkg: Confidential Computing".
> >  - Add support for the new KVM_HC_MAP_GPA_RANGE hypercall interface.
> >  - Add patch for SEV live migration support.
> 
> I have absolutely zero context in my mind about this work.
> 
> By v1 / v2 / v3, are you referring to the following patch series (from 
> December 2020):
> 
> - [PATCH v1 0/2] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00081.htmldata=04%7C01%7Cashish.kalra%40amd.com%7Ca402470f4cba428feaac08d935a21c79%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792647899814%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=cVUvWe6VgjR78OAk5LXgBQiKon4Gp%2F62a2hc%2FKwoLw4%3Dreserved=0
> 
> - [PATCH v2 0/3] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00198.htmldata=04%7C01%7Cashish.kalra%40amd.com%7Ca402470f4cba428feaac08d935a21c79%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792647899814%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=IXLGA2ttyxdVoC63HeCkPVNuUMH3u5Vd3U1fc6c8LQc%3Dreserved=0
> 
> - [PATCH v3 0/3] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00202.htmldata=04%7C01%7Cashish.kalra%40amd.com%7Ca402470f4cba428feaac08d935a21c79%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792647899814%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=cOJBqGyM3a7xMbfhbBAh3IEm7IBJFOGu2ReQMSFJ%2BDw%3Dreserved=0
> 

Yes, actually the guest kernel API for SEV live migration was not
decided at the time of the last patch-set submission, hence, i am now
submitting this patch-set as the guest kernel API has been discussed and
closed and the corresponding KVM/kernel patches have been queued now.

And therefore, this is simply not the SEV Page Encryption Bitmap support
anymore, but the SEV live migration support which includes the guest page
encryption status tracking.

> We certainly need a new TianoCore BZ for tracking this feature; I only found 
> the above patch set versions because I have full text search for my complete 
> email traffic on my laptop. Sending v4 after half a year hiatus is like 
> sending it in the next century. :)
> 

Ok. 

As i mentioned above it took such a long time to re-submit the
patch-set because of the guest kernel API discussions taking some
time and getting closed.

> Anyway, where I'm particularly lost is that I (very vaguely) recall 
> conflicting approaches from AMD and IBM on migration. Has an agreement been 
> reached there?
> 

Yes, these are the slow SEV live migration patches. The fast migration
support is being developed by IBM and that is a separate effort. 

As this slow live migration support has now been 

Re: [edk2-devel] [PATCH v4 0/4] SEV Live Migration support for OVMF.

2021-06-22 Thread Brijesh Singh via groups.io
Hi Ashish,

I have queue'd to review this series for later part of the week.
Just curious, did you run CI on this series ? A quick glance hints that this
series may fail to build on some platforms and additionally have formatting
error.

P.S: If you don't know how to use EDK2 CI then buzz me off-list.

thanks

On 6/22/2021 12:20 PM, Laszlo Ersek wrote:
> Hi Ashish,
> 
> (+Dave, +Paolo)
> 
> On 06/21/21 15:56, Ashish Kalra wrote:
>> From: Ashish Kalra 
>>
>> By default all the SEV guest memory regions are considered encrypted,
>> if a guest changes the encryption attribute of the page (e.g mark a
>> page as decrypted) then notify hypervisor. Hypervisor will need to
>> track the unencrypted pages. The information will be used during
>> guest live migration, guest page migration and guest debugging.
>>
>> The patch-set adds a new SEV and SEV-ES hypercall abstraction
>> library to support SEV Page encryption/decryption status hypercalls
>> for SEV and SEV-ES guests.
>>
>> BaseMemEncryptSevLib invokes hypercalls via this new hypercall library.
>>
>> The patch-set detects if it is running under KVM hypervisor and then
>> checks for SEV live migration feature support via KVM_FEATURE_CPUID,
>> if detected setup a new UEFI enviroment variable to indicate OVMF
>> support for SEV live migration.
>>
>> A branch containing these patches is available here:
>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fashkalra%2Fedk2%2Ftree%2Fsev_live_migration_v4data=04%7C01%7Cbrijesh.singh%40amd.com%7Cb6f0cd9ca0cb4203327908d935a21cb3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792656890122%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=zwiAg6jzSPYtUA8UARYE6K39Q3VCJkhm9Ey00aGYC10%3Dreserved=0
>>
>> Changes since v3:
>>  - Fix all DSC files under OvmfPkg except X64 to add support for 
>>BaseMemEncryptLib and add NULL instance of BaseMemEncryptLib
>>for 32 bit platforms.
>>  - Add the MemEncryptHypercallLib-related files to Maintainers.txt,
>>in section "OvmfPkg: Confidential Computing".
>>  - Add support for the new KVM_HC_MAP_GPA_RANGE hypercall interface.
>>  - Add patch for SEV live migration support.
> 
> I have absolutely zero context in my mind about this work.
> 
> By v1 / v2 / v3, are you referring to the following patch series (from 
> December 2020):
> 
> - [PATCH v1 0/2] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00081.htmldata=04%7C01%7Cbrijesh.singh%40amd.com%7Cb6f0cd9ca0cb4203327908d935a21cb3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792656890122%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=QkZUdYyeWREfXyx2%2B32chbp7dMzEVfBb78dEsecduFw%3Dreserved=0
> 
> - [PATCH v2 0/3] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00198.htmldata=04%7C01%7Cbrijesh.singh%40amd.com%7Cb6f0cd9ca0cb4203327908d935a21cb3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792656900118%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=TH%2BbYo%2B2CZyOunhIpegEjqQkdXlBuZsiyWz1k%2BGXtQc%3Dreserved=0
> 
> - [PATCH v3 0/3] SEV Page Encryption Bitmap support for OVMF.
>   
> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flistman.redhat.com%2Farchives%2Fedk2-devel-archive%2F2020-December%2Fmsg00202.htmldata=04%7C01%7Cbrijesh.singh%40amd.com%7Cb6f0cd9ca0cb4203327908d935a21cb3%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637599792656900118%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000sdata=css90wZ%2BFgbYm%2FQjvCLIFZwwozZz3dfzaVPDpsQsCsk%3Dreserved=0
> 
> We certainly need a new TianoCore BZ for tracking this feature; I only found 
> the above patch set versions because I have full text search for my complete 
> email traffic on my laptop. Sending v4 after half a year hiatus is like 
> sending it in the next century. :)
> 
> Anyway, where I'm particularly lost is that I (very vaguely) recall 
> conflicting approaches from AMD and IBM on migration. Has an agreement been 
> reached there?
> 
> I certainly apologize for missing the context here; had someone asked me if I 
> had seen any version of this patch set before, I would have *sworn* that I 
> hadn't.
> 
> I'm basically incapable of tracking this volume of development around 
> confidential computing; sorry.
> 
> Laszlo
> 
>>
>> Changes since v2:
>>  - GHCB_BASE setup during reset-vector as decrypted is marked explicitly
>>in the hypervisor page encryption bitmap after setting the 
>>PcdSevEsIsEnabled PCD.
>>
>> Changes since v1:
>>  - Mark GHCB_BASE setup during reset-vector as decrypted explicitly in
>>the 

Re: [edk2-devel] [PATCH v4 0/4] SEV Live Migration support for OVMF.

2021-06-22 Thread Laszlo Ersek
Hi Ashish,

(+Dave, +Paolo)

On 06/21/21 15:56, Ashish Kalra wrote:
> From: Ashish Kalra 
> 
> By default all the SEV guest memory regions are considered encrypted,
> if a guest changes the encryption attribute of the page (e.g mark a
> page as decrypted) then notify hypervisor. Hypervisor will need to
> track the unencrypted pages. The information will be used during
> guest live migration, guest page migration and guest debugging.
> 
> The patch-set adds a new SEV and SEV-ES hypercall abstraction
> library to support SEV Page encryption/decryption status hypercalls
> for SEV and SEV-ES guests.
> 
> BaseMemEncryptSevLib invokes hypercalls via this new hypercall library.
> 
> The patch-set detects if it is running under KVM hypervisor and then
> checks for SEV live migration feature support via KVM_FEATURE_CPUID,
> if detected setup a new UEFI enviroment variable to indicate OVMF
> support for SEV live migration.
> 
> A branch containing these patches is available here:
> https://github.com/ashkalra/edk2/tree/sev_live_migration_v4
> 
> Changes since v3:
>  - Fix all DSC files under OvmfPkg except X64 to add support for 
>BaseMemEncryptLib and add NULL instance of BaseMemEncryptLib
>for 32 bit platforms.
>  - Add the MemEncryptHypercallLib-related files to Maintainers.txt,
>in section "OvmfPkg: Confidential Computing".
>  - Add support for the new KVM_HC_MAP_GPA_RANGE hypercall interface.
>  - Add patch for SEV live migration support.

I have absolutely zero context in my mind about this work.

By v1 / v2 / v3, are you referring to the following patch series (from December 
2020):

- [PATCH v1 0/2] SEV Page Encryption Bitmap support for OVMF.
  
https://listman.redhat.com/archives/edk2-devel-archive/2020-December/msg00081.html

- [PATCH v2 0/3] SEV Page Encryption Bitmap support for OVMF.
  
https://listman.redhat.com/archives/edk2-devel-archive/2020-December/msg00198.html

- [PATCH v3 0/3] SEV Page Encryption Bitmap support for OVMF.
  
https://listman.redhat.com/archives/edk2-devel-archive/2020-December/msg00202.html

We certainly need a new TianoCore BZ for tracking this feature; I only found 
the above patch set versions because I have full text search for my complete 
email traffic on my laptop. Sending v4 after half a year hiatus is like sending 
it in the next century. :)

Anyway, where I'm particularly lost is that I (very vaguely) recall conflicting 
approaches from AMD and IBM on migration. Has an agreement been reached there?

I certainly apologize for missing the context here; had someone asked me if I 
had seen any version of this patch set before, I would have *sworn* that I 
hadn't.

I'm basically incapable of tracking this volume of development around 
confidential computing; sorry.

Laszlo

> 
> Changes since v2:
>  - GHCB_BASE setup during reset-vector as decrypted is marked explicitly
>in the hypervisor page encryption bitmap after setting the 
>PcdSevEsIsEnabled PCD.
> 
> Changes since v1:
>  - Mark GHCB_BASE setup during reset-vector as decrypted explicitly in
>the hypervisor page encryption bitmap.
>  - Resending the series with correct shallow threading.
> 
> Ashish Kalra (3):
>   OvmfPkg/MemEncryptHypercallLib: add library to support SEV hypercalls.
>   OvmfPkg/PlatformPei: Mark SEC GHCB page as unencrypted via hypercall
>   OvmfPkg/PlatformDxe: Add support for SEV live migration.
> 
> Brijesh Singh (1):
>   OvmfPkg/BaseMemEncryptLib: Support to issue unencrypted hypercall
> 
>  Maintainers.txt   |   2 +
>  OvmfPkg/Include/Guid/MemEncryptLib.h  |  20 
>  .../Include/Library/MemEncryptHypercallLib.h  |  43 +++
>  .../DxeMemEncryptSevLib.inf   |   1 +
>  .../PeiMemEncryptSevLib.inf   |   1 +
>  .../X64/PeiDxeVirtualMemory.c |  22 
>  .../Ia32/MemEncryptHypercallLib.c |  37 ++
>  .../MemEncryptHypercallLib.inf|  42 +++
>  .../X64/AsmHelperStub.nasm|  28 +
>  .../X64/MemEncryptHypercallLib.c  | 105 +
>  OvmfPkg/OvmfPkg.dec   |   1 +
>  OvmfPkg/OvmfPkgIa32.dsc   |   1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc|   1 +
>  OvmfPkg/OvmfPkgX64.dsc|   1 +
>  OvmfPkg/OvmfXen.dsc   |   1 +
>  OvmfPkg/PlatformDxe/AmdSev.c  | 108 ++
>  OvmfPkg/PlatformDxe/Platform.c|   5 +
>  OvmfPkg/PlatformDxe/Platform.inf  |   2 +
>  OvmfPkg/PlatformDxe/PlatformConfig.h  |   5 +
>  OvmfPkg/PlatformPei/AmdSev.c  |  10 ++
>  20 files changed, 436 insertions(+)
>  create mode 100644 OvmfPkg/Include/Guid/MemEncryptLib.h
>  create mode 100644 OvmfPkg/Include/Library/MemEncryptHypercallLib.h
>  create mode 100644 
> OvmfPkg/Library/MemEncryptHypercallLib/Ia32/MemEncryptHypercallLib.c
>  create mode 100644 
> 

Re: [edk2-devel] [PATCH RESEND v1 0/2] ArmVirtPkg: Enable PCIe support for Kvmtool

2021-06-22 Thread Sami Mujawar
Pushed as d9a7612f8d1d..4dda0f7ab44a.

Regards,

Sami Mujawar

On 22/06/2021, 17:49, "devel@edk2.groups.io on behalf of Sami Mujawar via 
groups.io"  
wrote:

Hi Laszlo,


On 22/06/2021, 12:01, "devel@edk2.groups.io on behalf of Laszlo Ersek via 
groups.io"  
wrote:

On 06/21/21 15:43, Alexandru Elisei wrote:
> Hi Pierre,
> 
> On 6/15/21 4:21 PM, PierreGondois via groups.io wrote:
>> From: Pierre Gondois 
>>
>> PCIe support has been added to the Kvmtool virtual machine
>> manager. Therefore, add a PciHostBridgeUtilityLib and enable
>> PCIe support for Kvmtool firmware.
>>
>> The patches were re-send as the devel@edk2.groups.io was not 
included.
>>
>> The patches can be seen at: 
https://github.com/PierreARM/edk2/tree/1413_Enable_ArmVirt_Pci_v1
>> The results of the CI can be seen at: 
https://github.com/tianocore/edk2/pull/1718
> 
> Tested the patches with the latest version of the kvmtool PCI Express 
support [1],
> and everything worked as expected. A summary of the tests that I ran 
can be found
> at [1]. So you can add for the entire series:
> 
> Tested-by: Alexandru Elisei 
> 
> One thing of note is that applying patch #2 of this series on top of 
11b1c1d4b98b
> ("SecurityPkg: TcgStorageOpalLib: Initialize SupportedAttributes 
parameter")
> failed.

If there is a conflict that needs to be resolved, then Pierre, can you
please repost?

Otherwise: Sami, can you please merge the series with Ard's and Alex's 
tags?

[SAMI] I will merge this series shortly.

Regards,

Sami Mujawar

Thanks!
Laszlo


> However, building from your repo went fine, and the binary that I 
used for
> testing was built from your repo.
> 
> [1] 
https://lore.kernel.org/kvm/20210621092128.11313-1-alexandru.eli...@arm.com/
> 
> Thanks,
> 
> Alex
> 
>>
>> Sami Mujawar (2):
>>   ArmVirtPkg: Add PCIe host bridge utility lib for ArmVirtPkg
>>   ArmVirtPkg: Enable PCIe support for Kvmtool
>>
>>  ArmVirtPkg/ArmVirtKvmTool.dsc |  35 ++-
>>  ArmVirtPkg/ArmVirtKvmTool.fdf |  11 +-
>>  .../ArmVirtPciHostBridgeUtilityLib.c  | 219 
++
>>  .../ArmVirtPciHostBridgeUtilityLib.inf|  39 
>>  4 files changed, 301 insertions(+), 3 deletions(-)
>>  create mode 100644 
ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.c
>>  create mode 100644 
ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.inf
>>
> 
> 
> 
> 
> 















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




Re: [edk2-devel] [PATCH RESEND v1 0/2] ArmVirtPkg: Enable PCIe support for Kvmtool

2021-06-22 Thread Sami Mujawar
Hi Laszlo,


On 22/06/2021, 12:01, "devel@edk2.groups.io on behalf of Laszlo Ersek via 
groups.io"  
wrote:

On 06/21/21 15:43, Alexandru Elisei wrote:
> Hi Pierre,
> 
> On 6/15/21 4:21 PM, PierreGondois via groups.io wrote:
>> From: Pierre Gondois 
>>
>> PCIe support has been added to the Kvmtool virtual machine
>> manager. Therefore, add a PciHostBridgeUtilityLib and enable
>> PCIe support for Kvmtool firmware.
>>
>> The patches were re-send as the devel@edk2.groups.io was not included.
>>
>> The patches can be seen at: 
https://github.com/PierreARM/edk2/tree/1413_Enable_ArmVirt_Pci_v1
>> The results of the CI can be seen at: 
https://github.com/tianocore/edk2/pull/1718
> 
> Tested the patches with the latest version of the kvmtool PCI Express 
support [1],
> and everything worked as expected. A summary of the tests that I ran can 
be found
> at [1]. So you can add for the entire series:
> 
> Tested-by: Alexandru Elisei 
> 
> One thing of note is that applying patch #2 of this series on top of 
11b1c1d4b98b
> ("SecurityPkg: TcgStorageOpalLib: Initialize SupportedAttributes 
parameter")
> failed.

If there is a conflict that needs to be resolved, then Pierre, can you
please repost?

Otherwise: Sami, can you please merge the series with Ard's and Alex's tags?

[SAMI] I will merge this series shortly.

Regards,

Sami Mujawar

Thanks!
Laszlo


> However, building from your repo went fine, and the binary that I used for
> testing was built from your repo.
> 
> [1] 
https://lore.kernel.org/kvm/20210621092128.11313-1-alexandru.eli...@arm.com/
> 
> Thanks,
> 
> Alex
> 
>>
>> Sami Mujawar (2):
>>   ArmVirtPkg: Add PCIe host bridge utility lib for ArmVirtPkg
>>   ArmVirtPkg: Enable PCIe support for Kvmtool
>>
>>  ArmVirtPkg/ArmVirtKvmTool.dsc |  35 ++-
>>  ArmVirtPkg/ArmVirtKvmTool.fdf |  11 +-
>>  .../ArmVirtPciHostBridgeUtilityLib.c  | 219 ++
>>  .../ArmVirtPciHostBridgeUtilityLib.inf|  39 
>>  4 files changed, 301 insertions(+), 3 deletions(-)
>>  create mode 100644 
ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.c
>>  create mode 100644 
ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.inf
>>
> 
> 
> 
> 
> 









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




Re: [edk2-devel] [PATCH 4/6] NetworkPkg/IScsiDxe: support multiple hash algorithms for CHAP

2021-06-22 Thread Laszlo Ersek
On 06/11/21 13:54, Rabeda, Maciej wrote:
> Laszlo,
> 
> Comments inline.
> 
> On 08-Jun-21 15:06, Laszlo Ersek wrote:
>> Introduce the "mChapHash" table, containing the hash algorithms supported
>> for CHAP. Hash algos listed at the beginning of the table are
>> preferred by
>> the initiator.
>>
>> In ISCSI_CHAP_STEP_ONE, send such a CHAP_A value that is the
>> comma-separated, ordered list of algorithm identifiers from "mChapHash".
>> Pre-format this value string at driver startup, in the new function
>> IScsiCHAPInitHashList().
>>
>> (In IScsiCHAPInitHashList(), also enforce that every hash algo's digest
>> size fit into ISCSI_CHAP_MAX_DIGEST_SIZE, as the latter controls the
>> digest, outgoing challenge, and hex *allocations*.)
>>
>> In ISCSI_CHAP_STEP_TWO, allow the target to select one of the offered
>> hash
>> algorithms, and remember the selection for the later steps. For
>> ISCSI_CHAP_STEP_THREE, hash the challenge from the target with the
>> selected hash algo.
>>
>> In ISCSI_CHAP_STEP_THREE, send the correctly sized digest to the target.
>> If the initiator wants mutual authentication, then generate a challenge
>> with as many bytes as the target's digest will have, in
>> ISCSI_CHAP_STEP_FOUR.
>>
>> In ISCSI_CHAP_STEP_FOUR (i.e., when mutual authentication is required by
>> the initiator), verify the target's response (digest) with the selected
>> algorithm.
>>
>> Clear the selected hash algorithm before every login (remember that in
>> IScsiDxe, every login is a leading login).
>>
>> There is no peer-observable change from this patch, as it only reworks
>> the
>> current MD5 support into the new internal representation.
>>
>> Cc: Jiaxin Wu 
>> Cc: Maciej Rabeda 
>> Cc: Philippe Mathieu-Daudé 
>> Cc: Siyuan Fu 
>> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3355
>> Signed-off-by: Laszlo Ersek 
>> ---
>>   NetworkPkg/IScsiDxe/IScsiCHAP.h   |  55 +++
>>   NetworkPkg/IScsiDxe/IScsiCHAP.c   | 158 +---
>>   NetworkPkg/IScsiDxe/IScsiDriver.c |   2 +
>>   NetworkPkg/IScsiDxe/IScsiProto.c  |   3 +
>>   4 files changed, 195 insertions(+), 23 deletions(-)
>>
>> diff --git a/NetworkPkg/IScsiDxe/IScsiCHAP.h
>> b/NetworkPkg/IScsiDxe/IScsiCHAP.h
>> index b8811b7580f0..1e5cc0b287ed 100644
>> --- a/NetworkPkg/IScsiDxe/IScsiCHAP.h
>> +++ b/NetworkPkg/IScsiDxe/IScsiCHAP.h
>> @@ -31,47 +31,91 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>>     #define ISCSI_CHAP_STEP_ONE   1
>>   #define ISCSI_CHAP_STEP_TWO   2
>>   #define ISCSI_CHAP_STEP_THREE 3
>>   #define ISCSI_CHAP_STEP_FOUR  4
>>       #pragma pack(1)
>>     typedef struct _ISCSI_CHAP_AUTH_CONFIG_NVDATA {
>>     UINT8 CHAPType;
>>     CHAR8 CHAPName[ISCSI_CHAP_NAME_STORAGE];
>>     CHAR8 CHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
>>     CHAR8 ReverseCHAPName[ISCSI_CHAP_NAME_STORAGE];
>>     CHAR8 ReverseCHAPSecret[ISCSI_CHAP_SECRET_STORAGE];
>>   } ISCSI_CHAP_AUTH_CONFIG_NVDATA;
>>     #pragma pack()
>>   +//
>> +// Typedefs for collecting sets of hash APIs from BaseCryptLib.
>> +//
>> +typedef
>> +UINTN
>> +(EFIAPI *CHAP_HASH_GET_CONTEXT_SIZE) (
>> +  VOID
>> +  );
>> +
>> +typedef
>> +BOOLEAN
>> +(EFIAPI *CHAP_HASH_INIT) (
>> +  OUT VOID *Context
>> +  );
>> +
>> +typedef
>> +BOOLEAN
>> +(EFIAPI *CHAP_HASH_UPDATE) (
>> +  IN OUT VOID   *Context,
>> +  IN CONST VOID *Data,
>> +  IN UINTN  DataSize
>> +  );
>> +
>> +typedef
>> +BOOLEAN
>> +(EFIAPI *CHAP_HASH_FINAL) (
>> +  IN OUT VOID  *Context,
>> +  OUT    UINT8 *HashValue
>> +  );
>> +
>> +typedef struct {
>> +  UINT8  Algorithm;  //
>> ISCSI_CHAP_ALGORITHM_*, CHAP_A
> Any chance to define an enum type for Algorithm? IMHO it brings more
> meaning to that number and limits the set of values it is expected to have.

I picked UINT8 intentionally; I wanted to stay close to the definition at

https://www.iana.org/assignments/ppp-numbers/ppp-numbers.xhtml#ppp-numbers-9

which says, "A one octet field". (Hence the reference to "CHAP_A" in the
comment as well.)

If we want an enum here, then I need to prepend a patch, for first
replacing the existent ISCSI_CHAP_ALGORITHM_MD5 macro with an enum type
/ constant.

I still like UINT8 for this, but if you strongly prefer the enum, I can
certainly do it. Please advise :)


>> +  UINT32 DigestSize;
>> +  CHAP_HASH_GET_CONTEXT_SIZE GetContextSize;
>> +  CHAP_HASH_INIT Init;
>> +  CHAP_HASH_UPDATE   Update;
>> +  CHAP_HASH_FINAL    Final;
>> +} CHAP_HASH;
>> +
>>   ///
>>   /// ISCSI CHAP Authentication Data
>>   ///
>>   typedef struct _ISCSI_CHAP_AUTH_DATA {
>>     ISCSI_CHAP_AUTH_CONFIG_NVDATA *AuthConfig;
>>     UINT32    InIdentifier;
>>     UINT8 InChallenge[1024];
>>     UINT32    InChallengeLength;
>>     //
>> +  // The hash algorithm (CHAP_A) that the target selects in
>> +  // ISCSI_CHAP_STEP_TWO.
>> +  //

Re: [edk2-devel] [PATCH] OvmfPkg/Bhyve: clean up TPM_ENABLE remnants

2021-06-22 Thread Michael D Kinney
Hi Laszlo,

I am trying the following configuration that is very conservative: 

actions:
  queue:
method: rebase
rebase_fallback: none
name: default

The auto rebase only attempts a strict rebase.  If that attempt at a strict 
rebase fails
then it will show that there is a conflict that the developer must take care of.

I believe any combination of 2 PRs that have overlapping diff stat should fail
a strict rebase.  The following link describes the method and rebase_fallback
settings in the queue command.

https://docs.mergify.io/actions/queue/#id2

I would be more concerned if we used a method of merge or a rebase_fallback of 
merge.

Are there examples you can think of where the diff stat overlap and the strict
rebase will succeed?

Another option to consider is to define an additional 'auto-rebase' label that 
is
off by default to enable the auto rebase feature.  By default the PR must be 
synced
with head when submitted.  Only if a maintainer sets the 'auto-rebase' label 
will
an auto-rebase be attempted.  

I also want to make it easy for non-maintainers to submit PRs and get CI test 
results.
So auto rebase may be useful for that use case.  Perhaps the 'auto-rebase' 
label 
can be considered when the 'push' label is also set.

Thanks,

Mike

> -Original Message-
> From: Laszlo Ersek 
> Sent: Tuesday, June 22, 2021 8:17 AM
> To: Kinney, Michael D ; devel@edk2.groups.io; 
> spbro...@outlook.com; a...@kernel.org
> Cc: Peter Grehan ; Ard Biesheuvel 
> ; Justen, Jordan L
> ; Sean Brogan ; Rebecca 
> Cran 
> Subject: Re: [edk2-devel] [PATCH] OvmfPkg/Bhyve: clean up TPM_ENABLE remnants
> 
> On 06/17/21 23:53, Kinney, Michael D wrote:
> > Hi Sean,
> >
> > Mergify had added a queue feature to handle the rebases automatically and 
> > make sure
> > CI passes in the order that the PRs are being applied to the base branch.
> 
> I'm opposed to *unconditional* auto-rebase.
> 
> On one hand, it is indeed unreasonable to require a human to manually
> rebase a "ShellPkg/Application/AcpiViewApp" series just because a series
> for "SecurityPkg/FvReportPei" was merged a bit earlier. In other words,
> merge requests for unrelated modules should not block each other.
> 
> On the other hand, auto-rebase is a bad idea if both series modify at
> least one module in common (especially if both series modify at least
> one *file* in common). In case there is a contextual conflict, even if
> the conflict can be auto-resolved, and even if that resolution
> *compiles*, it has to be reviewed by a human first.
> 
> I regularly use the git-range-diff command for this.
> 
> At Red Hat we've seen obscure bugs due to silent mis-merges (not in edk2
> -- in different packages); such issues are difficult to debug.
> 
> Bisectability helps for sure, but only if the community treats
> bisectability with high priority in the first place. (That is, if every
> contributor builds their patch set at every stage, before submitting it
> for review.)
> 
> Can we restrict the auto-rebase feature to such merge requests whose
> cumulative diffstats do not intersect?
> 
> Thanks,
> Laszlo


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




Re: [edk2-devel] [PATCH v1 0/5] EDK2 Code First: PI Specification: Update EFI_MM_COMMUNICATE_HEADER

2021-06-22 Thread Laszlo Ersek
On 06/18/21 11:37, Marvin Häuser wrote:
> On 16.06.21 22:58, Kun Qin wrote:
>> On 06/16/2021 00:02, Marvin Häuser wrote:

>>> 2) Is it feasible yet with the current set of supported compilers to
>>> support flexible arrays?
>> My impression is that flexible arrays are already supported (as seen
>> in UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkTypes.h).
>> Please correct me if I am wrong.
>>
>> Would you mind letting me know why this is applicable here? We are
>> trying to seek ideas on how to catch developer mistakes caused by this
>> change. So any input is appreciated.
> 
> Huh, interesting. Last time I tried I was told about incompatibilities
> with MSVC, but I know some have been dropped since then (2005 and 2008
> if I recall correctly?), so that'd be great to allow globally.

I too am surprised to see
"UnitTestFrameworkPkg/PrivateInclude/UnitTestFrameworkTypes.h". The
flexible array member is a C99 feature, and I didn't even know that we
disallowed it for the sake of particular VS toolchains -- I thought we
had a more general reason than just "not supported by VS versions X and Y".

The behavior of OFFSET_OF() would be interesting -- the OFFSET_OF()
macro definition for non-gcc / non-clang:

#define OFFSET_OF(TYPE, Field) ((UINTN) &(((TYPE *)0)->Field))

borders on undefined behavior as far as I can tell, so its behavior is
totally up to the compiler. It works thus far okay on Visual Studio, but
I couldn't say if it extended correctly to flexible array members.

Thanks
Laszlo

> I feel
> like if the structure is modified anyway, it should probably get a
> trailing flexible array over the 1-sized hack. What do you think?



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




Re: [edk2-devel] [PATCH] OvmfPkg/Bhyve: clean up TPM_ENABLE remnants

2021-06-22 Thread Laszlo Ersek
On 06/17/21 23:53, Kinney, Michael D wrote:
> Hi Sean,
> 
> Mergify had added a queue feature to handle the rebases automatically and 
> make sure
> CI passes in the order that the PRs are being applied to the base branch.

I'm opposed to *unconditional* auto-rebase.

On one hand, it is indeed unreasonable to require a human to manually
rebase a "ShellPkg/Application/AcpiViewApp" series just because a series
for "SecurityPkg/FvReportPei" was merged a bit earlier. In other words,
merge requests for unrelated modules should not block each other.

On the other hand, auto-rebase is a bad idea if both series modify at
least one module in common (especially if both series modify at least
one *file* in common). In case there is a contextual conflict, even if
the conflict can be auto-resolved, and even if that resolution
*compiles*, it has to be reviewed by a human first.

I regularly use the git-range-diff command for this.

At Red Hat we've seen obscure bugs due to silent mis-merges (not in edk2
-- in different packages); such issues are difficult to debug.

Bisectability helps for sure, but only if the community treats
bisectability with high priority in the first place. (That is, if every
contributor builds their patch set at every stage, before submitting it
for review.)

Can we restrict the auto-rebase feature to such merge requests whose
cumulative diffstats do not intersect?

Thanks,
Laszlo



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




Re: [edk2-devel] [edk2-platforms][PATCH V1 1/4] Silicon/ARM/NeoverseN1Soc: Add mem regions to support multi-chip usecase

2021-06-22 Thread Sami Mujawar

Hi Khasim,

I think this patch needs to be split. Also the commit message and the
code changes look out of place. Can you fix this, please?

From what I can see this patch includes the following changes:

- Fixes the missing function documentation. Thank you for that, but this
should be a separate patch.

- Defines new PCDs and configures the memory map.

Other than that one minor suggestion marked inline as [SAMI].

Regards,

Sami Mujawar


On 02/06/2021 01:46 PM, Khasim Mohammed via groups.io wrote:

This patch adds resource descriptor for multi-chip usecase and
introduces corresponding PCD definitions.

Signed-off-by: Chandni Cherukuri 
Signed-off-by: Khasim Syed Mohammed 
---
  Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec   | 30 
++-
  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf | 28 
---
  Silicon/ARM/NeoverseN1Soc/Include/NeoverseN1Soc.h | 10 +--
  Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c | 18 
++---
  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.c   | 43 
--
  Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLibMem.c| 84 
+---
  6 files changed, 172 insertions(+), 41 deletions(-)

diff --git a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec 
b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
index 54b793a937ff..8789795bbae3 100644
--- a/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
+++ b/Silicon/ARM/NeoverseN1Soc/NeoverseN1Soc.dec
@@ -1,5 +1,7 @@
+## @file
+#  Describes the entire platform configuration.
  #
-#  Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+#  Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.
  #
  #  SPDX-License-Identifier: BSD-2-Clause-Patent
  #
@@ -33,8 +35,8 @@ [PcdsFixedAtBuild]
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMax|17|UINT32|0x0005
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieBusMin|0|UINT32|0x0006
gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoBase|0x0|UINT32|0x0007
-  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoMaxBase|0x00FF|UINT32|0x0008
-  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize|0x0100|UINT32|0x0009
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoMaxBase|0x001|UINT32|0x0008
+  gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoSize|0x02|UINT32|0x0009

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieIoTranslation|0x7520|UINT32|0x000A

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32Base|0x7120|UINT32|0x000B

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio32MaxBase|0x751F|UINT32|0x000C
@@ -44,3 +46,25 @@ [PcdsFixedAtBuild]

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64MaxBase|0x28|UINT64|0x0010

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Size|0x20|UINT64|0x0011

gArmNeoverseN1SocTokenSpaceGuid.PcdPcieMmio64Translation|0x0|UINT64|0x0012
+
+  # CCIX
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusCount|18|UINT32|0x0016
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMax|17|UINT32|0x0017
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixBusMin|0|UINT32|0x0018
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixExpressBaseAddress|0x6800|UINT32|0x0019
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoBase|0x0|UINT32|0x001A
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoMaxBase|0x01|UINT32|0x001B
+  gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoSize|0x02|UINT32|0x001C
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixIoTranslation|0x6D20|UINT32|0x0001D
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Base|0x6920|UINT32|0x001E
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32MaxBase|0x6D1F|UINT32|0x0001F
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Size|0x0400|UINT32|0x0020
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio32Translation|0x0|UINT32|0x0021
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Base|0x29|UINT64|0x0022
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64MaxBase|0x48|UINT64|0x0023
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Size|0x20|UINT64|0x0024
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixMmio64Translation|0x0|UINT64|0x0025
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseAddress|0x6200|UINT32|0x0026
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdCcixRootPortConfigBaseSize|0x1000|UINT32|0x0027
+
+  
gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0x400|UINT64|0x0029
diff --git a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf 
b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
index 166c9e044483..8e2154aadf47 100644
--- a/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
@@ -1,6 +1,7 @@
  ## @file
+#  Platform Library for N1Sdp.
  #
-#  Copyright (c) 2018-2020, ARM Limited. All rights reserved.
+#  Copyright (c) 2018-2021, ARM Limited. All rights reserved.
  #
  # 

Re: [edk2-devel] [PATCH] OvmfPkg/Bhyve: Remove Xen remnants

2021-06-22 Thread Laszlo Ersek
On 06/12/21 23:07, Rebecca Cran wrote:
> Several Xen remnants were left over from adapting the Ovmf code for
> Bhyve. Remove them.
> 
> Signed-off-by: Rebecca Cran 
> ---
>  OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h |  7 ---
>  OvmfPkg/Bhyve/BhyveX64.dsc   |  1 -
>  OvmfPkg/Bhyve/PlatformPei/Platform.h | 17 -
>  3 files changed, 25 deletions(-)
> 
> diff --git a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h 
> b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
> index 994ee2c7cd..87c9bdafba 100644
> --- a/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
> +++ b/OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatform.h
> @@ -18,7 +18,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>  
>  typedef struct {
> @@ -46,12 +45,6 @@ BhyveInstallAcpiTable(
>OUT  UINTN *TableKey
>);
>  
> -EFI_STATUS
> -EFIAPI
> -InstallXenTables (
> -  IN   EFI_ACPI_TABLE_PROTOCOL   *AcpiProtocol
> -  );
> -
>  EFI_STATUS
>  EFIAPI
>  InstallAcpiTables (
> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> index d8792812ab..25420d8261 100644
> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> @@ -219,7 +219,6 @@
>
> S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
>SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
>
> OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
> -  XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
>  
>  
>  !if $(TPM_ENABLE) == TRUE
> diff --git a/OvmfPkg/Bhyve/PlatformPei/Platform.h 
> b/OvmfPkg/Bhyve/PlatformPei/Platform.h
> index 8239ca05ac..e0327202a5 100644
> --- a/OvmfPkg/Bhyve/PlatformPei/Platform.h
> +++ b/OvmfPkg/Bhyve/PlatformPei/Platform.h
> @@ -98,28 +98,11 @@ InstallClearCacheCallback (
>VOID
>);
>  
> -EFI_STATUS
> -InitializeXen (
> -  VOID
> -  );
> -
> -BOOLEAN
> -XenDetect (
> -  VOID
> -  );
> -
>  VOID
>  AmdSevInitialize (
>VOID
>);
>  
> -extern BOOLEAN mXen;
> -
> -VOID
> -XenPublishRamRegions (
> -  VOID
> -  );
> -
>  extern EFI_BOOT_MODE mBootMode;
>  
>  extern BOOLEAN mS3Supported;
> 

(1) If we go for simple "xen" matches in source code, this looks mostly
okay, although I see two comments that could be fixed up additionally, in
- PlatformPei/Platform.c
- SmbiosPlatformDxe/SmbiosPlatformDxe.c

(pathnames relative to OvmfPkg/Bhyve)


(2) I hinted at a larger possible cleanup in commit e43cca74ad02
("OvmfPkg/Bhyve: make "PcdPciDisableBusEnumeration" Fixed-at-Build",
2021-06-04).

If you locate "PcdPciDisableBusEnumeration" instances under
OvmfPkg/Bhyve, and substitute constant TRUE for them, a bunch of already
dead code in OvmfPkg/Bhyve/AcpiPlatformDxe is *shown dead* too, and you
can excise it.

That does not make this patch wrong, of course.

Thanks
Laszlo



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




Re: [edk2-devel] [edk2-platforms][PATCH V1 2/4] Platform/ARM/N1Sdp: Introduce platform DXE driver

2021-06-22 Thread Sami Mujawar

Hi Khasim,

I can see that some changes to the PlatformDxe are in the last patch of
this series.  Do they belong here?

Other than that, please find my response inline marked [SAMI].

Regards,

Sami Mujawar


On 02/06/2021 01:46 PM, Khasim Mohammed via groups.io wrote:

Add an initial platform DXE driver and support for ramdisk devices.

Signed-off-by: Deepak Pandey 
Signed-off-by: Khasim Syed Mohammed 
---
  Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf | 44 +
  Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.c   | 51 

  2 files changed, 95 insertions(+)

diff --git a/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf 
b/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf
new file mode 100644
index ..925bde4063cc
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf
@@ -0,0 +1,44 @@
+## @file
+#  Platform DXE driver for N1Sdp
+#
+#  Copyright (c) 2021, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x0001001B
+  BASE_NAME  = PlatformDxe
+  FILE_GUID  = 11fc8b5a-377d-47a8-aee9-0093d3d3407f
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  ENTRY_POINT= ArmN1SdpEntryPoint
+
+[Sources.common]
+  PlatformDxe.c
+
+[Packages]
+  ArmPkg/ArmPkg.dec
+  ArmPlatformPkg/ArmPlatformPkg.dec
+  EmbeddedPkg/EmbeddedPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  MdePkg/MdePkg.dec
+  Platform/ARM/N1Sdp/N1SdpPlatform.dec
+
+[LibraryClasses]
+  HobLib
+  UefiDriverEntryPoint
+
+[Protocols]
+  gEfiRamDiskProtocolGuid
+
+[FeaturePcd]
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskSupported
+
+[FixedPcd]
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskBase
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskSize
+
+[Depex]
+  gEfiRamDiskProtocolGuid
diff --git a/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.c 
b/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.c
new file mode 100644
index ..e0b89556d40d
--- /dev/null
+++ b/Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.c
@@ -0,0 +1,51 @@
+/** @file
+
+  Copyright (c) 2021, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+#include 
+#include 
+
+/**
+  Entrypoint of Platform Dxe Driver
+
+  @param  ImageHandle[in]   The firmware allocated handle for the EFI 
image.
+  @param  SystemTable[in]   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The entry point is executed successfully.
+**/
+EFI_STATUS
+EFIAPI
+ArmN1SdpEntryPoint (
+  IN EFI_HANDLE ImageHandle,
+  IN EFI_SYSTEM_TABLE   *SystemTable
+  )
+{
+  EFI_STATUS Status;
+  EFI_RAM_DISK_PROTOCOL  *RamDisk;
+  EFI_DEVICE_PATH_PROTOCOL   *DevicePath;
+
+  Status = EFI_UNSUPPORTED;
+  if (FeaturePcdGet (PcdRamDiskSupported)) {
+Status = gBS->LocateProtocol (, NULL, (VOID**) 
);
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: Couldn't find the RAM Disk protocol - %r\n", 
__FUNCTION__, Status));
+  return Status;
+}
+
+Status = RamDisk->Register (
+   (UINTN)PcdGet32(PcdRamDiskBase),
+   (UINTN)PcdGet32(PcdRamDiskSize),

[SAMI] Space needed between PcdGet32 and opening bracket. Please check
at other places in this patch series.

+   ,
+   NULL,
+   );
+if (EFI_ERROR (Status)) {
+  DEBUG ((DEBUG_ERROR, "%a: Failed to register RAM Disk - %r\n", 
__FUNCTION__, Status));
+}
+  }
+  return Status;
+}


IMPORTANT NOTICE: The contents of this email and any attachments are 
confidential and may also be privileged. If you are not the intended recipient, 
please notify the sender immediately and do not disclose the contents to any 
other person, use it for any purpose, or store or copy the information in any 
medium. Thank you.


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




Re: [edk2-devel] [PATCH v1 1/1] ArmPlatformPkg/Scripts: Create add-symbol-file commands from UEFI console

2021-06-22 Thread PierreGondois
Hello,
I tested this patch on the ArmVExpress-FVP-AArch64 platform with DS-5,
Regards,
Pierre


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




Re: [edk2-devel] [edk2-platforms][PATCH V1 3/4] Platform/ARM/N1Sdp: Enable N1Sdp platform specific configurations

2021-06-22 Thread Sami Mujawar

Hi Khasim,

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar


On 02/06/2021 01:47 PM, Khasim Mohammed via groups.io wrote:

This patch updates the fdf file and introduces component
description and configuration files for N1Sdp.

Signed-off-by: Deepak Pandey 
Signed-off-by: Khasim Syed Mohammed 
---
  Platform/ARM/N1Sdp/N1SdpPlatform.dec | 90 
  Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 28 +-
  Platform/ARM/N1Sdp/N1SdpPlatform.fdf | 13 ++-
  3 files changed, 128 insertions(+), 3 deletions(-)

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dec 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
new file mode 100644
index ..4b730d728eaf
--- /dev/null
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
@@ -0,0 +1,90 @@
+## @file
+#  Describes the N1Sdp configuration.
+#
+#  Copyright (c) 2021, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  DEC_SPECIFICATION  = 0x0001001A
+  PACKAGE_NAME   = N1SdpPlatform
+  PACKAGE_GUID   = 29aacb23-61e8-4fe2-8a06-793537cd26e9
+  PACKAGE_VERSION= 0.1
+
+
+#
+# Include Section - list of Include Paths that are provided by this package.
+#   Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+#  BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER 
DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+
+[Includes.common]
+
+[LibraryClasses]
+  ArmPlatformLib|Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
+
+[Guids.common]
+  gArmN1SdpTokenSpaceGuid =  { 0xd8f1624a, 0x98c1, 0x4f64, { 0xa6, 0x41, 0x19, 
0x5e, 0xb5, 0x3b, 0x26, 0x0f } }
+
+[PcdsFixedAtBuild]
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskBase|0x8800|UINT32|0x0001
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskSize|0x1800|UINT32|0x0002
+
+  # External memory
+  gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0|UINT64|0x0029
+
+[PcdsFeatureFlag.common]
+  gArmN1SdpTokenSpaceGuid.PcdRamDiskSupported|FALSE|BOOLEAN|0x0003
+
+[PcdsFixedAtBuild.common]
+  # CoreSight Debug and Trace components
+  # CoreSight ETMs
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm0Base|0x40204|UINT64|0x002D
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm0MaxBase|0x402040FFF|UINT64|0x002E
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm1Base|0x40214|UINT64|0x002F
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm1MaxBase|0x402140FFF|UINT64|0x0030
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm2Base|0x40304|UINT64|0x0031
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm2MaxBase|0x403040FFF|UINT64|0x0032
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm3Base|0x40314|UINT64|0x0033
+  gArmN1SdpTokenSpaceGuid.PcdCsEtm3MaxBase|0x403140FFF|UINT64|0x0034
+
+  # CoreSight TMC (ETRs/ETFs/ETBs)
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf0Base|0x40041|UINT64|0x0035
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf0MaxBase|0x400410FFF|UINT64|0x0036
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf1Base|0x40042|UINT64|0x0037
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf1MaxBase|0x400420FFF|UINT64|0x0038
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf2Base|0x40001|UINT64|0x0039
+  gArmN1SdpTokenSpaceGuid.PcdCsEtf2MaxBase|0x400010FFF|UINT64|0x003A
+  gArmN1SdpTokenSpaceGuid.PcdCsEtrBase|0x40012|UINT64|0x0043
+  gArmN1SdpTokenSpaceGuid.PcdCsEtrMaxBase|0x400120FFF|UINT64|0x0044
+
+  # CoreSight Dynamic Funnel(s)
+  gArmN1SdpTokenSpaceGuid.PcdCsFunnel0Base|0x4000B|UINT64|0x003B
+  gArmN1SdpTokenSpaceGuid.PcdCsFunnel0MaxBase|0x4000B0FFF|UINT64|0x003C
+  gArmN1SdpTokenSpaceGuid.PcdCsFunnel1Base|0x4000A|UINT64|0x003D
+  gArmN1SdpTokenSpaceGuid.PcdCsFunnel1MaxBase|0x4000A0FFF|UINT64|0x003E
+
+  # CoreSight Dynamic Replicator(s)
+  gArmN1SdpTokenSpaceGuid.PcdCsReplicatorBase|0x40011|UINT64|0x003F
+  gArmN1SdpTokenSpaceGuid.PcdCsReplicatorMaxBase|0x400110FFF|UINT64|0x0040
+
+  # CoreSight TPIU
+  gArmN1SdpTokenSpaceGuid.PcdCsTpiuBase|0x40013|UINT64|0x0041
+  gArmN1SdpTokenSpaceGuid.PcdCsTpiuMaxBase|0x400130FFF|UINT64|0x0042
+
+  # CoreSight STM and STM Stimulus
+  gArmN1SdpTokenSpaceGuid.PcdCsStmBase|0x40080|UINT64|0x0045
+  gArmN1SdpTokenSpaceGuid.PcdCsStmMaxBase|0x400800FFF|UINT64|0x0046
+  gArmN1SdpTokenSpaceGuid.PcdCsStmStimulusBase|0x4D00|UINT32|0x0047
+  gArmN1SdpTokenSpaceGuid.PcdCsStmStimulusSize|0x100|UINT32|0x0048
+
+  # CoreSight Components' Size
+  #
+  # Newton TRMs specify the size for these coresight components as 64K.
+  # The actual size is just 4K though 64K is reserved. Access to the
+  # unmapped reserved region results in a DECERR response.
+  #
+  gArmN1SdpTokenSpaceGuid.PcdCsComponentSize|0x1000|UINT32|0x0049
diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc 
b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
index 61e7a909f80d..abfcbe534550 

Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Initialize the fixed previous shadow stack token.

2021-06-22 Thread Laszlo Ersek
On 06/22/21 16:05, Laszlo Ersek wrote:
> On 06/13/21 06:36, Sheng Wei wrote:
>> The fixed previous shadow stack token should be initialized as UINT64.
>>
>> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192

(4) Please open a new BZ ticket for this issue. (It's OK to add the
previous ticket number, 3192, to the "See Also" field of the new ticket,
and to make a new comment on the old ticket as well.)

BZ#3192 was moved to RESOLVED|FIXED state in March, and commit
0930e7ff6428 has been part of two stable tags since; namely
edk2-stable202102 and edk2-stable202105. At this point, BZ#3192 should
no longer be modified; the issue needs to be tracked by a new ticket.

Thanks
Laszlo


>>
>> Signed-off-by: Sheng Wei 
>> Cc: Eric Dong 
>> Cc: Ray Ni 
>> Cc: Laszlo Ersek 
>> Cc: Rahul Kumar 
>> Cc: Jiewen Yao 
>> ---
>>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c 
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
>> index 661c1ba294..ca3f5ff91a 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
>> @@ -202,7 +202,7 @@ InitShadowStack (
>>// Please refer to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64 for 
>> the full stack frame at runtime.
>>//
>>InterruptSsp = (UINT32)((UINTN)ShadowStack + EFI_PAGES_TO_SIZE(1) - 
>> sizeof(UINT64));
>> -  *(UINT32 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof(UINT64) * 4) 
>> | 0x2;
>> +  *(UINT64 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof(UINT64) * 4) 
>> | 0x2;
>>mCetInterruptSsp = InterruptSsp - sizeof(UINT64);
>>  
>>mCetInterruptSspTable = (UINT32)(UINTN)(mSmmInterruptSspTables + 
>> sizeof(UINT64) * 8 * CpuIndex);
>>
> 
> (1) Please add the following line to the commit message:
> 
> Fixes: 0930e7ff64281017762c8c055bab38925944c724
> 
> (2) The subject line is quite confusing; how about:
> 
>   UefiCpuPkg/PiSmmCpuDxeSmm: initialize shadow stack token as UINT64
> 
> (3) Commit 0930e7ff6428 ("UefiCpuPkg/CpuExceptionHandlerLib: Clear CET
> shadow stack token busy bit", 2021-03-02) was reviewed by Jiewen and
> Ray; I'd like to ask them to review this fix as well.
> 
> Thanks
> Laszlo
> 



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




Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Initialize the fixed previous shadow stack token.

2021-06-22 Thread Laszlo Ersek
On 06/13/21 06:36, Sheng Wei wrote:
> The fixed previous shadow stack token should be initialized as UINT64.
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3192
> 
> Signed-off-by: Sheng Wei 
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Cc: Rahul Kumar 
> Cc: Jiewen Yao 
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c 
> b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> index 661c1ba294..ca3f5ff91a 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/SmmFuncsArch.c
> @@ -202,7 +202,7 @@ InitShadowStack (
>// Please refer to UefiCpuPkg/Library/CpuExceptionHandlerLib/X64 for 
> the full stack frame at runtime.
>//
>InterruptSsp = (UINT32)((UINTN)ShadowStack + EFI_PAGES_TO_SIZE(1) - 
> sizeof(UINT64));
> -  *(UINT32 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof(UINT64) * 4) | 
> 0x2;
> +  *(UINT64 *)(UINTN)InterruptSsp = (InterruptSsp - sizeof(UINT64) * 4) | 
> 0x2;
>mCetInterruptSsp = InterruptSsp - sizeof(UINT64);
>  
>mCetInterruptSspTable = (UINT32)(UINTN)(mSmmInterruptSspTables + 
> sizeof(UINT64) * 8 * CpuIndex);
> 

(1) Please add the following line to the commit message:

Fixes: 0930e7ff64281017762c8c055bab38925944c724

(2) The subject line is quite confusing; how about:

  UefiCpuPkg/PiSmmCpuDxeSmm: initialize shadow stack token as UINT64

(3) Commit 0930e7ff6428 ("UefiCpuPkg/CpuExceptionHandlerLib: Clear CET
shadow stack token busy bit", 2021-03-02) was reviewed by Jiewen and
Ray; I'd like to ask them to review this fix as well.

Thanks
Laszlo



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




Re: [edk2-rfc] [edk2-devel] RFC: design review for TDVF in OVMF

2021-06-22 Thread Laszlo Ersek
On 06/22/21 15:34, Laszlo Ersek wrote:
> Hi,
> 
> On 06/11/21 08:37, Xu, Min M wrote:
>> In today's TianoCore Design Meeting we reviewed the Overview Section (from 
>> slide 1 to 20). Thanks much for the valuable feedbacks and comments. The 
>> meeting minutes will be sent out soon.
>>
>> To address the concerns of the *one binary* solution in previous discussion, 
>> we propose 2 Configurations for TDVF to upstream. (slide 6 - 8)
>>
>>
>>
>> Config-A:
>>
>>   *   Merge the *basic* TDVF feature to existing OvmfX64Pkg.dsc. (Align with 
>> existing SEV)
>>   *   Threat model: VMM is NOT out of TCB. (We don't make things worse.)
>>   *   The OvmfX64Pkg.dsc includes SEV/TDX/normal OVMF basic boot capability. 
>> The final binary can run on SEV/TDX/normal OVMF
>>   *   No changes to existing OvmfPkgX64 image layout.
>>   *   No need to add additional security features if they do not exist today
>>   *   No need to remove features if they exist today.
>>   *   RTMR is not supported
>>   *   PEI phase is NOT skipped in either Td or Non-Td
> 
> (so this is "Config-A / Option B", per slide 9 in the v0.9 slide deck)
> 
>>
>>
>>
>> Config-B:
>>
>>   *   Add a standalone IntelTdx.dsc to a TDX specific directory for a *full* 
>> feature TDVF. (Align with existing SEV)
>>   *   Threat model: VMM is out of TCB. (We need necessary change to prevent 
>> attack from VMM)
>>   *   IntelTdx.dsc includes TDX/normal OVMF basic boot capability. The final 
>> binary can run on TDX/normal OVMF
>>   *   It might eventually merge with AmdSev.dsc, but NOT at this point of 
>> time. And we don't know when it will happen. We need sync with AMD in the 
>> community, after both of us think the solutions are mature to merge.
>>   *   Need to add necessary security feature as mandatory requirement, such 
>> as RTMR based Trusted Boot support
>>   *   Need to remove unnecessary attack surfaces, such as network stack.
> 
> After reading the above, and checking slides 6 through 10 of the v0.9
> slide deck:
> 
> - I prefer Config-B (IntelTdx.dsc).

I should clarify: the relevant part of my preference is not that
"IntelTdx.dsc" contain the *complete* TDVF feature set. The relevant
part (for me) is that "OvmfPkgX64.dsc" *not* be over-complicated for the
sake of TDX, even considering only the "basic" TDVF feature set. It's
fine to implement TDX in two stages ("basic" and "complete"); my point
is that even "basic" should not over-complicate "OvmfPkgX64.dsc".

Thanks
Laszlo


> 
> This is in accordance with what I wrote earlier about "OvmfPkgX64.dsc"
> maintainability and regressions.
> 
> Additionally (given that a full-featured TDVF is the ultimate goal), I
> see the advance from "Config-A / option B" to "Config-B" a lot less
> *incremental* than the step from "OvmfPkgX64.dsc" to "AmdSev.dsc" was.
> 
> Put differently, I think that any TDX work targeted at "OvmfPkgX64.dsc"
> is going to prove less useful for the final "IntelTdx.dsc" than how
> reusable SEV work from "OvmfPkgX64.dsc" did for "AmdSev.dsc".
> 
> Put yet differently, I'm concerned that a part of the TDX work for
> "OvmfPkgX64.dsc" might be a waste, with an eye towards the ultimate TDVF
> feature set ("IntelTdx.dsc").
> 
> 
> - I could (very cautiously) live with "Config-A / option B" as the
> initial approach. However, we'de have to be ready to make the full split
> (the switch-over to "IntelTdx.dsc") at *any point* during development,
> in case something turns out to be too intrusive. (And yes, "too
> intrusive" is subjective.)
> 
> By this I mean that any particular patch towards "Config-A / option B"
> could cause me to ask, "please create IntelTdx.dsc now". Note that the
> later we make the switch the more painful it could be (= the more
> invested in "OvmfPkgX64.dsc" we could be, at that point).
> 
> For example, as I stated earlier, "OvmfPkg/AcpiPlatformDxe" is a driver
> where I'd like to see zero changes, for either SEV or TDX. If the TD
> Mailbox location has to be reported to the OS via the MADT, and QEMU
> cannot (or must not) populate that field in the MADT, then a separate,
> TDX-specific edk2 driver should locate the MADT (installed technically
> by "OvmfPkg/AcpiPlatformDxe", earlier), and update the field.
> 
> Thanks,
> Laszlo
> 
>> From: devel@edk2.groups.io  On Behalf Of Min Xu
>> Sent: Friday, June 11, 2021 6:30 AM
>> To: devel@edk2.groups.io; Yao, Jiewen ; 
>> r...@edk2.groups.io
>> Cc: j...@linux.ibm.com; Laszlo Ersek ; Brijesh Singh 
>> ; Tom Lendacky ; 
>> erdemak...@google.com; c...@microsoft.com; bret.barke...@microsoft.com; Jon 
>> Lange ; Karen Noel ; Paolo Bonzini 
>> ; Nathaniel McCallum ; Dr. David 
>> Alan Gilbert ; Ademar de Souza Reis Jr. 
>> 
>> Subject: Re: [edk2-rfc] [edk2-devel] RFC: design review for TDVF in OVMF
>>
>> Hi, All
>> Thanks much for the valuable comments and discussion about the design.
>> We have updated the slides (v0.9) in below link. If some comments or 
>> concerns are not answered/addressed in the new slides, please don't 

Re: [edk2-rfc] [edk2-devel] RFC: design review for TDVF in OVMF

2021-06-22 Thread Laszlo Ersek
Hi,

On 06/11/21 08:37, Xu, Min M wrote:
> In today's TianoCore Design Meeting we reviewed the Overview Section (from 
> slide 1 to 20). Thanks much for the valuable feedbacks and comments. The 
> meeting minutes will be sent out soon.
> 
> To address the concerns of the *one binary* solution in previous discussion, 
> we propose 2 Configurations for TDVF to upstream. (slide 6 - 8)
> 
> 
> 
> Config-A:
> 
>   *   Merge the *basic* TDVF feature to existing OvmfX64Pkg.dsc. (Align with 
> existing SEV)
>   *   Threat model: VMM is NOT out of TCB. (We don't make things worse.)
>   *   The OvmfX64Pkg.dsc includes SEV/TDX/normal OVMF basic boot capability. 
> The final binary can run on SEV/TDX/normal OVMF
>   *   No changes to existing OvmfPkgX64 image layout.
>   *   No need to add additional security features if they do not exist today
>   *   No need to remove features if they exist today.
>   *   RTMR is not supported
>   *   PEI phase is NOT skipped in either Td or Non-Td

(so this is "Config-A / Option B", per slide 9 in the v0.9 slide deck)

> 
> 
> 
> Config-B:
> 
>   *   Add a standalone IntelTdx.dsc to a TDX specific directory for a *full* 
> feature TDVF. (Align with existing SEV)
>   *   Threat model: VMM is out of TCB. (We need necessary change to prevent 
> attack from VMM)
>   *   IntelTdx.dsc includes TDX/normal OVMF basic boot capability. The final 
> binary can run on TDX/normal OVMF
>   *   It might eventually merge with AmdSev.dsc, but NOT at this point of 
> time. And we don't know when it will happen. We need sync with AMD in the 
> community, after both of us think the solutions are mature to merge.
>   *   Need to add necessary security feature as mandatory requirement, such 
> as RTMR based Trusted Boot support
>   *   Need to remove unnecessary attack surfaces, such as network stack.

After reading the above, and checking slides 6 through 10 of the v0.9
slide deck:

- I prefer Config-B (IntelTdx.dsc).

This is in accordance with what I wrote earlier about "OvmfPkgX64.dsc"
maintainability and regressions.

Additionally (given that a full-featured TDVF is the ultimate goal), I
see the advance from "Config-A / option B" to "Config-B" a lot less
*incremental* than the step from "OvmfPkgX64.dsc" to "AmdSev.dsc" was.

Put differently, I think that any TDX work targeted at "OvmfPkgX64.dsc"
is going to prove less useful for the final "IntelTdx.dsc" than how
reusable SEV work from "OvmfPkgX64.dsc" did for "AmdSev.dsc".

Put yet differently, I'm concerned that a part of the TDX work for
"OvmfPkgX64.dsc" might be a waste, with an eye towards the ultimate TDVF
feature set ("IntelTdx.dsc").


- I could (very cautiously) live with "Config-A / option B" as the
initial approach. However, we'de have to be ready to make the full split
(the switch-over to "IntelTdx.dsc") at *any point* during development,
in case something turns out to be too intrusive. (And yes, "too
intrusive" is subjective.)

By this I mean that any particular patch towards "Config-A / option B"
could cause me to ask, "please create IntelTdx.dsc now". Note that the
later we make the switch the more painful it could be (= the more
invested in "OvmfPkgX64.dsc" we could be, at that point).

For example, as I stated earlier, "OvmfPkg/AcpiPlatformDxe" is a driver
where I'd like to see zero changes, for either SEV or TDX. If the TD
Mailbox location has to be reported to the OS via the MADT, and QEMU
cannot (or must not) populate that field in the MADT, then a separate,
TDX-specific edk2 driver should locate the MADT (installed technically
by "OvmfPkg/AcpiPlatformDxe", earlier), and update the field.

Thanks,
Laszlo

> From: devel@edk2.groups.io  On Behalf Of Min Xu
> Sent: Friday, June 11, 2021 6:30 AM
> To: devel@edk2.groups.io; Yao, Jiewen ; 
> r...@edk2.groups.io
> Cc: j...@linux.ibm.com; Laszlo Ersek ; Brijesh Singh 
> ; Tom Lendacky ; 
> erdemak...@google.com; c...@microsoft.com; bret.barke...@microsoft.com; Jon 
> Lange ; Karen Noel ; Paolo Bonzini 
> ; Nathaniel McCallum ; Dr. David 
> Alan Gilbert ; Ademar de Souza Reis Jr. 
> 
> Subject: Re: [edk2-rfc] [edk2-devel] RFC: design review for TDVF in OVMF
> 
> Hi, All
> Thanks much for the valuable comments and discussion about the design.
> We have updated the slides (v0.9) in below link. If some comments or concerns 
> are not answered/addressed in the new slides, please don't hesitate to tell 
> us. We do want to answer/address all the comments/concerns. But to be honest 
> it is a rather complicated one and we appreciate your feedbacks.
> https://edk2.groups.io/g/devel/files/Designs/2021/0611/TDVF_Design_Review%28v0.9%29.pptx
> 
> Thanks much!
> 
> Xu Min
> 
> 
> From: devel@edk2.groups.io 
> mailto:devel@edk2.groups.io>> On Behalf Of Yao, Jiewen
> Sent: Thursday, June 3, 2021 9:51 PM
> To: r...@edk2.groups.io; 
> devel@edk2.groups.io
> Cc: j...@linux.ibm.com; Laszlo 

[edk2-devel] [PATCH edk2-Platform v1 1/1] Hisilicon:Fix header file issues

2021-06-22 Thread wenyi,xie via groups.io
EDK2 has removed header file ArmLibPrivate.h, so need to
use ArmLib.h instead. A new file OemMiscLib.h is added
to EDK2, its name is same with the header file in
Hisilicon\Include and it will being included first. So
some undefined issue occured and need to change the order
of header files.

Cc: Leif Lindholm 
Cc: Ard Biesheuvel 
Signed-off-by: Wenyi Xie 
---
 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf  
|  2 +-
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
|  2 +-
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
|  2 +-
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf 
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf   
|  2 +-
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf  
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h  
| 13 -
 Silicon/Hisilicon/Hi1616/Pptt/Pptt.h   
|  2 +-
 Silicon/Hisilicon/Hi1620/Pptt/Pptt.h   
|  2 +-
 10 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf 
b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
index 1f992024acc2..f1b21ae80f3c 100644
--- a/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
+++ b/Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf
@@ -20,12 +20,12 @@
   EarlyConfigPeimD03.c
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
   ArmPkg/ArmPkg.dec
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
   PeimEntryPoint
diff --git a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
index ab14597d8b75..728b33e85030 100644
--- a/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
+++ b/Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf
@@ -21,11 +21,11 @@
   BoardFeature2PHi1610Strings.uni
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   ArmPkg/ArmPkg.dec
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
diff --git a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
index d471102199ee..8a605b417be8 100644
--- a/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
+++ b/Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf
@@ -21,11 +21,11 @@
   OemMiscLibD05.c
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   ArmPkg/ArmPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
diff --git a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
index 59373a968523..1121550b40c4 100644
--- a/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
+++ b/Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf
@@ -21,12 +21,12 @@
   OemMiscLibD06.c
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   ArmPkg/ArmPkg.dec
   MdeModulePkg/MdeModulePkg.dec
   MdePkg/MdePkg.dec
   Platform/Hisilicon/D06/D06.dec
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
   BaseMemoryLib
diff --git 
a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
 
b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
index 99eea93b7988..2c3c1ff51408 100644
--- 
a/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
+++ 
b/Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf
@@ -21,12 +21,12 @@
   ProcessorSubClass.c
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
 
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  Silicon/Hisilicon/HisiPkg.dec
 
 [LibraryClasses]
   UefiDriverEntryPoint
diff --git a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf 
b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
index 9c795b5fd401..99cc8fc4c14e 100644
--- a/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
+++ b/Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf
@@ -48,11 +48,11 @@
   ./Type09/MiscSystemSlotDesignationFunction.c
 
 [Packages]
+  Silicon/Hisilicon/HisiPkg.dec
   ArmPkg/ArmPkg.dec
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   Silicon/Hisilicon/HisiliconNonOsi.dec
-  

[edk2-devel] [PATCH edk2-Platform v1 0/1] Hisilicon:Fix header file issues

2021-06-22 Thread wenyi,xie via groups.io
Main Changes :
1.Replace ArmLibPrivate.h with ArmLib.h
2.Cahnge order of dec in some inf file since there are same name header files
3.Remove redundant declaration of union PROCESSOR_STATUS_DATA

Wenyi Xie (1):
  Hisilicon:Fix header file issues

 Platform/Hisilicon/D03/EarlyConfigPeim/EarlyConfigPeimD03.inf  
|  2 +-
 Platform/Hisilicon/D03/Library/OemMiscLib2P/OemMiscLib2PHi1610.inf 
|  2 +-
 Platform/Hisilicon/D05/Library/OemMiscLibD05/OemMiscLibD05.inf 
|  2 +-
 Platform/Hisilicon/D06/Library/OemMiscLibD06/OemMiscLibD06.inf 
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClassDxe.inf 
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/SmbiosMiscDxe/SmbiosMiscDxe.inf   
|  2 +-
 Silicon/Hisilicon/Hi1610/Drivers/PcieInit1610/PcieInitDxe.inf  
|  2 +-
 Silicon/Hisilicon/Drivers/Smbios/ProcessorSubClassDxe/ProcessorSubClass.h  
| 13 -
 Silicon/Hisilicon/Hi1616/Pptt/Pptt.h   
|  2 +-
 Silicon/Hisilicon/Hi1620/Pptt/Pptt.h   
|  2 +-
 10 files changed, 9 insertions(+), 22 deletions(-)

-- 
2.20.1.windows.1



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




Re: [edk2-devel] Possibly incorrect size in memory profile structure

2021-06-22 Thread Marvin Häuser
Ahhh, I see it. The size does to describe the data structure that is 
existent at that point in time, but the one that is created by 
MemoryProfileCopyData() later, and the alignment is applied because it 
ends up as a flat structure array. Makes sense, thank you a lot!


Best regards,
Marvin

On 22.06.21 12:20, Zeng, Star wrote:

Not sure I can understand your question correctly. But try best to recall and 
comment since not on it for long time. 

[2], [3] and [4] are all for interior storage management by 
MEMORY_PROFILE_DRIVER_INFO_DATA, MEMORY_PROFILE_DRIVER_INFO_DATA.PdbString 
points to the PDB string.

Exterior storage are managed by ProfileProtocolGetData() and 
MemoryProfileCopyData() from interior storage, 8B alignment are for exterior 
storage, PDB string is at the end of MEMORY_PROFILE_DRIVER_INFO structure.


Thanks,
Star
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Marvin Häuser
Sent: 2021年6月19日 18:56
To: Zeng, Star ; Yao, Jiewen ; 
devel@edk2.groups.io
Subject: [edk2-devel] Possibly incorrect size in memory profile structure

Good day,

I have a question regarding a part of the memory profiling code. Namely this piece of code [1] introduced 
storing the PDB file name among the driver information. This is implement by a string pointer in the 
"MEMORY_PROFILE_DRIVER_INFO_DATA" structure (which embeds the 
"MEMORY_PROFILE_DRIVER_INFO" structure [2]). The length of the embedded 
"MEMORY_PROFILE_DRIVER_INFO" instance is set to the header size plus the 8B-aligned size of the PDB 
name [3], albeit its storage is not used for the PDB file name, and the storage that is used instead is not 
aligned by 8B [4]. Ominously, the interior structure does have a comment that indicates it is (or was) 
supposed to hold the PDB file name at some point [5].

I do not see that concept being used, and instead see the previously described 
way of storage, so I believe the aligned size is a forgotten piece from a 
refactoring. I imagine early on, the interior structure was supposed to hold 
the PDB name, and the alignment was needed to satisfy the following data's 
requirements. However, the change to the exterior storage should make this 
superfluous, and the specified size seems to be incorrect in all cases.

Can you please give this a quick look and help me determine whether this is a 
bug? Thank you for your time!

Best regards,
Marvin

[1]
https://github.com/tianocore/edk2/commit/1d60fe96422206d37e1d74198bb11b2cf6195157#diff-b42ade68f10fa42dfa25570f0f9a165db4b974877c98d8845e384a40252ec220R407-R428

[2]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L25

[3]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L417

[4]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L404

[5]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Include/Guid/MemoryProfile.h#L59









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




Re: [edk2-devel] [PATCH v3 2/8] Platforms: add SecureBootVariableLib class resolution

2021-06-22 Thread Grzegorz Bernacki
Hi Laszlo,

I think I revert all the changes in all these files. I modified them
because I moved CreateTimeBasedPayload() to SecureBootVariableLib
library, but it created incorrect dependency on SecurityPkg from
MdeModulePkg. Anyway it needs another solution please check
https://edk2.groups.io/g/devel/message/76800 for details.
thanks,
greg

wt., 22 cze 2021 o 13:11 Laszlo Ersek  napisał(a):
>
> Hi Grzegorz,
>
> On 06/14/21 11:43, Grzegorz Bernacki wrote:
> > Update platform files to add  SecureBootVariableLib for each
> > platform which uses SecureBootConfigDxe.
> >
> > Signed-off-by: Grzegorz Bernacki 
> > ---
> >  ArmVirtPkg/ArmVirtQemu.dsc   | 3 +++
> >  ArmVirtPkg/ArmVirtQemuKernel.dsc | 3 +++
> >  EmulatorPkg/EmulatorPkg.dsc  | 1 +
> >  OvmfPkg/Bhyve/BhyveX64.dsc   | 1 +
> >  OvmfPkg/OvmfPkgIa32.dsc  | 1 +
> >  OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
> >  OvmfPkg/OvmfPkgX64.dsc   | 1 +
> >  7 files changed, 11 insertions(+)
>
> please split this patch in three (one patch per package), and assign
> according subject lines to those patches as well.
>
> I had some difficulties determining what I should look at in this patch
> set at all (the subject in particular is unhelpful).
>
> Thanks,
> Laszlo
>
>
> >
> > diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> > index 7ef5e7297b..c9cb0ff4ae 100644
> > --- a/ArmVirtPkg/ArmVirtQemu.dsc
> > +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> > @@ -82,6 +82,9 @@
> >
> > PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
> >
> > PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
> >
> > +!if $(SECURE_BOOT_ENABLE) == TRUE
> > +  
> > SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> > +!endif
> >  !if $(TPM2_ENABLE) == TRUE
> >Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
> >
> > Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
> > diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc 
> > b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > index a542fcb157..97b36e895e 100644
> > --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> > @@ -81,6 +81,9 @@
> >
> > PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
> >
> > TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
> >
> > +!if $(SECURE_BOOT_ENABLE) == TRUE
> > +  
> > SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> > +!endif
> >  [LibraryClasses.common.DXE_DRIVER]
> >
> > ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >
> > diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
> > index 20e5468398..966cc7af01 100644
> > --- a/EmulatorPkg/EmulatorPkg.dsc
> > +++ b/EmulatorPkg/EmulatorPkg.dsc
> > @@ -132,6 +132,7 @@
> >OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> >
> > PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
> >AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> > +  
> > SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> >  !else
> >
> > AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> >  !endif
> > diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> > index d8792812ab..f9c8131309 100644
> > --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> > +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> > @@ -198,6 +198,7 @@
> >  !if $(SECURE_BOOT_ENABLE) == TRUE
> >
> > PlatformSecureLib|OvmfPkg/Bhyve/Library/PlatformSecureLib/PlatformSecureLib.inf
> >AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> > +  
> > SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> >  !else
> >
> > AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> >  !endif
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index f53efeae79..9225966541 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -204,6 +204,7 @@
> >  !if $(SECURE_BOOT_ENABLE) == TRUE
> >PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
> >AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> > +  
> > SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> >  !else
> >
> > AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> >  !endif
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index b3662e17f2..5d53327edb 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -208,6 +208,7 @@
> >  !if $(SECURE_BOOT_ENABLE) == TRUE
> >

Re: [edk2-devel] [PATCH 1/1] MdeModulePkg: Add BootDiscoveryPolicyUiLib.

2021-06-22 Thread Wu, Hao A
> -Original Message-
> From: Grzegorz Bernacki 
> Sent: Tuesday, June 22, 2021 4:52 PM
> To: devel@edk2.groups.io
> Cc: l...@nuviainc.com; ardb+tianoc...@kernel.org; Samer.El-Haj-
> mahm...@arm.com; sunny.w...@arm.com; m...@semihalf.com;
> upstr...@semihalf.com; p...@akeo.ie; Wang, Jian J ;
> Wu, Hao A ; Bi, Dandan ; Dong,
> Eric ; Grzegorz Bernacki 
> Subject: [PATCH 1/1] MdeModulePkg: Add BootDiscoveryPolicyUiLib.
> 
> This library extends Boot Maintenance Menu and allows to select Boot
> Discovery Policy. When choice is made BootDiscoveryPolicy variable is set.
> Platform code can use this variable to decide which class of device shall be
> connected.


(Adding Ray and Zhichao)

Hello Ray and Zhichao,

Could you help to review this patch? Thanks in advance.

Best Regards,
Hao Wu


> 
> Signed-off-by: Grzegorz Bernacki 
> ---
>  MdeModulePkg/MdeModulePkg.dec
>  |   6 +
>  MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
> |  52 +++
>  MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h  
>  |  22
> +++
>  MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c
> | 160 
> 
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni
> |  18 +++
> 
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStri
> ngs.uni |  29 
> 
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.
> Vfr |  44 ++
>  7 files changed, 331 insertions(+)
>  create mode 100644
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
>  create mode 100644 MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
>  create mode 100644
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c
>  create mode 100644
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni
>  create mode 100644
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStri
> ngs.uni
>  create mode 100644
> MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.
> Vfr
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dec
> b/MdeModulePkg/MdeModulePkg.dec index 10602a8f79..1e65ad2dd7 100644
> --- a/MdeModulePkg/MdeModulePkg.dec
> +++ b/MdeModulePkg/MdeModulePkg.dec
> @@ -422,6 +422,9 @@
>## Include/UniversalPayload/ExtraData.h
>gUniversalPayloadExtraDataGuid = {0x15a5baf6, 0x1c91, 0x467d, {0x9d, 0xfb,
> 0x31, 0x9d, 0x17, 0x8d, 0x4b, 0xb4}}
> 
> +  ## GUID used for Boot Discovery Policy FormSet guid and related variables.
> +  gBootDiscoveryPolicyMgrFormsetGuid = { 0x5b6f7107, 0xbb3c, 0x4660, {
> + 0x92, 0xcd, 0x54, 0x26, 0x90, 0x28, 0x0b, 0xbd } }
> +
>  [Ppis]
>## Include/Ppi/AtaController.h
>gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 
> 0x7a,
> 0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
> @@ -1597,6 +1600,9 @@
># @Prompt Console Output Row of Text Setup
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x4
> 00e
> 
> +  ## Specify the Boot Discovery Policy settings
> +
> gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy|0|UINT32|0x4000
> 0
> + 00f
> +
>  [PcdsFixedAtBuild.AARCH64, PcdsPatchableInModule.AARCH64]
> 
> gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20|UINT3
> 2|0x0001004c
> 
> diff --git
> a/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.i
> nf
> b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.i
> nf
> new file mode 100644
> index 00..1fb4d43caa
> --- /dev/null
> +++ b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyU
> +++ iLib.inf
> @@ -0,0 +1,52 @@
> +## @file
> +#  Library for BDS phase to use Boot Discovery Policy # #  Copyright
> +(c) 2021, ARM Ltd. All rights reserved. #  Copyright (c) 2021,
> +Semihalf All rights reserved. #  SPDX-License-Identifier:
> +BSD-2-Clause-Patent # ##
> +
> +[Defines]
> +  INF_VERSION= 0x00010005
> +  BASE_NAME  = BootDiscoveryPolicyUiLib
> +  MODULE_UNI_FILE= BootDiscoveryPolicyUiLib.uni
> +  FILE_GUID  = BE73105A-B13D-4B57-A41A-463DBD15FE10
> +  MODULE_TYPE= DXE_DRIVER
> +  VERSION_STRING = 1.0
> +  LIBRARY_CLASS  = NULL|DXE_DRIVER UEFI_APPLICATION
> +  CONSTRUCTOR= BootDiscoveryPolicyUiLibConstructor
> +  DESTRUCTOR = BootDiscoveryPolicyUiLibDestructor
> +#
> +# The following information is for reference only and not required by the 
> build
> tools.
> +#
> +#  VALID_ARCHITECTURES   = IA32 X64 AARCH64
> +#
> +
> +[Sources]
> +  BootDiscoveryPolicyUiLib.c
> +  BootDiscoveryPolicyUiLibStrings.uni
> +  BootDiscoveryPolicyUiLibVfr.Vfr
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  DevicePathLib
> +  BaseLib
> +  

Re: [edk2-devel] [PATCH v3 2/8] Platforms: add SecureBootVariableLib class resolution

2021-06-22 Thread Laszlo Ersek
Hi Grzegorz,

On 06/14/21 11:43, Grzegorz Bernacki wrote:
> Update platform files to add  SecureBootVariableLib for each
> platform which uses SecureBootConfigDxe.
> 
> Signed-off-by: Grzegorz Bernacki 
> ---
>  ArmVirtPkg/ArmVirtQemu.dsc   | 3 +++
>  ArmVirtPkg/ArmVirtQemuKernel.dsc | 3 +++
>  EmulatorPkg/EmulatorPkg.dsc  | 1 +
>  OvmfPkg/Bhyve/BhyveX64.dsc   | 1 +
>  OvmfPkg/OvmfPkgIa32.dsc  | 1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc   | 1 +
>  OvmfPkg/OvmfPkgX64.dsc   | 1 +
>  7 files changed, 11 insertions(+)

please split this patch in three (one patch per package), and assign
according subject lines to those patches as well.

I had some difficulties determining what I should look at in this patch
set at all (the subject in particular is unhelpful).

Thanks,
Laszlo


> 
> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> index 7ef5e7297b..c9cb0ff4ae 100644
> --- a/ArmVirtPkg/ArmVirtQemu.dsc
> +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> @@ -82,6 +82,9 @@
>
> PciHostBridgeLib|ArmVirtPkg/Library/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
>
> PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
>  
> +!if $(SECURE_BOOT_ENABLE) == TRUE
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> +!endif
>  !if $(TPM2_ENABLE) == TRUE
>Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
>
> Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
> diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc 
> b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> index a542fcb157..97b36e895e 100644
> --- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
> +++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
> @@ -81,6 +81,9 @@
>
> PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
>
> TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
>  
> +!if $(SECURE_BOOT_ENABLE) == TRUE
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
> +!endif
>  [LibraryClasses.common.DXE_DRIVER]
>
> ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>  
> diff --git a/EmulatorPkg/EmulatorPkg.dsc b/EmulatorPkg/EmulatorPkg.dsc
> index 20e5468398..966cc7af01 100644
> --- a/EmulatorPkg/EmulatorPkg.dsc
> +++ b/EmulatorPkg/EmulatorPkg.dsc
> @@ -132,6 +132,7 @@
>OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
>
> PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecureLibNull.inf
>AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
>  !else
>
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
>  !endif
> diff --git a/OvmfPkg/Bhyve/BhyveX64.dsc b/OvmfPkg/Bhyve/BhyveX64.dsc
> index d8792812ab..f9c8131309 100644
> --- a/OvmfPkg/Bhyve/BhyveX64.dsc
> +++ b/OvmfPkg/Bhyve/BhyveX64.dsc
> @@ -198,6 +198,7 @@
>  !if $(SECURE_BOOT_ENABLE) == TRUE
>
> PlatformSecureLib|OvmfPkg/Bhyve/Library/PlatformSecureLib/PlatformSecureLib.inf
>AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
>  !else
>
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
>  !endif
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index f53efeae79..9225966541 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -204,6 +204,7 @@
>  !if $(SECURE_BOOT_ENABLE) == TRUE
>PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
>AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
>  !else
>
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
>  !endif
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index b3662e17f2..5d53327edb 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -208,6 +208,7 @@
>  !if $(SECURE_BOOT_ENABLE) == TRUE
>PlatformSecureLib|OvmfPkg/Library/PlatformSecureLib/PlatformSecureLib.inf
>AuthVariableLib|SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf
> +  
> SecureBootVariableLib|SecurityPkg/Library/SecureBootVariableLib/SecureBootVariableLib.inf
>  !else
>
> AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
>  !endif
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 0a237a9058..509acf7926 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -208,6 +208,7 @@
>  !if $(SECURE_BOOT_ENABLE) == TRUE
>

Re: [edk2-devel] [PATCH RESEND v1 0/2] ArmVirtPkg: Enable PCIe support for Kvmtool

2021-06-22 Thread Laszlo Ersek
On 06/21/21 15:43, Alexandru Elisei wrote:
> Hi Pierre,
> 
> On 6/15/21 4:21 PM, PierreGondois via groups.io wrote:
>> From: Pierre Gondois 
>>
>> PCIe support has been added to the Kvmtool virtual machine
>> manager. Therefore, add a PciHostBridgeUtilityLib and enable
>> PCIe support for Kvmtool firmware.
>>
>> The patches were re-send as the devel@edk2.groups.io was not included.
>>
>> The patches can be seen at: 
>> https://github.com/PierreARM/edk2/tree/1413_Enable_ArmVirt_Pci_v1
>> The results of the CI can be seen at: 
>> https://github.com/tianocore/edk2/pull/1718
> 
> Tested the patches with the latest version of the kvmtool PCI Express support 
> [1],
> and everything worked as expected. A summary of the tests that I ran can be 
> found
> at [1]. So you can add for the entire series:
> 
> Tested-by: Alexandru Elisei 
> 
> One thing of note is that applying patch #2 of this series on top of 
> 11b1c1d4b98b
> ("SecurityPkg: TcgStorageOpalLib: Initialize SupportedAttributes parameter")
> failed.

If there is a conflict that needs to be resolved, then Pierre, can you
please repost?

Otherwise: Sami, can you please merge the series with Ard's and Alex's tags?

Thanks!
Laszlo


> However, building from your repo went fine, and the binary that I used for
> testing was built from your repo.
> 
> [1] 
> https://lore.kernel.org/kvm/20210621092128.11313-1-alexandru.eli...@arm.com/
> 
> Thanks,
> 
> Alex
> 
>>
>> Sami Mujawar (2):
>>   ArmVirtPkg: Add PCIe host bridge utility lib for ArmVirtPkg
>>   ArmVirtPkg: Enable PCIe support for Kvmtool
>>
>>  ArmVirtPkg/ArmVirtKvmTool.dsc |  35 ++-
>>  ArmVirtPkg/ArmVirtKvmTool.fdf |  11 +-
>>  .../ArmVirtPciHostBridgeUtilityLib.c  | 219 ++
>>  .../ArmVirtPciHostBridgeUtilityLib.inf|  39 
>>  4 files changed, 301 insertions(+), 3 deletions(-)
>>  create mode 100644 
>> ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.c
>>  create mode 100644 
>> ArmVirtPkg/Library/ArmVirtPciHostBridgeUtilityLib/ArmVirtPciHostBridgeUtilityLib.inf
>>
> 
> 
> 
> 
> 



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




[edk2-devel] Need help with CI/CD failure for the PR

2021-06-22 Thread Sunil V L
Hi,

The PR https://github.com/tianocore/edk2/pull/1738 has hit error with below 
message.

"PR can not be merged due to a Windows VS2019 failure. Please resolve and 
resubmit"

Unfortunately, I am unable to gather any details why it is failing. Also, I 
don't have VS2019 build environment to try the build myself. Could some one 
with VS2019 or knowledge of this build environment help me what exactly is the 
issue with my patch?

Thanks in advance!

Sunil



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




Re: [edk2-devel] [PATCH v1 3/4] ArmPkg: SpellCheck: Update valid acronyms in ExtendedWords

2021-06-22 Thread Laszlo Ersek
Hi,

On 06/12/21 05:44, Kun Qin wrote:
> From: Sean Brogan 
> 
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3445
> 
> Spellcheck was not covering all specified files due to CSpell v5 and
> Node v10 incompatibility of current CI pipeline configuration.
> 
> This change updates ExtendedWords for ArmPkg with valid acronyms to avoid
> potential spell errors.
> 
> Cc: Laszlo Ersek 
> Cc: Ard Biesheuvel 
> Cc: Leif Lindholm 
> Cc: Sami Mujawar 
> 
> Signed-off-by: Kun Qin 
> Signed-off-by: Sean Brogan 
> ---
>  ArmPkg/ArmPkg.ci.yaml | 19 +++
>  1 file changed, 19 insertions(+)

I'm not an ArmPkg reviewer, so I'm not sure about the Cc.

That said, the patch seems sensible and I guess the sorting should be
OK; the actual mnemonics should be checked by others however :)

Acked-by: Laszlo Ersek 

Thanks
Laszlo

> 
> diff --git a/ArmPkg/ArmPkg.ci.yaml b/ArmPkg/ArmPkg.ci.yaml
> index d91c03f2acb8..a0d6a75fe881 100644
> --- a/ArmPkg/ArmPkg.ci.yaml
> +++ b/ArmPkg/ArmPkg.ci.yaml
> @@ -94,13 +94,18 @@
>"ackintid",
>"actlr",
>"aeabi",
> +  "asedis",
>"ashldi",
>"ashrdi",
> +  "baddr",
>"ccidx",
>"ccsidr",
>"clidr",
>"clrex",
>"clzsi",
> +  "cnthctl",
> +  "cortexa",
> +  "cpacr",
>"cpuactlr",
>"csselr",
>"ctzsi",
> @@ -116,6 +121,7 @@
>"divdi",
>"divsi",
>"dmdepkg",
> +  "dpref",
>"drsub",
>"fcmpeq",
>"fcmpge",
> @@ -125,17 +131,25 @@
>"ffreestanding",
>"frsub",
>"hisilicon",
> +  "iccabpr",
>"iccbpr",
>"icciar",
>"iccicr",
>"icciidr",
> +  "iccpir",
>"iccpmr",
> +  "iccrpr",
> +  "icdabr",
>"icdicer",
>"icdicfr",
> +  "icdicpr",
>"icdictr",
> +  "icdiidr",
>"icdiser",
>"icdisr",
> +  "icdppisr",
>"icdsgir",
> +  "icdspr",
>"icenabler",
>"intid",
>"ipriority",
> @@ -160,6 +174,7 @@
>"lshrdi",
>"moddi",
>"modsi",
> +  "mpcore",
>"mpidr",
>"muldi",
>"mullu",
> @@ -168,6 +183,9 @@
>"nsasedis",
>"nuvia",
>"oldit",
> +  "pcten",
> +  "plpis",
> +  "procno",
>"readc",
>"revsh",
>"rfedb",
> @@ -189,6 +207,7 @@
>"smmlsr",
>"sourcery",
>"srsdb",
> +  "ssacr",
>"stmdb",
>"stmia",
>"strbt",
> 



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




Re: [edk2-devel] [PUBLIC edk2 PATCH v2 01/10] NetworkPkg/IScsiDxe: wrap IScsiCHAP source files to 80 characters

2021-06-22 Thread Laszlo Ersek
On 06/11/21 13:39, Rabeda, Maciej wrote:
> I second Ray on the question!
> I can only assume it is vi without syntax coloring... :)
>
> On 11-Jun-21 13:37, Ni, Ray wrote:
>> No objection on the patch. Just curious what editor you are using :)

I'll quote myself from [1]:

"""
[...] my eyesight isn't the greatest, I totally depend on two code
windows being shown side by side, and I *also* can't work with multiple
monitors (I've tried it, I just can't). So... one monitor, mid-size
fonts, two columns of text --> 80 chars per column.
"""

If lines are longer than 80 characters, I either can't place two source
code windows side by side, or I must shrink the font so much that I
can't read it comfortably.

It's also not helped by a larger monitor: I use 22" and 24" regularly
(for different things), and 24" is already my limit. I wouldn't be
helped by 27" or wider -- that's about the same situation as two
monitors. I just can't work efficiently if I need to turn my head
constantly, whenever my gaze shifts. The whole point of having two
source code windows side by side is to compare two code snippets or even
*two patches*, with as few and as non-intrusive saccades as possible.

In a way, it's about making context switches cheap, and my eyesight is a
limiting factor.

Thanks,
Laszlo

[1] https://edk2.groups.io/g/devel/message/74657
2232673b-69db-43ca-7c93-347b3d4fa62f@redhat.com">http://mid.mail-archive.com/2232673b-69db-43ca-7c93-347b3d4fa62f@redhat.com



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




Re: [edk2-devel] Possibly incorrect size in memory profile structure

2021-06-22 Thread Zeng, Star
Not sure I can understand your question correctly. But try best to recall and 
comment since not on it for long time. 

[2], [3] and [4] are all for interior storage management by 
MEMORY_PROFILE_DRIVER_INFO_DATA, MEMORY_PROFILE_DRIVER_INFO_DATA.PdbString 
points to the PDB string.

Exterior storage are managed by ProfileProtocolGetData() and 
MemoryProfileCopyData() from interior storage, 8B alignment are for exterior 
storage, PDB string is at the end of MEMORY_PROFILE_DRIVER_INFO structure.


Thanks,
Star
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Marvin Häuser
Sent: 2021年6月19日 18:56
To: Zeng, Star ; Yao, Jiewen ; 
devel@edk2.groups.io
Subject: [edk2-devel] Possibly incorrect size in memory profile structure

Good day,

I have a question regarding a part of the memory profiling code. Namely this 
piece of code [1] introduced storing the PDB file name among the driver 
information. This is implement by a string pointer in the 
"MEMORY_PROFILE_DRIVER_INFO_DATA" structure (which embeds the 
"MEMORY_PROFILE_DRIVER_INFO" structure [2]). The length of the embedded 
"MEMORY_PROFILE_DRIVER_INFO" instance is set to the header size plus the 
8B-aligned size of the PDB name [3], albeit its storage is not used for the PDB 
file name, and the storage that is used instead is not aligned by 8B [4]. 
Ominously, the interior structure does have a comment that indicates it is (or 
was) supposed to hold the PDB file name at some point [5].

I do not see that concept being used, and instead see the previously described 
way of storage, so I believe the aligned size is a forgotten piece from a 
refactoring. I imagine early on, the interior structure was supposed to hold 
the PDB name, and the alignment was needed to satisfy the following data's 
requirements. However, the change to the exterior storage should make this 
superfluous, and the specified size seems to be incorrect in all cases.

Can you please give this a quick look and help me determine whether this is a 
bug? Thank you for your time!

Best regards,
Marvin

[1]
https://github.com/tianocore/edk2/commit/1d60fe96422206d37e1d74198bb11b2cf6195157#diff-b42ade68f10fa42dfa25570f0f9a165db4b974877c98d8845e384a40252ec220R407-R428

[2]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L25

[3]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L417

[4]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Core/Dxe/Mem/MemoryProfileRecord.c#L404

[5]
https://github.com/tianocore/edk2/blob/a63914d3f603580e5aeceb5edbafe56688210141/MdeModulePkg/Include/Guid/MemoryProfile.h#L59







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




Re: [edk2-devel] [PATCH] BaseTools: Fix spelling of "overwrite" and "overwriting" in toolset.bat

2021-06-22 Thread Philippe Mathieu-Daudé
On 6/13/21 5:56 AM, Rebecca Cran wrote:
> The words "overwrite" and "overwriting" are one word and shouldn't have
> hyphens.
> 
> Signed-off-by: Rebecca Cran 
> ---
>  BaseTools/toolsetup.bat | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daude 



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




[edk2-devel] [edk2-platforms PATCH 1/2] Platform/RaspberryPi: Enable Boot Discovery Policy.

2021-06-22 Thread Grzegorz Bernacki
This commit modify platform boot to check the value of
BootDiscoveryPolicy variable and use BootPolicyManager
Protocol to connect devices specified by the variable.

Signed-off-by: Grzegorz Bernacki 
---
 Platform/RaspberryPi/RPi4/RPi4.dsc 
|  3 +
 Platform/RaspberryPi/RPi4/RPi4.fdf 
|  1 +
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
|  4 +
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c   
| 85 
 4 files changed, 93 insertions(+)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index fd73c4d14b..8b9beac64a 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -555,6 +555,7 @@
   
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutColumn|L"Columns"|gRaspberryPiTokenSpaceGuid|0x0|80
   
gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|L"Rows"|gRaspberryPiTokenSpaceGuid|0x0|25
   
gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow|L"Rows"|gRaspberryPiTokenSpaceGuid|0x0|25
+  
gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy|L"BootDiscoveryPolicy"|gBootDiscoveryPolicyMgrFormsetGuid|0
 
 [PcdsDynamicDefault.common]
   #
@@ -682,6 +683,7 @@
   #
   # Bds
   #
+  MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.inf
   MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
   MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
@@ -690,6 +692,7 @@
   Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf
   MdeModulePkg/Application/UiApp/UiApp.inf {
 
+  
NULL|MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
   NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
   NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
   NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.inf
diff --git a/Platform/RaspberryPi/RPi4/RPi4.fdf 
b/Platform/RaspberryPi/RPi4/RPi4.fdf
index 1e13909a57..371197a93e 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.fdf
+++ b/Platform/RaspberryPi/RPi4/RPi4.fdf
@@ -253,6 +253,7 @@ READ_LOCK_STATUS   = TRUE
   #
   # Bds
   #
+  INF MdeModulePkg/Universal/BootManagerPolicyDxe/BootManagerPolicyDxe.inf
   INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf
   INF MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
   INF MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
diff --git 
a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 
b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index fbf510ab96..f8ca4bbf10 100644
--- 
a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ 
b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -66,6 +66,7 @@
   gRaspberryPiTokenSpaceGuid.PcdBootPolicy
 
 [Guids]
+  gBootDiscoveryPolicyMgrFormsetGuid
   gEfiFileInfoGuid
   gEfiFileSystemInfoGuid
   gEfiFileSystemVolumeLabelInfoIdGuid
@@ -73,8 +74,11 @@
   gEfiTtyTermGuid
   gUefiShellFileGuid
   gEfiEventExitBootServicesGuid
+  gEfiBootManagerPolicyNetworkGuid
+  gEfiBootManagerPolicyConnectAllGuid
 
 [Protocols]
+  gEfiBootManagerPolicyProtocolGuid
   gEfiDevicePathProtocolGuid
   gEfiGraphicsOutputProtocolGuid
   gEfiLoadedImageProtocolGuid
diff --git a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c 
b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
index d081fdae63..1b6418d693 100644
--- a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c
@@ -6,6 +6,7 @@
  *  Copyright (c) 2015-2016, Red Hat, Inc.
  *  Copyright (c) 2014-2021, ARM Ltd. All rights reserved.
  *  Copyright (c) 2004-2016, Intel Corporation. All rights reserved.
+ *  Copyright (c) 2021, Semihalf All rights reserved.
  *
  *  SPDX-License-Identifier: BSD-2-Clause-Patent
  *
@@ -19,10 +20,12 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -598,6 +601,83 @@ PlatformBootManagerBeforeConsole (
   FilterAndProcess (, NULL, Connect);
 }
 
+/**
+  Connect device specified by BootDiscoverPolicy variable and refresh
+  Boot order for newly discovered boot device.
+
+  @retval  EFI_SUCCESS  Devices connected succesfully or connection
+not required.
+  @retval  others   Return values from GetVariable(), LocateProtocol()
+and ConnectDeviceClass().
+--*/
+STATIC
+EFI_STATUS
+BootDiscoveryPolicyHandler (
+  VOID
+  )
+{
+  EFI_STATUS   Status;
+  UINT32   DiscoveryPolicy;
+  UINTNSize;
+  EFI_BOOT_MANAGER_POLICY_PROTOCOL *BMPolicy;
+  EFI_GUID *Class;
+
+  Size = sizeof 

[edk2-devel] [PATCH 1/1] MdeModulePkg: Add BootDiscoveryPolicyUiLib.

2021-06-22 Thread Grzegorz Bernacki
This library extends Boot Maintenance Menu and allows to select
Boot Discovery Policy. When choice is made BootDiscoveryPolicy
variable is set. Platform code can use this variable to decide
which class of device shall be connected.

Signed-off-by: Grzegorz Bernacki 
---
 MdeModulePkg/MdeModulePkg.dec  
   |   6 +
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf 
   |  52 +++
 MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
   |  22 +++
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c   
   | 160 
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni 
   |  18 +++
 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStrings.uni
 |  29 
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.Vfr  
   |  44 ++
 7 files changed, 331 insertions(+)
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
 create mode 100644 MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStrings.uni
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.Vfr

diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 10602a8f79..1e65ad2dd7 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -422,6 +422,9 @@
   ## Include/UniversalPayload/ExtraData.h
   gUniversalPayloadExtraDataGuid = {0x15a5baf6, 0x1c91, 0x467d, {0x9d, 0xfb, 
0x31, 0x9d, 0x17, 0x8d, 0x4b, 0xb4}}
 
+  ## GUID used for Boot Discovery Policy FormSet guid and related variables.
+  gBootDiscoveryPolicyMgrFormsetGuid = { 0x5b6f7107, 0xbb3c, 0x4660, { 0x92, 
0xcd, 0x54, 0x26, 0x90, 0x28, 0x0b, 0xbd } }
+
 [Ppis]
   ## Include/Ppi/AtaController.h
   gPeiAtaControllerPpiGuid   = { 0xa45e60d1, 0xc719, 0x44aa, { 0xb0, 0x7a, 
0xaa, 0x77, 0x7f, 0x85, 0x90, 0x6d }}
@@ -1597,6 +1600,9 @@
   # @Prompt Console Output Row of Text Setup
   gEfiMdeModulePkgTokenSpaceGuid.PcdSetupConOutRow|25|UINT32|0x400e
 
+  ## Specify the Boot Discovery Policy settings
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy|0|UINT32|0x400f
+
 [PcdsFixedAtBuild.AARCH64, PcdsPatchableInModule.AARCH64]
   
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiExposedTableVersions|0x20|UINT32|0x0001004c
 
diff --git 
a/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf 
b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
new file mode 100644
index 00..1fb4d43caa
--- /dev/null
+++ b/MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
@@ -0,0 +1,52 @@
+## @file
+#  Library for BDS phase to use Boot Discovery Policy
+#
+#  Copyright (c) 2021, ARM Ltd. All rights reserved.
+#  Copyright (c) 2021, Semihalf All rights reserved.
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = BootDiscoveryPolicyUiLib
+  MODULE_UNI_FILE= BootDiscoveryPolicyUiLib.uni
+  FILE_GUID  = BE73105A-B13D-4B57-A41A-463DBD15FE10
+  MODULE_TYPE= DXE_DRIVER
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = NULL|DXE_DRIVER UEFI_APPLICATION
+  CONSTRUCTOR= BootDiscoveryPolicyUiLibConstructor
+  DESTRUCTOR = BootDiscoveryPolicyUiLibDestructor
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64 AARCH64
+#
+
+[Sources]
+  BootDiscoveryPolicyUiLib.c
+  BootDiscoveryPolicyUiLibStrings.uni
+  BootDiscoveryPolicyUiLibVfr.Vfr
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  DevicePathLib
+  BaseLib
+  UefiRuntimeServicesTableLib
+  UefiBootServicesTableLib
+  DebugLib
+  HiiLib
+  UefiLib
+  BaseMemoryLib
+
+[Guids]
+  gBootDiscoveryPolicyMgrFormsetGuid
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBootDiscoveryPolicy  ## PRODUCES
+
+[Depex]
+  gEfiHiiDatabaseProtocolGuid AND gPcdProtocolGuid
diff --git a/MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h 
b/MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
new file mode 100644
index 00..8eb0968a16
--- /dev/null
+++ b/MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
@@ -0,0 +1,22 @@
+/** @file
+  Definition for structure & defines exported by Boot Discovery Policy UI
+
+  Copyright (c) 2021, ARM Ltd. All rights reserved.
+  Copyright (c) 2021, Semihalf All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+

[edk2-devel] [PATCH 0/4] Add BootDiscoveryPolicyUiLib

2021-06-22 Thread Grzegorz Bernacki
This patchset extends Boot Maintenance Menu and allows to select
Boot Discovery Policy. Raspberry Pi platforms uses the variable to
connect specified class of devices on boot. This patchset also
removes efdc159e which has similar functionality.

Discussion on design can be found at:
https://edk2.groups.io/g/rfc/topic/rfc_boot_discovery_policy/82450628

Grzegorz Bernacki (3):
edk2:
  MdeModulePkg: Add BootDiscoveryPolicyUiLib.
edk2-platforms:
  Platform/RaspberryPi: Enable Boot Discovery Policy.
  Revert "Platform/RaspberryPi: Setup option for disabling Fast Boot"

 MdeModulePkg/MdeModulePkg.dec  
   |   6 +
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf 
   |  52 +++
 MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
   |  22 +++
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c   
   | 160 
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni 
   |  18 +++
 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStrings.uni
 |  29 
 MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.Vfr  
   |  44 ++
 Platform/RaspberryPi/RaspberryPi.dec   
|  2 -
 Platform/RaspberryPi/RPi3/RPi3.dsc 
|  9 +-
 Platform/RaspberryPi/RPi4/RPi4.dsc 
| 12 +--
 Platform/RaspberryPi/RPi4/RPi4.fdf 
|  1 +
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf   
|  3 +-
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
|  5 +-
 Platform/RaspberryPi/Include/ConfigVars.h  
| 12 +--
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
| 16 +---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c 
| 11 +--
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c   
| 96 +---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
| 10 +-
 18 files changed, 431 insertions(+), 77 deletions(-)
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.inf
 create mode 100644 MdeModulePkg/Include/Guid/BootDiscoveryPolicy.h
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.c
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLib.uni
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibStrings.uni
 create mode 100644 
MdeModulePkg/Library/BootDiscoveryPolicyUiLib/BootDiscoveryPolicyUiLibVfr.Vfr

-- 
2.25.1



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




[edk2-devel] [edk2-platforms PATCH 2/2] Revert "Platform/RaspberryPi: Setup option for disabling Fast Boot"

2021-06-22 Thread Grzegorz Bernacki
This reverts commit efdc159ef7c9f15581a0f63d755a1530ff475156.

This commit is not longer required as Boot Discovery Policy has
been implemented for RPi.

Signed-off-by: Grzegorz Bernacki 
---
 Platform/RaspberryPi/RaspberryPi.dec   
|  2 --
 Platform/RaspberryPi/RPi3/RPi3.dsc 
|  9 +
 Platform/RaspberryPi/RPi4/RPi4.dsc 
|  9 +
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf   
|  3 +--
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
|  1 -
 Platform/RaspberryPi/Include/ConfigVars.h  
| 12 +---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.vfr
| 16 +---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c 
| 11 +--
 Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBm.c   
| 15 ++-
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxeHii.uni
| 10 +-
 10 files changed, 9 insertions(+), 79 deletions(-)

diff --git a/Platform/RaspberryPi/RaspberryPi.dec 
b/Platform/RaspberryPi/RaspberryPi.dec
index f1dd8ac0ed..2ca25ff9e6 100644
--- a/Platform/RaspberryPi/RaspberryPi.dec
+++ b/Platform/RaspberryPi/RaspberryPi.dec
@@ -2,7 +2,6 @@
 #
 #  Copyright (c) 2016, Linaro, Ltd. All rights reserved.
 #  Copyright (c) 2017-2018, Andrei Warkentin 
-#  Copyright (c) 2021, ARM Limited. All rights reserved.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -71,5 +70,4 @@
   gRaspberryPiTokenSpaceGuid.PcdFanTemp|0|UINT32|0x001D
   gRaspberryPiTokenSpaceGuid.PcdPlatformResetDelay|0|UINT32|0x001E
   gRaspberryPiTokenSpaceGuid.PcdMmcEnableDma|0|UINT32|0x001F
-  gRaspberryPiTokenSpaceGuid.PcdBootPolicy|0|UINT32|0x0020
   gRaspberryPiTokenSpaceGuid.PcdUartInUse|1|UINT32|0x0021
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc 
b/Platform/RaspberryPi/RPi3/RPi3.dsc
index 53825bcf62..b6e3372c61 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -1,6 +1,6 @@
 # @file
 #
-#  Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.
+#  Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
 #  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 #  Copyright (c) 2017 - 2018, Andrei Warkentin 
@@ -512,13 +512,6 @@
   
gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGuid|0x0|0
   gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0x0|0
 
-  #
-  # Boot Policy
-  # 0  - Fast Boot
-  # 1  - Full Discovery (Connect All)
-  #
-  
gRaspberryPiTokenSpaceGuid.PcdBootPolicy|L"BootPolicy"|gConfigDxeFormSetGuid|0x0|1
-
   #
   # Reset-related.
   #
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 8b9beac64a..07f36e7f1b 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -1,6 +1,6 @@
 # @file
 #
-#  Copyright (c) 2011 - 2021, ARM Limited. All rights reserved.
+#  Copyright (c) 2011 - 2020, ARM Limited. All rights reserved.
 #  Copyright (c) 2017 - 2018, Andrei Warkentin 
 #  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.
 #  Copyright (c) 2014, Linaro Limited. All rights reserved.
@@ -528,13 +528,6 @@
   
gRaspberryPiTokenSpaceGuid.PcdFanOnGpio|L"FanOnGpio"|gConfigDxeFormSetGuid|0x0|0
   gRaspberryPiTokenSpaceGuid.PcdFanTemp|L"FanTemp"|gConfigDxeFormSetGuid|0x0|60
 
-  #
-  # Boot Policy
-  # 0  - Fast Boot
-  # 1  - Full Discovery (Connect All)
-  #
-  
gRaspberryPiTokenSpaceGuid.PcdBootPolicy|L"BootPolicy"|gConfigDxeFormSetGuid|0x0|1
-
   #
   # Reset-related.
   #
diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf 
b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
index 597e1b4205..4bb2d08550 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
@@ -2,7 +2,7 @@
 #
 #  Component description file for the RasbperryPi DXE platform config driver.
 #
-#  Copyright (c) 2019 - 2021, ARM Limited. All rights reserved.
+#  Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.
 #  Copyright (c) 2018 - 2020, Andrei Warkentin 
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -93,7 +93,6 @@
   gRaspberryPiTokenSpaceGuid.PcdRamLimitTo3GB
   gRaspberryPiTokenSpaceGuid.PcdFanOnGpio
   gRaspberryPiTokenSpaceGuid.PcdFanTemp
-  gRaspberryPiTokenSpaceGuid.PcdBootPolicy
   gRaspberryPiTokenSpaceGuid.PcdUartInUse
 
 [Depex]
diff --git 
a/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
 
b/Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index f8ca4bbf10..86bbe574e7 100644
---