public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers
@ 2019-01-14 13:27 Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution Ard Biesheuvel
                   ` (17 more replies)
  0 siblings, 18 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

This v2 series is a followup to [0], and updates the SMM implementations of
the fault tolerant write and variable runtime drivers to provide standalone
MM versions that share as much of the existing code as possible with the
traditional SMM implementations.

The meat is in patches #5 - #8, which were part of v1. I updated them according
to the received feedback, and added tags that were given on list.

Patches #1 - #4 add library class resolutions for MmServiceTableLib, which was
introduced in v1 of the series, and has already been merged (at the request of
Liming) so that downstream platforms can add the resolution as well.

The remaining patches #9 - #17 are new, and have been added so that the new
standalone MM drivers can be added to and built from MdeModulePkg.dsc, but
for coverage only (the resulting binaries won't actually work)
- patches #9 and #10 add a definition and implementation of
  StandaloneMmDriverEntryPoint, which is rather straight-forward and has no
  dependencies on the standalone MM core, so it is reasonable to add it to
  MdePkg directly. Note that this version contains the _gMmVersion check that
  is missing from the one in StandaloneMmPkg
- patch #11 adds a standalone MM implementation of MmServicesTableLib to MdePkg,
  which -again- does not depend on the standalone MM core at all, so added here
  for simplicity
- patches #12 and #13 add NULL implementations of MemoryAllocationLib and HobLib
  so that the FTW and variable MM_STANDALONE modules can be built without
  depending on StandaloneMmPkg
- patch #14 is an unrelated fix so that MdeModulePkg.dsc can be built for
  AARCH64
- patches #15 and #16 add MM_STANDALONE support to a couple of libraries that
  the new modules depend on
- patch #17 adds the FTW and variable standalone MM drivers to MdeModulePkg.dsc

NOTE: the drivers added in patches #10 and #11 supersede the ones that reside in
or have been proposed for StandaloneMmPkg

Patches can be found here:
https://github.com/ardbiesheuvel/edk2/tree/variable-ftw-standalone-mm-conversion

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
Cc: Achin Gupta <Achin.Gupta@arm.com>
Cc: Thomas Panakamattam Abraham <thomas.abraham@arm.com>
Cc: Sami Mujawar <Sami.Mujawar@arm.com>
Cc: Star Zeng <star.zeng@intel.com>

[0] https://lists.01.org/pipermail/edk2-devel/2019-January/034608.html

Ard Biesheuvel (17):
  MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
  OvmfPkg: add MmServicesTableLib resolution
  QuarkPlatformPkg: add MmServicesTableLib resolution
  Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
  MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
  MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
  MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
  MdePkg: introduce standalone MM entry point library class
  MdePkg: introduce standalone MM entry point library implementation
  MdePkg: add MM_STANDALONE implementation of MmServicesTableLib
  MdeModulePkg: implement NULL instance of HobLib library class
  MdeModulePkg: implement NULL instance of MemoryAllocationLib library class
  MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section
  MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
  MdeModulePkg/VarCheckLib: add MM_STANDALONE support
  MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules

 MdePkg/MdePkg.dec                                                                                              |   3 +
 MdeModulePkg/MdeModulePkg.dsc                                                                                  |  12 +-
 MdePkg/MdePkg.dsc                                                                                              |   3 +
 OvmfPkg/OvmfPkgIa32.dsc                                                                                        |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                                                                                     |   1 +
 OvmfPkg/OvmfPkgX64.dsc                                                                                         |   1 +
 QuarkPlatformPkg/Quark.dsc                                                                                     |   1 +
 QuarkPlatformPkg/QuarkMin.dsc                                                                                  |   1 +
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc                                                                        |   1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc                                                                          |   1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc                                                                           |   1 +
 MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf                                               |   2 +-
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf                                                         |  38 ++
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf                               |  38 ++
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf                                                               |   2 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf                                         |   5 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf => FaultTolerantWriteStandaloneMm.inf} |  43 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf                                                     |   5 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf => VariableStandaloneMm.inf}                       |  43 +-
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf                                   |  43 ++
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf                                   |  39 ++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h                                              |  23 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h                                     |  34 ++
 MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h                                              |  58 ++
 MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h                                                          | 134 +++++
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c                                                           | 542 ++++++++++++++++++
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c                                 | 575 ++++++++++++++++++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c                                           |  31 ++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c                                           |  53 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c                                  |  88 +++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c                                 | 106 ++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c                                              |  10 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c                                                     |  18 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c                                                       |  59 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c                                              |  89 +++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c                                             | 130 +++++
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c                                     |  90 +++
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c                                     |  41 ++
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni                                                         |  20 +
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni                               |  20 +
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni                                   |  22 +
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni                                   |  20 +
 42 files changed, 2290 insertions(+), 157 deletions(-)
 create mode 100644 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
 create mode 100644 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
 copy MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf => FaultTolerantWriteStandaloneMm.inf} (68%)
 copy MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf => VariableStandaloneMm.inf} (82%)
 create mode 100644 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
 create mode 100644 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
 create mode 100644 MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
 create mode 100644 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
 create mode 100644 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
 create mode 100644 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
 create mode 100644 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
 create mode 100644 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
 create mode 100644 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
 create mode 100644 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
 create mode 100644 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c
 create mode 100644 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
 create mode 100644 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
 create mode 100644 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni
 create mode 100644 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni

-- 
2.20.1



^ permalink raw reply	[flat|nested] 41+ messages in thread

* [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:02   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 02/17] OvmfPkg: " Ard Biesheuvel
                   ` (16 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

The SMM based FTW and variable drivers are going to depend on
MmServicesTableLib after a subsequent patch, so add a resolution
for it to MdeModulePkg.dsc.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/MdeModulePkg.dsc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 5d042be3a862..967fe082aaae 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -152,6 +152,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 02/17] OvmfPkg: add MmServicesTableLib resolution
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-14 16:40   ` Laszlo Ersek
  2019-01-14 13:27 ` [PATCH v2 03/17] QuarkPlatformPkg: " Ard Biesheuvel
                   ` (15 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

The SMM based FTW and variable drivers are going to depend on
MmServicesTableLib after a subsequent patch, so add a resolution
for it to various OvmfPkg .dsc files.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 OvmfPkg/OvmfPkgIa32.dsc    | 1 +
 OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
 OvmfPkg/OvmfPkgX64.dsc     | 1 +
 3 files changed, 3 insertions(+)

diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 3f3533e5c163..aee19b75d7ae 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -385,6 +385,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index 6c08b2728d63..90cbd8e34158 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 4072c839d73f..83d16eb00b82 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
   ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
   HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
   SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
 !ifdef $(DEBUG_ON_SERIAL_PORT)
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 03/17] QuarkPlatformPkg: add MmServicesTableLib resolution
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 02/17] OvmfPkg: " Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16 15:14   ` Gao, Liming
  2019-01-14 13:27 ` [PATCH v2 04/17] Vlv2TbltDevicePkg: " Ard Biesheuvel
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

The SMM based FTW and variable drivers are going to depend on
MmServicesTableLib after a subsequent patch, so add a resolution
for it to various QuarkPlatformPkg .dsc files.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 QuarkPlatformPkg/Quark.dsc    | 1 +
 QuarkPlatformPkg/QuarkMin.dsc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
index 96ae404f476c..0e69b3c51f97 100644
--- a/QuarkPlatformPkg/Quark.dsc
+++ b/QuarkPlatformPkg/Quark.dsc
@@ -282,6 +282,7 @@ [LibraryClasses.IA32.DXE_CORE]
 !endif
 
 [LibraryClasses.IA32.DXE_SMM_DRIVER]
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
diff --git a/QuarkPlatformPkg/QuarkMin.dsc b/QuarkPlatformPkg/QuarkMin.dsc
index d7a25686a30b..0f6da821cb82 100644
--- a/QuarkPlatformPkg/QuarkMin.dsc
+++ b/QuarkPlatformPkg/QuarkMin.dsc
@@ -242,6 +242,7 @@ [LibraryClasses.IA32.DXE_CORE]
 !endif
 
 [LibraryClasses.IA32.DXE_SMM_DRIVER]
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (2 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 03/17] QuarkPlatformPkg: " Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16 15:14   ` Gao, Liming
  2019-01-14 13:27 ` [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses Ard Biesheuvel
                   ` (13 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

The SMM based FTW and variable drivers are going to depend on
MmServicesTableLib after a subsequent patch, so add a resolution
for it to various Vlv2TbltDevicePkg .dsc files.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
 Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
 Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
 3 files changed, 3 insertions(+)

diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
index d43611550285..eb7c205a10a6 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
@@ -406,6 +406,7 @@ [LibraryClasses.X64.DXE_CORE]
 !endif
 
 [LibraryClasses.X64.DXE_SMM_DRIVER]
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
index a33816c4d18b..b2f0d73f6d05 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
@@ -406,6 +406,7 @@ [LibraryClasses.IA32.DXE_CORE]
 !endif
 
 [LibraryClasses.IA32.DXE_SMM_DRIVER]
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
index 1da1442c64c6..aa62c07f177b 100644
--- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
+++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
@@ -408,6 +408,7 @@ [LibraryClasses.X64.DXE_CORE]
 !endif
 
 [LibraryClasses.X64.DXE_SMM_DRIVER]
+  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
   SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
   ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
   MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (3 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 04/17] Vlv2TbltDevicePkg: " Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  3:29   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version Ard Biesheuvel
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

In preparation of providing a standalone MM based FTW driver, move
the existing SMM driver to the new MM services table, and factor out
some pieces that are specific to the traditional driver, mainly
related to the use of UEFI boot services, which are not accessible
to standalone MM drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf         |   5 +-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h              |  23 ++++-
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h     |  34 +++++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c           |  31 ++++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c           |  53 ++++------
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c | 106 ++++++++++++++++++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c              |  10 +-
 7 files changed, 219 insertions(+), 43 deletions(-)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
index 606cc2266bda..1653365bc247 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
@@ -37,6 +37,7 @@ [Sources]
   FtwMisc.c
   UpdateWorkingBlock.c
   FaultTolerantWrite.c
+  FaultTolerantWriteTraditionalMm.c
   FaultTolerantWriteSmm.c
   FaultTolerantWrite.h
   FaultTolerantWriteSmmCommon.h
@@ -46,7 +47,7 @@ [Packages]
   MdeModulePkg/MdeModulePkg.dec
 
 [LibraryClasses]
-  SmmServicesTableLib
+  MmServicesTableLib
   MemoryAllocationLib
   BaseMemoryLib
   UefiDriverEntryPoint
@@ -73,7 +74,7 @@ [Protocols]
   ## PRODUCES
   ## UNDEFINED # SmiHandlerRegister
   gEfiSmmFaultTolerantWriteProtocolGuid
-  gEfiSmmEndOfDxeProtocolGuid                      ## CONSUMES
+  gEfiMmEndOfDxeProtocolGuid                      ## CONSUMES
 
 [FeaturePcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable    ## CONSUMES
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
index 844cf3bee04d..a23cb620e2f2 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
@@ -31,7 +31,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiDriverEntryPoint.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
 #include <Library/ReportStatusCodeLib.h>
 
 //
@@ -766,4 +765,26 @@ WriteWorkSpaceData (
   IN UINT8                              *Buffer
   );
 
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (traditional SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is
+                           to be computed.
+  @param[in]  Length       The number of bytes in the buffer Data.
+
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID                         *Buffer,
+  IN  UINTN                        Length
+  );
+
 #endif
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
index 8ad0015f3c9e..23d9a49e8bcf 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h
@@ -77,4 +77,38 @@ typedef struct {
   UINT8                                 Data[1];
 } SMM_FTW_GET_LAST_WRITE_HEADER;
 
+/**
+  Entry point of the module
+**/
+EFI_STATUS
+MmFaultTolerantWriteInitialize (
+  VOID
+  );
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  );
+
+/**
+  Notify the system that the SMM FTW driver is ready
+**/
+VOID
+FtwNotifySmmReady (
+  VOID
+  );
+
 #endif
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
index 094e40f9d86c..24e507104bbe 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
@@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
+#include <Library/UefiBootServicesTableLib.h>
 #include "FaultTolerantWrite.h"
 EFI_EVENT                                 mFvbRegistration = NULL;
 
@@ -250,3 +251,33 @@ FaultTolerantWriteInitialize (
 
   return EFI_SUCCESS;
 }
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (traditional SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is to be computed.
+  @param[in]  Length       The number of bytes in the buffer Data.
+
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID                         *Buffer,
+  IN  UINTN                        Length
+  )
+{
+  EFI_STATUS    Status;
+  UINT32        ReturnValue;
+
+  Status = gBS->CalculateCrc32 (Buffer, Length, &ReturnValue);
+  ASSERT_EFI_ERROR (Status);
+
+  return ReturnValue;
+}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
index 481fea3f1fdf..148eedc71a0c 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
@@ -54,14 +54,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
-#include <PiSmm.h>
-#include <Library/SmmServicesTableLib.h>
-#include <Library/SmmMemLib.h>
+#include <PiMm.h>
+#include <Library/MmServicesTableLib.h>
 #include <Library/BaseLib.h>
 #include <Protocol/SmmSwapAddressRange.h>
 #include "FaultTolerantWrite.h"
 #include "FaultTolerantWriteSmmCommon.h"
-#include <Protocol/SmmEndOfDxe.h>
+#include <Protocol/MmEndOfDxe.h>
 
 EFI_EVENT                                 mFvbRegistration = NULL;
 EFI_FTW_DEVICE                            *mFtwDevice      = NULL;
@@ -92,7 +91,7 @@ FtwGetFvbByHandle (
   //
   // To get the SMM FVB protocol interface on the handle
   //
-  return gSmst->SmmHandleProtocol (
+  return gMmst->MmHandleProtocol (
                   FvBlockHandle,
                   &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                   (VOID **) FvBlock
@@ -119,7 +118,7 @@ FtwGetSarProtocol (
   //
   // Locate Smm Swap Address Range protocol
   //
-  Status = gSmst->SmmLocateProtocol (
+  Status = gMmst->MmLocateProtocol (
                     &gEfiSmmSwapAddressRangeProtocolGuid,
                     NULL,
                     SarProtocol
@@ -158,7 +157,7 @@ GetFvbCountAndBuffer (
   BufferSize     = 0;
   *NumberHandles = 0;
   *Buffer        = NULL;
-  Status = gSmst->SmmLocateHandle (
+  Status = gMmst->MmLocateHandle (
                     ByProtocol,
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     NULL,
@@ -174,7 +173,7 @@ GetFvbCountAndBuffer (
     return EFI_OUT_OF_RESOURCES;
   }
 
-  Status = gSmst->SmmLocateHandle (
+  Status = gMmst->MmLocateHandle (
                     ByProtocol,
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     NULL,
@@ -336,7 +335,7 @@ SmmFaultTolerantWriteHandler (
   }
   CommBufferPayloadSize = TempCommBufferSize - SMM_FTW_COMMUNICATE_HEADER_SIZE;
 
-  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+  if (!FtwSmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
     DEBUG ((EFI_D_ERROR, "SmmFtwHandler: SMM communication buffer in SMRAM or overflow!\n"));
     return EFI_SUCCESS;
   }
@@ -525,13 +524,12 @@ FvbNotificationEvent (
   EFI_STATUS                              Status;
   EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL   *FtwProtocol;
   EFI_HANDLE                              SmmFtwHandle;
-  EFI_HANDLE                              FtwHandle;
 
   //
   // Just return to avoid install SMM FaultTolerantWriteProtocol again
   // if SMM Fault Tolerant Write protocol had been installed.
   //
-  Status = gSmst->SmmLocateProtocol (
+  Status = gMmst->MmLocateProtocol (
                     &gEfiSmmFaultTolerantWriteProtocolGuid,
                     NULL,
                     (VOID **) &FtwProtocol
@@ -551,7 +549,7 @@ FvbNotificationEvent (
   //
   // Install protocol interface
   //
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
                     &mFtwDevice->Handle,
                     &gEfiSmmFaultTolerantWriteProtocolGuid,
                     EFI_NATIVE_INTERFACE,
@@ -562,20 +560,13 @@ FvbNotificationEvent (
   ///
   /// Register SMM FTW SMI handler
   ///
-  Status = gSmst->SmiHandlerRegister (SmmFaultTolerantWriteHandler, &gEfiSmmFaultTolerantWriteProtocolGuid, &SmmFtwHandle);
+  Status = gMmst->MmiHandlerRegister (SmmFaultTolerantWriteHandler, &gEfiSmmFaultTolerantWriteProtocolGuid, &SmmFtwHandle);
   ASSERT_EFI_ERROR (Status);
 
   //
   // Notify the Ftw wrapper driver SMM Ftw is ready
   //
-  FtwHandle = NULL;
-  Status = gBS->InstallProtocolInterface (
-                  &FtwHandle,
-                  &gEfiSmmFaultTolerantWriteProtocolGuid,
-                  EFI_NATIVE_INTERFACE,
-                  NULL
-                  );
-  ASSERT_EFI_ERROR (Status);
+  FtwNotifySmmReady ();
 
   return EFI_SUCCESS;
 }
@@ -592,7 +583,7 @@ FvbNotificationEvent (
 **/
 EFI_STATUS
 EFIAPI
-SmmEndOfDxeCallback (
+MmEndOfDxeCallback (
   IN CONST EFI_GUID                       *Protocol,
   IN VOID                                 *Interface,
   IN EFI_HANDLE                           Handle
@@ -614,14 +605,12 @@ SmmEndOfDxeCallback (
 
 **/
 EFI_STATUS
-EFIAPI
-SmmFaultTolerantWriteInitialize (
-  IN EFI_HANDLE                           ImageHandle,
-  IN EFI_SYSTEM_TABLE                     *SystemTable
+MmFaultTolerantWriteInitialize (
+  VOID
   )
 {
   EFI_STATUS                              Status;
-  VOID                                    *SmmEndOfDxeRegistration;
+  VOID                                    *MmEndOfDxeRegistration;
 
   //
   // Allocate private data structure for SMM FTW protocol and do some initialization
@@ -634,17 +623,17 @@ SmmFaultTolerantWriteInitialize (
   //
   // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
   //
-  Status = gSmst->SmmRegisterProtocolNotify (
-                    &gEfiSmmEndOfDxeProtocolGuid,
-                    SmmEndOfDxeCallback,
-                    &SmmEndOfDxeRegistration
+  Status = gMmst->MmRegisterProtocolNotify (
+                    &gEfiMmEndOfDxeProtocolGuid,
+                    MmEndOfDxeCallback,
+                    &MmEndOfDxeRegistration
                     );
   ASSERT_EFI_ERROR (Status);
 
   //
   // Register FvbNotificationEvent () notify function.
   //
-  Status = gSmst->SmmRegisterProtocolNotify (
+  Status = gMmst->MmRegisterProtocolNotify (
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     FvbNotificationEvent,
                     &mFvbRegistration
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
new file mode 100644
index 000000000000..78351199d3f1
--- /dev/null
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
@@ -0,0 +1,106 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to traditional MM
+
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/SmmMemLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  )
+{
+  return SmmIsBufferOutsideSmmValid (Buffer, Length);
+}
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (traditional SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is
+                           to be computed.
+  @param[in]  Length       The number of bytes in the buffer Data.
+
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID                         *Buffer,
+  IN  UINTN                        Length
+  )
+{
+  EFI_STATUS    Status;
+  UINT32        ReturnValue;
+
+  Status = gBS->CalculateCrc32 (Buffer, Length, &ReturnValue);
+  ASSERT_EFI_ERROR (Status);
+
+  return ReturnValue;
+}
+
+/**
+  Notify the system that the SMM FTW driver is ready
+**/
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+  EFI_HANDLE          FtwHandle;
+  EFI_STATUS          Status;
+
+  FtwHandle = NULL;
+  Status = gBS->InstallProtocolInterface (
+                  &FtwHandle,
+                  &gEfiSmmFaultTolerantWriteProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  NULL
+                  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
+  Entry point of the module
+**/
+EFI_STATUS
+EFIAPI
+SmmFaultTolerantWriteInitialize (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SYSTEM_TABLE      *SystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
index 50d3421b88bb..d09e9719cf05 100644
--- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
@@ -29,8 +29,6 @@ InitializeLocalWorkSpaceHeader (
   VOID
   )
 {
-  EFI_STATUS                              Status;
-
   //
   // Check signature with gEdkiiWorkingBlockSignatureGuid.
   //
@@ -64,12 +62,8 @@ InitializeLocalWorkSpaceHeader (
   //
   // Calculate the Crc of woking block header
   //
-  Status = gBS->CalculateCrc32 (
-                  &mWorkingBlockHeader,
-                  sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER),
-                  &mWorkingBlockHeader.Crc
-                  );
-  ASSERT_EFI_ERROR (Status);
+  mWorkingBlockHeader.Crc = FtwCalculateCrc32 (&mWorkingBlockHeader,
+                              sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER));
 
   mWorkingBlockHeader.WorkingBlockValid    = FTW_VALID_STATE;
   mWorkingBlockHeader.WorkingBlockInvalid  = FTW_INVALID_STATE;
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (4 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  3:32   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses Ard Biesheuvel
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Implement a new version of the fault tolerant write driver that can
be used in the context of a standalone MM implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
---
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf | 90 ++++++++++++++++++++
 MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c   | 88 +++++++++++++++++++
 2 files changed, 178 insertions(+)

diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
new file mode 100644
index 000000000000..c667d4c19bfa
--- /dev/null
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
@@ -0,0 +1,90 @@
+ ## @file
+#   Fault Tolerant Write Smm Driver.
+#
+#   This driver installs SMM Fault Tolerant Write (FTW) protocol, which provides fault
+#   tolerant write capability in SMM environment for block devices. Its implementation
+#   depends on the full functionality SMM FVB protocol that support read, write/erase
+#   flash access.
+#
+# Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = FaultTolerantWriteStandaloneMm
+  FILE_GUID                      = 3aade4ec-63cc-4a48-a928-5a374dd463eb
+  MODULE_TYPE                    = MM_STANDALONE
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  ENTRY_POINT                    = StandaloneMmFaultTolerantWriteInitialize
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  FtwMisc.c
+  UpdateWorkingBlock.c
+  FaultTolerantWrite.c
+  FaultTolerantWriteStandaloneMm.c
+  FaultTolerantWriteSmm.c
+  FaultTolerantWrite.h
+  FaultTolerantWriteSmmCommon.h
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[LibraryClasses]
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  MemoryAllocationLib
+  MmServicesTableLib
+  PcdLib
+  ReportStatusCodeLib
+  StandaloneMmDriverEntryPoint
+
+[Guids]
+  #
+  # Signature in EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER
+  #
+  ## CONSUMES           ## GUID
+  ## PRODUCES           ## GUID
+  gEdkiiWorkingBlockSignatureGuid
+
+[Protocols]
+  gEfiSmmSwapAddressRangeProtocolGuid | gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable  ## SOMETIMES_CONSUMES
+  ## NOTIFY
+  ## CONSUMES
+  gEfiSmmFirmwareVolumeBlockProtocolGuid
+  ## PRODUCES
+  ## UNDEFINED # SmiHandlerRegister
+  gEfiSmmFaultTolerantWriteProtocolGuid
+  gEfiMmEndOfDxeProtocolGuid                       ## CONSUMES
+
+[FeaturePcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable    ## CONSUMES
+
+[Pcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase    ## SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase      ## SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64    ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize      ## CONSUMES
+
+[Depex]
+  TRUE
diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
new file mode 100644
index 000000000000..95effd6d75fa
--- /dev/null
+++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
@@ -0,0 +1,88 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/SmmMemLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include "FaultTolerantWrite.h"
+#include "FaultTolerantWriteSmmCommon.h"
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+FtwSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  )
+{
+  return TRUE;
+}
+
+/**
+  Internal implementation of CRC32. Depending on the execution context
+  (standalone SMM or DXE vs standalone MM), this function is implemented
+  via a call to the CalculateCrc32 () boot service, or via a library
+  call.
+
+  If Buffer is NULL, then ASSERT().
+  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is to be computed.
+  @param[in]  Length       The number of bytes in the buffer Data.
+
+  @retval Crc32            The 32-bit CRC was computed for the data buffer.
+
+**/
+UINT32
+FtwCalculateCrc32 (
+  IN  VOID                         *Buffer,
+  IN  UINTN                        Length
+  )
+{
+  return CalculateCrc32 (Buffer, Length);
+}
+
+/**
+  Notify the system that the SMM FTW driver is ready
+**/
+VOID
+FtwNotifySmmReady (
+  VOID
+  )
+{
+}
+
+/**
+  Entry point of the module
+**/
+EFI_STATUS
+EFIAPI
+StandaloneMmFaultTolerantWriteInitialize (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  return MmFaultTolerantWriteInitialize ();
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (5 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  4:57   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version Ard Biesheuvel
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

In preparation of providing a standalone MM based variable runtime
driver, move the existing SMM driver to the new MM services table,
and factor out some pieces that are specific to the traditional
driver, mainly related to the use of UEFI boot services, which are
not accessible to standalone MM drivers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf         |   5 +-
 MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h  |  58 +++++++++
 MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c         |  18 +--
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c           |  59 +++------
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c | 130 ++++++++++++++++++++
 5 files changed, 211 insertions(+), 59 deletions(-)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
index db7d220e06df..ed7392cbcffc 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
@@ -48,6 +48,7 @@ [Defines]
 [Sources]
   Reclaim.c
   Variable.c
+  VariableTraditionalMm.c
   VariableSmm.c
   VarCheck.c
   Variable.h
@@ -66,7 +67,7 @@ [LibraryClasses]
   BaseLib
   SynchronizationLib
   UefiLib
-  SmmServicesTableLib
+  MmServicesTableLib
   BaseMemoryLib
   DebugLib
   DxeServicesTableLib
@@ -85,7 +86,7 @@ [Protocols]
   ## PRODUCES
   ## UNDEFINED # SmiHandlerRegister
   gEfiSmmVariableProtocolGuid
-  gEfiSmmEndOfDxeProtocolGuid                   ## NOTIFY
+  gEfiMmEndOfDxeProtocolGuid                    ## NOTIFY
   gEdkiiSmmVarCheckProtocolGuid                 ## PRODUCES
   gEfiTcgProtocolGuid                           ## SOMETIMES_CONSUMES
   gEfiTcg2ProtocolGuid                          ## SOMETIMES_CONSUMES
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
index 7af22a4ad671..eb84589fc404 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
@@ -97,4 +97,62 @@ VariableSpeculationBarrier (
   VOID
   );
 
+/**
+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  );
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  );
+
+/**
+  Variable service MM driver entry point
+**/
+EFI_STATUS
+EFIAPI
+MmVariableServiceInitialize (
+  VOID
+  );
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  );
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.
+
+  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
+                protocol database
+  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
+                protocol database
+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  );
+
 #endif
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
index 28aa2893c6f8..009d96c3a65e 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
@@ -21,7 +21,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
 #include "Variable.h"
 
 typedef struct {
@@ -419,8 +418,6 @@ MorLockInitAtEndOfDxe (
 {
   UINTN      MorSize;
   EFI_STATUS MorStatus;
-  EFI_STATUS TcgStatus;
-  VOID       *TcgInterface;
 
   if (!mMorLockInitializationRequired) {
     //
@@ -458,20 +455,7 @@ MorLockInitAtEndOfDxe (
     // can be deduced from the absence of the TCG / TCG2 protocols, as edk2's
     // MOR implementation depends on (one of) those protocols.
     //
-    TcgStatus = gBS->LocateProtocol (
-                       &gEfiTcg2ProtocolGuid,
-                       NULL,                     // Registration
-                       &TcgInterface
-                       );
-    if (EFI_ERROR (TcgStatus)) {
-      TcgStatus = gBS->LocateProtocol (
-                         &gEfiTcgProtocolGuid,
-                         NULL,                   // Registration
-                         &TcgInterface
-                         );
-    }
-
-    if (!EFI_ERROR (TcgStatus)) {
+    if (VariableHaveTcgProtocols ()) {
       //
       // The MOR variable originates from the platform firmware; set the MOR
       // Control Lock variable to report the locking capability to the OS.
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
index 8c53f84ff6e8..7245587052df 100644
--- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
@@ -15,6 +15,7 @@
   SmmVariableGetStatistics() should also do validation based on its own knowledge.
 
 Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
 This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
@@ -28,18 +29,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/SmmVariable.h>
 #include <Protocol/SmmFirmwareVolumeBlock.h>
 #include <Protocol/SmmFaultTolerantWrite.h>
-#include <Protocol/SmmEndOfDxe.h>
+#include <Protocol/MmEndOfDxe.h>
 #include <Protocol/SmmVarCheck.h>
 
-#include <Library/SmmServicesTableLib.h>
-#include <Library/SmmMemLib.h>
+#include <Library/MmServicesTableLib.h>
 
 #include <Guid/SmmVariableCommon.h>
 #include "Variable.h"
 
 extern VARIABLE_INFO_ENTRY                           *gVariableInfo;
-EFI_HANDLE                                           mSmmVariableHandle      = NULL;
-EFI_HANDLE                                           mVariableHandle         = NULL;
 BOOLEAN                                              mAtRuntime              = FALSE;
 UINT8                                                *mVariableBufferPayload = NULL;
 UINTN                                                mVariableBufferPayloadSize;
@@ -218,7 +216,7 @@ GetFtwProtocol (
   //
   // Locate Smm Fault Tolerent Write protocol
   //
-  Status = gSmst->SmmLocateProtocol (
+  Status = gMmst->MmLocateProtocol (
                     &gEfiSmmFaultTolerantWriteProtocolGuid,
                     NULL,
                     FtwProtocol
@@ -248,7 +246,7 @@ GetFvbByHandle (
   //
   // To get the SMM FVB protocol interface on the handle
   //
-  return gSmst->SmmHandleProtocol (
+  return gMmst->MmHandleProtocol (
                   FvBlockHandle,
                   &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                   (VOID **) FvBlock
@@ -287,7 +285,7 @@ GetFvbCountAndBuffer (
   BufferSize     = 0;
   *NumberHandles = 0;
   *Buffer        = NULL;
-  Status = gSmst->SmmLocateHandle (
+  Status = gMmst->MmLocateHandle (
                     ByProtocol,
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     NULL,
@@ -303,7 +301,7 @@ GetFvbCountAndBuffer (
     return EFI_OUT_OF_RESOURCES;
   }
 
-  Status = gSmst->SmmLocateHandle (
+  Status = gMmst->MmLocateHandle (
                     ByProtocol,
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     NULL,
@@ -500,7 +498,7 @@ SmmVariableHandler (
     return EFI_SUCCESS;
   }
 
-  if (!SmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
+  if (!VariableSmmIsBufferOutsideSmmValid ((UINTN)CommBuffer, TempCommBufferSize)) {
     DEBUG ((EFI_D_ERROR, "SmmVariableHandler: SMM communication buffer in SMRAM or overflow!\n"));
     return EFI_SUCCESS;
   }
@@ -911,13 +909,7 @@ SmmFtwNotificationEvent (
   //
   // Notify the variable wrapper driver the variable write service is ready
   //
-  Status = gBS->InstallProtocolInterface (
-                  &mSmmVariableHandle,
-                  &gSmmVariableWriteGuid,
-                  EFI_NATIVE_INTERFACE,
-                  NULL
-                  );
-  ASSERT_EFI_ERROR (Status);
+  VariableNotifySmmWriteReady ();
 
   return EFI_SUCCESS;
 }
@@ -928,18 +920,11 @@ SmmFtwNotificationEvent (
   runtime services in the EFI System Table and installs arch protocols
   for variable read and write services being available. It also registers
   a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
-
-  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
-  @param[in] SystemTable    A pointer to the EFI System Table.
-
-  @retval EFI_SUCCESS       Variable service successfully initialized.
-
 **/
 EFI_STATUS
 EFIAPI
-VariableServiceInitialize (
-  IN EFI_HANDLE                           ImageHandle,
-  IN EFI_SYSTEM_TABLE                     *SystemTable
+MmVariableServiceInitialize (
+  VOID
   )
 {
   EFI_STATUS                              Status;
@@ -957,7 +942,7 @@ VariableServiceInitialize (
   // Install the Smm Variable Protocol on a new handle.
   //
   VariableHandle = NULL;
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
                     &VariableHandle,
                     &gEfiSmmVariableProtocolGuid,
                     EFI_NATIVE_INTERFACE,
@@ -965,7 +950,7 @@ VariableServiceInitialize (
                     );
   ASSERT_EFI_ERROR (Status);
 
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
                     &VariableHandle,
                     &gEdkiiSmmVarCheckProtocolGuid,
                     EFI_NATIVE_INTERFACE,
@@ -976,7 +961,7 @@ VariableServiceInitialize (
   mVariableBufferPayloadSize = GetMaxVariableSize () +
                                OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - GetVariableHeaderSize ();
 
-  Status = gSmst->SmmAllocatePool (
+  Status = gMmst->MmAllocatePool (
                     EfiRuntimeServicesData,
                     mVariableBufferPayloadSize,
                     (VOID **)&mVariableBufferPayload
@@ -987,25 +972,19 @@ VariableServiceInitialize (
   /// Register SMM variable SMI handler
   ///
   VariableHandle = NULL;
-  Status = gSmst->SmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
+  Status = gMmst->MmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
   ASSERT_EFI_ERROR (Status);
 
   //
   // Notify the variable wrapper driver the variable service is ready
   //
-  Status = SystemTable->BootServices->InstallProtocolInterface (
-                                        &mVariableHandle,
-                                        &gEfiSmmVariableProtocolGuid,
-                                        EFI_NATIVE_INTERFACE,
-                                        &gSmmVariable
-                                        );
-  ASSERT_EFI_ERROR (Status);
+  VariableNotifySmmReady ();
 
   //
   // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
   //
-  Status = gSmst->SmmRegisterProtocolNotify (
-                    &gEfiSmmEndOfDxeProtocolGuid,
+  Status = gMmst->MmRegisterProtocolNotify (
+                    &gEfiMmEndOfDxeProtocolGuid,
                     SmmEndOfDxeCallback,
                     &SmmEndOfDxeRegistration
                     );
@@ -1014,7 +993,7 @@ VariableServiceInitialize (
   //
   // Register FtwNotificationEvent () notify function.
   //
-  Status = gSmst->SmmRegisterProtocolNotify (
+  Status = gMmst->MmRegisterProtocolNotify (
                     &gEfiSmmFaultTolerantWriteProtocolGuid,
                     SmmFtwNotificationEvent,
                     &SmmFtwRegistration
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
new file mode 100644
index 000000000000..d702c8f8db67
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
@@ -0,0 +1,130 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to traditional MM
+
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/SmmMemLib.h>
+#include "Variable.h"
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  )
+{
+  return SmmIsBufferOutsideSmmValid (Buffer, Length);
+}
+
+/**
+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  )
+{
+  EFI_STATUS            Status;
+  EFI_HANDLE            Handle;
+
+  Handle = NULL;
+  Status = gBS->InstallProtocolInterface (
+                  &Handle,
+                  &gEfiSmmVariableProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  NULL
+                  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  )
+{
+  EFI_STATUS            Status;
+  EFI_HANDLE            Handle;
+
+  Handle = NULL;
+  Status = gBS->InstallProtocolInterface (
+                  &Handle,
+                  &gSmmVariableWriteGuid,
+                  EFI_NATIVE_INTERFACE,
+                  NULL
+                  );
+  ASSERT_EFI_ERROR (Status);
+}
+
+/**
+  Variable service MM driver entry point
+**/
+EFI_STATUS
+EFIAPI
+VariableServiceInitialize (
+  IN EFI_HANDLE                           ImageHandle,
+  IN EFI_SYSTEM_TABLE                     *SystemTable
+  )
+{
+  return MmVariableServiceInitialize ();
+}
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.
+
+  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
+                protocol database
+  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
+                protocol database
+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  )
+{
+  EFI_STATUS            Status;
+  VOID                  *Interface;
+
+  Status = gBS->LocateProtocol (
+                  &gEfiTcg2ProtocolGuid,
+                  NULL,                     // Registration
+                  &Interface
+                  );
+  if (!EFI_ERROR (Status)) {
+    return TRUE;
+  }
+
+  Status = gBS->LocateProtocol (
+                  &gEfiTcgProtocolGuid,
+                  NULL,                     // Registration
+                  &Interface
+                  );
+  return !EFI_ERROR (Status);
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (6 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:00   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class Ard Biesheuvel
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Reuse most of the existing code to implement a variable runtime
driver that will be able to execute in the context of standalone
MM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
---
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 136 ++++++++++++++++++++
 MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c   |  89 +++++++++++++
 2 files changed, 225 insertions(+)

diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
new file mode 100644
index 000000000000..efb84ed87832
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
@@ -0,0 +1,136 @@
+## @file
+#  Provides SMM variable service.
+#
+#  This module installs SMM variable protocol into SMM protocol database,
+#  which can be used by SMM driver, and installs SMM variable protocol
+#  into BS protocol database, which can be used to notify the SMM Runtime
+#  Dxe driver that the SMM variable service is ready.
+#  This module should be used with SMM Runtime DXE module together. The
+#  SMM Runtime DXE module would install variable arch protocol and variable
+#  write arch protocol based on SMM variable module.
+#
+#  Caution: This module requires additional review when modified.
+#  This driver will have external input - variable data and communicate buffer in SMM mode.
+#  This external input must be validated carefully to avoid security issues such as
+#  buffer overflow or integer overflow.
+#    The whole SMM authentication variable design relies on the integrity of flash part and SMM.
+#  which is assumed to be protected by platform.  All variable code and metadata in flash/SMM Memory
+#  may not be modified without authorization. If platform fails to protect these resources,
+#  the authentication service provided in this driver will be broken, and the behavior is undefined.
+#
+# Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = VariableStandaloneMm
+  FILE_GUID                      = 7ee2c0c1-c21a-4113-a53a-66824a95696f
+  MODULE_TYPE                    = MM_STANDALONE
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  ENTRY_POINT                    = VariableServiceInitialize
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+
+[Sources]
+  Reclaim.c
+  Variable.c
+  VariableSmm.c
+  VariableStandaloneMm.c
+  VarCheck.c
+  Variable.h
+  PrivilegePolymorphic.h
+  VariableExLib.c
+  TcgMorLockSmm.c
+  SpeculationBarrierSmm.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+  StandaloneMmPkg/StandaloneMmPkg.dec
+
+[LibraryClasses]
+  AuthVariableLib
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  HobLib
+  MemoryAllocationLib
+  MmServicesTableLib
+  StandaloneMmDriverEntryPoint
+  SynchronizationLib
+  VarCheckLib
+
+[Protocols]
+  gEfiSmmFirmwareVolumeBlockProtocolGuid        ## CONSUMES
+  ## CONSUMES
+  ## NOTIFY
+  gEfiSmmFaultTolerantWriteProtocolGuid
+  ## PRODUCES
+  ## UNDEFINED # SmiHandlerRegister
+  gEfiSmmVariableProtocolGuid
+  gEfiMmEndOfDxeProtocolGuid                   ## NOTIFY
+  gEdkiiSmmVarCheckProtocolGuid                ## PRODUCES
+
+[Guids]
+  ## SOMETIMES_CONSUMES   ## GUID # Signature of Variable store header
+  ## SOMETIMES_PRODUCES   ## GUID # Signature of Variable store header
+  ## SOMETIMES_CONSUMES   ## HOB
+  ## SOMETIMES_PRODUCES   ## SystemTable
+  gEfiAuthenticatedVariableGuid
+
+  ## SOMETIMES_CONSUMES   ## GUID # Signature of Variable store header
+  ## SOMETIMES_PRODUCES   ## GUID # Signature of Variable store header
+  ## SOMETIMES_CONSUMES   ## HOB
+  ## SOMETIMES_PRODUCES   ## SystemTable
+  gEfiVariableGuid
+
+  ## SOMETIMES_CONSUMES   ## Variable:L"PlatformLang"
+  ## SOMETIMES_PRODUCES   ## Variable:L"PlatformLang"
+  ## SOMETIMES_CONSUMES   ## Variable:L"Lang"
+  ## SOMETIMES_PRODUCES   ## Variable:L"Lang"
+  gEfiGlobalVariableGuid
+
+  gEfiMemoryOverwriteControlDataGuid            ## SOMETIMES_CONSUMES   ## Variable:L"MemoryOverwriteRequestControl"
+  gEfiMemoryOverwriteRequestControlLockGuid     ## SOMETIMES_PRODUCES   ## Variable:L"MemoryOverwriteRequestControlLock"
+
+  gEfiSystemNvDataFvGuid                        ## CONSUMES             ## GUID
+  gEdkiiFaultTolerantWriteGuid                  ## SOMETIMES_CONSUMES   ## HOB
+
+  ## SOMETIMES_CONSUMES   ## Variable:L"VarErrorFlag"
+  ## SOMETIMES_PRODUCES   ## Variable:L"VarErrorFlag"
+  gEdkiiVarErrorFlagGuid
+
+[FixedPcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize       ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase       ## SOMETIMES_CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64     ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize                  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize              ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize          ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize     ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize                ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdHwErrStorageSize                 ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdMaxUserNvVariableSpaceSize           ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdBoottimeReservedNvVariableSpaceSize  ## CONSUMES
+  gEfiMdeModulePkgTokenSpaceGuid.PcdReclaimVariableSpaceAtEndOfDxe   ## CONSUMES
+
+[FeaturePcd]
+  gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics        ## CONSUMES  # statistic the information of variable.
+  gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultLangDeprecate       ## CONSUMES  # Auto update PlatformLang/Lang
+
+[Depex]
+  TRUE
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
new file mode 100644
index 000000000000..51e21c599560
--- /dev/null
+++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
@@ -0,0 +1,89 @@
+/** @file
+
+  Parts of the SMM/MM implementation that are specific to standalone MM
+
+Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved. <BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved. <BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "Variable.h"
+
+/**
+  This function checks if the buffer is valid per processor architecture and
+  does not overlap with SMRAM.
+
+  @param Buffer The buffer start address to be checked.
+  @param Length The buffer length to be checked.
+
+  @retval TRUE  This buffer is valid per processor architecture and does not
+                overlap with SMRAM.
+  @retval FALSE This buffer is not valid per processor architecture or overlaps
+                with SMRAM.
+**/
+BOOLEAN
+VariableSmmIsBufferOutsideSmmValid (
+  IN EFI_PHYSICAL_ADDRESS  Buffer,
+  IN UINT64                Length
+  )
+{
+  return TRUE;
+}
+
+/**
+  Notify the system that the SMM variable driver is ready
+**/
+VOID
+VariableNotifySmmReady (
+  VOID
+  )
+{
+}
+
+/**
+  Notify the system that the SMM variable write driver is ready
+**/
+VOID
+VariableNotifySmmWriteReady (
+  VOID
+  )
+{
+}
+
+/**
+  Variable service MM driver entry point
+**/
+EFI_STATUS
+EFIAPI
+VariableServiceInitialize (
+  IN EFI_HANDLE                           ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE                  *MmSystemTable
+  )
+{
+  return MmVariableServiceInitialize ();
+}
+
+/**
+  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
+  This information is used by the MorLock code to infer whether an existing
+  MOR variable is legitimate or not.
+
+  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
+                protocol database
+  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
+                protocol database
+**/
+BOOLEAN
+VariableHaveTcgProtocols (
+  VOID
+  )
+{
+  return FALSE;
+}
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (7 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  6:32   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 10/17] MdePkg: introduce standalone MM entry point library implementation Ard Biesheuvel
                   ` (8 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Add the library interface for the standalone MM driver entry point.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/MdePkg.dec                                     |   3 +
 MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h | 134 ++++++++++++++++++++
 2 files changed, 137 insertions(+)

diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index a7383b6daafb..a4854083105d 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -247,6 +247,9 @@ [LibraryClasses]
   #                Only available to MM_STANDALONE, SMM/DXE Combined and SMM module types.
   MmServicesTableLib|Include/Library/MmServicesTableLib.h
 
+  ##  @libraryclass  Module entry point library for standalone MM drivers.
+  StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
+
 [LibraryClasses.IA32, LibraryClasses.X64]
   ##  @libraryclass  Abstracts both S/W SMI generation and detection.
   ##
diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
new file mode 100644
index 000000000000..d08a73303dbb
--- /dev/null
+++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
@@ -0,0 +1,134 @@
+/** @file
+  Module entry point library for Standalone MM Drivers.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
+
+This program and the accompanying materials are licensed and made available
+under the terms and conditions of the BSD License which accompanies this
+distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __MODULE_ENTRY_POINT_H__
+#define __MODULE_ENTRY_POINT_H__
+
+///
+/// Declare the PI Specification Revision that this driver requires to execute
+/// correctly.
+///
+extern CONST UINT32                   _gMmRevision;
+
+/**
+  The entry point of PE/COFF Image for a Standalone MM Driver.
+
+  This function is the entry point for a Standalone MM Driver.
+  This function must call ProcessLibraryConstructorList() and
+  ProcessModuleEntryPointList().
+  If the return status from ProcessModuleEntryPointList()
+  is an error status, then ProcessLibraryDestructorList() must be called.
+  The return value from ProcessModuleEntryPointList() is returned.
+  If _gDriverUnloadImageCount is greater
+  than zero, then an unload handler must be registered for this image and
+  the unload handler must invoke ProcessModuleUnloadList().
+  If _gMmRevision is not zero and SystemTable->Hdr.Revision is
+  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS               The Standalone MM Driver exited normally.
+  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
+                                     SystemTable->Hdr.Revision.
+  @retval  Other                     Return value from
+                                     ProcessModuleEntryPointList().
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
+  );
+
+
+/**
+  Auto generated function that calls the library constructors for all of the
+  module's dependent libraries.
+
+  This function must be called by _ModuleEntryPoint().
+  This function calls the set of library constructors for the set of library
+  instances that a module depends on.  This includes library instances that a
+  module depends on directly and library instances that a module depends on
+  indirectly through other libraries. This function is auto generated by build
+  tools and those build tools are responsible for collecting the set of library
+  instances, determine which ones have constructors, and calling the library
+  constructors in the proper order based upon each of the library instances own
+  dependencies.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the MM System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
+  );
+
+
+/**
+  Auto generated function that calls the library descructors for all of the
+  module's dependent libraries.
+
+  This function may be called by _ModuleEntryPoint().
+  This function calls the set of library destructors for the set of library
+  instances that a module depends on. This includes library instances that a
+  module depends on directly and library instances that a module depends on
+  indirectly through other libraries.
+  This function is auto generated by build tools and those build tools are
+  responsible for collecting the set of library instances, determine which ones
+  have destructors, and calling the library destructors in the proper order
+  based upon each of the library instances own dependencies.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the MM System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryDestructorList (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
+  );
+
+
+/**
+  Auto generated function that calls a set of module entry points.
+
+  This function must be called by _ModuleEntryPoint().
+  This function calls the set of module entry points.
+  This function is auto generated by build tools and those build tools are
+  responsible for collecting the module entry points and calling them in a
+  specified order.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS   The Standalone MM Driver executed normally.
+  @retval  !EFI_SUCCESS  The Standalone MM Driver failed to execute normally.
+**/
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+  IN EFI_HANDLE             ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
+  );
+
+#endif
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 10/17] MdePkg: introduce standalone MM entry point library implementation
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (8 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 11/17] MdePkg: add MM_STANDALONE implementation of MmServicesTableLib Ard Biesheuvel
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Add an implementation of the StandaloneMmDriverEntryPoint library
class.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/MdePkg.dsc                                                            |  2 +
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf | 43 ++++++++++
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c   | 90 ++++++++++++++++++++
 MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni | 22 +++++
 4 files changed, 157 insertions(+)

diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index 428b14e6a4e0..ec561c53cab0 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -115,6 +115,8 @@ [Components]
   MdePkg/Library/SmmLibNull/SmmLibNull.inf
   MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
 
+  MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+
 [Components.IA32, Components.X64]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
new file mode 100644
index 000000000000..c9309de1c755
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
@@ -0,0 +1,43 @@
+## @file
+# Module entry point library for Standalone MM driver.
+#
+# Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2016-2018, ARM Ltd. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = StandaloneMmDriverEntryPoint
+  MODULE_UNI_FILE                = StandaloneMmDriverEntryPoint.uni
+  FILE_GUID                      = 5ca126c0-b598-4f4b-abb9-b6e7d077aea9
+  MODULE_TYPE                    = MM_STANDALONE
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  LIBRARY_CLASS                  = StandaloneMmDriverEntryPoint|MM_STANDALONE
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64 AARCH64
+#
+
+[Sources]
+  StandaloneMmDriverEntryPoint.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  BaseLib
+  DebugLib
+  MmServicesTableLib
diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
new file mode 100644
index 000000000000..111bb1f18a2a
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
@@ -0,0 +1,90 @@
+/** @file
+  Entry point to a Standalone MM driver.
+
+Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2016 - 2018, ARM Ltd. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
+
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiMm.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MmServicesTableLib.h>
+#include <Library/StandaloneMmDriverEntryPoint.h>
+
+/**
+  The entry point of PE/COFF Image for a Standalone MM Driver.
+
+  This function is the entry point for a Standalone MM Driver.
+  This function must call ProcessLibraryConstructorList() and
+  ProcessModuleEntryPointList().
+  If the return status from ProcessModuleEntryPointList()
+  is an error status, then ProcessLibraryDestructorList() must be called.
+  The return value from ProcessModuleEntryPointList() is returned.
+  If _gDriverUnloadImageCount is greater
+  than zero, then an unload handler must be registered for this image and
+  the unload handler must invoke ProcessModuleUnloadList().
+  If _gMmRevision is not zero and SystemTable->Hdr.Revision is
+  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
+
+  @param  ImageHandle  The image handle of the Standalone MM Driver.
+  @param  SystemTable  A pointer to the EFI System Table.
+
+  @retval  EFI_SUCCESS               The Standalone MM Driver exited normally.
+  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
+                                     SystemTable->Hdr.Revision.
+  @retval  Other                     Return value from
+                                     ProcessModuleEntryPointList().
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+  IN EFI_HANDLE               ImageHandle,
+  IN IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  EFI_STATUS                 Status;
+
+  if (_gMmRevision != 0) {
+    //
+    // Make sure that the MM spec revision of the platform
+    // is >= MM spec revision of the driver
+    //
+    if (MmSystemTable->Hdr.Revision < _gMmRevision) {
+      return EFI_INCOMPATIBLE_VERSION;
+    }
+  }
+
+  //
+  // Call constructor for all libraries
+  //
+  ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
+
+  //
+  // Call the driver entry point
+  //
+  Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
+
+  //
+  // If all of the drivers returned errors, then invoke all of the library destructors
+  //
+  if (EFI_ERROR (Status)) {
+    ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
+  }
+
+  //
+  // Return the cumulative return status code from all of the driver entry points
+  //
+  return Status;
+}
diff --git a/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni
new file mode 100644
index 000000000000..11765d7fb4a6
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.uni
@@ -0,0 +1,22 @@
+// /** @file
+//
+// Module entry point library for standalone MM driver
+//
+// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
+// Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php.
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Module entry point library for standalone MM driver"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Module entry point library for standalone MM driver."
+
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 11/17] MdePkg: add MM_STANDALONE implementation of MmServicesTableLib
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (9 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 10/17] MdePkg: introduce standalone MM entry point library implementation Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-14 13:27 ` [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class Ard Biesheuvel
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

The newly introduced generic MmServicesTableLib can be implemented
for traditional SMM (as we did already), but MM_STANDALONE drivers
require an implementation that is based on standalone MM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdePkg/MdePkg.dsc                                                            |  1 +
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf | 39 +++++++++++++++++++
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c   | 41 ++++++++++++++++++++
 MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni | 20 ++++++++++
 4 files changed, 101 insertions(+)

diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc
index ec561c53cab0..303e1ab3bd0f 100644
--- a/MdePkg/MdePkg.dsc
+++ b/MdePkg/MdePkg.dsc
@@ -116,6 +116,7 @@ [Components]
   MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
 
   MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+  MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
 
 [Components.IA32, Components.X64]
   MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
diff --git a/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
new file mode 100644
index 000000000000..86f6c5c78035
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
@@ -0,0 +1,39 @@
+## @file
+# Standalone MM Services Table Library.
+#
+# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = StandaloneMmServicesTableLib
+  MODULE_UNI_FILE                = StandaloneMmServicesTableLib.uni
+  FILE_GUID                      = eaa4684f-fb4e-41f3-9967-307d5b409182
+  MODULE_TYPE                    = MM_STANDALONE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = MmServicesTableLib|MM_STANDALONE
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  CONSTRUCTOR                    = StandaloneMmServicesTableLibConstructor
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  StandaloneMmServicesTableLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git a/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c
new file mode 100644
index 000000000000..b870f25fcfed
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.c
@@ -0,0 +1,41 @@
+/** @file
+  MM Services Table Library.
+
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiMm.h>
+#include <Library/MmServicesTableLib.h>
+#include <Library/DebugLib.h>
+
+EFI_MM_SYSTEM_TABLE   *gMmst             = NULL;
+
+/**
+  The constructor function caches the pointer of the MM Services Table.
+
+  @param  ImageHandle   The firmware allocated handle for the EFI image.
+  @param  SystemTable   A pointer to the EFI System Table.
+
+  @retval EFI_SUCCESS   The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+StandaloneMmServicesTableLibConstructor (
+  IN EFI_HANDLE           ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE  *MmSystemTable
+  )
+{
+  gMmst = MmSystemTable;
+  ASSERT (gMmst != NULL);
+  return EFI_SUCCESS;
+}
diff --git a/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni
new file mode 100644
index 000000000000..2cabf1af1483
--- /dev/null
+++ b/MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.uni
@@ -0,0 +1,20 @@
+// /** @file
+//
+// Standalone MM Services Table Library.
+//
+// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php.
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Standalone MM Services Table Library"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Standalone MM Services Table Library."
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (10 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 11/17] MdePkg: add MM_STANDALONE implementation of MmServicesTableLib Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:10   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib " Ard Biesheuvel
                   ` (5 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

In order to permit MM_STANDALONE modules to be built without relying
on StandaloneMmPkg, provide a BASE type NULL implementation of HobLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf |  38 ++
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c   | 542 ++++++++++++++++++++
 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni |  20 +
 3 files changed, 600 insertions(+)

diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
new file mode 100644
index 000000000000..c0e927ff14be
--- /dev/null
+++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+# Null instance of HOB Library.
+#
+# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = BaseHobLibNull
+  MODULE_UNI_FILE                = BaseHobLibNull.uni
+  FILE_GUID                      = a89dea6f-c9a0-40be-903c-7cac2ef8a0e7
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = HobLib
+
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  BaseHobLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
new file mode 100644
index 000000000000..0ea7d9304e9d
--- /dev/null
+++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
@@ -0,0 +1,542 @@
+/** @file
+  Provide Hob Library functions for build testing only.
+
+Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Pi/PiMultiPhase.h>
+
+#include <Library/DebugLib.h>
+#include <Library/HobLib.h>
+
+/**
+  Returns the pointer to the HOB list.
+
+  This function returns the pointer to first HOB in the list.
+  For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
+  to the HOB list.  For the DXE phase, the HOB list pointer can be retrieved through
+  the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
+  Since the System Configuration Table does not exist that the time the DXE Core is
+  launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
+  to manage the pointer to the HOB list.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+
+  @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+  VOID
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the next instance of a HOB type from the starting HOB.
+
+  This function searches the first instance of a HOB type from the starting HOB pointer.
+  If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+
+  If HobStart is NULL, then ASSERT().
+
+  @param  Type          The HOB type to return.
+  @param  HobStart      The starting HOB pointer to search from.
+
+  @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+  IN UINT16                 Type,
+  IN CONST VOID             *HobStart
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the first instance of a HOB type among the whole HOB list.
+
+  This function searches the first instance of a HOB type among the whole HOB list.
+  If there does not exist such HOB type in the HOB list, it will return NULL.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+
+  @param  Type          The HOB type to return.
+
+  @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetFirstHob (
+  IN UINT16                 Type
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the next instance of the matched GUID HOB from the starting HOB.
+
+  This function searches the first instance of a HOB from the starting HOB pointer.
+  Such HOB should satisfy two conditions:
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+  to extract the data section and its size information, respectively.
+  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+  unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+
+  If Guid is NULL, then ASSERT().
+  If HobStart is NULL, then ASSERT().
+
+  @param  Guid          The GUID to match with in the HOB list.
+  @param  HobStart      A pointer to a Guid.
+
+  @return The next instance of the matched GUID HOB from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextGuidHob (
+  IN CONST EFI_GUID         *Guid,
+  IN CONST VOID             *HobStart
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Returns the first instance of the matched GUID HOB among the whole HOB list.
+
+  This function searches the first instance of a HOB among the whole HOB list.
+  Such HOB should satisfy two conditions:
+  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+  If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+  to extract the data section and its size information, respectively.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+  If Guid is NULL, then ASSERT().
+
+  @param  Guid          The GUID to match with in the HOB list.
+
+  @return The first instance of the matched GUID HOB among the whole HOB list.
+
+**/
+VOID *
+EFIAPI
+GetFirstGuidHob (
+  IN CONST EFI_GUID         *Guid
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Get the system boot mode from the HOB list.
+
+  This function returns the system boot mode information from the
+  PHIT HOB in HOB list.
+
+  If the pointer to the HOB list is NULL, then ASSERT().
+
+  @param  VOID.
+
+  @return The Boot Mode.
+
+**/
+EFI_BOOT_MODE
+EFIAPI
+GetBootModeHob (
+  VOID
+  )
+{
+  ASSERT (FALSE);
+  return MAX_UINT32;
+}
+
+/**
+  Builds a HOB for a loaded PE32 module.
+
+  This function builds a HOB for a loaded PE32 module.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If ModuleName is NULL, then ASSERT().
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  ModuleName              The GUID File Name of the module.
+  @param  MemoryAllocationModule  The 64 bit physical address of the module.
+  @param  ModuleLength            The length of the module in bytes.
+  @param  EntryPoint              The 64 bit physical address of the module entry point.
+
+**/
+VOID
+EFIAPI
+BuildModuleHob (
+  IN CONST EFI_GUID         *ModuleName,
+  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,
+  IN UINT64                 ModuleLength,
+  IN EFI_PHYSICAL_ADDRESS   EntryPoint
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB that describes a chunk of system memory with Owner GUID.
+
+  This function builds a HOB that describes a chunk of system memory.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  ResourceType        The type of resource described by this HOB.
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
+  @param  OwnerGUID           GUID for the owner of this resource.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorWithOwnerHob (
+  IN EFI_RESOURCE_TYPE            ResourceType,
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
+  IN UINT64                       NumberOfBytes,
+  IN EFI_GUID                     *OwnerGUID
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB that describes a chunk of system memory.
+
+  This function builds a HOB that describes a chunk of system memory.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  ResourceType        The type of resource described by this HOB.
+  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
+  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
+  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorHob (
+  IN EFI_RESOURCE_TYPE            ResourceType,
+  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
+  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
+  IN UINT64                       NumberOfBytes
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a customized HOB tagged with a GUID for identification and returns
+  the start address of GUID HOB data.
+
+  This function builds a customized HOB tagged with a GUID for identification
+  and returns the start address of GUID HOB data so that caller can fill the customized data.
+  The HOB Header and Name field is already stripped.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If Guid is NULL, then ASSERT().
+  If there is no additional space for HOB creation, then ASSERT().
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+
+  @param  Guid          The GUID to tag the customized HOB.
+  @param  DataLength    The size of the data payload for the GUID HOB.
+
+  @retval  NULL         The GUID HOB could not be allocated.
+  @retval  others       The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidHob (
+  IN CONST EFI_GUID              *Guid,
+  IN UINTN                       DataLength
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
+  data field, and returns the start address of the GUID HOB data.
+
+  This function builds a customized HOB tagged with a GUID for identification and copies the input
+  data to the HOB data field and returns the start address of the GUID HOB data.  It can only be
+  invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+  The HOB Header and Name field is already stripped.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If Guid is NULL, then ASSERT().
+  If Data is NULL and DataLength > 0, then ASSERT().
+  If there is no additional space for HOB creation, then ASSERT().
+  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
+
+  @param  Guid          The GUID to tag the customized HOB.
+  @param  Data          The data to be copied into the data field of the GUID HOB.
+  @param  DataLength    The size of the data payload for the GUID HOB.
+
+  @retval  NULL         The GUID HOB could not be allocated.
+  @retval  others       The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidDataHob (
+  IN CONST EFI_GUID              *Guid,
+  IN VOID                        *Data,
+  IN UINTN                       DataLength
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Builds a Firmware Volume HOB.
+
+  This function builds a Firmware Volume HOB.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+  If the FvImage buffer is not at its required alignment, then ASSERT().
+
+  @param  BaseAddress   The base address of the Firmware Volume.
+  @param  Length        The size of the Firmware Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildFvHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a EFI_HOB_TYPE_FV2 HOB.
+
+  This function builds a EFI_HOB_TYPE_FV2 HOB.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+  If the FvImage buffer is not at its required alignment, then ASSERT().
+
+  @param  BaseAddress   The base address of the Firmware Volume.
+  @param  Length        The size of the Firmware Volume in bytes.
+  @param  FvName        The name of the Firmware Volume.
+  @param  FileName      The name of the file.
+
+**/
+VOID
+EFIAPI
+BuildFv2Hob (
+  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN          UINT64                      Length,
+  IN CONST    EFI_GUID                    *FvName,
+  IN CONST    EFI_GUID                    *FileName
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a EFI_HOB_TYPE_FV3 HOB.
+
+  This function builds a EFI_HOB_TYPE_FV3 HOB.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+  If the FvImage buffer is not at its required alignment, then ASSERT().
+
+  @param BaseAddress            The base address of the Firmware Volume.
+  @param Length                 The size of the Firmware Volume in bytes.
+  @param AuthenticationStatus   The authentication status.
+  @param ExtractedFv            TRUE if the FV was extracted as a file within
+                                another firmware volume. FALSE otherwise.
+  @param FvName                 The name of the Firmware Volume.
+                                Valid only if IsExtractedFv is TRUE.
+  @param FileName               The name of the file.
+                                Valid only if IsExtractedFv is TRUE.
+
+**/
+VOID
+EFIAPI
+BuildFv3Hob (
+  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN          UINT64                      Length,
+  IN          UINT32                      AuthenticationStatus,
+  IN          BOOLEAN                     ExtractedFv,
+  IN CONST    EFI_GUID                    *FvName, OPTIONAL
+  IN CONST    EFI_GUID                    *FileName OPTIONAL
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a Capsule Volume HOB.
+
+  This function builds a Capsule Volume HOB.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If the platform does not support Capsule Volume HOBs, then ASSERT().
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The base address of the Capsule Volume.
+  @param  Length        The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB for the CPU.
+
+  This function builds a HOB for the CPU.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.
+  @param  SizeOfIoSpace       The maximum physical I/O addressability of the processor.
+
+**/
+VOID
+EFIAPI
+BuildCpuHob (
+  IN UINT8                       SizeOfMemorySpace,
+  IN UINT8                       SizeOfIoSpace
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB for the Stack.
+
+  This function builds a HOB for the stack.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The 64 bit physical address of the Stack.
+  @param  Length        The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB for the BSP store.
+
+  This function builds a HOB for BSP store.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The 64 bit physical address of the BSP.
+  @param  Length        The length of the BSP store in bytes.
+  @param  MemoryType    The type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length,
+  IN EFI_MEMORY_TYPE             MemoryType
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Builds a HOB for the memory allocation.
+
+  This function builds a HOB for the memory allocation.
+  It can only be invoked during PEI phase;
+  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+
+  If there is no additional space for HOB creation, then ASSERT().
+
+  @param  BaseAddress   The 64 bit physical address of the memory.
+  @param  Length        The length of the memory allocation in bytes.
+  @param  MemoryType    The type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildMemoryAllocationHob (
+  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
+  IN UINT64                      Length,
+  IN EFI_MEMORY_TYPE             MemoryType
+  )
+{
+  ASSERT (FALSE);
+}
diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
new file mode 100644
index 000000000000..4a999e381aa0
--- /dev/null
+++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
@@ -0,0 +1,20 @@
+// /** @file
+// Null instance of HOB Library.
+//
+// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php.
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Null instance of HOB Library"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "HOB Library implementation for build testing only."
+
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib library class
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (11 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:09   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section Ard Biesheuvel
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

In order to permit MM_STANDALONE modules to be built without relying
on StandaloneMmPkg, provide a BASE type NULL implementation of
MemoryAllocationLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf |  38 ++
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c   | 575 ++++++++++++++++++++
 MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni |  20 +
 3 files changed, 633 insertions(+)

diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
new file mode 100644
index 000000000000..c231cd0e271b
--- /dev/null
+++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
@@ -0,0 +1,38 @@
+## @file
+# Null instance of Memory Allocation Library.
+#
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php.
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = BaseMemoryAllocationLibNull
+  MODULE_UNI_FILE                = BaseMemoryAllocationLibNull.uni
+  FILE_GUID                      = fd56f5d6-f194-448f-be69-c0cbb0c281af
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = MemoryAllocationLib
+
+
+#
+#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
+#
+
+[Sources]
+  BaseMemoryAllocationLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
new file mode 100644
index 000000000000..16812d3f9bb3
--- /dev/null
+++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
@@ -0,0 +1,575 @@
+/** @file
+  DUmmy support routines for memory allocation
+
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+
+#include <Uefi/UefiBaseType.h>
+
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+
+/**
+  Allocates one or more 4KB pages of type EfiBootServicesData.
+
+  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
+  returned.
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocatePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
+  returned.
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
+  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
+  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
+  returned.
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPages (
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Frees one or more 4KB pages that were previously allocated with one of the page allocation
+  functions in the Memory Allocation Library.
+
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
+  must have been allocated on a previous call to the page allocation services of the Memory
+  Allocation Library.  If it is not possible to free allocated pages, then this function will
+  perform no actions.
+
+  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
+  then ASSERT().
+  If Pages is zero, then ASSERT().
+
+  @param  Buffer                The pointer to the buffer of pages to free.
+  @param  Pages                 The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreePages (
+  IN VOID   *Buffer,
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
+
+  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
+  request, then NULL is returned.
+
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+  @param  Alignment             The requested alignment of the allocation.
+                                Must be a power of two.
+                                If Alignment is zero, then byte alignment is used.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPages (
+  IN UINTN  Pages,
+  IN UINTN  Alignment
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
+
+  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
+  request, then NULL is returned.
+
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+  @param  Alignment             The requested alignment of the allocation.
+                                Must be a power of two.
+                                If Alignment is zero, then byte alignment is used.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePages (
+  IN UINTN  Pages,
+  IN UINTN  Alignment
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
+
+  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
+  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
+  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
+  request, then NULL is returned.
+
+  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
+
+  @param  Pages                 The number of 4 KB pages to allocate.
+  @param  Alignment             The requested alignment of the allocation.
+                                Must be a power of two.
+                                If Alignment is zero, then byte alignment is used.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPages (
+  IN UINTN  Pages,
+  IN UINTN  Alignment
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Frees one or more 4KB pages that were previously allocated with one of the aligned page
+  allocation functions in the Memory Allocation Library.
+
+  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
+  must have been allocated on a previous call to the aligned page allocation services of the Memory
+  Allocation Library.  If it is not possible to free allocated pages, then this function will
+  perform no actions.
+
+  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
+  Library, then ASSERT().
+  If Pages is zero, then ASSERT().
+
+  @param  Buffer                The pointer to the buffer of pages to free.
+  @param  Pages                 The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPages (
+  IN VOID   *Buffer,
+  IN UINTN  Pages
+  )
+{
+  ASSERT (FALSE);
+}
+
+/**
+  Allocates a buffer of type EfiBootServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
+  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocatePool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates a buffer of type EfiRuntimeServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates a buffer of type EfiReservedMemoryType.
+
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
+  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
+  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates and zeros a buffer of type EfiBootServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
+  request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateZeroPool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates and zeros a buffer of type EfiRuntimeServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
+  request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeZeroPool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Allocates and zeros a buffer of type EfiReservedMemoryType.
+
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
+  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
+  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
+  request, then NULL is returned.
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedZeroPool (
+  IN UINTN  AllocationSize
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Copies a buffer to an allocated buffer of type EfiBootServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
+  is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  If Buffer is NULL, then ASSERT().
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+  @param  Buffer                The buffer to copy to the allocated buffer.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateCopyPool (
+  IN UINTN       AllocationSize,
+  IN CONST VOID  *Buffer
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
+
+  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
+  is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  If Buffer is NULL, then ASSERT().
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+  @param  Buffer                The buffer to copy to the allocated buffer.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeCopyPool (
+  IN UINTN       AllocationSize,
+  IN CONST VOID  *Buffer
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
+
+  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
+  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
+  is not enough memory remaining to satisfy the request, then NULL is returned.
+
+  If Buffer is NULL, then ASSERT().
+  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+
+  @param  AllocationSize        The number of bytes to allocate and zero.
+  @param  Buffer                The buffer to copy to the allocated buffer.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedCopyPool (
+  IN UINTN       AllocationSize,
+  IN CONST VOID  *Buffer
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Reallocates a buffer of type EfiBootServicesData.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
+  enough memory remaining to satisfy the request, then NULL is returned.
+
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSize        The size, in bytes, of OldBuffer.
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
+                         parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocatePool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Reallocates a buffer of type EfiRuntimeServicesData.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
+  enough memory remaining to satisfy the request, then NULL is returned.
+
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSize        The size, in bytes, of OldBuffer.
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
+                         parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocateRuntimePool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Reallocates a buffer of type EfiReservedMemoryType.
+
+  Allocates and zeros the number bytes specified by NewSize from memory of type
+  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and
+  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
+  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
+  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
+  enough memory remaining to satisfy the request, then NULL is returned.
+
+  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
+  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
+
+  @param  OldSize        The size, in bytes, of OldBuffer.
+  @param  NewSize        The size, in bytes, of the buffer to reallocate.
+  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an
+                         optional parameter that may be NULL.
+
+  @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+ReallocateReservedPool (
+  IN UINTN  OldSize,
+  IN UINTN  NewSize,
+  IN VOID   *OldBuffer  OPTIONAL
+  )
+{
+  ASSERT (FALSE);
+  return NULL;
+}
+
+/**
+  Frees a buffer that was previously allocated with one of the pool allocation functions in the
+  Memory Allocation Library.
+
+  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
+  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool
+  resources, then this function will perform no actions.
+
+  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+  then ASSERT().
+
+  @param  Buffer                The pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreePool (
+  IN VOID   *Buffer
+  )
+{
+  ASSERT (FALSE);
+}
diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
new file mode 100644
index 000000000000..9acf17bc2038
--- /dev/null
+++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
@@ -0,0 +1,20 @@
+// /** @file
+// Null instance of Memory Allocation Library
+//
+// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php.
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Null instance of Memory Allocation Library"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "Memory Allocation Library for build testing only."
+
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (12 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib " Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:27   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support Ard Biesheuvel
                   ` (3 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf does not
build for AARCH64 since it does not provide the needed PlDebugSupport.h
header. So move the module to a x86 only section.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/MdeModulePkg.dsc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 967fe082aaae..3e9a9daf1649 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -421,7 +421,6 @@ [Components]
   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
 
 [Components.IA32, Components.X64, Components.AARCH64]
-  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
   MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
@@ -438,6 +437,7 @@ [Components.IA32, Components.X64, Components.Ebc]
   MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
 
 [Components.IA32, Components.X64]
+  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
   MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (13 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:03   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 16/17] MdeModulePkg/VarCheckLib: " Ard Biesheuvel
                   ` (2 subsequent siblings)
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Add MM_STANDALONE to the list of permitted module types of the
AuthVariableLibNull library implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
index 900fef5d4989..93f3e675a2ff 100644
--- a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
+++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
@@ -21,7 +21,7 @@ [Defines]
   FILE_GUID                      = 435CB0E4-7C9A-4BB7-9907-8FD4643E978A
   MODULE_TYPE                    = DXE_RUNTIME_DRIVER
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  LIBRARY_CLASS                  = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE
 
 #
 # The following information is for reference only and not required by the build tools.
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 16/17] MdeModulePkg/VarCheckLib: add MM_STANDALONE support
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (14 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:03   ` Zeng, Star
  2019-01-14 13:27 ` [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules Ard Biesheuvel
  2019-01-15  8:25 ` [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Wang, Jian J
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

Add MM_STANDALONE to the list of permitted module types of the
VarCheckLib library implementation.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
index 099f83dd6aee..b1041c290df9 100644
--- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
+++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
@@ -21,7 +21,7 @@ [Defines]
   FILE_GUID                      = 63E12D08-0C5D-47F8-95E4-09F89D7506C5
   MODULE_TYPE                    = DXE_RUNTIME_DRIVER
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = VarCheckLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
+  LIBRARY_CLASS                  = VarCheckLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE
 
 #
 # The following information is for reference only and not required by the build tools.
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (15 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 16/17] MdeModulePkg/VarCheckLib: " Ard Biesheuvel
@ 2019-01-14 13:27 ` Ard Biesheuvel
  2019-01-16  5:04   ` Zeng, Star
  2019-01-15  8:25 ` [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Wang, Jian J
  17 siblings, 1 reply; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 13:27 UTC (permalink / raw)
  To: edk2-devel
  Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

For build testing coverage, add the newly introduced MM_STANDALONE
versions of the fault tolerant write (FTW) and variable runtime
driver to MdeModulePkg.dsc. Note that the resulting binaries will
not be able to run, since they rely on dummy implementations of
MemoryAllocationLib and HobLib.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 MdeModulePkg/MdeModulePkg.dsc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index 3e9a9daf1649..93eaf4b404a1 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -168,6 +168,12 @@ [LibraryClasses.common.UEFI_APPLICATION]
   MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
   DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
 
+[LibraryClasses.common.MM_STANDALONE]
+  HobLib|MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
+  MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
+  StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
+  MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
+
 [LibraryClasses.ARM, LibraryClasses.AARCH64]
   ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
   ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -420,6 +426,9 @@ [Components]
   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
   MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
 
+  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
+  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
+
 [Components.IA32, Components.X64, Components.AARCH64]
   MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
   MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 02/17] OvmfPkg: add MmServicesTableLib resolution
  2019-01-14 13:27 ` [PATCH v2 02/17] OvmfPkg: " Ard Biesheuvel
@ 2019-01-14 16:40   ` Laszlo Ersek
  2019-01-14 17:05     ` Ard Biesheuvel
  0 siblings, 1 reply; 41+ messages in thread
From: Laszlo Ersek @ 2019-01-14 16:40 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Leif Lindholm, Michael D Kinney, Liming Gao, Jian J Wang, Hao Wu,
	Jagadeesh Ujja, Achin Gupta, Thomas Panakamattam Abraham,
	Sami Mujawar, Star Zeng

On 01/14/19 14:27, Ard Biesheuvel wrote:
> The SMM based FTW and variable drivers are going to depend on
> MmServicesTableLib after a subsequent patch, so add a resolution
> for it to various OvmfPkg .dsc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  OvmfPkg/OvmfPkgIa32.dsc    | 1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
>  OvmfPkg/OvmfPkgX64.dsc     | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> index 3f3533e5c163..aee19b75d7ae 100644
> --- a/OvmfPkg/OvmfPkgIa32.dsc
> +++ b/OvmfPkg/OvmfPkgIa32.dsc
> @@ -385,6 +385,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> index 6c08b2728d63..90cbd8e34158 100644
> --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> index 4072c839d73f..83d16eb00b82 100644
> --- a/OvmfPkg/OvmfPkgX64.dsc
> +++ b/OvmfPkg/OvmfPkgX64.dsc
> @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
>    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>  !ifdef $(DEBUG_ON_SERIAL_PORT)
>    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Also, because this patch is clearly equivalent (although not textually
identical) to the one I used in
<http://mid.mail-archive.com/0d229de3-623a-1062-1daf-cce5dec14824@redhat.com>,
I believe we should add:

Regression-tested-by: Laszlo Ersek <lersek@redhat.com>

(From the blurb, I sought to familiarize myself with the anatomy of this
v2 series, and after checking my R-t-b on patches v2 05/17 and v2 07/17,
I think v2 02/17 -- i.e., this patch -- is the only one where my review
is required. Please correct me if I'm wrong.)

Thanks!
Laszlo


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 02/17] OvmfPkg: add MmServicesTableLib resolution
  2019-01-14 16:40   ` Laszlo Ersek
@ 2019-01-14 17:05     ` Ard Biesheuvel
  0 siblings, 0 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-14 17:05 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: edk2-devel@lists.01.org, Leif Lindholm, Michael D Kinney,
	Liming Gao, Jian J Wang, Hao Wu, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Star Zeng

On Mon, 14 Jan 2019 at 17:40, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 01/14/19 14:27, Ard Biesheuvel wrote:
> > The SMM based FTW and variable drivers are going to depend on
> > MmServicesTableLib after a subsequent patch, so add a resolution
> > for it to various OvmfPkg .dsc files.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  OvmfPkg/OvmfPkgIa32.dsc    | 1 +
> >  OvmfPkg/OvmfPkgIa32X64.dsc | 1 +
> >  OvmfPkg/OvmfPkgX64.dsc     | 1 +
> >  3 files changed, 3 insertions(+)
> >
> > diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
> > index 3f3533e5c163..aee19b75d7ae 100644
> > --- a/OvmfPkg/OvmfPkgIa32.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32.dsc
> > @@ -385,6 +385,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> > diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
> > index 6c08b2728d63..90cbd8e34158 100644
> > --- a/OvmfPkg/OvmfPkgIa32X64.dsc
> > +++ b/OvmfPkg/OvmfPkgIa32X64.dsc
> > @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> > diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
> > index 4072c839d73f..83d16eb00b82 100644
> > --- a/OvmfPkg/OvmfPkgX64.dsc
> > +++ b/OvmfPkg/OvmfPkgX64.dsc
> > @@ -390,6 +390,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
> >    ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
> >    HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
> >    SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >  !ifdef $(DEBUG_ON_SERIAL_PORT)
> >    DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
> >
>
> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
>

Thanks.

> Also, because this patch is clearly equivalent (although not textually
> identical) to the one I used in
> <http://mid.mail-archive.com/0d229de3-623a-1062-1daf-cce5dec14824@redhat.com>,
> I believe we should add:
>
> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
>

OK.

> (From the blurb, I sought to familiarize myself with the anatomy of this
> v2 series, and after checking my R-t-b on patches v2 05/17 and v2 07/17,
> I think v2 02/17 -- i.e., this patch -- is the only one where my review
> is required. Please correct me if I'm wrong.)
>

Indeed.


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers
  2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
                   ` (16 preceding siblings ...)
  2019-01-14 13:27 ` [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules Ard Biesheuvel
@ 2019-01-15  8:25 ` Wang, Jian J
  2019-01-16 19:28   ` Ard Biesheuvel
  17 siblings, 1 reply; 41+ messages in thread
From: Wang, Jian J @ 2019-01-15  8:25 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel@lists.01.org
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Gao, Liming,
	Wu, Hao A, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Zeng, Star

Ard,

For patch 1,5,6,7,8,12,13,14,15,16,17

Reviewed-by: Jian J Wang <jian.j.wang@intel.com>


> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Monday, January 14, 2019 9:28 PM
> To: edk2-devel@lists.01.org
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>;
> Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Jagadeesh Ujja <jagadeesh.ujja@arm.com>; Achin Gupta
> <Achin.Gupta@arm.com>; Thomas Panakamattam Abraham
> <thomas.abraham@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>;
> Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH v2 00/17] implement standalone MM versions of the variable
> runtime drivers
> 
> This v2 series is a followup to [0], and updates the SMM implementations of
> the fault tolerant write and variable runtime drivers to provide standalone
> MM versions that share as much of the existing code as possible with the
> traditional SMM implementations.
> 
> The meat is in patches #5 - #8, which were part of v1. I updated them according
> to the received feedback, and added tags that were given on list.
> 
> Patches #1 - #4 add library class resolutions for MmServiceTableLib, which was
> introduced in v1 of the series, and has already been merged (at the request of
> Liming) so that downstream platforms can add the resolution as well.
> 
> The remaining patches #9 - #17 are new, and have been added so that the new
> standalone MM drivers can be added to and built from MdeModulePkg.dsc, but
> for coverage only (the resulting binaries won't actually work)
> - patches #9 and #10 add a definition and implementation of
>   StandaloneMmDriverEntryPoint, which is rather straight-forward and has no
>   dependencies on the standalone MM core, so it is reasonable to add it to
>   MdePkg directly. Note that this version contains the _gMmVersion check that
>   is missing from the one in StandaloneMmPkg
> - patch #11 adds a standalone MM implementation of MmServicesTableLib to
> MdePkg,
>   which -again- does not depend on the standalone MM core at all, so added
> here
>   for simplicity
> - patches #12 and #13 add NULL implementations of MemoryAllocationLib and
> HobLib
>   so that the FTW and variable MM_STANDALONE modules can be built without
>   depending on StandaloneMmPkg
> - patch #14 is an unrelated fix so that MdeModulePkg.dsc can be built for
>   AARCH64
> - patches #15 and #16 add MM_STANDALONE support to a couple of libraries
> that
>   the new modules depend on
> - patch #17 adds the FTW and variable standalone MM drivers to
> MdeModulePkg.dsc
> 
> NOTE: the drivers added in patches #10 and #11 supersede the ones that reside
> in
> or have been proposed for StandaloneMmPkg
> 
> Patches can be found here:
> https://github.com/ardbiesheuvel/edk2/tree/variable-ftw-standalone-mm-
> conversion
> 
> Cc: Laszlo Ersek <lersek@redhat.com>
> Cc: Leif Lindholm <leif.lindholm@linaro.org>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
> Cc: Achin Gupta <Achin.Gupta@arm.com>
> Cc: Thomas Panakamattam Abraham <thomas.abraham@arm.com>
> Cc: Sami Mujawar <Sami.Mujawar@arm.com>
> Cc: Star Zeng <star.zeng@intel.com>
> 
> [0] https://lists.01.org/pipermail/edk2-devel/2019-January/034608.html
> 
> Ard Biesheuvel (17):
>   MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
>   OvmfPkg: add MmServicesTableLib resolution
>   QuarkPlatformPkg: add MmServicesTableLib resolution
>   Vlv2TbltDevicePkg: add MmServicesTableLib resolution
>   MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
>   MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
>   MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
>   MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
>   MdePkg: introduce standalone MM entry point library class
>   MdePkg: introduce standalone MM entry point library implementation
>   MdePkg: add MM_STANDALONE implementation of MmServicesTableLib
>   MdeModulePkg: implement NULL instance of HobLib library class
>   MdeModulePkg: implement NULL instance of MemoryAllocationLib library
> class
>   MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only
> section
>   MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
>   MdeModulePkg/VarCheckLib: add MM_STANDALONE support
>   MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable
> modules
> 
>  MdePkg/MdePkg.dec                                                                                              |   3 +
>  MdeModulePkg/MdeModulePkg.dsc
> |  12 +-
>  MdePkg/MdePkg.dsc                                                                                              |   3 +
>  OvmfPkg/OvmfPkgIa32.dsc                                                                                        |   1
> +
>  OvmfPkg/OvmfPkgIa32X64.dsc                                                                                     |
> 1 +
>  OvmfPkg/OvmfPkgX64.dsc                                                                                         |   1
> +
>  QuarkPlatformPkg/Quark.dsc                                                                                     |   1
> +
>  QuarkPlatformPkg/QuarkMin.dsc                                                                                  |
> 1 +
>  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> |   1 +
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> |   1 +
>  Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> |   1 +
>  MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> |   2 +-
>  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> |  38 ++
> 
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.inf                               |  38 ++
>  MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> |   2 +-
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
> |   5 +-
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf
> => FaultTolerantWriteStandaloneMm.inf} |  43 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> |   5 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf =>
> VariableStandaloneMm.inf}                       |  43 +-
> 
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.inf                                   |  43 ++
> 
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.inf                                   |  39 ++
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
> |  23 +-
> 
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCom
> mon.h                                     |  34 ++
>  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> |  58 ++
>  MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> | 134 +++++
>  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
> | 542 ++++++++++++++++++
> 
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.c                                 | 575 ++++++++++++++++++++
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
> |  31 ++
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
> |  53 +-
> 
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
> eMm.c                                  |  88 +++
> 
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditiona
> lMm.c                                 | 106 ++++
>  MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
> |  10 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
> |  18 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> |  59 +-
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
> |  89 +++
>  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
> | 130 +++++
> 
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.c                                     |  90 +++
> 
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.c                                     |  41 ++
>  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
> |  20 +
> 
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.uni                               |  20 +
> 
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.uni                                   |  22 +
> 
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.uni                                   |  20 +
>  42 files changed, 2290 insertions(+), 157 deletions(-)
>  create mode 100644
> MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
>  create mode 100644
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.inf
>  copy
> MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf
> => FaultTolerantWriteStandaloneMm.inf} (68%)
>  copy MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf =>
> VariableStandaloneMm.inf} (82%)
>  create mode 100644
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.inf
>  create mode 100644
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.inf
>  create mode 100644 MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
>  create mode 100644 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
>  create mode 100644
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.c
>  create mode 100644
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
> eMm.c
>  create mode 100644
> MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditiona
> lMm.c
>  create mode 100644
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
>  create mode 100644
> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
>  create mode 100644
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.c
>  create mode 100644
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.c
>  create mode 100644
> MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
>  create mode 100644
> MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> ibNull.uni
>  create mode 100644
> MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> t.uni
>  create mode 100644
> MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> b.uni
> 
> --
> 2.20.1



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
  2019-01-14 13:27 ` [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses Ard Biesheuvel
@ 2019-01-16  3:29   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  3:29 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

Some minor comments.

With them handled, Reviewed-by: Star Zeng <star.zeng@intel.com>

Thanks,
Star

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> In preparation of providing a standalone MM based FTW driver, move
> the existing SMM driver to the new MM services table, and factor out
> some pieces that are specific to the traditional driver, mainly
> related to the use of UEFI boot services, which are not accessible
> to standalone MM drivers.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
> ---
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf         |   5 +-
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h              |  23 ++++-
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCommon.h     |  34 +++++++
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c           |  31 ++++++
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c           |  53 ++++------
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c | 106 ++++++++++++++++++++
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c              |  10 +-
>   7 files changed, 219 insertions(+), 43 deletions(-)
> 

[Trimmed]

>   
> +/**
> +  Entry point of the module
> +**/

The block should be matched with the MmFaultTolerantWriteInitialize 
implementation in FaultTolerantWriteSmm.c. But not 
SmmFaultTolerantWriteInitialize implementation in 
FaultTolerantWriteTraditionalMm.c

> +EFI_STATUS
> +MmFaultTolerantWriteInitialize (
> +  VOID
> +  );
> +
> +/**
> +  This function checks if the buffer is valid per processor architecture and
> +  does not overlap with SMRAM.
> +
> +  @param Buffer The buffer start address to be checked.
> +  @param Length The buffer length to be checked.
> +
> +  @retval TRUE  This buffer is valid per processor architecture and does not
> +                overlap with SMRAM.
> +  @retval FALSE This buffer is not valid per processor architecture or overlaps
> +                with SMRAM.
> +**/
> +BOOLEAN
> +FtwSmmIsBufferOutsideSmmValid (
> +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> +  IN UINT64                Length
> +  );
> +
> +/**
> +  Notify the system that the SMM FTW driver is ready
> +**/
> +VOID
> +FtwNotifySmmReady (
> +  VOID
> +  );
> +
>   #endif
> diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
> index 094e40f9d86c..24e507104bbe 100644
> --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
> +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
> @@ -51,6 +51,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

[Trimmed]

>   
>   **/
>   EFI_STATUS
> -EFIAPI
> -SmmFaultTolerantWriteInitialize (
> -  IN EFI_HANDLE                           ImageHandle,
> -  IN EFI_SYSTEM_TABLE                     *SystemTable

The comments block should be also removed for these two parameters.

> +MmFaultTolerantWriteInitialize (
> +  VOID
>     )
>   {
>     EFI_STATUS                              Status;
> -  VOID                                    *SmmEndOfDxeRegistration;
> +  VOID                                    *MmEndOfDxeRegistration;
>   
>     //
>     // Allocate private data structure for SMM FTW protocol and do some initialization
> @@ -634,17 +623,17 @@ SmmFaultTolerantWriteInitialize (
>     //
>     // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
>     //
> -  Status = gSmst->SmmRegisterProtocolNotify (
> -                    &gEfiSmmEndOfDxeProtocolGuid,
> -                    SmmEndOfDxeCallback,
> -                    &SmmEndOfDxeRegistration
> +  Status = gMmst->MmRegisterProtocolNotify (
> +                    &gEfiMmEndOfDxeProtocolGuid,
> +                    MmEndOfDxeCallback,
> +                    &MmEndOfDxeRegistration
>                       );
>     ASSERT_EFI_ERROR (Status);
>   
>     //
>     // Register FvbNotificationEvent () notify function.
>     //
> -  Status = gSmst->SmmRegisterProtocolNotify (
> +  Status = gMmst->MmRegisterProtocolNotify (
>                       &gEfiSmmFirmwareVolumeBlockProtocolGuid,
>                       FvbNotificationEvent,
>                       &mFvbRegistration
> diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
> new file mode 100644
> index 000000000000..78351199d3f1
> --- /dev/null
> +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditionalMm.c
> @@ -0,0 +1,106 @@

[Trimmed]

> +
> +/**
> +  Entry point of the module

The comments block should have description for the two parameters.


Thanks,
Star

> +**/
> +EFI_STATUS
> +EFIAPI
> +SmmFaultTolerantWriteInitialize (
> +  IN EFI_HANDLE            ImageHandle,
> +  IN EFI_SYSTEM_TABLE      *SystemTable
> +  )
> +{
> +  return MmFaultTolerantWriteInitialize ();
> +}
> diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
> index 50d3421b88bb..d09e9719cf05 100644
> --- a/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
> +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
> @@ -29,8 +29,6 @@ InitializeLocalWorkSpaceHeader (
>     VOID
>     )
>   {
> -  EFI_STATUS                              Status;
> -
>     //
>     // Check signature with gEdkiiWorkingBlockSignatureGuid.
>     //
> @@ -64,12 +62,8 @@ InitializeLocalWorkSpaceHeader (
>     //
>     // Calculate the Crc of woking block header
>     //
> -  Status = gBS->CalculateCrc32 (
> -                  &mWorkingBlockHeader,
> -                  sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER),
> -                  &mWorkingBlockHeader.Crc
> -                  );
> -  ASSERT_EFI_ERROR (Status);
> +  mWorkingBlockHeader.Crc = FtwCalculateCrc32 (&mWorkingBlockHeader,
> +                              sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER));
>   
>     mWorkingBlockHeader.WorkingBlockValid    = FTW_VALID_STATE;
>     mWorkingBlockHeader.WorkingBlockInvalid  = FTW_INVALID_STATE;
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
  2019-01-14 13:27 ` [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version Ard Biesheuvel
@ 2019-01-16  3:32   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  3:32 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

One minor comment.

With it handled, Reviewed-by: Star Zeng <star.zeng@intel.com>

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> Implement a new version of the fault tolerant write driver that can
> be used in the context of a standalone MM implementation.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> ---
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf | 90 ++++++++++++++++++++
>   MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c   | 88 +++++++++++++++++++
>   2 files changed, 178 insertions(+)
> 

[Trimmed]

> diff --git a/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
> new file mode 100644
> index 000000000000..95effd6d75fa
> --- /dev/null
> +++ b/MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.c
> @@ -0,0 +1,88 @@
> +/** @file
> +
> +  Parts of the SMM/MM implementation that are specific to standalone MM
> +
> +Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD License
> +which accompanies this distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Library/SmmMemLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include "FaultTolerantWrite.h"
> +#include "FaultTolerantWriteSmmCommon.h"
> +
> +/**
> +  This function checks if the buffer is valid per processor architecture and
> +  does not overlap with SMRAM.
> +
> +  @param Buffer The buffer start address to be checked.
> +  @param Length The buffer length to be checked.
> +
> +  @retval TRUE  This buffer is valid per processor architecture and does not
> +                overlap with SMRAM.
> +  @retval FALSE This buffer is not valid per processor architecture or overlaps
> +                with SMRAM.
> +**/
> +BOOLEAN
> +FtwSmmIsBufferOutsideSmmValid (
> +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> +  IN UINT64                Length
> +  )
> +{
> +  return TRUE;
> +}
> +
> +/**
> +  Internal implementation of CRC32. Depending on the execution context
> +  (standalone SMM or DXE vs standalone MM), this function is implemented
> +  via a call to the CalculateCrc32 () boot service, or via a library
> +  call.
> +
> +  If Buffer is NULL, then ASSERT().
> +  If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param[in]  Buffer       A pointer to the buffer on which the 32-bit CRC is to be computed.
> +  @param[in]  Length       The number of bytes in the buffer Data.
> +
> +  @retval Crc32            The 32-bit CRC was computed for the data buffer.
> +
> +**/
> +UINT32
> +FtwCalculateCrc32 (
> +  IN  VOID                         *Buffer,
> +  IN  UINTN                        Length
> +  )
> +{
> +  return CalculateCrc32 (Buffer, Length);
> +}
> +
> +/**
> +  Notify the system that the SMM FTW driver is ready
> +**/
> +VOID
> +FtwNotifySmmReady (
> +  VOID
> +  )
> +{
> +}
> +
> +/**
> +  Entry point of the module

The comments block should have description for the two parameters.


Thanks,
Star

> +**/
> +EFI_STATUS
> +EFIAPI
> +StandaloneMmFaultTolerantWriteInitialize (
> +  IN EFI_HANDLE            ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
> +  )
> +{
> +  return MmFaultTolerantWriteInitialize ();
> +}
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
  2019-01-14 13:27 ` [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses Ard Biesheuvel
@ 2019-01-16  4:57   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  4:57 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

Some minor comments.

With them handled, Reviewed-by: Star Zeng <star.zeng@intel.com>

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> In preparation of providing a standalone MM based variable runtime
> driver, move the existing SMM driver to the new MM services table,
> and factor out some pieces that are specific to the traditional
> driver, mainly related to the use of UEFI boot services, which are
> not accessible to standalone MM drivers.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Regression-tested-by: Laszlo Ersek <lersek@redhat.com>
> ---
>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf         |   5 +-
>   MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h  |  58 +++++++++
>   MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c         |  18 +--
>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c           |  59 +++------
>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c | 130 ++++++++++++++++++++
>   5 files changed, 211 insertions(+), 59 deletions(-)
> 

[Trimmed]

> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> index 7af22a4ad671..eb84589fc404 100644
> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> @@ -97,4 +97,62 @@ VariableSpeculationBarrier (
>     VOID
>     );
>   
> +/**
> +  Notify the system that the SMM variable driver is ready
> +**/
> +VOID
> +VariableNotifySmmReady (
> +  VOID
> +  );
> +
> +/**
> +  Notify the system that the SMM variable write driver is ready
> +**/
> +VOID
> +VariableNotifySmmWriteReady (
> +  VOID
> +  );
> +
> +/**
> +  Variable service MM driver entry point

The block should be matched with the MmVariableServiceInitialize 
implementation in VariableSmm.c. But not SmmVariableServiceInitialize 
implementation in VariableTraditionalMm.c

> +**/
> +EFI_STATUS
> +EFIAPI
> +MmVariableServiceInitialize (
> +  VOID
> +  );
> +
> +/**
> +  This function checks if the buffer is valid per processor architecture and
> +  does not overlap with SMRAM.
> +
> +  @param Buffer The buffer start address to be checked.
> +  @param Length The buffer length to be checked.
> +
> +  @retval TRUE  This buffer is valid per processor architecture and does not
> +                overlap with SMRAM.
> +  @retval FALSE This buffer is not valid per processor architecture or overlaps
> +                with SMRAM.
> +**/
> +BOOLEAN
> +VariableSmmIsBufferOutsideSmmValid (
> +  IN EFI_PHYSICAL_ADDRESS  Buffer,
> +  IN UINT64                Length
> +  );
> +
> +/**
> +  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
> +  This information is used by the MorLock code to infer whether an existing
> +  MOR variable is legitimate or not.
> +
> +  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
> +                protocol database
> +  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
> +                protocol database
> +**/
> +BOOLEAN
> +VariableHaveTcgProtocols (
> +  VOID
> +  );
> +
>   #endif

[Trimmed]

> @@ -928,18 +920,11 @@ SmmFtwNotificationEvent (
>     runtime services in the EFI System Table and installs arch protocols
>     for variable read and write services being available. It also registers
>     a notification function for an EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.
> -
> -  @param[in] ImageHandle    The firmware allocated handle for the EFI image.
> -  @param[in] SystemTable    A pointer to the EFI System Table.
> -
> -  @retval EFI_SUCCESS       Variable service successfully initialized.

This line needs to be kept.

> -
>   **/
>   EFI_STATUS
>   EFIAPI
> -VariableServiceInitialize (
> -  IN EFI_HANDLE                           ImageHandle,
> -  IN EFI_SYSTEM_TABLE                     *SystemTable
> +MmVariableServiceInitialize (
> +  VOID
>     )
>   {
>     EFI_STATUS                              Status;
> @@ -957,7 +942,7 @@ VariableServiceInitialize (
>     // Install the Smm Variable Protocol on a new handle.
>     //
>     VariableHandle = NULL;
> -  Status = gSmst->SmmInstallProtocolInterface (
> +  Status = gMmst->MmInstallProtocolInterface (
>                       &VariableHandle,
>                       &gEfiSmmVariableProtocolGuid,
>                       EFI_NATIVE_INTERFACE,
> @@ -965,7 +950,7 @@ VariableServiceInitialize (
>                       );
>     ASSERT_EFI_ERROR (Status);
>   
> -  Status = gSmst->SmmInstallProtocolInterface (
> +  Status = gMmst->MmInstallProtocolInterface (
>                       &VariableHandle,
>                       &gEdkiiSmmVarCheckProtocolGuid,
>                       EFI_NATIVE_INTERFACE,
> @@ -976,7 +961,7 @@ VariableServiceInitialize (
>     mVariableBufferPayloadSize = GetMaxVariableSize () +
>                                  OFFSET_OF (SMM_VARIABLE_COMMUNICATE_VAR_CHECK_VARIABLE_PROPERTY, Name) - GetVariableHeaderSize ();
>   
> -  Status = gSmst->SmmAllocatePool (
> +  Status = gMmst->MmAllocatePool (
>                       EfiRuntimeServicesData,
>                       mVariableBufferPayloadSize,
>                       (VOID **)&mVariableBufferPayload
> @@ -987,25 +972,19 @@ VariableServiceInitialize (
>     /// Register SMM variable SMI handler
>     ///
>     VariableHandle = NULL;
> -  Status = gSmst->SmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
> +  Status = gMmst->MmiHandlerRegister (SmmVariableHandler, &gEfiSmmVariableProtocolGuid, &VariableHandle);
>     ASSERT_EFI_ERROR (Status);
>   
>     //
>     // Notify the variable wrapper driver the variable service is ready
>     //
> -  Status = SystemTable->BootServices->InstallProtocolInterface (
> -                                        &mVariableHandle,
> -                                        &gEfiSmmVariableProtocolGuid,
> -                                        EFI_NATIVE_INTERFACE,
> -                                        &gSmmVariable
> -                                        );
> -  ASSERT_EFI_ERROR (Status);
> +  VariableNotifySmmReady ();
>   
>     //
>     // Register EFI_SMM_END_OF_DXE_PROTOCOL_GUID notify function.
>     //
> -  Status = gSmst->SmmRegisterProtocolNotify (
> -                    &gEfiSmmEndOfDxeProtocolGuid,
> +  Status = gMmst->MmRegisterProtocolNotify (
> +                    &gEfiMmEndOfDxeProtocolGuid,
>                       SmmEndOfDxeCallback,
>                       &SmmEndOfDxeRegistration
>                       );
> @@ -1014,7 +993,7 @@ VariableServiceInitialize (
>     //
>     // Register FtwNotificationEvent () notify function.
>     //
> -  Status = gSmst->SmmRegisterProtocolNotify (
> +  Status = gMmst->MmRegisterProtocolNotify (
>                       &gEfiSmmFaultTolerantWriteProtocolGuid,
>                       SmmFtwNotificationEvent,
>                       &SmmFtwRegistration
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
> new file mode 100644
> index 000000000000..d702c8f8db67
> --- /dev/null
> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
> @@ -0,0 +1,130 @@

[Trimmed]

> +
> +/**
> +  Variable service MM driver entry point

The comments block should have description for the two parameters.

Thanks,
Star

> +**/
> +EFI_STATUS
> +EFIAPI
> +VariableServiceInitialize (
> +  IN EFI_HANDLE                           ImageHandle,
> +  IN EFI_SYSTEM_TABLE                     *SystemTable
> +  )
> +{
> +  return MmVariableServiceInitialize ();
> +}
> +
> +/**
> +  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
> +  This information is used by the MorLock code to infer whether an existing
> +  MOR variable is legitimate or not.
> +
> +  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
> +                protocol database
> +  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
> +                protocol database
> +**/
> +BOOLEAN
> +VariableHaveTcgProtocols (
> +  VOID
> +  )
> +{
> +  EFI_STATUS            Status;
> +  VOID                  *Interface;
> +
> +  Status = gBS->LocateProtocol (
> +                  &gEfiTcg2ProtocolGuid,
> +                  NULL,                     // Registration
> +                  &Interface
> +                  );
> +  if (!EFI_ERROR (Status)) {
> +    return TRUE;
> +  }
> +
> +  Status = gBS->LocateProtocol (
> +                  &gEfiTcgProtocolGuid,
> +                  NULL,                     // Registration
> +                  &Interface
> +                  );
> +  return !EFI_ERROR (Status);
> +}
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
  2019-01-14 13:27 ` [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version Ard Biesheuvel
@ 2019-01-16  5:00   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:00 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

One minor comment.

With it handled, Reviewed-by: Star Zeng <star.zeng@intel.com>

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> Reuse most of the existing code to implement a variable runtime
> driver that will be able to execute in the context of standalone
> MM.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> Reviewed-by: Star Zeng <star.zeng@intel.com>
> ---
>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 136 ++++++++++++++++++++
>   MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c   |  89 +++++++++++++
>   2 files changed, 225 insertions(+)
> 

[Trimmed]

> +
> +/**
> +  Variable service MM driver entry point

The comments block should have description for the two parameters and 
return status (forgot to mention this for other places).


Thanks,
Star

> +**/
> +EFI_STATUS
> +EFIAPI
> +VariableServiceInitialize (
> +  IN EFI_HANDLE                           ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE                  *MmSystemTable
> +  )
> +{
> +  return MmVariableServiceInitialize ();
> +}
> +
> +/**
> +  Whether the TCG or TCG2 protocols are installed in the UEFI protocol database.
> +  This information is used by the MorLock code to infer whether an existing
> +  MOR variable is legitimate or not.
> +
> +  @retval TRUE  Either the TCG or TCG2 protocol is installed in the UEFI
> +                protocol database
> +  @retval FALSE Neither the TCG nor the TCG2 protocol is installed in the UEFI
> +                protocol database
> +**/
> +BOOLEAN
> +VariableHaveTcgProtocols (
> +  VOID
> +  )
> +{
> +  return FALSE;
> +}
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
  2019-01-14 13:27 ` [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution Ard Biesheuvel
@ 2019-01-16  5:02   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:02 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> The SMM based FTW and variable drivers are going to depend on
> MmServicesTableLib after a subsequent patch, so add a resolution
> for it to MdeModulePkg.dsc.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/MdeModulePkg.dsc | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index 5d042be3a862..967fe082aaae 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -152,6 +152,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>     HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>     DebugLib|MdePkg/Library/UefiDebugLibConOut/UefiDebugLibConOut.inf
>     MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>     SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>     LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
>     SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
  2019-01-14 13:27 ` [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support Ard Biesheuvel
@ 2019-01-16  5:03   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:03 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> Add MM_STANDALONE to the list of permitted module types of the
> AuthVariableLibNull library implementation.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> index 900fef5d4989..93f3e675a2ff 100644
> --- a/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> +++ b/MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> @@ -21,7 +21,7 @@ [Defines]
>     FILE_GUID                      = 435CB0E4-7C9A-4BB7-9907-8FD4643E978A
>     MODULE_TYPE                    = DXE_RUNTIME_DRIVER
>     VERSION_STRING                 = 1.0
> -  LIBRARY_CLASS                  = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
> +  LIBRARY_CLASS                  = AuthVariableLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE
>   
>   #
>   # The following information is for reference only and not required by the build tools.
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 16/17] MdeModulePkg/VarCheckLib: add MM_STANDALONE support
  2019-01-14 13:27 ` [PATCH v2 16/17] MdeModulePkg/VarCheckLib: " Ard Biesheuvel
@ 2019-01-16  5:03   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:03 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> Add MM_STANDALONE to the list of permitted module types of the
> VarCheckLib library implementation.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> index 099f83dd6aee..b1041c290df9 100644
> --- a/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> +++ b/MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> @@ -21,7 +21,7 @@ [Defines]
>     FILE_GUID                      = 63E12D08-0C5D-47F8-95E4-09F89D7506C5
>     MODULE_TYPE                    = DXE_RUNTIME_DRIVER
>     VERSION_STRING                 = 1.0
> -  LIBRARY_CLASS                  = VarCheckLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER
> +  LIBRARY_CLASS                  = VarCheckLib|DXE_RUNTIME_DRIVER DXE_SMM_DRIVER MM_STANDALONE
>   
>   #
>   # The following information is for reference only and not required by the build tools.
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules
  2019-01-14 13:27 ` [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules Ard Biesheuvel
@ 2019-01-16  5:04   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:04 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> For build testing coverage, add the newly introduced MM_STANDALONE
> versions of the fault tolerant write (FTW) and variable runtime
> driver to MdeModulePkg.dsc. Note that the resulting binaries will
> not be able to run, since they rely on dummy implementations of
> MemoryAllocationLib and HobLib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/MdeModulePkg.dsc | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index 3e9a9daf1649..93eaf4b404a1 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -168,6 +168,12 @@ [LibraryClasses.common.UEFI_APPLICATION]
>     MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
>     DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
>   
> +[LibraryClasses.common.MM_STANDALONE]
> +  HobLib|MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> +  MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
> +  StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
> +  MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
> +
>   [LibraryClasses.ARM, LibraryClasses.AARCH64]
>     ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
>     ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
> @@ -420,6 +426,9 @@ [Components]
>     MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
>     MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
>   
> +  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandaloneMm.inf
> +  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf
> +
>   [Components.IA32, Components.X64, Components.AARCH64]
>     MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>     MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib library class
  2019-01-14 13:27 ` [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib " Ard Biesheuvel
@ 2019-01-16  5:09   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:09 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> In order to permit MM_STANDALONE modules to be built without relying
> on StandaloneMmPkg, provide a BASE type NULL implementation of
> MemoryAllocationLib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>   MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf |  38 ++
>   MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c   | 575 ++++++++++++++++++++
>   MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni |  20 +
>   3 files changed, 633 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
> new file mode 100644
> index 000000000000..c231cd0e271b
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.inf
> @@ -0,0 +1,38 @@
> +## @file
> +# Null instance of Memory Allocation Library.
> +#
> +# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution. The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php.
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = BaseMemoryAllocationLibNull
> +  MODULE_UNI_FILE                = BaseMemoryAllocationLibNull.uni
> +  FILE_GUID                      = fd56f5d6-f194-448f-be69-c0cbb0c281af
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = MemoryAllocationLib
> +
> +
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
> +#
> +
> +[Sources]
> +  BaseMemoryAllocationLibNull.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
> new file mode 100644
> index 000000000000..16812d3f9bb3
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.c
> @@ -0,0 +1,575 @@
> +/** @file
> +  DUmmy support routines for memory allocation

Should be "Dummy" here?

With it handled, Reviewed-by: Star Zeng <star.zeng@intel.com>.

Thanks,
Star

> +
> +  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +  Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD License
> +  which accompanies this distribution.  The full text of the license may be found at
> +  http://opensource.org/licenses/bsd-license.php.
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +
> +#include <Uefi/UefiBaseType.h>
> +
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
> +
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiBootServicesData.
> +
> +  Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocatePages (
> +  IN UINTN  Pages
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiRuntimeServicesData.
> +
> +  Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimePages (
> +  IN UINTN  Pages
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiReservedMemoryType.
> +
> +  Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
> +  allocated buffer.  The buffer returned is aligned on a 4KB boundary.  If Pages is 0, then NULL
> +  is returned.  If there is not enough memory remaining to satisfy the request, then NULL is
> +  returned.
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateReservedPages (
> +  IN UINTN  Pages
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Frees one or more 4KB pages that were previously allocated with one of the page allocation
> +  functions in the Memory Allocation Library.
> +
> +  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
> +  must have been allocated on a previous call to the page allocation services of the Memory
> +  Allocation Library.  If it is not possible to free allocated pages, then this function will
> +  perform no actions.
> +
> +  If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
> +  then ASSERT().
> +  If Pages is zero, then ASSERT().
> +
> +  @param  Buffer                The pointer to the buffer of pages to free.
> +  @param  Pages                 The number of 4 KB pages to free.
> +
> +**/
> +VOID
> +EFIAPI
> +FreePages (
> +  IN VOID   *Buffer,
> +  IN UINTN  Pages
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
> +
> +  Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
> +  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
> +  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
> +  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +  @param  Alignment             The requested alignment of the allocation.
> +                                Must be a power of two.
> +                                If Alignment is zero, then byte alignment is used.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateAlignedPages (
> +  IN UINTN  Pages,
> +  IN UINTN  Alignment
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
> +
> +  Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
> +  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
> +  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
> +  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +  @param  Alignment             The requested alignment of the allocation.
> +                                Must be a power of two.
> +                                If Alignment is zero, then byte alignment is used.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateAlignedRuntimePages (
> +  IN UINTN  Pages,
> +  IN UINTN  Alignment
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
> +
> +  Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
> +  alignment specified by Alignment.  The allocated buffer is returned.  If Pages is 0, then NULL is
> +  returned.  If there is not enough memory at the specified alignment remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
> +  If Pages plus EFI_SIZE_TO_PAGES (Alignment) overflows, then ASSERT().
> +
> +  @param  Pages                 The number of 4 KB pages to allocate.
> +  @param  Alignment             The requested alignment of the allocation.
> +                                Must be a power of two.
> +                                If Alignment is zero, then byte alignment is used.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateAlignedReservedPages (
> +  IN UINTN  Pages,
> +  IN UINTN  Alignment
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Frees one or more 4KB pages that were previously allocated with one of the aligned page
> +  allocation functions in the Memory Allocation Library.
> +
> +  Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer.  Buffer
> +  must have been allocated on a previous call to the aligned page allocation services of the Memory
> +  Allocation Library.  If it is not possible to free allocated pages, then this function will
> +  perform no actions.
> +
> +  If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
> +  Library, then ASSERT().
> +  If Pages is zero, then ASSERT().
> +
> +  @param  Buffer                The pointer to the buffer of pages to free.
> +  @param  Pages                 The number of 4 KB pages to free.
> +
> +**/
> +VOID
> +EFIAPI
> +FreeAlignedPages (
> +  IN VOID   *Buffer,
> +  IN UINTN  Pages
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Allocates a buffer of type EfiBootServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
> +  pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
> +  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocatePool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates a buffer of type EfiRuntimeServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
> +  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
> +  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimePool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates a buffer of type EfiReservedMemoryType.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType and returns
> +  a pointer to the allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is
> +  returned.  If there is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateReservedPool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates and zeros a buffer of type EfiBootServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
> +  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
> +  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateZeroPool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates and zeros a buffer of type EfiRuntimeServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
> +  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
> +  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimeZeroPool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Allocates and zeros a buffer of type EfiReservedMemoryType.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
> +  buffer with zeros, and returns a pointer to the allocated buffer.  If AllocationSize is 0, then a
> +  valid buffer of 0 size is returned.  If there is not enough memory remaining to satisfy the
> +  request, then NULL is returned.
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateReservedZeroPool (
> +  IN UINTN  AllocationSize
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Copies a buffer to an allocated buffer of type EfiBootServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
> +  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
> +  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
> +  is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If Buffer is NULL, then ASSERT().
> +  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +  @param  Buffer                The buffer to copy to the allocated buffer.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateCopyPool (
> +  IN UINTN       AllocationSize,
> +  IN CONST VOID  *Buffer
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
> +  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
> +  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
> +  is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If Buffer is NULL, then ASSERT().
> +  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +  @param  Buffer                The buffer to copy to the allocated buffer.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateRuntimeCopyPool (
> +  IN UINTN       AllocationSize,
> +  IN CONST VOID  *Buffer
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
> +
> +  Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
> +  AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
> +  allocated buffer.  If AllocationSize is 0, then a valid buffer of 0 size is returned.  If there
> +  is not enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If Buffer is NULL, then ASSERT().
> +  If AllocationSize is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
> +
> +  @param  AllocationSize        The number of bytes to allocate and zero.
> +  @param  Buffer                The buffer to copy to the allocated buffer.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +AllocateReservedCopyPool (
> +  IN UINTN       AllocationSize,
> +  IN CONST VOID  *Buffer
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Reallocates a buffer of type EfiBootServicesData.
> +
> +  Allocates and zeros the number bytes specified by NewSize from memory of type
> +  EfiBootServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
> +  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
> +  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
> +  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
> +  enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
> +  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
> +
> +  @param  OldSize        The size, in bytes, of OldBuffer.
> +  @param  NewSize        The size, in bytes, of the buffer to reallocate.
> +  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
> +                         parameter that may be NULL.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +ReallocatePool (
> +  IN UINTN  OldSize,
> +  IN UINTN  NewSize,
> +  IN VOID   *OldBuffer  OPTIONAL
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Reallocates a buffer of type EfiRuntimeServicesData.
> +
> +  Allocates and zeros the number bytes specified by NewSize from memory of type
> +  EfiRuntimeServicesData.  If OldBuffer is not NULL, then the smaller of OldSize and
> +  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
> +  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
> +  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
> +  enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
> +  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
> +
> +  @param  OldSize        The size, in bytes, of OldBuffer.
> +  @param  NewSize        The size, in bytes, of the buffer to reallocate.
> +  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an optional
> +                         parameter that may be NULL.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +ReallocateRuntimePool (
> +  IN UINTN  OldSize,
> +  IN UINTN  NewSize,
> +  IN VOID   *OldBuffer  OPTIONAL
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Reallocates a buffer of type EfiReservedMemoryType.
> +
> +  Allocates and zeros the number bytes specified by NewSize from memory of type
> +  EfiReservedMemoryType.  If OldBuffer is not NULL, then the smaller of OldSize and
> +  NewSize bytes are copied from OldBuffer to the newly allocated buffer, and
> +  OldBuffer is freed.  A pointer to the newly allocated buffer is returned.
> +  If NewSize is 0, then a valid buffer of 0 size is  returned.  If there is not
> +  enough memory remaining to satisfy the request, then NULL is returned.
> +
> +  If the allocation of the new buffer is successful and the smaller of NewSize and OldSize
> +  is greater than (MAX_ADDRESS - OldBuffer + 1), then ASSERT().
> +
> +  @param  OldSize        The size, in bytes, of OldBuffer.
> +  @param  NewSize        The size, in bytes, of the buffer to reallocate.
> +  @param  OldBuffer      The buffer to copy to the allocated buffer.  This is an
> +                         optional parameter that may be NULL.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +EFIAPI
> +ReallocateReservedPool (
> +  IN UINTN  OldSize,
> +  IN UINTN  NewSize,
> +  IN VOID   *OldBuffer  OPTIONAL
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Frees a buffer that was previously allocated with one of the pool allocation functions in the
> +  Memory Allocation Library.
> +
> +  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
> +  pool allocation services of the Memory Allocation Library.  If it is not possible to free pool
> +  resources, then this function will perform no actions.
> +
> +  If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
> +  then ASSERT().
> +
> +  @param  Buffer                The pointer to the buffer to free.
> +
> +**/
> +VOID
> +EFIAPI
> +FreePool (
> +  IN VOID   *Buffer
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> diff --git a/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
> new file mode 100644
> index 000000000000..9acf17bc2038
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationLibNull.uni
> @@ -0,0 +1,20 @@
> +// /** @file
> +// Null instance of Memory Allocation Library
> +//
> +// Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
> +// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php.
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT             #language en-US "Null instance of Memory Allocation Library"
> +
> +#string STR_MODULE_DESCRIPTION          #language en-US "Memory Allocation Library for build testing only."
> +
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class
  2019-01-14 13:27 ` [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class Ard Biesheuvel
@ 2019-01-16  5:10   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:10 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> In order to permit MM_STANDALONE modules to be built without relying
> on StandaloneMmPkg, provide a BASE type NULL implementation of HobLib.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf |  38 ++
>   MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c   | 542 ++++++++++++++++++++
>   MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni |  20 +
>   3 files changed, 600 insertions(+)
> 
> diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> new file mode 100644
> index 000000000000..c0e927ff14be
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> @@ -0,0 +1,38 @@
> +## @file
> +# Null instance of HOB Library.
> +#
> +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
> +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +#
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the BSD License
> +#  which accompanies this distribution. The full text of the license may be found at
> +#  http://opensource.org/licenses/bsd-license.php.
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x0001001B
> +  BASE_NAME                      = BaseHobLibNull
> +  MODULE_UNI_FILE                = BaseHobLibNull.uni
> +  FILE_GUID                      = a89dea6f-c9a0-40be-903c-7cac2ef8a0e7
> +  MODULE_TYPE                    = BASE
> +  VERSION_STRING                 = 1.0
> +  LIBRARY_CLASS                  = HobLib
> +
> +
> +#
> +#  VALID_ARCHITECTURES           = IA32 X64 ARM AARCH64
> +#
> +
> +[Sources]
> +  BaseHobLibNull.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +
> +[LibraryClasses]
> +  DebugLib
> diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
> new file mode 100644
> index 000000000000..0ea7d9304e9d
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
> @@ -0,0 +1,542 @@
> +/** @file
> +  Provide Hob Library functions for build testing only.
> +
> +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +This program and the accompanying materials
> +are licensed and made available under the terms and conditions of the BSD License
> +which accompanies this distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php.
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#include <Uefi.h>
> +#include <Pi/PiMultiPhase.h>
> +
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +
> +/**
> +  Returns the pointer to the HOB list.
> +
> +  This function returns the pointer to first HOB in the list.
> +  For PEI phase, the PEI service GetHobList() can be used to retrieve the pointer
> +  to the HOB list.  For the DXE phase, the HOB list pointer can be retrieved through
> +  the EFI System Table by looking up theHOB list GUID in the System Configuration Table.
> +  Since the System Configuration Table does not exist that the time the DXE Core is
> +  launched, the DXE Core uses a global variable from the DXE Core Entry Point Library
> +  to manage the pointer to the HOB list.
> +
> +  If the pointer to the HOB list is NULL, then ASSERT().
> +
> +  @return The pointer to the HOB list.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetHobList (
> +  VOID
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Returns the next instance of a HOB type from the starting HOB.
> +
> +  This function searches the first instance of a HOB type from the starting HOB pointer.
> +  If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
> +  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
> +  unconditionally: it returns HobStart back if HobStart itself meets the requirement;
> +  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
> +
> +  If HobStart is NULL, then ASSERT().
> +
> +  @param  Type          The HOB type to return.
> +  @param  HobStart      The starting HOB pointer to search from.
> +
> +  @return The next instance of a HOB type from the starting HOB.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetNextHob (
> +  IN UINT16                 Type,
> +  IN CONST VOID             *HobStart
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Returns the first instance of a HOB type among the whole HOB list.
> +
> +  This function searches the first instance of a HOB type among the whole HOB list.
> +  If there does not exist such HOB type in the HOB list, it will return NULL.
> +
> +  If the pointer to the HOB list is NULL, then ASSERT().
> +
> +  @param  Type          The HOB type to return.
> +
> +  @return The next instance of a HOB type from the starting HOB.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetFirstHob (
> +  IN UINT16                 Type
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Returns the next instance of the matched GUID HOB from the starting HOB.
> +
> +  This function searches the first instance of a HOB from the starting HOB pointer.
> +  Such HOB should satisfy two conditions:
> +  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
> +  If there does not exist such HOB from the starting HOB pointer, it will return NULL.
> +  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
> +  to extract the data section and its size information, respectively.
> +  In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
> +  unconditionally: it returns HobStart back if HobStart itself meets the requirement;
> +  caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
> +
> +  If Guid is NULL, then ASSERT().
> +  If HobStart is NULL, then ASSERT().
> +
> +  @param  Guid          The GUID to match with in the HOB list.
> +  @param  HobStart      A pointer to a Guid.
> +
> +  @return The next instance of the matched GUID HOB from the starting HOB.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetNextGuidHob (
> +  IN CONST EFI_GUID         *Guid,
> +  IN CONST VOID             *HobStart
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Returns the first instance of the matched GUID HOB among the whole HOB list.
> +
> +  This function searches the first instance of a HOB among the whole HOB list.
> +  Such HOB should satisfy two conditions:
> +  its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
> +  If there does not exist such HOB from the starting HOB pointer, it will return NULL.
> +  Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
> +  to extract the data section and its size information, respectively.
> +
> +  If the pointer to the HOB list is NULL, then ASSERT().
> +  If Guid is NULL, then ASSERT().
> +
> +  @param  Guid          The GUID to match with in the HOB list.
> +
> +  @return The first instance of the matched GUID HOB among the whole HOB list.
> +
> +**/
> +VOID *
> +EFIAPI
> +GetFirstGuidHob (
> +  IN CONST EFI_GUID         *Guid
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Get the system boot mode from the HOB list.
> +
> +  This function returns the system boot mode information from the
> +  PHIT HOB in HOB list.
> +
> +  If the pointer to the HOB list is NULL, then ASSERT().
> +
> +  @param  VOID.
> +
> +  @return The Boot Mode.
> +
> +**/
> +EFI_BOOT_MODE
> +EFIAPI
> +GetBootModeHob (
> +  VOID
> +  )
> +{
> +  ASSERT (FALSE);
> +  return MAX_UINT32;
> +}
> +
> +/**
> +  Builds a HOB for a loaded PE32 module.
> +
> +  This function builds a HOB for a loaded PE32 module.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If ModuleName is NULL, then ASSERT().
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  ModuleName              The GUID File Name of the module.
> +  @param  MemoryAllocationModule  The 64 bit physical address of the module.
> +  @param  ModuleLength            The length of the module in bytes.
> +  @param  EntryPoint              The 64 bit physical address of the module entry point.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildModuleHob (
> +  IN CONST EFI_GUID         *ModuleName,
> +  IN EFI_PHYSICAL_ADDRESS   MemoryAllocationModule,
> +  IN UINT64                 ModuleLength,
> +  IN EFI_PHYSICAL_ADDRESS   EntryPoint
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB that describes a chunk of system memory with Owner GUID.
> +
> +  This function builds a HOB that describes a chunk of system memory.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  ResourceType        The type of resource described by this HOB.
> +  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
> +  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
> +  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
> +  @param  OwnerGUID           GUID for the owner of this resource.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildResourceDescriptorWithOwnerHob (
> +  IN EFI_RESOURCE_TYPE            ResourceType,
> +  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
> +  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
> +  IN UINT64                       NumberOfBytes,
> +  IN EFI_GUID                     *OwnerGUID
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB that describes a chunk of system memory.
> +
> +  This function builds a HOB that describes a chunk of system memory.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  ResourceType        The type of resource described by this HOB.
> +  @param  ResourceAttribute   The resource attributes of the memory described by this HOB.
> +  @param  PhysicalStart       The 64 bit physical address of memory described by this HOB.
> +  @param  NumberOfBytes       The length of the memory described by this HOB in bytes.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildResourceDescriptorHob (
> +  IN EFI_RESOURCE_TYPE            ResourceType,
> +  IN EFI_RESOURCE_ATTRIBUTE_TYPE  ResourceAttribute,
> +  IN EFI_PHYSICAL_ADDRESS         PhysicalStart,
> +  IN UINT64                       NumberOfBytes
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a customized HOB tagged with a GUID for identification and returns
> +  the start address of GUID HOB data.
> +
> +  This function builds a customized HOB tagged with a GUID for identification
> +  and returns the start address of GUID HOB data so that caller can fill the customized data.
> +  The HOB Header and Name field is already stripped.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If Guid is NULL, then ASSERT().
> +  If there is no additional space for HOB creation, then ASSERT().
> +  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> +  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
> +
> +  @param  Guid          The GUID to tag the customized HOB.
> +  @param  DataLength    The size of the data payload for the GUID HOB.
> +
> +  @retval  NULL         The GUID HOB could not be allocated.
> +  @retval  others       The start address of GUID HOB data.
> +
> +**/
> +VOID *
> +EFIAPI
> +BuildGuidHob (
> +  IN CONST EFI_GUID              *Guid,
> +  IN UINTN                       DataLength
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Builds a customized HOB tagged with a GUID for identification, copies the input data to the HOB
> +  data field, and returns the start address of the GUID HOB data.
> +
> +  This function builds a customized HOB tagged with a GUID for identification and copies the input
> +  data to the HOB data field and returns the start address of the GUID HOB data.  It can only be
> +  invoked during PEI phase; for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +  The HOB Header and Name field is already stripped.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If Guid is NULL, then ASSERT().
> +  If Data is NULL and DataLength > 0, then ASSERT().
> +  If there is no additional space for HOB creation, then ASSERT().
> +  If DataLength > (0xFFF8 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
> +  HobLength is UINT16 and multiples of 8 bytes, so the max HobLength is 0xFFF8.
> +
> +  @param  Guid          The GUID to tag the customized HOB.
> +  @param  Data          The data to be copied into the data field of the GUID HOB.
> +  @param  DataLength    The size of the data payload for the GUID HOB.
> +
> +  @retval  NULL         The GUID HOB could not be allocated.
> +  @retval  others       The start address of GUID HOB data.
> +
> +**/
> +VOID *
> +EFIAPI
> +BuildGuidDataHob (
> +  IN CONST EFI_GUID              *Guid,
> +  IN VOID                        *Data,
> +  IN UINTN                       DataLength
> +  )
> +{
> +  ASSERT (FALSE);
> +  return NULL;
> +}
> +
> +/**
> +  Builds a Firmware Volume HOB.
> +
> +  This function builds a Firmware Volume HOB.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +  If the FvImage buffer is not at its required alignment, then ASSERT().
> +
> +  @param  BaseAddress   The base address of the Firmware Volume.
> +  @param  Length        The size of the Firmware Volume in bytes.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildFvHob (
> +  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN UINT64                      Length
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a EFI_HOB_TYPE_FV2 HOB.
> +
> +  This function builds a EFI_HOB_TYPE_FV2 HOB.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +  If the FvImage buffer is not at its required alignment, then ASSERT().
> +
> +  @param  BaseAddress   The base address of the Firmware Volume.
> +  @param  Length        The size of the Firmware Volume in bytes.
> +  @param  FvName        The name of the Firmware Volume.
> +  @param  FileName      The name of the file.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildFv2Hob (
> +  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN          UINT64                      Length,
> +  IN CONST    EFI_GUID                    *FvName,
> +  IN CONST    EFI_GUID                    *FileName
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a EFI_HOB_TYPE_FV3 HOB.
> +
> +  This function builds a EFI_HOB_TYPE_FV3 HOB.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +  If the FvImage buffer is not at its required alignment, then ASSERT().
> +
> +  @param BaseAddress            The base address of the Firmware Volume.
> +  @param Length                 The size of the Firmware Volume in bytes.
> +  @param AuthenticationStatus   The authentication status.
> +  @param ExtractedFv            TRUE if the FV was extracted as a file within
> +                                another firmware volume. FALSE otherwise.
> +  @param FvName                 The name of the Firmware Volume.
> +                                Valid only if IsExtractedFv is TRUE.
> +  @param FileName               The name of the file.
> +                                Valid only if IsExtractedFv is TRUE.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildFv3Hob (
> +  IN          EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN          UINT64                      Length,
> +  IN          UINT32                      AuthenticationStatus,
> +  IN          BOOLEAN                     ExtractedFv,
> +  IN CONST    EFI_GUID                    *FvName, OPTIONAL
> +  IN CONST    EFI_GUID                    *FileName OPTIONAL
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a Capsule Volume HOB.
> +
> +  This function builds a Capsule Volume HOB.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If the platform does not support Capsule Volume HOBs, then ASSERT().
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  BaseAddress   The base address of the Capsule Volume.
> +  @param  Length        The size of the Capsule Volume in bytes.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildCvHob (
> +  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN UINT64                      Length
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB for the CPU.
> +
> +  This function builds a HOB for the CPU.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  SizeOfMemorySpace   The maximum physical memory addressability of the processor.
> +  @param  SizeOfIoSpace       The maximum physical I/O addressability of the processor.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildCpuHob (
> +  IN UINT8                       SizeOfMemorySpace,
> +  IN UINT8                       SizeOfIoSpace
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB for the Stack.
> +
> +  This function builds a HOB for the stack.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  BaseAddress   The 64 bit physical address of the Stack.
> +  @param  Length        The length of the stack in bytes.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildStackHob (
> +  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN UINT64                      Length
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB for the BSP store.
> +
> +  This function builds a HOB for BSP store.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  BaseAddress   The 64 bit physical address of the BSP.
> +  @param  Length        The length of the BSP store in bytes.
> +  @param  MemoryType    The type of memory allocated by this HOB.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildBspStoreHob (
> +  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN UINT64                      Length,
> +  IN EFI_MEMORY_TYPE             MemoryType
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> +
> +/**
> +  Builds a HOB for the memory allocation.
> +
> +  This function builds a HOB for the memory allocation.
> +  It can only be invoked during PEI phase;
> +  for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
> +
> +  If there is no additional space for HOB creation, then ASSERT().
> +
> +  @param  BaseAddress   The 64 bit physical address of the memory.
> +  @param  Length        The length of the memory allocation in bytes.
> +  @param  MemoryType    The type of memory allocated by this HOB.
> +
> +**/
> +VOID
> +EFIAPI
> +BuildMemoryAllocationHob (
> +  IN EFI_PHYSICAL_ADDRESS        BaseAddress,
> +  IN UINT64                      Length,
> +  IN EFI_MEMORY_TYPE             MemoryType
> +  )
> +{
> +  ASSERT (FALSE);
> +}
> diff --git a/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
> new file mode 100644
> index 000000000000..4a999e381aa0
> --- /dev/null
> +++ b/MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
> @@ -0,0 +1,20 @@
> +// /** @file
> +// Null instance of HOB Library.
> +//
> +// Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
> +// Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
> +//
> +// This program and the accompanying materials
> +// are licensed and made available under the terms and conditions of the BSD License
> +// which accompanies this distribution. The full text of the license may be found at
> +// http://opensource.org/licenses/bsd-license.php.
> +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +//
> +// **/
> +
> +
> +#string STR_MODULE_ABSTRACT             #language en-US "Null instance of HOB Library"
> +
> +#string STR_MODULE_DESCRIPTION          #language en-US "HOB Library implementation for build testing only."
> +
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section
  2019-01-14 13:27 ` [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section Ard Biesheuvel
@ 2019-01-16  5:27   ` Zeng, Star
  0 siblings, 0 replies; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  5:27 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf does not
> build for AARCH64 since it does not provide the needed PlDebugSupport.h
> header. So move the module to a x86 only section.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Star Zeng <star.zeng@intel.com>

> ---
>   MdeModulePkg/MdeModulePkg.dsc | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
> index 967fe082aaae..3e9a9daf1649 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -421,7 +421,6 @@ [Components]
>     MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
>   
>   [Components.IA32, Components.X64, Components.AARCH64]
> -  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
>     MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
>     MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
>     MdeModulePkg/Universal/EbcDxe/EbcDebuggerConfig.inf
> @@ -438,6 +437,7 @@ [Components.IA32, Components.X64, Components.Ebc]
>     MdeModulePkg/Universal/Variable/EmuRuntimeDxe/EmuVariableRuntimeDxe.inf
>   
>   [Components.IA32, Components.X64]
> +  MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
>     MdeModulePkg/Application/SmiHandlerProfileInfo/SmiHandlerProfileInfo.inf
>     MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
>     MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
  2019-01-14 13:27 ` [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class Ard Biesheuvel
@ 2019-01-16  6:32   ` Zeng, Star
  2019-01-16 14:56     ` Gao, Liming
  0 siblings, 1 reply; 41+ messages in thread
From: Zeng, Star @ 2019-01-16  6:32 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel
  Cc: Hao Wu, Liming Gao, Michael D Kinney, Laszlo Ersek, star.zeng

On 2019/1/14 21:27, Ard Biesheuvel wrote:
> Add the library interface for the standalone MM driver entry point.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>   MdePkg/MdePkg.dec                                     |   3 +
>   MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h | 134 ++++++++++++++++++++
>   2 files changed, 137 insertions(+)
> 
> diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> index a7383b6daafb..a4854083105d 100644
> --- a/MdePkg/MdePkg.dec
> +++ b/MdePkg/MdePkg.dec
> @@ -247,6 +247,9 @@ [LibraryClasses]
>     #                Only available to MM_STANDALONE, SMM/DXE Combined and SMM module types.
>     MmServicesTableLib|Include/Library/MmServicesTableLib.h
>   
> +  ##  @libraryclass  Module entry point library for standalone MM drivers.
> +  StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
> +
>   [LibraryClasses.IA32, LibraryClasses.X64]
>     ##  @libraryclass  Abstracts both S/W SMI generation and detection.
>     ##
> diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> new file mode 100644
> index 000000000000..d08a73303dbb
> --- /dev/null
> +++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> @@ -0,0 +1,134 @@
> +/** @file
> +  Module entry point library for Standalone MM Drivers.
> +
> +Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
> +Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
> +Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
> +
> +This program and the accompanying materials are licensed and made available
> +under the terms and conditions of the BSD License which accompanies this
> +distribution.  The full text of the license may be found at
> +http://opensource.org/licenses/bsd-license.php
> +
> +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +
> +#ifndef __MODULE_ENTRY_POINT_H__
> +#define __MODULE_ENTRY_POINT_H__
> +
> +///
> +/// Declare the PI Specification Revision that this driver requires to execute
> +/// correctly.
> +///
> +extern CONST UINT32                   _gMmRevision;
> +
> +/**
> +  The entry point of PE/COFF Image for a Standalone MM Driver.
> +
> +  This function is the entry point for a Standalone MM Driver.
> +  This function must call ProcessLibraryConstructorList() and
> +  ProcessModuleEntryPointList().
> +  If the return status from ProcessModuleEntryPointList()
> +  is an error status, then ProcessLibraryDestructorList() must be called.
> +  The return value from ProcessModuleEntryPointList() is returned.

noop

> +  If _gDriverUnloadImageCount is greater
> +  than zero, then an unload handler must be registered for this image and
> +  the unload handler must invoke ProcessModuleUnloadList().

This block could be removed.

> +  If _gMmRevision is not zero and SystemTable->Hdr.Revision is

SystemTable should be MmSystemTable.

> +  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.

_gUefiDriverRevison should be _gMmRevision.

> +
> +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> +  @param  SystemTable  A pointer to the EFI System Table.
> +
> +  @retval  EFI_SUCCESS               The Standalone MM Driver exited normally.
> +  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
> +                                     SystemTable->Hdr.Revision.

SystemTable should be MmSystemTable.

These feedback may be also applied to the implementation in next patch.

With them handled, Acked-by: Star Zeng <star.zeng@intel.com> to this and 
next patches.

Thanks,
Star


> +  @retval  Other                     Return value from
> +                                     ProcessModuleEntryPointList().
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +_ModuleEntryPoint (
> +  IN EFI_HANDLE             ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> +  );
> +
> +
> +/**
> +  Auto generated function that calls the library constructors for all of the
> +  module's dependent libraries.
> +
> +  This function must be called by _ModuleEntryPoint().
> +  This function calls the set of library constructors for the set of library
> +  instances that a module depends on.  This includes library instances that a
> +  module depends on directly and library instances that a module depends on
> +  indirectly through other libraries. This function is auto generated by build
> +  tools and those build tools are responsible for collecting the set of library
> +  instances, determine which ones have constructors, and calling the library
> +  constructors in the proper order based upon each of the library instances own
> +  dependencies.
> +
> +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> +  @param  SystemTable  A pointer to the MM System Table.
> +
> +**/
> +VOID
> +EFIAPI
> +ProcessLibraryConstructorList (
> +  IN EFI_HANDLE             ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> +  );
> +
> +
> +/**
> +  Auto generated function that calls the library descructors for all of the
> +  module's dependent libraries.
> +
> +  This function may be called by _ModuleEntryPoint().
> +  This function calls the set of library destructors for the set of library
> +  instances that a module depends on. This includes library instances that a
> +  module depends on directly and library instances that a module depends on
> +  indirectly through other libraries.
> +  This function is auto generated by build tools and those build tools are
> +  responsible for collecting the set of library instances, determine which ones
> +  have destructors, and calling the library destructors in the proper order
> +  based upon each of the library instances own dependencies.
> +
> +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> +  @param  SystemTable  A pointer to the MM System Table.
> +
> +**/
> +VOID
> +EFIAPI
> +ProcessLibraryDestructorList (
> +  IN EFI_HANDLE             ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> +  );
> +
> +
> +/**
> +  Auto generated function that calls a set of module entry points.
> +
> +  This function must be called by _ModuleEntryPoint().
> +  This function calls the set of module entry points.
> +  This function is auto generated by build tools and those build tools are
> +  responsible for collecting the module entry points and calling them in a
> +  specified order.
> +
> +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> +  @param  SystemTable  A pointer to the EFI System Table.
> +
> +  @retval  EFI_SUCCESS   The Standalone MM Driver executed normally.
> +  @retval  !EFI_SUCCESS  The Standalone MM Driver failed to execute normally.
> +**/
> +EFI_STATUS
> +EFIAPI
> +ProcessModuleEntryPointList (
> +  IN EFI_HANDLE             ImageHandle,
> +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> +  );
> +
> +#endif
> 



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
  2019-01-16  6:32   ` Zeng, Star
@ 2019-01-16 14:56     ` Gao, Liming
  2019-01-16 14:57       ` Ard Biesheuvel
  0 siblings, 1 reply; 41+ messages in thread
From: Gao, Liming @ 2019-01-16 14:56 UTC (permalink / raw)
  To: Zeng, Star, Ard Biesheuvel, edk2-devel@lists.01.org
  Cc: Wu, Hao A, Kinney, Michael D, Laszlo Ersek

Ard:
  I have no other comment for the changes in MdePkg. You can add my R-B for MdePkg. Besides, I have updated our internal platform too consume new MmServicesTableLib. 

Thanks
Liming
> -----Original Message-----
> From: Zeng, Star
> Sent: Wednesday, January 16, 2019 2:32 PM
> To: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org
> Cc: Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Laszlo
> Ersek <lersek@redhat.com>; Zeng, Star <star.zeng@intel.com>
> Subject: Re: [edk2] [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
> 
> On 2019/1/14 21:27, Ard Biesheuvel wrote:
> > Add the library interface for the standalone MM driver entry point.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >   MdePkg/MdePkg.dec                                     |   3 +
> >   MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h | 134 ++++++++++++++++++++
> >   2 files changed, 137 insertions(+)
> >
> > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> > index a7383b6daafb..a4854083105d 100644
> > --- a/MdePkg/MdePkg.dec
> > +++ b/MdePkg/MdePkg.dec
> > @@ -247,6 +247,9 @@ [LibraryClasses]
> >     #                Only available to MM_STANDALONE, SMM/DXE Combined and SMM module types.
> >     MmServicesTableLib|Include/Library/MmServicesTableLib.h
> >
> > +  ##  @libraryclass  Module entry point library for standalone MM drivers.
> > +  StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
> > +
> >   [LibraryClasses.IA32, LibraryClasses.X64]
> >     ##  @libraryclass  Abstracts both S/W SMI generation and detection.
> >     ##
> > diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> > new file mode 100644
> > index 000000000000..d08a73303dbb
> > --- /dev/null
> > +++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> > @@ -0,0 +1,134 @@
> > +/** @file
> > +  Module entry point library for Standalone MM Drivers.
> > +
> > +Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
> > +Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
> > +Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
> > +
> > +This program and the accompanying materials are licensed and made available
> > +under the terms and conditions of the BSD License which accompanies this
> > +distribution.  The full text of the license may be found at
> > +http://opensource.org/licenses/bsd-license.php
> > +
> > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> > +
> > +**/
> > +
> > +#ifndef __MODULE_ENTRY_POINT_H__
> > +#define __MODULE_ENTRY_POINT_H__
> > +
> > +///
> > +/// Declare the PI Specification Revision that this driver requires to execute
> > +/// correctly.
> > +///
> > +extern CONST UINT32                   _gMmRevision;
> > +
> > +/**
> > +  The entry point of PE/COFF Image for a Standalone MM Driver.
> > +
> > +  This function is the entry point for a Standalone MM Driver.
> > +  This function must call ProcessLibraryConstructorList() and
> > +  ProcessModuleEntryPointList().
> > +  If the return status from ProcessModuleEntryPointList()
> > +  is an error status, then ProcessLibraryDestructorList() must be called.
> > +  The return value from ProcessModuleEntryPointList() is returned.
> 
> noop
> 
> > +  If _gDriverUnloadImageCount is greater
> > +  than zero, then an unload handler must be registered for this image and
> > +  the unload handler must invoke ProcessModuleUnloadList().
> 
> This block could be removed.
> 
> > +  If _gMmRevision is not zero and SystemTable->Hdr.Revision is
> 
> SystemTable should be MmSystemTable.
> 
> > +  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
> 
> _gUefiDriverRevison should be _gMmRevision.
> 
> > +
> > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > +  @param  SystemTable  A pointer to the EFI System Table.
> > +
> > +  @retval  EFI_SUCCESS               The Standalone MM Driver exited normally.
> > +  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
> > +                                     SystemTable->Hdr.Revision.
> 
> SystemTable should be MmSystemTable.
> 
> These feedback may be also applied to the implementation in next patch.
> 
> With them handled, Acked-by: Star Zeng <star.zeng@intel.com> to this and
> next patches.
> 
> Thanks,
> Star
> 
> 
> > +  @retval  Other                     Return value from
> > +                                     ProcessModuleEntryPointList().
> > +
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +_ModuleEntryPoint (
> > +  IN EFI_HANDLE             ImageHandle,
> > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > +  );
> > +
> > +
> > +/**
> > +  Auto generated function that calls the library constructors for all of the
> > +  module's dependent libraries.
> > +
> > +  This function must be called by _ModuleEntryPoint().
> > +  This function calls the set of library constructors for the set of library
> > +  instances that a module depends on.  This includes library instances that a
> > +  module depends on directly and library instances that a module depends on
> > +  indirectly through other libraries. This function is auto generated by build
> > +  tools and those build tools are responsible for collecting the set of library
> > +  instances, determine which ones have constructors, and calling the library
> > +  constructors in the proper order based upon each of the library instances own
> > +  dependencies.
> > +
> > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > +  @param  SystemTable  A pointer to the MM System Table.
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +ProcessLibraryConstructorList (
> > +  IN EFI_HANDLE             ImageHandle,
> > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > +  );
> > +
> > +
> > +/**
> > +  Auto generated function that calls the library descructors for all of the
> > +  module's dependent libraries.
> > +
> > +  This function may be called by _ModuleEntryPoint().
> > +  This function calls the set of library destructors for the set of library
> > +  instances that a module depends on. This includes library instances that a
> > +  module depends on directly and library instances that a module depends on
> > +  indirectly through other libraries.
> > +  This function is auto generated by build tools and those build tools are
> > +  responsible for collecting the set of library instances, determine which ones
> > +  have destructors, and calling the library destructors in the proper order
> > +  based upon each of the library instances own dependencies.
> > +
> > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > +  @param  SystemTable  A pointer to the MM System Table.
> > +
> > +**/
> > +VOID
> > +EFIAPI
> > +ProcessLibraryDestructorList (
> > +  IN EFI_HANDLE             ImageHandle,
> > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > +  );
> > +
> > +
> > +/**
> > +  Auto generated function that calls a set of module entry points.
> > +
> > +  This function must be called by _ModuleEntryPoint().
> > +  This function calls the set of module entry points.
> > +  This function is auto generated by build tools and those build tools are
> > +  responsible for collecting the module entry points and calling them in a
> > +  specified order.
> > +
> > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > +  @param  SystemTable  A pointer to the EFI System Table.
> > +
> > +  @retval  EFI_SUCCESS   The Standalone MM Driver executed normally.
> > +  @retval  !EFI_SUCCESS  The Standalone MM Driver failed to execute normally.
> > +**/
> > +EFI_STATUS
> > +EFIAPI
> > +ProcessModuleEntryPointList (
> > +  IN EFI_HANDLE             ImageHandle,
> > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > +  );
> > +
> > +#endif
> >


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
  2019-01-16 14:56     ` Gao, Liming
@ 2019-01-16 14:57       ` Ard Biesheuvel
  0 siblings, 0 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-16 14:57 UTC (permalink / raw)
  To: Gao, Liming
  Cc: Zeng, Star, edk2-devel@lists.01.org, Wu, Hao A, Kinney, Michael D,
	Laszlo Ersek

On Wed, 16 Jan 2019 at 15:56, Gao, Liming <liming.gao@intel.com> wrote:
>
> Ard:
>   I have no other comment for the changes in MdePkg. You can add my R-B for MdePkg. Besides, I have updated our internal platform too consume new MmServicesTableLib.
>

Thank you Liming. I will go through all Star's comments, and fix up
the patches before pushing.

What about the Quark and Vlv2 changes? (adding MmServicesTableLib)


> > From: Zeng, Star
> > Sent: Wednesday, January 16, 2019 2:32 PM
> > To: Ard Biesheuvel <ard.biesheuvel@linaro.org>; edk2-devel@lists.01.org
> > Cc: Wu, Hao A <hao.a.wu@intel.com>; Gao, Liming <liming.gao@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>; Laszlo
> > Ersek <lersek@redhat.com>; Zeng, Star <star.zeng@intel.com>
> > Subject: Re: [edk2] [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class
> >
> > On 2019/1/14 21:27, Ard Biesheuvel wrote:
> > > Add the library interface for the standalone MM driver entry point.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > > ---
> > >   MdePkg/MdePkg.dec                                     |   3 +
> > >   MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h | 134 ++++++++++++++++++++
> > >   2 files changed, 137 insertions(+)
> > >
> > > diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
> > > index a7383b6daafb..a4854083105d 100644
> > > --- a/MdePkg/MdePkg.dec
> > > +++ b/MdePkg/MdePkg.dec
> > > @@ -247,6 +247,9 @@ [LibraryClasses]
> > >     #                Only available to MM_STANDALONE, SMM/DXE Combined and SMM module types.
> > >     MmServicesTableLib|Include/Library/MmServicesTableLib.h
> > >
> > > +  ##  @libraryclass  Module entry point library for standalone MM drivers.
> > > +  StandaloneMmDriverEntryPoint|Include/Library/StandaloneMmDriverEntryPoint.h
> > > +
> > >   [LibraryClasses.IA32, LibraryClasses.X64]
> > >     ##  @libraryclass  Abstracts both S/W SMI generation and detection.
> > >     ##
> > > diff --git a/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> > > new file mode 100644
> > > index 000000000000..d08a73303dbb
> > > --- /dev/null
> > > +++ b/MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> > > @@ -0,0 +1,134 @@
> > > +/** @file
> > > +  Module entry point library for Standalone MM Drivers.
> > > +
> > > +Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
> > > +Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.<BR>
> > > +Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
> > > +
> > > +This program and the accompanying materials are licensed and made available
> > > +under the terms and conditions of the BSD License which accompanies this
> > > +distribution.  The full text of the license may be found at
> > > +http://opensource.org/licenses/bsd-license.php
> > > +
> > > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> > > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> > > +
> > > +**/
> > > +
> > > +#ifndef __MODULE_ENTRY_POINT_H__
> > > +#define __MODULE_ENTRY_POINT_H__
> > > +
> > > +///
> > > +/// Declare the PI Specification Revision that this driver requires to execute
> > > +/// correctly.
> > > +///
> > > +extern CONST UINT32                   _gMmRevision;
> > > +
> > > +/**
> > > +  The entry point of PE/COFF Image for a Standalone MM Driver.
> > > +
> > > +  This function is the entry point for a Standalone MM Driver.
> > > +  This function must call ProcessLibraryConstructorList() and
> > > +  ProcessModuleEntryPointList().
> > > +  If the return status from ProcessModuleEntryPointList()
> > > +  is an error status, then ProcessLibraryDestructorList() must be called.
> > > +  The return value from ProcessModuleEntryPointList() is returned.
> >
> > noop
> >
> > > +  If _gDriverUnloadImageCount is greater
> > > +  than zero, then an unload handler must be registered for this image and
> > > +  the unload handler must invoke ProcessModuleUnloadList().
> >
> > This block could be removed.
> >
> > > +  If _gMmRevision is not zero and SystemTable->Hdr.Revision is
> >
> > SystemTable should be MmSystemTable.
> >
> > > +  less than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
> >
> > _gUefiDriverRevison should be _gMmRevision.
> >
> > > +
> > > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > > +  @param  SystemTable  A pointer to the EFI System Table.
> > > +
> > > +  @retval  EFI_SUCCESS               The Standalone MM Driver exited normally.
> > > +  @retval  EFI_INCOMPATIBLE_VERSION  _gMmRevision is greater than
> > > +                                     SystemTable->Hdr.Revision.
> >
> > SystemTable should be MmSystemTable.
> >
> > These feedback may be also applied to the implementation in next patch.
> >
> > With them handled, Acked-by: Star Zeng <star.zeng@intel.com> to this and
> > next patches.
> >
> > Thanks,
> > Star
> >
> >
> > > +  @retval  Other                     Return value from
> > > +                                     ProcessModuleEntryPointList().
> > > +
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +_ModuleEntryPoint (
> > > +  IN EFI_HANDLE             ImageHandle,
> > > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > > +  );
> > > +
> > > +
> > > +/**
> > > +  Auto generated function that calls the library constructors for all of the
> > > +  module's dependent libraries.
> > > +
> > > +  This function must be called by _ModuleEntryPoint().
> > > +  This function calls the set of library constructors for the set of library
> > > +  instances that a module depends on.  This includes library instances that a
> > > +  module depends on directly and library instances that a module depends on
> > > +  indirectly through other libraries. This function is auto generated by build
> > > +  tools and those build tools are responsible for collecting the set of library
> > > +  instances, determine which ones have constructors, and calling the library
> > > +  constructors in the proper order based upon each of the library instances own
> > > +  dependencies.
> > > +
> > > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > > +  @param  SystemTable  A pointer to the MM System Table.
> > > +
> > > +**/
> > > +VOID
> > > +EFIAPI
> > > +ProcessLibraryConstructorList (
> > > +  IN EFI_HANDLE             ImageHandle,
> > > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > > +  );
> > > +
> > > +
> > > +/**
> > > +  Auto generated function that calls the library descructors for all of the
> > > +  module's dependent libraries.
> > > +
> > > +  This function may be called by _ModuleEntryPoint().
> > > +  This function calls the set of library destructors for the set of library
> > > +  instances that a module depends on. This includes library instances that a
> > > +  module depends on directly and library instances that a module depends on
> > > +  indirectly through other libraries.
> > > +  This function is auto generated by build tools and those build tools are
> > > +  responsible for collecting the set of library instances, determine which ones
> > > +  have destructors, and calling the library destructors in the proper order
> > > +  based upon each of the library instances own dependencies.
> > > +
> > > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > > +  @param  SystemTable  A pointer to the MM System Table.
> > > +
> > > +**/
> > > +VOID
> > > +EFIAPI
> > > +ProcessLibraryDestructorList (
> > > +  IN EFI_HANDLE             ImageHandle,
> > > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > > +  );
> > > +
> > > +
> > > +/**
> > > +  Auto generated function that calls a set of module entry points.
> > > +
> > > +  This function must be called by _ModuleEntryPoint().
> > > +  This function calls the set of module entry points.
> > > +  This function is auto generated by build tools and those build tools are
> > > +  responsible for collecting the module entry points and calling them in a
> > > +  specified order.
> > > +
> > > +  @param  ImageHandle  The image handle of the Standalone MM Driver.
> > > +  @param  SystemTable  A pointer to the EFI System Table.
> > > +
> > > +  @retval  EFI_SUCCESS   The Standalone MM Driver executed normally.
> > > +  @retval  !EFI_SUCCESS  The Standalone MM Driver failed to execute normally.
> > > +**/
> > > +EFI_STATUS
> > > +EFIAPI
> > > +ProcessModuleEntryPointList (
> > > +  IN EFI_HANDLE             ImageHandle,
> > > +  IN EFI_MM_SYSTEM_TABLE    *MmSystemTable
> > > +  );
> > > +
> > > +#endif
> > >
>


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  2019-01-14 13:27 ` [PATCH v2 04/17] Vlv2TbltDevicePkg: " Ard Biesheuvel
@ 2019-01-16 15:14   ` Gao, Liming
  2019-01-16 17:44     ` Ard Biesheuvel
  0 siblings, 1 reply; 41+ messages in thread
From: Gao, Liming @ 2019-01-16 15:14 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel@lists.01.org, Sun, Zailiang
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Wang, Jian J,
	Wu, Hao A, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Zeng, Star

Zailiang:
  Could you help review this change?

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Monday, January 14, 2019 9:28 PM
> To: edk2-devel@lists.01.org
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Jagadeesh Ujja <jagadeesh.ujja@arm.com>; Achin Gupta <Achin.Gupta@arm.com>; Thomas Panakamattam
> Abraham <thomas.abraham@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
> 
> The SMM based FTW and variable drivers are going to depend on
> MmServicesTableLib after a subsequent patch, so add a resolution
> for it to various Vlv2TbltDevicePkg .dsc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
>  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
>  Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> index d43611550285..eb7c205a10a6 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> @@ -406,6 +406,7 @@ [LibraryClasses.X64.DXE_CORE]
>  !endif
> 
>  [LibraryClasses.X64.DXE_SMM_DRIVER]
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
>    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> index a33816c4d18b..b2f0d73f6d05 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> @@ -406,6 +406,7 @@ [LibraryClasses.IA32.DXE_CORE]
>  !endif
> 
>  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
>    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> index 1da1442c64c6..aa62c07f177b 100644
> --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> @@ -408,6 +408,7 @@ [LibraryClasses.X64.DXE_CORE]
>  !endif
> 
>  [LibraryClasses.X64.DXE_SMM_DRIVER]
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
>    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> --
> 2.20.1



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 03/17] QuarkPlatformPkg: add MmServicesTableLib resolution
  2019-01-14 13:27 ` [PATCH v2 03/17] QuarkPlatformPkg: " Ard Biesheuvel
@ 2019-01-16 15:14   ` Gao, Liming
  0 siblings, 0 replies; 41+ messages in thread
From: Gao, Liming @ 2019-01-16 15:14 UTC (permalink / raw)
  To: Ard Biesheuvel, edk2-devel@lists.01.org
  Cc: Laszlo Ersek, Leif Lindholm, Kinney, Michael D, Wang, Jian J,
	Wu, Hao A, Jagadeesh Ujja, Achin Gupta,
	Thomas Panakamattam Abraham, Sami Mujawar, Zeng, Star

Reviewed-by: Liming Gao <liming.gao@intel.com>

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Monday, January 14, 2019 9:28 PM
> To: edk2-devel@lists.01.org
> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> <hao.a.wu@intel.com>; Jagadeesh Ujja <jagadeesh.ujja@arm.com>; Achin Gupta <Achin.Gupta@arm.com>; Thomas Panakamattam
> Abraham <thomas.abraham@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>; Zeng, Star <star.zeng@intel.com>
> Subject: [PATCH v2 03/17] QuarkPlatformPkg: add MmServicesTableLib resolution
> 
> The SMM based FTW and variable drivers are going to depend on
> MmServicesTableLib after a subsequent patch, so add a resolution
> for it to various QuarkPlatformPkg .dsc files.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  QuarkPlatformPkg/Quark.dsc    | 1 +
>  QuarkPlatformPkg/QuarkMin.dsc | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/QuarkPlatformPkg/Quark.dsc b/QuarkPlatformPkg/Quark.dsc
> index 96ae404f476c..0e69b3c51f97 100644
> --- a/QuarkPlatformPkg/Quark.dsc
> +++ b/QuarkPlatformPkg/Quark.dsc
> @@ -282,6 +282,7 @@ [LibraryClasses.IA32.DXE_CORE]
>  !endif
> 
>  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
>    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> diff --git a/QuarkPlatformPkg/QuarkMin.dsc b/QuarkPlatformPkg/QuarkMin.dsc
> index d7a25686a30b..0f6da821cb82 100644
> --- a/QuarkPlatformPkg/QuarkMin.dsc
> +++ b/QuarkPlatformPkg/QuarkMin.dsc
> @@ -242,6 +242,7 @@ [LibraryClasses.IA32.DXE_CORE]
>  !endif
> 
>  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
>    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
>    ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
>    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> --
> 2.20.1



^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  2019-01-16 15:14   ` Gao, Liming
@ 2019-01-16 17:44     ` Ard Biesheuvel
  2019-01-16 19:00       ` Kinney, Michael D
  2019-01-17  5:20       ` Qian, Yi
  0 siblings, 2 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-16 17:44 UTC (permalink / raw)
  To: Gao, Liming, Qian, Yi
  Cc: edk2-devel@lists.01.org, Sun, Zailiang, Laszlo Ersek,
	Leif Lindholm, Kinney, Michael D, Wang, Jian J, Wu, Hao A,
	Jagadeesh Ujja, Achin Gupta, Thomas Panakamattam Abraham,
	Sami Mujawar, Zeng, Star

(add Yi as well)

On Wed, 16 Jan 2019 at 16:14, Gao, Liming <liming.gao@intel.com> wrote:
>
> Zailiang:
>   Could you help review this change?
>
> > -----Original Message-----
> > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> > Sent: Monday, January 14, 2019 9:28 PM
> > To: edk2-devel@lists.01.org
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> > Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A
> > <hao.a.wu@intel.com>; Jagadeesh Ujja <jagadeesh.ujja@arm.com>; Achin Gupta <Achin.Gupta@arm.com>; Thomas Panakamattam
> > Abraham <thomas.abraham@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>; Zeng, Star <star.zeng@intel.com>
> > Subject: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
> >
> > The SMM based FTW and variable drivers are going to depend on
> > MmServicesTableLib after a subsequent patch, so add a resolution
> > for it to various Vlv2TbltDevicePkg .dsc files.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
> >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
> >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
> >  3 files changed, 3 insertions(+)
> >
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > index d43611550285..eb7c205a10a6 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > @@ -406,6 +406,7 @@ [LibraryClasses.X64.DXE_CORE]
> >  !endif
> >
> >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
> >    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > index a33816c4d18b..b2f0d73f6d05 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > @@ -406,6 +406,7 @@ [LibraryClasses.IA32.DXE_CORE]
> >  !endif
> >
> >  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
> >    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> > diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > index 1da1442c64c6..aa62c07f177b 100644
> > --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > @@ -408,6 +408,7 @@ [LibraryClasses.X64.DXE_CORE]
> >  !endif
> >
> >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > +  MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
> >    SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
> >    ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf
> >    MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
> > --
> > 2.20.1
>


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  2019-01-16 17:44     ` Ard Biesheuvel
@ 2019-01-16 19:00       ` Kinney, Michael D
  2019-01-17  5:20       ` Qian, Yi
  1 sibling, 0 replies; 41+ messages in thread
From: Kinney, Michael D @ 2019-01-16 19:00 UTC (permalink / raw)
  To: Ard Biesheuvel, Gao, Liming, Qian, Yi, Kinney, Michael D
  Cc: Wu, Hao A, edk2-devel@lists.01.org, Laszlo Ersek, Zeng, Star

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

Mike

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-
> bounces@lists.01.org] On Behalf Of Ard Biesheuvel
> Sent: Wednesday, January 16, 2019 9:45 AM
> To: Gao, Liming <liming.gao@intel.com>; Qian, Yi
> <yi.qian@intel.com>
> Cc: Wu, Hao A <hao.a.wu@intel.com>; edk2-
> devel@lists.01.org; Kinney, Michael D
> <michael.d.kinney@intel.com>; Laszlo Ersek
> <lersek@redhat.com>; Zeng, Star <star.zeng@intel.com>
> Subject: Re: [edk2] [PATCH v2 04/17] Vlv2TbltDevicePkg:
> add MmServicesTableLib resolution
> 
> (add Yi as well)
> 
> On Wed, 16 Jan 2019 at 16:14, Gao, Liming
> <liming.gao@intel.com> wrote:
> >
> > Zailiang:
> >   Could you help review this change?
> >
> > > -----Original Message-----
> > > From: Ard Biesheuvel
> [mailto:ard.biesheuvel@linaro.org]
> > > Sent: Monday, January 14, 2019 9:28 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>;
> Laszlo Ersek <lersek@redhat.com>; Leif Lindholm
> <leif.lindholm@linaro.org>; Kinney,
> > > Michael D <michael.d.kinney@intel.com>; Gao, Liming
> <liming.gao@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A
> > > <hao.a.wu@intel.com>; Jagadeesh Ujja
> <jagadeesh.ujja@arm.com>; Achin Gupta
> <Achin.Gupta@arm.com>; Thomas Panakamattam
> > > Abraham <thomas.abraham@arm.com>; Sami Mujawar
> <Sami.Mujawar@arm.com>; Zeng, Star <star.zeng@intel.com>
> > > Subject: [PATCH v2 04/17] Vlv2TbltDevicePkg: add
> MmServicesTableLib resolution
> > >
> > > The SMM based FTW and variable drivers are going to
> depend on
> > > MmServicesTableLib after a subsequent patch, so add
> a resolution
> > > for it to various Vlv2TbltDevicePkg .dsc files.
> > >
> > > Contributed-under: TianoCore Contribution Agreement
> 1.1
> > > Signed-off-by: Ard Biesheuvel
> <ard.biesheuvel@linaro.org>
> > > ---
> > >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
> > >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
> > >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
> > >  3 files changed, 3 insertions(+)
> > >
> > > diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > index d43611550285..eb7c205a10a6 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > @@ -406,6 +406,7 @@ [LibraryClasses.X64.DXE_CORE]
> > >  !endif
> > >
> > >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmS
> ervicesTableLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/S
> mmServicesTableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatus
> CodeLib/SmmReportStatusCodeLib.inf
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLi
> b/SmmMemoryAllocationLib.inf
> > > diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > index a33816c4d18b..b2f0d73f6d05 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > @@ -406,6 +406,7 @@ [LibraryClasses.IA32.DXE_CORE]
> > >  !endif
> > >
> > >  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmS
> ervicesTableLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/S
> mmServicesTableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatus
> CodeLib/SmmReportStatusCodeLib.inf
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLi
> b/SmmMemoryAllocationLib.inf
> > > diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > index 1da1442c64c6..aa62c07f177b 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > @@ -408,6 +408,7 @@ [LibraryClasses.X64.DXE_CORE]
> > >  !endif
> > >
> > >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmS
> ervicesTableLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/S
> mmServicesTableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatus
> CodeLib/SmmReportStatusCodeLib.inf
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLi
> b/SmmMemoryAllocationLib.inf
> > > --
> > > 2.20.1
> >
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers
  2019-01-15  8:25 ` [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Wang, Jian J
@ 2019-01-16 19:28   ` Ard Biesheuvel
  0 siblings, 0 replies; 41+ messages in thread
From: Ard Biesheuvel @ 2019-01-16 19:28 UTC (permalink / raw)
  To: Wang, Jian J
  Cc: edk2-devel@lists.01.org, Laszlo Ersek, Leif Lindholm,
	Kinney, Michael D, Gao, Liming, Wu, Hao A, Jagadeesh Ujja,
	Achin Gupta, Thomas Panakamattam Abraham, Sami Mujawar,
	Zeng, Star

On Tue, 15 Jan 2019 at 09:25, Wang, Jian J <jian.j.wang@intel.com> wrote:
>
> Ard,
>
> For patch 1,5,6,7,8,12,13,14,15,16,17
>
> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
>


Series pushed as 2f4a5a9f4c17..5072c47411b8

Thanks all.


>
> > -----Original Message-----
> > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> > Sent: Monday, January 14, 2019 9:28 PM
> > To: edk2-devel@lists.01.org
> > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>; Kinney,
> > Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>;
> > Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> > Jagadeesh Ujja <jagadeesh.ujja@arm.com>; Achin Gupta
> > <Achin.Gupta@arm.com>; Thomas Panakamattam Abraham
> > <thomas.abraham@arm.com>; Sami Mujawar <Sami.Mujawar@arm.com>;
> > Zeng, Star <star.zeng@intel.com>
> > Subject: [PATCH v2 00/17] implement standalone MM versions of the variable
> > runtime drivers
> >
> > This v2 series is a followup to [0], and updates the SMM implementations of
> > the fault tolerant write and variable runtime drivers to provide standalone
> > MM versions that share as much of the existing code as possible with the
> > traditional SMM implementations.
> >
> > The meat is in patches #5 - #8, which were part of v1. I updated them according
> > to the received feedback, and added tags that were given on list.
> >
> > Patches #1 - #4 add library class resolutions for MmServiceTableLib, which was
> > introduced in v1 of the series, and has already been merged (at the request of
> > Liming) so that downstream platforms can add the resolution as well.
> >
> > The remaining patches #9 - #17 are new, and have been added so that the new
> > standalone MM drivers can be added to and built from MdeModulePkg.dsc, but
> > for coverage only (the resulting binaries won't actually work)
> > - patches #9 and #10 add a definition and implementation of
> >   StandaloneMmDriverEntryPoint, which is rather straight-forward and has no
> >   dependencies on the standalone MM core, so it is reasonable to add it to
> >   MdePkg directly. Note that this version contains the _gMmVersion check that
> >   is missing from the one in StandaloneMmPkg
> > - patch #11 adds a standalone MM implementation of MmServicesTableLib to
> > MdePkg,
> >   which -again- does not depend on the standalone MM core at all, so added
> > here
> >   for simplicity
> > - patches #12 and #13 add NULL implementations of MemoryAllocationLib and
> > HobLib
> >   so that the FTW and variable MM_STANDALONE modules can be built without
> >   depending on StandaloneMmPkg
> > - patch #14 is an unrelated fix so that MdeModulePkg.dsc can be built for
> >   AARCH64
> > - patches #15 and #16 add MM_STANDALONE support to a couple of libraries
> > that
> >   the new modules depend on
> > - patch #17 adds the FTW and variable standalone MM drivers to
> > MdeModulePkg.dsc
> >
> > NOTE: the drivers added in patches #10 and #11 supersede the ones that reside
> > in
> > or have been proposed for StandaloneMmPkg
> >
> > Patches can be found here:
> > https://github.com/ardbiesheuvel/edk2/tree/variable-ftw-standalone-mm-
> > conversion
> >
> > Cc: Laszlo Ersek <lersek@redhat.com>
> > Cc: Leif Lindholm <leif.lindholm@linaro.org>
> > Cc: Michael D Kinney <michael.d.kinney@intel.com>
> > Cc: Liming Gao <liming.gao@intel.com>
> > Cc: Jian J Wang <jian.j.wang@intel.com>
> > Cc: Hao Wu <hao.a.wu@intel.com>
> > Cc: Jagadeesh Ujja <jagadeesh.ujja@arm.com>
> > Cc: Achin Gupta <Achin.Gupta@arm.com>
> > Cc: Thomas Panakamattam Abraham <thomas.abraham@arm.com>
> > Cc: Sami Mujawar <Sami.Mujawar@arm.com>
> > Cc: Star Zeng <star.zeng@intel.com>
> >
> > [0] https://lists.01.org/pipermail/edk2-devel/2019-January/034608.html
> >
> > Ard Biesheuvel (17):
> >   MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution
> >   OvmfPkg: add MmServicesTableLib resolution
> >   QuarkPlatformPkg: add MmServicesTableLib resolution
> >   Vlv2TbltDevicePkg: add MmServicesTableLib resolution
> >   MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses
> >   MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version
> >   MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses
> >   MdeModulePkg/VariableRuntimeDxe: implement standalone MM version
> >   MdePkg: introduce standalone MM entry point library class
> >   MdePkg: introduce standalone MM entry point library implementation
> >   MdePkg: add MM_STANDALONE implementation of MmServicesTableLib
> >   MdeModulePkg: implement NULL instance of HobLib library class
> >   MdeModulePkg: implement NULL instance of MemoryAllocationLib library
> > class
> >   MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only
> > section
> >   MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support
> >   MdeModulePkg/VarCheckLib: add MM_STANDALONE support
> >   MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable
> > modules
> >
> >  MdePkg/MdePkg.dec                                                                                              |   3 +
> >  MdeModulePkg/MdeModulePkg.dsc
> > |  12 +-
> >  MdePkg/MdePkg.dsc                                                                                              |   3 +
> >  OvmfPkg/OvmfPkgIa32.dsc                                                                                        |   1
> > +
> >  OvmfPkg/OvmfPkgIa32X64.dsc                                                                                     |
> > 1 +
> >  OvmfPkg/OvmfPkgX64.dsc                                                                                         |   1
> > +
> >  QuarkPlatformPkg/Quark.dsc                                                                                     |   1
> > +
> >  QuarkPlatformPkg/QuarkMin.dsc                                                                                  |
> > 1 +
> >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > |   1 +
> >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > |   1 +
> >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > |   1 +
> >  MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
> > |   2 +-
> >  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> > |  38 ++
> >
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.inf                               |  38 ++
> >  MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
> > |   2 +-
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf
> > |   5 +-
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf
> > => FaultTolerantWriteStandaloneMm.inf} |  43 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> > |   5 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf =>
> > VariableStandaloneMm.inf}                       |  43 +-
> >
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.inf                                   |  43 ++
> >
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.inf                                   |  39 ++
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWrite.h
> > |  23 +-
> >
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmmCom
> > mon.h                                     |  34 ++
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/PrivilegePolymorphic.h
> > |  58 ++
> >  MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> > | 134 +++++
> >  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
> > | 542 ++++++++++++++++++
> >
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.c                                 | 575 ++++++++++++++++++++
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.c
> > |  31 ++
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.c
> > |  53 +-
> >
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
> > eMm.c                                  |  88 +++
> >
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditiona
> > lMm.c                                 | 106 ++++
> >  MdeModulePkg/Universal/FaultTolerantWriteDxe/UpdateWorkingBlock.c
> > |  10 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/TcgMorLockSmm.c
> > |  18 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c
> > |  59 +-
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
> > |  89 +++
> >  MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
> > | 130 +++++
> >
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.c                                     |  90 +++
> >
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.c                                     |  41 ++
> >  MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
> > |  20 +
> >
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.uni                               |  20 +
> >
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.uni                                   |  22 +
> >
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.uni                                   |  20 +
> >  42 files changed, 2290 insertions(+), 157 deletions(-)
> >  create mode 100644
> > MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.inf
> >  create mode 100644
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.inf
> >  copy
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/{FaultTolerantWriteSmm.inf
> > => FaultTolerantWriteStandaloneMm.inf} (68%)
> >  copy MdeModulePkg/Universal/Variable/RuntimeDxe/{VariableSmm.inf =>
> > VariableStandaloneMm.inf} (82%)
> >  create mode 100644
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.inf
> >  create mode 100644
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.inf
> >  create mode 100644 MdePkg/Include/Library/StandaloneMmDriverEntryPoint.h
> >  create mode 100644 MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.c
> >  create mode 100644
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.c
> >  create mode 100644
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteStandalon
> > eMm.c
> >  create mode 100644
> > MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteTraditiona
> > lMm.c
> >  create mode 100644
> > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.c
> >  create mode 100644
> > MdeModulePkg/Universal/Variable/RuntimeDxe/VariableTraditionalMm.c
> >  create mode 100644
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.c
> >  create mode 100644
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.c
> >  create mode 100644
> > MdeModulePkg/Library/BaseHobLibNull/BaseHobLibNull.uni
> >  create mode 100644
> > MdeModulePkg/Library/BaseMemoryAllocationLibNull/BaseMemoryAllocationL
> > ibNull.uni
> >  create mode 100644
> > MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoin
> > t.uni
> >  create mode 100644
> > MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLi
> > b.uni
> >
> > --
> > 2.20.1
>


^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib resolution
  2019-01-16 17:44     ` Ard Biesheuvel
  2019-01-16 19:00       ` Kinney, Michael D
@ 2019-01-17  5:20       ` Qian, Yi
  1 sibling, 0 replies; 41+ messages in thread
From: Qian, Yi @ 2019-01-17  5:20 UTC (permalink / raw)
  To: Ard Biesheuvel, Gao, Liming
  Cc: edk2-devel@lists.01.org, Sun, Zailiang, Laszlo Ersek,
	Leif Lindholm, Kinney, Michael D, Wang, Jian J, Wu, Hao A,
	Jagadeesh Ujja, Achin Gupta, Thomas Panakamattam Abraham,
	Sami Mujawar, Zeng, Star

Reviewed-by: Qian Yi <yi.qian@intel.com>

Thanks
Qian Yi

> -----Original Message-----
> From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> Sent: Thursday, January 17, 2019 1:45 AM
> To: Gao, Liming <liming.gao@intel.com>; Qian, Yi <yi.qian@intel.com>
> Cc: edk2-devel@lists.01.org; Sun, Zailiang <zailiang.sun@intel.com>; Laszlo
> Ersek <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>;
> Kinney, Michael D <michael.d.kinney@intel.com>; Wang, Jian J
> <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>; Jagadeesh Ujja
> <jagadeesh.ujja@arm.com>; Achin Gupta <Achin.Gupta@arm.com>;
> Thomas Panakamattam Abraham <thomas.abraham@arm.com>; Sami
> Mujawar <Sami.Mujawar@arm.com>; Zeng, Star <star.zeng@intel.com>
> Subject: Re: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib
> resolution
> 
> (add Yi as well)
> 
> On Wed, 16 Jan 2019 at 16:14, Gao, Liming <liming.gao@intel.com> wrote:
> >
> > Zailiang:
> >   Could you help review this change?
> >
> > > -----Original Message-----
> > > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]
> > > Sent: Monday, January 14, 2019 9:28 PM
> > > To: edk2-devel@lists.01.org
> > > Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>; Laszlo Ersek
> > > <lersek@redhat.com>; Leif Lindholm <leif.lindholm@linaro.org>;
> > > Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming
> > > <liming.gao@intel.com>; Wang, Jian J <jian.j.wang@intel.com>; Wu,
> > > Hao A <hao.a.wu@intel.com>; Jagadeesh Ujja
> <jagadeesh.ujja@arm.com>;
> > > Achin Gupta <Achin.Gupta@arm.com>; Thomas Panakamattam Abraham
> > > <thomas.abraham@arm.com>; Sami Mujawar
> <Sami.Mujawar@arm.com>; Zeng,
> > > Star <star.zeng@intel.com>
> > > Subject: [PATCH v2 04/17] Vlv2TbltDevicePkg: add MmServicesTableLib
> > > resolution
> > >
> > > The SMM based FTW and variable drivers are going to depend on
> > > MmServicesTableLib after a subsequent patch, so add a resolution for
> > > it to various Vlv2TbltDevicePkg .dsc files.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > > ---
> > >  Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc | 1 +
> > >  Vlv2TbltDevicePkg/PlatformPkgIA32.dsc   | 1 +
> > >  Vlv2TbltDevicePkg/PlatformPkgX64.dsc    | 1 +
> > >  3 files changed, 3 insertions(+)
> > >
> > > diff --git a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > index d43611550285..eb7c205a10a6 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgGccX64.dsc
> > > @@ -406,6 +406,7 @@ [LibraryClasses.X64.DXE_CORE]  !endif
> > >
> > >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > > +
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTab
> > > + leLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesT
> ableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/S
> mmReportStatusCodeLib.inf
> > >
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMe
> moryA
> > > llocationLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > index a33816c4d18b..b2f0d73f6d05 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgIA32.dsc
> > > @@ -406,6 +406,7 @@ [LibraryClasses.IA32.DXE_CORE]  !endif
> > >
> > >  [LibraryClasses.IA32.DXE_SMM_DRIVER]
> > > +
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTab
> > > + leLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesT
> ableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/S
> mmReportStatusCodeLib.inf
> > >
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMe
> moryA
> > > llocationLib.inf diff --git a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > index 1da1442c64c6..aa62c07f177b 100644
> > > --- a/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > +++ b/Vlv2TbltDevicePkg/PlatformPkgX64.dsc
> > > @@ -408,6 +408,7 @@ [LibraryClasses.X64.DXE_CORE]  !endif
> > >
> > >  [LibraryClasses.X64.DXE_SMM_DRIVER]
> > > +
> > > +
> MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTab
> > > + leLib.inf
> > >
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesT
> ableLib.inf
> > >
> ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/S
> mmReportStatusCodeLib.inf
> > >
> > >
> MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMe
> moryA
> > > llocationLib.inf
> > > --
> > > 2.20.1
> >

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2019-01-17  5:20 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-14 13:27 [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Ard Biesheuvel
2019-01-14 13:27 ` [PATCH v2 01/17] MdeModulePkg/MdeModulePkg.dsc: add MmServicesTableLib resolution Ard Biesheuvel
2019-01-16  5:02   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 02/17] OvmfPkg: " Ard Biesheuvel
2019-01-14 16:40   ` Laszlo Ersek
2019-01-14 17:05     ` Ard Biesheuvel
2019-01-14 13:27 ` [PATCH v2 03/17] QuarkPlatformPkg: " Ard Biesheuvel
2019-01-16 15:14   ` Gao, Liming
2019-01-14 13:27 ` [PATCH v2 04/17] Vlv2TbltDevicePkg: " Ard Biesheuvel
2019-01-16 15:14   ` Gao, Liming
2019-01-16 17:44     ` Ard Biesheuvel
2019-01-16 19:00       ` Kinney, Michael D
2019-01-17  5:20       ` Qian, Yi
2019-01-14 13:27 ` [PATCH v2 05/17] MdeModulePkg/FaultTolerantWriteDxe: factor out boot service accesses Ard Biesheuvel
2019-01-16  3:29   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 06/17] MdeModulePkg/FaultTolerantWriteDxe: implement standalone MM version Ard Biesheuvel
2019-01-16  3:32   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 07/17] MdeModulePkg/VariableRuntimeDxe: factor out boot service accesses Ard Biesheuvel
2019-01-16  4:57   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 08/17] MdeModulePkg/VariableRuntimeDxe: implement standalone MM version Ard Biesheuvel
2019-01-16  5:00   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 09/17] MdePkg: introduce standalone MM entry point library class Ard Biesheuvel
2019-01-16  6:32   ` Zeng, Star
2019-01-16 14:56     ` Gao, Liming
2019-01-16 14:57       ` Ard Biesheuvel
2019-01-14 13:27 ` [PATCH v2 10/17] MdePkg: introduce standalone MM entry point library implementation Ard Biesheuvel
2019-01-14 13:27 ` [PATCH v2 11/17] MdePkg: add MM_STANDALONE implementation of MmServicesTableLib Ard Biesheuvel
2019-01-14 13:27 ` [PATCH v2 12/17] MdeModulePkg: implement NULL instance of HobLib library class Ard Biesheuvel
2019-01-16  5:10   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 13/17] MdeModulePkg: implement NULL instance of MemoryAllocationLib " Ard Biesheuvel
2019-01-16  5:09   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 14/17] MdeModulePkg/MdeModulePkg/dsc: move DxeDebugSupportDxe to x86 only section Ard Biesheuvel
2019-01-16  5:27   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 15/17] MdeModulePkg/AuthVariableLibNull: add MM_STANDALONE support Ard Biesheuvel
2019-01-16  5:03   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 16/17] MdeModulePkg/VarCheckLib: " Ard Biesheuvel
2019-01-16  5:03   ` Zeng, Star
2019-01-14 13:27 ` [PATCH v2 17/17] MdeModulePkg/MdeModulePkg.dsc: add MM_STANDALONE FTW and variable modules Ard Biesheuvel
2019-01-16  5:04   ` Zeng, Star
2019-01-15  8:25 ` [PATCH v2 00/17] implement standalone MM versions of the variable runtime drivers Wang, Jian J
2019-01-16 19:28   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox