Date   

[PATCH v2 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg

Bret Barkelew
 

From: Bret Barkelew <brbarkel@...>

TODO: Might keep the name of the .inf. Pending discussion.

This aligns better with Mu's philosophy around dependency structuring
and is one of the steps to enable Basecore to have zero CI dependencies
on other Mu repos.

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

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Supreeth Venkatesh <supreeth.venkatesh@...>
Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Ray Ni <ray.ni@...>
Cc: Zhichao Gao <zhichao.gao@...>
Cc: Sean Brogan <sean.brogan@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>
---
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memset.c =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c =
| 0
ArmPkg/ArmPkg.dsc =
| 3 +--
CryptoPkg/CryptoPkg.dsc =
| 2 +-
MdeModulePkg/MdeModulePkg.dsc =
| 2 +-
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S =
| 0
{ArmPkg =3D> MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm =
| 0
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf =3D> MdePkg=
/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf | 3 +--
MdePkg/MdePkg.dsc =
| 1 +
NetworkPkg/NetworkPkg.dsc =
| 2 +-
ShellPkg/ShellPkg.dsc =
| 2 +-
StandaloneMmPkg/StandaloneMmPkg.dsc =
| 2 +-
UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc =
| 2 +-
58 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/memcmp_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcmp_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c b/MdePkg/Library=
/CompilerIntrinsicsLib/memcpy.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/memcpy_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memcpy_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/memmove_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memmove_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memmove_ms.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset.c b/MdePkg/Library=
/CompilerIntrinsicsLib/memset.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memset.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memset.c
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/memset_ms.c
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/memset_ms.c
rename to MdePkg/Library/CompilerIntrinsicsLib/memset_ms.c
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
index 59fd8f295d4f..06ede068f99d 100644
--- a/ArmPkg/ArmPkg.dsc
+++ b/ArmPkg/ArmPkg.dsc
@@ -101,7 +101,7 @@ [LibraryClasses.common.PEIM]
PeiServicesTablePointerLib|MdePkg/Library/PeiServicesTablePointerLib/Pei=
ServicesTablePointerLib.inf=0D
=0D
[LibraryClasses.ARM, LibraryClasses.AARCH64]=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
# Add support for GCC stack protector=0D
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
@@ -109,7 +109,6 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
[Components.common]=0D
ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf=0D
ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf=0D
- ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
ArmPkg/Library/DebugAgentSymbolsBaseLib/DebugAgentSymbolsBaseLib.inf=0D
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf=0D
ArmPkg/Library/DefaultExceptionHandlerLib/DefaultExceptionHandlerLib.inf=
=0D
diff --git a/CryptoPkg/CryptoPkg.dsc b/CryptoPkg/CryptoPkg.dsc
index 0aa72ed87846..eab46e4b4fbc 100644
--- a/CryptoPkg/CryptoPkg.dsc
+++ b/CryptoPkg/CryptoPkg.dsc
@@ -74,7 +74,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# [LibraryClasses.ARM, LibraryClasses.AARCH64] and NULL mean link this l=
ibrary=0D
# into all ARM and AARCH64 images.=0D
#=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
# Add support for stack protector=0D
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index b1d83461865e..ab505f5bb2c6 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -183,7 +183,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# This library provides the instrinsic functions generated by a given co=
mpiler.=0D
# [LibraryClasses.ARM] and NULL mean link this library into all ARM imag=
es.=0D
#=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
#=0D
# Since software stack checking may be heuristically enabled by the comp=
iler=0D
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S b/MdePk=
g/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
rename to MdePkg/Library/CompilerIntrinsicsLib/AArch64/Atomics.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/ashldi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashldi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/ashrdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/clzsi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/clzsi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/ctzsi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S b/MdePkg/Librar=
y/CompilerIntrinsicsLib/Arm/div.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/Arm/div.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/div.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/div.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/divdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/divsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/divsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S b/MdePkg/Libra=
ry/CompilerIntrinsicsLib/Arm/lasr.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/lasr.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lasr.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/ldivmod.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm b/MdePkg/=
Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S b/MdePkg/Libra=
ry/CompilerIntrinsicsLib/Arm/llsl.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/llsl.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsl.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S b/MdePkg/Libra=
ry/CompilerIntrinsicsLib/Arm/llsr.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/llsr.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/llsr.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/lshrdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/memmove.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm b/MdePkg/=
Library/CompilerIntrinsicsLib/Arm/memmove.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/memmove.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/moddi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/moddi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/modsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/modsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/muldi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/muldi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/Arm/mullu.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/mullu.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/mullu.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/sourcery.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/sourcery.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/switch.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/switch16.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch16.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/switch32.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch32.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/switch8.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switch8.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/switchu8.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/switchu8.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/ucmpdi2.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/udivdi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivdi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S b/MdePkg=
/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/udivsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/udivsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/Arm/uldiv.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/uldiv.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uldiv.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/umoddi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umoddi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/umodsi3.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/umodsi3.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S b/MdePkg/Libr=
ary/CompilerIntrinsicsLib/Arm/uread.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm b/MdePkg/Li=
brary/CompilerIntrinsicsLib/Arm/uread.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uread.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S b/MdePkg/Lib=
rary/CompilerIntrinsicsLib/Arm/uwrite.S
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.S
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm b/MdePkg/L=
ibrary/CompilerIntrinsicsLib/Arm/uwrite.asm
similarity index 100%
rename from ArmPkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
rename to MdePkg/Library/CompilerIntrinsicsLib/Arm/uwrite.asm
diff --git a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=
b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
similarity index 93%
rename from ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
rename to MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
index fcf48c678119..46224f79ea85 100644
--- a/ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf
+++ b/MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf
@@ -11,7 +11,7 @@
=0D
[Defines]=0D
INF_VERSION =3D 0x00010005=0D
- BASE_NAME =3D CompilerIntrinsicsLib=0D
+ BASE_NAME =3D ArmCompilerIntrinsicsLib=0D
FILE_GUID =3D 855274FA-3575-4C20-9709-C031DC5589FA=
=0D
MODULE_TYPE =3D BASE=0D
VERSION_STRING =3D 1.0=0D
@@ -84,7 +84,6 @@ [Sources.AARCH64]
=0D
[Packages]=0D
MdePkg/MdePkg.dec=0D
- ArmPkg/ArmPkg.dec=0D
=0D
[BuildOptions]=0D
MSFT:*_*_*_CC_FLAGS =3D /GL-=0D
diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index a94959169b2f..cb3907c88b4e 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -183,5 +183,6 @@ [Components.EBC]
[Components.ARM, Components.AARCH64]=0D
MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicArmVirt.inf=0D
MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
+ MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
[BuildOptions]=0D
diff --git a/NetworkPkg/NetworkPkg.dsc b/NetworkPkg/NetworkPkg.dsc
index cf2164aefe25..1c727a9a4bf1 100644
--- a/NetworkPkg/NetworkPkg.dsc
+++ b/NetworkPkg/NetworkPkg.dsc
@@ -75,7 +75,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# This library provides the instrinsic functions generated by a given co=
mpiler.=0D
# [LibraryClasses.ARM] and NULL mean link this library into all ARM imag=
es.=0D
#=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
ArmSoftFloatLib|ArmPkg/Library/ArmSoftFloatLib/ArmSoftFloatLib.inf=0D
=0D
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index 6f0d0929319d..25e8831bf36e 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -69,7 +69,7 @@ [LibraryClasses.ARM,LibraryClasses.AARCH64]
# This library provides the instrinsic functions generate by a given com=
piler.=0D
# [LibraryClasses.ARM] and NULL mean link this library into all ARM imag=
es.=0D
#=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
# Add support for GCC stack protector=0D
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/Standalo=
neMmPkg.dsc
index 8012f93b7dcc..2c0c9396d633 100644
--- a/StandaloneMmPkg/StandaloneMmPkg.dsc
+++ b/StandaloneMmPkg/StandaloneMmPkg.dsc
@@ -67,7 +67,7 @@ [LibraryClasses.AARCH64, LibraryClasses.ARM]
CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMainte=
nanceLib.inf=0D
PeCoffExtraActionLib|StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActi=
onLib/StandaloneMmPeCoffExtraActionLib.inf=0D
=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf=0D
=0D
[LibraryClasses.common.MM_CORE_STANDALONE]=0D
diff --git a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc b/Unit=
TestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
index 8adf690098ae..2bbf2398b7e9 100644
--- a/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
+++ b/UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc
@@ -37,7 +37,7 @@ [LibraryClasses.ARM, LibraryClasses.AARCH64]
# This library provides the instrinsic functions generated by a given co=
mpiler.=0D
# [LibraryClasses.ARM] and NULL mean link this library into all ARM imag=
es.=0D
#=0D
- NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf=0D
+ NULL|MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf=0D
=0D
#=0D
# Since software stack checking may be heuristically enabled by the comp=
iler=0D
--=20
2.31.1.windows.1


[PATCH v2 04/16] ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib

Bret Barkelew
 

From: Bret Barkelew <brbarkel@...>

This extra interface is redundant and unnecessary. Dropping it is
more EDK2-ish.

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

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sean Brogan <sean.brogan@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>
Reviewed-by: Leif Lindholm <leif@...>
---
ArmPkg/ArmPkg.dec | 4 ---
ArmPkg/Include/Library/StandaloneMmMmuLib.h | 36 --------------------
2 files changed, 40 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 9da1bbc9f216..f5c235ecc11b 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -88,10 +88,6 @@ [LibraryClasses.common]
#=0D
SemihostLib|Include/Library/SemihostLib.h=0D
=0D
- ## @libraryclass Provides an interface for a StandaloneMm Mmu.=0D
- #=0D
- StandaloneMmMmuLib|Include/Library/StandaloneMmMmuLib.h=0D
-=0D
[Guids.common]=0D
gArmTokenSpaceGuid =3D { 0xBB11ECFE, 0x820F, 0x4968, { 0xBB, 0xA6,=
0xF7, 0x6A, 0xFE, 0x30, 0x25, 0x96 } }=0D
=0D
diff --git a/ArmPkg/Include/Library/StandaloneMmMmuLib.h b/ArmPkg/Include/L=
ibrary/StandaloneMmMmuLib.h
deleted file mode 100644
index ccc016d0350a..000000000000
--- a/ArmPkg/Include/Library/StandaloneMmMmuLib.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file=0D
-=0D
- Copyright (c) 2018, ARM Ltd. All rights reserved.=0D
-=0D
- SPDX-License-Identifier: BSD-2-Clause-Patent=0D
-=0D
-**/=0D
-=0D
-#ifndef STANDALONE_MM_MMU_LIB_=0D
-#define STANDALONE_MM_MMU_LIB_=0D
-=0D
-EFI_STATUS=0D
-ArmSetMemoryRegionNoExec (=0D
- IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D
- IN UINT64 Length=0D
- );=0D
-=0D
-EFI_STATUS=0D
-ArmClearMemoryRegionNoExec (=0D
- IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D
- IN UINT64 Length=0D
- );=0D
-=0D
-EFI_STATUS=0D
-ArmSetMemoryRegionReadOnly (=0D
- IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D
- IN UINT64 Length=0D
- );=0D
-=0D
-EFI_STATUS=0D
-ArmClearMemoryRegionReadOnly (=0D
- IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D
- IN UINT64 Length=0D
- );=0D
-=0D
-#endif /* STANDALONE_MM_MMU_LIB_ */=0D
--=20
2.31.1.windows.1


[PATCH v2 03/16] ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib

Bret Barkelew
 

From: Bret Barkelew <brbarkel@...>

StandaloneMmMmuLib has been turned into an implementation of the
ArmMmuLib class (without any change to the interface itself), so
this module can now change its dependency.

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

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Supreeth Venkatesh <supreeth.venkatesh@...>
Cc: Sean Brogan <sean.brogan@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>
---
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPo=
int.inf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneM=
mCoreEntryPoint.inf b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/St=
andaloneMmCoreEntryPoint.inf
index 75cfb98c0e75..a0629cbc1a6f 100644
--- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn=
tryPoint.inf
+++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEn=
tryPoint.inf
@@ -42,7 +42,7 @@ [LibraryClasses]
DebugLib=0D
=0D
[LibraryClasses.ARM, LibraryClasses.AARCH64]=0D
- StandaloneMmMmuLib=0D
+ ArmMmuLib=0D
ArmSvcLib=0D
=0D
[Guids]=0D
--=20
2.31.1.windows.1


[PATCH v2 02/16] ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib

Bret Barkelew
 

From: Bret Barkelew <brbarkel@...>

Drop switch from the custom "StandaloneMmMmuLib" class to the
more generic "ArmMmuLib" class and add the missing functions
to fulfill that interface.

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

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sean Brogan <sean.brogan@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>
---
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 37 +++++++++=
+++++++++++
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 2 +-
2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c b/Ar=
mPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
index 20f873e6802c..42216bf40ac7 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c
@@ -325,3 +325,40 @@ ArmClearMemoryRegionReadOnly (
}=0D
return Status;=0D
}=0D
+=0D
+EFI_STATUS=0D
+EFIAPI=0D
+ArmConfigureMmu (=0D
+ IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable,=0D
+ OUT VOID **TranslationTableBase OPTIONAL,=0D
+ OUT UINTN *TranslationTableSize OPTIONAL=0D
+ )=0D
+{=0D
+ DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__))=
;=0D
+ ASSERT (FALSE);=0D
+ return EFI_UNSUPPORTED;=0D
+}=0D
+=0D
+VOID=0D
+EFIAPI=0D
+ArmReplaceLiveTranslationEntry (=0D
+ IN UINT64 *Entry,=0D
+ IN UINT64 Value,=0D
+ IN UINT64 RegionStart=0D
+ )=0D
+{=0D
+ DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__))=
;=0D
+ ASSERT (FALSE);=0D
+}=0D
+=0D
+EFI_STATUS=0D
+ArmSetMemoryAttributes (=0D
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D
+ IN UINT64 Length,=0D
+ IN UINT64 Attributes=0D
+ )=0D
+{=0D
+ DEBUG ((DEBUG_ERROR, "%a() interface not implemented!\n", __FUNCTION__))=
;=0D
+ ASSERT (FALSE);=0D
+ return EFI_UNSUPPORTED;=0D
+}=0D
diff --git a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf b/=
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
index ff20e5898051..d34086853d32 100644
--- a/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
+++ b/ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
@@ -13,7 +13,7 @@ [Defines]
FILE_GUID =3D 44a741c2-655f-41fc-b066-179f5a9aa78a=
=0D
MODULE_TYPE =3D MM_CORE_STANDALONE=0D
VERSION_STRING =3D 1.0=0D
- LIBRARY_CLASS =3D StandaloneMmMmuLib=0D
+ LIBRARY_CLASS =3D ArmMmuLib | MM_CORE_STANDALONE MM_STA=
NDALONE=0D
PI_SPECIFICATION_VERSION =3D 0x00010032=0D
=0D
[Sources]=0D
--=20
2.31.1.windows.1


[PATCH v2 01/16] ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM

Bret Barkelew
 

From: Bret Barkelew <brbarkel@...>

Not sure what all module types this HAS been validated against, but it
doesn't work with STANDALONE_MM or STANDALONE_MM_CORE.

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

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Sean Brogan <sean.brogan@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>
Reviewed-by: Leif Lindholm <leif@...>
---
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/Ar=
mMmuLib/ArmMmuBaseLib.inf
index 2a7e7147958c..d0988b27d582 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -13,7 +13,7 @@ [Defines]
FILE_GUID =3D da8f0232-fb14-42f0-922c-63104d2c70bd=
=0D
MODULE_TYPE =3D BASE=0D
VERSION_STRING =3D 1.0=0D
- LIBRARY_CLASS =3D ArmMmuLib=0D
+ LIBRARY_CLASS =3D ArmMmuLib | DXE_DRIVER PEIM PEI_CORE =
DXE_CORE DXE_RUNTIME_DRIVER SEC=0D
=0D
[Defines.AARCH64]=0D
CONSTRUCTOR =3D ArmMmuBaseLibConstructor=0D
--=20
2.31.1.windows.1


[PATCH v2 00/16] Un-siloing Arm common code

Bret Barkelew
 

This series of patch commits moves a number of modules and libraries around in order
to better un-silo the Arm-specific code. Unnecessary abstractions were removed, some
duplicate code was abstracted, and generally things were cleaned up so that common
code (e.g. MdePkg, MdeModulePkg, StandaloneMmPkg) does not require ArmPkg or
ArmPlatformPkg.

Also, some things that were previously hidden away under ArmPkg are now located
with the core functionality or build tooling that makes sense for it.

Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Jiaxin Wu <jiaxin.wu@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Leif Lindholm <leif@...>
Cc: Liming Gao <gaoliming@...>
Cc: Maciej Rabeda <maciej.rabeda@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Ray Ni <ray.ni@...>
Cc: Sami Mujawar <sami.mujawar@...>
Cc: Sean Brogan <sean.brogan@...>
Cc: Siyuan Fu <siyuan.fu@...>
Cc: Supreeth Venkatesh <supreeth.venkatesh@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Zhichao Gao <zhichao.gao@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Signed-off-by: Bret Barkelew <bret.barkelew@...>

Bret Barkelew (15):
ArmPkg/ArmMmuBaseLib: Disallow STANDALONE_MM
ArmPkg/ArmMmuStandaloneMmLib: Update to match ArmMmuLib
ArmPkg/StandaloneMmCoreEntryPoint: Swap to ArmMmuLib
ArmPkg: Disavow StandaloneMmMmuLib. It's just ArmMmuLib
ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg
ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to
BaseTools
ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg
MdePkg: Create the MMU access lib to abstract memory protection
settings
MdeModulePkg: Swap to MmuLib instead of Arm-specific lib
StandaloneMmPkg: Switch to the MmuLib abstraction
ArmPkg: Move the StandaloneMmCpu driver to ArmPkg
ArmPkg: Move the StandaloneMmCoreEntryPoint lib to ArmPkg
ArmPkg/Library: Convert StandaloneMmCoreEntryPoint to Arm-only
ArmPkg/ArmPkg.dsc: Resolve build errors resulting from package moves
ArmPlatformPkg: Resolve build errors resulting from package moves

Sean Brogan (1):
ArmPkg: Add Basic MMU Lib for Arm silicon

{StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c | 0
{StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c | 0
ArmPkg/Library/MmuLib/MmuLib.c | 120 ++++++++++++++++++++
{StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c | 0
{StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c | 0
{StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c | 0
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.c | 37 ++++++
MdeModulePkg/Core/DxeIplPeim/Arm/DxeLoadFunc.c | 4 +-
MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c | 86 ++++++++++++++
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c | 0
StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c | 71 ------------
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c | 50 +++++++-
ArmPkg/ArmPkg.ci.yaml | 3 +-
ArmPkg/ArmPkg.dec | 4 -
ArmPkg/ArmPkg.dsc | 15 ++-
{StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h | 0
{StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf | 0
ArmPkg/Include/Library/StandaloneMmMmuLib.h | 36 ------
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 2 +-
ArmPkg/Library/MmuLib/BaseMmuLib.inf | 30 +++++
{StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf | 8 +-
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf | 2 +-
ArmPlatformPkg/ArmPlatformPkg.dsc | 4 +-
{ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a | Bin
{ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s | 0
{ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a | Bin
{ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s | 0
BaseTools/Conf/tools_def.template | 19 ++--
CryptoPkg/CryptoPkg.dsc | 2 +-
MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf | 4 +-
MdeModulePkg/MdeModulePkg.dsc | 5 +-
{ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h | 0
{ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h | 0
MdePkg/Include/Library/MmuLib.h | 75 ++++++++++++
MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf | 28 +++++
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S | 0
{ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm | 0
ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf | 3 +-
MdePkg/MdePkg.dec | 5 +
MdePkg/MdePkg.dsc | 3 +
NetworkPkg/NetworkPkg.dsc | 2 +-
ShellPkg/ShellPkg.dsc | 2 +-
StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf | 3 +-
StandaloneMmPkg/StandaloneMmPkg.dsc | 3 +-
UnitTestFrameworkPkg/UnitTestFrameworkPkgTarget.dsc.inc | 2 +-
91 files changed, 475 insertions(+), 153 deletions(-)
rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c (100%)
rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c (100%)
create mode 100644 ArmPkg/Library/MmuLib/MmuLib.c
rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/CreateHobList.c (100%)
rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c (100%)
rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/Arm/StandaloneMmCoreEntryPoint.c (100%)
create mode 100644 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.c
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcmp_ms.c (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy.c (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memcpy_ms.c (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memmove_ms.c (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset.c (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/memset_ms.c (100%)
delete mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/X64/StandaloneMmCoreEntryPoint.c
rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h (100%)
rename {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf (100%)
delete mode 100644 ArmPkg/Include/Library/StandaloneMmMmuLib.h
create mode 100644 ArmPkg/Library/MmuLib/BaseMmuLib.inf
rename {StandaloneMmPkg => ArmPkg}/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf (84%)
rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a (100%)
rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s (100%)
rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a (100%)
rename {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s (100%)
rename {ArmPkg/Include => MdePkg/Include/AArch64}/AsmMacroIoLibV8.h (100%)
rename {ArmPkg/Include => MdePkg/Include/Arm}/AsmMacroIoLib.h (100%)
create mode 100644 MdePkg/Include/Library/MmuLib.h
create mode 100644 MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/AArch64/Atomics.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashldi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ashrdi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/clzsi2.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ctzsi2.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/div.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divdi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/divsi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lasr.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ldivmod.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsl.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/llsr.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/lshrdi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/memmove.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/moddi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/modsi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/muldi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/mullu.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/sourcery.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch16.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch32.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switch8.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/switchu8.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/ucmpdi2.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivdi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivmoddi4.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/udivsi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uldiv.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umoddi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/umodsi3.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uread.asm (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.S (100%)
rename {ArmPkg => MdePkg}/Library/CompilerIntrinsicsLib/Arm/uwrite.asm (100%)
rename ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf (93%)

--
2.31.1.windows.1


Re: [PATCH] Enable wildcard host name matching in EDK2 HTTPS/TLS implementation

Maciej Rabeda
 

Hi Vineel,

I will integrate the change to edk2 tomorrow.

For now:
Reviewed-by: Maciej Rabeda <maciej.rabeda@...>

Thanks,
Maciej

On 02-Nov-21 19:57, Vineel Kovvuri via groups.io wrote:
Hi Folks,

Thanks for reviewing the patch. May I know what are the next steps to get it in to edk2?
I have already updated the same in https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning

Thanks,
Vineel

-----Original Message-----
From: Wu, Jiaxin <jiaxin.wu@...>
Sent: Monday, November 1, 2021 6:15 PM
To: devel@edk2.groups.io; vineel.kovvuri@...; Rabeda, Maciej <maciej.rabeda@...>; Yao, Jiewen <jiewen.yao@...>; Jancarlo Perez <jpere@...>; Mike Turner <Michael.Turner@...>; Sean Brogan <sean.brogan@...>; Bret Barkelew <Bret.Barkelew@...>
Cc: Vineel Kovvuri <vineelko@...>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH] Enable wildcard host name matching in EDK2 HTTPS/TLS implementation

It's good to me change the default the verify flag.

Reviewed-by: Jiaxin Wu <jiaxin.wu@...>

Thanks,
Jiaxin

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vineel
Kovvuri
Sent: Friday, October 15, 2021 8:55 AM
To: Rabeda, Maciej <maciej.rabeda@...>; Yao, Jiewen
<jiewen.yao@...>; jpere@...;
Michael.Turner@...; sean.brogan@...;
bret.barkelew@...; devel@edk2.groups.io
Cc: Vineel Kovvuri <vineelko@...>
Subject: [edk2-devel] [PATCH] Enable wildcard host name matching in
EDK2 HTTPS/TLS implementation

The current UEFI implementation of HTTPS during its TLS configuration
uses EFI_TLS_VERIFY_FLAG_NO_WILDCARDS for host name verification. As
per the spec this flag does is "to disable the match of any wildcards
in the host name". So, certificates which are issued with
wildcards(*.dm.corp.net etc) in it will fail the TLS host name
matching. On the other hand,
EFI_TLS_VERIFY_FLAG_NONE(misnomer) means "no additional flags set for
hostname validation. Wildcards are supported and they match only in
the left-most label."
this behavior/definition is coming from openssl's X509_check_host()
api
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
openssl.org%2Fdocs%2Fman1.1.0%2Fman3%2FX509_check_host.html&amp;data=0
4%7C01%7Cvineelko%40microsoft.com%7C1a8a6c07efcb42e043a008d99d9e3fba%7
C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637714125291796675%7CUnkno
wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
CJXVCI6Mn0%3D%7C1000&amp;sdata=Ygz4XOYjA0m7JL6acQ1Jv55fxJJv6pFvE6n%2F%
2Bc6jwBU%3D&amp;reserved=0

Without EFI_TLS_VERIFY_FLAG_NONE any UEFI application using
certificates issued with wildcards in them would fail to match while
trying to communicate with HTTPS endpoint.

BugZilla:
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugz
illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D3691&amp;data=04%7C01%7Cvinee
lko%40microsoft.com%7C1a8a6c07efcb42e043a008d99d9e3fba%7C72f988bf86f14
1af91ab2d7cd011db47%7C1%7C0%7C637714125291806667%7CUnknown%7CTWFpbGZsb
3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%
7C1000&amp;sdata=q5qkhZ5fyWdx2SBzKytPsx%2BB%2BWfvCeZp56gEVln2SsA%3D&am
p;reserved=0

Signed-off-by: Vineel Kovvuri <vineelko@...>
---
NetworkPkg/HttpDxe/HttpsSupport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c
b/NetworkPkg/HttpDxe/HttpsSupport.c
index 7e0bf85c3c..0f28ae9447 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -625,7 +625,7 @@ TlsConfigureSession (
//
HttpInstance->TlsConfigData.ConnectionEnd = EfiTlsClient;
HttpInstance->TlsConfigData.VerifyMethod = EFI_TLS_VERIFY_PEER;
- HttpInstance->TlsConfigData.VerifyHost.Flags =
EFI_TLS_VERIFY_FLAG_NO_WILDCARDS;
+ HttpInstance->TlsConfigData.VerifyHost.Flags =
EFI_TLS_VERIFY_FLAG_NONE;
HttpInstance->TlsConfigData.VerifyHost.HostName = HttpInstance-
RemoteHost;
HttpInstance->TlsConfigData.SessionState = EfiTlsSessionNotStarted;

--
2.17.1







Re: [PATCH v1 12/16] ArmPkg: Move the StandaloneMmCpu driver to ArmPkg

Bret Barkelew
 

If the implementation didn't make so many calls into Arm-specific libs for SMC servicing, it could stay right where it is.
It's just that untangling that Gordian knot is outside my ken.

On Tue, Nov 2, 2021 at 3:00 AM Leif Lindholm <leif@...> wrote:
On Mon, Nov 01, 2021 at 12:56:44 -0700, brbarkel@... wrote:
> From: Bret Barkelew <brbarkel@...>
>
> This aligns better with Mu's philosophy around dependency structuring
> and is one of the steps to enable Basecore to have zero CI dependencies
> on other Mu repos.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3652

I much prefer moving things out of ArmPkg (which shouldn't exist),
than moving things into it. Where would be the logical place for this
to go if ARM wasn't so special it needed its own top-level package?

/
    Leif

> Cc: Leif Lindholm <leif@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Sami Mujawar <sami.mujawar@...>
> Cc: Jiewen Yao <jiewen.yao@...>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@...>
> Cc: Sean Brogan <sean.brogan@...>
> Signed-off-by: Bret Barkelew <bret.barkelew@...>
> ---
>  {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/EventHandle.c       | 0
>  {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.c   | 0
>  {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.h   | 0
>  {StandaloneMmPkg => ArmPkg}/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf | 0
>  4 files changed, 0 insertions(+), 0 deletions(-)
>
> diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c b/ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c
> similarity index 100%
> rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/EventHandle.c
> rename to ArmPkg/Drivers/StandaloneMmCpu/EventHandle.c
> diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
> similarity index 100%
> rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
> rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.c
> diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
> similarity index 100%
> rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
> rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.h
> diff --git a/StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf b/ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
> similarity index 100%
> rename from StandaloneMmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
> rename to ArmPkg/Drivers/StandaloneMmCpu/StandaloneMmCpu.inf
> --
> 2.31.1.windows.1
>


Re: [PATCH v1 11/16] ArmPkg: Add Basic MMU Lib for Arm silicon

Bret Barkelew
 

Will address.


On Tue, Nov 2, 2021 at 2:57 AM Leif Lindholm <leif@...> wrote:

On Mon, Nov 01, 2021 at 12:56:43 -0700, brbarkel@... wrote:
> From: Sean Brogan <sean.brogan@...>
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3651

Some description please.

> Cc: Leif Lindholm <leif@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Sean Brogan <sean.brogan@...>
> Signed-off-by: Bret Barkelew <bret.barkelew@...>
> ---
>  ArmPkg/Library/MmuLib/MmuLib.c       | 120 ++++++++++++++++++++
>  ArmPkg/ArmPkg.dsc                    |   1 +
>  ArmPkg/Library/MmuLib/BaseMmuLib.inf |  30 +++++
>  3 files changed, 151 insertions(+)
>
> diff --git a/ArmPkg/Library/MmuLib/MmuLib.c b/ArmPkg/Library/MmuLib/MmuLib.c
> new file mode 100644
> index 000000000000..7a6ba1f81819
> --- /dev/null
> +++ b/ArmPkg/Library/MmuLib/MmuLib.c
> @@ -0,0 +1,120 @@
> +/** @file
> +This library instance implements a very limited MMU Lib instance
> +for the ARM/AARCH64 architectures.  This library shims a common library
> +interface to the ArmPkg defined ArmMmuLib.ib.

- ib. ?

> +
> +Copyright (c) Microsoft Corporation.
> +SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <Library/MmuLib.h>
> +#include <Library/ArmMmuLib.h>
> +#include <Library/DebugLib.h>

Please sort alphabetically.

/
    Leif

> +
> +/**
> +  Bitwise sets the memory attributes on a range of memory based on an attributes mask.
> +
> +  @param  BaseAddress           The start of the range for which to set attributes.
> +  @param  Length                The length of the range.
> +  @param  Attributes            A bitmask of the attributes to set. See "Physical memory
> +                                protection attributes" in UefiSpec.h
> +
> +  @return EFI_SUCCESS
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuSetAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  IN  UINT64                    Length,
> +  IN  UINT64                    Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    if (Attributes & EFI_MEMORY_XP) {
> +      Status = ArmSetMemoryRegionNoExec (BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to set NX.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> +
> +
> +/**
> +  Bitwise clears the memory attributes on a range of memory based on an attributes mask.
> +
> +  @param  BaseAddress           The start of the range for which to clear attributes.
> +  @param  Length                The length of the range.
> +  @param  Attributes            A bitmask of the attributes to clear. See "Physical memory
> +                                protection attributes" in UefiSpec.h
> +
> +  @return EFI_SUCCESS
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuClearAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  IN  UINT64                    Length,
> +  IN  UINT64                    Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    if (Attributes & EFI_MEMORY_XP) {
> +      Status = ArmClearMemoryRegionNoExec (BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to clear NX.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    if (Attributes & EFI_MEMORY_RO) {
> +      Status = ArmClearMemoryRegionReadOnly(BaseAddress, Length);
> +      if (EFI_ERROR(Status)) {
> +        DEBUG((DEBUG_ERROR, "%a - Failed to clear RO.  Status = %r\n", __FUNCTION__, Status));
> +      }
> +    }
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> +
> +
> +/**
> +  Returns the memory attributes on a range of memory.
> +
> +  @param  BaseAddress           The start of the range for which to set attributes.
> +  @param  Attributes            A return pointer for the attributes.
> +
> +  @return EFI_SUCCESS
> +  @return EFI_INVALID_PARAMETER   A return pointer is NULL.
> +  @return Others
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +MmuGetAttributes (
> +  IN  EFI_PHYSICAL_ADDRESS      BaseAddress,
> +  OUT UINT64                    *Attributes
> +  )
> +  {
> +    EFI_STATUS Status;
> +
> +    Status = EFI_UNSUPPORTED;
> +
> +    DEBUG ((DEBUG_ERROR, "%a() API not implemented\n", __FUNCTION__));
> +
> +    ASSERT_EFI_ERROR(Status);
> +    return Status;
> +  }
> diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc
> index 06ede068f99d..cbc67daa7696 100644
> --- a/ArmPkg/ArmPkg.dsc
> +++ b/ArmPkg/ArmPkg.dsc
> @@ -165,3 +165,4 @@ [Components.AARCH64]

>  [Components.AARCH64, Components.ARM]
>    ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf
> +  ArmPkg/Library/MmuLib/BaseMmuLib.inf
> diff --git a/ArmPkg/Library/MmuLib/BaseMmuLib.inf b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> new file mode 100644
> index 000000000000..15095abee9c3
> --- /dev/null
> +++ b/ArmPkg/Library/MmuLib/BaseMmuLib.inf
> @@ -0,0 +1,30 @@
> +## @file
> +# This library instance implements a very limited MMU Lib instance
> +# for the ARM/AARCH64 architectures.  This library shims a common library
> +# interface to the ArmPkg defined ArmMmuLib.
> +#
> +# Copyright (c) Microsoft Corporation.
> +#
> +# SPDX-License-Identifier: BSD-2-Clause-Patent
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010005
> +  BASE_NAME                      = MmuLib
> +  FILE_GUID                      = 6f2ee9a4-79b3-4b77-9a47-e2bd4b917b75
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = MmuLib
> +
> +[Sources]
> +  MmuLib.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +  ArmPkg/ArmPkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> +  ArmMmuLib
> --
> 2.31.1.windows.1
>


Re: [PATCH v1 07/16] ArmPkg and MdePkg: Move the AsmMacroIoLib from ArmPkg to MdePkg

Bret Barkelew
 

Will address. Thanks!


On Tue, Nov 2, 2021 at 2:25 AM Leif Lindholm <leif@...> wrote:
On Mon, Nov 01, 2021 at 12:56:39 -0700, brbarkel@... wrote:
> From: Bret Barkelew <brbarkel@...>
>
> Cc: Leif Lindholm <leif@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Michael D Kinney <michael.d.kinney@...>
> Cc: Liming Gao <gaoliming@...>
> Cc: Zhiguang Liu <zhiguang.liu@...>
> Cc: Sean Brogan <sean.brogan@...>
> Signed-off-by: Bret Barkelew <bret.barkelew@...>
> ---
>  {ArmPkg => MdePkg}/Include/AsmMacroIoLib.h | 0

I approve of this move, but if it goes into MdePkg, it needs some form
of arch-specific handling (like ProcessorBind.h, and indeed for x86,
Nasm.inc).

I also note that the AArch64 version is not moved at the same time.
That seems counterintuituve.

So could you:
Move
ArmPkg/Include/AsmMacroIoLib.h => MdePkg/Include/ARM/AsmMacroIoLib.h
ArmPkg/Include/AsmMacroIoLibV8.h => MdePkg/Include/AArch64/AsmMacroIoLibV8.h
?

Ideally, the AArch64 version should also lose its spectacularly
incorrect suffix, but that can wait for another day due to the
resulting fallout.

Ideally2, the VS .inc files ought to move with the ARM header, but that
feels like a bit much of a can of worms to ask for.

/
    Leif

>  1 file changed, 0 insertions(+), 0 deletions(-)
>
> diff --git a/ArmPkg/Include/AsmMacroIoLib.h b/MdePkg/Include/AsmMacroIoLib.h
> similarity index 100%
> rename from ArmPkg/Include/AsmMacroIoLib.h
> rename to MdePkg/Include/AsmMacroIoLib.h
> --
> 2.31.1.windows.1
>


Re: [EXTERNAL] Re: [edk2-devel] [PATCH v1 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools

Bret Barkelew <bret.barkelew@...>
 

Good call. Maintainers, your opinion?

 

- Bret

 

From: Leif Lindholm via groups.io
Sent: Tuesday, November 2, 2021 2:55 AM
To: brbarkel@...
Cc: devel@edk2.groups.io; Ard Biesheuvel; Feng, Bob C; Liming Gao; Chen, Yuwei; Sean Brogan
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v1 06/16] ArmPkg and BaseTools: Move the GccLto binaries from ArmPkg to BaseTools

 

On Mon, Nov 01, 2021 at 12:56:38 -0700, brbarkel@... wrote:
> From: Bret Barkelew <brbarkel@...>
>
> This aligns better with Mu's philosophy around dependency structuring
> and is one of the steps to enable Basecore to have zero CI dependencies
> on other Mu repos.
>
> REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3650&amp;data=04%7C01%7Cbret.barkelew%40microsoft.com%7Cc9129586336447a44c3908d99de6e1d1%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637714437251132216%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=ijjQG1L4fScVxSn5nIBQGrFHLVtNbuTfd0YYLGdw8sg%3D&amp;reserved=0
>
> Cc: Leif Lindholm <leif@...>
> Cc: Ard Biesheuvel <ardb+tianocore@...>
> Cc: Bob Feng <bob.c.feng@...>
> Cc: Liming Gao <gaoliming@...>
> Cc: Yuwei Chen <yuwei.chen@...>
> Cc: Sean Brogan <sean.brogan@...>
> Signed-off-by: Bret Barkelew <bret.barkelew@...>

No objections to this for any of my use-cases, but I'd like for one of
the BaseTools maintainers to comment on whether this breaks anything
with regards to EDK_TOOLS_PATH, or if we can finally get rid of that
and replace it with $WORKSPACE/BaseTools globally.

/
    Leif

> ---
>  {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.a | Bin
>  {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-aarch64.s |   0
>  {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.a     | Bin
>  {ArmPkg/Library => BaseTools/Bin}/GccLto/liblto-arm.s     |   0
>  BaseTools/Conf/tools_def.template                         |  19 ++++++++++---------
>  5 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/ArmPkg/Library/GccLto/liblto-aarch64.a b/BaseTools/Bin/GccLto/liblto-aarch64.a
> similarity index 100%
> rename from ArmPkg/Library/GccLto/liblto-aarch64.a
> rename to BaseTools/Bin/GccLto/liblto-aarch64.a
> diff --git a/ArmPkg/Library/GccLto/liblto-aarch64.s b/BaseTools/Bin/GccLto/liblto-aarch64.s
> similarity index 100%
> rename from ArmPkg/Library/GccLto/liblto-aarch64.s
> rename to BaseTools/Bin/GccLto/liblto-aarch64.s
> diff --git a/ArmPkg/Library/GccLto/liblto-arm.a b/BaseTools/Bin/GccLto/liblto-arm.a
> similarity index 100%
> rename from ArmPkg/Library/GccLto/liblto-arm.a
> rename to BaseTools/Bin/GccLto/liblto-arm.a
> diff --git a/ArmPkg/Library/GccLto/liblto-arm.s b/BaseTools/Bin/GccLto/liblto-arm.s
> similarity index 100%
> rename from ArmPkg/Library/GccLto/liblto-arm.s
> rename to BaseTools/Bin/GccLto/liblto-arm.s
> diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
> index 2e6b382ab623..cd8899d24d4a 100755
> --- a/BaseTools/Conf/tools_def.template
> +++ b/BaseTools/Conf/tools_def.template
> @@ -15,7 +15,8 @@
>  # 2.00 - Initial version with changes for CI
>  #      - Change RC path to use plugin
>  #
> -#!VERSION=2.00
> +# 2.10 - Move GccLto files to a tools path to be more repository layout agnostic
> +#!VERSION=2.10

>  IDENTIFIER = Default TOOL_CHAIN_CONF

> @@ -2386,10 +2387,10 @@ RELEASE_GCC5_X64_DLINK_FLAGS     = DEF(GCC5_X64_DLINK_FLAGS) -flto -Os
>  *_GCC5_ARM_CC_XIPFLAGS           = DEF(GCC5_ARM_CC_XIPFLAGS)

>    DEBUG_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
> -  DEBUG_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
> +  DEBUG_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm

>  RELEASE_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
> -RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
> +RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm

>    NOOPT_GCC5_ARM_CC_FLAGS        = DEF(GCC5_ARM_CC_FLAGS) -O0
>    NOOPT_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -O0
> @@ -2420,11 +2421,11 @@ RELEASE_GCC5_ARM_DLINK_FLAGS     = DEF(GCC5_ARM_DLINK_FLAGS) -flto -Os -L$(WORKS
>  *_GCC5_AARCH64_CC_XIPFLAGS       = DEF(GCC5_AARCH64_CC_XIPFLAGS)

>    DEBUG_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
> -  DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
> +  DEBUG_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
>    DEBUG_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20

>  RELEASE_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -flto -Wno-unused-but-set-variable -Wno-unused-const-variable
> -RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
> +RELEASE_GCC5_AARCH64_DLINK_FLAGS = DEF(GCC5_AARCH64_DLINK_FLAGS) -flto -Os -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64 -Wno-lto-type-mismatch
>  RELEASE_GCC5_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20

>    NOOPT_GCC5_AARCH64_CC_FLAGS    = DEF(GCC5_AARCH64_CC_FLAGS) -O0
> @@ -2681,11 +2682,11 @@ DEFINE CLANG38_ARM_DLINK_FLAGS   = DEF(CLANG38_ARM_TARGET) DEF(GCC_ARM_DLINK_FLA
>  *_CLANG38_ARM_CC_XIPFLAGS        = DEF(GCC_ARM_CC_XIPFLAGS)

>    DEBUG_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
> -  DEBUG_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
> +  DEBUG_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
>    NOOPT_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -O0
>    NOOPT_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS)
>  RELEASE_CLANG38_ARM_CC_FLAGS     = DEF(CLANG38_ARM_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
> -RELEASE_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm
> +RELEASE_CLANG38_ARM_DLINK_FLAGS  = DEF(CLANG38_ARM_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-arm -Wl,-plugin-opt=-pass-through=-llto-arm

>  ##################
>  # CLANG38 AARCH64 definitions
> @@ -2727,11 +2728,11 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6
>  *_CLANG38_AARCH64_CC_XIPFLAGS    = DEF(GCC_AARCH64_CC_XIPFLAGS)

>    DEBUG_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O1
> -  DEBUG_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
> +  DEBUG_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O1 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
>    NOOPT_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -O0
>    NOOPT_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS)
>  RELEASE_CLANG38_AARCH64_CC_FLAGS    = DEF(CLANG38_AARCH64_CC_FLAGS) $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -flto -O3
> -RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/ArmPkg/Library/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64
> +RELEASE_CLANG38_AARCH64_DLINK_FLAGS = DEF(CLANG38_AARCH64_DLINK_FLAGS) -flto -Wl,-O3 -L$(WORKSPACE)/BaseTools/Bin/GccLto -llto-aarch64 -Wl,-plugin-opt=-pass-through=-llto-aarch64

>  ####################################################################################
>  #
> --
> 2.31.1.windows.1
>




 


Re: [EXTERNAL] Re: [edk2-devel] [PATCH v1 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg

Bret Barkelew <bret.barkelew@...>
 

I’d be amenable to that. @Sean?

 

- Bret

 

From: Leif Lindholm via groups.io
Sent: Tuesday, November 2, 2021 2:51 AM
To: brbarkel@...
Cc: devel@edk2.groups.io; Ard Biesheuvel; Kinney, Michael D; Liming Gao; Zhiguang Liu; Sami Mujawar; Yao, Jiewen; Supreeth Venkatesh; Maciej Rabeda; Jiaxin Wu; Siyuan Fu; Ni, Ray; Zhichao Gao; Sean Brogan
Subject: [EXTERNAL] Re: [edk2-devel] [PATCH v1 05/16] ArmPkg and MdePkg: Move the Arm CompilerIntrinsicsLib to MdePkg

 

On Mon, Nov 01, 2021 at 12:56:37 -0700, brbarkel@... wrote:
> From: Bret Barkelew <brbarkel@...>
>
> This aligns better with Mu's philosophy around dependency structuring
> and is one of the steps to enable Basecore to have zero CI dependencies
> on other Mu repos.
>
> REF: https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.tianocore.org%2Fshow_bug.cgi%3Fid%3D3649&amp;data=04%7C01%7CBret.Barkelew%40microsoft.com%7C6acadbd5a03f44edf9c408d99de642ee%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637714434603817528%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&amp;sdata=AmwBKl6uWTs1VYo3Hw3I3RglkhPrWXhKPkobrwQid84%3D&amp;reserved=0
>

Only one comment on this patch really.

>  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf => MdePkg/Library/CompilerIntrinsicsLib/ArmCompilerIntrinsicsLib.inf | 3 +--

Could we just keep the .inf name as is?

I think we're getting closer to the x86 folk accepting that they
need this too, rather than keep inventing new dialects of C in the
desperate hope that the compiler won't generate stdlib calls it's
fully permitted to generate whenever it feels like.

/
    Leif




 


Re: [PATCH] Enable wildcard host name matching in EDK2 HTTPS/TLS implementation

Vineel Kovvuri
 

Hi Folks,

Thanks for reviewing the patch. May I know what are the next steps to get it in to edk2?
I have already updated the same in https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Release-Planning

Thanks,
Vineel

-----Original Message-----
From: Wu, Jiaxin <jiaxin.wu@...>
Sent: Monday, November 1, 2021 6:15 PM
To: devel@edk2.groups.io; vineel.kovvuri@...; Rabeda, Maciej <maciej.rabeda@...>; Yao, Jiewen <jiewen.yao@...>; Jancarlo Perez <jpere@...>; Mike Turner <Michael.Turner@...>; Sean Brogan <sean.brogan@...>; Bret Barkelew <Bret.Barkelew@...>
Cc: Vineel Kovvuri <vineelko@...>
Subject: [EXTERNAL] RE: [edk2-devel] [PATCH] Enable wildcard host name matching in EDK2 HTTPS/TLS implementation

It's good to me change the default the verify flag.

Reviewed-by: Jiaxin Wu <jiaxin.wu@...>

Thanks,
Jiaxin

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Vineel
Kovvuri
Sent: Friday, October 15, 2021 8:55 AM
To: Rabeda, Maciej <maciej.rabeda@...>; Yao, Jiewen
<jiewen.yao@...>; jpere@...;
Michael.Turner@...; sean.brogan@...;
bret.barkelew@...; devel@edk2.groups.io
Cc: Vineel Kovvuri <vineelko@...>
Subject: [edk2-devel] [PATCH] Enable wildcard host name matching in
EDK2 HTTPS/TLS implementation

The current UEFI implementation of HTTPS during its TLS configuration
uses EFI_TLS_VERIFY_FLAG_NO_WILDCARDS for host name verification. As
per the spec this flag does is "to disable the match of any wildcards
in the host name". So, certificates which are issued with
wildcards(*.dm.corp.net etc) in it will fail the TLS host name
matching. On the other hand,
EFI_TLS_VERIFY_FLAG_NONE(misnomer) means "no additional flags set for
hostname validation. Wildcards are supported and they match only in
the left-most label."
this behavior/definition is coming from openssl's X509_check_host()
api
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.
openssl.org%2Fdocs%2Fman1.1.0%2Fman3%2FX509_check_host.html&amp;data=0
4%7C01%7Cvineelko%40microsoft.com%7C1a8a6c07efcb42e043a008d99d9e3fba%7
C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637714125291796675%7CUnkno
wn%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiL
CJXVCI6Mn0%3D%7C1000&amp;sdata=Ygz4XOYjA0m7JL6acQ1Jv55fxJJv6pFvE6n%2F%
2Bc6jwBU%3D&amp;reserved=0

Without EFI_TLS_VERIFY_FLAG_NONE any UEFI application using
certificates issued with wildcards in them would fail to match while
trying to communicate with HTTPS endpoint.

BugZilla:
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugz
illa.tianocore.org%2Fshow_bug.cgi%3Fid%3D3691&amp;data=04%7C01%7Cvinee
lko%40microsoft.com%7C1a8a6c07efcb42e043a008d99d9e3fba%7C72f988bf86f14
1af91ab2d7cd011db47%7C1%7C0%7C637714125291806667%7CUnknown%7CTWFpbGZsb
3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%
7C1000&amp;sdata=q5qkhZ5fyWdx2SBzKytPsx%2BB%2BWfvCeZp56gEVln2SsA%3D&am
p;reserved=0

Signed-off-by: Vineel Kovvuri <vineelko@...>
---
NetworkPkg/HttpDxe/HttpsSupport.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c
b/NetworkPkg/HttpDxe/HttpsSupport.c
index 7e0bf85c3c..0f28ae9447 100644
--- a/NetworkPkg/HttpDxe/HttpsSupport.c
+++ b/NetworkPkg/HttpDxe/HttpsSupport.c
@@ -625,7 +625,7 @@ TlsConfigureSession (
//
HttpInstance->TlsConfigData.ConnectionEnd = EfiTlsClient;
HttpInstance->TlsConfigData.VerifyMethod = EFI_TLS_VERIFY_PEER;
- HttpInstance->TlsConfigData.VerifyHost.Flags =
EFI_TLS_VERIFY_FLAG_NO_WILDCARDS;
+ HttpInstance->TlsConfigData.VerifyHost.Flags =
EFI_TLS_VERIFY_FLAG_NONE;
HttpInstance->TlsConfigData.VerifyHost.HostName = HttpInstance-
RemoteHost;
HttpInstance->TlsConfigData.SessionState = EfiTlsSessionNotStarted;

--
2.17.1





Re: [edk2platforms][PATCH v2 1/1] IntelSiliconPkg: Add IntelDieInfoProtocol

Chaganty, Rangasai V
 

Thanks for incorporating the feedback.
Few more minor comments based on the new patch:
1. The description of "DieIndex" perhaps should be modified to " Index of the die in the package" to make it more apt.
2. The description of "DieId" perhaps should be modified to " Unique ID specific to the die and the associated generation" to make it more apt.

Regards,
Sai

-----Original Message-----
From: Czajkowski, Maciej <maciej.czajkowski@...>
Sent: Monday, October 18, 2021 6:57 AM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@...>; Chaganty, Rangasai V <rangasai.v.chaganty@...>
Subject: [edk2platforms][PATCH v2 1/1] IntelSiliconPkg: Add IntelDieInfoProtocol

Added IntelDieInfoProtocol header into IntelSiliconPkg tree.
The purpose is to have generic and unified interface for getting information about dies installed in the system.
It will be implemented by silicon code.

Change-Id: Iedc414d435c27f37e6f12e7affd046a0a9e7e19d
Cc: Ray Ni <ray.ni@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Signed-off-by: Maciej Czajkowski <maciej.czajkowski@...>
---

Notes:
v2:
- added interface description
- added die specific GUIDs into .dec file

Silicon/Intel/IntelSiliconPkg/Include/Protocol/IntelDieInfoProtocol.h | 117 ++++++++++++++++++++
Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec | 9 ++
2 files changed, 126 insertions(+)

diff --git a/Silicon/Intel/IntelSiliconPkg/Include/Protocol/IntelDieInfoProtocol.h b/Silicon/Intel/IntelSiliconPkg/Include/Protocol/IntelDieInfoProtocol.h
new file mode 100644
index 000000000000..954c9ee10c22
--- /dev/null
+++ b/Silicon/Intel/IntelSiliconPkg/Include/Protocol/IntelDieInfoProtoco
+++ l.h
@@ -0,0 +1,117 @@
+/** @file+ IntelDieInfoProtocol definition++ Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>+ SPDX-License-Identifier: BSD-2-Clause-Patent++**/+#ifndef _DIE_INFO_PROTOCOL_H_+#define _DIE_INFO_PROTOCOL_H_++typedef struct _INTEL_DIE_INFO_PROTOCOL INTEL_DIE_INFO_PROTOCOL;+typedef INTEL_DIE_INFO_PROTOCOL INTEL_DIE_INFO_PPI;++extern EFI_GUID gIntelDieInfoProtocolGuid;+extern EFI_GUID gIntelDieInfoPpiGuid;++extern EFI_GUID gIntelDieInfoPchGuid;+extern EFI_GUID gIntelDieInfoSocGuid;+extern EFI_GUID gIntelDieInfoIoGuid;+extern EFI_GUID gIntelDieInfoCpuGuid;+extern EFI_GUID gIntelDieInfoGfxGuid;++#define INTEL_DIE_INFO_PPI_GUID \+{ 0xAED8A0A1, 0xFDE6, 0x4CF2, { 0xA3, 0x85, 0x08, 0xF1, 0x25, 0xF2, 0x40, 0x37 }}++#define INTEL_DIE_INFO_PROTOCOL_GUID \+{ 0xAED8A0A1, 0xFDE6, 0x4CF2, { 0xA3, 0x85, 0x08, 0xF1, 0x25, 0xF2, 0x40, 0x37 }}++#define DIE_INFO_PROTOCOL_REVISION 1+#define DIE_INFO_PROTOCOL_SIGNATURE SIGNATURE_32 ('I', 'D', 'I', 'P')++#define DIE_INFO_PCH_GUID \+{ 0x62CB6D68, 0x4771, 0x4569, { 0x81, 0xFA, 0x1E, 0x99, 0x6E, 0xA9, 0x91, 0xC5 }}++#define DIE_INFO_SOC_GUID \+{ 0x63287105, 0x578E, 0x4799, { 0xBE, 0x55, 0x5D, 0xDA, 0xCA, 0x03, 0x74, 0xD0 }}++#define DIE_INFO_IO_GUID \+{ 0x23DA4C74, 0x54A0, 0x4E01, { 0x83, 0xB1, 0x8C, 0xA7, 0x43, 0x43, 0x1F, 0xF0 }}++#define DIE_INFO_CPU_GUID \+{ 0x6E5AF2E3, 0x5D84, 0x48F2, { 0x84, 0x28, 0x99, 0xE4, 0x93, 0x4F, 0x51, 0xE4 }}++#define DIE_INFO_GFX_GUID \+{ 0x1D3D2599, 0x7A1C, 0x4B1E, { 0x8C, 0xC5, 0x0F, 0x88, 0x27, 0xA0, 0x2E, 0xEC }}++/**+ Returns pointer to constant string representing die name.+ Name is specific to die type.++ @param[in] This Pointer to the DieInfoProtocol context structure+ @retval Pointer to the const string+**/+typedef+CONST CHAR8*+(EFIAPI *INTEL_DIE_INFO_GET_DIE_NAME_STR) (+ IN INTEL_DIE_INFO_PROTOCOL *This+ );++/**+ Returns pointer to constant string representing stepping of the die.++ @param[in] This Pointer to the DieInfoProtocol context structure+ @retval Pointer to the const string+**/+typedef+CONST CHAR8*+(EFIAPI *INTEL_DIE_INFO_GET_STEPPING_STR) (+ IN INTEL_DIE_INFO_PROTOCOL *This+ );++/**+ Returns pointer to constant string representing SKU of the die.++ @param[in] This Pointer to the DieInfoProtocol context structure+ @retval Pointer to the const string+**/+typedef+CONST CHAR8*+(EFIAPI *INTEL_DIE_INFO_GET_SKU_STR) (+ IN INTEL_DIE_INFO_PROTOCOL *This+ );++/**+ Protocol/PPI definition.+ The purpose of this interface is to serve die-specific informations in a unified, generic way.+ It will be produced by silicon code per die, and can be consumed by any module that needs contained information.++ <b>Revision 1</b>:+ - Initial version.+**/+struct _INTEL_DIE_INFO_PROTOCOL {+ UINT32 Signature; ///< Protocol signature+ UINT32 Revision; ///< Current protocol revision+ /**+ Type of the die that particular instance is reffering to. See DIE_INFO_*_GUID+ **/+ EFI_GUID Type;+ /**+ Index of the die in the system.+ **/+ UINT32 DieIndex;+ /**+ Generation and die specific ID number.+ **/+ UINT64 DieId;+ /**+ Generation and die specific stepping ID.+ **/+ UINT32 SteppingId;++ INTEL_DIE_INFO_GET_DIE_NAME_STR GetNameStr;+ INTEL_DIE_INFO_GET_STEPPING_STR GetSteppingStr;+ INTEL_DIE_INFO_GET_SKU_STR GetSkuStr;+};++#endif // _DIE_INFO_PROTOCOL_H_diff --git a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec
index 2461ab8e06e7..fe9b13ba28c7 100644
--- a/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec
+++ b/Silicon/Intel/IntelSiliconPkg/IntelSiliconPkg.dec
@@ -70,12 +70,21 @@ [Guids]
## Include/Guid/MicrocodeShadowInfoHob.h gEdkiiMicrocodeStorageTypeFlashGuid = { 0x2cba01b3, 0xd391, 0x4598, { 0x8d, 0x89, 0xb7, 0xfc, 0x39, 0x22, 0xfd, 0x71 } } + ## Include/Protocol/IntelDieInfoProtocol.h+ gIntelDieInfoPchGuid = { 0x62CB6D68, 0x4771, 0x4569, { 0x81, 0xFA, 0x1E, 0x99, 0x6E, 0xA9, 0x91, 0xC5 }}+ gIntelDieInfoSocGuid = { 0x63287105, 0x578E, 0x4799, { 0xBE, 0x55, 0x5D, 0xDA, 0xCA, 0x03, 0x74, 0xD0 }}+ gIntelDieInfoIoGuid = { 0x23DA4C74, 0x54A0, 0x4E01, { 0x83, 0xB1, 0x8C, 0xA7, 0x43, 0x43, 0x1F, 0xF0 }}+ gIntelDieInfoCpuGuid = { 0x6E5AF2E3, 0x5D84, 0x48F2, { 0x84, 0x28, 0x99, 0xE4, 0x93, 0x4F, 0x51, 0xE4 }}+ gIntelDieInfoGfxGuid = { 0x1D3D2599, 0x7A1C, 0x4B1E, { 0x8C, 0xC5, 0x0F, 0x88, 0x27, 0xA0, 0x2E, 0xEC }}+ [Ppis] gEdkiiVTdInfoPpiGuid = { 0x8a59fcb3, 0xf191, 0x400c, { 0x97, 0x67, 0x67, 0xaf, 0x2b, 0x25, 0x68, 0x4a } } gEdkiiVTdNullRootEntryTableGuid = { 0x3de0593f, 0x6e3e, 0x4542, { 0xa1, 0xcb, 0xcb, 0xb2, 0xdb, 0xeb, 0xd8, 0xff } }+ gIntelDieInfoPpiGuid = { 0xAED8A0A1, 0xFDE6, 0x4CF2, { 0xA3, 0x85, 0x08, 0xF1, 0x25, 0xF2, 0x40, 0x37 }} [Protocols] gEdkiiPlatformVTdPolicyProtocolGuid = { 0x3d17e448, 0x466, 0x4e20, { 0x99, 0x9f, 0xb2, 0xe1, 0x34, 0x88, 0xee, 0x22 }}+ gIntelDieInfoProtocolGuid = { 0xAED8A0A1, 0xFDE6, 0x4CF2, { 0xA3, 0x85, 0x08, 0xF1, 0x25, 0xF2, 0x40, 0x37 }} ## Protocol for device security policy. # Include/Protocol/PlatformDeviceSecurityPolicy.h--
2.27.0.windows.1


[PATCH v2 2/4] OvmfPkg: Copy TPM 1.2 DxeTcgPhysicalPresenceLib.c from SecuityPkg

Stefan Berger
 

Copy the TPM 1.2 physical presence interface support from SecurityPkg
DxeTcgPhysicalPresenceLib.c along with its .inf and .uni files into
OvmfPkg.

Fix EFI_F_INFO and EFI_D_ERROR to meet code standards.

Signed-off-by: Stefan Berger <stefanb@...>
---
.../DxeTcgPhysicalPresenceLib.c | 1455 +++++++++++++++++
.../DxeTcgPhysicalPresenceLib.inf | 64 +
.../DxeTcgPhysicalPresenceLib.uni | 22 +
.../PhysicalPresenceStrings.uni | 46 +
4 files changed, 1587 insertions(+)
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysic=
alPresenceLib.c
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysic=
alPresenceLib.inf
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysic=
alPresenceLib.uni
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/PhysicalPres=
enceStrings.uni

diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPrese=
nceLib.c b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenc=
eLib.c
new file mode 100644
index 0000000000..8a3ae95012
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c
@@ -0,0 +1,1455 @@
+/** @file=0D
+=0D
+ Execute pending TPM requests from OS or BIOS and Lock TPM.=0D
+=0D
+ Caution: This module requires additional review when modified.=0D
+ This driver will have external input - variable.=0D
+ This external input must be validated carefully to avoid security issue.=
=0D
+=0D
+ ExecutePendingTpmRequest() will receive untrusted input and do validatio=
n.=0D
+=0D
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#include <PiDxe.h>=0D
+=0D
+#include <Protocol/TcgService.h>=0D
+#include <Protocol/VariableLock.h>=0D
+#include <Library/DebugLib.h>=0D
+#include <Library/BaseMemoryLib.h>=0D
+#include <Library/UefiRuntimeServicesTableLib.h>=0D
+#include <Library/UefiDriverEntryPoint.h>=0D
+#include <Library/UefiBootServicesTableLib.h>=0D
+#include <Library/UefiLib.h>=0D
+#include <Library/MemoryAllocationLib.h>=0D
+#include <Library/PrintLib.h>=0D
+#include <Library/HiiLib.h>=0D
+#include <Guid/EventGroup.h>=0D
+#include <Guid/PhysicalPresenceData.h>=0D
+#include <Library/TcgPpVendorLib.h>=0D
+=0D
+#define CONFIRM_BUFFER_SIZE 4096=0D
+=0D
+EFI_HII_HANDLE mPpStringPackHandle;=0D
+=0D
+/**=0D
+ Get string by string id from HII Interface.=0D
+=0D
+ @param[in] Id String ID.=0D
+=0D
+ @retval CHAR16 * String from ID.=0D
+ @retval NULL If error occurs.=0D
+=0D
+**/=0D
+CHAR16 *=0D
+PhysicalPresenceGetStringById (=0D
+ IN EFI_STRING_ID Id=0D
+ )=0D
+{=0D
+ return HiiGetString (mPpStringPackHandle, Id, NULL);=0D
+}=0D
+=0D
+/**=0D
+ Get TPM physical presence permanent flags.=0D
+=0D
+ @param[in] TcgProtocol EFI TCG Protocol instance.=0D
+ @param[out] LifetimeLock physicalPresenceLifetimeLock permanent flag.=0D
+ @param[out] CmdEnable physicalPresenceCMDEnable permanent flag.=0D
+=0D
+ @retval EFI_SUCCESS Flags were returns successfully.=0D
+ @retval other Failed to locate EFI TCG Protocol.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+GetTpmCapability (=0D
+ IN EFI_TCG_PROTOCOL *TcgProtocol,=0D
+ OUT BOOLEAN *LifetimeLock,=0D
+ OUT BOOLEAN *CmdEnable=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ TPM_RQU_COMMAND_HDR *TpmRqu;=0D
+ TPM_RSP_COMMAND_HDR *TpmRsp;=0D
+ UINT32 *SendBufPtr;=0D
+ UINT8 SendBuffer[sizeof (*TpmRqu) + sizeof (=
UINT32) * 3];=0D
+ TPM_PERMANENT_FLAGS *TpmPermanentFlags;=0D
+ UINT8 RecvBuffer[40];=0D
+=0D
+ //=0D
+ // Fill request header=0D
+ //=0D
+ TpmRsp =3D (TPM_RSP_COMMAND_HDR*)RecvBuffer;=0D
+ TpmRqu =3D (TPM_RQU_COMMAND_HDR*)SendBuffer;=0D
+=0D
+ TpmRqu->tag =3D SwapBytes16 (TPM_TAG_RQU_COMMAND);=0D
+ TpmRqu->paramSize =3D SwapBytes32 (sizeof (SendBuffer));=0D
+ TpmRqu->ordinal =3D SwapBytes32 (TPM_ORD_GetCapability);=0D
+=0D
+ //=0D
+ // Set request parameter=0D
+ //=0D
+ SendBufPtr =3D (UINT32*)(TpmRqu + 1);=0D
+ WriteUnaligned32 (SendBufPtr++, SwapBytes32 (TPM_CAP_FLAG));=0D
+ WriteUnaligned32 (SendBufPtr++, SwapBytes32 (sizeof (TPM_CAP_FLAG_PERMAN=
ENT)));=0D
+ WriteUnaligned32 (SendBufPtr, SwapBytes32 (TPM_CAP_FLAG_PERMANENT));=0D
+=0D
+ Status =3D TcgProtocol->PassThroughToTpm (=0D
+ TcgProtocol,=0D
+ sizeof (SendBuffer),=0D
+ (UINT8*)TpmRqu,=0D
+ sizeof (RecvBuffer),=0D
+ (UINT8*)&RecvBuffer=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return Status;=0D
+ }=0D
+=0D
+ if ((TpmRsp->tag !=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)) || (TpmRsp->ret=
urnCode !=3D 0)) {=0D
+ return EFI_DEVICE_ERROR;=0D
+ }=0D
+=0D
+ TpmPermanentFlags =3D (TPM_PERMANENT_FLAGS *)&RecvBuffer[sizeof (TPM_RSP=
_COMMAND_HDR) + sizeof (UINT32)];=0D
+=0D
+ if (LifetimeLock !=3D NULL) {=0D
+ *LifetimeLock =3D TpmPermanentFlags->physicalPresenceLifetimeLock;=0D
+ }=0D
+=0D
+ if (CmdEnable !=3D NULL) {=0D
+ *CmdEnable =3D TpmPermanentFlags->physicalPresenceCMDEnable;=0D
+ }=0D
+=0D
+ return Status;=0D
+}=0D
+=0D
+/**=0D
+ Issue TSC_PhysicalPresence command to TPM.=0D
+=0D
+ @param[in] TcgProtocol EFI TCG Protocol instance.=0D
+ @param[in] PhysicalPresence The state to set the TPM's Physical Pres=
ence flags.=0D
+=0D
+ @retval EFI_SUCCESS TPM executed the command successfully.=0D
+ @retval EFI_SECURITY_VIOLATION TPM returned error when executing the co=
mmand.=0D
+ @retval other Failed to locate EFI TCG Protocol.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+TpmPhysicalPresence (=0D
+ IN EFI_TCG_PROTOCOL *TcgProtocol,=0D
+ IN TPM_PHYSICAL_PRESENCE PhysicalPresence=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ TPM_RQU_COMMAND_HDR *TpmRqu;=0D
+ TPM_PHYSICAL_PRESENCE *TpmPp;=0D
+ TPM_RSP_COMMAND_HDR TpmRsp;=0D
+ UINT8 Buffer[sizeof (*TpmRqu) + sizeof (*Tpm=
Pp)];=0D
+=0D
+ TpmRqu =3D (TPM_RQU_COMMAND_HDR*)Buffer;=0D
+ TpmPp =3D (TPM_PHYSICAL_PRESENCE*)(TpmRqu + 1);=0D
+=0D
+ TpmRqu->tag =3D SwapBytes16 (TPM_TAG_RQU_COMMAND);=0D
+ TpmRqu->paramSize =3D SwapBytes32 (sizeof (Buffer));=0D
+ TpmRqu->ordinal =3D SwapBytes32 (TSC_ORD_PhysicalPresence);=0D
+ WriteUnaligned16 (TpmPp, (TPM_PHYSICAL_PRESENCE) SwapBytes16 (PhysicalPr=
esence));=0D
+=0D
+ Status =3D TcgProtocol->PassThroughToTpm (=0D
+ TcgProtocol,=0D
+ sizeof (Buffer),=0D
+ (UINT8*)TpmRqu,=0D
+ sizeof (TpmRsp),=0D
+ (UINT8*)&TpmRsp=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return Status;=0D
+ }=0D
+=0D
+ if (TpmRsp.tag !=3D SwapBytes16 (TPM_TAG_RSP_COMMAND)) {=0D
+ return EFI_DEVICE_ERROR;=0D
+ }=0D
+=0D
+ if (TpmRsp.returnCode !=3D 0) {=0D
+ //=0D
+ // If it fails, some requirements may be needed for this command.=0D
+ //=0D
+ return EFI_SECURITY_VIOLATION;=0D
+ }=0D
+=0D
+ return Status;=0D
+}=0D
+=0D
+/**=0D
+ Issue a TPM command for which no additional output data will be returned=
.=0D
+=0D
+ @param[in] TcgProtocol EFI TCG Protocol instance.=0D
+ @param[in] Ordinal TPM command code.=0D
+ @param[in] AdditionalParameterSize Additional parameter size.=0D
+ @param[in] AdditionalParameters Pointer to the Additional parameters=
.=0D
+=0D
+ @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE Error occurred during se=
nding command to TPM or=0D
+ receiving response from =
TPM.=0D
+ @retval Others Return code from the TPM=
device after command execution.=0D
+=0D
+**/=0D
+UINT32=0D
+TpmCommandNoReturnData (=0D
+ IN EFI_TCG_PROTOCOL *TcgProtocol,=0D
+ IN TPM_COMMAND_CODE Ordinal,=0D
+ IN UINTN AdditionalParameterSize,=0D
+ IN VOID *AdditionalParameters=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ TPM_RQU_COMMAND_HDR *TpmRqu;=0D
+ TPM_RSP_COMMAND_HDR TpmRsp;=0D
+ UINT32 Size;=0D
+=0D
+ TpmRqu =3D (TPM_RQU_COMMAND_HDR*) AllocatePool (sizeof (*TpmRqu) + Addit=
ionalParameterSize);=0D
+ if (TpmRqu =3D=3D NULL) {=0D
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;=0D
+ }=0D
+=0D
+ TpmRqu->tag =3D SwapBytes16 (TPM_TAG_RQU_COMMAND);=0D
+ Size =3D (UINT32)(sizeof (*TpmRqu) + AdditionalParameterSiz=
e);=0D
+ TpmRqu->paramSize =3D SwapBytes32 (Size);=0D
+ TpmRqu->ordinal =3D SwapBytes32 (Ordinal);=0D
+ CopyMem (TpmRqu + 1, AdditionalParameters, AdditionalParameterSize);=0D
+=0D
+ Status =3D TcgProtocol->PassThroughToTpm (=0D
+ TcgProtocol,=0D
+ Size,=0D
+ (UINT8*)TpmRqu,=0D
+ (UINT32)sizeof (TpmRsp),=0D
+ (UINT8*)&TpmRsp=0D
+ );=0D
+ FreePool (TpmRqu);=0D
+ if (EFI_ERROR (Status) || (TpmRsp.tag !=3D SwapBytes16 (TPM_TAG_RSP_COMM=
AND))) {=0D
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;=0D
+ }=0D
+ return SwapBytes32 (TpmRsp.returnCode);=0D
+}=0D
+=0D
+/**=0D
+ Execute physical presence operation requested by the OS.=0D
+=0D
+ @param[in] TcgProtocol EFI TCG Protocol instance.=0D
+ @param[in] CommandCode Physical presence operation value.=0D
+ @param[in, out] PpiFlags The physical presence interface flag=
s.=0D
+=0D
+ @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE Unknown physical presenc=
e operation.=0D
+ @retval TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE Error occurred during se=
nding command to TPM or=0D
+ receiving response from =
TPM.=0D
+ @retval Others Return code from the TPM=
device after command execution.=0D
+=0D
+**/=0D
+UINT32=0D
+ExecutePhysicalPresence (=0D
+ IN EFI_TCG_PROTOCOL *TcgProtocol,=0D
+ IN UINT32 CommandCode,=0D
+ IN OUT EFI_PHYSICAL_PRESENCE_FLAGS *PpiFlags=0D
+ )=0D
+{=0D
+ BOOLEAN BoolVal;=0D
+ UINT32 TpmResponse;=0D
+ UINT32 InData[5];=0D
+=0D
+ switch (CommandCode) {=0D
+ case PHYSICAL_PRESENCE_ENABLE:=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_PhysicalEnable,=0D
+ 0,=0D
+ NULL=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_DISABLE:=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_PhysicalDisable,=0D
+ 0,=0D
+ NULL=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_ACTIVATE:=0D
+ BoolVal =3D FALSE;=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_PhysicalSetDeactivated,=0D
+ sizeof (BoolVal),=0D
+ &BoolVal=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE:=0D
+ BoolVal =3D TRUE;=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_PhysicalSetDeactivated,=0D
+ sizeof (BoolVal),=0D
+ &BoolVal=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR:=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_ForceClear,=0D
+ 0,=0D
+ NULL=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESE=
NCE_ENABLE, PpiFlags);=0D
+ if (TpmResponse =3D=3D 0) {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_ACTIVATE, PpiFlags);=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESE=
NCE_DEACTIVATE, PpiFlags);=0D
+ if (TpmResponse =3D=3D 0) {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_DISABLE, PpiFlags);=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:=0D
+ BoolVal =3D TRUE;=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_SetOwnerInstall,=0D
+ sizeof (BoolVal),=0D
+ &BoolVal=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:=0D
+ BoolVal =3D FALSE;=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_SetOwnerInstall,=0D
+ sizeof (BoolVal),=0D
+ &BoolVal=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:=0D
+ //=0D
+ // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_SET_OWNER_I=
NSTALL_TRUE=0D
+ // PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE will be executed after r=
eboot=0D
+ //=0D
+ if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) =3D=3D 0) =
{=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_ENABLE_ACTIVATE, PpiFlags);=0D
+ PpiFlags->PPFlags |=3D TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ } else {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_SET_OWNER_INSTALL_TRUE, PpiFlags);=0D
+ PpiFlags->PPFlags &=3D ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESE=
NCE_SET_OWNER_INSTALL_FALSE, PpiFlags);=0D
+ if (TpmResponse =3D=3D 0) {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_DEACTIVATE_DISABLE, PpiFlags);=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:=0D
+ InData[0] =3D SwapBytes32 (TPM_SET_STCLEAR_DATA); // Capa=
bilityArea=0D
+ InData[1] =3D SwapBytes32 (sizeof(UINT32)); // SubC=
apSize=0D
+ InData[2] =3D SwapBytes32 (TPM_SD_DEFERREDPHYSICALPRESENCE); // SubC=
ap=0D
+ InData[3] =3D SwapBytes32 (sizeof(UINT32)); // SetV=
alueSize=0D
+ InData[4] =3D SwapBytes32 (1); // Unow=
nedFieldUpgrade; bit0=0D
+ return TpmCommandNoReturnData (=0D
+ TcgProtocol,=0D
+ TPM_ORD_SetCapability,=0D
+ sizeof (UINT32) * 5,=0D
+ InData=0D
+ );=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:=0D
+ //=0D
+ // TPM_SetOperatorAuth=0D
+ // This command requires UI to prompt user for Auth data=0D
+ // Here it is NOT implemented=0D
+ //=0D
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRESE=
NCE_CLEAR, PpiFlags);=0D
+ if (TpmResponse =3D=3D 0) {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_ENABLE_ACTIVATE, PpiFlags);=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:=0D
+ PpiFlags->PPFlags &=3D ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISIO=
N;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:=0D
+ PpiFlags->PPFlags |=3D TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION=
;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:=0D
+ PpiFlags->PPFlags &=3D ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:=0D
+ PpiFlags->PPFlags |=3D TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:=0D
+ PpiFlags->PPFlags &=3D ~TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENA=
NCE;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:=0D
+ PpiFlags->PPFlags |=3D TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENAN=
CE;=0D
+ return 0;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:=0D
+ //=0D
+ // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR=0D
+ // PHYSICAL_PRESENCE_CLEAR will be executed after reboot.=0D
+ //=0D
+ if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) =3D=3D 0) =
{=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_ENABLE_ACTIVATE, PpiFlags);=0D
+ PpiFlags->PPFlags |=3D TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ } else {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_CLEAR, PpiFlags);=0D
+ PpiFlags->PPFlags &=3D ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:=0D
+ //=0D
+ // PHYSICAL_PRESENCE_ENABLE_ACTIVATE + PHYSICAL_PRESENCE_CLEAR_ENABL=
E_ACTIVATE=0D
+ // PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE will be executed after re=
boot.=0D
+ //=0D
+ if ((PpiFlags->PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) =3D=3D 0) =
{=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_ENABLE_ACTIVATE, PpiFlags);=0D
+ PpiFlags->PPFlags |=3D TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ } else {=0D
+ TpmResponse =3D ExecutePhysicalPresence (TcgProtocol, PHYSICAL_PRE=
SENCE_CLEAR_ENABLE_ACTIVATE, PpiFlags);=0D
+ PpiFlags->PPFlags &=3D ~TCG_VENDOR_LIB_FLAG_RESET_TRACK;=0D
+ }=0D
+ return TpmResponse;=0D
+=0D
+ default:=0D
+ ;=0D
+ }=0D
+ return TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;=0D
+}=0D
+=0D
+=0D
+/**=0D
+ Read the specified key for user confirmation.=0D
+=0D
+ @param[in] CautionKey If true, F12 is used as confirm key;=0D
+ If false, F10 is used as confirm key.=0D
+=0D
+ @retval TRUE User confirmed the changes by input.=0D
+ @retval FALSE User discarded the changes or device error.=0D
+=0D
+**/=0D
+BOOLEAN=0D
+ReadUserKey (=0D
+ IN BOOLEAN CautionKey=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ EFI_INPUT_KEY Key;=0D
+ UINT16 InputKey;=0D
+ UINTN Index;=0D
+=0D
+ InputKey =3D 0;=0D
+ do {=0D
+ Status =3D gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);=0D
+ if (Status =3D=3D EFI_NOT_READY) {=0D
+ gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);=0D
+ continue;=0D
+ }=0D
+=0D
+ if (Status =3D=3D EFI_DEVICE_ERROR) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ if (Key.ScanCode =3D=3D SCAN_ESC) {=0D
+ InputKey =3D Key.ScanCode;=0D
+ }=0D
+ if ((Key.ScanCode =3D=3D SCAN_F10) && !CautionKey) {=0D
+ InputKey =3D Key.ScanCode;=0D
+ }=0D
+ if ((Key.ScanCode =3D=3D SCAN_F12) && CautionKey) {=0D
+ InputKey =3D Key.ScanCode;=0D
+ }=0D
+ } while (InputKey =3D=3D 0);=0D
+=0D
+ if (InputKey !=3D SCAN_ESC) {=0D
+ return TRUE;=0D
+ }=0D
+=0D
+ return FALSE;=0D
+}=0D
+=0D
+/**=0D
+ The constructor function register UNI strings into imageHandle.=0D
+=0D
+ It will ASSERT() if that operation fails and it will always return EFI_S=
UCCESS.=0D
+=0D
+ @param ImageHandle The firmware allocated handle for the EFI image.=0D
+ @param SystemTable A pointer to the EFI System Table.=0D
+=0D
+ @retval EFI_SUCCESS The constructor successfully added string package.=
=0D
+ @retval Other value The constructor can't add string package.=0D
+=0D
+**/=0D
+EFI_STATUS=0D
+EFIAPI=0D
+TcgPhysicalPresenceLibConstructor (=0D
+ IN EFI_HANDLE ImageHandle,=0D
+ IN EFI_SYSTEM_TABLE *SystemTable=0D
+ )=0D
+{=0D
+ mPpStringPackHandle =3D HiiAddPackages (&gEfiPhysicalPresenceGuid, Image=
Handle, DxeTcgPhysicalPresenceLibStrings, NULL);=0D
+ ASSERT (mPpStringPackHandle !=3D NULL);=0D
+=0D
+ return EFI_SUCCESS;=0D
+}=0D
+=0D
+/**=0D
+ Display the confirm text and get user confirmation.=0D
+=0D
+ @param[in] TpmPpCommand The requested TPM physical presence command.=0D
+=0D
+ @retval TRUE The user has confirmed the changes.=0D
+ @retval FALSE The user doesn't confirm the changes.=0D
+**/=0D
+BOOLEAN=0D
+UserConfirm (=0D
+ IN UINT32 TpmPpCommand=0D
+ )=0D
+{=0D
+ CHAR16 *ConfirmText;=0D
+ CHAR16 *TmpStr1;=0D
+ CHAR16 *TmpStr2;=0D
+ UINTN BufSize;=0D
+ BOOLEAN CautionKey;=0D
+ UINT16 Index;=0D
+ CHAR16 DstStr[81];=0D
+=0D
+ TmpStr2 =3D NULL;=0D
+ CautionKey =3D FALSE;=0D
+ BufSize =3D CONFIRM_BUFFER_SIZE;=0D
+ ConfirmText =3D AllocateZeroPool (BufSize);=0D
+ ASSERT (ConfirmText !=3D NULL);=0D
+=0D
+ switch (TpmPpCommand) {=0D
+ case PHYSICAL_PRESENCE_ENABLE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ENABLE)=
);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DISABLE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_DISABLE=
));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_ACTIVATE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACTIVAT=
E));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_DEACTIV=
ATE));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR))=
;=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize=
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ENABLE_=
ACTIVATE));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_DEACTIV=
ATE_DISABLE));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_OF=
F));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ALLOW_T=
AKE_OWNERSHIP));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_DISALLO=
W_TAKE_OWNERSHIP));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_TURN_ON=
));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_TURN_OF=
F));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_OF=
F));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_UNOWNED=
_FIELD_UPGRADE));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_UPGRADE=
_HEAD_STR));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_MAINTAIN));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:=0D
+ //=0D
+ // TPM_SetOperatorAuth=0D
+ // This command requires UI to prompt user for Auth data=0D
+ // Here it is NOT implemented=0D
+ //=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR_T=
URN_ON));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR_CONT));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_=
PROVISION));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_PPI_HEA=
D_STR));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ACCEPT_=
KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_=
INFO));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CLEAR))=
;=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_PPI_HEA=
D_STR));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_CL=
EAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize=
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_=
INFO));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_=
MAINTAIN));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_PPI_HEA=
D_STR));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_MAINTAIN));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NO_PPI_=
INFO));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ENABLE_=
ACTIVATE_CLEAR));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), L" \n\n", (BufSize=
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:=0D
+ CautionKey =3D TRUE;=0D
+ TmpStr2 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_ENABLE_=
ACTIVATE_CLEAR_ENABLE_ACTIVATE));=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_HEAD_ST=
R));=0D
+ UnicodeSPrint (ConfirmText, BufSize, TmpStr1, TmpStr2);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_NOTE_ON=
));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_WARNING=
_CLEAR_CONT));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_CAUTION=
_KEY));=0D
+ StrnCatS (ConfirmText, BufSize / sizeof (CHAR16), TmpStr1, (BufSize =
/ sizeof (CHAR16)) - StrLen (ConfirmText) - 1);=0D
+ FreePool (TmpStr1);=0D
+ break;=0D
+=0D
+ default:=0D
+ ;=0D
+ }=0D
+=0D
+ if (TmpStr2 =3D=3D NULL) {=0D
+ FreePool (ConfirmText);=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ TmpStr1 =3D PhysicalPresenceGetStringById (STRING_TOKEN (TPM_REJECT_KEY)=
);=0D
+ BufSize -=3D StrSize (ConfirmText);=0D
+ UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, Tmp=
Str2);=0D
+=0D
+ DstStr[80] =3D L'\0';=0D
+ for (Index =3D 0; Index < StrLen (ConfirmText); Index +=3D 80) {=0D
+ StrnCpyS(DstStr, sizeof (DstStr) / sizeof (CHAR16), ConfirmText + Inde=
x, sizeof (DstStr) / sizeof (CHAR16) - 1);=0D
+ Print (DstStr);=0D
+ }=0D
+=0D
+ FreePool (TmpStr1);=0D
+ FreePool (TmpStr2);=0D
+ FreePool (ConfirmText);=0D
+=0D
+ if (ReadUserKey (CautionKey)) {=0D
+ return TRUE;=0D
+ }=0D
+=0D
+ return FALSE;=0D
+}=0D
+=0D
+/**=0D
+ Check if there is a valid physical presence command request. Also update=
s parameter value=0D
+ to whether the requested physical presence command already confirmed by =
user=0D
+=0D
+ @param[in] TcgPpData EFI TCG Physical Presence request data.=
=0D
+ @param[in] Flags The physical presence interface flags.=
=0D
+ @param[out] RequestConfirmed If the physical presence operation comm=
and required user confirm from UI.=0D
+ True, it indicates the command doesn't =
require user confirm, or already confirmed=0D
+ in last boot cycle by user.=0D
+ False, it indicates the command need us=
er confirm from UI.=0D
+=0D
+ @retval TRUE Physical Presence operation command is valid.=0D
+ @retval FALSE Physical Presence operation command is invalid.=0D
+=0D
+**/=0D
+BOOLEAN=0D
+HaveValidTpmRequest (=0D
+ IN EFI_PHYSICAL_PRESENCE *TcgPpData,=0D
+ IN EFI_PHYSICAL_PRESENCE_FLAGS Flags,=0D
+ OUT BOOLEAN *RequestConfirmed=0D
+ )=0D
+{=0D
+ BOOLEAN IsRequestValid;=0D
+=0D
+ *RequestConfirmed =3D FALSE;=0D
+=0D
+ switch (TcgPpData->PPRequest) {=0D
+ case PHYSICAL_PRESENCE_NO_ACTION:=0D
+ *RequestConfirmed =3D TRUE;=0D
+ return TRUE;=0D
+ case PHYSICAL_PRESENCE_ENABLE:=0D
+ case PHYSICAL_PRESENCE_DISABLE:=0D
+ case PHYSICAL_PRESENCE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE:=0D
+ case PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:=0D
+ case PHYSICAL_PRESENCE_SET_OPERATOR_AUTH:=0D
+ if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) =
!=3D 0) {=0D
+ *RequestConfirmed =3D TRUE;=0D
+ }=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:=0D
+ if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) !=3D=
0) {=0D
+ *RequestConfirmed =3D TRUE;=0D
+ }=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:=0D
+ if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE=
) !=3D 0) {=0D
+ *RequestConfirmed =3D TRUE;=0D
+ }=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:=0D
+ if ((Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) !=3D=
0 && (Flags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) !=3D =
0) {=0D
+ *RequestConfirmed =3D TRUE;=0D
+ }=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE:=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE:=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE:=0D
+ *RequestConfirmed =3D TRUE;=0D
+ break;=0D
+=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE:=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE:=0D
+ case PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE:=0D
+ break;=0D
+=0D
+ default:=0D
+ if (TcgPpData->PPRequest >=3D TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_=
OPERATION) {=0D
+ IsRequestValid =3D TcgPpVendorLibHasValidRequest (TcgPpData->PPReq=
uest, Flags.PPFlags, RequestConfirmed);=0D
+ if (!IsRequestValid) {=0D
+ return FALSE;=0D
+ } else {=0D
+ break;=0D
+ }=0D
+ } else {=0D
+ //=0D
+ // Wrong Physical Presence command=0D
+ //=0D
+ return FALSE;=0D
+ }=0D
+ }=0D
+=0D
+ if ((Flags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) !=3D 0) {=0D
+ //=0D
+ // It had been confirmed in last boot, it doesn't need confirm again.=
=0D
+ //=0D
+ *RequestConfirmed =3D TRUE;=0D
+ }=0D
+=0D
+ //=0D
+ // Physical Presence command is correct=0D
+ //=0D
+ return TRUE;=0D
+}=0D
+=0D
+=0D
+/**=0D
+ Check and execute the requested physical presence command.=0D
+=0D
+ Caution: This function may receive untrusted input.=0D
+ TcgPpData variable is external input, so this function will validate=0D
+ its data structure to be valid value.=0D
+=0D
+ @param[in] TcgProtocol EFI TCG Protocol instance.=0D
+ @param[in] TcgPpData Point to the physical presence NV variab=
le.=0D
+ @param[in] Flags The physical presence interface flags.=0D
+=0D
+**/=0D
+VOID=0D
+ExecutePendingTpmRequest (=0D
+ IN EFI_TCG_PROTOCOL *TcgProtocol,=0D
+ IN EFI_PHYSICAL_PRESENCE *TcgPpData,=0D
+ IN EFI_PHYSICAL_PRESENCE_FLAGS Flags=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ UINTN DataSize;=0D
+ BOOLEAN RequestConfirmed;=0D
+ EFI_PHYSICAL_PRESENCE_FLAGS NewFlags;=0D
+ BOOLEAN ResetRequired;=0D
+ UINT32 NewPPFlags;=0D
+=0D
+ if (!HaveValidTpmRequest(TcgPpData, Flags, &RequestConfirmed)) {=0D
+ //=0D
+ // Invalid operation request.=0D
+ //=0D
+ TcgPpData->PPResponse =3D TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;=0D
+ TcgPpData->LastPPRequest =3D TcgPpData->PPRequest;=0D
+ TcgPpData->PPRequest =3D PHYSICAL_PRESENCE_NO_ACTION;=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A=
CCESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ DataSize,=0D
+ TcgPpData=0D
+ );=0D
+ return;=0D
+ }=0D
+=0D
+ ResetRequired =3D FALSE;=0D
+ if (TcgPpData->PPRequest >=3D TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPER=
ATION) {=0D
+ NewFlags =3D Flags;=0D
+ NewPPFlags =3D NewFlags.PPFlags;=0D
+ TcgPpData->PPResponse =3D TcgPpVendorLibExecutePendingRequest (TcgPpDa=
ta->PPRequest, &NewPPFlags, &ResetRequired);=0D
+ NewFlags.PPFlags =3D (UINT8)NewPPFlags;=0D
+ } else {=0D
+ if (!RequestConfirmed) {=0D
+ //=0D
+ // Print confirm text and wait for approval.=0D
+ //=0D
+ RequestConfirmed =3D UserConfirm (TcgPpData->PPRequest);=0D
+ }=0D
+=0D
+ //=0D
+ // Execute requested physical presence command=0D
+ //=0D
+ TcgPpData->PPResponse =3D TCG_PP_OPERATION_RESPONSE_USER_ABORT;=0D
+ NewFlags =3D Flags;=0D
+ if (RequestConfirmed) {=0D
+ TcgPpData->PPResponse =3D ExecutePhysicalPresence (TcgProtocol, TcgP=
pData->PPRequest, &NewFlags);=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // Save the flags if it is updated.=0D
+ //=0D
+ if (CompareMem (&Flags, &NewFlags, sizeof(EFI_PHYSICAL_PRESENCE_FLAGS)) =
!=3D 0) {=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_FLAGS_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE=
_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ sizeof (EFI_PHYSICAL_PRESENCE_FLAGS),=0D
+ &NewFlags=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return;=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // Clear request=0D
+ //=0D
+ if ((NewFlags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) =3D=3D 0) {=0D
+ TcgPpData->LastPPRequest =3D TcgPpData->PPRequest;=0D
+ TcgPpData->PPRequest =3D PHYSICAL_PRESENCE_NO_ACTION;=0D
+ }=0D
+=0D
+ //=0D
+ // Save changes=0D
+ //=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACC=
ESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ DataSize,=0D
+ TcgPpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return;=0D
+ }=0D
+=0D
+ if (TcgPpData->PPResponse =3D=3D TCG_PP_OPERATION_RESPONSE_USER_ABORT) {=
=0D
+ return;=0D
+ }=0D
+=0D
+ //=0D
+ // Reset system to make new TPM settings in effect=0D
+ //=0D
+ switch (TcgPpData->LastPPRequest) {=0D
+ case PHYSICAL_PRESENCE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE:=0D
+ case PHYSICAL_PRESENCE_CLEAR:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE:=0D
+ case PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE:=0D
+ case PHYSICAL_PRESENCE_DEFERRED_PP_UNOWNERED_FIELD_UPGRADE:=0D
+ case PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR:=0D
+ case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:=0D
+ break;=0D
+ default:=0D
+ if (TcgPpData->LastPPRequest >=3D TCG_PHYSICAL_PRESENCE_VENDOR_SPECI=
FIC_OPERATION) {=0D
+ if (ResetRequired) {=0D
+ break;=0D
+ } else {=0D
+ return ;=0D
+ }=0D
+ }=0D
+ if (TcgPpData->PPRequest !=3D PHYSICAL_PRESENCE_NO_ACTION) {=0D
+ break;=0D
+ }=0D
+ return;=0D
+ }=0D
+=0D
+ Print (L"Rebooting system to make TPM settings in effect\n");=0D
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);=0D
+ ASSERT (FALSE);=0D
+}=0D
+=0D
+/**=0D
+ Check and execute the pending TPM request and Lock TPM.=0D
+=0D
+ The TPM request may come from OS or BIOS. This API will display request =
information and wait=0D
+ for user confirmation if TPM request exists. The TPM request will be sen=
t to TPM device after=0D
+ the TPM request is confirmed, and one or more reset may be required to m=
ake TPM request to=0D
+ take effect. At last, it will lock TPM to prevent TPM state change by ma=
lware.=0D
+=0D
+ This API should be invoked after console in and console out are all read=
y as they are required=0D
+ to display request information and get user input to confirm the request=
. This API should also=0D
+ be invoked as early as possible as TPM is locked in this function.=0D
+=0D
+**/=0D
+VOID=0D
+EFIAPI=0D
+TcgPhysicalPresenceLibProcessRequest (=0D
+ VOID=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ BOOLEAN LifetimeLock;=0D
+ BOOLEAN CmdEnable;=0D
+ UINTN DataSize;=0D
+ EFI_PHYSICAL_PRESENCE TcgPpData;=0D
+ EFI_TCG_PROTOCOL *TcgProtocol;=0D
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;=0D
+ EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;=0D
+=0D
+ Status =3D gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&Tc=
gProtocol);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return ;=0D
+ }=0D
+=0D
+ //=0D
+ // Initialize physical presence flags.=0D
+ //=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);=0D
+ Status =3D gRT->GetVariable (=0D
+ PHYSICAL_PRESENCE_FLAGS_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ NULL,=0D
+ &DataSize,=0D
+ &PpiFlags=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ PpiFlags.PPFlags =3D TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION;=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_FLAGS_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE=
_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ sizeof (EFI_PHYSICAL_PRESENCE_FLAGS),=0D
+ &PpiFlags=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "[TPM] Set physical presence flag failed, Statu=
s =3D %r\n", Status));=0D
+ return ;=0D
+ }=0D
+ }=0D
+ DEBUG ((DEBUG_INFO, "[TPM] PpiFlags =3D %x\n", PpiFlags.PPFlags));=0D
+=0D
+ //=0D
+ // This flags variable controls whether physical presence is required fo=
r TPM command.=0D
+ // It should be protected from malicious software. We set it as read-onl=
y variable here.=0D
+ //=0D
+ Status =3D gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (=
VOID **)&VariableLockProtocol);=0D
+ if (!EFI_ERROR (Status)) {=0D
+ Status =3D VariableLockProtocol->RequestToLock (=0D
+ VariableLockProtocol,=0D
+ PHYSICAL_PRESENCE_FLAGS_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "[TPM] Error when lock variable %s, Status =3D =
%r\n", PHYSICAL_PRESENCE_FLAGS_VARIABLE, Status));=0D
+ ASSERT_EFI_ERROR (Status);=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // Initialize physical presence variable.=0D
+ //=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->GetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ NULL,=0D
+ &DataSize,=0D
+ &TcgPpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE=
_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ DataSize,=0D
+ &TcgPpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "[TPM] Set physical presence variable failed, S=
tatus =3D %r\n", Status));=0D
+ return;=0D
+ }=0D
+ }=0D
+=0D
+ DEBUG ((DEBUG_INFO, "[TPM] Flags=3D%x, PPRequest=3D%x\n", PpiFlags.PPFla=
gs, TcgPpData.PPRequest));=0D
+=0D
+ if (TcgPpData.PPRequest =3D=3D PHYSICAL_PRESENCE_NO_ACTION) {=0D
+ //=0D
+ // No operation request=0D
+ //=0D
+ return;=0D
+ }=0D
+=0D
+ Status =3D GetTpmCapability (TcgProtocol, &LifetimeLock, &CmdEnable);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return ;=0D
+ }=0D
+=0D
+ if (!CmdEnable) {=0D
+ if (LifetimeLock) {=0D
+ //=0D
+ // physicalPresenceCMDEnable is locked, can't execute physical prese=
nce command.=0D
+ //=0D
+ return ;=0D
+ }=0D
+ Status =3D TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_CMD=
_ENABLE);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return ;=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // Set operator physical presence flags=0D
+ //=0D
+ Status =3D TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_PRESE=
NT);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return;=0D
+ }=0D
+=0D
+ //=0D
+ // Execute pending TPM request.=0D
+ //=0D
+ ExecutePendingTpmRequest (TcgProtocol, &TcgPpData, PpiFlags);=0D
+ DEBUG ((DEBUG_INFO, "[TPM] PPResponse =3D %x\n", TcgPpData.PPResponse));=
=0D
+=0D
+ //=0D
+ // Lock physical presence.=0D
+ //=0D
+ TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_NOTPRESENT | TPM=
_PHYSICAL_PRESENCE_LOCK);=0D
+}=0D
+=0D
+/**=0D
+ Check if the pending TPM request needs user input to confirm.=0D
+=0D
+ The TPM request may come from OS. This API will check if TPM request exi=
sts and need user=0D
+ input to confirmation.=0D
+=0D
+ @retval TRUE TPM needs input to confirm user physical presence=
.=0D
+ @retval FALSE TPM doesn't need input to confirm user physical p=
resence.=0D
+=0D
+**/=0D
+BOOLEAN=0D
+EFIAPI=0D
+TcgPhysicalPresenceLibNeedUserConfirm(=0D
+ VOID=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ EFI_PHYSICAL_PRESENCE TcgPpData;=0D
+ UINTN DataSize;=0D
+ BOOLEAN RequestConfirmed;=0D
+ BOOLEAN LifetimeLock;=0D
+ BOOLEAN CmdEnable;=0D
+ EFI_TCG_PROTOCOL *TcgProtocol;=0D
+ EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;=0D
+=0D
+ Status =3D gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&Tc=
gProtocol);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // Check Tpm requests=0D
+ //=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->GetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ NULL,=0D
+ &DataSize,=0D
+ &TcgPpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);=0D
+ Status =3D gRT->GetVariable (=0D
+ PHYSICAL_PRESENCE_FLAGS_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ NULL,=0D
+ &DataSize,=0D
+ &PpiFlags=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ if (TcgPpData.PPRequest =3D=3D PHYSICAL_PRESENCE_NO_ACTION) {=0D
+ //=0D
+ // No operation request=0D
+ //=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ if (!HaveValidTpmRequest(&TcgPpData, PpiFlags, &RequestConfirmed)) {=0D
+ //=0D
+ // Invalid operation request.=0D
+ //=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ //=0D
+ // Check Tpm Capability=0D
+ //=0D
+ Status =3D GetTpmCapability (TcgProtocol, &LifetimeLock, &CmdEnable);=0D
+ if (EFI_ERROR (Status)) {=0D
+ return FALSE;=0D
+ }=0D
+=0D
+ if (!CmdEnable) {=0D
+ if (LifetimeLock) {=0D
+ //=0D
+ // physicalPresenceCMDEnable is locked, can't execute physical prese=
nce command.=0D
+ //=0D
+ return FALSE;=0D
+ }=0D
+ }=0D
+=0D
+ if (!RequestConfirmed) {=0D
+ //=0D
+ // Need UI to confirm=0D
+ //=0D
+ return TRUE;=0D
+ }=0D
+=0D
+ return FALSE;=0D
+}=0D
+=0D
+/**=0D
+ The handler for TPM physical presence function:=0D
+ Submit TPM Operation Request to Pre-OS Environment and=0D
+ Submit TPM Operation Request to Pre-OS Environment 2.=0D
+=0D
+ Caution: This function may receive untrusted input.=0D
+=0D
+ @param[in] OperationRequest TPM physical presence operation request=
.=0D
+=0D
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environme=
nt and=0D
+ Submit TPM Operation Request to Pre-OS Environment 2.=0D
+**/=0D
+UINT32=0D
+EFIAPI=0D
+TcgPhysicalPresenceLibSubmitRequestToPreOSFunction (=0D
+ IN UINT32 OperationRequest=0D
+ )=0D
+{=0D
+ EFI_STATUS Status;=0D
+ UINTN DataSize;=0D
+ EFI_PHYSICAL_PRESENCE PpData;=0D
+=0D
+ DEBUG ((DEBUG_INFO, "[TPM] SubmitRequestToPreOSFunction, Request =3D %x\=
n", OperationRequest));=0D
+=0D
+ //=0D
+ // Get the Physical Presence variable=0D
+ //=0D
+ DataSize =3D sizeof (EFI_PHYSICAL_PRESENCE);=0D
+ Status =3D gRT->GetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ NULL,=0D
+ &DataSize,=0D
+ &PpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status =3D %r\n",=
Status));=0D
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;=0D
+ }=0D
+=0D
+ PpData.PPRequest =3D (UINT8)OperationRequest;=0D
+ Status =3D gRT->SetVariable (=0D
+ PHYSICAL_PRESENCE_VARIABLE,=0D
+ &gEfiPhysicalPresenceGuid,=0D
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_A=
CCESS | EFI_VARIABLE_RUNTIME_ACCESS,=0D
+ DataSize,=0D
+ &PpData=0D
+ );=0D
+ if (EFI_ERROR (Status)) {=0D
+ DEBUG ((DEBUG_ERROR, "[TPM] Set PP variable failure! Status =3D %r\n",=
Status));=0D
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;=0D
+ }=0D
+=0D
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;=0D
+}=0D
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPrese=
nceLib.inf b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPrese=
nceLib.inf
new file mode 100644
index 0000000000..cfe14f20ca
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.=
inf
@@ -0,0 +1,64 @@
+## @file=0D
+# Executes pending TPM 1.2 requests from OS or BIOS and Locks TPM=0D
+#=0D
+# This library will check and execute TPM 1.2 request from OS or BIOS. Th=
e request may=0D
+# ask for user confirmation before execution. This Library will also lock=
TPM physical=0D
+# presence at last.=0D
+#=0D
+# Caution: This module requires additional review when modified.=0D
+# This driver will have external input - variable.=0D
+# This external input must be validated carefully to avoid security issue=
.=0D
+#=0D
+# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+#=0D
+##=0D
+=0D
+[Defines]=0D
+ INF_VERSION =3D 0x00010005=0D
+ BASE_NAME =3D DxeTcgPhysicalPresenceLib=0D
+ MODULE_UNI_FILE =3D DxeTcgPhysicalPresenceLib.uni=0D
+ FILE_GUID =3D EBC43A46-34AC-4F07-A7F5-A5394619361C=
=0D
+ MODULE_TYPE =3D DXE_DRIVER=0D
+ VERSION_STRING =3D 1.0=0D
+ LIBRARY_CLASS =3D TcgPhysicalPresenceLib|DXE_DRIVER DXE=
_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER=0D
+ CONSTRUCTOR =3D TcgPhysicalPresenceLibConstructor=0D
+=0D
+#=0D
+# The following information is for reference only and not required by the =
build tools.=0D
+#=0D
+# VALID_ARCHITECTURES =3D IA32 X64 EBC=0D
+#=0D
+=0D
+[Sources]=0D
+ DxeTcgPhysicalPresenceLib.c=0D
+ PhysicalPresenceStrings.uni=0D
+=0D
+[Packages]=0D
+ MdePkg/MdePkg.dec=0D
+ MdeModulePkg/MdeModulePkg.dec=0D
+ SecurityPkg/SecurityPkg.dec=0D
+=0D
+[LibraryClasses]=0D
+ MemoryAllocationLib=0D
+ UefiLib=0D
+ UefiBootServicesTableLib=0D
+ UefiDriverEntryPoint=0D
+ UefiRuntimeServicesTableLib=0D
+ BaseMemoryLib=0D
+ DebugLib=0D
+ PrintLib=0D
+ HiiLib=0D
+ TcgPpVendorLib=0D
+=0D
+[Protocols]=0D
+ gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES=0D
+ gEdkiiVariableLockProtocolGuid ## SOMETIMES_CONSUMES=0D
+=0D
+[Guids]=0D
+ ## SOMETIMES_CONSUMES ## HII=0D
+ ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence"=0D
+ ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence"=0D
+ ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresenceFlags"=0D
+ ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresenceFlags"=0D
+ gEfiPhysicalPresenceGuid=0D
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPrese=
nceLib.uni b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPrese=
nceLib.uni
new file mode 100644
index 0000000000..c7fcca5c65
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.=
uni
@@ -0,0 +1,22 @@
+// /** @file=0D
+// Executes pending TPM 1.2 requests from OS or BIOS and Locks TPM=0D
+//=0D
+// This library will check and execute TPM 1.2 request from OS or BIOS. Th=
e request may=0D
+// ask for user confirmation before execution. This Library will also lock=
TPM physical=0D
+// presence at last.=0D
+//=0D
+// Caution: This module requires additional review when modified.=0D
+// This driver will have external input - variable.=0D
+// This external input must be validated carefully to avoid security issue=
.=0D
+//=0D
+// Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>=
=0D
+//=0D
+// SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+//=0D
+// **/=0D
+=0D
+=0D
+#string STR_MODULE_ABSTRACT #language en-US "Executes pending =
TPM 1.2 requests from OS or BIOS and Locks TPM"=0D
+=0D
+#string STR_MODULE_DESCRIPTION #language en-US "This library will=
ask for user confirmation for the pending TPM physical present requests. O=
nce confirmed, it will execute the request, and locks TPM physical presence=
at last. Caution: This module requires additional review when modified. Th=
is driver will have external input - variable. This external input must be =
validated carefully to avoid security issue."=0D
+=0D
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/PhysicalPresenceStr=
ings.uni b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/PhysicalPresenceStrin=
gs.uni
new file mode 100644
index 0000000000..9d17432ef8
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/PhysicalPresenceStrings.uni
@@ -0,0 +1,46 @@
+/** @file=0D
+ String definitions for TPM 1.2 physical presence confirm text.=0D
+=0D
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>=0D
+(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>=0D
+SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#langdef en-US "English"=0D
+=0D
+#string TPM_HEAD_STR #language en-US "A configuration =
change was requested to %s this computer's TPM (Trusted Platform Module)\n\=
n"=0D
+#string TPM_PPI_HEAD_STR #language en-US "A configuration =
change was requested to allow the Operating System to %s the computer's TPM=
(Trusted Platform Module) without asking for user confirmation in the futu=
re.\n\n"=0D
+#string TPM_UPGRADE_HEAD_STR #language en-US "A configuration =
change was requested to %s to the TPM's (Trusted Platform Module) firmware.=
\n\n"=0D
+=0D
+#string TPM_ACCEPT_KEY #language en-US "Press F10 "=0D
+#string TPM_CAUTION_KEY #language en-US "Press F12 "=0D
+#string TPM_REJECT_KEY #language en-US "to %s the TPM \n=
Press ESC to reject this change request and continue\n"=0D
+=0D
+#string TPM_ENABLE #language en-US "enable"=0D
+#string TPM_DISABLE #language en-US "disable"=0D
+#string TPM_ACTIVATE #language en-US "activate"=0D
+#string TPM_DEACTIVATE #language en-US "deactivate"=0D
+#string TPM_CLEAR #language en-US "clear"=0D
+#string TPM_ENABLE_ACTIVATE #language en-US "enable and activ=
ate"=0D
+#string TPM_DEACTIVATE_DISABLE #language en-US "deactivate and d=
isable"=0D
+#string TPM_ALLOW_TAKE_OWNERSHIP #language en-US "allow a user to =
take ownership of"=0D
+#string TPM_DISALLOW_TAKE_OWNERSHIP #language en-US "disallow a user =
to take ownership of"=0D
+#string TPM_TURN_ON #language en-US "enable, activate=
, and allow a user to take ownership of"=0D
+#string TPM_TURN_OFF #language en-US "deactivate, disa=
ble, and disallow a user to take ownership of"=0D
+#string TPM_CLEAR_TURN_ON #language en-US "clear, enable, a=
nd activate"=0D
+#string TPM_ENABLE_ACTIVATE_CLEAR #language en-US "enable, activate=
and clear"=0D
+#string TPM_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE #language en-US =
"enable, activate, clear, enable, and activate"=0D
+#string TPM_UNOWNED_FIELD_UPGRADE #language en-US "allow field upgr=
ade"=0D
+=0D
+#string TPM_NO_PPI_PROVISION #language en-US "provision"=0D
+#string TPM_NO_PPI_MAINTAIN #language en-US "maintain"=0D
+#string TPM_NO_PPI_INFO #language en-US "to approve futur=
e Operating System requests "=0D
+=0D
+#string TPM_WARNING_MAINTAIN #language en-US "WARNING: Allowin=
g changes to the TPM's firmware may affect the operation of the TPM and may=
erase information stored on the TPM.\nYou may lose all created keys and ac=
cess to data encrypted by these keys.\n\n"=0D
+#string TPM_WARNING #language en-US "WARNING: Doing s=
o might prevent security applications that rely on the TPM from functioning=
as expected\n\n"=0D
+#string TPM_WARNING_CLEAR #language en-US "WARNING: Clearin=
g erases information stored on the TPM. You will lose all created keys and =
access to data encrypted by these keys. "=0D
+#string TPM_WARNING_CLEAR_CONT #language en-US "Take ownership a=
s soon as possible after this step.\n\n"=0D
+#string TPM_NOTE_OFF #language en-US "NOTE: This actio=
n will turn off the TPM\n\n"=0D
+#string TPM_NOTE_ON #language en-US "NOTE: This actio=
n will turn on the TPM\n\n"=0D
+#string TPM_NOTE_CLEAR #language en-US "NOTE: This actio=
n does not clear the TPM, but by approving this configuration change, futur=
e actions to clear the TPM will not require user confirmation.\n\n"=0D
--=20
2.31.1


[PATCH v2 0/4] Add support for TPM 1.2 Physical Presence Interface and Menu

Stefan Berger
 

This series adds support for the full TPM 1.2 Physical Presence Interface
(PPI) and activates the TPM 1.2 menu at the end. PPI is a prerequisite for
the menu to work.

The modifications to the original code are mostly due to the fact that we
are using a memory region for PPI in QEMU. I tried to keep them at a minimum.
For the PPI Flags I am using a EFI variable just like the original code does.
(SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c)

Regards,
Stefan

v2:
- Added patch that copies sources from SecurityPkg to OvmfPkg before changes
- Use CONSTRUCTOR from DxeTcgPhysicalPresenceLib.inf
- Other nits

Gerd Hoffmann (1):
OvmfPkg: add TPM 1.2 config menu

Stefan Berger (3):
SecurityPkg: Store physical presence code by submitting to PreOS func
OvmfPkg: Copy TPM 1.2 DxeTcgPhysicalPresenceLib.c from SecuityPkg
OvmfPkg: Enable physical presence interface for TPM 1.2

.../PlatformBootManagerLib/BdsPlatform.c | 2 +
.../PlatformBootManagerLib.inf | 1 +
.../DxeTcgPhysicalPresenceLib.c | 22 +
.../DxeTcgPhysicalPresenceLib.inf | 27 +
.../DxeTcgPhysicalPresenceLib.c | 1469 +++++++++++++++++
.../DxeTcgPhysicalPresenceLib.inf | 64 +
.../DxeTcgPhysicalPresenceLib.uni | 22 +
.../PhysicalPresenceStrings.uni | 46 +
OvmfPkg/OvmfTpmComponentsDxe.dsc.inc | 1 +
OvmfPkg/OvmfTpmDxe.fdf.inc | 1 +
OvmfPkg/OvmfTpmLibs.dsc.inc | 4 +
.../Include/Library/TcgPhysicalPresenceLib.h | 39 +
.../DxeTcgPhysicalPresenceLib.c | 55 +
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf | 1 +
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c | 41 +-
15 files changed, 1769 insertions(+), 26 deletions(-)
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.c
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.uni
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibQemu/PhysicalPresenceStrings.uni

--
2.31.1


[PATCH v2 4/4] OvmfPkg: add TPM 1.2 config menu

Stefan Berger
 

From: Gerd Hoffmann <kraxel@...>

When building OVMF with TPM 1.2 support enabled do also include the
configuration menu.

Suggested-by: Stefan Berger <stefanb@...>
Signed-off-by: Gerd Hoffmann <kraxel@...>
---
OvmfPkg/OvmfTpmComponentsDxe.dsc.inc | 1 +
OvmfPkg/OvmfTpmDxe.fdf.inc | 1 +
2 files changed, 2 insertions(+)

diff --git a/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc b/OvmfPkg/OvmfTpmComponen=
tsDxe.dsc.inc
index 75ae09571e..cdcae42ad1 100644
--- a/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
+++ b/OvmfPkg/OvmfTpmComponentsDxe.dsc.inc
@@ -20,6 +20,7 @@
<LibraryClasses>=0D
Tpm12DeviceLib|SecurityPkg/Library/Tpm12DeviceLibDTpm/Tpm12DeviceLib=
DTpm.inf=0D
}=0D
+ SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf=0D
!endif=0D
SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf {=0D
<LibraryClasses>=0D
diff --git a/OvmfPkg/OvmfTpmDxe.fdf.inc b/OvmfPkg/OvmfTpmDxe.fdf.inc
index 7fc2bf8590..5907d8a8f1 100644
--- a/OvmfPkg/OvmfTpmDxe.fdf.inc
+++ b/OvmfPkg/OvmfTpmDxe.fdf.inc
@@ -5,6 +5,7 @@
!if $(TPM2_ENABLE) =3D=3D TRUE=0D
!if $(TPM1_ENABLE) =3D=3D TRUE=0D
INF SecurityPkg/Tcg/TcgDxe/TcgDxe.inf=0D
+INF SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf=0D
!endif=0D
INF SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf=0D
INF SecurityPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf=0D
--=20
2.31.1


[PATCH v2 3/4] OvmfPkg: Enable physical presence interface for TPM 1.2

Stefan Berger
 

Enable the physical presence interface for TPM 1.2. It is required for the
TPM 1.2 menu to work.

The changes to DxeTcgPhysicalPresenceLib.c are due to the device we are using
in QEMU for presenting the supported PPI commands and results to the OS via
ACPI as well as to store the PPI opcode to execute.

Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ard Biesheuvel <ardb+tianocore@...>
Cc: Jordan Justen <jordan.l.justen@...>
Cc: Gerd Hoffmann <kraxel@...>
Cc: Marc-André Lureau <marcandre.lureau@...>
Signed-off-by: Stefan Berger <stefanb@...>
---
.../PlatformBootManagerLib/BdsPlatform.c | 2 +
.../PlatformBootManagerLib.inf | 1 +
.../DxeTcgPhysicalPresenceLib.c | 22 +
.../DxeTcgPhysicalPresenceLib.inf | 27 +
.../DxeTcgPhysicalPresenceLib.c | 466 +++++++++---------
.../DxeTcgPhysicalPresenceLib.inf | 14 +-
OvmfPkg/OvmfTpmLibs.dsc.inc | 4 +
.../Include/Library/TcgPhysicalPresenceLib.h | 39 ++
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf | 1 +
9 files changed, 343 insertions(+), 233 deletions(-)
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.c
create mode 100644 OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 9b21ba2bd6..f56aff2ec5 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -12,6 +12,7 @@
#include <Protocol/FirmwareVolume2.h>
#include <Library/PlatformBmPrintScLib.h>
#include <Library/Tcg2PhysicalPresenceLib.h>
+#include <Library/TcgPhysicalPresenceLib.h>
#include <Library/XenPlatformLib.h>


@@ -396,6 +397,7 @@ PlatformBootManagerBeforeConsole (
//
// Process TPM PPI request; this may require keyboard input
//
+ TcgPhysicalPresenceLibProcessRequest ();
Tcg2PhysicalPresenceLibProcessRequest (NULL);

//
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index c249a3cf1e..f12975d065 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -54,6 +54,7 @@
ReportStatusCodeLib
UefiLib
PlatformBmPrintScLib
+ TcgPhysicalPresenceLib
Tcg2PhysicalPresenceLib
XenPlatformLib

diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.c b/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.c
new file mode 100644
index 0000000000..d434175717
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.c
@@ -0,0 +1,22 @@
+/** @file
+ NULL TcgPhysicalPresenceLib library instance
+
+ Copyright (C) 2021, IBM Corporation
+ Copyright (c) 2018, Red Hat, Inc.
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/TcgPhysicalPresenceLib.h>
+
+VOID
+EFIAPI
+TcgPhysicalPresenceLibProcessRequest (
+ VOID
+ )
+{
+ //
+ // do nothing
+ //
+}
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf b/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf
new file mode 100644
index 0000000000..4421c6c5b0
--- /dev/null
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf
@@ -0,0 +1,27 @@
+# NULL TcgPhysicalPresenceLib library instance
+#
+# Under SecurityPkg, the corresponding library instance will check and
+# execute TPM 1.2 request from OS or BIOS; the request may ask for user
+# confirmation before execution. This Null instance implements a no-op
+# Tcg2PhysicalPresenceLibProcessRequest(), without user interaction.
+#
+# Copyright (C) 2018, Red Hat, Inc.
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeTcgPhysicalPresenceLibNull
+ FILE_GUID = B648575C-ED00-4C0D-BD7F-B705B9B0CC93
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TcgPhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
+
+[Sources]
+ DxeTcgPhysicalPresenceLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SecurityPkg/SecurityPkg.dec
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c
index 8a3ae95012..9e489623c3 100644
--- a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.c
@@ -15,18 +15,24 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#include <PiDxe.h>

+#include <IndustryStandard/QemuTpm.h>
+#include <IndustryStandard/TcgPhysicalPresence.h>
+
#include <Protocol/TcgService.h>
#include <Protocol/VariableLock.h>
+#include <Library/HobLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/DxeServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
+#include <Library/UefiBootManagerLib.h>
#include <Library/UefiLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
+#include <Library/QemuFwCfgLib.h>
#include <Library/HiiLib.h>
-#include <Guid/EventGroup.h>
#include <Guid/PhysicalPresenceData.h>
#include <Library/TcgPpVendorLib.h>

@@ -34,6 +40,168 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

EFI_HII_HANDLE mPpStringPackHandle;

+STATIC volatile QEMU_TPM_PPI *mPpi;
+
+#define TPM_PPI_PROVISION_FLAGS(PpiFlags) \
+ ((PpiFlags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_PROVISION) != 0) \
+ ? QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ \
+ : QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ
+
+#define TPM_PPI_CLEAR_FLAGS(PpiFlags) \
+ ((PpiFlags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0) \
+ ? QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ \
+ : QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ
+
+#define TPM_PPI_CLEAR_MAINT_FLAGS(PpiFlags) \
+ ((PpiFlags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_CLEAR) != 0 && \
+ (PpiFlags.PPFlags & TCG_BIOS_TPM_MANAGEMENT_FLAG_NO_PPI_MAINTENANCE) != 0) \
+ ? QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ \
+ : QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ
+
+/**
+ Reads QEMU PPI config from fw_cfg.
+
+ @param[out] The Config structure to read to.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_PROTOCOL_ERROR Invalid fw_cfg entry size.
+**/
+STATIC
+EFI_STATUS
+QemuTpmReadConfig (
+ OUT QEMU_FWCFG_TPM_CONFIG *Config
+ )
+{
+ EFI_STATUS Status;
+ FIRMWARE_CONFIG_ITEM FwCfgItem;
+ UINTN FwCfgSize;
+
+ Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (FwCfgSize != sizeof (*Config)) {
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ QemuFwCfgSelectItem (FwCfgItem);
+ QemuFwCfgReadBytes (sizeof (*Config), Config);
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Initilalize the QEMU PPI memory region's function array
+**/
+STATIC
+VOID
+QemuTpmInitPPIFunc(
+ EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags
+ )
+{
+ ZeroMem ((void *)mPpi->Func, sizeof(mPpi->Func));
+
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_DISABLE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ACTIVATE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_DEACTIVATE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_CLEAR] = TPM_PPI_CLEAR_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE_ACTIVATE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_DEACTIVATE_DISABLE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_OWNER_INSTALL_TRUE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_OWNER_INSTALL_FALSE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE_ACTIVATE_OWNER_TRUE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_DEACTIVATE_DISABLE_OWNER_FALSE] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_OPERATOR_AUTH] = TPM_PPI_PROVISION_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_CLEAR_ENABLE_ACTIVATE] = TPM_PPI_CLEAR_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_FALSE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_PROVISION_TRUE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_FALSE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_CLEAR_TRUE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_FALSE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_NOT_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_SET_NO_PPI_MAINTENANCE_TRUE] = QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ;
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR] = TPM_PPI_CLEAR_MAINT_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE] = TPM_PPI_CLEAR_MAINT_FLAGS(PpiFlags);
+ mPpi->Func[TCG_PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR] = TPM_PPI_CLEAR_MAINT_FLAGS(PpiFlags);
+}
+
+
+/**
+ Initializes QEMU PPI memory region.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_PROTOCOL_ERROR PPI address is invalid.
+**/
+STATIC
+EFI_STATUS
+QemuTpmInitPPI (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ QEMU_FWCFG_TPM_CONFIG Config;
+ EFI_PHYSICAL_ADDRESS PpiAddress64;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
+ EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;
+
+ if (mPpi != NULL) {
+ return EFI_SUCCESS;
+ }
+
+ Status = QemuTpmReadConfig (&Config);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Config.TpmVersion != QEMU_TPM_VERSION_1_2) {
+ DEBUG ((DEBUG_ERROR, "[TPM] Not setting up PPI. This is not a TPM 1.2.\n"));
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ mPpi = (QEMU_TPM_PPI *)(UINTN)Config.PpiAddress;
+ if (mPpi == NULL) {
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ DEBUG ((DEBUG_INFO, "[TPM] mPpi=%p version=%d\n", mPpi, Config.TpmVersion));
+
+ PpiAddress64 = (UINTN)mPpi;
+ if ((PpiAddress64 & ~(UINT64)EFI_PAGE_MASK) !=
+ ((PpiAddress64 + sizeof *mPpi - 1) & ~(UINT64)EFI_PAGE_MASK)) {
+ DEBUG ((DEBUG_ERROR, "[TPM] mPpi crosses a page boundary\n"));
+ goto InvalidPpiAddress;
+ }
+
+ Status = gDS->GetMemorySpaceDescriptor (PpiAddress64, &Descriptor);
+ if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+ ASSERT_EFI_ERROR (Status);
+ goto InvalidPpiAddress;
+ }
+ if (!EFI_ERROR (Status) &&
+ (Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo &&
+ Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)) {
+ DEBUG ((DEBUG_ERROR, "[TPM] mPpi has an invalid memory type\n"));
+ goto InvalidPpiAddress;
+ }
+
+ PpiFlags.PPFlags = 0;
+ QemuTpmInitPPIFunc(PpiFlags);
+
+ if (mPpi->In == 0) {
+ mPpi->In = 1;
+ mPpi->Request = PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->LastRequest = PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->NextStep = PHYSICAL_PRESENCE_NO_ACTION;
+ }
+
+ return EFI_SUCCESS;
+
+InvalidPpiAddress:
+ mPpi = NULL;
+ return EFI_PROTOCOL_ERROR;
+}
+
/**
Get string by string id from HII Interface.

@@ -506,7 +674,7 @@ TcgPhysicalPresenceLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- mPpStringPackHandle = HiiAddPackages (&gEfiPhysicalPresenceGuid, ImageHandle, DxeTcgPhysicalPresenceLibStrings, NULL);
+ mPpStringPackHandle = HiiAddPackages (&gEfiPhysicalPresenceGuid, ImageHandle, TcgPhysicalPresenceLibQemuStrings, NULL);
ASSERT (mPpStringPackHandle != NULL);

return EFI_SUCCESS;
@@ -875,6 +1043,10 @@ UserConfirm (
return FALSE;
}

+ // Console for user interaction
+ // We need to connect all trusted consoles for TCG PP. Here we treat all consoles in OVMF to be trusted consoles.
+ EfiBootManagerConnectAllDefaultConsoles ();
+
TmpStr1 = PhysicalPresenceGetStringById (STRING_TOKEN (TPM_REJECT_KEY));
BufSize -= StrSize (ConfirmText);
UnicodeSPrint (ConfirmText + StrLen (ConfirmText), BufSize, TmpStr1, TmpStr2);
@@ -975,7 +1147,7 @@ HaveValidTpmRequest (

default:
if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
- IsRequestValid = TcgPpVendorLibHasValidRequest (TcgPpData->PPRequest, Flags.PPFlags, RequestConfirmed);
+ IsRequestValid = FALSE; // vendor-specifc commands are not supported
if (!IsRequestValid) {
return FALSE;
} else {
@@ -1015,60 +1187,47 @@ HaveValidTpmRequest (
@param[in] Flags The physical presence interface flags.

**/
+STATIC
VOID
ExecutePendingTpmRequest (
IN EFI_TCG_PROTOCOL *TcgProtocol,
- IN EFI_PHYSICAL_PRESENCE *TcgPpData,
IN EFI_PHYSICAL_PRESENCE_FLAGS Flags
)
{
EFI_STATUS Status;
- UINTN DataSize;
BOOLEAN RequestConfirmed;
+ EFI_PHYSICAL_PRESENCE TcgPpData;
EFI_PHYSICAL_PRESENCE_FLAGS NewFlags;
- BOOLEAN ResetRequired;
- UINT32 NewPPFlags;

- if (!HaveValidTpmRequest(TcgPpData, Flags, &RequestConfirmed)) {
+ DEBUG ((DEBUG_INFO, "[TPM] Flags=%x, PPRequest=%x\n", Flags.PPFlags, mPpi->Request));
+
+ TcgPpData.PPRequest = (UINT8)mPpi->Request;
+
+ if (!HaveValidTpmRequest(&TcgPpData, Flags, &RequestConfirmed)) {
//
// Invalid operation request.
//
- TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
- TcgPpData->LastPPRequest = TcgPpData->PPRequest;
- TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->SetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- TcgPpData
- );
+ mPpi->Response = TCG_PP_OPERATION_RESPONSE_BIOS_FAILURE;
+ mPpi->LastRequest = mPpi->Request;
+ mPpi->Request = TCG_PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->RequestParameter = 0;
return;
}

- ResetRequired = FALSE;
- if (TcgPpData->PPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
- NewFlags = Flags;
- NewPPFlags = NewFlags.PPFlags;
- TcgPpData->PPResponse = TcgPpVendorLibExecutePendingRequest (TcgPpData->PPRequest, &NewPPFlags, &ResetRequired);
- NewFlags.PPFlags = (UINT8)NewPPFlags;
- } else {
- if (!RequestConfirmed) {
- //
- // Print confirm text and wait for approval.
- //
- RequestConfirmed = UserConfirm (TcgPpData->PPRequest);
- }
-
+ if (!RequestConfirmed) {
//
- // Execute requested physical presence command
+ // Print confirm text and wait for approval.
//
- TcgPpData->PPResponse = TCG_PP_OPERATION_RESPONSE_USER_ABORT;
- NewFlags = Flags;
- if (RequestConfirmed) {
- TcgPpData->PPResponse = ExecutePhysicalPresence (TcgProtocol, TcgPpData->PPRequest, &NewFlags);
- }
+ RequestConfirmed = UserConfirm (mPpi->Request);
+ }
+
+ //
+ // Execute requested physical presence command
+ //
+ mPpi->Response = TCG_PP_OPERATION_RESPONSE_USER_ABORT;
+ NewFlags = Flags;
+ if (RequestConfirmed) {
+ mPpi->Response = ExecutePhysicalPresence (TcgProtocol, mPpi->Request, &NewFlags);
}

//
@@ -1085,39 +1244,32 @@ ExecutePendingTpmRequest (
if (EFI_ERROR (Status)) {
return;
}
+
+ //
+ // Update the flags for the commands following PPFlags changes
+ //
+ QemuTpmInitPPIFunc(NewFlags);
+
+ DEBUG ((DEBUG_INFO, "[TPM] New PPFlags = %x\n", NewFlags.PPFlags));
}

//
// Clear request
//
if ((NewFlags.PPFlags & TCG_VENDOR_LIB_FLAG_RESET_TRACK) == 0) {
- TcgPpData->LastPPRequest = TcgPpData->PPRequest;
- TcgPpData->PPRequest = PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->LastRequest = mPpi->Request;
+ mPpi->Request = PHYSICAL_PRESENCE_NO_ACTION;
+ mPpi->RequestParameter = 0;
}

- //
- // Save changes
- //
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->SetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- TcgPpData
- );
- if (EFI_ERROR (Status)) {
- return;
- }
-
- if (TcgPpData->PPResponse == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {
+ if (mPpi->Response == TCG_PP_OPERATION_RESPONSE_USER_ABORT) {
return;
}

//
// Reset system to make new TPM settings in effect
//
- switch (TcgPpData->LastPPRequest) {
+ switch (mPpi->LastRequest) {
case PHYSICAL_PRESENCE_ACTIVATE:
case PHYSICAL_PRESENCE_DEACTIVATE:
case PHYSICAL_PRESENCE_CLEAR:
@@ -1131,17 +1283,10 @@ ExecutePendingTpmRequest (
case PHYSICAL_PRESENCE_ENABLE_ACTIVATE_CLEAR_ENABLE_ACTIVATE:
break;
default:
- if (TcgPpData->LastPPRequest >= TCG_PHYSICAL_PRESENCE_VENDOR_SPECIFIC_OPERATION) {
- if (ResetRequired) {
- break;
- } else {
- return ;
- }
- }
- if (TcgPpData->PPRequest != PHYSICAL_PRESENCE_NO_ACTION) {
- break;
- }
- return;
+ if (mPpi->Request != TCG_PHYSICAL_PRESENCE_NO_ACTION) {
+ break;
+ }
+ return;
}

Print (L"Rebooting system to make TPM settings in effect\n");
@@ -1172,11 +1317,25 @@ TcgPhysicalPresenceLibProcessRequest (
BOOLEAN LifetimeLock;
BOOLEAN CmdEnable;
UINTN DataSize;
- EFI_PHYSICAL_PRESENCE TcgPpData;
EFI_TCG_PROTOCOL *TcgProtocol;
- EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;
+// EDKII_VARIABLE_LOCK_PROTOCOL *VariableLockProtocol;
EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;

+ Status = QemuTpmInitPPI ();
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ DEBUG ((DEBUG_INFO, "[TPM] Detected a TPM 1.2\n"));
+
+ //
+ // Check S4 resume
+ //
+ if (GetBootModeHob () == BOOT_ON_S4_RESUME) {
+ DEBUG ((DEBUG_INFO, "S4 Resume, Skip TPM PP process!\n"));
+ return ;
+ }
+
Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);
if (EFI_ERROR (Status)) {
return ;
@@ -1213,6 +1372,7 @@ TcgPhysicalPresenceLibProcessRequest (
// This flags variable controls whether physical presence is required for TPM command.
// It should be protected from malicious software. We set it as read-only variable here.
//
+#if 0
Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **)&VariableLockProtocol);
if (!EFI_ERROR (Status)) {
Status = VariableLockProtocol->RequestToLock (
@@ -1225,37 +1385,13 @@ TcgPhysicalPresenceLibProcessRequest (
ASSERT_EFI_ERROR (Status);
}
}
+#endif

- //
- // Initialize physical presence variable.
- //
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->GetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- NULL,
- &DataSize,
- &TcgPpData
- );
- if (EFI_ERROR (Status)) {
- ZeroMem ((VOID*)&TcgPpData, sizeof (TcgPpData));
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->SetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- &TcgPpData
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "[TPM] Set physical presence variable failed, Status = %r\n", Status));
- return;
- }
- }
+ QemuTpmInitPPIFunc(PpiFlags);

- DEBUG ((DEBUG_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, TcgPpData.PPRequest));
+ DEBUG ((DEBUG_INFO, "[TPM] Flags=%x, PPRequest=%x\n", PpiFlags.PPFlags, mPpi->Request));

- if (TcgPpData.PPRequest == PHYSICAL_PRESENCE_NO_ACTION) {
+ if (mPpi->Request == PHYSICAL_PRESENCE_NO_ACTION) {
//
// No operation request
//
@@ -1291,8 +1427,8 @@ TcgPhysicalPresenceLibProcessRequest (
//
// Execute pending TPM request.
//
- ExecutePendingTpmRequest (TcgProtocol, &TcgPpData, PpiFlags);
- DEBUG ((DEBUG_INFO, "[TPM] PPResponse = %x\n", TcgPpData.PPResponse));
+ ExecutePendingTpmRequest (TcgProtocol, PpiFlags);
+ DEBUG ((DEBUG_INFO, "[TPM] PPResponse = %x\n", mPpi->Response));

//
// Lock physical presence.
@@ -1300,104 +1436,6 @@ TcgPhysicalPresenceLibProcessRequest (
TpmPhysicalPresence (TcgProtocol, TPM_PHYSICAL_PRESENCE_NOTPRESENT | TPM_PHYSICAL_PRESENCE_LOCK);
}

-/**
- Check if the pending TPM request needs user input to confirm.
-
- The TPM request may come from OS. This API will check if TPM request exists and need user
- input to confirmation.
-
- @retval TRUE TPM needs input to confirm user physical presence.
- @retval FALSE TPM doesn't need input to confirm user physical presence.
-
-**/
-BOOLEAN
-EFIAPI
-TcgPhysicalPresenceLibNeedUserConfirm(
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_PRESENCE TcgPpData;
- UINTN DataSize;
- BOOLEAN RequestConfirmed;
- BOOLEAN LifetimeLock;
- BOOLEAN CmdEnable;
- EFI_TCG_PROTOCOL *TcgProtocol;
- EFI_PHYSICAL_PRESENCE_FLAGS PpiFlags;
-
- Status = gBS->LocateProtocol (&gEfiTcgProtocolGuid, NULL, (VOID **)&TcgProtocol);
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- //
- // Check Tpm requests
- //
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->GetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- NULL,
- &DataSize,
- &TcgPpData
- );
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE_FLAGS);
- Status = gRT->GetVariable (
- PHYSICAL_PRESENCE_FLAGS_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- NULL,
- &DataSize,
- &PpiFlags
- );
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- if (TcgPpData.PPRequest == PHYSICAL_PRESENCE_NO_ACTION) {
- //
- // No operation request
- //
- return FALSE;
- }
-
- if (!HaveValidTpmRequest(&TcgPpData, PpiFlags, &RequestConfirmed)) {
- //
- // Invalid operation request.
- //
- return FALSE;
- }
-
- //
- // Check Tpm Capability
- //
- Status = GetTpmCapability (TcgProtocol, &LifetimeLock, &CmdEnable);
- if (EFI_ERROR (Status)) {
- return FALSE;
- }
-
- if (!CmdEnable) {
- if (LifetimeLock) {
- //
- // physicalPresenceCMDEnable is locked, can't execute physical presence command.
- //
- return FALSE;
- }
- }
-
- if (!RequestConfirmed) {
- //
- // Need UI to confirm
- //
- return TRUE;
- }
-
- return FALSE;
-}
-
/**
The handler for TPM physical presence function:
Submit TPM Operation Request to Pre-OS Environment and
@@ -1416,40 +1454,16 @@ TcgPhysicalPresenceLibSubmitRequestToPreOSFunction (
IN UINT32 OperationRequest
)
{
- EFI_STATUS Status;
- UINTN DataSize;
- EFI_PHYSICAL_PRESENCE PpData;
+ EFI_STATUS Status;

DEBUG ((DEBUG_INFO, "[TPM] SubmitRequestToPreOSFunction, Request = %x\n", OperationRequest));

- //
- // Get the Physical Presence variable
- //
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->GetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- NULL,
- &DataSize,
- &PpData
- );
+ Status = QemuTpmInitPPI ();
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));
return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
}

- PpData.PPRequest = (UINT8)OperationRequest;
- Status = gRT->SetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- &PpData
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "[TPM] Set PP variable failure! Status = %r\n", Status));
- return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
- }
+ mPpi->Request = OperationRequest;

return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;
}
diff --git a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf
index cfe14f20ca..a7f76d5918 100644
--- a/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf
+++ b/OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf
@@ -16,9 +16,8 @@

[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = DxeTcgPhysicalPresenceLib
- MODULE_UNI_FILE = DxeTcgPhysicalPresenceLib.uni
- FILE_GUID = EBC43A46-34AC-4F07-A7F5-A5394619361C
+ BASE_NAME = TcgPhysicalPresenceLibQemu
+ FILE_GUID = DA5A2055-ACD6-49A1-8277-857f3A47BB0C
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = TcgPhysicalPresenceLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
@@ -37,19 +36,22 @@
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
+ OvmfPkg/OvmfPkg.dec
SecurityPkg/SecurityPkg.dec

[LibraryClasses]
MemoryAllocationLib
+ DxeServicesTableLib
+ HobLib
+ QemuFwCfgLib
+ UefiBootManagerLib
UefiLib
UefiBootServicesTableLib
- UefiDriverEntryPoint
UefiRuntimeServicesTableLib
BaseMemoryLib
DebugLib
PrintLib
HiiLib
- TcgPpVendorLib

[Protocols]
gEfiTcgProtocolGuid ## SOMETIMES_CONSUMES
@@ -57,8 +59,6 @@

[Guids]
## SOMETIMES_CONSUMES ## HII
- ## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresence"
- ## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresence"
## SOMETIMES_PRODUCES ## Variable:L"PhysicalPresenceFlags"
## SOMETIMES_CONSUMES ## Variable:L"PhysicalPresenceFlags"
gEfiPhysicalPresenceGuid
diff --git a/OvmfPkg/OvmfTpmLibs.dsc.inc b/OvmfPkg/OvmfTpmLibs.dsc.inc
index 418747b134..24b54861ed 100644
--- a/OvmfPkg/OvmfTpmLibs.dsc.inc
+++ b/OvmfPkg/OvmfTpmLibs.dsc.inc
@@ -5,6 +5,9 @@
!if $(TPM2_ENABLE) == TRUE
!if $(TPM1_ENABLE) == TRUE
Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
+ TcgPhysicalPresenceLib|OvmfPkg/Library/TcgPhysicalPresenceLibQemu/DxeTcgPhysicalPresenceLib.inf
+!else
+ TcgPhysicalPresenceLib|OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf
!endif
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
@@ -13,4 +16,5 @@
!else
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
+ TcgPhysicalPresenceLib|OvmfPkg/Library/TcgPhysicalPresenceLibNull/DxeTcgPhysicalPresenceLib.inf
!endif
diff --git a/SecurityPkg/Include/Library/TcgPhysicalPresenceLib.h b/SecurityPkg/Include/Library/TcgPhysicalPresenceLib.h
index 9826a79742..6877c08e74 100644
--- a/SecurityPkg/Include/Library/TcgPhysicalPresenceLib.h
+++ b/SecurityPkg/Include/Library/TcgPhysicalPresenceLib.h
@@ -45,4 +45,43 @@ TcgPhysicalPresenceLibNeedUserConfirm(
VOID
);

+/**
+ The handler for TPM physical presence function:
+ Return TPM Operation Response to OS Environment.
+
+ This API should be invoked in OS runtime phase to interface with ACPI method.
+
+ @param[out] MostRecentRequest Most recent operation request.
+ @param[out] Response Response to the most recent operation request.
+
+ @return Return Code for Return TPM Operation Response to OS Environment.
+**/
+UINT32
+EFIAPI
+Tcg2PhysicalPresenceLibReturnOperationResponseToOsFunction (
+ OUT UINT32 *MostRecentRequest,
+ OUT UINT32 *Response
+ );
+
+/**
+ The handler for TPM physical presence function:
+ Submit TPM Operation Request to Pre-OS Environment and
+ Submit TPM Operation Request to Pre-OS Environment 2.
+
+ This API should be invoked in OS runtime phase to interface with ACPI method.
+
+ Caution: This function may receive untrusted input.
+
+ @param[in] OperationRequest TPM physical presence operation request.
+ @param[in] RequestParameter TPM physical presence operation request parameter.
+
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and
+ Submit TPM Operation Request to Pre-OS Environment 2.
+**/
+UINT32
+EFIAPI
+TcgPhysicalPresenceLibSubmitRequestToPreOSFunction (
+ IN UINT32 OperationRequest
+ );
+
#endif
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
index 24428e050c..b2f36fdbb2 100644
--- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigDxe.inf
@@ -47,6 +47,7 @@
HiiLib
PcdLib
PrintLib
+ TcgPhysicalPresenceLib
Tpm12DeviceLib

[Guids]
--
2.31.1


[PATCH v2 1/4] SecurityPkg: Store physical presence code by submitting to PreOS func

Stefan Berger
 

Modify SavePpRequest to look like its TPM 2 equivalent SaveTcg2PpRequest
and have it submit the physical presence opcode to the PreOS function so
that we can choose our own method for how to store it.

Move the existing code into DxeTcgPhysicalPresenceLib.c and adapt the
return codes.

Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Marc-André Lureau <marcandre.lureau@...>
Signed-off-by: Stefan Berger <stefanb@...>
---
.../DxeTcgPhysicalPresenceLib.c | 55 +++++++++++++++++++
SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c | 41 +++++---------
2 files changed, 70 insertions(+), 26 deletions(-)

diff --git a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
index ba1abe9e08..aa0031dd77 100644
--- a/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
+++ b/SecurityPkg/Library/DxeTcgPhysicalPresenceLib/DxeTcgPhysicalPresenceLib.c
@@ -1398,3 +1398,58 @@ TcgPhysicalPresenceLibNeedUserConfirm(
return FALSE;
}

+/**
+ The handler for TPM physical presence function:
+ Submit TPM Operation Request to Pre-OS Environment and
+ Submit TPM Operation Request to Pre-OS Environment 2.
+
+ Caution: This function may receive untrusted input.
+
+ @param[in] OperationRequest TPM physical presence operation request.
+
+ @return Return Code for Submit TPM Operation Request to Pre-OS Environment and
+ Submit TPM Operation Request to Pre-OS Environment 2.
+**/
+UINT32
+EFIAPI
+TcgPhysicalPresenceLibSubmitRequestToPreOSFunction (
+ IN UINT32 OperationRequest
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+ EFI_PHYSICAL_PRESENCE PpData;
+
+ DEBUG ((DEBUG_INFO, "[TPM] SubmitRequestToPreOSFunction, Request = %x\n", OperationRequest));
+
+ //
+ // Get the Physical Presence variable
+ //
+ DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
+ Status = gRT->GetVariable (
+ PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiPhysicalPresenceGuid,
+ NULL,
+ &DataSize,
+ &PpData
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[TPM] Get PP variable failure! Status = %r\n", Status));
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
+ }
+
+ PpData.PPRequest = (UINT8)OperationRequest;
+ Status = gRT->SetVariable (
+ PHYSICAL_PRESENCE_VARIABLE,
+ &gEfiPhysicalPresenceGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize,
+ &PpData
+ );
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "[TPM] Set PP variable failure! Status = %r\n", Status));
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE;
+ }
+
+ return TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS;
+}
diff --git a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
index 68cd62307c..61c072d1a3 100644
--- a/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
+++ b/SecurityPkg/Tcg/TcgConfigDxe/TcgConfigImpl.c
@@ -8,6 +8,9 @@ SPDX-License-Identifier: BSD-2-Clause-Patent

