[edk2] [PATCH v2 19/32] OvmfPkg: S3 Suspend: introduce DiscloseSmstSmm driver

Subject: [edk2] [PATCH v2 19/32] OvmfPkg: S3 Suspend: introduce DiscloseSmstSmm driver

From: Laszlo Ersek <lersek@redhat.com>

To: edk2-devel@lists.sourceforge.net

Date: 2013-12-25 01:49:55

  • 2013-12-25 01:49:55  Laszlo Ersek   [edk2] [PATCH v2 19/32] OvmfPkg: S3 Suspend: introduce DiscloseSmstSmm driver
This is a rogue SMM driver. It runs in SMM mode and has access to
confidential SMM data. It saves the address of the SMST for the next
patch, at a known location in the emulated NVRAM.

v3:
- rebased to EmuNvramLib

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek 
---
 OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf | 50 +++++++++++++++++++++++++++++
 OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.c   | 36 +++++++++++++++++++++
 OvmfPkg/OvmfPkgIa32.dsc                     |  1 +
 OvmfPkg/OvmfPkgIa32.fdf                     |  1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                  |  1 +
 OvmfPkg/OvmfPkgIa32X64.fdf                  |  1 +
 OvmfPkg/OvmfPkgX64.dsc                      |  1 +
 OvmfPkg/OvmfPkgX64.fdf                      |  1 +
 8 files changed, 92 insertions(+)
 create mode 100644 OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 create mode 100644 OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.c

diff --git a/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf b/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
new file mode 100644
index 0000000..5b31a52
--- /dev/null
+++ b/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
@@ -0,0 +1,50 @@
+## @file
+# An SMM driver that publishes the address of the SMST.
+#
+# Copyright (C) 2013, Red Hat, Inc.
+#
+# 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                    = 0x00010005
+  BASE_NAME                      = DiscloseSmstSmm
+  FILE_GUID                      = 2AD83D53-687B-4C3A-8840-EE71164195EB
+  MODULE_TYPE                    = DXE_SMM_DRIVER
+  VERSION_STRING                 = 1.0
+  PI_SPECIFICATION_VERSION       = 0x0001000A
+  ENTRY_POINT                    = DiscloseSmstSmmEntryPoint
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+[Sources]
+  DiscloseSmstSmm.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  EmuNvramLib
+  SmmServicesTableLib
+  UefiDriverEntryPoint
+
+[Pcd]
+
+[Guids]
+
+[Protocols]
+
+[Depex]
+  TRUE
diff --git a/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.c b/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.c
new file mode 100644
index 0000000..ee82a22
--- /dev/null
+++ b/OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.c
@@ -0,0 +1,36 @@
+/** @file
+  An SMM driver that publishes the address of the SMST.
+
+  Copyright (C) 2013, Red Hat, Inc.
+
+  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 
+#include 
+#include 
+
+EFI_STATUS
+EFIAPI
+DiscloseSmstSmmEntryPoint (
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
+  )
+{
+  ASSERT (EmuNvramSmstPtrSize () == sizeof (EFI_PHYSICAL_ADDRESS));
+  *(EFI_PHYSICAL_ADDRESS *)(UINTN) EmuNvramSmstPtrBase () =
+    (EFI_PHYSICAL_ADDRESS)(UINTN) gSmst;
+
+  //
+  // No need to keep this in memory after saving the pointer at a known
+  // address.
+  //
+  return EFI_ABORTED;
+}
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
index 252e01a..8af09b6 100644
--- a/OvmfPkg/OvmfPkgIa32.dsc
+++ b/OvmfPkg/OvmfPkgIa32.dsc
@@ -497,6 +497,7 @@
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
   MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
   #
   # ACPI Support
diff --git a/OvmfPkg/OvmfPkgIa32.fdf b/OvmfPkg/OvmfPkgIa32.fdf
index 35f1286..8a99c0b 100644
--- a/OvmfPkg/OvmfPkgIa32.fdf
+++ b/OvmfPkg/OvmfPkgIa32.fdf
@@ -367,6 +367,7 @@ INF  OvmfPkg/EmuSmmDxe/EmuSmmDxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+INF  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
 INF  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
index bdfda12..2a29232 100644
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
@@ -504,6 +504,7 @@
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
   MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
   #
   # ACPI Support
diff --git a/OvmfPkg/OvmfPkgIa32X64.fdf b/OvmfPkg/OvmfPkgIa32X64.fdf
index 4990622..0fdf459 100644
--- a/OvmfPkg/OvmfPkgIa32X64.fdf
+++ b/OvmfPkg/OvmfPkgIa32X64.fdf
@@ -367,6 +367,7 @@ INF  OvmfPkg/EmuSmmDxe/EmuSmmDxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+INF  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
 INF  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
index 30315fe..0d38a50 100644
--- a/OvmfPkg/OvmfPkgX64.dsc
+++ b/OvmfPkg/OvmfPkgX64.dsc
@@ -524,6 +524,7 @@
   MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
   MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
   MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
   #
   # ACPI Support
diff --git a/OvmfPkg/OvmfPkgX64.fdf b/OvmfPkg/OvmfPkgX64.fdf
index 9e2da17..f7b903a 100644
--- a/OvmfPkg/OvmfPkgX64.fdf
+++ b/OvmfPkg/OvmfPkgX64.fdf
@@ -367,6 +367,7 @@ INF  OvmfPkg/EmuSmmDxe/EmuSmmDxe.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf
 INF  MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
 INF  MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf
+INF  OvmfPkg/DiscloseSmstSmm/DiscloseSmstSmm.inf
 
 INF  MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
 INF  OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
-- 
1.8.3.1



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel