[edk2-devel] [Patch] BaseTools/GenSec: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2345

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Michael D Kinney 
---
 BaseTools/Source/C/GenSec/GenSec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenSec/GenSec.c 
b/BaseTools/Source/C/GenSec/GenSec.c
index a0d6293ee1..d54a4f9e0a 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -177,7 +177,7 @@ Returns:
   fprintf (stdout, "  -l GuidHeaderLength, --HeaderLength GuidHeaderLength\n\
 GuidHeaderLength is the size of header of guided 
data\n");
   fprintf (stdout, "  -r GuidAttr, --attributes GuidAttr\n\
-GuidAttr is guid section atttributes, which may be\n\
+GuidAttr is guid section attributes, which may be\n\
 PROCESSING_REQUIRED, AUTH_STATUS_VALID and NONE. \n\
 if -r option is not given, default 
PROCESSING_REQUIRED\n");
   fprintf (stdout, "  -n String, --name String\n\
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63616): https://edk2.groups.io/g/devel/message/63616
Mute This Topic: https://groups.io/mt/75919491/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] SecurityPkg/OpalPassword: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2346

Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Michael D Kinney 
---
 SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c 
b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
index 211e75537a..0ab71a3665 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
@@ -548,7 +548,7 @@ HiiConfirmDataRemovalAction (
 Unicode,
 L" System should not be powered off until action completion ",
 L" ",
-L" Press 'Y/y' to continue, press 'N/n' to cancal ",
+L" Press 'Y/y' to continue, press 'N/n' to cancel ",
 NULL
 );
   } while (
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63615): https://edk2.groups.io/g/devel/message/63615
Mute This Topic: https://groups.io/mt/75919457/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] MdeModulePkg/BdsDxe: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2355

Cc: Zhichao Gao 
Cc: Ray Ni 
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Universal/BdsDxe/BdsEntry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c 
b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
index d387dbe7ac..83b773a2fa 100644
--- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
+++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c
@@ -785,7 +785,7 @@ BdsEntry (
 
   FilePath = FileDevicePath (NULL, EFI_REMOVABLE_MEDIA_FILE_NAME);
   if (FilePath == NULL) {
-DEBUG ((DEBUG_ERROR, "Fail to allocate memory for defualt boot file path. 
Unable to boot.\n"));
+DEBUG ((DEBUG_ERROR, "Fail to allocate memory for default boot file path. 
Unable to boot.\n"));
 CpuDeadLoop ();
   }
   Status = EfiBootManagerInitializeLoadOption (
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63614): https://edk2.groups.io/g/devel/message/63614
Mute This Topic: https://groups.io/mt/75919320/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 5/6] SecurityPkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Michael D Kinney 
---
 .../Library/DxeImageVerificationLib/DxeImageVerificationLib.c   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c 
b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
index 36b87e16d5..b08fe24e85 100644
--- a/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
+++ b/SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.c
@@ -1465,7 +1465,7 @@ IsAllowedByDb (
 
   //
   // Fetch 'dbx' content. If 'dbx' doesn't exist, continue to check 'db'.
-  // If any other errors occured, no need to check 'db' but just return
+  // If any other errors occurred, no need to check 'db' but just return
   // not-allowed-by-db (FALSE) to avoid bypass.
   //
   DbxDataSize = 0;
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63612): https://edk2.groups.io/g/devel/message/63612
Mute This Topic: https://groups.io/mt/75919240/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 6/6] ShellPkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Ray Ni 
Cc: Zhichao Gao 
Signed-off-by: Michael D Kinney 
---
 ShellPkg/Include/Library/ShellLib.h   |  4 +-
 .../UefiShellBcfgCommandLib.c |  4 +-
 .../Edit/FileBuffer.c |  4 +-
 .../Edit/MainTextEditor.c | 34 ++---
 .../Edit/MainTextEditor.h |  6 +--
 .../HexEdit/BufferImage.c |  8 ++--
 .../HexEdit/BufferImage.h |  6 +--
 .../HexEdit/Clipboard.c   |  4 +-
 .../HexEdit/Clipboard.h   |  4 +-
 .../HexEdit/DiskImage.c   |  6 +--
 .../HexEdit/DiskImage.h   |  6 +--
 .../HexEdit/FileImage.c   |  4 +-
 .../HexEdit/FileImage.h   |  4 +-
 .../HexEdit/MainHexEditor.c   | 48 +--
 .../HexEdit/MainHexEditor.h   |  8 ++--
 .../HexEdit/MemImage.c|  6 +--
 .../HexEdit/MemImage.h|  6 +--
 .../UefiShellDebug1CommandsLib/HexEdit/Misc.c |  8 ++--
 .../UefiShellDebug1CommandsLib/HexEdit/Misc.h |  4 +-
 .../UefiShellDriver1CommandsLib/Drivers.c |  2 +-
 .../Library/UefiShellLevel2CommandsLib/Rm.c   |  2 +-
 .../UefiShellLevel2CommandsLib.h  |  2 +-
 ShellPkg/Library/UefiShellLib/UefiShellLib.c  |  6 +--
 23 files changed, 93 insertions(+), 93 deletions(-)

diff --git a/ShellPkg/Include/Library/ShellLib.h 
b/ShellPkg/Include/Library/ShellLib.h
index 1dc41f2cc1..ed9b8f9105 100644
--- a/ShellPkg/Include/Library/ShellLib.h
+++ b/ShellPkg/Include/Library/ShellLib.h
@@ -1034,7 +1034,7 @@ ShellIsFileInPath(
   @param[in] String   String representation of a number.
 
   @return The unsigned integer result of the conversion.
-  @retval (UINTN)(-1) An error occured.
+  @retval (UINTN)(-1) An error occurred.
 **/
 UINTN
 EFIAPI
@@ -1051,7 +1051,7 @@ ShellStrToUintn(
   @param[in] String   String representation of a number.
 
   @return The unsigned integer result of the conversion.
-  @retval (UINTN)(-1) An error occured.
+  @retval (UINTN)(-1) An error occurred.
 **/
 UINTN
 EFIAPI
diff --git a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c 
b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
index f8bcaebe46..52d90e3c97 100644
--- a/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
+++ b/ShellPkg/Library/UefiShellBcfgCommandLib/UefiShellBcfgCommandLib.c
@@ -84,7 +84,7 @@ typedef struct {
   @param[in]  TargetThe target of the operation.
 
   @retval EFI_SUCCESS   The data was sucessfully updated.
-  @retval other A error occured.
+  @retval other A error occurred.
 **/
 EFI_STATUS
 UpdateOptionalData(
@@ -170,7 +170,7 @@ UpdateOptionalData(
   @param[in]  BootIndex   The boot option index to CRC.
 
   @retval EFI_SUCCESS   The CRC was sucessfully returned.
-  @retval other A error occured.
+  @retval other A error occurred.
 **/
 EFI_STATUS
 GetBootOptionCrc(
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
index c9814e400c..5659ec9810 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/FileBuffer.c
@@ -221,7 +221,7 @@ InternalEditorMiscLineRetreat (
>0 : advance
<0 : retreat
 
-  @retval NULL An error occured.
+  @retval NULL An error occurred.
   @return The line after advance/retreat.
 **/
 EFI_EDITOR_LINE *
@@ -2609,7 +2609,7 @@ RightCurrentScreen (
  >0 : advance
  <0: retreat
 
-  @retval NULL An error occured.
+  @retval NULL An error occurred.
   @return The line after advance/retreat.
 **/
 EFI_EDITOR_LINE *
diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c 
b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
index df530f1119..a9423e0d10 100644
--- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
+++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/MainTextEditor.c
@@ -40,7 +40,7 @@ EFI_EDITOR_GLOBAL_EDITOR  MainEditor;
   Load a file from disk to editor
 
   @retval EFI_SUCCESS The operation was successful.
-  @retval EFI_LOAD_ERROR  A load error occured.
+  @retval EFI_LOAD_ERROR  A load error occurred.
   @retval EFI_OUT_OF_RESOURCESA memory allocation failed.
 **/
 EFI_STATUS
@@ -74,7 +74,7 @@ MainCommandGotoLine (
 
   @retval EFI_SUCCESS   The file was saved correctly.
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.
-  @retval EFI_LOAD_ERROR  A file access error occured.
+  @retval EFI_LOAD_ERROR  A file access error occurred.
 **/
 EFI_STATUS
 

[edk2-devel] [Patch 0/6] Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Ray Ni 
Cc: Zhichao Gao 
Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Cc: Qi Zhang 
Cc: Rahul Kumar 
Signed-off-by: Michael D Kinney 

Michael D Kinney (6):
  EmulatorPkg: Fix spelling mistake for occurred
  MdeModulePkg: Fix spelling mistake for occurred
  MdePkg: Fix spelling mistake for occurred
  OvmfPkg: Fix spelling mistake for occurred
  SecurityPkg: Fix spelling mistake for occurred
  ShellPkg: Fix spelling mistake for occurred

 EmulatorPkg/EmuGopDxe/GopScreen.c |  2 +-
 EmulatorPkg/TimerDxe/Timer.c  |  2 +-
 MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c  |  4 +-
 MdeModulePkg/Core/Dxe/FwVol/FwVol.c   |  2 +-
 .../Include/Protocol/GenericMemoryTest.h  |  4 +-
 .../Acpi/S3SaveStateDxe/S3SaveState.c |  2 +-
 .../Acpi/SmmS3SaveState/SmmS3SaveState.c  |  2 +-
 .../Console/ConSplitterDxe/ConSplitter.h  |  4 +-
 .../ConSplitterDxe/ConSplitterGraphics.c  |  4 +-
 .../Universal/DebugPortDxe/DebugPort.c|  2 +-
 .../Universal/DebugPortDxe/DebugPort.h|  2 +-
 .../FvSimpleFileSystem.c  |  2 +-
 .../Universal/LoadFileOnFv2/LoadFileOnFv2.c   |  2 +-
 .../GenericMemoryTestDxe/LightMemoryTest.c|  4 +-
 .../GenericMemoryTestDxe/LightMemoryTest.h|  4 +-
 MdePkg/Include/Protocol/UgaDraw.h |  2 +-
 MdePkg/Library/BaseLib/FilePaths.c|  2 +-
 OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c |  2 +-
 OvmfPkg/Include/Protocol/Legacy8259.h |  2 +-
 OvmfPkg/SioBusDxe/SioService.c|  2 +-
 .../DxeImageVerificationLib.c |  2 +-
 ShellPkg/Include/Library/ShellLib.h   |  4 +-
 .../UefiShellBcfgCommandLib.c |  4 +-
 .../Edit/FileBuffer.c |  4 +-
 .../Edit/MainTextEditor.c | 34 ++---
 .../Edit/MainTextEditor.h |  6 +--
 .../HexEdit/BufferImage.c |  8 ++--
 .../HexEdit/BufferImage.h |  6 +--
 .../HexEdit/Clipboard.c   |  4 +-
 .../HexEdit/Clipboard.h   |  4 +-
 .../HexEdit/DiskImage.c   |  6 +--
 .../HexEdit/DiskImage.h   |  6 +--
 .../HexEdit/FileImage.c   |  4 +-
 .../HexEdit/FileImage.h   |  4 +-
 .../HexEdit/MainHexEditor.c   | 48 +--
 .../HexEdit/MainHexEditor.h   |  8 ++--
 .../HexEdit/MemImage.c|  6 +--
 .../HexEdit/MemImage.h|  6 +--
 .../UefiShellDebug1CommandsLib/HexEdit/Misc.c |  8 ++--
 .../UefiShellDebug1CommandsLib/HexEdit/Misc.h |  4 +-
 .../UefiShellDriver1CommandsLib/Drivers.c |  2 +-
 .../Library/UefiShellLevel2CommandsLib/Rm.c   |  2 +-
 .../UefiShellLevel2CommandsLib.h  |  2 +-
 ShellPkg/Library/UefiShellLib/UefiShellLib.c  |  6 +--
 44 files changed, 120 insertions(+), 120 deletions(-)

-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63607): https://edk2.groups.io/g/devel/message/63607
Mute This Topic: https://groups.io/mt/75919234/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 3/6] MdePkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Michael D Kinney 
---
 MdePkg/Include/Protocol/UgaDraw.h  | 2 +-
 MdePkg/Library/BaseLib/FilePaths.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/MdePkg/Include/Protocol/UgaDraw.h 
b/MdePkg/Include/Protocol/UgaDraw.h
index 3d423be052..47286bb684 100644
--- a/MdePkg/Include/Protocol/UgaDraw.h
+++ b/MdePkg/Include/Protocol/UgaDraw.h
@@ -127,7 +127,7 @@ typedef enum {
 
 @retval EFI_SUCCESS   - The Blt operation completed.
 @retval EFI_INVALID_PARAMETER - BltOperation is not valid.
-@retval EFI_DEVICE_ERROR  - A hardware error occured writting to the 
video buffer.
+@retval EFI_DEVICE_ERROR  - A hardware error occurred writting to the 
video buffer.
 
 **/
 typedef
diff --git a/MdePkg/Library/BaseLib/FilePaths.c 
b/MdePkg/Library/BaseLib/FilePaths.c
index 40e8d773ce..c2c561ac64 100644
--- a/MdePkg/Library/BaseLib/FilePaths.c
+++ b/MdePkg/Library/BaseLib/FilePaths.c
@@ -57,7 +57,7 @@ PathRemoveLastItem(
 
   @param[in] Path   The pointer to the string containing the path.
 
-  @return   Returns Path, otherwise returns NULL to indicate that an error 
has occured.
+  @return   Returns Path, otherwise returns NULL to indicate that an error 
has occurred.
 **/
 CHAR16*
 EFIAPI
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63610): https://edk2.groups.io/g/devel/message/63610
Mute This Topic: https://groups.io/mt/75919238/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 2/6] MdeModulePkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c  | 4 ++--
 MdeModulePkg/Core/Dxe/FwVol/FwVol.c   | 2 +-
 MdeModulePkg/Include/Protocol/GenericMemoryTest.h | 4 ++--
 MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c  | 2 +-
 MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c   | 2 +-
 MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h   | 4 ++--
 .../Universal/Console/ConSplitterDxe/ConSplitterGraphics.c| 4 ++--
 MdeModulePkg/Universal/DebugPortDxe/DebugPort.c   | 2 +-
 MdeModulePkg/Universal/DebugPortDxe/DebugPort.h   | 2 +-
 .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c  | 2 +-
 MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c  | 2 +-
 .../MemoryTest/GenericMemoryTestDxe/LightMemoryTest.c | 4 ++--
 .../MemoryTest/GenericMemoryTestDxe/LightMemoryTest.h | 4 ++--
 13 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c 
b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c
index 12afbec852..e216418849 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/UhciSched.c
@@ -513,7 +513,7 @@ UhciCheckTdStatus (
   // terminate the transfer
   //
   if (!IsLow && (TdHw->ShortPacket == 1) && (Len < Td->DataLen)) {
-DEBUG ((EFI_D_VERBOSE, "UhciCheckTdStatus: short packet read 
occured\n"));
+DEBUG ((DEBUG_VERBOSE, "UhciCheckTdStatus: short packet read 
occurred\n"));
 
 Finished = TRUE;
 goto ON_EXIT;
@@ -590,7 +590,7 @@ UhciExecuteTransfer (
 Finished = UhciCheckTdStatus (Uhc, Td, IsLow, QhResult);
 
 //
-// Transfer is OK or some error occured (TD inactive)
+// Transfer is OK or some error occurred (TD inactive)
 //
 if (Finished) {
   break;
diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c 
b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
index e2f58c4d82..cbf5c1c7b9 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVol.c
@@ -572,7 +572,7 @@ Done:
   EFI_FIRMWARE_VOLUME2_PROTOCOL on the same handle.  This is the function where
   the actual initialization of the EFI_FIRMWARE_VOLUME2_PROTOCOL is done.
 
-  @param  Event The event that occured
+  @param  Event The event that occurred
   @param  Context   For EFI compatiblity.  Not used.
 
 **/
diff --git a/MdeModulePkg/Include/Protocol/GenericMemoryTest.h 
b/MdeModulePkg/Include/Protocol/GenericMemoryTest.h
index 61cab8c4ae..08157f35f5 100644
--- a/MdeModulePkg/Include/Protocol/GenericMemoryTest.h
+++ b/MdeModulePkg/Include/Protocol/GenericMemoryTest.h
@@ -54,12 +54,12 @@ EFI_STATUS
   @param  TestedMemorySizeReturn the tested extended memory size.
   @param  TotalMemorySize Return the whole system physical memory size.
   The total memory size does not include memory in 
a slot with a disabled DIMM.
-  @param  ErrorOutTRUE if the memory error occured.
+  @param  ErrorOutTRUE if the memory error occurred.
   @param  IfTestAbort Indicates that the user pressed "ESC" to skip 
the memory test.
 
   @retval EFI_SUCCESS One block of memory passed the test.
   @retval EFI_NOT_FOUND   All memory blocks have already been tested.
-  @retval EFI_DEVICE_ERRORMemory device error occured, and no agent can 
handle it.
+  @retval EFI_DEVICE_ERRORMemory device error occurred, and no agent can 
handle it.
 
 **/
 typedef
diff --git a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c 
b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
index cfa8ebbd2f..e342f73485 100644
--- a/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveState.c
@@ -889,7 +889,7 @@ BootScriptCompare (
 
   @retval EFI_OUT_OF_RESOURCES  No enough resource
   @retval EFI_SUCCESS   Succesfully installed the ScriptSave driver.
-  @retval other Errors occured.
+  @retval other Errors occurred.
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c 
b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
index fc6d29e48b..601c8218db 100644
--- a/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
+++ b/MdeModulePkg/Universal/Acpi/SmmS3SaveState/SmmS3SaveState.c
@@ -887,7 +887,7 @@ BootScriptCompare (
 
   @retval EFI_OUT_OF_RESOURCES  No enough resource
   @retval EFI_SUCCESS   Succesfully installed the ScriptSave driver.
-  @retval other Errors occured.
+  @retval other Errors occurred.
 
 **/
 EFI_STATUS
diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h 
b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h
index 

[edk2-devel] [Patch 1/6] EmulatorPkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Jordan Justen 
Cc: Andrew Fish 
Cc: Ray Ni 
Signed-off-by: Michael D Kinney 
---
 EmulatorPkg/EmuGopDxe/GopScreen.c | 2 +-
 EmulatorPkg/TimerDxe/Timer.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/EmulatorPkg/EmuGopDxe/GopScreen.c 
b/EmulatorPkg/EmuGopDxe/GopScreen.c
index fbac649f8b..cbbb0db07f 100644
--- a/EmulatorPkg/EmuGopDxe/GopScreen.c
+++ b/EmulatorPkg/EmuGopDxe/GopScreen.c
@@ -177,7 +177,7 @@ EmuGopSetMode (
 
   @retval EFI_SUCCESS   The Blt operation completed.
   @retval EFI_INVALID_PARAMETER BltOperation is not valid.
-  @retval EFI_DEVICE_ERROR  A hardware error occured writting to the video 
buffer.
+  @retval EFI_DEVICE_ERROR  A hardware error occurred writting to the 
video buffer.
 
 **/
 EFI_STATUS
diff --git a/EmulatorPkg/TimerDxe/Timer.c b/EmulatorPkg/TimerDxe/Timer.c
index dfd92acc8c..8e2b5b 100644
--- a/EmulatorPkg/TimerDxe/Timer.c
+++ b/EmulatorPkg/TimerDxe/Timer.c
@@ -301,7 +301,7 @@ Returns:
 
   EFI_OUT_OF_RESOURCES  - Not enough resources available to initialize driver.
 
-  EFI_DEVICE_ERROR  - A device error occured attempting to initialize the 
driver.
+  EFI_DEVICE_ERROR  - A device error occurred attempting to initialize the 
driver.
 
 **/
 {
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63608): https://edk2.groups.io/g/devel/message/63608
Mute This Topic: https://groups.io/mt/75919236/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch 4/6] OvmfPkg: Fix spelling mistake for occurred

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2361

Cc: Jordan Justen 
Cc: Laszlo Ersek 
Cc: Ard Biesheuvel 
Signed-off-by: Michael D Kinney 
---
 OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c | 2 +-
 OvmfPkg/Include/Protocol/Legacy8259.h | 2 +-
 OvmfPkg/SioBusDxe/SioService.c| 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c 
b/OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c
index 0760ffb722..672a67fbe1 100644
--- a/OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c
+++ b/OvmfPkg/Bhyve/BhyveRfbDxe/GopScreen.c
@@ -226,7 +226,7 @@ EmuGopSetMode (
 
   @retval EFI_SUCCESS   The Blt operation completed.
   @retval EFI_INVALID_PARAMETER BltOperation is not valid.
-  @retval EFI_DEVICE_ERROR  A hardware error occured writting to the video 
buffer.
+  @retval EFI_DEVICE_ERROR  A hardware error occurred writting to the 
video buffer.
 
 **/
 EFI_STATUS
diff --git a/OvmfPkg/Include/Protocol/Legacy8259.h 
b/OvmfPkg/Include/Protocol/Legacy8259.h
index 74bbb674ed..7fde1c8537 100644
--- a/OvmfPkg/Include/Protocol/Legacy8259.h
+++ b/OvmfPkg/Include/Protocol/Legacy8259.h
@@ -58,7 +58,7 @@ typedef enum {
   @param  SlaveBase The base vector for the Slave PIC in the 8259 
controller.
 
   @retval EFI_SUCCESS   The new bases were programmed.
-  @retval EFI_DEVICE_ERROR  A device error occured programming the vector 
bases.
+  @retval EFI_DEVICE_ERROR  A device error occurred programming the vector 
bases.
 
 **/
 typedef
diff --git a/OvmfPkg/SioBusDxe/SioService.c b/OvmfPkg/SioBusDxe/SioService.c
index 407132ddcd..ab8fa7676f 100644
--- a/OvmfPkg/SioBusDxe/SioService.c
+++ b/OvmfPkg/SioBusDxe/SioService.c
@@ -265,7 +265,7 @@ SioModify (
   @param[in] DeviceIndex   Index of the device supported by this driver.
 
   @retval EFI_SUCCESS  The child device has been created successfully.
-  @retval Others   Error occured during the child device creation.
+  @retval Others   Error occurred during the child device creation.
 
 **/
 EFI_STATUS
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63611): https://edk2.groups.io/g/devel/message/63611
Mute This Topic: https://groups.io/mt/75919239/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] MdeModulePkg/CapsuleApp: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2356

Cc: Hao A Wu 
Cc: Liming Gao 
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c 
b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
index b161d1a981..dba50b3202 100644
--- a/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Application/CapsuleApp/CapsuleOnDisk.c
@@ -795,7 +795,7 @@ ProcessCapsuleOnDisk (
 
   Status = GetUpdateFileSystem (Map, , , );
   if (EFI_ERROR (Status)) {
-Print (L"CapsuleApp: cannot find a valid file system on boot devies. 
Status = %r\n", Status);
+Print (L"CapsuleApp: cannot find a valid file system on boot devices. 
Status = %r\n", Status);
 return Status;
   }
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63606): https://edk2.groups.io/g/devel/message/63606
Mute This Topic: https://groups.io/mt/75918896/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] UefiCpuPkg/CpuCommonFeaturesLib: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2357

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Cc: Rahul Kumar 
Signed-off-by: Michael D Kinney 
---
 UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c 
b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
index 844052b9a5..822126d355 100644
--- a/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
+++ b/UefiCpuPkg/Library/CpuCommonFeaturesLib/MachineCheck.c
@@ -287,7 +287,7 @@ LmceSupport (
 
   McgCap.Uint64 = AsmReadMsr64 (MSR_IA32_MCG_CAP);
   if (ProcessorNumber == 0) {
-DEBUG ((EFI_D_INFO, "LMCE eanble = %x\n", (BOOLEAN) 
(McgCap.Bits.MCG_LMCE_P != 0)));
+DEBUG ((EFI_D_INFO, "LMCE enable = %x\n", (BOOLEAN) 
(McgCap.Bits.MCG_LMCE_P != 0)));
   }
   return (BOOLEAN) (McgCap.Bits.MCG_LMCE_P != 0);
 }
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63605): https://edk2.groups.io/g/devel/message/63605
Mute This Topic: https://groups.io/mt/75918827/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v3 1/3] CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool

2020-07-31 Thread Yao, Jiewen
Hi
I have read https://bugzilla.tianocore.org/show_bug.cgi?id=1871
I would like to give R-B, because the code matches what described in Bugzilla.

Before that, I would like double confirm on the randomness requirement.
According to 
https://software.intel.com/content/www/us/en/develop/blogs/the-difference-between-rdrand-and-rdseed.html,
 the RDSEED is a "Non-deterministic random bit generator", while RDRAND is a 
"Cryptographically secure pseudorandom number generator"

Before this patch:
rand_pool_acquire_entropy()-> 
RandGetSeed128()->MicroSecondDelay()+RandGetBytes()->GetRandomNoise64()->AsmReadTsc()+MicroSecondDelay().
rand_pool_add_nonce_data()->GetPerformanceCounter()+RandGetBytes()
It seems return TSC and TimerCounter.

After this patch:
rand_pool_acquire_entropy()->RandGetBytes()->GetRandomNumber64()->AsmRdRand64().
rand_pool_add_nonce_data()->RandGetBytes()
It becomes pseudorandom.

So the meaning of the function seems changed.
I have not checked the randomness requirement for those two functions yet.
But could anyone confirm that a pseudorandom value returned is OK?

Or should we use RDSEED for non-deterministic value?

Thank you
Yao Jiewen


> -Original Message-
> From: matthewfcarl...@gmail.com 
> Sent: Saturday, August 1, 2020 4:27 AM
> To: devel@edk2.groups.io
> Cc: Yao, Jiewen ; Wang, Jian J ;
> Lu, XiaoyuX ; Matthew Carlson
> 
> Subject: [PATCH v3 1/3] CryptoPkg: OpensslLib: Use RngLib to generate entropy
> in rand_pool
> 
> From: Matthew Carlson 
> 
> Changes OpenSSL to no longer depend on TimerLib and instead use RngLib.
> This allows platforms to decide for themsevles what sort of entropy source
> they provide to OpenSSL and TlsLib.
> 
> Cc: Jiewen Yao 
> Cc: Jian J Wang 
> Cc: Xiaoyu Lu 
> Signed-off-by: Matthew Carlson 
> ---
>  CryptoPkg/Library/OpensslLib/rand_pool.c   | 203 ++--
>  CryptoPkg/Library/OpensslLib/rand_pool_noise.c |  29 ---
>  CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c |  43 -
>  CryptoPkg/CryptoPkg.dsc|   1 +
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf|  15 +-
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  |  15 +-
>  CryptoPkg/Library/OpensslLib/rand_pool_noise.h |  29 ---
>  7 files changed, 22 insertions(+), 313 deletions(-)
> 
> diff --git a/CryptoPkg/Library/OpensslLib/rand_pool.c
> b/CryptoPkg/Library/OpensslLib/rand_pool.c
> index 9e0179b03490..b3ff03b2aa13 100644
> --- a/CryptoPkg/Library/OpensslLib/rand_pool.c
> +++ b/CryptoPkg/Library/OpensslLib/rand_pool.c
> @@ -11,53 +11,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>  #include 
> 
> 
> 
>  #include 
> 
> -#include 
> 
> -
> 
> -#include "rand_pool_noise.h"
> 
> -
> 
> -/**
> 
> -  Get some randomness from low-order bits of GetPerformanceCounter results.
> 
> -  And combine them to the 64-bit value
> 
> -
> 
> -  @param[out] RandBuffer pointer to store the 64-bit random value.
> 
> -
> 
> -  @retval TRUERandom number generated successfully.
> 
> -  @retval FALSE   Failed to generate.
> 
> -**/
> 
> -STATIC
> 
> -BOOLEAN
> 
> -EFIAPI
> 
> -GetRandNoise64FromPerformanceCounter(
> 
> -  OUT UINT64  *Rand
> 
> -  )
> 
> -{
> 
> -  UINT32 Index;
> 
> -  UINT32 *RandPtr;
> 
> -
> 
> -  if (NULL == Rand) {
> 
> -return FALSE;
> 
> -  }
> 
> -
> 
> -  RandPtr = (UINT32 *) Rand;
> 
> -
> 
> -  for (Index = 0; Index < 2; Index ++) {
> 
> -*RandPtr = (UINT32) (GetPerformanceCounter () & 0xFF);
> 
> -MicroSecondDelay (10);
> 
> -RandPtr++;
> 
> -  }
> 
> -
> 
> -  return TRUE;
> 
> -}
> 
> +#include 
> 
> 
> 
>  /**
> 
>Calls RandomNumber64 to fill
> 
>a buffer of arbitrary size with random bytes.
> 
> +  This is a shim layer to RngLib.
> 
> 
> 
>@param[in]   LengthSize of the buffer, in bytes,  to fill with.
> 
>@param[out]  RandBufferPointer to the buffer to store the random 
> result.
> 
> 
> 
> -  @retval EFI_SUCCESSRandom bytes generation succeeded.
> 
> -  @retval EFI_NOT_READY  Failed to request random bytes.
> 
> +  @retval TrueRandom bytes generation succeeded.
> 
> +  @retval False   Failed to request random bytes.
> 
> 
> 
>  **/
> 
>  STATIC
> 
> @@ -73,17 +38,17 @@ RandGetBytes (
> 
> 
>Ret = FALSE;
> 
> 
> 
> +  if (RandBuffer == NULL) {
> 
> +DEBUG((DEBUG_ERROR, "[OPENSSL_RAND_POOL] NULL RandBuffer. No
> random numbers are generated and your system is not secure\n"));
> 
> +ASSERT(FALSE); // Since we can't generate random numbers, we should
> assert. Otherwise we will just blow up later.
> 
> +return Ret;
> 
> +  }
> 
> +
> 
> +
> 
>while (Length > 0) {
> 
> -//
> 
> -// Get random noise from platform.
> 
> -// If it failed, fallback to PerformanceCounter
> 
> -// If you really care about security, you must override
> 
> -// GetRandomNoise64FromPlatform.
> 
> -//
> 
> -Ret = GetRandomNoise64 ();
> 
> -if (Ret == FALSE) {
> 
> -  Ret = 

[edk2-devel] [Patch] MdeModulePkg/EbcDxe: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2360

Cc: Jian J Wang 
Cc: Hao A Wu 
Signed-off-by: Michael D Kinney 
---
 MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c 
b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c
index fb85b30578..5597a7e154 100644
--- a/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c
+++ b/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCommand.c
@@ -218,7 +218,7 @@ EFI_DEBUGGER_COMMAND_SET  mDebuggerCommandSet[] = {
 L"TRACE  - show/clear trace instruction branch\n",
 L"The trace command will show or clear the latest instruction branch.\n\n",
 L"TRACE [c]\n"
-L"  (No Argument) - Show current instrcution branch\n"
+L"  (No Argument) - Show current instruction branch\n"
 L"  c - Clear current instruction branch\n",
 L"",
 {SCAN_NULL, CHAR_NULL},
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63603): https://edk2.groups.io/g/devel/message/63603
Mute This Topic: https://groups.io/mt/75917297/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [Patch] BaseTools/VolInfo: Fix spelling mistake

2020-07-31 Thread Michael D Kinney
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2349

Cc: Bob Feng 
Cc: Liming Gao 
Signed-off-by: Michael D Kinney 
---
 BaseTools/Source/C/VolInfo/VolInfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c 
b/BaseTools/Source/C/VolInfo/VolInfo.c
index ffe0b47f03..2457ddd2e7 100644
--- a/BaseTools/Source/C/VolInfo/VolInfo.c
+++ b/BaseTools/Source/C/VolInfo/VolInfo.c
@@ -1077,7 +1077,7 @@ Returns:
   }
 
   if (VolumeHeader.FvLength != Size) {
-printf ("ERROR: Volume Size not consistant with Block Maps!\n");
+printf ("ERROR: Volume Size not consistent with Block Maps!\n");
 return EFI_ABORTED;
   }
 
-- 
2.21.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63602): https://edk2.groups.io/g/devel/message/63602
Mute This Topic: https://groups.io/mt/75917191/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 0/2] Use RngLib instead of TimerLib for OpensslLib

2020-07-31 Thread Matthew Carlson via groups.io
I included a null lib and I was including the wrong version of Rng anyway.

I think that would make sense to split them into two different DSC files.

Typo fixed, good spot!
--
- Matthew Carlson

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63601): https://edk2.groups.io/g/devel/message/63601
Mute This Topic: https://groups.io/mt/75890825/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v13 45/46] UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

2020-07-31 Thread Laszlo Ersek
On 07/31/20 16:47, Tom Lendacky wrote:
> On 7/31/20 9:44 AM, Tom Lendacky wrote:
>> On 7/31/20 8:36 AM, Tom Lendacky wrote:
>>> On 7/31/20 7:43 AM, Laszlo Ersek wrote:
 Hi Tom,
>>>
>>> Hi Laszlo,
>>
>> Hi Laszlo,
>>
>> Can you try this incremental patch to see if it fixes the issue you're
>> seeing? If it does, I'll merge it into patch #45 and send out a v14.
> 
> Looking at the formatting, I'm not sure if Thunderbird messed up the
> diff. I'll send you another copy directly to you using git send-email
> just in case.

I got the separate copy; I'll report back sometime next week.
Thanks!
Laszlo

>> diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
>> b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
>> index 7165bcf3124a..2c00d72ddefe 100644
>> --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
>> +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
>> @@ -365,9 +365,9 @@ RelocateApLoop (
>>   MwaitSupport,
>>
>>   CpuMpData->ApTargetCState,
>>
>>   CpuMpData->PmCodeSegment,
>>
>> -    CpuMpData->Pm16CodeSegment,
>>
>>   StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,
>>
>>   (UINTN) ,
>>
>> +    CpuMpData->Pm16CodeSegment,
>>
>>   CpuMpData->SevEsAPBuffer,
>>
>>   CpuMpData->WakeupBuffer
>>
>>   );
>>
>> diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
>> b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
>> index 309d53bf3b37..7e81d24aa60f 100644
>> --- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
>> +++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
>> @@ -226,7 +226,10 @@ SwitchToRealProcStart:
>>   SwitchToRealProcEnd:
>>
>>  
>>  
>> ;-
>>
>>
>> -;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment,
>> TopOfApStack, CountTofinish);
>>
>> +;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment,
>> TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable,
>> WakeupBuffer);
>>
>> +;
>>
>> +;  The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and
>> WakeupBuffer) are
>>
>> +;  specific to SEV-ES support and are not applicable on IA32.
>>
>>  
>> ;-
>>
>>
>>   global ASM_PFX(AsmRelocateApLoop)
>>
>>   ASM_PFX(AsmRelocateApLoop):
>>
>> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h
>> b/UefiCpuPkg/Library/MpInitLib/MpLib.h
>> index 267aa5201c50..02652eaae126 100644
>> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
>> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
>> @@ -350,9 +350,9 @@ VOID
>>     IN BOOLEAN MwaitSupport,
>>
>>     IN UINTN   ApTargetCState,
>>
>>     IN UINTN   PmCodeSegment,
>>
>> -  IN UINTN   Pm16CodeSegment,
>>
>>     IN UINTN   TopOfApStack,
>>
>>     IN UINTN   NumberToFinish,
>>
>> +  IN UINTN   Pm16CodeSegment,
>>
>>     IN UINTN   SevEsAPJumpTable,
>>
>>     IN UINTN   WakeupBuffer
>>
>>     );
>>
>> diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
>> b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
>> index 3b8ec477b8b3..5d30f35b201c 100644
>> --- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
>> +++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
>> @@ -491,13 +491,13 @@ PM16Mode:
>>   SwitchToRealProcEnd:
>>
>>  
>>  
>> ;-
>>
>>
>> -;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment,
>> Pm16CodeSegment, TopOfApStack, CountTofinish, SevEsAPJumpTable,
>> WakeupBuffer);
>>
>> +;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment,
>> TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable,
>> WakeupBuffer);
>>
>>  
>> ;-
>>
>>
>>   global ASM_PFX(AsmRelocateApLoop)
>>
>>   ASM_PFX(AsmRelocateApLoop):
>>
>>   AsmRelocateApLoopStart:
>>
>>   BITS 64
>>
>> -    cmp    qword [rsp + 56], 0
>>
>> +    cmp    qword [rsp + 56], 0  ; SevEsAPJumpTable
>>
>>   je NoSevEs
>>
>>  
>>   ;
>>
>> @@ -539,16 +539,17 @@ BITS 64
>>  
>>   NoSevEs:
>>
>>   cli  ; Disable interrupt before
>> switching to 32-bit mode
>>
>> -    mov    rax, [rsp + 48]   ; CountTofinish
>>
>> +    mov    rax, [rsp + 40]   ; CountTofinish
>>
>>   lock dec   dword [rax]   ; (*CountTofinish)--
>>
>>  
>> +    mov    r10, [rsp + 48]   ; Pm16CodeSegment
>>
>>   mov    rax, [rsp + 56]   ; SevEsAPJumpTable
>>
>>   mov    rbx, [rsp + 64]   ; WakeupBuffer
>>
>> -    mov    rsp, [rsp + 40]   ; TopOfApStack
>>
>> +    mov    rsp, r9   ; TopOfApStack
>>
>>  
>>   push   rax   ; Save SevEsAPJumpTable
>>
>>   push   rbx   ; Save WakeupBuffer
>>
>> -    push   r9    ; Save Pm16CodeSegment

Re: [edk2-devel] [PATCH v3 0/3] Use RngLib instead of TimerLib for OpensslLib

2020-07-31 Thread Michael D Kinney
Hi Matt,

1) BaseRngLibTimerLib
  a) The comments incorrectly list delays in ms instead of us.
  b) Did you consider use of GetPerformanceCounterProperties()?
 I also do not seen an explanation of the delay values used.
 (why not smaller or larger values).  At a minimum, the file
 header should state it only works if the rate of the perf
 counter from TimerLib is much greater than 1MHz.
2) BaseRngLibDxe
   a) This is not a lib of type Base.  I recommend the name
  DxeRngLibRngProtocol.
   b) Has a "MU_CHANGE" comment that can be removed
   c) GenerateRandomNumberViaNist800Algorithm() assigns values in
  declaration.  Init should be moved into statements.
   d) How would gBS aver be NULL?  The INF lists the BootServicesTableLib
  as a dependency, so the constructer is always run before the
  services are used.  I think these checks can be removed.
   e) Minor code style issues.  if statements should have { as end of line.

With the addition of DxeRngLibRngProtocol to MdePkg, I think the CryptoPkg
DSC can be updated to use this RngLib instance from the Crypto DXE mododule.

Best regards,

Mike

> -Original Message-
> From: devel@edk2.groups.io  On
> Behalf Of Matthew Carlson
> Sent: Friday, July 31, 2020 1:27 PM
> To: devel@edk2.groups.io
> Subject: [edk2-devel] [PATCH v3 0/3] Use RngLib instead
> of TimerLib for OpensslLib
> 
> From: Matthew Carlson 
> 
> Fixes Bugzilla#1871
> https://github.com/tianocore/edk2/pull/845
> 
> 
> Matthew Carlson (3):
>   CryptoPkg: OpensslLib: Use RngLib to generate entropy
> in rand_pool
>   MdePkg: TimerRngLib: Added RngLib that uses TimerLib
>   MdePkg: BaseRngLibDxe: Add RngLib that uses RngDxe
> 
>  CryptoPkg/Library/OpensslLib/rand_pool.c
> | 203 ++
>  CryptoPkg/Library/OpensslLib/rand_pool_noise.c
> |  29 ---
>  CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c
> |  43 
>  MdePkg/Library/BaseRngLibDxe/RngDxeLib.c
> | 216 
>  MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c
> | 154 ++
>  CryptoPkg/CryptoPkg.dsc
> |   1 +
>  CryptoPkg/Library/OpensslLib/OpensslLib.inf
> |  15 +-
>  CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf
> |  15 +-
>  CryptoPkg/Library/OpensslLib/rand_pool_noise.h
> |  29 ---
>  MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf
> |  38 
> 
> MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.in
> f |  38 
> 
> MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.un
> i |  17 ++
>  MdePkg/MdePkg.dsc
> |   5 +-
>  13 files changed, 489 insertions(+), 314 deletions(-)
>  delete mode 100644
> CryptoPkg/Library/OpensslLib/rand_pool_noise.c
>  delete mode 100644
> CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c
>  create mode 100644
> MdePkg/Library/BaseRngLibDxe/RngDxeLib.c
>  create mode 100644
> MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c
>  delete mode 100644
> CryptoPkg/Library/OpensslLib/rand_pool_noise.h
>  create mode 100644
> MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf
>  create mode 100644
> MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.in
> f
>  create mode 100644
> MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.un
> i
> 
> --
> 2.27.0.windows.1
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63599): https://edk2.groups.io/g/devel/message/63599
Mute This Topic: https://groups.io/mt/75915445/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] Add BhyvePkg, to support the bhyve hypervisor

2020-07-31 Thread Laszlo Ersek
Hi Sean,

thank you for reporting this. I apologize for the breakage. Please see
my comments below.

(Rebecca and the stewards should read on as well, please.)

On 07/31/20 19:32, Sean Brogan wrote:
> This patch as committed is breaking CI.  It was not captured in PR
> because the PR optimizes to detect packages impacted by the commits and
> the BhyvePkg addition is not depended on by other packages (that are in
> CI).

Yup, both Rebecca and myself put the package through CI.

>  BhyvePkg which is nested inside OvmfPkg ( a violation of DEC spec:
>  see
> https://edk2-docs.gitbook.io/edk-ii-dec-specification/2_dec_file_overview 
> paragraph

Indeed! I've been unaware of this:

> An EDK II Package (directory) is a directory that contains an EDK II
> package declaration (DEC) file. Only one DEC file is permitted per
> directory. EDK II Packages cannot be nested within other EDK II
> Packages.

Thank you for teaching me this. This is the first time in my 8-9-ish
years with edk2 that I'm participating in the addition of a (not-quite)
top-level package.

We originally intended BhyvePkg to be stand-alone, but that was not
welcomed by many. So we pushed it into OvmfPkg/Bhyve (note: no "Pkg"
suffix on the "Bhyve" subdirectory). While doing so, we should have
eliminated the separate DEC file.

Namely, if we compare both DEC files now:
- OvmfPkg/OvmfPkg.dec
- OvmfPkg/Bhyve/BhyvePkg.dec

there are not many differences (in fact only changes and additions in
BhyvePkg.dec matter, removals (= trimming) don't):

- some copyright notices,
- the BhyveFwCtlLib lib class,
- a different default value for PcdDebugIoPort.

That's all. So it should not be hard for Rebecca to incorporate these
changes into the "main" OvmfPkg/OvmfPkg.dec file. And, the
PcdDebugIoPort value change actually belongs in
"OvmfPkg/Bhyve/BhyvePkgX64.dsc".

Furthermore, the new Bhyve DEC file -- which should be removed -- is
referenced in the following INF files only:

- Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf
- Bhyve/BhyveRfbDxe/BhyveRfbDxe.inf
- Bhyve/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf

Those INF files should be re-pointed to the main OvmfPkg.dec file.

> 4) does not support CI so it is not tested but now that it is in the
> edk2 tree it is causing the other packages to fail.
> 
> 
> You can see the ReadMe badge showing the broken state of edk2 master.
> The build with logs can be seen here
> https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=10494=logs=ec42d809-3c3b-54a9-276c-e54a8b9aaee9=596e0656-4def-5804-b10b-1585519aa2e8
> and some of the relevant failures are added below.
> 
> [...]
> 
> The errors can be easily resolved but the nested packages is a bigger
> problem.

Both the individual errors and the nested package situation (which
indeed violates the DEC spec) should hopefully be resolved by the
suggestions above.

Regarding actual actions: I'm going to be away for a short while now.
Plus, I'm not entirely sure what exactly is being prevented by the
current state of the tree (i.e., how grave the regression is).

(1) If the current issue interferes with work on, and usability of,
other packages (that is, anything *not* OvmfPkg), then I would request
that one of the stewards please revert 656419f922c0 ("Add BhyvePkg, to
support the bhyve hypervisor", 2020-07-31). For such a revert, please
add at once:

Acked-by: Laszlo Ersek 

This is because the IRL stuff I've got queued up does not allow me to
participate in the revert, urgently, either from the reviewer side, or
even from the submitter side. (I wouldn't like to simply push a revert
without formal review, and I don't have time to *post* the revert
urgently). I was about to disappear for a bit, and logged back in only
because I snuck a peek on the mailing list archive, and noticed the
problem report.

After the revert, Rebecca and I can collaborate on the next version of
the patch (I can review that incrementally against the one being
reverted under this option).

(2) If, on the other hand, the current issue is restricted to OvmfPkg
(and even OvmfPkg platforms other than bhyve can be built), then I'd
like to ask that we keep commit 656419f922c0, and that Rebecca please
submit an incremental fix (per the above suggestions, assuming they work).

... Upon re-reading your comment "causing the other packages to fail", I
think we have case (1); if that's right, then please proceed accordingly.

Thank you, and again I apologize for the mess. :(
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63598): https://edk2.groups.io/g/devel/message/63598
Mute This Topic: https://groups.io/mt/75472166/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 0/2] Use RngLib instead of TimerLib for OpensslLib

2020-07-31 Thread Michael D Kinney
Hi Matt,

I know you can use the Null lib and have the module be function.  The Package 
DSC is for build verification.  Does not have to be functional.  We already 
have examples in the Security using a Null BaseCryptLib to improve build 
verification performance, but of course those security modules as built would 
not run.

I know one goal is to build functional binaries from the CryptoPkg.  Perhaps 
that should be a different DSC file?

The typo is True -> TRUE and False -> FALSE

Mike

From: macarl via [] 
Sent: Friday, July 31, 2020 1:16 PM
To: Kinney, Michael D ; devel@edk2.groups.io
Subject: Re: [edk2-devel] [Patch v2 0/2] Use RngLib instead of TimerLib for 
OpensslLib


Hey Mike!

Thanks for the comments. I've addressed the feedback below.

1. All good comments. I think I've addressed them all. New patch series should 
be coming soon.

2. This is a problem for BaseCryptLibOnProtocol. We can't use a null lib for 
RngLib since it explodes when it tries to seed OpenSSL with entropy. I think 
for now, let's stick with established dependencies and figure this out at a 
later date. I added an RngLib that uses the DXE RNG Protocol.

3. I don't see a typo?

  Calls RandomNumber64 to fill

  a buffer of arbitrary size with random bytes.



  @param[in]   LengthSize of the buffer, in bytes,  to fill with.

  @param[out]  RandBufferPointer to the buffer to store the random result.



  @retval TrueRandom bytes generation succeeded.

  @retval False   Failed to request random bytes.



--
- Matthew Carlson

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63597): https://edk2.groups.io/g/devel/message/63597
Mute This Topic: https://groups.io/mt/75890825/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] Add BhyvePkg, to support the bhyve hypervisor

2020-07-31 Thread Rebecca Cran

On 7/31/20 11:32 AM, Sean Brogan wrote:

This patch as committed is breaking CI.  It was not captured in PR 
because the PR optimizes to detect packages impacted by the commits 
and the BhyvePkg addition is not depended on by other packages (that 
are in CI).  BhyvePkg which is nested inside OvmfPkg ( a violation of 
DEC spec:  see 
https://edk2-docs.gitbook.io/edk-ii-dec-specification/2_dec_file_overview 
paragraph 4) does not support CI so it is not tested but now that it 
is in the edk2 tree it is causing the other packages to fail.



Sorry. I've replicated the errors locally, and will see if I can work 
around them.



--

Rebecca Cran



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63596): https://edk2.groups.io/g/devel/message/63596
Mute This Topic: https://groups.io/mt/75472166/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 1/3] CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool

2020-07-31 Thread Matthew Carlson
From: Matthew Carlson 

Changes OpenSSL to no longer depend on TimerLib and instead use RngLib.
This allows platforms to decide for themsevles what sort of entropy source
they provide to OpenSSL and TlsLib.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Signed-off-by: Matthew Carlson 
---
 CryptoPkg/Library/OpensslLib/rand_pool.c   | 203 ++--
 CryptoPkg/Library/OpensslLib/rand_pool_noise.c |  29 ---
 CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c |  43 -
 CryptoPkg/CryptoPkg.dsc|   1 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf|  15 +-
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf  |  15 +-
 CryptoPkg/Library/OpensslLib/rand_pool_noise.h |  29 ---
 7 files changed, 22 insertions(+), 313 deletions(-)

diff --git a/CryptoPkg/Library/OpensslLib/rand_pool.c 
b/CryptoPkg/Library/OpensslLib/rand_pool.c
index 9e0179b03490..b3ff03b2aa13 100644
--- a/CryptoPkg/Library/OpensslLib/rand_pool.c
+++ b/CryptoPkg/Library/OpensslLib/rand_pool.c
@@ -11,53 +11,18 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include 
 
 #include 
-#include 
-
-#include "rand_pool_noise.h"
-
-/**
-  Get some randomness from low-order bits of GetPerformanceCounter results.
-  And combine them to the 64-bit value
-
-  @param[out] RandBuffer pointer to store the 64-bit random value.
-
-  @retval TRUERandom number generated successfully.
-  @retval FALSE   Failed to generate.
-**/
-STATIC
-BOOLEAN
-EFIAPI
-GetRandNoise64FromPerformanceCounter(
-  OUT UINT64  *Rand
-  )
-{
-  UINT32 Index;
-  UINT32 *RandPtr;
-
-  if (NULL == Rand) {
-return FALSE;
-  }
-
-  RandPtr = (UINT32 *) Rand;
-
-  for (Index = 0; Index < 2; Index ++) {
-*RandPtr = (UINT32) (GetPerformanceCounter () & 0xFF);
-MicroSecondDelay (10);
-RandPtr++;
-  }
-
-  return TRUE;
-}
+#include 
 
 /**
   Calls RandomNumber64 to fill
   a buffer of arbitrary size with random bytes.
+  This is a shim layer to RngLib.
 
   @param[in]   LengthSize of the buffer, in bytes,  to fill with.
   @param[out]  RandBufferPointer to the buffer to store the random result.
 
-  @retval EFI_SUCCESSRandom bytes generation succeeded.
-  @retval EFI_NOT_READY  Failed to request random bytes.
+  @retval TrueRandom bytes generation succeeded.
+  @retval False   Failed to request random bytes.
 
 **/
 STATIC
@@ -73,17 +38,17 @@ RandGetBytes (
 
   Ret = FALSE;
 
+  if (RandBuffer == NULL) {
+DEBUG((DEBUG_ERROR, "[OPENSSL_RAND_POOL] NULL RandBuffer. No random 
numbers are generated and your system is not secure\n"));
+ASSERT(FALSE); // Since we can't generate random numbers, we should 
assert. Otherwise we will just blow up later.
+return Ret;
+  }
+
+
   while (Length > 0) {
-//
-// Get random noise from platform.
-// If it failed, fallback to PerformanceCounter
-// If you really care about security, you must override
-// GetRandomNoise64FromPlatform.
-//
-Ret = GetRandomNoise64 ();
-if (Ret == FALSE) {
-  Ret = GetRandNoise64FromPerformanceCounter ();
-}
+// Use RngLib to get random number
+Ret = GetRandomNumber64();
+
 if (!Ret) {
   return Ret;
 }
@@ -100,125 +65,6 @@ RandGetBytes (
   return Ret;
 }
 
-/**
-  Creates a 128bit random value that is fully forward and backward prediction 
resistant,
-  suitable for seeding a NIST SP800-90 Compliant.
-  This function takes multiple random numbers from PerformanceCounter to 
ensure reseeding
-  and performs AES-CBC-MAC over the data to compute the seed value.
-
-  @param[out]  SeedBufferPointer to a 128bit buffer to store the random 
seed.
-
-  @retval TRUERandom seed generation succeeded.
-  @retval FALSE  Failed to request random bytes.
-
-**/
-STATIC
-BOOLEAN
-EFIAPI
-RandGetSeed128 (
-  OUT UINT8*SeedBuffer
-  )
-{
-  BOOLEAN Ret;
-  UINT8   RandByte[16];
-  UINT8   Key[16];
-  UINT8   Ffv[16];
-  UINT8   Xored[16];
-  UINT32  Index;
-  UINT32  Index2;
-  AES_KEY AESKey;
-
-  //
-  // Chose an arbitrary key and zero the feed_forward_value (FFV)
-  //
-  for (Index = 0; Index < 16; Index++) {
-Key[Index] = (UINT8) Index;
-Ffv[Index] = 0;
-  }
-
-  AES_set_encrypt_key (Key, 16 * 8, );
-
-  //
-  // Perform CBC_MAC over 32 * 128 bit values, with 10us gaps between 128 bit 
value
-  // The 10us gaps will ensure multiple reseeds within the system time with a 
large
-  // design margin.
-  //
-  for (Index = 0; Index < 32; Index++) {
-MicroSecondDelay (10);
-Ret = RandGetBytes (16, RandByte);
-if (!Ret) {
-  return Ret;
-}
-
-//
-// Perform XOR operations on two 128-bit value.
-//
-for (Index2 = 0; Index2 < 16; Index2++) {
-  Xored[Index2] = RandByte[Index2] ^ Ffv[Index2];
-}
-
-AES_encrypt (Xored, Ffv, );
-  }
-
-  for (Index = 0; Index < 16; Index++) {
-SeedBuffer[Index] = Ffv[Index];
-  }
-
-  return Ret;
-}
-
-/**
-  

[edk2-devel] [PATCH v3 3/3] MdePkg: BaseRngLibDxe: Add RngLib that uses RngDxe

2020-07-31 Thread Matthew Carlson
From: Matthew Carlson 

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Matthew Carlson 
---
 MdePkg/Library/BaseRngLibDxe/RngDxeLib.c   | 216 
 MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf |  38 
 MdePkg/MdePkg.dsc  |   4 +-
 3 files changed, 257 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseRngLibDxe/RngDxeLib.c 
b/MdePkg/Library/BaseRngLibDxe/RngDxeLib.c
new file mode 100644
index ..45bd6bad8f7a
--- /dev/null
+++ b/MdePkg/Library/BaseRngLibDxe/RngDxeLib.c
@@ -0,0 +1,216 @@
+/** @file
+ Provides an implementation of the library class RngLib that uses the Rng 
protocol.
+
+Copyright (c) Microsoft Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+MU_CHANGE: New file
+
+**/
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/**
+Routine Description:
+
+Generates a random number via the NIST
+800-9A algorithm.  Refer to
+http://csrc.nist.gov/groups/STM/cavp/documents/drbg/DRBGVS.pdf
+for more information.
+
+Arguments:
+
+Buffer  -- Buffer to receive the random number.
+BufferSize  -- Number of bytes in Buffer.
+
+Return Value:
+
+EFI_SUCCESS or underlying failure code.
+
+**/
+EFI_STATUS
+EFIAPI
+GenerateRandomNumberViaNist800Algorithm(
+  OUT UINT8* Buffer,
+  IN  UINTN  BufferSize
+  )
+{
+  EFI_STATUSStatus  = EFI_SUCCESS;
+  EFI_RNG_PROTOCOL* RngProtocol = NULL;
+
+  if (Buffer == NULL)
+  {
+  DEBUG((DEBUG_ERROR, "[%a] Buffer == NULL.\n", __FUNCTION__));
+  return EFI_INVALID_PARAMETER;
+  }
+
+  if (gBS == NULL)
+  {
+  DEBUG((DEBUG_ERROR, "[%a] GenerateRandomNumber, gBS == NULL.  Called too 
soon.\n", __FUNCTION__));
+  return EFI_LOAD_ERROR;
+  }
+
+  Status = gBS->LocateProtocol(, NULL, (VOID 
**));
+  if (EFI_ERROR(Status) || RngProtocol == NULL)
+  {
+  DEBUG((DEBUG_ERROR, "[%a] Could not locate RNG prototocol, Status = 
%r\n", __FUNCTION__, Status));
+  return Status;
+  }
+
+  Status = RngProtocol->GetRNG(RngProtocol, 
, BufferSize, Buffer);
+  DEBUG((DEBUG_INFO, "[%a] GetRNG algorithm CTR-256 - Status = %r\n", 
__FUNCTION__, Status));
+  if(!EFI_ERROR(Status))
+  {
+return Status;
+  }
+
+  Status = RngProtocol->GetRNG(RngProtocol, 
, BufferSize, Buffer);
+  DEBUG((DEBUG_INFO, "[%a] GetRNG algorithm HMAC-256 - Status = %r\n", 
__FUNCTION__, Status));
+  if(!EFI_ERROR(Status))
+  {
+return Status;
+  }
+
+  Status = RngProtocol->GetRNG(RngProtocol, 
, BufferSize, Buffer);
+  DEBUG((DEBUG_INFO, "[%a] GetRNG algorithm Hash-256 - Status = %r\n", 
__FUNCTION__, Status));
+  if(!EFI_ERROR(Status))
+  {
+return Status;
+  }
+  // If we get to this point, we have failed
+  DEBUG((DEBUG_ERROR, "[%a] GetRNG() failed, staus = %r\n", __FUNCTION__, 
Status));
+
+  return Status;
+}// GenerateRandomNumberViaNist800Algorithm()
+
+
+/**
+  Generates a 16-bit random number.
+
+  if Rand is NULL, return FALSE.
+
+  @param[out] Rand Buffer pointer to store the 16-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber16 (
+  OUT UINT16*Rand
+  )
+{
+  EFI_STATUS Status;
+
+  if (Rand == NULL)
+  {
+return FALSE;
+  }
+
+  Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, 2);
+  if (EFI_ERROR(Status))
+  {
+return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+  Generates a 32-bit random number.
+
+  if Rand is NULL, return FALSE.
+
+  @param[out] Rand Buffer pointer to store the 32-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber32 (
+  OUT UINT32*Rand
+  )
+{
+  EFI_STATUS Status;
+
+  if (Rand == NULL)
+  {
+return FALSE;
+  }
+
+  Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, 4);
+  if (EFI_ERROR(Status))
+  {
+return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+  Generates a 64-bit random number.
+
+  if Rand is NULL, return FALSE.
+
+  @param[out] Rand Buffer pointer to store the 64-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber64 (
+  OUT UINT64*Rand
+  )
+{
+  EFI_STATUS Status;
+
+  if (Rand == NULL)
+  {
+return FALSE;
+  }
+
+  Status = GenerateRandomNumberViaNist800Algorithm ((UINT8 *)Rand, 8);
+  if (EFI_ERROR(Status))
+  {
+return FALSE;
+  }
+  return TRUE;
+}
+
+/**
+  Generates a 128-bit random number.
+
+  if Rand is NULL, return FALSE.
+
+  @param[out] Rand Buffer pointer to store the 128-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/

[edk2-devel] [PATCH v3 0/3] Use RngLib instead of TimerLib for OpensslLib

2020-07-31 Thread Matthew Carlson
From: Matthew Carlson 

Fixes Bugzilla#1871
https://github.com/tianocore/edk2/pull/845


Matthew Carlson (3):
  CryptoPkg: OpensslLib: Use RngLib to generate entropy in rand_pool
  MdePkg: TimerRngLib: Added RngLib that uses TimerLib
  MdePkg: BaseRngLibDxe: Add RngLib that uses RngDxe

 CryptoPkg/Library/OpensslLib/rand_pool.c | 203 
++
 CryptoPkg/Library/OpensslLib/rand_pool_noise.c   |  29 ---
 CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c   |  43 
 MdePkg/Library/BaseRngLibDxe/RngDxeLib.c | 216 

 MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c  | 154 ++
 CryptoPkg/CryptoPkg.dsc  |   1 +
 CryptoPkg/Library/OpensslLib/OpensslLib.inf  |  15 +-
 CryptoPkg/Library/OpensslLib/OpensslLibCrypto.inf|  15 +-
 CryptoPkg/Library/OpensslLib/rand_pool_noise.h   |  29 ---
 MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf   |  38 
 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf |  38 
 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni |  17 ++
 MdePkg/MdePkg.dsc|   5 +-
 13 files changed, 489 insertions(+), 314 deletions(-)
 delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise.c
 delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise_tsc.c
 create mode 100644 MdePkg/Library/BaseRngLibDxe/RngDxeLib.c
 create mode 100644 MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c
 delete mode 100644 CryptoPkg/Library/OpensslLib/rand_pool_noise.h
 create mode 100644 MdePkg/Library/BaseRngLibDxe/BaseRngLibDxe.inf
 create mode 100644 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
 create mode 100644 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni

-- 
2.27.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63592): https://edk2.groups.io/g/devel/message/63592
Mute This Topic: https://groups.io/mt/75915445/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH v3 2/3] MdePkg: TimerRngLib: Added RngLib that uses TimerLib

2020-07-31 Thread Matthew Carlson
From: Matthew Carlson 

Added a new RngLib that provides random numbers from the TimerLib
using the performance counter. This is meant to be used for OpenSSL
to replicate past behavior. This should not be used in production as
a real source of entropy.

Cc: Michael D Kinney 
Cc: Liming Gao 
Cc: Zhiguang Liu 
Signed-off-by: Matthew Carlson 
---
 MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c  | 154 

 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf |  38 +
 MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.uni |  17 +++
 MdePkg/MdePkg.dsc|   3 +-
 4 files changed, 211 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c 
b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c
new file mode 100644
index ..8244a740555c
--- /dev/null
+++ b/MdePkg/Library/BaseRngLibTimerLib/RngLibTimer.c
@@ -0,0 +1,154 @@
+/** @file
+  BaseRng Library that uses the TimerLib to provide reasonably random numbers.
+  Do not use this on a production system.
+
+  Copyright (c) Microsoft Corporation.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include 
+#include 
+#include 
+#include 
+
+
+/**
+  Generates a 16-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand Buffer pointer to store the 16-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber16 (
+  OUT UINT16*Rand
+  )
+{
+  UINT32  Index;
+  UINT8* RandPtr;
+
+  ASSERT (Rand != NULL);
+
+  if (NULL == Rand) {
+return FALSE;
+  }
+
+  RandPtr = (UINT8 *) Rand;
+  // Get 2 bytes of random ish data
+  // This should take around 10ms
+  for (Index = 0; Index < 2; Index ++) {
+*RandPtr = (UINT8) (GetPerformanceCounter () & 0xFF);
+MicroSecondDelay (5); // delay to give chance for performance counter to 
catch up
+RandPtr++;
+  }
+  return TRUE;
+}
+
+/**
+  Generates a 32-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand Buffer pointer to store the 32-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber32 (
+  OUT UINT32*Rand
+  )
+{
+  UINT32  Index;
+  UINT8* RandPtr;
+
+  ASSERT (Rand != NULL);
+
+  if (NULL == Rand) {
+return FALSE;
+  }
+
+  RandPtr = (UINT8 *) Rand;
+  // Get 4 bytes of random ish data
+  // This should take around 20ms
+  for (Index = 0; Index < 4; Index ++) {
+*RandPtr = (UINT8) (GetPerformanceCounter () & 0xFF);
+MicroSecondDelay (5); // delay to give chance for performance counter to 
catch up
+RandPtr++;
+  }
+  return TRUE;
+}
+
+/**
+  Generates a 64-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand Buffer pointer to store the 64-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber64 (
+  OUT UINT64*Rand
+  )
+{
+  UINT32  Index;
+  UINT8* RandPtr;
+
+  ASSERT (Rand != NULL);
+
+  if (NULL == Rand) {
+return FALSE;
+  }
+
+  RandPtr = (UINT8 *) Rand;
+  // Get 8 bytes of random ish data
+  // This should take around 40ms
+  for (Index = 0; Index < 8; Index ++) {
+*RandPtr = (UINT8) (GetPerformanceCounter () & 0xFF);
+MicroSecondDelay (5); // delay to give chance for performance counter to 
catch up
+RandPtr++;
+  }
+
+  return TRUE;
+}
+
+/**
+  Generates a 128-bit random number.
+
+  if Rand is NULL, then ASSERT().
+
+  @param[out] Rand Buffer pointer to store the 128-bit random value.
+
+  @retval TRUE Random number generated successfully.
+  @retval FALSEFailed to generate the random number.
+
+**/
+BOOLEAN
+EFIAPI
+GetRandomNumber128 (
+  OUT UINT64*Rand
+  )
+{
+  ASSERT (Rand != NULL);
+  // This should take around 80ms
+
+  // Read first 64 bits
+  if (!GetRandomNumber64 (Rand)) {
+return FALSE;
+  }
+
+  // Read second 64 bits
+  return GetRandomNumber64 (++Rand);
+}
diff --git a/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf 
b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
new file mode 100644
index ..0d20fd13c1da
--- /dev/null
+++ b/MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
@@ -0,0 +1,38 @@
+## @file
+#  Instance of RNG (Random Number Generator) Library.
+#
+#  BaseRng Library that uses the TimerLib to provide reasonably random numbers.
+#  Do not use this on a production system as this uses the system performance
+#  counter rather than a true source of random in addition to have a weak 
random
+#  algorithm.
+#
+#  Copyright (c) Microsoft Corporation. All rights reserved.
+#
+#  SPDX-License-Identifier: 

Re: [edk2-devel] [Patch v2 0/2] Use RngLib instead of TimerLib for OpensslLib

2020-07-31 Thread Matthew Carlson via groups.io
Hey Mike!

Thanks for the comments. I've addressed the feedback below.

1. All good comments. I think I've addressed them all. New patch series should 
be coming soon.

2. This is a problem for BaseCryptLibOnProtocol. We can't use a null lib for 
RngLib since it explodes when it tries to seed OpenSSL with entropy. I think 
for now, let's stick with established dependencies and figure this out at a 
later date. I added an RngLib that uses the DXE RNG Protocol.

3. I don't see a typo?

Calls RandomNumber64 to fill
a buffer of arbitrary size with random bytes.

@param [in]   LengthSize of the buffer, in bytes,  to fill with.
@param [out]  RandBufferPointer to the buffer to store the random result.

@retval TrueRandom bytes generation succeeded.
@retval False   Failed to request random bytes.

--
- Matthew Carlson

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63591): https://edk2.groups.io/g/devel/message/63591
Mute This Topic: https://groups.io/mt/75890825/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] SimicsOpenBoardPkg: Update usage of functions to be removed

2020-07-31 Thread Agyeman, Prince


Reviewed-by: Prince Agyeman  

-Original Message-
From: Zhang, Shenglei  
Sent: Tuesday, July 28, 2020 8:34 PM
To: devel@edk2.groups.io
Cc: Agyeman, Prince 
Subject: [PATCH] SimicsOpenBoardPkg: Update usage of functions to be removed

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2777
With some functions to be deprecated, their usage in platforms should also be 
updated.

Cc: Agyeman Prince 
Signed-off-by: Shenglei Zhang 
---
 .../Library/BoardBdsHookLib/BoardBdsHookLib.c|  2 +-
 .../Intel/SimicsOpenBoardPkg/SimicsDxe/Platform.c|  4 ++--
 .../Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c   |  6 +++---
 .../Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c| 12 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git 
a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c 
b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
index 1058dbf3..ba4d2b02 100644
--- 
a/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBdsHookLib.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/Library/BoardBdsHookLib/BoardBds
+++ HookLib.c
@@ -1206,7 +1206,7 @@ VisitingFileSystemInstance (
   NULL,
   
   );
-  PcdSet64 (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
+  PcdSet64S (PcdEmuVariableEvent, (UINT64)(UINTN) mEmuVariableEvent);
 
   return EFI_SUCCESS;
 }
diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsDxe/Platform.c 
b/Platform/Intel/SimicsOpenBoardPkg/SimicsDxe/Platform.c
index b7fd4d1f..c856ff44 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/SimicsDxe/Platform.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsDxe/Platform.c
@@ -669,9 +669,9 @@ ExecutePlatformConfig (
 //
 // Pass the preferred resolution to GraphicsConsoleDxe via dynamic PCDs.
 //
-PcdSet32 (PcdVideoHorizontalResolution,
+PcdSet32S (PcdVideoHorizontalResolution,
   PlatformConfig.HorizontalResolution);
-PcdSet32 (PcdVideoVerticalResolution,
+PcdSet32S (PcdVideoVerticalResolution,
   PlatformConfig.VerticalResolution);
   }
 
diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c 
b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c
index 60aa54be..127afffc 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/MemDetect.c
@@ -155,7 +155,7 @@ GetFirstNonAddress (
 if (mBootMode != BOOT_ON_S3_RESUME) {
   DEBUG ((EFI_D_INFO, "%a: disabling 64-bit PCI host aperture\n",
 __FUNCTION__));
-  PcdSet64 (PcdPciMmio64Size, 0);
+  PcdSet64S (PcdPciMmio64Size, 0);
 }
 
 //
@@ -187,8 +187,8 @@ GetFirstNonAddress (
 // the GCD memory space map through our PciHostBridgeLib instance; here we
 // only need to set the PCDs.
 //
-PcdSet64 (PcdPciMmio64Base, Pci64Base);
-PcdSet64 (PcdPciMmio64Size, Pci64Size);
+PcdSet64S (PcdPciMmio64Base, Pci64Base);
+PcdSet64S (PcdPciMmio64Size, Pci64Size);
 DEBUG ((EFI_D_INFO, "%a: Pci64Base=0x%Lx Pci64Size=0x%Lx\n",
   __FUNCTION__, Pci64Base, Pci64Size));
   }
diff --git a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c 
b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c
index 0bec76e4..6963f39a 100644
--- a/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c
+++ b/Platform/Intel/SimicsOpenBoardPkg/SimicsPei/Platform.c
@@ -257,8 +257,8 @@ MemMapInitialization (
   //
   PciSize = 0xFC00 - PciBase;
   AddIoMemoryBaseSizeHob (PciBase, PciSize);
-  PcdSet64 (PcdPciMmio32Base, PciBase);
-  PcdSet64 (PcdPciMmio32Size, PciSize);
+  PcdSet64S (PcdPciMmio32Base, PciBase);  PcdSet64S (PcdPciMmio32Size, 
+ PciSize);
   AddIoMemoryBaseSizeHob (0xFEC0, SIZE_4KB);
   AddIoMemoryBaseSizeHob (0xFED0, SIZE_1KB);
   if (mHostBridgeDevId == INTEL_ICH10_DEVICE_ID) { @@ -300,8 +300,8 @@ 
MemMapInitialization (
 PciIoBase,
 PciIoSize
 );
-  PcdSet64 (PcdPciIoBase, PciIoBase);
-  PcdSet64 (PcdPciIoSize, PciIoSize);
+  PcdSet64S (PcdPciIoBase, PciIoBase);
+  PcdSet64S (PcdPciIoSize, PciIoSize);
 
   //
   // Add flash range.
@@ -367,7 +367,7 @@ MiscInitialization (
   ASSERT (FALSE);
   return;
   }
-  PcdSet16 (PcdSimicsX58HostBridgePciDevId, mHostBridgeDevId);
+  PcdSet16S (PcdSimicsX58HostBridgePciDevId, mHostBridgeDevId);
 
   //
   // If the appropriate IOspace enable bit is set, assume the ACPI PMBA @@ 
-483,7 +483,7 @@ ReserveEmuVariableNvStore (
   VariableStore,
   (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
 ));
-  PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);
+  PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
 }
 
 
--
2.18.0.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63590): https://edk2.groups.io/g/devel/message/63590
Mute This Topic: https://groups.io/mt/75858614/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  

Re: [edk2-devel] [PATCH 1/1] Add BhyvePkg, to support the bhyve hypervisor

2020-07-31 Thread Sean
This patch as committed is breaking CI.  It was not captured in PR 
because the PR optimizes to detect packages impacted by the commits and 
the BhyvePkg addition is not depended on by other packages (that are in 
CI).  BhyvePkg which is nested inside OvmfPkg ( a violation of DEC spec: 
 see 
https://edk2-docs.gitbook.io/edk-ii-dec-specification/2_dec_file_overview 
paragraph 4) does not support CI so it is not tested but now that it is 
in the edk2 tree it is causing the other packages to fail.



You can see the ReadMe badge showing the broken state of edk2 master. 
The build with logs can be seen here 
https://dev.azure.com/tianocore/edk2-ci/_build/results?buildId=10494=logs=ec42d809-3c3b-54a9-276c-e54a8b9aaee9=596e0656-4def-5804-b10b-1585519aa2e8 
and some of the relevant failures are added below.



ERROR - Error Duplicate guid:  24A2D66F-EEDD-4086-9042-F26E4797EE69 (2)
	GUID: 24A2D66F-EEDD-4086-9042-F26E4797EE69 NAME: 
gRootBridgesConnectedEventGroupGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: 24A2D66F-EEDD-4086-9042-F26E4797EE69 NAME: 
gRootBridgesConnectedEventGroupGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gEfiLegacyBiosProtocolGuid (2)
	GUID: DB9A1E3D-45CB-4ABB-853B-E5387FDB2E2D NAME: 
gEfiLegacyBiosProtocolGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: DB9A1E3D-45CB-4ABB-853B-E5387FDB2E2D NAME: 
gEfiLegacyBiosProtocolGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gIoMmuAbsentProtocolGuid (2)
	GUID: F8775D50-8ABD-4ADF-92AC-853E51F6C8DC NAME: 
gIoMmuAbsentProtocolGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: F8775D50-8ABD-4ADF-92AC-853E51F6C8DC NAME: 
gIoMmuAbsentProtocolGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gOvmfPlatformConfigGuid (2)
	GUID: 7235C51C-0C80-4CAB-87AC-3B084A6304B1 NAME: 
gOvmfPlatformConfigGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: 7235C51C-0C80-4CAB-87AC-3B084A6304B1 NAME: 
gOvmfPlatformConfigGuid FILE: /home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gRootBridgesConnectedEventGroupGuid (2)
	GUID: 24A2D66F-EEDD-4086-9042-F26E4797EE69 NAME: 
gRootBridgesConnectedEventGroupGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: 24A2D66F-EEDD-4086-9042-F26E4797EE69 NAME: 
gRootBridgesConnectedEventGroupGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gUefiOvmfPkgTokenSpaceGuid (2)
	GUID: 93BB96AF-B9F2-4EB8-9462-E0BA74564236 NAME: 
gUefiOvmfPkgTokenSpaceGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: 93BB96AF-B9F2-4EB8-9462-E0BA74564236 NAME: 
gUefiOvmfPkgTokenSpaceGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gVirtioDeviceProtocolGuid (2)
	GUID: FA920010-6785-4941-B6EC-498C579F160A NAME: 
gVirtioDeviceProtocolGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: FA920010-6785-4941-B6EC-498C579F160A NAME: 
gVirtioDeviceProtocolGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


ERROR - Error Duplicate name:  gVirtioMmioTransportGuid (2)
	GUID: 837DCA9E-E874-4D82-B29A-23FE0E23D1E2 NAME: 
gVirtioMmioTransportGuid FILE: /home/vsts/work/1/s/OvmfPkg/OvmfPkg.dec
	GUID: 837DCA9E-E874-4D82-B29A-23FE0E23D1E2 NAME: 
gVirtioMmioTransportGuid FILE: 
/home/vsts/work/1/s/OvmfPkg/Bhyve/BhyvePkg.dec


and

ERROR - Dependency Check: Invalid Dependency INF: 
OvmfPkg/Bhyve/Library/BhyveFwCtlLib/BhyveFwCtlLib.inf depends on pkg 
OvmfPkg/Bhyve/BhyvePkg.dec
ERROR - Dependency Check: Invalid Dependency INF: 
OvmfPkg/Bhyve/BhyveRfbDxe/BhyveRfbDxe.inf depends on pkg 
OvmfPkg/Bhyve/BhyvePkg.dec
ERROR - Dependency Check: Invalid Dependency INF: 
OvmfPkg/Bhyve/AcpiPlatformDxe/AcpiPlatformDxe.inf depends on pkg 
OvmfPkg/Bhyve/BhyvePkg.dec



The errors can be easily resolved but the nested packages is a bigger 
problem.



Thanks
Sean





On 7/31/2020 6:10 AM, Laszlo Ersek wrote:

On 07/31/20 15:07, Laszlo Ersek wrote:

On 07/31/20 07:17, Rebecca Cran wrote:

On 7/13/20 2:25 PM, Rebecca Cran wrote:


On 7/13/20 12:09 PM, Laszlo Ersek wrote:


Can you please ping me when the PatchCheck.py problem has been solved,
so I can go ahead with the merge?


Will do.



Hi Laszlo,


I just rebased the bhyve commit against the latest edk2 master with no
conflicts, and all CI checks passed
(https://github.com/tianocore/edk2/pull/841).

So I think it's ready to go into the tree.


Thanks for the ping.

I've had your patch applied locally, from the list, on top of
then-master HEAD f45e3a4afa65, ready for pushing.

I've now fetched your branch (from your PR above), at commit
d6ec30afebe6. I've also rebased my local branch (see above) on top of
current master (137c2c6eff67). Your rebase and my rebase are identical
(except my version carries your original Message-Id for the patch, plus
my Acked-by given earlier).

Thus I've submitted the following PR, using my rebased branch (including
the 

[edk2-devel] [PATCH] Check return status on calls to GetTime()

2020-07-31 Thread Grant Likely
Not all platforms implement GetTime(), but the SCT just assumes calls to
GetTime will be successful. If GetTime() doesn't return EFI_SUCCESS,
then the EFI_TIME value will be uninitialized data.

Fix by checking the GetTime() return code. If it doesn't return
EFI_SUCCESS, then use the traditional 1/1/1970 epoch so that the test
report at least looks sane, but it is obvious that we don't have a valid
timestamp.

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

Cc: G Edhaya Chandran 
Cc: Heinrich Schuchardt 
Cc: Samer El-Haj-Mahmoud 
Signed-off-by: Grant Likely 
---
 .../SimpleNetwork/SimpleNetworkENTSTestCase.c | 26 +--
 .../MiscBootServicesBBTestFunction.c  |  8 --
 .../DriverBindingBBTestFunction.c |  5 +++-
 .../SCT/Drivers/StandardTest/StandardTest.c   | 11 +---
 .../Framework/ENTS/EasDispatcher/Core/Eas.c   |  9 +--
 .../ENTS/EasDispatcher/Exec/EasCmdDisp.c  | 20 +-
 6 files changed, 57 insertions(+), 22 deletions(-)

diff --git 
a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
 
b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
index 9c8d2a70..5579be7e 100644
--- 
a/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
+++ 
b/uefi-sct/SctPkg/TestCase/RIVL/Protocol/SimpleNetwork/SimpleNetworkENTSTestCase.c
@@ -24,6 +24,8 @@ Abstract:
 
 #include "SimpleNetworkENTSTestCase.h"
 
+static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
+
 //
 // SimpleNetwork.Start
 //
@@ -928,7 +930,8 @@ Returns:
   Status  = EFI_SUCCESS;
   tBS->Stall (5000);
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
   for (Index = 0; Index < 1;) {
 Status = SimpleNetwork->Transmit (
   SimpleNetwork,
@@ -964,7 +967,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < TransmitPattern1Number;) {
 Status = SimpleNetwork->Transmit (
@@ -1002,7 +1006,8 @@ Returns:
   }
 
 End:
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *TransmitPattern1Status = Status;
 
@@ -1125,7 +1130,8 @@ Returns:
   Status  = EFI_SUCCESS;
   tBS->Stall (5000);
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
   for (Index = 0; Index < 1;) {
 Status = SimpleNetwork->Transmit (
   SimpleNetwork,
@@ -1161,7 +1167,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < TransmitPattern2Number;) {
 Status = SimpleNetwork->Transmit (
@@ -1199,7 +1206,8 @@ Returns:
   }
 
 End:
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *TransmitPattern1Status = Status;
 
@@ -1326,7 +1334,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+BeginTime = Epoch;
 
   for (Index = 1; Index < ReceivePattern1Number;) {
 *ReceivePattern1BufferSize = BufferSizeOrg;
@@ -1346,7 +1355,8 @@ Returns:
 }
   }
 
-  tRT->GetTime (, NULL);
+  if (tRT->GetTime (, NULL) != EFI_SUCCESS)
+EndTime = Epoch;
 
   *ReceivePattern1Status = Status;
 
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
index 1d231d8c..3a530282 100644
--- 
a/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
+++ 
b/uefi-sct/SctPkg/TestCase/UEFI/EFI/BootServices/MiscBootServices/BlackBoxTest/MiscBootServicesBBTestFunction.c
@@ -27,6 +27,8 @@ Abstract:
 #include "SctLib.h"
 #include "MiscBootServicesBBTestMain.h"
 
+static EFI_TIME Epoch = { .Year = 1970, .Month = 1, .Day = 1 };
+
 /**
  *  Entrypoint for gtBS->SetWatchdogTimer() Interface Test.
  *  @param This a pointer of EFI_BB_TEST_PROTOCOL.
@@ -821,13 +823,15 @@ BBTestStallInterfaceTest (
 //
 // 4.2.2.1  Stall must succeed.
 //
-gtRT->GetTime (, NULL);
+if (gtRT->GetTime (, NULL) != EFI_SUCCESS)
+  StartTime = Epoch;
 OldTpl = gtBS->RaiseTPL (TplArray[Index]);
 Status = gtBS->Stall (
  1000
  );
 gtBS->RestoreTPL (OldTpl);
-gtRT->GetTime (, NULL);
+if (gtRT->GetTime (, NULL) != EFI_SUCCESS)
+  EndTime = Epoch;
 if (Status == EFI_SUCCESS) {
   AssertionType = EFI_TEST_ASSERTION_PASSED;
 } else {
diff --git 
a/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/DriverBinding/BlackBoxTest/DriverBindingBBTestFunction.c
 
b/uefi-sct/SctPkg/TestCase/UEFI/IHV/Protocol/DriverBinding/BlackBoxTest/DriverBindingBBTestFunction.c
index 

[edk2-devel] [PATCH 4/8] DynamicTablesPkg: Update ConfigurationManagerProtocol

2020-07-31 Thread Tomas Pilar (tpilar)
The Configuration Manager Protocol is updated to include
a FreeObject function that must be used by the callers to
GetObject to clean up any dynamic allocations and other resources
reserved by the Configuration Manager in the process of fulfilling the
request in GetObject.

A NULL inline static FreeObject function is provided for the ease
of transition for v1.0 managers.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../Protocol/ConfigurationManagerProtocol.h   | 83 ++-
 1 file changed, 80 insertions(+), 3 deletions(-)

diff --git a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h 
b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
index 7de1be3b23..72bf3c79bc 100644
--- a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
+++ b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h
@@ -25,7 +25,7 @@
 
 /** This macro defines the Configuration Manager Protocol Revision.
 */
-#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION  CREATE_REVISION (1, 0)
+#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION  CREATE_REVISION (1, 1)
 
 #pragma pack(1)
 
@@ -35,10 +35,18 @@
 typedef struct ConfigurationManagerProtocol 
EDKII_CONFIGURATION_MANAGER_PROTOCOL;
 typedef struct PlatformRepositoryInfo   EDKII_PLATFORM_REPOSITORY_INFO;
 
-/** The GetObject function defines the interface implemented by the
+/** The GetObject function defines the interface of the
 Configuration Manager Protocol for returning the Configuration
 Manager Objects.
 
+If Token is CM_NULL_TOKEN, the function provides in its output all
+the objects of the given CmObjectId. If the Token is not CM_NULL_TOKEN,
+the function provides only those object that match both the CmObjectId
+and Token.
+
+The memory in CmObject.Data may be static or dynamic. The caller of this
+function must call FreeObject on the CmObject populated by this function.
+
   @param [in]  ThisPointer to the Configuration Manager Protocol.
   @param [in]  CmObjectId  The Configuration Manager Object ID.
   @param [in]  Token   An optional token identifying the object. If
@@ -62,10 +70,24 @@ EFI_STATUS
   IN  OUT   CM_OBJ_DESCRIPTOR * CONST CmObject
   );
 
-/** The SetObject function defines the interface implemented by the
+/** The SetObject function defines the interface of the
 Configuration Manager Protocol for updating the Configuration
 Manager Objects.
 
+If Token is CM_NULL_TOKEN, and CmObject is not NULL, then the objects
+in the configuration manager that match the CmObjectId and do not
+have an associated cross reference Token are replaced by the contents of
+CmObject.
+
+If Token is not CM_NULL_TOKEN and CmObject is not NULL, then the objects
+that match both CmObjectId and Token in the configuration manager are
+replaced with the contents of CmObject.
+
+If CmObject is NULL, then objects that match the CmObjectId and Token
+are removed from the configuration manager. If Token is also CM_NULL_TOKEN,
+then all objects of given CmObjectId are removed, regardless of their
+cross-reference Token.
+
   @param [in]  ThisPointer to the Configuration Manager Protocol.
   @param [in]  CmObjectId  The Configuration Manager Object ID.
   @param [in]  Token   An optional token identifying the object. If
@@ -90,6 +112,29 @@ EFI_STATUS
   INCM_OBJ_DESCRIPTOR * CONST CmObject
   );
 
+/** The FreeObject function defines the interface of the
+Configuration Manager Protocol for correctly freeing resources
+that have been reserved by calls to the GetObject interface.
+
+The caller of GetObject must use this function to dispose of CmObject
+populated by the GetObject call when the CmObject is no longer needed.
+
+If an implementation of the Configuration Manager Protocol does not
+use dynamically allocated memory, this function should simply return
+EFI_SUCCESS.
+
+@param [in]  This Pointer to the Configuration Manager Protocol
+@param [in]  CmObject Pointer to the CmObject that has been populated
+  by the GetObject function and is to be destroyed.
+@retval EFI_SUCCESS   The CmObject was successfully destroyed
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EDKII_CONFIGURATION_MANAGER_FREE_OBJECT) (
+  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST This,
+  INCM_OBJ_DESCRIPTOR *   CmObject
+  );
+
 /** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the
 Configuration Manager Protocol interface.
 */
@@ -111,12 +156,44 @@ typedef struct ConfigurationManagerProtocol {
   provisioned by the Configuration Manager.
   */
   EDKII_PLATFORM_REPOSITORY_INFO* PlatRepoInfo;
+
+  /** The interface used to destroy CmObject instances
+  populated by calls to GetObject
+  */
+  

[edk2-devel] [PATCH 6/8] DynamicTablesPkg/TableHelperLib: User friendly strings

2020-07-31 Thread Tomas Pilar (tpilar)
Add user friendly strings for CmObjectIds to TableHelperLib
and add debug print invocations to common helper methods.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../ConfigurationManagerDumpApp.c | 13 +--
 .../ConfigurationManagerDumpApp.h |  8 --
 .../ConfigurationManagerDumpApp.inf   |  3 +-
 .../ConfigurationObjectStrings.c  | 50 --
 .../Include/Library/TableHelperLib.h  | 12 +++
 .../ConfigurationObjectStrings.c  | 92 +++
 .../Common/TableHelperLib/TableHelperLib.inf  |  1 +
 7 files changed, 109 insertions(+), 70 deletions(-)
 delete mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
 delete mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
 create mode 100644 
DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c

diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
index 15936c78c1..20977c1b82 100644
--- 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
+++ 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
@@ -1,10 +1,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
-#include "ConfigurationManagerDumpApp.h"
-
 EDKII_CONFIGURATION_MANAGER_PROTOCOL *mCfgMgr;
 
 EFI_STATUS
@@ -33,10 +32,7 @@ UefiMain(
   continue;
 }
 
-Print (
-  L"<%s>::<%s>\n",
-  ObjectNameSpaceString[EObjNameSpaceStandard],
-  StdObjectString[ObjectId - EObjNameSpaceStandard]);
+Print (L"<%s>\n", CmObjectIdName (ObjectId));
 
 Print (
   L"Id=%x Size=0x%x at=%p count=%d\n",
@@ -54,10 +50,7 @@ UefiMain(
   continue;
 }
 
-Print (
-  L"<%s>::<%s>\n",
-  ObjectNameSpaceString[EObjNameSpaceArm],
-  ArmObjectString[ObjectId - EObjNameSpaceArm]);
+Print (L"<%s>\n", CmObjectIdName(ObjectId));
 
 Print (
   L"Id=%x Size=0x%x at=%p count=%d\n",
diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
deleted file mode 100644
index 5017d55b4a..00
--- 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef CONFIGURATION_MANAGER_DUMP_APP_H_
-#define CONFIGURATION_MANAGER_DUMP_APP_H_
-
-extern CHAR16 *ArmObjectString[];
-extern CHAR16 *ObjectNameSpaceString[];
-extern CHAR16 *StdObjectString[];
-
-#endif
diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
index 9f8beb916d..f930ca3dcb 100644
--- 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
+++ 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
@@ -23,8 +23,6 @@
 
 [Sources]
   ConfigurationManagerDumpApp.c
-  ConfigurationManagerDumpApp.h
-  ConfigurationObjectStrings.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -32,6 +30,7 @@
   DynamicTablesPkg/DynamicTablesPkg.dec
 
 [LibraryClasses]
+  TableHelperLib
   UefiLib
   UefiBootServicesTableLib
   UefiApplicationEntryPoint
diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
deleted file mode 100644
index ad8dbb6354..00
--- 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c
+++ /dev/null
@@ -1,50 +0,0 @@
-
-CHAR16 *ArmObjectString[] = {
-  L"Reserved",
-  L"Boot Architecture Info",
-  L"CPU Info",
-  L"Power Management Profile Info",
-  L"GIC CPU Interface Info",
-  L"GIC Distributor Info",
-  L"GIC MSI Frame Info",
-  L"GIC Redistributor Info",
-  L"GIC ITS Info",
-  L"Serial Console Port Info",
-  L"Serial Debug Port Info",
-  L"Generic Timer Info",
-  L"Platform GT Block Info",
-  L"Generic Timer Block Frame Info",
-  L"Platform Generic Watchdog",
-  L"PCI Configuration Space Info",
-  L"Hypervisor Vendor Id",
-  L"Fixed feature flags for FADT",
-  L"ITS Group",
-  L"Named Component",
-  L"Root Complex",
-  L"SMMUv1 or SMMUv2",
-  L"SMMUv3",
-  L"PMCG",
-  L"GIC ITS Identifier Array",
-  L"ID Mapping Array",
-  L"SMMU Interrupt Array",
-  L"Processor Hierarchy Info",
-  L"Cache Info",
-  L"Processor Node ID Info",
-  L"CM Object Reference",
-  L"Memory Affinity Info",
-  L"Device Handle Acpi",
-  L"Device Handle Pci",
-  L"Generic Initiator Affinity"
-};
-
-CHAR16 *ObjectNameSpaceString[] = {
-  L"Standard Objects Namespace",
-  L"ARM Objects Namespace",
-  L"OEM Objects Namespace"

[edk2-devel] [PATCH 7/8] DynamicTablesPkg: Simplify AddAcpiHeader, CfgMgrGetInfo

2020-07-31 Thread Tomas Pilar (tpilar)
Simplify the methods to use the other object getter methods.
The methods no longer need CfgMgr context parameter, the getter
helpers retrieve the singleton platform protocol.

The CfgMgrGetInfo always allocates the memory that is passed to the caller.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../DynamicTableManagerDxe.c  | 20 ++--
 .../Include/Library/TableHelperLib.h  | 23 ++---
 .../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c   | 10 +-
 .../Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c   | 12 +--
 .../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c   |  8 +-
 .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c   |  8 +-
 .../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c   |  8 +-
 .../Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c   |  8 +-
 .../Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c   |  8 +-
 .../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c   | 10 +-
 .../Acpi/Arm/AcpiSratLibArm/SratGenerator.c   |  8 +-
 .../Common/TableHelperLib/TableHelper.c   | 97 ---
 .../Common/TableHelperLib/TableHelperLib.inf  |  3 +-
 13 files changed, 56 insertions(+), 167 deletions(-)

diff --git 
a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c 
b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
index e27dcaf374..b194a38659 100644
--- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
+++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDxe.c
@@ -661,7 +661,7 @@ DynamicTableManagerDxeInitialize (
 {
   EFI_STATUS Status;
   EDKII_CONFIGURATION_MANAGER_PROTOCOL * CfgMgrProtocol;
-  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO* CfgMfrInfo;
+  CM_STD_OBJ_CONFIGURATION_MANAGER_INFO* CfgMgrInfo;
   EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL * TableFactoryProtocol;
 
   // Locate the Dynamic Table Factory
@@ -695,7 +695,7 @@ DynamicTableManagerDxeInitialize (
 return Status;
   }
 
-  Status = GetCgfMgrInfo (CfgMgrProtocol, );
+  Status = CfgMgrGetInfo ();
   if (EFI_ERROR (Status)) {
 DEBUG ((
   DEBUG_ERROR,
@@ -708,15 +708,17 @@ DynamicTableManagerDxeInitialize (
   DEBUG ((
 DEBUG_INFO,
 "INFO: Configuration Manager Version = 0x%x, OemID = %c%c%c%c%c%c\n",
-CfgMfrInfo->Revision,
-CfgMfrInfo->OemId[0],
-CfgMfrInfo->OemId[1],
-CfgMfrInfo->OemId[2],
-CfgMfrInfo->OemId[3],
-CfgMfrInfo->OemId[4],
-CfgMfrInfo->OemId[5]
+CfgMgrInfo->Revision,
+CfgMgrInfo->OemId[0],
+CfgMgrInfo->OemId[1],
+CfgMgrInfo->OemId[2],
+CfgMgrInfo->OemId[3],
+CfgMgrInfo->OemId[4],
+CfgMgrInfo->OemId[5]
 ));
 
+  FreePool(CfgMgrInfo);
+
   Status = ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol);
   if (EFI_ERROR (Status)) {
 DEBUG ((
diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h 
b/DynamicTablesPkg/Include/Library/TableHelperLib.h
index 9269e77377..0dce81827b 100644
--- a/DynamicTablesPkg/Include/Library/TableHelperLib.h
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -194,33 +194,26 @@ CfgMgrGetObjects (
   OUT UINT32 * ItemCountOPTIONAL
   );
 
-/** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
+/** The CfgMgrGetInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_INFO
 object from the Configuration Manager.
 
-  @param [in]  CfgMgrProtocol Pointer to the Configuration Manager protocol
-  interface.
   @param [out] CfgMfrInfo Pointer to the Configuration Manager Info
   object structure.
 
   @retval EFI_SUCCESS   The object is returned.
-  @retval EFI_INVALID_PARAMETER The Object ID is invalid.
   @retval EFI_NOT_FOUND The requested Object is not found.
-  @retval EFI_BAD_BUFFER_SIZE   The size returned by the Configuration
-Manager is less than the Object size.
 **/
 EFI_STATUS
 EFIAPI
-GetCgfMgrInfo (
-  IN  CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL  * CONST  CfgMgrProtocol,
+CfgMgrGetInfo (
   OUT   CM_STD_OBJ_CONFIGURATION_MANAGER_INFO**CfgMfrInfo
   );
 
-/** The AddAcpiHeader function updates the ACPI header structure. It uses the
-ACPI table Generator and the Configuration Manager protocol to obtain the
-information required for constructing the header.
+/** The AddAcpiHeader function updates the ACPI header structure pointed by
+the AcpiHeader. It utilizes the ACPI table Generator and the Configuration
+Manager protocol to obtain any information required for constructing the
+header.
 
-  @param [in] CfgMgrProtocol Pointer to the Configuration Manager
- protocol interface.
   @param [in] Generator  Pointer to the ACPI table Generator.
   @param [in,out] AcpiHeader Pointer to the ACPI table header to be
  updated.
@@ -230,14 +223,10 @@ GetCgfMgrInfo (
   @retval EFI_SUCCESS   The 

[edk2-devel] [PATCH 5/8] DynamicTablesPkg: Add CfgMgrProtocol helper functions

2020-07-31 Thread Tomas Pilar (tpilar)
Add functions abstracting adding and removing of objects using
the ConfigurationManagerProtocol to TableHelperLib. Also add
helpers for writing component library constructors for component
libraries populating a ConfigurationManager.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../Include/Library/TableHelperLib.h  | 170 
 .../Common/TableHelperLib/TableHelper.c   | 379 +-
 .../Common/TableHelperLib/TableHelperLib.inf  |   6 +
 3 files changed, 554 insertions(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h 
b/DynamicTablesPkg/Include/Library/TableHelperLib.h
index e4a8dfa046..0d3d1bbd60 100644
--- a/DynamicTablesPkg/Include/Library/TableHelperLib.h
+++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h
@@ -12,6 +12,176 @@
 #ifndef TABLE_HELPER_LIB_H_
 #define TABLE_HELPER_LIB_H_
 
+#include 
+
+/**
+  Get a unique token that can be used for configuration object
+  cross referencing.
+
+  @retval Unique arbitrary cross reference token.
+**/
+UINTN
+EFIAPI
+GetNewToken();
+
+/**
+  Return the count of objects of a given ObjectId.
+
+  @param[in]  CmObjectId   The id of the desired configuration objects.
+  @param[out] ItemCountNumber of objects with given ObjectId.
+**/
+EFI_STATUS
+EFIAPI
+CfgMgrCountObjects (
+  IN   CONST  CM_OBJECT_ID CmObjectId,
+  OUT UINT32   *ItemCount
+  );
+
+/**
+  Get a single object form the configuration manager with the
+  matching ObjectId regardless of any cross reference tokens.
+
+  @param[in]  CmObjectId   The id of the desired configuration object
+  @param[out] Buffer   Buffer containing the payload of the CmObject.
+
+  @retval EFI_SUCCESS  Payload was successfully returned
+  @retval EFI_NOT_FOUNDThere was no such object
+  @retval EFI_UNSUPPORTED  ConfigurationManangerProtocol is not installed
+**/
+EFI_STATUS
+EFIAPI
+CfgMgrGetSimpleObject(
+  IN  CONST CM_OBJECT_ID CmObjectId,
+  OUT VOID **Buffer
+  );
+
+/**
+  Prototype for an initialiser function to be used by component
+  libraries that are linked as NULL libraries to a Configuration
+  Manager binary and used to populate said Configuration Manager
+  with objects.
+
+  @param[in] CfgMgrProtocol  The newly installed ConfigurationManagerProtocol
+ that can be used by the library to populate the
+ Configuration Manager with objects.
+**/
+typedef EFI_STATUS (EFIAPI *CFG_MGR_COMPONENT_LIB_INIT) (
+  IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol
+  );
+
+/**
+  Register a callback inintialiser to be called when a configuration
+  manager is installed. The initialiser function is expected to
+  populate the newly installed configuration manager with objects when
+  called.
+
+  This helper should be used by component libraries that want to
+  provide configuration objects and are to be linked in as NULL
+  libraries into the configuration manager binary.
+
+  @param[in] InitFunction   An initialiser function that will be called when
+a configuration manager becomes available.
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate necessary memory.
+  @retval EFI_SUCCESSRegistration was successful.
+**/
+EFI_STATUS
+EFIAPI
+RegisterForCfgManager (
+  IN CONST CFG_MGR_COMPONENT_LIB_INIT InitFunction
+  );
+
+/**
+  Remove a configuration object from the configuration manager. If a
+  cross reference token is supplied, only objects referenced by that
+  token will be removed. If a token is not supplied, all objects of the
+  given type will be removed.
+
+  @param[in] CmObjectId   The id of the object that is to be removed.
+  @param[in] TokenUnique cross-reference token of the object to be 
removed.
+
+  @retval EFI_UNSUPPORTED There is no configuration manager installed.
+  @retval EFI_NOT_FOUND   The combination of id and token was not found in the
+  configuration manager.
+  @retval EFI_SUCCESS Object was successfully deleted.
+**/
+EFI_STATUS
+EFIAPI
+CfgMgrRemoveObject (
+  IN  CONST CM_OBJECT_ID  CmObjectId,
+  IN  CONST CM_OBJECT_TOKEN   Token OPTIONAL
+  );
+
+/**
+  Add an instance of object to the configuration manager. If an object with
+  the specified object id and token already exists in the manager, append the
+  provided object to the existing list. Otherwise, create a new list with this
+  object being the only member.
+
+  @param[in] CmObjectId The id of the object that is to be added.
+  @param[in] Token  The unique cross-reference token for this object.
+  @param[in] Buffer The instance of the object being added.
+  @param[in] BufferSize Size of Buffer in bytes.
+
+  @retval EFI_OUT_OF_RESOURCES   Failed to allocate required memory when 
appending data
+  @retval EFI_UNSUPPORTEDThere is no Configuration 

[edk2-devel] [PATCH 1/8] DynamicTablesPkg: Include BaseStackCheckLib

2020-07-31 Thread Tomas Pilar (tpilar)
In GCC10 the __stack_chk_guard global variable no longer exists,
the stack checking is done a different way. This patch includes the
BaseStackCheckLib as a NULL library which provides the global variable
explicitly. This fixes compilation with GCC10.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 DynamicTablesPkg/DynamicTablesPkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc 
b/DynamicTablesPkg/DynamicTablesPkg.dsc
index 02f04447ff..346fa8ccdd 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dsc
+++ b/DynamicTablesPkg/DynamicTablesPkg.dsc
@@ -33,6 +33,7 @@
 
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+  NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
   PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf
 
 [Components.common]
-- 
2.25.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63580): https://edk2.groups.io/g/devel/message/63580
Mute This Topic: https://groups.io/mt/75910564/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 0/8] ConfigurationManagerProtocol update

2020-07-31 Thread Tomas Pilar (tpilar)
This patch series updates the configuration manager protocol
API to allow for configuration managers that dynamically allocate
memory when servicing calls from the Dynamic Tables framework.

Helper methods are provided in TableHelperLib to ensure
backwards compatibility with configuration managers that
do not allocate the memory that is provided to the caller.
Additional methods are provided to reduce the difficulty of
developing Dynamic Tables extensions and Configuration Managers.

The Dynamic Tables framework is simplified to use the new revision 
of the protocol, while retaining backwards compatbility.

The refactoring was tested using the AcpiViewApp and the
Configuration Manager that is included in the JunoPkg, running
in the SbsaQemu platform. The resulting dump of the ACPI tables
is identical between a build that includes these patches and
a build without this patchset. 

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
--

Tomas Pilar (8):
  DynamicTablesPkg: Include BaseStackCheckLib
  DynamicTablesPkg: Fold Namespaces into CmObjectId Enums
  DynamicTablesPkg: Add ConfigurationManagerDumpApp
  DynamicTablesPkg: Update ConfigurationManagerProtocol
  DynamicTablesPkg: Add CfgMgrProtocol helper functions
  DynamicTablesPkg/TableHelperLib: User friendly strings
  DynamicTablesPkg: Simplify AddAcpiHeader, CfgMgrGetInfo
  DynamicTablesPkg: Remove GET_OBJECT_LIST

 .../ConfigurationManagerDumpApp.c |   69 ++
 .../ConfigurationManagerDumpApp.inf   |   41 +
 .../DynamicTableFactoryDxe.c  |1 -
 .../DynamicTableManagerDxe.c  |   54 +-
 DynamicTablesPkg/DynamicTablesPkg.dsc |7 +
 .../Include/ArmNameSpaceObjects.h |3 +-
 .../Include/ConfigurationManagerHelper.h  |  126 --
 .../Include/ConfigurationManagerNameSpace.h   |   43 +
 .../Include/ConfigurationManagerObject.h  |   57 +-
 .../Include/Library/TableHelperLib.h  |  205 +++-
 .../Protocol/ConfigurationManagerProtocol.h   |   83 +-
 .../Include/StandardNameSpaceObjects.h|7 +-
 .../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c   |   44 +-
 .../Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c   |  211 +---
 .../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c   |  242 ++--
 .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c   | 1066 +
 .../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c   |  312 ++---
 .../Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c   |  108 +-
 .../Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c   |  295 ++---
 .../Acpi/Arm/AcpiRawLibArm/RawGenerator.c |1 -
 .../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c   |   45 +-
 .../Acpi/Arm/AcpiSratLibArm/SratGenerator.c   |  447 +++
 .../ConfigurationObjectStrings.c  |   92 ++
 .../Common/TableHelperLib/TableHelper.c   |  468 ++--
 .../Common/TableHelperLib/TableHelperLib.inf  |   10 +-
 25 files changed, 1766 insertions(+), 2271 deletions(-)
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
 delete mode 100644 DynamicTablesPkg/Include/ConfigurationManagerHelper.h
 create mode 100644 DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h
 create mode 100644 
DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStrings.c

-- 
2.25.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63579): https://edk2.groups.io/g/devel/message/63579
Mute This Topic: https://groups.io/mt/75910561/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 3/8] DynamicTablesPkg: Add ConfigurationManagerDumpApp

2020-07-31 Thread Tomas Pilar (tpilar)
Simple application to dump the contents of the configuration
manager loaded in the platform to the screen.

There is no provision in the ConfigurationManagerProtocol for
informing consumers of the contents of the database, so the app
scans through the known namespaces using the GetObject method.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../ConfigurationManagerDumpApp.c | 76 +++
 .../ConfigurationManagerDumpApp.h |  8 ++
 .../ConfigurationManagerDumpApp.inf   | 42 ++
 .../ConfigurationObjectStrings.c  | 50 
 DynamicTablesPkg/DynamicTablesPkg.dsc |  6 ++
 5 files changed, 182 insertions(+)
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
 create mode 100644 
DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationObjectStrings.c

diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
new file mode 100644
index 00..15936c78c1
--- /dev/null
+++ 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.c
@@ -0,0 +1,76 @@
+#include 
+#include 
+#include 
+#include 
+
+#include "ConfigurationManagerDumpApp.h"
+
+EDKII_CONFIGURATION_MANAGER_PROTOCOL *mCfgMgr;
+
+EFI_STATUS
+EFIAPI
+UefiMain(
+  IN  EFI_HANDLEImageHandle,
+  IN  EFI_SYSTEM_TABLE   *  SystemTable
+  )
+{
+  EFI_STATUS Status = gBS->LocateProtocol (
+, NULL, (VOID **));
+
+  UINTN ObjectId;
+  CM_OBJ_DESCRIPTOR CmObject;
+  UINTN Count = 0;
+
+
+  if (EFI_ERROR(Status)) {
+Print(L"No Configuration Manager installed!\n");
+return EFI_UNSUPPORTED;
+  }
+
+  for (ObjectId = EObjNameSpaceStandard; ObjectId < EStdObjMax; ObjectId++) {
+Status = mCfgMgr->GetObject (mCfgMgr, ObjectId, CM_NULL_TOKEN, );
+if (EFI_ERROR(Status)) {
+  continue;
+}
+
+Print (
+  L"<%s>::<%s>\n",
+  ObjectNameSpaceString[EObjNameSpaceStandard],
+  StdObjectString[ObjectId - EObjNameSpaceStandard]);
+
+Print (
+  L"Id=%x Size=0x%x at=%p count=%d\n",
+  CmObject.ObjectId,
+  CmObject.Size,
+  CmObject.Count,
+  CmObject.Count);
+
+Count++;
+  }
+
+  for (ObjectId = EObjNameSpaceArm; ObjectId < EArmObjMax; ObjectId++) {
+Status = mCfgMgr->GetObject (mCfgMgr, ObjectId, CM_NULL_TOKEN, );
+if (EFI_ERROR(Status)) {
+  continue;
+}
+
+Print (
+  L"<%s>::<%s>\n",
+  ObjectNameSpaceString[EObjNameSpaceArm],
+  ArmObjectString[ObjectId - EObjNameSpaceArm]);
+
+Print (
+  L"Id=%x Size=0x%x at=%p count=%d\n",
+  CmObject.ObjectId,
+  CmObject.Size,
+  CmObject.Count,
+  CmObject.Count);
+
+  Count++;
+  }
+
+  Print(L"Found %d objects\n", Count);
+  return EFI_SUCCESS;
+}
+
+
diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
new file mode 100644
index 00..5017d55b4a
--- /dev/null
+++ 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.h
@@ -0,0 +1,8 @@
+#ifndef CONFIGURATION_MANAGER_DUMP_APP_H_
+#define CONFIGURATION_MANAGER_DUMP_APP_H_
+
+extern CHAR16 *ArmObjectString[];
+extern CHAR16 *ObjectNameSpaceString[];
+extern CHAR16 *StdObjectString[];
+
+#endif
diff --git 
a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
new file mode 100644
index 00..9f8beb916d
--- /dev/null
+++ 
b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationManagerDumpApp.inf
@@ -0,0 +1,42 @@
+## @file
+#  Application that will dump the contents of the configuration
+#  manager.
+#
+#  Copyright (c) 2020, ARM Limited. All rights reserved.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+  INF_VERSION= 0x00010019
+  BASE_NAME  = ConfigurationManagerDumpApp
+  FILE_GUID  = 1E12FA81-8465-4D78-918F-735DB8CB828B
+  MODULE_TYPE= UEFI_APPLICATION
+  VERSION_STRING = 1.0
+  ENTRY_POINT= UefiMain
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = ARM AARCH64
+#
+
+[Sources]
+  ConfigurationManagerDumpApp.c
+  ConfigurationManagerDumpApp.h
+  ConfigurationObjectStrings.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  

[edk2-devel] [PATCH 2/8] DynamicTablesPkg: Fold Namespaces into CmObjectId Enums

2020-07-31 Thread Tomas Pilar (tpilar)
The enums for CmObjectIds defined in Dynamic Tables Framework
that are used to identify types of configuration manager objects
already include their namespaces in the symbols for enum values.

Namespace enum values are shifted up by NAMESPACE_BIT_SHIFT and
the enums tables for CmObjectIds are bitwise-ORed with their
corresponding namespace.

This means we no longer need to use macros to compose and decompose
CmObjectIds. The macros are adjusted so that they result in NOP.

Cc: Sami Mujawar 
Cc: Alexei Fedorov 
Signed-off-by: Tomas Pilar 
---
 .../Include/ArmNameSpaceObjects.h |  3 +-
 .../Include/ConfigurationManagerNameSpace.h   | 43 ++
 .../Include/ConfigurationManagerObject.h  | 57 ---
 .../Include/StandardNameSpaceObjects.h|  7 ++-
 4 files changed, 72 insertions(+), 38 deletions(-)
 create mode 100644 DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h

diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h 
b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
index 2f32696031..cf7846e024 100644
--- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
+++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h
@@ -14,6 +14,7 @@
 #define ARM_NAMESPACE_OBJECTS_H_
 
 #include 
+#include 
 
 #pragma pack(1)
 
@@ -21,7 +22,7 @@
 in the ARM Namespace
 */
 typedef enum ArmObjectID {
-  EArmObjReserved, ///<  0 - Reserved
+  EArmObjReserved = EObjNameSpaceArm,  ///<  0 - Reserved, namespace starts at 
0x1000
   EArmObjBootArchInfo, ///<  1 - Boot Architecture Info
   EArmObjCpuInfo,  ///<  2 - CPU Info
   EArmObjPowerManagementProfileInfo,   ///<  3 - Power Management Profile Info
diff --git a/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h 
b/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h
new file mode 100644
index 00..acba77e2b3
--- /dev/null
+++ b/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h
@@ -0,0 +1,43 @@
+/** @file
+
+  Copyright (c) 2020, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef CONFIGURATION_MANAGER_NAMESPACE_H_
+#define CONFIGURATION_MANAGER_NAMESPACE_H_
+
+/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
+for the Configuration Manager Objects.
+
+ Description of Configuration Manager Object ID
+___
+|31 |30 |29 |28 || 27 | 26 | 25 | 24 || 23 | 22 | 21 | 20 || 19 | 18 | 17 | 16|
+---
+| Name Space ID ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0 ||  0 |  0 |  0 |  0|
+___
+
+Bits: [31:28] - Name Space ID
+ - Standard
+0001 - ARM
+1000 - Custom/OEM
+All other values are reserved.
+
+Bits: [27:16] - Reserved.
+___
+|15 |14 |13 |12 || 11 | 10 |  9 |  8 ||  7 |  6 |  5 |  4 ||  3 |  2 |  1 |  0|
+---
+| 0 | 0 | 0 | 0 ||  0 |  0 |  0 |  0 || Object ID |
+___
+
+Bits: [15:8] - Are reserved and must be zero.
+Bits: [7:0] - Object ID
+*/
+typedef enum ObjectNameSpaceID {
+  EObjNameSpaceStandard = 0x,  ///< Standard Objects Namespace
+  EObjNameSpaceArm  = 0x1000,  ///< ARM Objects Namespace
+  EObjNameSpaceOem  = 0x8000,  ///< OEM Objects Namespace
+} EOBJECT_NAMESPACE_ID;
+
+#endif
diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h 
b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
index b0d3e709ec..9d39bd8a9e 100644
--- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h
+++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h
@@ -86,25 +86,11 @@ typedef UINT32  CM_OBJECT_ID;
 
 /** A mask for Object ID
 */
-#define OBJECT_ID_MASK0xFF
+#define OBJECT_ID_MASK0x00FF
 
 /** A mask for Namespace ID
 */
-#define NAMESPACE_ID_MASK 0xF
-
-/** Starting bit position for Namespace ID
-*/
-#define NAMESPACE_ID_BIT_SHIFT28
-
-/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces
-for the Configuration Manager Objects.
-*/
-typedef enum ObjectNameSpaceID {
-  EObjNameSpaceStandard,  ///< Standard Objects Namespace
-  EObjNameSpaceArm,   ///< ARM Objects Namespace
-  EObjNameSpaceOem = 0x8, ///< OEM Objects Namespace
-  EObjNameSpaceMax
-} EOBJECT_NAMESPACE_ID;
+#define NAMESPACE_ID_MASK 0xF000
 
 /** A descriptor for Configuration Manager Objects.
 
@@ -133,19 +119,21 @@ typedef struct CmObjDescriptor {
 
   @retval Returns the Namespace ID corresponding to the CmObjectID.
 **/
-#define 

Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by DISABLE_NEW_DEPRECATED_INTERFACES

2020-07-31 Thread Marcin Wojtas
Hi Ard,


pt., 31 lip 2020 o 10:27 Ard Biesheuvel  napisał(a):
>
> The reason PcdSet## was deprecated in the first place was because it cannot 
> signal failure, whereas PcdSet##S can.
>
> So please fix the affected platforms by capturing the returned status value, 
> and at the very least, use ASSERT_EFI_ERROR() on it so we can spot any 
> failures in DEBUG builds. Just swapping out one for the other kind of defeats 
> the purpose.
>

Done: https://edk2.groups.io/g/devel/message/63577

Best regards,
Marcin

> 
> From: Pete Batard 
> Sent: Friday, July 31, 2020 09:53
> To: devel@edk2.groups.io ; liming@intel.com 
> ; m...@semihalf.com ; Leif Lindholm 
> 
> Cc: Zhang, Shenglei ; Ard Biesheuvel 
> ; Kinney, Michael D ; 
> Ming Huang 
> Subject: Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by 
> DISABLE_NEW_DEPRECATED_INTERFACES
>
> All,
>
> Fix for Raspberry Pi platforms submitted at:
> https://edk2.groups.io/g/devel/message/63554
>
> Regards,
>
> /Pete
>
> On 2020.07.31 02:55, Liming Gao wrote:
> > Thanks Marcin.
> >
> > Leif:
> >Is there the way to get the fix plan from the platform owner? If so, I 
> > can work the plan to merge this change.
> >
> > Thanks
> > Liming
> > -Original Message-
> > From: devel@edk2.groups.io  On Behalf Of Marcin Wojtas
> > Sent: 2020年7月31日 0:09
> > To: Leif Lindholm 
> > Cc: Gao, Liming ; devel@edk2.groups.io; Zhang, 
> > Shenglei ; Ard Biesheuvel 
> > ; Kinney, Michael D ; 
> > Ming Huang ; Pete Batard 
> > Subject: Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by 
> > DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > Hi Leif,
> >
> >
> > śr., 29 lip 2020 o 15:35 Leif Lindholm  napisał(a):
> >>
> >> Right, so the following platforms break once this patch is merged:
> >>
> >> - AMD Overdrive, Overdrive 1000, Cello
> >> - Hisilicon D03, D05, D06 (some of these due to binary drivers in
> >>edk2-non-osi)
> >> - Marvell Armada 78x0/80x0, MacchiatoBIN
> >
> > Fix for Marvell platforms submitted:
> > https://edk2.groups.io/g/devel/message/63472
> >
> > Best regards,
> > Marcin
> >
> >> - Raspberry Pi 3/4
> >>
> >> I think this provides enough argument to push this patch at least
> >> until after August stable tag.
> >>
> >> As far as I can tell, all of these are due to the PcdSet And
> >> UnicodeStrToAsciiStr functions/macros disappearing. Presumably these
> >> should be replaced with their S-suffixed counterparts.
> >>
> >> Maintainers/reviewers on cc. I'd appreciate if you could update and
> >> sanity check your platforms and send out patches.
> >>
> >> Best Regards,
> >>
> >> Leif
> >>
> >> On Wed, Jul 29, 2020 at 13:24:15 +0100, Leif Lindholm wrote:
> >>> Thanks Liming,
> >>>
> >>> Yes, this does affect several ARM platforms. Currently running a build
> >>> test to determine just how many. My preference would be for a change
> >>> of this magnitude to go in just after a stable tag - what, if any, are
> >>> the plans for this patch?
> >>>
> >>> Best Regards,
> >>>
> >>> Leif
> >>>
> >>> On Wed, Jul 29, 2020 at 07:55:09 +, Gao, Liming wrote:
>  Include Leif and Ard. This change may impact ARM platform.
> 
>  Thanks
>  Liming
>  -Original Message-
>  From: devel@edk2.groups.io  On Behalf Of Liming Gao
>  Sent: 2020年6月9日 21:08
>  To: Zhang, Shenglei ; devel@edk2.groups.io
>  Cc: Kinney, Michael D 
>  Subject: Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by 
>  DISABLE_NEW_DEPRECATED_INTERFACES
> 
>  Shenglei:
> Please also remove the deprecated code in MdeModulePkg.
> 
>  Thanks
>  Liming
> > -Original Message-
> > From: Zhang, Shenglei 
> > Sent: Friday, June 5, 2020 4:13 PM
> > To: devel@edk2.groups.io
> > Cc: Kinney, Michael D ; Gao, Liming 
> > 
> > Subject: [PATCH] MdePkg: Remove code wrapped by 
> > DISABLE_NEW_DEPRECATED_INTERFACES
> >
> > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2777
> > Code wrapped by DISABLE_NEW_DEPRECATED_INTERFACES is deprecated.
> > So remove it.
> >
> > Cc: Michael D Kinney 
> > Cc: Liming Gao 
> > Signed-off-by: Shenglei Zhang 
> > ---
> >   MdePkg/Library/BaseLib/String.c| 626 -
> >   MdePkg/Library/BasePcdLibNull/PcdLib.c | 361 --
> >   MdePkg/Library/BasePrintLib/PrintLib.c | 118 -
> >   MdePkg/Library/DxePcdLib/DxePcdLib.c   | 399 
> >   MdePkg/Library/PeiPcdLib/PeiPcdLib.c   | 397 
> >   MdePkg/Library/UefiLib/UefiLib.c   |  92 
> >   MdePkg/Include/Library/BaseLib.h   | 409 
> >   MdePkg/Include/Library/PcdLib.h| 520 
> >   MdePkg/Include/Library/PrintLib.h  | 110 -
> >   MdePkg/Include/Library/UefiLib.h   |  53 ---
> >   MdePkg/MdePkg.dsc  |   1 -
> >   11 files changed, 3086 deletions(-)
> >

[edk2-devel] [platforms: PATCH v2 1/1] Marvell/Drivers: MvFvbDxe: Switch to PcdSet64S

2020-07-31 Thread Marcin Wojtas
According to the bug:
https://bugzilla.tianocore.org/show_bug.cgi?id=2777
the deprecated code under DISABLE_NEW_DEPRECATED_INTERFACES
will be removed, which will result in compilation breakage
of the Marvell platforms. Prevent that by switching to the
different PcdSet API.

Signed-off-by: Marcin Wojtas 
---
 Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c | 21 +++-
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c 
b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c
index fba75b6..a5d4ec3 100644
--- a/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c
+++ b/Silicon/Marvell/Drivers/Spi/MvFvbDxe/MvFvbDxe.c
@@ -1059,15 +1059,18 @@ MvFvbConfigureFlashInstance (
 return EFI_OUT_OF_RESOURCES;
 }
 
-PcdSet64 (PcdFlashNvStorageVariableBase64,
-  (UINT64) FlashInstance->RegionBaseAddress);
-PcdSet64 (PcdFlashNvStorageFtwWorkingBase64,
-  (UINT64) FlashInstance->RegionBaseAddress
-  + VariableSize);
-PcdSet64 (PcdFlashNvStorageFtwSpareBase64,
-  (UINT64) FlashInstance->RegionBaseAddress
-  + VariableSize
-  + FtwWorkingSize);
+Status = PcdSet64S (PcdFlashNvStorageVariableBase64,
+   (UINT64) FlashInstance->RegionBaseAddress);
+ASSERT_EFI_ERROR (Status);
+Status = PcdSet64S (PcdFlashNvStorageFtwWorkingBase64,
+   (UINT64) FlashInstance->RegionBaseAddress
+   + VariableSize);
+ASSERT_EFI_ERROR (Status);
+Status = PcdSet64S (PcdFlashNvStorageFtwSpareBase64,
+   (UINT64) FlashInstance->RegionBaseAddress
+   + VariableSize
+   + FtwWorkingSize);
+ASSERT_EFI_ERROR (Status);
 
 // Fill the buffer with data from flash
 DataOffset = GET_DATA_OFFSET (FlashInstance->FvbOffset,
-- 
2.7.4


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63577): https://edk2.groups.io/g/devel/message/63577
Mute This Topic: https://groups.io/mt/75909686/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v13 45/46] UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

2020-07-31 Thread Lendacky, Thomas

On 7/31/20 9:44 AM, Tom Lendacky wrote:

On 7/31/20 8:36 AM, Tom Lendacky wrote:

On 7/31/20 7:43 AM, Laszlo Ersek wrote:

Hi Tom,


Hi Laszlo,


Hi Laszlo,

Can you try this incremental patch to see if it fixes the issue you're
seeing? If it does, I'll merge it into patch #45 and send out a v14.


Looking at the formatting, I'm not sure if Thunderbird messed up the diff. 
I'll send you another copy directly to you using git send-email just in case.


Thanks,
Tom



Thanks,
Tom


diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 7165bcf3124a..2c00d72ddefe 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -365,9 +365,9 @@ RelocateApLoop (
  MwaitSupport,

  CpuMpData->ApTargetCState,

  CpuMpData->PmCodeSegment,

-CpuMpData->Pm16CodeSegment,

  StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,

  (UINTN) ,

+CpuMpData->Pm16CodeSegment,

  CpuMpData->SevEsAPBuffer,

  CpuMpData->WakeupBuffer

  );

diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
index 309d53bf3b37..7e81d24aa60f 100644
--- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
@@ -226,7 +226,10 @@ SwitchToRealProcStart:
  SwitchToRealProcEnd:

  


  
;-

-;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish);

+;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);

+;

+;  The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and 
WakeupBuffer) are

+;  specific to SEV-ES support and are not applicable on IA32.

  
;-

  global ASM_PFX(AsmRelocateApLoop)

  ASM_PFX(AsmRelocateApLoop):

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 267aa5201c50..02652eaae126 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -350,9 +350,9 @@ VOID
IN BOOLEAN MwaitSupport,

IN UINTN   ApTargetCState,

IN UINTN   PmCodeSegment,

-  IN UINTN   Pm16CodeSegment,

IN UINTN   TopOfApStack,

IN UINTN   NumberToFinish,

+  IN UINTN   Pm16CodeSegment,

IN UINTN   SevEsAPJumpTable,

IN UINTN   WakeupBuffer

);

diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
index 3b8ec477b8b3..5d30f35b201c 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
@@ -491,13 +491,13 @@ PM16Mode:
  SwitchToRealProcEnd:

  


  
;-

-;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
Pm16CodeSegment, TopOfApStack, CountTofinish, SevEsAPJumpTable, WakeupBuffer);

+;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);

  
;-

  global ASM_PFX(AsmRelocateApLoop)

  ASM_PFX(AsmRelocateApLoop):

  AsmRelocateApLoopStart:

  BITS 64

-cmpqword [rsp + 56], 0

+cmpqword [rsp + 56], 0  ; SevEsAPJumpTable

  je NoSevEs

  


  ;

@@ -539,16 +539,17 @@ BITS 64
  


  NoSevEs:

  cli  ; Disable interrupt before switching to 
32-bit mode

-movrax, [rsp + 48]   ; CountTofinish

+movrax, [rsp + 40]   ; CountTofinish

  lock dec   dword [rax]   ; (*CountTofinish)--

  


+movr10, [rsp + 48]   ; Pm16CodeSegment

  movrax, [rsp + 56]   ; SevEsAPJumpTable

  movrbx, [rsp + 64]   ; WakeupBuffer

-movrsp, [rsp + 40]   ; TopOfApStack

+movrsp, r9   ; TopOfApStack

  


  push   rax   ; Save SevEsAPJumpTable

  push   rbx   ; Save WakeupBuffer

-push   r9; Save Pm16CodeSegment

+push   r10   ; Save Pm16CodeSegment

  push   rcx   ; Save MwaitSupport

  push   rdx   ; Save ApTargetCState

  








On 07/30/20 20:43, Tom Lendacky wrote:

From: Tom Lendacky 

BZ:

Re: [edk2-devel] [PATCH v13 45/46] UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

2020-07-31 Thread Lendacky, Thomas
On 7/31/20 8:36 AM, Tom Lendacky wrote:
> On 7/31/20 7:43 AM, Laszlo Ersek wrote:
>> Hi Tom,
> 
> Hi Laszlo,

Hi Laszlo,

Can you try this incremental patch to see if it fixes the issue you're
seeing? If it does, I'll merge it into patch #45 and send out a v14.

Thanks,
Tom


diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c 
b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 7165bcf3124a..2c00d72ddefe 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -365,9 +365,9 @@ RelocateApLoop (
 MwaitSupport,

 CpuMpData->ApTargetCState,

 CpuMpData->PmCodeSegment,

-CpuMpData->Pm16CodeSegment,

 StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,

 (UINTN) ,

+CpuMpData->Pm16CodeSegment,

 CpuMpData->SevEsAPBuffer,

 CpuMpData->WakeupBuffer

 );

diff --git a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
index 309d53bf3b37..7e81d24aa60f 100644
--- a/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/Ia32/MpFuncs.nasm
@@ -226,7 +226,10 @@ SwitchToRealProcStart:
 SwitchToRealProcEnd:

 

 
;-

-;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish);

+;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);

+;

+;  The last three parameters (Pm16CodeSegment, SevEsAPJumpTable and 
WakeupBuffer) are

+;  specific to SEV-ES support and are not applicable on IA32.

 
;-

 global ASM_PFX(AsmRelocateApLoop)

 ASM_PFX(AsmRelocateApLoop):

diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 267aa5201c50..02652eaae126 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -350,9 +350,9 @@ VOID
   IN BOOLEAN MwaitSupport,

   IN UINTN   ApTargetCState,

   IN UINTN   PmCodeSegment,

-  IN UINTN   Pm16CodeSegment,

   IN UINTN   TopOfApStack,

   IN UINTN   NumberToFinish,

+  IN UINTN   Pm16CodeSegment,

   IN UINTN   SevEsAPJumpTable,

   IN UINTN   WakeupBuffer

   );

diff --git a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm 
b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
index 3b8ec477b8b3..5d30f35b201c 100644
--- a/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
+++ b/UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm
@@ -491,13 +491,13 @@ PM16Mode:
 SwitchToRealProcEnd:

 

 
;-

-;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
Pm16CodeSegment, TopOfApStack, CountTofinish, SevEsAPJumpTable, WakeupBuffer);

+;  AsmRelocateApLoop (MwaitSupport, ApTargetCState, PmCodeSegment, 
TopOfApStack, CountTofinish, Pm16CodeSegment, SevEsAPJumpTable, WakeupBuffer);

 
;-

 global ASM_PFX(AsmRelocateApLoop)

 ASM_PFX(AsmRelocateApLoop):

 AsmRelocateApLoopStart:

 BITS 64

-cmpqword [rsp + 56], 0

+cmpqword [rsp + 56], 0  ; SevEsAPJumpTable

 je NoSevEs

 

 ;

@@ -539,16 +539,17 @@ BITS 64
 

 NoSevEs:

 cli  ; Disable interrupt before switching to 
32-bit mode

-movrax, [rsp + 48]   ; CountTofinish

+movrax, [rsp + 40]   ; CountTofinish

 lock dec   dword [rax]   ; (*CountTofinish)--

 

+movr10, [rsp + 48]   ; Pm16CodeSegment

 movrax, [rsp + 56]   ; SevEsAPJumpTable

 movrbx, [rsp + 64]   ; WakeupBuffer

-movrsp, [rsp + 40]   ; TopOfApStack

+movrsp, r9   ; TopOfApStack

 

 push   rax   ; Save SevEsAPJumpTable

 push   rbx   ; Save WakeupBuffer

-push   r9; Save Pm16CodeSegment

+push   r10   ; Save Pm16CodeSegment

 push   rcx   ; Save MwaitSupport

 push   rdx   ; Save ApTargetCState

 



> 
>>
>> On 07/30/20 20:43, Tom Lendacky wrote:
>>> From: Tom Lendacky 
>>>
>>> BZ: 
>>> https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Cthomas.lendacky%40amd.com%7Cb8c77cf296c949d2bbd808d8354f542b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317962138028351sdata=HISHZmLjOc%2FfgVrBm8MlNeDAk453NJ64%2B51bETZj4rk%3Dreserved=0
>>>  
>>>
>>>
>>> Before UEFI transfers control to the OS, it must park the AP. This is
>>> done using the AsmRelocateApLoop function to transition into 32-bit
>>> non-paging mode. For 

Re: [edk2-devel] [PATCH v13 45/46] UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

2020-07-31 Thread Lendacky, Thomas

On 7/31/20 7:43 AM, Laszlo Ersek wrote:

Hi Tom,


Hi Laszlo,



On 07/30/20 20:43, Tom Lendacky wrote:

From: Tom Lendacky 

BZ: 
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D2198data=02%7C01%7Cthomas.lendacky%40amd.com%7Cb8c77cf296c949d2bbd808d8354f542b%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317962138028351sdata=HISHZmLjOc%2FfgVrBm8MlNeDAk453NJ64%2B51bETZj4rk%3Dreserved=0

Before UEFI transfers control to the OS, it must park the AP. This is
done using the AsmRelocateApLoop function to transition into 32-bit
non-paging mode. For an SEV-ES guest, a few additional things must be
done:
   - AsmRelocateApLoop must be updated to support SEV-ES. This means
 performing a VMGEXIT AP Reset Hold instead of an MWAIT or HLT loop.
   - Since the AP must transition to real mode, a small routine is copied
 to the WakeupBuffer area. Since the WakeupBuffer will be used by
 the AP during OS booting, it must be placed in reserved memory.
 Additionally, the AP stack must be located where it can be accessed
 in real mode.
   - Once the AP is in real mode it will transfer control to the
 destination specified by the OS in the SEV-ES AP Jump Table. The
 SEV-ES AP Jump Table address is saved by the hypervisor for the OS
 using the GHCB VMGEXIT AP Jump Table exit code.

Cc: Eric Dong 
Cc: Ray Ni 
Cc: Laszlo Ersek 
Reviewed-by: Eric Dong 
Signed-off-by: Tom Lendacky 
---
  UefiCpuPkg/Library/MpInitLib/MpLib.h  |   8 +-
  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   |  54 +++-
  UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 131 --
  3 files changed, 175 insertions(+), 18 deletions(-)


Now that this series is almost ready to merge, I've done a bit of
regression-testing.

Unfortunately, this patch breaks booting with IA32 OVMF.

More precisely, it breaks the IA32 version of DxeMpInitLib.


Yeah, that's not good.  I will look into this based on your input below. 
What's strange is that my system doesn't hang and successfully boots all 
APs (up to 64 is what I've tested with).


But, yes, both call sites should be the same and I will make that change.



The symptom is that just when the OS would be launched, the
multiprocessor guest hangs. This is how the log terminates:


FSOpen: Open '\370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\linux'
Success
[Security] 3rd party image[0] can be loaded after EndOfDxe:
PciRoot(0x0)/Pci(0x2,0x1)/Pci(0x0,0x0)/Scsi(0x0,0x0)/HD(1,GPT,D9F1FBA5-E5D3-440A-B6A7-87B593E4FAB1,0x800,0x10)/\370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\linux.
InstallProtocolInterface: [EfiLoadedImageProtocol] 853A03A8
Loading driver at 0x00083E72000 EntryPoint=0x00083E76680
InstallProtocolInterface: [EfiLoadedImageDevicePathProtocol] 853A0510
ProtectUefiImageCommon - 0x853A03A8
   - 0x83E72000 - 0x00E75000
FSOpen: Open '370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\initrd'
Success
PixelBlueGreenRedReserved8BitPerColor
ConvertPages: range 40 - 1274FFF covers multiple entries
SmmInstallProtocolInterface: [EdkiiSmmExitBootServicesProtocol] 0
CpuDxe: 5-Level Paging = 0
[HANG]


Meanwhile some guest CPUs are pegged.

Normally, when this series is not applied, the next log entry is (in
place of [HANG]):


MpInitChangeApLoopCallback() done!


I've identified this patch by bisection, after applying the series on
current master (137c2c6eff67, "Revert "BaseTools/PatchCheck.py: Add
LicenseCheck"", 2020-07-31).

Here's the bisection log:


git bisect start
# good: [137c2c6eff67f4750d77e8e40af6683c412d3ed0] Revert "BaseTools/PatchCheck.py: 
Add LicenseCheck"
git bisect good 137c2c6eff67f4750d77e8e40af6683c412d3ed0
# bad: [d3f7971f4f70c9f39170b42af837e58e59435ad3] Maintainers.txt: Add 
reviewers for the OvmfPkg SEV-related files
git bisect bad d3f7971f4f70c9f39170b42af837e58e59435ad3
# good: [9551e3fc61ba0c0ddf8e79b425a22aa7dd61cb8b] OvmfPkg/VmgExitLib: Add 
support for RDTSCP NAE events
git bisect good 9551e3fc61ba0c0ddf8e79b425a22aa7dd61cb8b
# good: [10acf16b38522d8a1b538b3aa432daaa72c0e97b] OvmfPkg: Reserve a page in 
memory for the SEV-ES usage
git bisect good 10acf16b38522d8a1b538b3aa432daaa72c0e97b
# good: [ccb4267e76b6474657c41bef7e76a980930c22ea] UefiCpuPkg: Add a 16-bit 
protected mode code segment descriptor
git bisect good ccb4267e76b6474657c41bef7e76a980930c22ea
# good: [94e238ae37505cfb081f3b9b4632067e4a113cf9] OvmfPkg: Use the SEV-ES work 
area for the SEV-ES AP reset vector
git bisect good 94e238ae37505cfb081f3b9b4632067e4a113cf9
# bad: [16c21b9d10b032d66d4105dd4693fd9dc6e6ec18] UefiCpuPkg/MpInitLib: Prepare 
SEV-ES guest APs for OS use
git bisect bad 16c21b9d10b032d66d4105dd4693fd9dc6e6ec18
# good: [49855596e383ab2aa6410fa060e22d4817d8e64e] OvmfPkg: Move the GHCB 
allocations into reserved memory
git bisect good 49855596e383ab2aa6410fa060e22d4817d8e64e
# first bad commit: [16c21b9d10b032d66d4105dd4693fd9dc6e6ec18] 
UefiCpuPkg/MpInitLib: 

Re: [edk2-devel] [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: pause in WaitForSemaphore() before re-fetch

2020-07-31 Thread Laszlo Ersek
On 07/31/20 03:10, Dong, Eric wrote:
> Reviewed-by: Eric Dong 

Thank you, merged as commit 9001b750df64, via
.

Laszlo

>> -Original Message-
>> From: Laszlo Ersek 
>> Sent: Thursday, July 30, 2020 2:52 AM
>> To: edk2-devel-groups-io 
>> Cc: Dong, Eric ; Philippe Mathieu-Daudé
>> ; Kumar, Rahul1 ; Ni, Ray
>> 
>> Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: pause in
>> WaitForSemaphore() before re-fetch
>>
>> Most busy waits (spinlocks) in
>> "UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c"
>> already call CpuPause() in their loop bodies; see SmmWaitForApArrival(),
>> APHandler(), and SmiRendezvous(). However, the "main wait" within
>> APHandler():
>>
>>> //
>>> // Wait for something to happen
>>> //
>>> WaitForSemaphore (mSmmMpSyncData->CpuData[CpuIndex].Run);
>>
>> doesn't do so, as WaitForSemaphore() keeps trying to acquire the
>> semaphore without pausing.
>>
>> The performance impact is especially notable in QEMU/KVM + OVMF
>> virtualization with CPU overcommit (that is, when the guest has significantly
>> more VCPUs than the host has physical CPUs). The guest BSP is working
>> heavily in:
>>
>>   BSPHandler()  [MpService.c]
>> PerformRemainingTasks() [PiSmmCpuDxeSmm.c]
>>   SetUefiMemMapAttributes() [SmmCpuMemoryManagement.c]
>>
>> while the many guest APs are spinning in the "Wait for something to happen"
>> semaphore acquisition, in APHandler(). The guest APs are generating useless
>> memory traffic and saturating host CPUs, hindering the guest BSP's progress
>> in SetUefiMemMapAttributes().
>>
>> Rework the loop in WaitForSemaphore(): call CpuPause() in every iteration
>> after the first check fails. Due to Pause Loop Exiting (known as Pause 
>> Filter on
>> AMD), the host scheduler can favor the guest BSP over the guest APs.
>>
>> Running a 16 GB RAM + 512 VCPU guest on a 448 PCPU host, this patch
>> reduces OVMF boot time (counted until reaching grub) from 20-30 minutes
>> to less than 4 minutes.
>>
>> The patch should benefit physical machines as well -- according to the Intel
>> SDM, PAUSE "Improves the performance of spin-wait loops". Adding PAUSE
>> to the generic WaitForSemaphore() function is considered a general
>> improvement.
>>
>> Cc: Eric Dong 
>> Cc: Philippe Mathieu-Daudé 
>> Cc: Rahul Kumar 
>> Cc: Ray Ni 
>> Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1861718
>> Signed-off-by: Laszlo Ersek 
>> ---
>>
>> Notes:
>> Repo:   https://pagure.io/lersek/edk2.git
>> Branch: sem_wait_pause_rhbz1861718
>>
>>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 18 +++---
>>  1 file changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> index 57e788c01b1f..4bcd217917d7 100644
>> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
>> @@ -40,14 +40,18 @@ WaitForSemaphore (
>>  {
>>UINT32Value;
>>
>> -  do {
>> +  for (;;) {
>>  Value = *Sem;
>> -  } while (Value == 0 ||
>> -   InterlockedCompareExchange32 (
>> - (UINT32*)Sem,
>> - Value,
>> - Value - 1
>> - ) != Value);
>> +if (Value != 0 &&
>> +InterlockedCompareExchange32 (
>> +  (UINT32*)Sem,
>> +  Value,
>> +  Value - 1
>> +  ) == Value) {
>> +  break;
>> +}
>> +CpuPause ();
>> +  }
>>return Value - 1;
>>  }
>>
>> --
>> 2.19.1.3.g30247aa5d201
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63573): https://edk2.groups.io/g/devel/message/63573
Mute This Topic: https://groups.io/mt/75871294/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] Add BhyvePkg, to support the bhyve hypervisor

2020-07-31 Thread Laszlo Ersek
On 07/31/20 15:07, Laszlo Ersek wrote:
> On 07/31/20 07:17, Rebecca Cran wrote:
>> On 7/13/20 2:25 PM, Rebecca Cran wrote:
>>
>>> On 7/13/20 12:09 PM, Laszlo Ersek wrote:
>>>
 Can you please ping me when the PatchCheck.py problem has been solved,
 so I can go ahead with the merge?
>>>
>>> Will do.
>>
>>
>> Hi Laszlo,
>>
>>
>> I just rebased the bhyve commit against the latest edk2 master with no
>> conflicts, and all CI checks passed
>> (https://github.com/tianocore/edk2/pull/841).
>>
>> So I think it's ready to go into the tree.
> 
> Thanks for the ping.
> 
> I've had your patch applied locally, from the list, on top of
> then-master HEAD f45e3a4afa65, ready for pushing.
> 
> I've now fetched your branch (from your PR above), at commit
> d6ec30afebe6. I've also rebased my local branch (see above) on top of
> current master (137c2c6eff67). Your rebase and my rebase are identical
> (except my version carries your original Message-Id for the patch, plus
> my Acked-by given earlier).
> 
> Thus I've submitted the following PR, using my rebased branch (including
> the Message-Id and Acked-by tags):
> 
>   https://github.com/tianocore/edk2/pull/842
> 
> Merged as commit 656419f922c0.

... We should have updated the subject line from

  Add BhyvePkg, to support the bhyve hypervisor

to

  OvmfPkg: add OvmfPkg/Bhyve, to support the bhyve hypervisor

I hope the rest of the community will forgive us for missing that.

My apologies.

Laszlo

> Thank you for the contribution!
> 
> Please follow up with a patch for "Maintainers.txt", as discussed up-thread.
> 
> Thanks!
> Laszlo
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63572): https://edk2.groups.io/g/devel/message/63572
Mute This Topic: https://groups.io/mt/75472166/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH 1/1] Add BhyvePkg, to support the bhyve hypervisor

2020-07-31 Thread Laszlo Ersek
On 07/31/20 07:17, Rebecca Cran wrote:
> On 7/13/20 2:25 PM, Rebecca Cran wrote:
> 
>> On 7/13/20 12:09 PM, Laszlo Ersek wrote:
>>
>>> Can you please ping me when the PatchCheck.py problem has been solved,
>>> so I can go ahead with the merge?
>>
>> Will do.
> 
> 
> Hi Laszlo,
> 
> 
> I just rebased the bhyve commit against the latest edk2 master with no
> conflicts, and all CI checks passed
> (https://github.com/tianocore/edk2/pull/841).
> 
> So I think it's ready to go into the tree.

Thanks for the ping.

I've had your patch applied locally, from the list, on top of
then-master HEAD f45e3a4afa65, ready for pushing.

I've now fetched your branch (from your PR above), at commit
d6ec30afebe6. I've also rebased my local branch (see above) on top of
current master (137c2c6eff67). Your rebase and my rebase are identical
(except my version carries your original Message-Id for the patch, plus
my Acked-by given earlier).

Thus I've submitted the following PR, using my rebased branch (including
the Message-Id and Acked-by tags):

  https://github.com/tianocore/edk2/pull/842

Merged as commit 656419f922c0.

Thank you for the contribution!

Please follow up with a patch for "Maintainers.txt", as discussed up-thread.

Thanks!
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63571): https://edk2.groups.io/g/devel/message/63571
Mute This Topic: https://groups.io/mt/75472166/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v13 45/46] UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

2020-07-31 Thread Laszlo Ersek
Hi Tom,

On 07/30/20 20:43, Tom Lendacky wrote:
> From: Tom Lendacky 
>
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
>
> Before UEFI transfers control to the OS, it must park the AP. This is
> done using the AsmRelocateApLoop function to transition into 32-bit
> non-paging mode. For an SEV-ES guest, a few additional things must be
> done:
>   - AsmRelocateApLoop must be updated to support SEV-ES. This means
> performing a VMGEXIT AP Reset Hold instead of an MWAIT or HLT loop.
>   - Since the AP must transition to real mode, a small routine is copied
> to the WakeupBuffer area. Since the WakeupBuffer will be used by
> the AP during OS booting, it must be placed in reserved memory.
> Additionally, the AP stack must be located where it can be accessed
> in real mode.
>   - Once the AP is in real mode it will transfer control to the
> destination specified by the OS in the SEV-ES AP Jump Table. The
> SEV-ES AP Jump Table address is saved by the hypervisor for the OS
> using the GHCB VMGEXIT AP Jump Table exit code.
>
> Cc: Eric Dong 
> Cc: Ray Ni 
> Cc: Laszlo Ersek 
> Reviewed-by: Eric Dong 
> Signed-off-by: Tom Lendacky 
> ---
>  UefiCpuPkg/Library/MpInitLib/MpLib.h  |   8 +-
>  UefiCpuPkg/Library/MpInitLib/DxeMpLib.c   |  54 +++-
>  UefiCpuPkg/Library/MpInitLib/X64/MpFuncs.nasm | 131 --
>  3 files changed, 175 insertions(+), 18 deletions(-)

Now that this series is almost ready to merge, I've done a bit of
regression-testing.

Unfortunately, this patch breaks booting with IA32 OVMF.

More precisely, it breaks the IA32 version of DxeMpInitLib.

The symptom is that just when the OS would be launched, the
multiprocessor guest hangs. This is how the log terminates:

> FSOpen: Open '\370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\linux'
> Success
> [Security] 3rd party image[0] can be loaded after EndOfDxe:
> PciRoot(0x0)/Pci(0x2,0x1)/Pci(0x0,0x0)/Scsi(0x0,0x0)/HD(1,GPT,D9F1FBA5-E5D3-440A-B6A7-87B593E4FAB1,0x800,0x10)/\370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\linux.
> InstallProtocolInterface: [EfiLoadedImageProtocol] 853A03A8
> Loading driver at 0x00083E72000 EntryPoint=0x00083E76680
> InstallProtocolInterface: [EfiLoadedImageDevicePathProtocol] 853A0510
> ProtectUefiImageCommon - 0x853A03A8
>   - 0x83E72000 - 0x00E75000
> FSOpen: Open '370ac550dcaa48b88f1ca75ad903b0e7\4.16.7-100.fc26.i686\initrd'
> Success
> PixelBlueGreenRedReserved8BitPerColor
> ConvertPages: range 40 - 1274FFF covers multiple entries
> SmmInstallProtocolInterface: [EdkiiSmmExitBootServicesProtocol] 0
> CpuDxe: 5-Level Paging = 0
> [HANG]

Meanwhile some guest CPUs are pegged.

Normally, when this series is not applied, the next log entry is (in
place of [HANG]):

> MpInitChangeApLoopCallback() done!

I've identified this patch by bisection, after applying the series on
current master (137c2c6eff67, "Revert "BaseTools/PatchCheck.py: Add
LicenseCheck"", 2020-07-31).

Here's the bisection log:

> git bisect start
> # good: [137c2c6eff67f4750d77e8e40af6683c412d3ed0] Revert 
> "BaseTools/PatchCheck.py: Add LicenseCheck"
> git bisect good 137c2c6eff67f4750d77e8e40af6683c412d3ed0
> # bad: [d3f7971f4f70c9f39170b42af837e58e59435ad3] Maintainers.txt: Add 
> reviewers for the OvmfPkg SEV-related files
> git bisect bad d3f7971f4f70c9f39170b42af837e58e59435ad3
> # good: [9551e3fc61ba0c0ddf8e79b425a22aa7dd61cb8b] OvmfPkg/VmgExitLib: Add 
> support for RDTSCP NAE events
> git bisect good 9551e3fc61ba0c0ddf8e79b425a22aa7dd61cb8b
> # good: [10acf16b38522d8a1b538b3aa432daaa72c0e97b] OvmfPkg: Reserve a page in 
> memory for the SEV-ES usage
> git bisect good 10acf16b38522d8a1b538b3aa432daaa72c0e97b
> # good: [ccb4267e76b6474657c41bef7e76a980930c22ea] UefiCpuPkg: Add a 16-bit 
> protected mode code segment descriptor
> git bisect good ccb4267e76b6474657c41bef7e76a980930c22ea
> # good: [94e238ae37505cfb081f3b9b4632067e4a113cf9] OvmfPkg: Use the SEV-ES 
> work area for the SEV-ES AP reset vector
> git bisect good 94e238ae37505cfb081f3b9b4632067e4a113cf9
> # bad: [16c21b9d10b032d66d4105dd4693fd9dc6e6ec18] UefiCpuPkg/MpInitLib: 
> Prepare SEV-ES guest APs for OS use
> git bisect bad 16c21b9d10b032d66d4105dd4693fd9dc6e6ec18
> # good: [49855596e383ab2aa6410fa060e22d4817d8e64e] OvmfPkg: Move the GHCB 
> allocations into reserved memory
> git bisect good 49855596e383ab2aa6410fa060e22d4817d8e64e
> # first bad commit: [16c21b9d10b032d66d4105dd4693fd9dc6e6ec18] 
> UefiCpuPkg/MpInitLib: Prepare SEV-ES guest APs for OS use

So clearly we should be looking for an IA32-specific change, or
IA32-specific *omission*, in this patch, that could cause the problem.

The bug is the following:

On 07/30/20 20:43, Tom Lendacky wrote:
>
> diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h 
> b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> index b1a9d99cb3eb..267aa5201c50 100644
> --- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
> +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
> @@ 

Re: [edk2-devel] [PATCH v13 00/46] SEV-ES guest support

2020-07-31 Thread Laszlo Ersek
On 07/30/20 20:43, Tom Lendacky wrote:

> Changes since v12:
> - Change IA32 VMGEXIT .nasm file to issue an int 3. Depending on the
>   version of NASM, the "BITS 64" trick to get NASM to recognize the
>   VMMCALL instruction (VMGEXIT is a REP VMMCALL) caused an error. Since
>   SEV-ES is X64 only, VMGEXIT should never be called in IA32.

I've build-tested this series with various OvmfPkg and ArmVirtPkg
platforms / settings (including Xen); it looks good.

Build-tested-by: Laszlo Ersek 

Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63569): https://edk2.groups.io/g/devel/message/63569
Mute This Topic: https://groups.io/mt/75892660/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH v13 07/46] MdePkg/BaseLib: Add support for the VMGEXIT instruction

2020-07-31 Thread Laszlo Ersek
On 07/30/20 20:43, Lendacky, Thomas wrote:
> From: Tom Lendacky 
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198
> 
> VMGEXIT is a new instruction used for Hypervisor/Guest communication when
> running as an SEV-ES guest. A VMGEXIT will cause an automatic exit (AE)
> to occur, resulting in a #VMEXIT with an exit code value of 0x403.
> 
> Since SEV-ES is only supported in X64, provide the necessary X64 support
> to execute the VMGEXIT instruction, which is coded as "rep vmmcall". For
> IA32, since "vmmcall" is not supported in NASM 32-bit mode and VMGEXIT
> should never be called, provide a stub implementation that is identical
> to CpuBreakpoint().
> 
> Cc: Michael D Kinney 
> Cc: Liming Gao 
> Signed-off-by: Tom Lendacky 
> ---
>  MdePkg/Library/BaseLib/BaseLib.inf   |  2 ++
>  MdePkg/Include/Library/BaseLib.h | 14 +
>  MdePkg/Library/BaseLib/Ia32/VmgExit.nasm | 38 
>  MdePkg/Library/BaseLib/X64/VmgExit.nasm  | 32 
>  4 files changed, 86 insertions(+)
>  create mode 100644 MdePkg/Library/BaseLib/Ia32/VmgExit.nasm
>  create mode 100644 MdePkg/Library/BaseLib/X64/VmgExit.nasm
> 
> diff --git a/MdePkg/Library/BaseLib/BaseLib.inf 
> b/MdePkg/Library/BaseLib/BaseLib.inf
> index 3b93b5db8d24..3b85c56c3c03 100644
> --- a/MdePkg/Library/BaseLib/BaseLib.inf
> +++ b/MdePkg/Library/BaseLib/BaseLib.inf
> @@ -184,6 +184,7 @@ [Sources.Ia32]
>Ia32/DisableCache.nasm| GCC
>Ia32/RdRand.nasm
>Ia32/XGetBv.nasm
> +  Ia32/VmgExit.nasm
>  
>Ia32/DivS64x64Remainder.c
>Ia32/InternalSwitchStack.c | MSFT
> @@ -317,6 +318,7 @@ [Sources.X64]
>X64/DisablePaging64.nasm
>X64/RdRand.nasm
>X64/XGetBv.nasm
> +  X64/VmgExit.nasm
>ChkStkGcc.c  | GCC
>  
>  [Sources.EBC]
> diff --git a/MdePkg/Include/Library/BaseLib.h 
> b/MdePkg/Include/Library/BaseLib.h
> index 7edf0051a0a0..04fb329eaabb 100644
> --- a/MdePkg/Include/Library/BaseLib.h
> +++ b/MdePkg/Include/Library/BaseLib.h
> @@ -7848,6 +7848,20 @@ AsmXGetBv (
>);
>  
>  
> +/**
> +  Executes a VMGEXIT instruction (VMMCALL with a REP prefix)
> +
> +  Executes a VMGEXIT instruction. This function is only available on IA-32 
> and
> +  x64.
> +
> +**/
> +VOID
> +EFIAPI
> +AsmVmgExit (
> +  VOID
> +  );
> +
> +
>  /**
>Patch the immediate operand of an IA32 or X64 instruction such that the 
> byte,
>word, dword or qword operand is encoded at the end of the instruction's
> diff --git a/MdePkg/Library/BaseLib/Ia32/VmgExit.nasm 
> b/MdePkg/Library/BaseLib/Ia32/VmgExit.nasm
> new file mode 100644
> index ..69f7fbf3506a
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/Ia32/VmgExit.nasm
> @@ -0,0 +1,38 @@
> +;--
> +;
> +; Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> +;
> +; Module Name:
> +;
> +;   VmgExit.Asm
> +;
> +; Abstract:
> +;
> +;   AsmVmgExit function
> +;
> +; Notes:
> +;
> +;--
> +
> +SECTION .text
> +
> +;--
> +; VOID
> +; EFIAPI
> +; AsmVmgExit (
> +;   VOID
> +;   );
> +;--
> +global ASM_PFX(AsmVmgExit)
> +ASM_PFX(AsmVmgExit):
> +;
> +; NASM doesn't support the vmmcall instruction in 32-bit mode and NASM 
> versions
> +; before 2.12 cannot translate the 64-bit "rep vmmcall" instruction into 
> elf32
> +; format. Given that VMGEXIT does not make sense on IA32, provide a stub
> +; implementation that is identical to CpuBreakpoint(). In practice, 
> AsmVmgExit()
> +; should never be called on IA32.
> +;
> +int  3
> +ret
> +
> diff --git a/MdePkg/Library/BaseLib/X64/VmgExit.nasm 
> b/MdePkg/Library/BaseLib/X64/VmgExit.nasm
> new file mode 100644
> index ..26f034593c67
> --- /dev/null
> +++ b/MdePkg/Library/BaseLib/X64/VmgExit.nasm
> @@ -0,0 +1,32 @@
> +;--
> +;
> +; Copyright (C) 2020, Advanced Micro Devices, Inc. All rights reserved.
> +; SPDX-License-Identifier: BSD-2-Clause-Patent
> +;
> +; Module Name:
> +;
> +;   VmgExit.Asm
> +;
> +; Abstract:
> +;
> +;   AsmVmgExit function
> +;
> +; Notes:
> +;
> +;--
> +
> +DEFAULT REL
> +SECTION .text
> +
> +;--
> +; VOID
> +; EFIAPI
> +; AsmVmgExit (
> +;   VOID
> +;   );
> +;--
> +global ASM_PFX(AsmVmgExit)
> +ASM_PFX(AsmVmgExit):
> +rep vmmcall
> +ret
> +
> 

FWIW:

Reviewed-by: Laszlo Ersek 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply 

[edk2-devel] [PATCH 5/9] IntelFsp2WrapperPkg/FspMeasurementLib: Add header file.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../Include/Library/FspMeasurementLib.h   | 65 +++
 1 file changed, 65 insertions(+)
 create mode 100644 IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h

diff --git a/IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h 
b/IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h
new file mode 100644
index 00..ca02ecdf1f
--- /dev/null
+++ b/IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h
@@ -0,0 +1,65 @@
+/** @file
+  This library is used by FSP modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _FSP_MEASUREMENT_LIB_H_
+#define _FSP_MEASUREMENT_LIB_H_
+
+#define FSP_MEASURE_FSP   BIT0
+#define FSP_MEASURE_FSPT  BIT1
+#define FSP_MEASURE_FSPM  BIT2
+#define FSP_MEASURE_FSPS  BIT3
+#define FSP_MEASURE_FSPUPDBIT31
+
+/**
+  Mesure a FSP FirmwareBlob.
+
+  @param[in]  PcrIndexPCR Index.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFspFirmwareBlob (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength
+  );
+
+/**
+  Mesure a FSP FirmwareBlob.
+
+  @param[in]  PcrIndexPCR Index.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+  @param[in]  CfgRegionOffset Configuration region offset in bytes.
+  @param[in]  CfgRegionSize   Configuration region in bytes.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFspFirmwareBlobWithCfg (
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength,
+  IN UINT32 CfgRegionOffset,
+  IN UINT32 CfgRegionSize
+  );
+
+#endif
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63562): https://edk2.groups.io/g/devel/message/63562
Mute This Topic: https://groups.io/mt/75903683/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 3/9] SecurityPkg/DxeTpmMeasurementLib: Add new API.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../DxeTpmMeasurementLib.inf  |   6 +-
 .../DxeTpmMeasurementLib/EventLogRecord.c | 218 ++
 2 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 SecurityPkg/Library/DxeTpmMeasurementLib/EventLogRecord.c

diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf 
b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
index 7d41bc41f9..39448f8ee8 100644
--- a/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
@@ -4,7 +4,7 @@
 #  This library provides TpmMeasureAndLogData() to measure and log data, and
 #  extend the measurement result into a specific PCR.
 #
-# Copyright (c) 2012 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -26,6 +26,7 @@
 
 [Sources]
   DxeTpmMeasurementLib.c
+  EventLogRecord.c
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -42,3 +43,6 @@
 [Protocols]
   gEfiTcgProtocolGuid   ## SOMETIMES_CONSUMES
   gEfiTcg2ProtocolGuid  ## SOMETIMES_CONSUMES
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdTcgPfpMeasurementRevision  ## 
CONSUMES
diff --git a/SecurityPkg/Library/DxeTpmMeasurementLib/EventLogRecord.c 
b/SecurityPkg/Library/DxeTpmMeasurementLib/EventLogRecord.c
new file mode 100644
index 00..7b3726e44b
--- /dev/null
+++ b/SecurityPkg/Library/DxeTpmMeasurementLib/EventLogRecord.c
@@ -0,0 +1,218 @@
+/** @file
+  This library is used by other modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#pragma pack (1)
+
+#define PLATFORM_FIRMWARE_BLOB_DESC "Fv(----)"
+typedef struct {
+  UINT8 BlobDescriptionSize;
+  UINT8 
BlobDescription[sizeof(PLATFORM_FIRMWARE_BLOB_DESC)];
+  EFI_PHYSICAL_ADDRESS  BlobBase;
+  UINT64BlobLength;
+} PLATFORM_FIRMWARE_BLOB2_STRUCT;
+
+#define HANDOFF_TABLE_POINTER_DESC  "1234567890ABCDEF"
+typedef struct {
+  UINT8 TableDescriptionSize;
+  UINT8 
TableDescription[sizeof(HANDOFF_TABLE_POINTER_DESC)];
+  UINT64NumberOfTables;
+  EFI_CONFIGURATION_TABLE   TableEntry[1];
+} HANDOFF_TABLE_POINTERS2_STRUCT;
+
+#pragma pack ()
+
+/**
+  Get the FvName from the FV header.
+
+  Causion: The FV is untrusted input.
+
+  @param[in]  FvBaseBase address of FV image.
+  @param[in]  FvLength  Length of FV image.
+
+  @return FvName pointer
+  @retval NULL   FvName is NOT found
+**/
+VOID *
+TpmMeasurementGetFvName (
+  IN EFI_PHYSICAL_ADDRESS   FvBase,
+  IN UINT64 FvLength
+  )
+{
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;
+  EFI_FIRMWARE_VOLUME_EXT_HEADER  *FvExtHeader;
+
+  if (FvBase >= MAX_ADDRESS) {
+return NULL;
+  }
+  if (FvLength >= MAX_ADDRESS - FvBase) {
+return NULL;
+  }
+  if (FvLength < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) {
+return NULL;
+  }
+
+  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvBase;
+  if (FvHeader->Signature != EFI_FVH_SIGNATURE) {
+return NULL;
+  }
+  if (FvHeader->ExtHeaderOffset < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) {
+return NULL;
+  }
+  if (FvHeader->ExtHeaderOffset + sizeof(EFI_FIRMWARE_VOLUME_EXT_HEADER) > 
FvLength) {
+return NULL;
+  }
+  FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(UINTN)(FvBase + 
FvHeader->ExtHeaderOffset);
+
+  return >FvName;
+}
+
+/**
+  Mesure a FirmwareBlob.
+
+  @param[in]  PcrIndexPcrIndex of the measurment.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFirmwareBlob (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength
+  )
+{
+  EFI_PLATFORM_FIRMWARE_BLOBFvBlob;
+  PLATFORM_FIRMWARE_BLOB2_STRUCTFvBlob2;
+  VOID  *FvName;
+  UINT32EventType;
+  VOID

[edk2-devel] [PATCH 7/9] IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../FspmWrapperPeim/FspmWrapperPeim.c | 115 +-
 .../FspmWrapperPeim/FspmWrapperPeim.inf   |  20 ++-
 .../FspsWrapperPeim/FspsWrapperPeim.c |  96 ++-
 .../FspsWrapperPeim/FspsWrapperPeim.inf   |  27 ++--
 4 files changed, 239 insertions(+), 19 deletions(-)

diff --git a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c 
b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
index 265b77ed60..1533971d7f 100644
--- a/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
+++ b/IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register 
MemoryDiscoveredPpi
   notify to call FspSiliconInit API.
 
-  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
+  Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -25,11 +25,14 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -147,7 +150,21 @@ FspmWrapperInit (
   VOID
   )
 {
-  EFI_STATUS   Status;
+  EFI_STATUSStatus;
+  EFI_PEI_FIRMWARE_VOLUME_INFO_MEASUREMENT_EXCLUDED_PPI 
*MeasurementExcludedFvPpi;
+  EFI_PEI_PPI_DESCRIPTOR
*MeasurementExcludedPpiList;
+
+  MeasurementExcludedFvPpi = AllocatePool (sizeof(*MeasurementExcludedFvPpi));
+  ASSERT(MeasurementExcludedFvPpi != NULL);
+  MeasurementExcludedFvPpi->Count = 1;
+  MeasurementExcludedFvPpi->Fv[0].FvBase = PcdGet32 (PcdFspmBaseAddress);
+  MeasurementExcludedFvPpi->Fv[0].FvLength = ((EFI_FIRMWARE_VOLUME_HEADER *) 
(UINTN) PcdGet32 (PcdFspmBaseAddress))->FvLength;
+
+  MeasurementExcludedPpiList = AllocatePool 
(sizeof(*MeasurementExcludedPpiList));
+  ASSERT(MeasurementExcludedPpiList != NULL);
+  MeasurementExcludedPpiList->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+  MeasurementExcludedPpiList->Guid  = 

+  MeasurementExcludedPpiList->Ppi   = MeasurementExcludedFvPpi;
 
   Status = EFI_SUCCESS;
 
@@ -155,6 +172,9 @@ FspmWrapperInit (
 Status = PeiFspMemoryInit ();
 ASSERT_EFI_ERROR (Status);
   } else {
+Status = PeiServicesInstallPpi (MeasurementExcludedPpiList);
+ASSERT_EFI_ERROR (Status);
+
 PeiServicesInstallFvInfoPpi (
   NULL,
   (VOID *)(UINTN) PcdGet32 (PcdFspmBaseAddress),
@@ -167,6 +187,92 @@ FspmWrapperInit (
   return Status;
 }
 
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServicesPointer to PEI Services Table.
+  @param[in] NotifyDesc Pointer to the descriptor for the Notification 
event that
+caused this function to execute.
+  @param[in] PpiPointer to the PPI data associated with this 
function.
+
+  @retval EFI_STATUSAlways return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES  **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID  *Ppi
+  );
+
+EFI_PEI_NOTIFY_DESCRIPTOR mTcgPpiNotifyDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | 
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  ,
+  TcgPpiNotify
+};
+
+/**
+  This function is called after TCG installed PPI.
+
+  @param[in] PeiServicesPointer to PEI Services Table.
+  @param[in] NotifyDesc Pointer to the descriptor for the Notification 
event that
+caused this function to execute.
+  @param[in] PpiPointer to the PPI data associated with this 
function.
+
+  @retval EFI_STATUSAlways return EFI_SUCCESS
+**/
+EFI_STATUS
+EFIAPI
+TcgPpiNotify (
+  IN EFI_PEI_SERVICES  **PeiServices,
+  IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDesc,
+  IN VOID  *Ppi
+  )
+{
+  UINT32FspMeasureMask;
+  FSP_INFO_HEADER   *FspHeaderPtr;
+
+  DEBUG ((DEBUG_INFO, "TcgPpiNotify FSPM\n"));
+
+  FspMeasureMask = PcdGet32 (PcdFspMeasurementConfig);
+  if (FspMeasureMask & FSP_MEASURE_FSP) {
+if (FspMeasureMask & FSP_MEASURE_FSPT) {
+  if(FspMeasureMask & FSP_MEASURE_FSPUPD) {
+FspHeaderPtr = (FSP_INFO_HEADER *) FspFindFspHeader (PcdGet32 
(PcdFsptBaseAddress));
+if (FspHeaderPtr == NULL) {
+  return EFI_DEVICE_ERROR;
+}
+DEBUG ((DEBUG_INFO, "FSPT: CfgRegionOffset 0x%x, CfgRegionSize 
0x%x\n", FspHeaderPtr->CfgRegionOffset, FspHeaderPtr->CfgRegionSize));
+DEBUG ((DEBUG_INFO, "FSPT: PcdFsptBaseAddress 0x%x, ImageBase 0x%x\n", 
PcdGet32(PcdFsptBaseAddress), FspHeaderPtr->ImageBase));
+MeasureFspFirmwareBlobWithCfg ("FSPT", PcdGet32(PcdFsptBaseAddress),
+   

[edk2-devel] [PATCH 8/9] IntelFsp2Wrapper/dsc: Add FspTpmMeasurementLib and PcdFspMeasurementConfig.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec | 17 +
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc |  5 -
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec 
b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
index faf2be621c..4bd3250571 100644
--- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
+++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
@@ -92,6 +92,23 @@
   #
   
gIntelFsp2WrapperTokenSpaceGuid.PcdFspModeSelection|0x0001|UINT8|0x400A
 
+  ## This PCD decides how FSP is measured
+  # 1) The BootGuard ACM may already measured the FSP component, such as 
FSPT/FSPM.
+  # We need a flag (PCD) to indicate if there is need to do such FSP 
measurement or NOT.
+  # 2) The FSP binary includes FSP code and FSP UPD region. The UPD region is 
considered
+  # as configuration block, and it may be updated by OEM by design.
+  # This flag (PCD) is to indicate if we need isolate the the UPD region from 
the FSP code region.
+  # BIT0: Need measure FSP. (for FSP1.x) - reserved in FSP2.
+  # BIT1: Need measure FSPT. (for FSP 2.x)
+  # BIT2: Need measure FSPM. (for FSP 2.x)
+  # BIT3: Need measure FSPS. (for FSP 2.x)
+  # BIT4~30: reserved.
+  # BIT31: Need isolate UPD region measurement.
+#0: measure FSP[T|M|S] as one binary in one record (PCR0).
+#1: measure FSP UPD region in one record (PCR1), the FSP code without UPD 
in another record (PCR0).
+  #
+  
gIntelFsp2WrapperTokenSpaceGuid.PcdFspMeasurementConfig|0x000F|UINT32|0x400B
+
 [PcdsFixedAtBuild, PcdsPatchableInModule,PcdsDynamic,PcdsDynamicEx]
   #
   ## These are the base address of FSP-M/S
diff --git a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc 
b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
index cb4f69285d..5c0d509be4 100644
--- a/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
+++ b/IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc
@@ -1,7 +1,7 @@
 ## @file
 # Provides drivers and definitions to support fsp in EDKII bios.
 #
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2014 - 2020, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -45,6 +45,7 @@
   # FSP Wrapper Lib
   
FspWrapperApiLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperApiLib/BaseFspWrapperApiLib.inf
   
FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperApiTestLibNull/BaseFspWrapperApiTestLibNull.inf
+  
FspMeasurementLib|IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
 
   # FSP platform sample
   
FspWrapperPlatformLib|IntelFsp2WrapperPkg/Library/BaseFspWrapperPlatformLibSample/BaseFspWrapperPlatformLibSample.inf
@@ -57,6 +58,7 @@
   PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
   
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
   HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
+  
TpmMeasurementLib|SecurityPkg/Library/PeiTpmMeasurementLib/PeiTpmMeasurementLib.inf
 
 [LibraryClasses.common.DXE_DRIVER]
   
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
@@ -73,6 +75,7 @@
   
IntelFsp2WrapperPkg/Library/SecFspWrapperPlatformSecLibSample/SecFspWrapperPlatformSecLibSample.inf
   
IntelFsp2WrapperPkg/Library/PeiFspWrapperHobProcessLibSample/PeiFspWrapperHobProcessLibSample.inf
   
IntelFsp2WrapperPkg/Library/PeiFspWrapperApiTestLib/PeiFspWrapperApiTestLib.inf
+  IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
 
   IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
   IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63566): https://edk2.groups.io/g/devel/message/63566
Mute This Topic: https://groups.io/mt/75903687/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 9/9] SecurityPkg/HashLib: add API HashFinal

2020-07-31 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2376

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Qi Zhang 
---
 SecurityPkg/Include/Library/HashLib.h | 15 ++
 .../HashLibBaseCryptoRouterPei.c  | 48 +++
 2 files changed, 63 insertions(+)

diff --git a/SecurityPkg/Include/Library/HashLib.h 
b/SecurityPkg/Include/Library/HashLib.h
index 6ad960ad70..e2d9a62a1d 100644
--- a/SecurityPkg/Include/Library/HashLib.h
+++ b/SecurityPkg/Include/Library/HashLib.h
@@ -47,6 +47,21 @@ HashUpdate (
   IN UINTN  DataToHashLen
   );
 
+/**
+  Hash sequence complete and extend to PCR.
+
+  @param HashHandleHash handle.
+  @param DigestListDigest list.
+
+  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashFinal (
+  IN HASH_HANDLE HashHandle,
+  OUT TPML_DIGEST_VALUES *DigestList
+  );
+
 /**
   Hash sequence complete and extend to PCR.
 
diff --git 
a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c 
b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
index 42cb562f67..5b9719630d 100644
--- a/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
+++ b/SecurityPkg/Library/HashLibBaseCryptoRouter/HashLibBaseCryptoRouterPei.c
@@ -208,6 +208,54 @@ HashUpdate (
   return EFI_SUCCESS;
 }
 
+/**
+  Hash sequence complete and extend to PCR.
+
+  @param HashHandleHash handle.
+  @param DigestListDigest list.
+
+  @retval EFI_SUCCESS Hash sequence complete and DigestList is returned.
+**/
+EFI_STATUS
+EFIAPI
+HashFinal (
+  IN HASH_HANDLE HashHandle,
+  OUT TPML_DIGEST_VALUES *DigestList
+  )
+{
+  TPML_DIGEST_VALUES Digest;
+  HASH_INTERFACE_HOB *HashInterfaceHob;
+  HASH_HANDLE*HashCtx;
+  UINTN  Index;
+  UINT32 HashMask;
+
+  HashInterfaceHob = InternalGetHashInterfaceHob ();
+  if (HashInterfaceHob == NULL) {
+return EFI_UNSUPPORTED;
+  }
+
+  if (HashInterfaceHob->HashInterfaceCount == 0) {
+return EFI_UNSUPPORTED;
+  }
+
+  CheckSupportedHashMaskMismatch (HashInterfaceHob);
+
+  HashCtx = (HASH_HANDLE *)HashHandle;
+  ZeroMem (DigestList, sizeof(*DigestList));
+
+  for (Index = 0; Index < HashInterfaceHob->HashInterfaceCount; Index++) {
+HashMask = Tpm2GetHashMaskFromAlgo 
(>HashInterface[Index].HashGuid);
+if ((HashMask & PcdGet32 (PcdTpm2HashMask)) != 0) {
+  HashInterfaceHob->HashInterface[Index].HashFinal (HashCtx[Index], 
);
+  Tpm2SetHashToDigestList (DigestList, );
+}
+  }
+
+  FreePool (HashCtx);
+
+  return EFI_SUCCESS;
+}
+
 /**
   Hash sequence complete and extend to PCR.
 
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63567): https://edk2.groups.io/g/devel/message/63567
Mute This Topic: https://groups.io/mt/75903688/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 4/9] SecurityPkg/PeiTpmMeasurementLib: Add new API.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../PeiTpmMeasurementLib/EventLogRecord.c | 409 ++
 .../PeiTpmMeasurementLib.inf  |   5 +
 2 files changed, 414 insertions(+)
 create mode 100644 SecurityPkg/Library/PeiTpmMeasurementLib/EventLogRecord.c

diff --git a/SecurityPkg/Library/PeiTpmMeasurementLib/EventLogRecord.c 
b/SecurityPkg/Library/PeiTpmMeasurementLib/EventLogRecord.c
new file mode 100644
index 00..bd3d7000a1
--- /dev/null
+++ b/SecurityPkg/Library/PeiTpmMeasurementLib/EventLogRecord.c
@@ -0,0 +1,409 @@
+/** @file
+  This library is used by other modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#pragma pack (1)
+
+#define PLATFORM_FIRMWARE_BLOB_DESC "Fv(----)"
+typedef struct {
+  UINT8 BlobDescriptionSize;
+  UINT8 
BlobDescription[sizeof(PLATFORM_FIRMWARE_BLOB_DESC)];
+  EFI_PHYSICAL_ADDRESS  BlobBase;
+  UINT64BlobLength;
+} PLATFORM_FIRMWARE_BLOB2_STRUCT;
+
+#define HANDOFF_TABLE_POINTER_DESC  "1234567890ABCDEF"
+typedef struct {
+  UINT8 TableDescriptionSize;
+  UINT8 
TableDescription[sizeof(HANDOFF_TABLE_POINTER_DESC)];
+  UINT64NumberOfTables;
+  EFI_CONFIGURATION_TABLE   TableEntry[1];
+} HANDOFF_TABLE_POINTERS2_STRUCT;
+
+#pragma pack ()
+
+/**
+  Tpm measure and log data, and extend the measurement result into a specific 
PCR.
+
+  @param[in]  PcrIndex PCR Index.
+  @param[in]  EventTypeEvent type.
+  @param[in]  EventLog Measurement event log.
+  @param[in]  LogLen   Event log length in bytes.
+  @param[in]  HashData The start of the data buffer to be hashed, 
extended.
+  @param[in]  HashDataLen  The length, in bytes, of the buffer referenced 
by HashData
+  @param[in]  FlagsBitmap providing additional information.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+**/
+EFI_STATUS
+EFIAPI
+TpmMeasureAndLogDataWithFlags (
+  IN UINT32 PcrIndex,
+  IN UINT32 EventType,
+  IN VOID   *EventLog,
+  IN UINT32 LogLen,
+  IN VOID   *HashData,
+  IN UINT64 HashDataLen,
+  IN UINT64 Flags
+  )
+{
+  EFI_STATUSStatus;
+  EDKII_TCG_PPI *TcgPpi;
+  TCG_PCR_EVENT_HDR TcgEventHdr;
+
+  Status = PeiServicesLocatePpi(
+ ,
+ 0,
+ NULL,
+ (VOID**)
+ );
+  if (EFI_ERROR(Status)) {
+return Status;
+  }
+
+  TcgEventHdr.PCRIndex  = PcrIndex;
+  TcgEventHdr.EventType = EventType;
+  TcgEventHdr.EventSize = LogLen;
+
+  Status = TcgPpi->HashLogExtendEvent (
+ TcgPpi,
+ Flags,
+ HashData,
+ (UINTN)HashDataLen,
+ ,
+ EventLog
+ );
+  return Status;
+}
+
+/**
+  Get the FvName from the FV header.
+
+  Causion: The FV is untrusted input.
+
+  @param[in]  FvBaseBase address of FV image.
+  @param[in]  FvLength  Length of FV image.
+
+  @return FvName pointer
+  @retval NULL   FvName is NOT found
+**/
+VOID *
+TpmMeasurementGetFvName (
+  IN EFI_PHYSICAL_ADDRESS   FvBase,
+  IN UINT64 FvLength
+  )
+{
+  EFI_FIRMWARE_VOLUME_HEADER  *FvHeader;
+  EFI_FIRMWARE_VOLUME_EXT_HEADER  *FvExtHeader;
+
+  if (FvBase >= MAX_ADDRESS) {
+return NULL;
+  }
+  if (FvLength >= MAX_ADDRESS - FvBase) {
+return NULL;
+  }
+  if (FvLength < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) {
+return NULL;
+  }
+
+  FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)FvBase;
+  if (FvHeader->Signature != EFI_FVH_SIGNATURE) {
+return NULL;
+  }
+  if (FvHeader->ExtHeaderOffset < sizeof(EFI_FIRMWARE_VOLUME_HEADER)) {
+return NULL;
+  }
+  if (FvHeader->ExtHeaderOffset + sizeof(EFI_FIRMWARE_VOLUME_EXT_HEADER) > 
FvLength) {
+return NULL;
+  }
+  FvExtHeader = (EFI_FIRMWARE_VOLUME_EXT_HEADER *)(UINTN)(FvBase + 
FvHeader->ExtHeaderOffset);
+
+  return >FvName;
+}
+
+/**
+  Mesure a FirmwareBlob.
+
+  @param[in]  PcrIndexPcrIndex of the measurment.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this 

[edk2-devel] [PATCH 6/9] IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../BaseFspMeasurementLib.inf | 37 ++
 .../BaseFspMeasurementLib/FspMeasurementLib.c | 70 +++
 2 files changed, 107 insertions(+)
 create mode 100644 
IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
 create mode 100644 
IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib.c

diff --git 
a/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf 
b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
new file mode 100644
index 00..2539164e40
--- /dev/null
+++ 
b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
@@ -0,0 +1,37 @@
+## @file
+#  Provides FSP measurement functions.
+#
+#  This library provides MeasureFspFirmwareBlob() to measure FSP binary.
+#
+# Copyright (c) 2020, Intel Corporation. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION= 0x00010005
+  BASE_NAME  = FspMeasurementLib
+  FILE_GUID  = 9A62C49D-C45A-4322-9F3C-45958DF0056B
+  MODULE_TYPE= BASE
+  VERSION_STRING = 1.0
+  LIBRARY_CLASS  = FspMeasurementLib
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES   = IA32 X64
+#
+
+[Sources]
+  FspMeasurementLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  TpmMeasurementLib
diff --git 
a/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib.c 
b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib.c
new file mode 100644
index 00..8a33fe97c0
--- /dev/null
+++ b/IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib.c
@@ -0,0 +1,70 @@
+/** @file
+  This library is used by FSP modules to measure data to TPM.
+
+Copyright (c) 2020, Intel Corporation. All rights reserved. 
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+/**
+  Mesure a FSP FirmwareBlob.
+
+  @param[in]  PcrIndexPCR Index.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFspFirmwareBlob (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength
+  )
+{
+  return MeasureFirmwareBlob (PcrIndex, Description, FirmwareBlobBase, 
FirmwareBlobLength);
+}
+
+/**
+  Mesure a FSP FirmwareBlob.
+
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+  @param[in]  CfgRegionOffset Configuration region offset in bytes.
+  @param[in]  CfgRegionSize   Configuration region in bytes.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFspFirmwareBlobWithCfg (
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength,
+  IN UINT32 CfgRegionOffset,
+  IN UINT32 CfgRegionSize
+  )
+{
+  return MeasureFirmwareBlobWithCfg (Description, FirmwareBlobBase, 
FirmwareBlobLength, CfgRegionOffset, CfgRegionSize);
+
+}
+
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63564): https://edk2.groups.io/g/devel/message/63564
Mute This Topic: https://groups.io/mt/75903685/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 2/9] MdeModulePkg/NullTpmMeasurementLib: Add new API.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../TpmMeasurementLibNull.c   | 61 ++-
 .../TpmMeasurementLibNull.inf |  6 +-
 2 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c 
b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c
index b9c5b68de8..2ce38d8258 100644
--- a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c
+++ b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.c
@@ -1,11 +1,13 @@
 /** @file
   This library is used by other modules to measure data to TPM.
 
-Copyright (c) 2015, Intel Corporation. All rights reserved. 
+Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved. 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
+#include 
+
 /**
   Tpm measure and log data, and extend the measurement result into a specific 
PCR.
 
@@ -37,3 +39,60 @@ TpmMeasureAndLogData (
   //
   return EFI_SUCCESS;
 }
+
+/**
+  Mesure a FirmwareBlob.
+
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFirmwareBlob (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength
+  )
+{
+  //
+  // Do nothing, just return EFI_SUCCESS.
+  //
+  return EFI_SUCCESS;
+}
+
+/**
+  Mesure a HandoffTable.
+
+  @param[in]  PcrIndexPcrIndex of the measurment.
+  @param[in]  Descrption  Description for this HandoffTable.
+  @param[in]  TableGuid   GUID of this HandoffTable.
+  @param[in]  TableAddressBase address of this HandoffTable.
+  @param[in]  TableLength Size in bytes of this HandoffTable.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureHandoffTable (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_GUID   *TableGuid,
+  IN VOID   *TableAddress,
+  IN UINTN  TableLength
+  )
+{
+  //
+  // Do nothing, just return EFI_SUCCESS.
+  //
+  return EFI_SUCCESS;
+}
diff --git 
a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf 
b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
index 61abcfa2ec..1db2c0d6a7 100644
--- a/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+++ b/MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
@@ -1,7 +1,7 @@
 ## @file
 #  Provides NULL TPM measurement function.
 #
-# Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2020, Intel Corporation. All rights reserved.
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
@@ -10,9 +10,9 @@
   INF_VERSION= 0x00010005
   BASE_NAME  = TpmMeasurementLibNull
   FILE_GUID  = 6DFD6E9F-9278-48D8-8F45-B6CFF2C2B69C
-  MODULE_TYPE= UEFI_DRIVER
+  MODULE_TYPE= BASE
   VERSION_STRING = 1.0
-  LIBRARY_CLASS  = TpmMeasurementLib|DXE_DRIVER 
DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
+  LIBRARY_CLASS  = TpmMeasurementLib
   MODULE_UNI_FILE= TpmMeasurementLibNull.uni
 
 #
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63560): https://edk2.groups.io/g/devel/message/63560
Mute This Topic: https://groups.io/mt/75903679/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 0/9] Need add a FSP binary measurement

2020-07-31 Thread Qi Zhang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2376

The EDKII BIOS calls FSP API in FSP Wrapper Pkg.
This FSP code need to be measured into TPM.

We need add a generic module in FSP Wrapper Pkg code to measure:
1) FSP-T, FSP-M, FSP-S in API mode.
2) FSP-T in Dispatch-mode. The FSP-M and FSP-S will be reported
   as standard FV and they will be measured by TCG-PEI.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Chasel Chiu 
Cc: Nate DeSimone 
Cc: Star Zeng 
Cc: Qi Zhang 

Jiewen Yao (8):
  MdeModulePkg/TpmMeasurementLib: Add new API to TpmMeasurmentLib.
  MdeModulePkg/NullTpmMeasurementLib: Add new API.
  SecurityPkg/DxeTpmMeasurementLib: Add new API.
  SecurityPkg/PeiTpmMeasurementLib: Add new API.
  IntelFsp2WrapperPkg/FspMeasurementLib: Add header file.
  IntelFsp2WrapperPkg/FspMeasurementLib: Add BaseFspMeasurementLib.
  IntelFsp2WraperPkg/Fsp{m|s}WrapperPeim: Add FspBin measurement.
  IntelFsp2Wrapper/dsc: Add FspTpmMeasurementLib and
PcdFspMeasurementConfig.

Qi Zhang (1):
  SecurityPkg/HashLib: add API HashFinal

 .../FspmWrapperPeim/FspmWrapperPeim.c | 115 -
 .../FspmWrapperPeim/FspmWrapperPeim.inf   |  20 +-
 .../FspsWrapperPeim/FspsWrapperPeim.c |  96 +++-
 .../FspsWrapperPeim/FspsWrapperPeim.inf   |  27 +-
 .../Include/Library/FspMeasurementLib.h   |  65 +++
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec   |  17 +
 IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dsc   |   5 +-
 .../BaseFspMeasurementLib.inf |  37 ++
 .../BaseFspMeasurementLib/FspMeasurementLib.c |  70 +++
 .../Include/Library/TpmMeasurementLib.h   |  71 ++-
 .../TpmMeasurementLibNull.c   |  61 ++-
 .../TpmMeasurementLibNull.inf |   6 +-
 SecurityPkg/Include/Library/HashLib.h |  15 +
 .../DxeTpmMeasurementLib.inf  |   6 +-
 .../DxeTpmMeasurementLib/EventLogRecord.c | 218 ++
 .../HashLibBaseCryptoRouterPei.c  |  48 ++
 .../PeiTpmMeasurementLib/EventLogRecord.c | 409 ++
 .../PeiTpmMeasurementLib.inf  |   5 +
 18 files changed, 1265 insertions(+), 26 deletions(-)
 create mode 100644 IntelFsp2WrapperPkg/Include/Library/FspMeasurementLib.h
 create mode 100644 
IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/BaseFspMeasurementLib.inf
 create mode 100644 
IntelFsp2WrapperPkg/Library/BaseFspMeasurementLib/FspMeasurementLib.c
 create mode 100644 SecurityPkg/Library/DxeTpmMeasurementLib/EventLogRecord.c
 create mode 100644 SecurityPkg/Library/PeiTpmMeasurementLib/EventLogRecord.c

-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63558): https://edk2.groups.io/g/devel/message/63558
Mute This Topic: https://groups.io/mt/75903677/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/9] MdeModulePkg/TpmMeasurementLib: Add new API to TpmMeasurmentLib.

2020-07-31 Thread Qi Zhang
From: Jiewen Yao 

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

Cc: Jian J Wang 
Cc: Hao A Wu 
Cc: Qi Zhang 
Signed-off-by: Jiewen Yao 
---
 .../Include/Library/TpmMeasurementLib.h   | 71 ++-
 1 file changed, 70 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Include/Library/TpmMeasurementLib.h 
b/MdeModulePkg/Include/Library/TpmMeasurementLib.h
index ddf6723f03..cd4d175918 100644
--- a/MdeModulePkg/Include/Library/TpmMeasurementLib.h
+++ b/MdeModulePkg/Include/Library/TpmMeasurementLib.h
@@ -1,7 +1,7 @@
 /** @file
   This library is used by other modules to measure data to TPM.
 
-Copyright (c) 2012, Intel Corporation. All rights reserved. 
+Copyright (c) 2012 - 2020, Intel Corporation. All rights reserved. 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
@@ -35,4 +35,73 @@ TpmMeasureAndLogData (
   IN UINT64 HashDataLen
   );
 
+/**
+  Mesure a FirmwareBlob.
+
+  @param[in]  PcrIndexPCR Index.
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFirmwareBlob (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength
+  );
+
+/**
+  Mesure a FirmwareBlob in separation mode of FV binary and configuration.
+
+  @param[in]  Descrption  Description for this FirmwareBlob.
+  @param[in]  FirmwareBlobBaseBase address of this FirmwareBlob.
+  @param[in]  FirmwareBlobLength  Size in bytes of this FirmwareBlob.
+  @param[in]  CfgRegionOffset Configuration region offset in bytes.
+  @param[in]  CfgRegionSize   Configuration region in bytes.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureFirmwareBlobWithCfg (
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_PHYSICAL_ADDRESS   FirmwareBlobBase,
+  IN UINT64 FirmwareBlobLength,
+  IN UINT32 CfgRegionOffset,
+  IN UINT32 CfgRegionSize
+  );
+/**
+  Mesure a HandoffTable.
+
+  @param[in]  PcrIndexPcrIndex of the measurment.
+  @param[in]  Descrption  Description for this HandoffTable.
+  @param[in]  TableGuid   GUID of this HandoffTable.
+  @param[in]  TableAddressBase address of this HandoffTable.
+  @param[in]  TableLength Size in bytes of this HandoffTable.
+
+  @retval EFI_SUCCESS   Operation completed successfully.
+  @retval EFI_UNSUPPORTED   TPM device not available.
+  @retval EFI_OUT_OF_RESOURCES  Out of memory.
+  @retval EFI_DEVICE_ERROR  The operation was unsuccessful.
+*/
+EFI_STATUS
+EFIAPI
+MeasureHandoffTable (
+  IN UINT32 PcrIndex,
+  IN CHAR8  *Description OPTIONAL,
+  IN EFI_GUID   *TableGuid,
+  IN VOID   *TableAddress,
+  IN UINTN  TableLength
+  );
+
 #endif
-- 
2.26.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63559): https://edk2.groups.io/g/devel/message/63559
Mute This Topic: https://groups.io/mt/75903678/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [edk2-platform][PATCH v1 1/1] Platforms/RaspberryPi: Fix RPi4 GICC PMU PPI

2020-07-31 Thread Pete Batard

On 2020.07.28 22:00, Samer El-Haj-Mahmoud wrote:

Arm SBSA specification section ver 6.0, 4.1.5 defines specific PPI
values for certain standard interrupt IDs. The value for
"Performance Monitors Interrupt" needs to be 23.

REF: https://developer.arm.com/documentation/den0029/latest

This partially fixes SBSA test #11 ("Incorrect PPI value") reported in
https://github.com/pftf/RPi4/issues/74

Cc: Leif Lindholm 
Cc: Pete Batard 
Cc: Andrei Warkentin 
Cc: Ard Biesheuvel 
Signed-off-by: Samer El-Haj-Mahmoud 
---
  Platform/RaspberryPi/RPi4/RPi4.dsc | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc 
b/Platform/RaspberryPi/RPi4/RPi4.dsc
index c481c3534263..00683afe96b9 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -433,10 +433,10 @@ [PcdsFixedAtBuild.common]
gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceHBase|0xFF844000
gRaspberryPiTokenSpaceGuid.PcdGicInterruptInterfaceVBase|0xFF846000
gRaspberryPiTokenSpaceGuid.PcdGicGsivId|0x19
-  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|0x30
-  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|0x31
-  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|0x32
-  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|0x33
+  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq0|23
+  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq1|23
+  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq2|23
+  gRaspberryPiTokenSpaceGuid.PcdGicPmuIrq3|23
  
#

# Fixed CPU settings.



Reviewed-by: Pete Batard 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63556): https://edk2.groups.io/g/devel/message/63556
Mute This Topic: https://groups.io/mt/75853085/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by DISABLE_NEW_DEPRECATED_INTERFACES

2020-07-31 Thread Pete Batard

All,

Fix for Raspberry Pi platforms submitted at:
https://edk2.groups.io/g/devel/message/63554

Regards,

/Pete

On 2020.07.31 02:55, Liming Gao wrote:

Thanks Marcin.

Leif:
   Is there the way to get the fix plan from the platform owner? If so, I can 
work the plan to merge this change.

Thanks
Liming
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Marcin Wojtas
Sent: 2020年7月31日 0:09
To: Leif Lindholm 
Cc: Gao, Liming ; devel@edk2.groups.io; Zhang, Shenglei 
; Ard Biesheuvel ; Kinney, Michael D 
; Ming Huang ; Pete Batard 
Subject: Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by 
DISABLE_NEW_DEPRECATED_INTERFACES

Hi Leif,


śr., 29 lip 2020 o 15:35 Leif Lindholm  napisał(a):


Right, so the following platforms break once this patch is merged:

- AMD Overdrive, Overdrive 1000, Cello
- Hisilicon D03, D05, D06 (some of these due to binary drivers in
   edk2-non-osi)
- Marvell Armada 78x0/80x0, MacchiatoBIN


Fix for Marvell platforms submitted:
https://edk2.groups.io/g/devel/message/63472

Best regards,
Marcin


- Raspberry Pi 3/4

I think this provides enough argument to push this patch at least
until after August stable tag.

As far as I can tell, all of these are due to the PcdSet And
UnicodeStrToAsciiStr functions/macros disappearing. Presumably these
should be replaced with their S-suffixed counterparts.

Maintainers/reviewers on cc. I'd appreciate if you could update and
sanity check your platforms and send out patches.

Best Regards,

Leif

On Wed, Jul 29, 2020 at 13:24:15 +0100, Leif Lindholm wrote:

Thanks Liming,

Yes, this does affect several ARM platforms. Currently running a build
test to determine just how many. My preference would be for a change
of this magnitude to go in just after a stable tag - what, if any, are
the plans for this patch?

Best Regards,

Leif

On Wed, Jul 29, 2020 at 07:55:09 +, Gao, Liming wrote:

Include Leif and Ard. This change may impact ARM platform.

Thanks
Liming
-Original Message-
From: devel@edk2.groups.io  On Behalf Of Liming Gao
Sent: 2020年6月9日 21:08
To: Zhang, Shenglei ; devel@edk2.groups.io
Cc: Kinney, Michael D 
Subject: Re: [edk2-devel] [PATCH] MdePkg: Remove code wrapped by 
DISABLE_NEW_DEPRECATED_INTERFACES

Shenglei:
   Please also remove the deprecated code in MdeModulePkg.

Thanks
Liming

-Original Message-
From: Zhang, Shenglei 
Sent: Friday, June 5, 2020 4:13 PM
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 

Subject: [PATCH] MdePkg: Remove code wrapped by 
DISABLE_NEW_DEPRECATED_INTERFACES

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2777
Code wrapped by DISABLE_NEW_DEPRECATED_INTERFACES is deprecated.
So remove it.

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Shenglei Zhang 
---
  MdePkg/Library/BaseLib/String.c| 626 -
  MdePkg/Library/BasePcdLibNull/PcdLib.c | 361 --
  MdePkg/Library/BasePrintLib/PrintLib.c | 118 -
  MdePkg/Library/DxePcdLib/DxePcdLib.c   | 399 
  MdePkg/Library/PeiPcdLib/PeiPcdLib.c   | 397 
  MdePkg/Library/UefiLib/UefiLib.c   |  92 
  MdePkg/Include/Library/BaseLib.h   | 409 
  MdePkg/Include/Library/PcdLib.h| 520 
  MdePkg/Include/Library/PrintLib.h  | 110 -
  MdePkg/Include/Library/UefiLib.h   |  53 ---
  MdePkg/MdePkg.dsc  |   1 -
  11 files changed, 3086 deletions(-)

diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/String.c
index 45198373f25c..f4854f357e3a 100644
--- a/MdePkg/Library/BaseLib/String.c
+++ b/MdePkg/Library/BaseLib/String.c
@@ -8,135 +8,6 @@

  #include "BaseLibInternals.h"

-#ifndef DISABLE_NEW_DEPRECATED_INTERFACES
-
-/**
-  [ATTENTION] This function will be deprecated for security reason.
-
-  Copies one Null-terminated Unicode string to another Null-terminated Unicode
-  string and returns the new Unicode string.
-
-  This function copies the contents of the Unicode string Source to the Unicode
-  string Destination, and returns Destination. If Source and Destination
-  overlap, then the results are undefined.
-
-  If Destination is NULL, then ASSERT().
-  If Destination is not aligned on a 16-bit boundary, then ASSERT().
-  If Source is NULL, then ASSERT().
-  If Source is not aligned on a 16-bit boundary, then ASSERT().
-  If Source and Destination overlap, then ASSERT().
-  If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
-  PcdMaximumUnicodeStringLength Unicode characters, not including the
-  Null-terminator, then ASSERT().
-
-  @param  Destination A pointer to a Null-terminated Unicode string.
-  @param  Source  A pointer to a Null-terminated Unicode string.
-
-  @return Destination.
-
-**/
-CHAR16 *
-EFIAPI
-StrCpy (
-  OUT CHAR16*Destination,
-  IN  CONST CHAR16  *Source
-  )
-{
-  CHAR16*ReturnValue;
-
-  //
-  // Destination 

[edk2-devel] [edk2-platforms][PATCH 1/1] Platforms/RaspberryPi: Switch to PcdSet##S

2020-07-31 Thread Pete Batard
According to the bug:
https://bugzilla.tianocore.org/show_bug.cgi?id=2777
the deprecated code under DISABLE_NEW_DEPRECATED_INTERFACES
will be removed, which will result in compilation breakage
of the Raspberry Pi platforms. Prevent that by switching to
the different PcdSet API.

Signed-off-by: Pete Batard 
---
 Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c   | 34 ++--
 Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.c |  4 +--
 2 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c 
b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
index bab494a7c254..9f3372a7631d 100644
--- a/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
+++ b/Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.c
@@ -202,7 +202,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
+PcdSet32S (PcdCpuClock, PcdGet32 (PcdCpuClock));
   }
 
   Size = sizeof (UINT32);
@@ -210,25 +210,25 @@ SetupVariables (
 ,
 NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
+PcdSet32S (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
   }
 
   if (mModelFamily >= 4 && mModelInstalledMB > 3 * 1024) {
 /*
  * This allows changing PcdRamLimitTo3GB in forms.
  */
-PcdSet32 (PcdRamMoreThan3GB, 1);
+PcdSet32S (PcdRamMoreThan3GB, 1);
 
 Size = sizeof (UINT32);
 Status = gRT->GetVariable (L"RamLimitTo3GB",
,
NULL, , );
 if (EFI_ERROR (Status)) {
-  PcdSet32 (PcdRamLimitTo3GB, PcdGet32 (PcdRamLimitTo3GB));
+  PcdSet32S (PcdRamLimitTo3GB, PcdGet32 (PcdRamLimitTo3GB));
 }
   } else {
-PcdSet32 (PcdRamMoreThan3GB, 0);
-PcdSet32 (PcdRamLimitTo3GB, 0);
+PcdSet32S (PcdRamMoreThan3GB, 0);
+PcdSet32S (PcdRamLimitTo3GB, 0);
   }
 
   Size = sizeof (UINT32);
@@ -236,7 +236,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
+PcdSet32S (PcdSystemTableMode, PcdGet32 (PcdSystemTableMode));
   }
 
   Size = sizeof(AssetTagVar);
@@ -260,7 +260,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdSdIsArasan, PcdGet32 (PcdSdIsArasan));
+PcdSet32S (PcdSdIsArasan, PcdGet32 (PcdSdIsArasan));
   }
 
   Size = sizeof (UINT32);
@@ -268,7 +268,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdMmcDisableMulti, PcdGet32 (PcdMmcDisableMulti));
+PcdSet32S (PcdMmcDisableMulti, PcdGet32 (PcdMmcDisableMulti));
   }
 
   Size = sizeof (UINT32);
@@ -276,7 +276,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdMmcForce1Bit, PcdGet32 (PcdMmcForce1Bit));
+PcdSet32S (PcdMmcForce1Bit, PcdGet32 (PcdMmcForce1Bit));
   }
 
   Size = sizeof (UINT32);
@@ -284,7 +284,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdMmcForceDefaultSpeed, PcdGet32 (PcdMmcForceDefaultSpeed));
+PcdSet32S (PcdMmcForceDefaultSpeed, PcdGet32 (PcdMmcForceDefaultSpeed));
   }
 
   Size = sizeof (UINT32);
@@ -292,7 +292,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdMmcSdDefaultSpeedMHz, PcdGet32 (PcdMmcSdDefaultSpeedMHz));
+PcdSet32S (PcdMmcSdDefaultSpeedMHz, PcdGet32 (PcdMmcSdDefaultSpeedMHz));
   }
 
   Size = sizeof (UINT32);
@@ -300,7 +300,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdMmcSdHighSpeedMHz, PcdGet32 (PcdMmcSdHighSpeedMHz));
+PcdSet32S (PcdMmcSdHighSpeedMHz, PcdGet32 (PcdMmcSdHighSpeedMHz));
   }
 
   Size = sizeof (UINT32);
@@ -308,7 +308,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdDebugEnableJTAG, PcdGet32 (PcdDebugEnableJTAG));
+PcdSet32S (PcdDebugEnableJTAG, PcdGet32 (PcdDebugEnableJTAG));
   }
 
   Size = sizeof (UINT8);
@@ -316,7 +316,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet8 (PcdDisplayEnableScaledVModes, PcdGet8 
(PcdDisplayEnableScaledVModes));
+PcdSet8S (PcdDisplayEnableScaledVModes, PcdGet8 
(PcdDisplayEnableScaledVModes));
   }
 
   Size = sizeof (UINT32);
@@ -324,7 +324,7 @@ SetupVariables (
   ,
   NULL, , );
   if (EFI_ERROR (Status)) {
-PcdSet32 (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot));
+PcdSet32S (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot));
   }
 
   if (mModelFamily == 4) {
@@ -381,7 +381,7 

Re: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU generic bug fix

2020-07-31 Thread Liming Gao
Lorena:
  Thanks for your update. Can you correct name style as Star Zeng 
 for below message?

Suggested-by: Star Zeng star.z...@intel.com
Signed-off-by: 
lorena.r.de.leon.vazq...@intel.com

Thanks
Liming
From: De Leon Vasquez, Lorena R 
Sent: 2020年7月29日 23:23
To: Gao, Liming ; devel@edk2.groups.io; Lohr, Paul A 
; Yao, Jiewen 
Cc: Kinney, Michael D 
Subject: RE: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

I’ve attached patch with modifications suggested

From: Gao, Liming mailto:liming@intel.com>>
Sent: Thursday, July 9, 2020 7:45 AM
To: De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>;
 devel@edk2.groups.io; Lohr, Paul A 
mailto:paul.a.l...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: RE: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

Lorena:
  I have one minor comment on this patch. The error return status should be 
EFI_UNSUPPORTED.

+  return error;
==>
return EFI_UNSUPPORTED;

Thanks
Liming
From: De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>
Sent: Tuesday, July 7, 2020 1:24 AM
To: Gao, Liming mailto:liming@intel.com>>; 
devel@edk2.groups.io; Lohr, Paul A 
mailto:paul.a.l...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: RE: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

Hi Liming,
I’ve attached the patch

Thanks,
Lorena

From: Gao, Liming mailto:liming@intel.com>>
Sent: Thursday, July 2, 2020 8:54 PM
To: devel@edk2.groups.io; Lohr, Paul A 
mailto:paul.a.l...@intel.com>>; Yao, Jiewen 
mailto:jiewen@intel.com>>; De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: RE: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

Paul:
  This patch is missing to be merged.

Lorena:
  I can’t extract the patch from the mail. Can you send the patch to me? I can 
help merge it.

Thanks
Liming
From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Lohr, Paul A
Sent: Thursday, July 2, 2020 9:56 PM
To: devel@edk2.groups.io; Yao, Jiewen 
mailto:jiewen@intel.com>>; De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: Re: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

Hello,

It seems this did not get checked in.  Is there something wrong with the patch 
itself?  Or was this simply submitted incorrectly?  I don’t see a Bugzilla 
associated with it is why I ask.

Paul A. Lohr - Server Firmware Enabling
512.239.9073 (cell)
512.794.5044 (work)

From: devel@edk2.groups.io 
mailto:devel@edk2.groups.io>> On Behalf Of Yao, Jiewen
Sent: Monday, March 2, 2020 5:46 PM
To: De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>;
 devel@edk2.groups.io
Cc: Kinney, Michael D 
mailto:michael.d.kin...@intel.com>>
Subject: Re: [edk2-devel] [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU 
generic bug fix

Reviewed-by: jiewen@intel.com

From: De Leon Vazquez, Lorena R 
mailto:lorena.r.de.leon.vazq...@intel.com>>
Sent: Tuesday, March 3, 2020 7:04 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen mailto:jiewen@intel.com>>; Kinney, 
Michael D mailto:michael.d.kin...@intel.com>>
Subject: [edk2-platforms] [PATCH] IntelSiliconPkg: IOMMU generic bug fix

Looks like Addresswidth is BIT wise values. Right now these values are not used 
any

Suggested-by: Star Zeng star.z...@intel.com
Signed-off-by: 
lorena.r.de.leon.vazq...@intel.com

--
.../Feature/VTd/IntelVTdDxe/TranslationTable.c| 11 ---
.../Feature/VTd/IntelVTdDxe/TranslationTableEx.c  | 11 ---
2 files changed, 8 insertions(+), 14 deletions(-)

diff --git 
a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/TranslationTable.c 
b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/TranslationTable.c
index cc970c0..61fbb4a 100644
--- a/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/TranslationTable.c
+++ b/Silicon/Intel/IntelSiliconPkg/Feature/VTd/IntelVTdDxe/TranslationTable.c
@@ -128,14 +128,11 @@ CreateContextEntry (

 DEBUG ((DEBUG_INFO,"Source: S%04x B%02x D%02x F%02x\n", 
mVtdUnitInformation[VtdIndex].Segment, SourceId.Bits.Bus, SourceId.Bits.Device, 
SourceId.Bits.Function));

-switch (mVtdUnitInformation[VtdIndex].CapReg.Bits.SAGAW) {
-case BIT1:
-  

Re: [edk2-devel] [PATCH 1/1] Maintainers.txt: Add reviewer for FmpDevicePkg.

2020-07-31 Thread Liming Gao
Reviewed-by: Liming Gao 

-Original Message-
From: Xu, Wei6  
Sent: 2020年7月31日 15:29
To: devel@edk2.groups.io
Cc: Kinney, Michael D ; Gao, Liming 

Subject: [edk2-devel] [PATCH 1/1] Maintainers.txt: Add reviewer for 
FmpDevicePkg.

Add "Wei6 Xu" as reviewer for FmpDevicePkg.

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Wei6 Xu 
---
 Maintainers.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Maintainers.txt b/Maintainers.txt index 5504bb3d17..1eb6cb377e 
100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -195,10 +195,11 @@ T: git - https://github.com/tianocore/edk2-FatPkg.git
 FmpDevicePkg
 F: FmpDevicePkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/FmpDevicePkg
 M: Liming Gao 
 M: Michael D Kinney 
+R: Wei6 Xu 
 
 IntelFsp2Pkg
 F: IntelFsp2Pkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg
 M: Chasel Chiu 
--
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63553): https://edk2.groups.io/g/devel/message/63553
Mute This Topic: https://groups.io/mt/75903041/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



[edk2-devel] [PATCH 1/1] Maintainers.txt: Add reviewer for FmpDevicePkg.

2020-07-31 Thread Xu, Wei6
Add "Wei6 Xu" as reviewer for FmpDevicePkg.

Cc: Michael D Kinney 
Cc: Liming Gao 
Signed-off-by: Wei6 Xu 
---
 Maintainers.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Maintainers.txt b/Maintainers.txt
index 5504bb3d17..1eb6cb377e 100644
--- a/Maintainers.txt
+++ b/Maintainers.txt
@@ -195,10 +195,11 @@ T: git - https://github.com/tianocore/edk2-FatPkg.git
 FmpDevicePkg
 F: FmpDevicePkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/FmpDevicePkg
 M: Liming Gao 
 M: Michael D Kinney 
+R: Wei6 Xu 
 
 IntelFsp2Pkg
 F: IntelFsp2Pkg/
 W: https://github.com/tianocore/tianocore.github.io/wiki/IntelFsp2Pkg
 M: Chasel Chiu 
-- 
2.16.2.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63552): https://edk2.groups.io/g/devel/message/63552
Mute This Topic: https://groups.io/mt/75903041/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/7] FmpDevicePkg Minor Fixes

2020-07-31 Thread Xu, Wei6
Reviewed-by: Wei6 Xu 

-Original Message-
From: devel@edk2.groups.io  On Behalf Of Michael Kubacki
Sent: Friday, July 31, 2020 11:15 AM
To: devel@edk2.groups.io
Cc: Gao, Liming ; Kinney, Michael D 

Subject: [edk2-devel] [PATCH v1 0/7] FmpDevicePkg Minor Fixes

From: Michael Kubacki 

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

This patch series makes minor fixes and enhancements in FmpDevicePkg. None of 
the issues impact functionality in a major way.

These are smaller sets of changes that are being submitted prior to a larger 
future patch series that will cover functional changes for BZ2802.

Please check the git notes in patch 3 and patch 5.

Cc: Liming Gao 
Cc: Michael D Kinney 
Signed-off-by: Michael Kubacki 

Michael Kubacki (7):
  FmpDevicePkg/FmpDependencyLib: Correct ValidateDependency()
documentation
  FmpDevicePkg/FmpDependencyLib: Fix "exression" typo
  FmpDevicePkg/FmpDependencyLib: Handle version string overflow
  FmpDevicePkg/FmpDependencyCheckLib: Return unsatisfied on handle
failure
  FmpDevicePkg/FmpDxe: Better warn of potential ImageTypeId misconfig
  FmpDevicePkg/FmpDxe: Indicate ESRT GUID on invalid ImageIdName
  FmpDevicePkg/FmpDxe: Improve function parameter validation

 FmpDevicePkg/FmpDxe/FmpDxe.c   | 62 

 FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c |  2 +
 FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c   |  8 ++-
 FmpDevicePkg/FmpDxe/FmpDxe.h   | 10 ++--
 FmpDevicePkg/Include/Library/FmpDependencyLib.h|  5 +-
 5 files changed, 67 insertions(+), 20 deletions(-)

--
2.27.0.windows.1





-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63550): https://edk2.groups.io/g/devel/message/63550
Mute This Topic: https://groups.io/mt/75900877/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-