#include "TcgConfigImpl.h"

+#include <IndustryStandard/TcgPhysicalPresence.h>
+#include <Library/TcgPhysicalPresenceLib.h>
+
CHAR16 mTcgStorageName[] = L"TCG_CONFIGURATION";

TCG_CONFIG_PRIVATE_DATA mTcgConfigPrivateDateTemplate = {
@@ -299,37 +302,23 @@ SavePpRequest (
)
{
EFI_STATUS Status;
- UINTN DataSize;
- EFI_PHYSICAL_PRESENCE PpData;
+ UINT32 ReturnCode;

//
- // Save TPM command to variable.
+ // Submit TPM command to PreOS fuction
//
- DataSize = sizeof (EFI_PHYSICAL_PRESENCE);
- Status = gRT->GetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- NULL,
- &DataSize,
- &PpData
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- PpData.PPRequest = PpRequest;
- Status = gRT->SetVariable (
- PHYSICAL_PRESENCE_VARIABLE,
- &gEfiPhysicalPresenceGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- &PpData
- );
- if (EFI_ERROR(Status)) {
- return Status;
+ ReturnCode = TcgPhysicalPresenceLibSubmitRequestToPreOSFunction (PpRequest);
+ if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_SUCCESS) {
+ Status = EFI_SUCCESS;
+ } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_GENERAL_FAILURE) {
+ Status = EFI_OUT_OF_RESOURCES;
+ } else if (ReturnCode == TCG_PP_SUBMIT_REQUEST_TO_PREOS_NOT_IMPLEMENTED) {
+ Status = EFI_UNSUPPORTED;
+ } else {
+ Status = EFI_DEVICE_ERROR;
}

- return EFI_SUCCESS;
+ return Status;
}

