Date   

Re: [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix readme files in edk2-libc

Jayaprakash, N
 

Hi Mike,

Has this change been merged to master?

Regards,
JP

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: 02 November 2021 00:30
To: Jayaprakash, N <n.jayaprakash@...>; devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@...>
Cc: Rebecca Cran <rebecca@...>
Subject: RE: [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix readme files in edk2-libc

Series Reviewed-by: Michael D Kinney <michael.d.kinney@...>


-----Original Message-----
From: Jayaprakash, N <n.jayaprakash@...>
Sent: Monday, November 1, 2021 11:35 AM
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@...>; Kinney, Michael D
<michael.d.kinney@...>; Jayaprakash, N <n.jayaprakash@...>
Subject: [edk2-libc Patch V4 6/6] AppPkg/Applications/Python: to fix
readme files in edk2-libc

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

This commit is to update remaining references to py 2.7.10 in
StdLib/Readme.txt and StdLibPrivateInternalFiles/ReadMe.txt
documents to py3.6.8.

Cc: Rebecca Cran <rebecca@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Signed-off-by: Jayaprakash N <n.jayaprakash@...>
---
StdLib/ReadMe.txt | 15 +++++++--------
StdLibPrivateInternalFiles/ReadMe.txt | 14 ++++++--------
2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/StdLib/ReadMe.txt b/StdLib/ReadMe.txt index
5199692..8e0305e 100644
--- a/StdLib/ReadMe.txt
+++ b/StdLib/ReadMe.txt
@@ -158,14 +158,13 @@ There are some boiler-plate declarations and
definitions that need to be included in your application's INF and
DSC build files. These are described in the CONFIGURATION section, below.

-A subset of the Python 2.7.2 distribution is included as part of
AppPkg. If desired, -the full Python 2.7.2 distribution may be downloaded from python.org and used instead.
-Delete or rename the existing Python-2.7.2 directory then extract the
downloaded -Python-2.7.2.tgz file into the AppPkg\Applications\Python
directory. This will produce a
-Python-2.7.2 directory containing the full Python distribution.
Python files that had to be -modified for EDK II are in the
AppPkg\Applications\Python\PyMod-2.7.2 directory. These -files need
to be copied into the corresponding directories within the extracted Python-2.7.2 -directory before Python can be built.
+A full distribution of the Python 3.6.8 has been included as part of
+AppPkg. But only a subset of the features have been enabled for UEFI
+use case. Python files that had to be modified for EDK II are in the AppPkg\Applications\Python\Python-3.6.8\PyMod-3.6.8 directory.
+These files need to be copied into the corresponding directories
+within the Python-3.6.8 directory before Python can be built. This
+can be achieved by running the srcprep.py available under AppPkg\Applications\Python\Python-3.6.8.
+


BUILDING
diff --git a/StdLibPrivateInternalFiles/ReadMe.txt
b/StdLibPrivateInternalFiles/ReadMe.txt
index 424ee96..e21d2c8 100644
--- a/StdLibPrivateInternalFiles/ReadMe.txt
+++ b/StdLibPrivateInternalFiles/ReadMe.txt
@@ -146,14 +146,12 @@ There are some boiler-plate declarations and
definitions that need to be included in your application's INF and
DSC build files. These are described in the CONFIGURATION section, below.

-A subset of the Python 2.7.2 distribution is included as part of
AppPkg. If desired, -the full Python 2.7.2 distribution may be downloaded from python.org and used instead.
-Delete or rename the existing Python-2.7.2 directory then extract the
downloaded -Python-2.7.2.tgz file into the AppPkg\Applications\Python
directory. This will produce a
-Python-2.7.2 directory containing the full Python distribution.
Python files that had to be -modified for EDK II are in the
AppPkg\Applications\Python\PyMod-2.7.2 directory. These -files need
to be copied into the corresponding directories within the extracted Python-2.7.2 -directory before Python can be built.
+A full distribution of the Python 3.6.8 has been included as part of
+AppPkg. But only a subset of the features have been enabled for UEFI
+use case. Python files that had to be modified for EDK II are in the AppPkg\Applications\Python\Python-3.6.8\PyMod-3.6.8 directory.
+These files need to be copied into the corresponding directories
+within the Python-3.6.8 directory before Python can be built. This
+can be achieved by running the srcprep.py available under AppPkg\Applications\Python\Python-3.6.8.


BUILDING
--
2.32.0.windows.2


Re: [PATCH V3 14/29] UefiCpuPkg: Enable Tdx support in MpInitLib

Gerd Hoffmann
 

+++ b/UefiCpuPkg/Library/MpInitLib/X64/IntelTdcall.nasm
@@ -0,0 +1,120 @@
+;------------------------------------------------------------------------------
+;*
+;* Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
+;* SPDX-License-Identifier: BSD-2-Clause-Patent
+;*
+;*
+;------------------------------------------------------------------------------
+
+DEFAULT REL
+SECTION .text
+
+%macro tdcall 0
+ db 0x66,0x0f,0x01,0xcc
+%endmacro
Hmm, could you just use TdxLib instead of bringing your own copy of the
assembler code?

take care,
Gerd


Re: [PATCH 1/2] OvmfPkg/OvmfPkgX64: Add SEV launch secret and hashes table areas to MEMFD

Gerd Hoffmann
 

Hi,

Does SEV need and/or use SMM mode? Looking through AmdSevX64.dsc
doesn't give a clear answer, on one hand there is a
LibraryClasses.common.SMM_CORE section, but on the other hand it uses
the non-SMM variable driver stack.
I think SEV doesn't work with SMM. James - can you please give a more
definitive answer here?
SEV works with SMM, but SEV-ES (and likely SEV-SNP) doesn't work with SMM
because of the fact that the hypervisor wants to change the guest register
state to enter SMM, which isn't allowed and results in a VMRUN failure.
Ok. So the same reason why TDX doesn't support SMM either.

It might be possible to get SMM to work by having separate VMSAs for the SMM
state, but it is not anything that really has been investigated too deeply.
Should we just drop the SMM leftovers in AmdSevX64.{dsc,fdf} then?

take care,
Gerd


Re: The arm virtual machine displays problems in QXL during the UEFI phase

Gerd Hoffmann
 

On Wed, Nov 03, 2021 at 09:46:01AM +0800, Lange Tang wrote:
Hi Gerd:
Thanks for your reply. In fact, I have no choice, only QXL in my work.
1. I wonder why the device display be normal when it hung on bus=pci.8,addr=0x0, but it is abnormal when bus=pci.9,addr=0x1 or bus=pci.7,addr=0x0.
Placing qxl behind a pci bridge is problematic too (even on x86).
I'm surprised it works at all. qxl needs io ports 0x01ce + 0x1cf for
programming video modes in vga compatibility mode, and pci bridges
typically don't pass that though.

Maybe the working bridge got the 0x0000 -> 0x0fff io window assigned.
Wouldn't happen on x86 because of the legacy hardware in the 0x000 ->
0x3ff range, but maybe it is used for pci-pci bridges on arm.

2. Why cache properties are going to cause QXL display abnormal on
ARM. Are there any links or materials? Thanks.
The fundamental issue is that the pci memory br for vram is virtual.
The guest maps it as io memory, but it actually is normal ram, so guest
and host map the same memory with different attributes. That just
doesn't work on arm and results in display corruption when actually
running on arm hardware (when running in emulation, for example using
qemu on a x86 machine, this doesn't happen).

This is the reason why QemuVideoDxe is not compiled into ArmVirt.

take care,
Gerd


[PATCH] EmulatorPkg: Re-enable IA32 GCC5 CI builds

Akira Moroo
 

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

This commit re-enables the EmulatorPkg IA32 GCC5 CI builds with fixing
library dependencies.

The IA32 GCC5 CI builds are broken as the CI runner environment has
changed. According to commit `612edbe6cd71f4392b681b75849b2ab6e48f592d`,
which temporary disabled the CI builds, they are not working due to a
failure to install the i386 library dependencies in Ubuntu 18.04.

As previously commented in the Github Actions issue[1], the missing gcc
multi-architecture libraries prevent from successful build. This commit
fixes this issue by adding the missing library with version specified.

[1]
https://github.com/actions/virtual-environments/issues/2324#issuecomment-74=
9985726

Cc: Andrew Fish <afish@...>
Cc: Ray Ni <ray.ni@...>
Signed-off-by: Akira Moroo <retrage01@...>
---
.../.azurepipelines/Ubuntu-GCC5.yml | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)

diff --git a/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml b/Emula=
torPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
index 416c15e708..587976d815 100644
--- a/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
+++ b/EmulatorPkg/PlatformCI/.azurepipelines/Ubuntu-GCC5.yml
@@ -47,6 +47,27 @@ jobs:
Build.Target: "NOOPT"=0D
Run.Flags: $(run_flags)=0D
Run: $(should_run)=0D
+ EmulatorPkg_IA32_DEBUG:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: ""=0D
+ Build.Target: "DEBUG"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
+ EmulatorPkg_IA32_RELEASE:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: ""=0D
+ Build.Target: "RELEASE"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
+ EmulatorPkg_IA32_NOOPT:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: ""=0D
+ Build.Target: "NOOPT"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
EmulatorPkg_X64_FULL_DEBUG:=0D
Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
Build.Arch: "X64"=0D
@@ -68,6 +89,27 @@ jobs:
Build.Target: "NOOPT"=0D
Run.Flags: $(run_flags)=0D
Run: $(should_run)=0D
+ EmulatorPkg_IA32_FULL_DEBUG:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: "BLD_*_SECURE_BOOT_ENABLE=3DTRUE"=0D
+ Build.Target: "DEBUG"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
+ EmulatorPkg_IA32_FULL_RELEASE:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: "BLD_*_SECURE_BOOT_ENABLE=3DTRUE"=0D
+ Build.Target: "RELEASE"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
+ EmulatorPkg_IA32_FULL_NOOPT:=0D
+ Build.File: "$(package)/PlatformCI/PlatformBuild.py"=0D
+ Build.Arch: "IA32"=0D
+ Build.Flags: "BLD_*_SECURE_BOOT_ENABLE=3DTRUE"=0D
+ Build.Target: "NOOPT"=0D
+ Run.Flags: $(run_flags)=0D
+ Run: $(should_run)=0D
=0D
workspace:=0D
clean: all=0D
@@ -85,3 +127,14 @@ jobs:
build_file: $(Build.File)=0D
build_flags: $(Build.Flags)=0D
run_flags: $(Run.Flags)=0D
+ # Add steps to install some IA32 only dependencies=0D
+ extra_install_step:=0D
+ - bash: sudo dpkg --add-architecture i386=0D
+ displayName: Add i386 to dpkg=0D
+ condition: and(gt(variables.pkg_count, 0), eq(variables['Build.A=
rch'], 'IA32'), succeeded())=0D
+ - bash: sudo apt-get update=0D
+ displayName: do apt-get update=0D
+ condition: and(gt(variables.pkg_count, 0), eq(variables['Build.A=
rch'], 'IA32'), succeeded())=0D
+ - bash: sudo apt-get install libc6-dev:i386 libx11-dev:i386 libxex=
t-dev:i386 lib32gcc-9-dev gcc-9-multilib=0D
+ displayName: Add additional i386 packages=0D
+ condition: and(gt(variables.pkg_count, 0), eq(variables['Build.A=
rch'], 'IA32'), succeeded())=0D
--=20
2.33.0


Re: [Patch 4/6] SignedCapsulePkg/SignedCapsulePkg.dsc: Add RngLib mapping

Daniel Schaefer
 

Reviewed-by: Daniel Schaefer <daniel.schaefer@...>

On 11/3/21 11:05, Michael D Kinney wrote:
Fix build breaks for all architectures by adding RngLib mapping.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
SignedCapsulePkg/SignedCapsulePkg.dsc | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/SignedCapsulePkg/SignedCapsulePkg.dsc b/SignedCapsulePkg/SignedCapsulePkg.dsc
index 2152d3d15668..8a27207a6f20 100644
--- a/SignedCapsulePkg/SignedCapsulePkg.dsc
+++ b/SignedCapsulePkg/SignedCapsulePkg.dsc
@@ -93,6 +93,7 @@ [LibraryClasses]
EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf
IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
PlatformFlashAccessLib|SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.inf
+ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf

[LibraryClasses.ARM]
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
@@ -108,6 +109,12 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
# Add support for GCC stack protector
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[LibraryClasses.common.PEI_CORE]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf


Re: [Patch 3/6] SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM and RISCV64

Daniel Schaefer
 

Reviewed-by: Daniel Schaefer <daniel.schaefer@...>

On 11/3/21 13:28, Yao, Jiewen wrote:
Acked-by: Jiewen Yao <Jiewen.yao@...>

Need ARM/RISC-V owner to confirm.

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Wednesday, November 3, 2021 11:06 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>;
Ard Biesheuvel <ardb+tianocore@...>; Chang, Abner
<abner.chang@...>; Schaefer, Daniel <daniel.schaefer@...>
Subject: [Patch 3/6] SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM
and RISCV64

Fix SecurityPkg build breaks for ARM and RISCV64 by adding RngLib
mapping.

Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
SecurityPkg/SecurityPkg.dsc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 37318c64c59f..73a93c2285b1 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -84,6 +84,14 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# Add support for GCC stack protector
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

+ ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+
+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
@@ -381,4 +389,3 @@ [BuildOptions]
MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256
INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
--
2.32.0.windows.1


Re: [Patch 2/6] NetworkPkg/NetworkPkg.dsc: Add RngLib mapping for ARM and RISCV64

Daniel Schaefer
 

Perfect, thanks.
I think BaseRngLib has an implementation for ARM or perhaps only AARCH64.
I'm working one for RISCV64: https://bugzilla.tianocore.org/show_bug.cgi?id=3676

But until then this is good.

Reviewed-by: Daniel Schaefer <daniel.schaefer@...>

On 11/3/21 11:05, Michael D Kinney wrote:
Fix NetworkPkg build breaks for ARM and RISCV64 by adding RngLib
mapping.

Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
NetworkPkg/NetworkPkg.dsc | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index cf2164aefe25..8691a0f5d07a 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -79,6 +79,12 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf

+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[PcdsFeatureFlag]
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|TRUE
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|TRUE


Re: [Patch 3/6] SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM and RISCV64

Yao, Jiewen
 

Acked-by: Jiewen Yao <Jiewen.yao@...>

Need ARM/RISC-V owner to confirm.

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Wednesday, November 3, 2021 11:06 AM
To: devel@edk2.groups.io
Cc: Yao, Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>;
Ard Biesheuvel <ardb+tianocore@...>; Chang, Abner
<abner.chang@...>; Schaefer, Daniel <daniel.schaefer@...>
Subject: [Patch 3/6] SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM
and RISCV64

Fix SecurityPkg build breaks for ARM and RISCV64 by adding RngLib
mapping.

Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
SecurityPkg/SecurityPkg.dsc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 37318c64c59f..73a93c2285b1 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -84,6 +84,14 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# Add support for GCC stack protector
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

+ ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+
+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
@@ -381,4 +389,3 @@ [BuildOptions]
MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256
INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
--
2.32.0.windows.1


[Patch 5/6] UefiCpuPkg/MtrrLib/UnitTest: Fix 32-bit GCC build issues

Michael D Kinney
 

When using UT_ASSERT_EQUAL() on a pointer value, it must be
cast to UINTN. This follows the samples provided with the
UnitTestFrameworkPkg.

Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
index 30ee1dc32522..e84b9390601d 100644
--- a/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
+++ b/UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c
@@ -599,7 +599,7 @@ UnitTestMtrrGetFixedMtrr (
}

Result = MtrrGetFixedMtrr (&FixedSettings);
- UT_ASSERT_EQUAL (Result, &FixedSettings);
+ UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&FixedSettings);
UT_ASSERT_MEM_EQUAL (&FixedSettings, &ExpectedFixedSettings, sizeof (FixedSettings));
}

@@ -612,7 +612,7 @@ UnitTestMtrrGetFixedMtrr (
ZeroMem (&FixedSettings, sizeof (FixedSettings));
ZeroMem (&ExpectedFixedSettings, sizeof (ExpectedFixedSettings));
Result = MtrrGetFixedMtrr (&FixedSettings);
- UT_ASSERT_EQUAL (Result, &FixedSettings);
+ UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&FixedSettings);
UT_ASSERT_MEM_EQUAL (&ExpectedFixedSettings, &FixedSettings, sizeof (ExpectedFixedSettings));

return UNIT_TEST_PASSED;
@@ -653,7 +653,7 @@ UnitTestMtrrGetAllMtrrs (
AsmWriteMsr64 (MSR_IA32_MTRR_PHYSMASK0 + (Index << 1), VariableMtrr[Index].Mask);
}
Result = MtrrGetAllMtrrs (&Mtrrs);
- UT_ASSERT_EQUAL (Result, &Mtrrs);
+ UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&Mtrrs);
UT_ASSERT_MEM_EQUAL (Mtrrs.Variables.Mtrr, VariableMtrr, sizeof (MTRR_VARIABLE_SETTING) * SystemParameter.VariableMtrrCount);

//
@@ -665,7 +665,7 @@ UnitTestMtrrGetAllMtrrs (
SystemParameter.MtrrSupported = FALSE;
InitializeMtrrRegs (&SystemParameter);
Result = MtrrGetAllMtrrs (&Mtrrs);
- UT_ASSERT_EQUAL (Result, &Mtrrs);
+ UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&Mtrrs);
UT_ASSERT_MEM_EQUAL (&ExpectedMtrrs, &Mtrrs, sizeof (ExpectedMtrrs));

//
@@ -718,7 +718,7 @@ UnitTestMtrrSetAllMtrrs (
GenerateRandomMtrrPair (SystemParameter.PhysicalAddressBits, GenerateRandomCacheType (), &Mtrrs.Variables.Mtrr[Index], NULL);
}
Result = MtrrSetAllMtrrs (&Mtrrs);
- UT_ASSERT_EQUAL (Result, &Mtrrs);
+ UT_ASSERT_EQUAL ((UINTN)Result, (UINTN)&Mtrrs);

UT_ASSERT_EQUAL (AsmReadMsr64 (MSR_IA32_MTRR_DEF_TYPE), Mtrrs.MtrrDefType);
for (Index = 0; Index < SystemParameter.VariableMtrrCount; Index++) {
--
2.32.0.windows.1


[Patch 6/6] MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds

Michael D Kinney
 

When using will_return() on a pointer value, it must be
cast to UINTN to be compatible with 32-bit GCC builds.
This uses the same approach in samples provided in the
UnitTestFramworkPkg when passing pointer values to
UT_ASSERT_EQUAL().

Cc: Hao A Wu <hao.a.wu@...>
Cc: Liming Gao <gaoliming@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
.../RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
index 44d70e639d77..880994fe71fc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/RuntimeDxeUnitTest/VariableLockRequestToLockUnitTest.c
@@ -287,7 +287,7 @@ LockingAnUnlockedVariableShouldFail (
// With a policy, make sure that writes still work, since the variable doesn't exist.
will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL ); // Attributes
will_return( StubGetVariableNull, 0 ); // Size
- will_return( StubGetVariableNull, NULL ); // DataPtr
+ will_return( StubGetVariableNull, (UINTN)NULL ); // DataPtr
will_return( StubGetVariableNull, EFI_NOT_FOUND); // Status

Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -342,7 +342,7 @@ LockingALockedVariableWithMatchingDataShouldSucceed (
Data = 1;
will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL ); // Attributes
will_return( StubGetVariableNull, sizeof (Data) ); // Size
- will_return( StubGetVariableNull, &Data ); // DataPtr
+ will_return( StubGetVariableNull, (UINTN)&Data ); // DataPtr
will_return( StubGetVariableNull, EFI_SUCCESS); // Status

Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
@@ -397,7 +397,7 @@ LockingALockedVariableWithNonMatchingDataShouldFail (
Data = 2;
will_return( StubGetVariableNull, TEST_POLICY_ATTRIBUTES_NULL ); // Attributes
will_return( StubGetVariableNull, sizeof (Data) ); // Size
- will_return( StubGetVariableNull, &Data ); // DataPtr
+ will_return( StubGetVariableNull, (UINTN)&Data ); // DataPtr
will_return( StubGetVariableNull, EFI_SUCCESS); // Status

Status = VariableLockRequestToLock (NULL, TEST_VAR_1_NAME, &mTestGuid1);
--
2.32.0.windows.1


[Patch 3/6] SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM and RISCV64

Michael D Kinney
 

Fix SecurityPkg build breaks for ARM and RISCV64 by adding RngLib
mapping.

Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
SecurityPkg/SecurityPkg.dsc | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/SecurityPkg/SecurityPkg.dsc b/SecurityPkg/SecurityPkg.dsc
index 37318c64c59f..73a93c2285b1 100644
--- a/SecurityPkg/SecurityPkg.dsc
+++ b/SecurityPkg/SecurityPkg.dsc
@@ -84,6 +84,14 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# Add support for GCC stack protector
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

+ ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
+
+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[LibraryClasses.common.PEIM]
PeimEntryPoint|MdePkg/Library/PeimEntryPoint/PeimEntryPoint.inf
PeiServicesLib|MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
@@ -381,4 +389,3 @@ [BuildOptions]
MSFT:*_*_IA32_DLINK_FLAGS = /ALIGN:256
INTEL:*_*_IA32_DLINK_FLAGS = /ALIGN:256
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-
--
2.32.0.windows.1


[Patch 4/6] SignedCapsulePkg/SignedCapsulePkg.dsc: Add RngLib mapping

Michael D Kinney
 

Fix build breaks for all architectures by adding RngLib mapping.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
SignedCapsulePkg/SignedCapsulePkg.dsc | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/SignedCapsulePkg/SignedCapsulePkg.dsc b/SignedCapsulePkg/SignedCapsulePkg.dsc
index 2152d3d15668..8a27207a6f20 100644
--- a/SignedCapsulePkg/SignedCapsulePkg.dsc
+++ b/SignedCapsulePkg/SignedCapsulePkg.dsc
@@ -93,6 +93,7 @@ [LibraryClasses]
EdkiiSystemCapsuleLib|SignedCapsulePkg/Library/EdkiiSystemCapsuleLib/EdkiiSystemCapsuleLib.inf
IniParsingLib|SignedCapsulePkg/Library/IniParsingLib/IniParsingLib.inf
PlatformFlashAccessLib|SignedCapsulePkg/Library/PlatformFlashAccessLibNull/PlatformFlashAccessLibNull.inf
+ RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf

[LibraryClasses.ARM]
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf
@@ -108,6 +109,12 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
# Add support for GCC stack protector
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf

+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[LibraryClasses.common.PEI_CORE]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
--
2.32.0.windows.1


[Patch 2/6] NetworkPkg/NetworkPkg.dsc: Add RngLib mapping for ARM and RISCV64

Michael D Kinney
 

Fix NetworkPkg build breaks for ARM and RISCV64 by adding RngLib
mapping.

Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
NetworkPkg/NetworkPkg.dsc | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index cf2164aefe25..8691a0f5d07a 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -79,6 +79,12 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf

+[LibraryClasses.ARM]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
+[LibraryClasses.RISCV64]
+ RngLib|MdePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
+
[PcdsFeatureFlag]
gEfiMdePkgTokenSpaceGuid.PcdComponentName2Disable|TRUE
gEfiMdePkgTokenSpaceGuid.PcdDriverDiagnostics2Disable|TRUE
--
2.32.0.windows.1


[Patch 0/6] Fix package build issues

Michael D Kinney
 

This patch series fixes a number of diffent package build
issues. These were discovered when evaluating the source
format changes from uncrustify and there where valid
package builds that are not working before applying the
uncrustify changes.

* Missing RngLib mappings
* Missing ArmSoftFloatLib mapping
* Missing BaseStackCheckLib instance
* Incorrect use of UT_ASSERT_EQUAL() with pointers
* Incorrect use of cmocka will_return*() with pointers

Cc: Hao A Wu <hao.a.wu@...>
Cc: Liming Gao <gaoliming@...>
Cc: Bret Barkelew <Bret.Barkelew@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Abner Chang <abner.chang@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Cc: Sami Mujawar <Sami.Mujawar@...>
Cc: Alexei Fedorov <Alexei.Fedorov@...>
Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>

Michael D Kinney (6):
DynamicTablesPkg: Add missing BaseStackCheckLib instance
NetworkPkg/NetworkPkg.dsc: Add RngLib mapping for ARM and RISCV64
SecurityPkg/SecurityPkg.dsc: Add missing RngLib for ARM and RISCV64
SignedCapsulePkg/SignedCapsulePkg.dsc: Add RngLib mapping
UefiCpuPkg/MtrrLib/UnitTest: Fix 32-bit GCC build issues
MdeModulePkg/Variable/RuntimeDxeUnitTest: Fix 32-bit GCC builds

DynamicTablesPkg/DynamicTablesPkg.dsc | 2 +-
.../VariableLockRequestToLockUnitTest.c | 6 +++---
NetworkPkg/NetworkPkg.dsc | 6 ++++++
SecurityPkg/SecurityPkg.dsc | 9 ++++++++-
SignedCapsulePkg/SignedCapsulePkg.dsc | 7 +++++++
UefiCpuPkg/Library/MtrrLib/UnitTest/MtrrLibUnitTest.c | 10 +++++-----
6 files changed, 30 insertions(+), 10 deletions(-)

--
2.32.0.windows.1


[Patch 1/6] DynamicTablesPkg: Add missing BaseStackCheckLib instance

Michael D Kinney
 

Fix ARM and AARCH64 build issues by adding the BaseStackCheckLib
instance.

Cc: Sami Mujawar <Sami.Mujawar@...>
Cc: Alexei Fedorov <Alexei.Fedorov@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Signed-off-by: Michael D Kinney <michael.d.kinney@...>
---
DynamicTablesPkg/DynamicTablesPkg.dsc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/DynamicTablesPkg.dsc
index 46b2e667fd25..e1439a130143 100644
--- a/DynamicTablesPkg/DynamicTablesPkg.dsc
+++ b/DynamicTablesPkg/DynamicTablesPkg.dsc
@@ -35,6 +35,7 @@ [LibraryClasses]

[LibraryClasses.ARM, LibraryClasses.AARCH64]
NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+ NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf
PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf

[Components.common]
@@ -51,4 +52,3 @@ [BuildOptions]
# Inhibit C6305: Potential mismatch between sizeof and countof quantities.
*_VS2017_*_CC_FLAGS = /wd6305 /analyze
!endif
-
--
2.32.0.windows.1


Re: [PATCH V4 3/3] SecurityPkg: Support CcMeasurementProtocol in DxeTpmMeasurementLib

Min Xu
 

On November 2, 2021 2:25 PM, Jiewen Yao wrote:
May I know which platform you have run the test?

I think we need cover both TD and TPM in real platform.
I have run the test in Intel's internal hardware platform (covering both TD and TPM).
The test all pass.

Thanks
Min


Re: [PATCH V4 2/3] SecurityPkg: Support CcMeasurementProtocol in DxeTpm2MeasureBootLib

Min Xu
 

On November 2, 2021 2:25 PM, Jiewen Yao wrote:
May I know which platform you have run the test?

I think we need cover both TD and TPM in real platform.
I have run the test in Intel's internal hardware platform (covering both TD and TPM).
The test all pass.

Thanks
Min


Re: [PATCH v2 1/1] MdeModulePkg: Add MpServicesTest application to exercise MP Services

Rebecca Cran <rebecca@...>
 

Sami,


I don't see your review. Did you review this, or just the separate patch to add EFI_MP_SERVICES_PROTOCOL for AArch64?


--
Rebecca Cran


On 10/16/21 12:54 AM, Sami Mujawar wrote:
Hi Rebecca,

I will review this next week.

Regard

Sami Mujawar


From: Rebecca Cran <rebecca@...>
Sent: Saturday, 16 October 2021, 7:33 am
To: devel@edk2.groups.io; Jian J Wang; Liming Gao
Cc: Ard Biesheuvel; Samer El-Haj-Mahmoud; Leif Lindholm; Sami Mujawar; Gerd Hoffmann
Subject: Re: [edk2-devel] [PATCH v2 1/1] MdeModulePkg: Add MpServicesTest application to exercise MP Services

(cc Leif, Ard, Sami, Samer, Gerd)


Could someone review this please?


--
Rebecca Cran


On 9/20/21 9:47 AM, Rebecca Cran via groups.io wrote:
> Add a new MpServicesTest application under MdeModulePkg/Application that
> exercises the EFI_MP_SERVICES_PROTOCOL.
>
> Signed-off-by: Rebecca Cran <rebecca@...>
> ---
>   MdeModulePkg/Application/MpServicesTest/MpServicesTest.c   | 433 ++++++++++++++++++++
>   MdeModulePkg/Application/MpServicesTest/MpServicesTest.inf |  38 ++
>   MdeModulePkg/MdeModulePkg.dsc                              |   2 +
>   3 files changed, 473 insertions(+)
>
> diff --git a/MdeModulePkg/Application/MpServicesTest/MpServicesTest.c b/MdeModulePkg/Application/MpServicesTest/MpServicesTest.c
> new file mode 100644
> index 000000000000..4eb06e6b7cbd
> --- /dev/null
> +++ b/MdeModulePkg/Application/MpServicesTest/MpServicesTest.c
> @@ -0,0 +1,433 @@
> +/** @file
> +
> +    Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +    SPDX-License-Identifier: BSD-2-Clause-Patent
> +**/
> +
> +#include <Uefi.h>
> +#include <Library/DebugLib.h>
> +#include <Library/RngLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/UefiLib.h>
> +#include <Pi/PiMultiPhase.h>
> +#include <Protocol/MpService.h>
> +
> +#define MAX_RANDOM_PROCESSOR_RETRIES 10
> +
> +#define AP_STARTUP_TEST_TIMEOUT_US  50000
> +#define INFINITE_TIMEOUT            0
> +
> +#define RETURN_IF_EFI_ERROR(x)   \
> +  if (EFI_ERROR (x)) {           \
> +    Print (L"failed: %r\n", x);  \
> +    return;                      \
> +  }                              \
> +  else {                         \
> +    Print (L"done.\n");          \
> +  }
> +
> +/** The procedure to run with the MP Services interface.
> +
> +  @param Buffer The procedure argument.
> +
> +**/
> +STATIC
> +VOID
> +EFIAPI
> +ApFunction (
> +  IN OUT VOID *Buffer
> +  )
> +{
> +}
> +
> +/** Displays information returned from MP Services Protocol.
> +
> +  @param Mp  The MP Services Protocol
> +
> +  @return The number of CPUs in the system.
> +
> +**/
> +STATIC
> +UINTN
> +PrintProcessorInformation (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp
> +  )
> +{
> +  EFI_STATUS                 Status;
> +  EFI_PROCESSOR_INFORMATION  CpuInfo;
> +  UINTN                      Index;
> +  UINTN                      NumCpu;
> +  UINTN                      NumEnabledCpu;
> +
> +  Status = Mp->GetNumberOfProcessors (Mp, &NumCpu, &NumEnabledCpu);
> +  if (EFI_ERROR (Status)) {
> +    Print (L"GetNumberOfProcessors failed: %r\n", Status);
> +  } else {
> +    Print (L"Number of CPUs: %ld, Enabled: %d\n", NumCpu, NumEnabledCpu);
> +  }
> +
> +  for (Index = 0; Index < NumCpu; Index++) {
> +    Status = Mp->GetProcessorInfo (Mp, CPU_V2_EXTENDED_TOPOLOGY | Index, &CpuInfo);
> +    if (EFI_ERROR (Status)) {
> +      Print (L"GetProcessorInfo for Processor %d failed: %r\n", Index, Status);
> +    } else {
> +      Print (
> +        L"Processor %d:\n"
> +        L"\tID: %016lx\n"
> +        L"\tStatus: %s | ",
> +        Index,
> +        CpuInfo.ProcessorId,
> +        (CpuInfo.StatusFlag & PROCESSOR_AS_BSP_BIT) ? L"BSP" : L"AP"
> +        );
> +
> +      Print (L"%s | ", (CpuInfo.StatusFlag & PROCESSOR_ENABLED_BIT) ? L"Enabled" : L"Disabled");
> +      Print (L"%s\n", (CpuInfo.StatusFlag & PROCESSOR_HEALTH_STATUS_BIT) ? L"Healthy" : L"Faulted");
> +
> +      Print (
> +        L"\tLocation: Package %d, Core %d, Thread %d\n"
> +        L"\tExtended Information: Package %d, Module %d, Tile %d, Die %d, Core %d, Thread %d\n\n",
> +        CpuInfo.Location.Package,
> +        CpuInfo.Location.Core,
> +        CpuInfo.Location.Thread,
> +        CpuInfo.ExtendedInformation.Location2.Package,
> +        CpuInfo.ExtendedInformation.Location2.Module,
> +        CpuInfo.ExtendedInformation.Location2.Tile,
> +        CpuInfo.ExtendedInformation.Location2.Die,
> +        CpuInfo.ExtendedInformation.Location2.Core,
> +        CpuInfo.ExtendedInformation.Location2.Thread
> +        );
> +    }
> +  }
> +
> +  return NumCpu;
> +}
> +
> +/** Returns the index of an enabled AP selected at random.
> +
> +  @param Mp             The MP Services Protocol.
> +  @param ProcessorIndex The index of a random enabled AP.
> +
> +  @retval EFI_SUCCESS   An enabled processor was found and returned.
> +  @retval EFI_NOT_FOUND A processor was unable to be selected.
> +
> +**/
> +STATIC
> +EFI_STATUS
> +GetRandomEnabledProcessorIndex (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp,
> +  OUT UINTN *ProcessorIndex
> +  )
> +{
> +  UINTN                      Index;
> +  UINTN                      IndexOfEnabledCpu;
> +  UINTN                      NumCpus;
> +  UINTN                      NumEnabledCpus;
> +  UINTN                      IndexOfEnabledCpuToUse;
> +  UINT16                     RandomNumber;
> +  BOOLEAN                    Success;
> +  EFI_STATUS                 Status;
> +  EFI_PROCESSOR_INFORMATION  CpuInfo;
> +
> +  IndexOfEnabledCpu = 0;
> +
> +  Success = GetRandomNumber16 (&RandomNumber);
> +  ASSERT (Success == TRUE);
> +
> +  Status = Mp->GetNumberOfProcessors (Mp, &NumCpus, &NumEnabledCpus);
> +  ASSERT_EFI_ERROR (Status);
> +
> +  if (NumEnabledCpus == 1) {
> +    Print (L"All APs are disabled\n");
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  IndexOfEnabledCpuToUse = RandomNumber % NumEnabledCpus;
> +
> +  for (Index = 0; Index < NumCpus; Index++) {
> +    Status = Mp->GetProcessorInfo (Mp, Index, &CpuInfo);
> +    ASSERT_EFI_ERROR (Status);
> +    if ((CpuInfo.StatusFlag & PROCESSOR_ENABLED_BIT) &&
> +        !(CpuInfo.StatusFlag & PROCESSOR_AS_BSP_BIT)) {
> +      if (IndexOfEnabledCpuToUse == IndexOfEnabledCpu) {
> +        *ProcessorIndex = Index;
> +        Status = EFI_SUCCESS;
> +        break;
> +      }
> +
> +      IndexOfEnabledCpu++;
> +    }
> +  }
> +
> +  if (Index == NumCpus) {
> +    Status = EFI_NOT_FOUND;
> +  }
> +
> +  return Status;
> +}
> +
> +/** Tests for the StartupThisAP function.
> +
> +  @param Mp The MP Services Protocol.
> +
> +**/
> +STATIC
> +VOID
> +StartupThisApTests (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINTN       ProcessorIndex;
> +  UINT32      Retries;
> +
> +  Retries = 0;
> +
> +  do {
> +    Status = GetRandomEnabledProcessorIndex (Mp, &ProcessorIndex);
> +  } while (EFI_ERROR (Status) && Retries++ < MAX_RANDOM_PROCESSOR_RETRIES);
> +
> +  if (EFI_ERROR (Status)) {
> +    return;
> +  }
> +
> +  Print (
> +    L"StartupThisAP on Processor %d with 0 (infinite) timeout...",
> +    ProcessorIndex
> +    );
> +
> +  Status = Mp->StartupThisAP (
> +    Mp,
> +    ApFunction,
> +    ProcessorIndex,
> +    NULL,
> +    INFINITE_TIMEOUT,
> +    NULL,
> +    NULL
> +    );
> +
> +  RETURN_IF_EFI_ERROR (Status);
> +
> +  Retries = 0;
> +
> +  do {
> +    Status = GetRandomEnabledProcessorIndex (Mp, &ProcessorIndex);
> +  } while (EFI_ERROR (Status) && Retries++ < MAX_RANDOM_PROCESSOR_RETRIES);
> +
> +  if (EFI_ERROR (Status)) {
> +    return;
> +  }
> +
> +  Print (
> +    L"StartupThisAP on Processor %d with %dms timeout...",
> +    ProcessorIndex,
> +    AP_STARTUP_TEST_TIMEOUT_US / 1000
> +    );
> +  Status = Mp->StartupThisAP (
> +                 Mp,
> +                 ApFunction,
> +                 ProcessorIndex,
> +                 NULL,
> +                 AP_STARTUP_TEST_TIMEOUT_US,
> +                 NULL,
> +                 NULL
> +                 );
> +  RETURN_IF_EFI_ERROR (Status);
> +}
> +
> +/** Tests for the StartupAllAPs function.
> +
> +  @param Mp      The MP Services Protocol.
> +  @param NumCpus The number of CPUs in the system.
> +
> +**/
> +STATIC
> +VOID
> +StartupAllAPsTests (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp,
> +  IN UINTN NumCpus
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINTN       Timeout;
> +
> +  Print (L"Running with SingleThread FALSE, 0 (infinite) timeout...");
> +  Status = Mp->StartupAllAPs (Mp, ApFunction, FALSE, NULL, INFINITE_TIMEOUT, NULL, NULL);
> +  RETURN_IF_EFI_ERROR (Status);
> +
> +  Timeout = NumCpus * AP_STARTUP_TEST_TIMEOUT_US;
> +
> +  Print (L"Running with SingleThread TRUE, %dms timeout...", Timeout / 1000);
> +  Status = Mp->StartupAllAPs (
> +                 Mp,
> +                 ApFunction,
> +                 TRUE,
> +                 NULL,
> +                 Timeout,
> +                 NULL,
> +                 NULL
> +                 );
> +  RETURN_IF_EFI_ERROR (Status);
> +}
> +
> +/** Tests for the EnableDisableAP function.
> +
> +  @param Mp      The MP Services Protocol.
> +  @param NumCpus The number of CPUs in the system.
> +
> +**/
> +STATIC
> +VOID
> +EnableDisableAPTests (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp,
> +  IN UINTN                    NumCpus
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINTN       Index;
> +  UINT32      HealthFlag;
> +
> +  HealthFlag = 0;
> +
> +  for (Index = 1; Index < NumCpus; Index++) {
> +    Print (L"Disabling Processor %d with HealthFlag faulted...", Index);
> +    Status = Mp->EnableDisableAP (Mp, Index, FALSE, &HealthFlag);
> +    RETURN_IF_EFI_ERROR (Status);
> +  }
> +
> +  HealthFlag = PROCESSOR_HEALTH_STATUS_BIT;
> +
> +  for (Index = 1; Index < NumCpus; Index++) {
> +    Print (L"Enabling Processor %d with HealthFlag healthy...", Index);
> +    Status = Mp->EnableDisableAP (Mp, Index, TRUE, &HealthFlag);
> +    RETURN_IF_EFI_ERROR (Status);
> +  }
> +}
> +
> +/** Tests for the SwitchBSP function.
> +
> +  @param Mp      The MP Services Protocol.
> +  @param NumCpus The number of CPUs in the system.
> +
> +**/
> +STATIC
> +VOID
> +SwitchBSPTests (
> +  IN EFI_MP_SERVICES_PROTOCOL *Mp,
> +  IN UINTN                    NumCpus
> +  )
> +{
> +  EFI_STATUS  Status;
> +  UINTN       Index;
> +
> +  for (Index = 1; Index < NumCpus; Index++) {
> +    Print (L"Switching BSP to Processor %d with EnableOldBSP FALSE...", Index);
> +    Status = Mp->SwitchBSP (Mp, Index, FALSE);
> +    RETURN_IF_EFI_ERROR (Status);
> +  }
> +
> +  for (Index = 0; Index < NumCpus; Index++) {
> +    Print (L"Switching BSP to Processor %d with EnableOldBSP TRUE...", Index);
> +    Status = Mp->SwitchBSP (Mp, Index, TRUE);
> +    RETURN_IF_EFI_ERROR (Status);
> +  }
> +}
> +
> +/**
> +  The user Entry Point for Application. The user code starts with this function
> +  as the real entry point for the application.
> +
> +  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
> +  @param[in] SystemTable    A pointer to the EFI System Table.
> +
> +  @retval EFI_SUCCESS       The entry point is executed successfully.
> +  @retval other             Some error occurs when executing this entry point.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +UefiMain (
> +  IN EFI_HANDLE        ImageHandle,
> +  IN EFI_SYSTEM_TABLE  *SystemTable
> +  )
> +{
> +  EFI_STATUS                Status;
> +  EFI_MP_SERVICES_PROTOCOL  *Mp;
> +  EFI_HANDLE                *pHandle;
> +  UINTN                     HandleCount;
> +  UINTN                     BspId;
> +  UINTN                     NumCpus;
> +  UINTN                     Index;
> +
> +  pHandle     = NULL;
> +  HandleCount = 0;
> +  BspId = 0;
> +
> +  Status = gBS->LocateHandleBuffer (
> +                  ByProtocol,
> +                  &gEfiMpServiceProtocolGuid,
> +                  NULL,
> +                  &HandleCount,
> +                  &pHandle
> +                  );
> +
> +  if (EFI_ERROR (Status)) {
> +    Print (L"Failed to locate EFI_MP_SERVICES_PROTOCOL (%r). Not installed on platform?\n", Status);
> +    return EFI_NOT_FOUND;
> +  }
> +
> +  for (Index = 0; Index < HandleCount; Index++) {
> +    Status = gBS->OpenProtocol (
> +                    *pHandle,
> +                    &gEfiMpServiceProtocolGuid,
> +                    (VOID **)&Mp,
> +                    NULL,
> +                    gImageHandle,
> +                    EFI_OPEN_PROTOCOL_GET_PROTOCOL
> +                    );
> +
> +    if (EFI_ERROR (Status)) {
> +      return Status;
> +    }
> +
> +    pHandle++;
> +  }
> +
> +  Print (L"Exercising WhoAmI\n\n");
> +  Status = Mp->WhoAmI (Mp, &BspId);
> +  if (EFI_ERROR (Status)) {
> +    Print (L"WhoAmI failed: %r\n", Status);
> +    return Status;
> +  } else {
> +    Print (L"WhoAmI: %016lx\n", BspId);
> +  }
> +
> +  Print (L"\n");
> +  Print (
> +    L"Exercising GetNumberOfProcessors and GetProcessorInformation with "
> +    L"CPU_V2_EXTENDED_TOPOLOGY\n\n"
> +    );
> +  NumCpus = PrintProcessorInformation (Mp);
> +  if (NumCpus < 2) {
> +    Print (L"UP system found. Not running further tests.\n");
> +    return EFI_INVALID_PARAMETER;
> +  }
> +
> +  Print (L"\n");
> +  Print (L"Exercising StartupThisAP:\n\n");
> +  StartupThisApTests (Mp);
> +
> +  Print (L"\n");
> +  Print (L"Exercising StartupAllAPs:\n\n");
> +  StartupAllAPsTests (Mp, NumCpus);
> +
> +  Print (L"\n");
> +  Print (L"Exercising EnableDisableAP:\n\n");
> +  EnableDisableAPTests (Mp, NumCpus);
> +
> +  Print (L"\n");
> +  Print (L"Exercising SwitchBSP\n\n");
> +  SwitchBSPTests (Mp, NumCpus);
> +
> +  gBS->CloseProtocol (pHandle, &gEfiMpServiceProtocolGuid, gImageHandle, NULL);
> +  return EFI_SUCCESS;
> +}
> diff --git a/MdeModulePkg/Application/MpServicesTest/MpServicesTest.inf b/MdeModulePkg/Application/MpServicesTest/MpServicesTest.inf
> new file mode 100644
> index 000000000000..8a21ca70d8fa
> --- /dev/null
> +++ b/MdeModulePkg/Application/MpServicesTest/MpServicesTest.inf
> @@ -0,0 +1,38 @@
> +## @file
> +#  UEFI Application to exercise EFI_MP_SERVICES_PROTOCOL.
> +#
> +#  Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
> +#
> +#  SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 1.29
> +  BASE_NAME                      = MpServicesTest
> +  FILE_GUID                      = 43e9defa-7209-4b0d-b136-cc4ca02cb469
> +  MODULE_TYPE                    = UEFI_APPLICATION
> +  VERSION_STRING                 = 0.1
> +  ENTRY_POINT                    = UefiMain
> +
> +#
> +# The following information is for reference only and not required by the build tools.
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 AARCH64
> +#
> +
> +[Sources]
> +  MpServicesTest.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  BaseLib
> +  RngLib
> +  UefiApplicationEntryPoint
> +  UefiLib
> +
> +[Protocols]
> +  gEfiMpServiceProtocolGuid    ## CONSUMES
> +
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index b1d83461865e..1cf5ccd30d40 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -164,6 +164,7 @@
>     MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
>     DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
>     FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
> +  RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf
>  
>   [LibraryClasses.common.MM_STANDALONE]
>     HobLib|MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> @@ -215,6 +216,7 @@
>     MdeModulePkg/Application/HelloWorld/HelloWorld.inf
>     MdeModulePkg/Application/DumpDynPcd/DumpDynPcd.inf
>     MdeModulePkg/Application/MemoryProfileInfo/MemoryProfileInfo.inf
> +  MdeModulePkg/Application/MpServicesTest/MpServicesTest.inf
>  
>     MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
>     MdeModulePkg/Logo/Logo.inf


回复: [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file name capsule

gaoliming
 

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

-----邮件原件-----
发件人: Bob Morgan <bobm@...>
发送时间: 2021年11月3日 4:40
收件人: devel@edk2.groups.io
抄送: Bob Morgan <bobm@...>; Jian J Wang
<jian.j.wang@...>; Liming Gao <gaoliming@...>; Guomin
Jiang <guomin.jiang@...>
主题: [PATCH v2] MdeModulePkg/DxeCapsuleLibFmp: Capsule on Disk file
name capsule

Enhance RelocateCapsuleToRam() to skip creation of the Capsule on Disk
file name capsule if PcdSupportUpdateCapsuleReset feature is not enabled.
This avoids an EFI_UNSUPPORTED return status from UpdateCapsule() when
the
file name capsule is encountered and PcdSupportUpdateCapsuleReset is
FALSE.

Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Cc: Guomin Jiang <guomin.jiang@...>
Signed-off-by: Bob Morgan <bobm@...>
---
.../Library/DxeCapsuleLibFmp/CapsuleOnDisk.c | 19
++++++++++++++++---
.../DxeCapsuleLibFmp/DxeCapsuleLib.inf | 3 +++
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
index 4c32c6cdcf..814c5400fe 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/CapsuleOnDisk.c
@@ -1739,6 +1739,7 @@ RelocateCapsuleToRam (
UINT8 *StringBuf;
UINTN StringSize;
UINTN TotalStringSize;
+ UINTN CapsulesToProcess;

CapsuleOnDiskBuf = NULL;
BlockDescriptors = NULL;
@@ -1778,6 +1779,13 @@ RelocateCapsuleToRam (
TotalStringSize += StrSize
(CapsuleOnDiskBuf[Index].FileInfo->FileName);
}

+ // If Persist Across Reset isn't supported, skip the file name strings
capsule
+ if (!FeaturePcdGet (PcdSupportUpdateCapsuleReset)) {
+ CapsulesToProcess = CapsuleOnDiskNum;
+ goto BuildGather;
+ }
+ CapsulesToProcess = CapsuleOnDiskNum + 1;
+
FileNameCapsule = AllocateZeroPool (sizeof (EFI_CAPSULE_HEADER) +
TotalStringSize);
if (FileNameCapsule == NULL) {
DEBUG ((DEBUG_ERROR, "Fail to allocate memory for name
capsule.\n"));
@@ -1804,18 +1812,23 @@ RelocateCapsuleToRam (
//
// 3. Build Gather list for the capsules
//
- Status = BuildGatherList (CapsuleBuffer, CapsuleSize, CapsuleOnDiskNum
+
1, &BlockDescriptors);
+BuildGather:
+ Status = BuildGatherList (CapsuleBuffer, CapsuleSize,
CapsulesToProcess,
&BlockDescriptors);
if (EFI_ERROR (Status) || BlockDescriptors == NULL) {
FreePool (CapsuleBuffer);
FreePool (CapsuleSize);
- FreePool (FileNameCapsule);
+ if (FileNameCapsule != NULL) {
+ FreePool (FileNameCapsule);
+ }
return EFI_OUT_OF_RESOURCES;
}

//
// 4. Call UpdateCapsule() service
//
- Status = gRT->UpdateCapsule((EFI_CAPSULE_HEADER **) CapsuleBuffer,
CapsuleOnDiskNum + 1, (UINTN) BlockDescriptors);
+ Status = gRT->UpdateCapsule ((EFI_CAPSULE_HEADER **) CapsuleBuffer,
+ CapsulesToProcess,
+ (UINTN) BlockDescriptors);

return Status;
}
diff --git a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
index 05de4299fb..4932479d42 100644
--- a/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
+++ b/MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
@@ -68,6 +68,9 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdCodRelocationDevPath
## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdCoDRelocationFileName
## CONSUMES

+[FeaturePcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdSupportUpdateCapsuleReset ##
CONSUMES
+
[Protocols]
gEsrtManagementProtocolGuid ## CONSUMES
gEfiFirmwareManagementProtocolGuid ## CONSUMES
--
2.17.1

11441 - 11460 of 94575