/**
--
2.31.1


Re: About how to submit a new architecture called LoongArch

Andrew Fish
 

Chao,

This is probably a little out of date, but in case it helps http://vzimmer.blogspot.com/2014/11/porting-to-new-architecture.html?m=1


On Nov 2, 2021, at 7:32 AM, gaoliming <gaoliming@...> wrote:

Chao:
 Can you follow Mike's suggestion to share the your code change in your personal GitHub repo as the first step?

Thanks
Liming
-----邮件原件-----
发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Michael D
Kinney
发送时间: 2021年10月29日 13:19
收件人: devel@edk2.groups.io; kilaterlee@...; Kinney, Michael D
<michael.d.kinney@...>
主题: Re: [edk2-devel] About how to submit a new architecture called
LoongArch

LI Chao,

The best way to share your source code changes with the TianoCore
community
with a fork of the edk2 repository in your personal GitHub.  Create a branch
with the proposed changes and send an email with the link to the branch for
the community to review.

The edk2-staging repository would be a good second step if the new
architecture is approved for the EDK II project.

Best regards,

Mike

-----Original Message-----
From: Kinney, Michael D <michael.d.kinney@...>
Sent: Thursday, October 28, 2021 10:13 PM
To: devel@edk2.groups.io; kilaterlee@...; Kinney, Michael D
<michael.d.kinney@...>
Subject: RE: [edk2-devel] About how to submit a new architecture called
LoongArch

Hi LI Chao,

Can you provide a brief description of LoongArch and perhaps provide links
to
documentation and overview materials?

Thanks,

Mike


==============================================================
==================

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
kilaterlee@...
Sent: Wednesday, October 27, 2021 2:41 AM
To: devel@edk2.groups.io
Subject: [edk2-devel] About how to submit a new architecture called
LoongArch

Dear All:
   I want to submit a new architecture called LoongArch on EDK2 and
the USWG recommands us do "code first" because the
UEFI specifitcation will easily accpet our arch.
   What can we do? Do I submit the part 1 code for new architecture on
the "staging" branch? Hop you reply. :)
________________________________________
Thanks,
LI Chao













9281 - 9300 of 92359