The SmmCpuPlatformHookLib class provides the following APIs:
- PlatformValidSmi()
- ClearTopLevelSmiStatus()
- PlatformSmmBspElection()
- GetPlatformPageTableAttribute()
- PlatformSmmExitProcessing()

The Quark_EDKII_v1.1.0 distribution provides two instances:
- IA32FamilyCpuBasePkg/Library/SmmCpuPlatformHookLibNull
- QuarkPlatformPkg/Library/SmmCpuPlatformHookLib

The first doesn't do anything at all, and the second isn't much different
either: the only difference is that the second instance's
PlatformSmmExitProcessing() function performs the following steps (quoting
the comments there):

(a) SMM Write Protect Disable bit must be cleared before the processor
    exits SMM mode to prevent write cycles to SPI flash when the processor
    is in a non-SMM mode.

(b) Ensure that SMI signal pin indicator is clear at the end of SMM
    handling.

Goal (a) will be covered by QEMU automatically, and goal (b) is irrelevant
on QEMU.

PiSmmCpuDxeSmm calls these APIs in a number of places and contexts, so
it's simpler to import the library header file, and the Null instance,
than to eliminate the references.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <ler...@redhat.com>
---
 
OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
 |  65 +++++++++
 OvmfPkg/QuarkPort/Include/Library/SmmCpuPlatformHookLib.h                      
   | 137 +++++++++++++++++++
 
OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c 
  | 143 ++++++++++++++++++++
 OvmfPkg/OvmfPkg.dec                                                            
   |   4 +
 4 files changed, 349 insertions(+)

diff --git 
a/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
 
b/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
new file mode 100644
index 0000000..c375b35
--- /dev/null
+++ 
b/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf
@@ -0,0 +1,65 @@
+## @file
+# Component description file for CPU Configuration Library.
+#
+# CPU Configuration Library implementation that retrieves data in Processor
+# Configuration Context Buffer.
+# Copyright (c) 2013-2015 Intel Corporation.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of Intel Corporation nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+#
+##
+
+
+################################################################################
+#
+# Defines Section - statements that will be processed to create a Makefile.
+#
+################################################################################
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = SmmCpuPlatformHookLibNull
+  FILE_GUID                      = 1328AEBC-010B-46ec-832E-1DB2890C2452
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = SmmCpuPlatformHookLib 
+
+
+#
+# The following information is for reference only and not required by the 
build tools.
+#
+#  VALID_ARCHITECTURES           = IA32 X64
+#
+
+
+[Sources]
+  SmmCpuPlatformHookLibNull.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  IA32FamilyCpuBasePkg/IA32FamilyCpuBasePkg.dec
+
diff --git a/OvmfPkg/QuarkPort/Include/Library/SmmCpuPlatformHookLib.h 
b/OvmfPkg/QuarkPort/Include/Library/SmmCpuPlatformHookLib.h
new file mode 100644
index 0000000..b017a27
--- /dev/null
+++ b/OvmfPkg/QuarkPort/Include/Library/SmmCpuPlatformHookLib.h
@@ -0,0 +1,137 @@
+/** @file
+  Public include file for the SMM CPU Platform Hook Library.
+
+  Copyright (c) 2013-2015 Intel Corporation.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+  * Neither the name of Intel Corporation nor the names of its
+  contributors may be used to endorse or promote products derived
+  from this software without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#ifndef __SMM_CPU_PLATFORM_HOOK_LIB_H__
+#define __SMM_CPU_PLATFORM_HOOK_LIB_H__
+
+/**
+  Checks if platform produces a valid SMI. 
+  
+  This function checks if platform produces a valid SMI. This function is 
+  called at SMM entry to detect if this is a spurious SMI. This function 
+  must be implemented in an MP safe way because it is called by multiple CPU
+  threads.
+  
+  @retval TRUE              There is a valid SMI
+  @retval FALSE             There is no valid SMI
+
+**/
+BOOLEAN
+EFIAPI
+PlatformValidSmi (
+  VOID
+  );
+
+/**
+  Clears platform top level SMI status bit. 
+  
+  This function clears platform top level SMI status bit.
+  
+  @retval TRUE              The platform top level SMI status is cleared.
+  @retval FALSE             The paltform top level SMI status cannot be 
cleared.
+
+**/
+BOOLEAN
+EFIAPI
+ClearTopLevelSmiStatus (
+  VOID
+  );
+
+/**
+  Performs platform specific way of SMM BSP election.
+  
+  This function performs platform specific way of SMM BSP election.
+  
+  @param  IsBsp             Output parameter. TRUE: the CPU this function 
executes
+                            on is elected to be the SMM BSP. FALSE: the CPU 
this 
+                            function executes on is to be SMM AP.
+
+  @retval EFI_SUCCESS       The function executes successfully.
+  @retval EFI_NOT_READY     The function does not determine whether this CPU 
should be
+                            BSP or AP. This may occur if hardware init 
sequence to
+                            enable the determination is yet to be done, or the 
function
+                            chooses not to do BSP election and will let SMM 
CPU driver to
+                            use its default BSP election process.
+  @retval EFI_DEVICE_ERROR  The function cannot determine whether this CPU 
should be
+                            BSP or AP due to hardware error.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformSmmBspElection (
+  OUT BOOLEAN     *IsBsp
+  );
+
+
+typedef enum {
+    SmmPageSize4K,
+    SmmPageSize2M,
+    SmmPageSize1G,
+    MaxSmmPageSizeType
+} SMM_PAGE_SIZE_TYPE;
+
+
+/**
+  Get platform page table attribute .
+
+  This function gets page table attribute of platform.
+
+  @param  Address        Input parameter. Obtain the page table entries 
attribute on this address.
+  @param  PageSize       Output parameter. The size of the page.
+  @param  NumOfPages     Output parameter. Number of page.
+  @param  PageAttribute  Output parameter. Paging Attributes (WB, UC, etc).
+  
+  @retval EFI_SUCCESS       The platform page table attribute from the address 
is determined.
+  @retval EFI_UNSUPPORTED  The paltform not supoort to get page table 
attribute from the address.
+
+**/
+EFI_STATUS
+EFIAPI
+GetPlatformPageTableAttribute (
+  IN  UINT64                Address,
+  OUT SMM_PAGE_SIZE_TYPE    *PageSize,
+  OUT UINTN                 *NumOfPages,
+  OUT UINTN                 *PageAttribute
+  );
+
+/**
+  Platform hook called when exiting SMM.
+
+**/
+VOID
+EFIAPI
+PlatformSmmExitProcessing (
+  VOID
+  );
+
+#endif   
diff --git 
a/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c
 
b/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c
new file mode 100644
index 0000000..b7b5bfa
--- /dev/null
+++ 
b/OvmfPkg/QuarkPort/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.c
@@ -0,0 +1,143 @@
+/** @file
+
+  CPU Configuration Library.
+
+  Copyright (c) 2013-2015 Intel Corporation.
+
+  Redistribution and use in source and binary forms, with or without
+  modification, are permitted provided that the following conditions
+  are met:
+
+  * Redistributions of source code must retain the above copyright
+  notice, this list of conditions and the following disclaimer.
+  * Redistributions in binary form must reproduce the above copyright
+  notice, this list of conditions and the following disclaimer in
+  the documentation and/or other materials provided with the
+  distribution.
+  * Neither the name of Intel Corporation nor the names of its
+  contributors may be used to endorse or promote products derived
+  from this software without specific prior written permission.
+
+  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+**/
+
+#include <Library/SmmCpuPlatformHookLib.h>
+
+
+/**
+  Checks if platform produces a valid SMI. 
+  
+  This function checks if platform produces a valid SMI. This function is 
+  called at SMM entry to detect if this is a spurious SMI. This function 
+  must be implemented in an MP safe way because it is called by multiple CPU
+  threads.
+  
+  @retval TRUE              There is a valid SMI
+  @retval FALSE             There is no valid SMI
+
+**/
+BOOLEAN
+EFIAPI
+PlatformValidSmi (
+  VOID
+  )
+{
+  return TRUE;
+}
+
+
+/**
+  Clears platform top level SMI status bit. 
+  
+  This function clears platform top level SMI status bit.
+  
+  @retval TRUE              The platform top level SMI status is cleared.
+  @retval FALSE             The paltform top level SMI status cannot be 
cleared.
+
+**/
+BOOLEAN
+EFIAPI
+ClearTopLevelSmiStatus (
+  VOID
+  )
+{
+  return TRUE;
+}
+
+
+/**
+  Performs platform specific way of SMM BSP election.
+  
+  This function performs platform specific way of SMM BSP election.
+  
+  @param  IsBsp             Output parameter. TRUE: the CPU this function 
executes
+                            on is elected to be the SMM BSP. FALSE: the CPU 
this 
+                            function executes on is to be SMM AP.
+
+  @retval EFI_SUCCESS       The function executes successfully.
+  @retval EFI_NOT_READY     The function does not determine whether this CPU 
should be
+                            BSP or AP. This may occur if hardware init 
sequence to
+                            enable the determination is yet to be done, or the 
function
+                            chooses not to do BSP election and will let SMM 
CPU driver to
+                            use its default BSP election process.
+  @retval EFI_DEVICE_ERROR  The function cannot determine whether this CPU 
should be
+                            BSP or AP due to hardware error.
+
+**/
+EFI_STATUS
+EFIAPI
+PlatformSmmBspElection (
+  OUT BOOLEAN     *IsBsp
+  )
+{
+  return EFI_NOT_READY;
+}
+
+/**
+  Get platform page table attribute .
+
+  This function gets page table attribute of platform.
+
+  @param  Address        Input parameter. Obtain the page table entries 
attribute on this address.
+  @param  PageSize       Output parameter. The size of the page.
+  @param  NumOfPages     Output parameter. Number of page.
+  @param  PageAttribute  Output parameter. Paging Attributes (WB, UC, etc).
+  
+  @retval EFI_SUCCESS       The platform page table attribute from the address 
is determined.
+  @retval EFI_UNSUPPORTED   The paltform not supoort to get page table 
attribute from the address.
+
+**/
+EFI_STATUS
+EFIAPI
+GetPlatformPageTableAttribute (
+  IN  UINT64                Address,
+  IN OUT SMM_PAGE_SIZE_TYPE *PageSize,
+  IN OUT UINTN              *NumOfPages,
+  IN OUT UINTN              *PageAttribute
+  )
+{
+  return EFI_UNSUPPORTED;
+}
+
+/**
+  Platform hook called when exiting SMM.
+
+**/
+VOID
+EFIAPI
+PlatformSmmExitProcessing (
+  VOID
+  )
+{
+}
diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec
index c7c6d8a..229fad4 100644
--- a/OvmfPkg/OvmfPkg.dec
+++ b/OvmfPkg/OvmfPkg.dec
@@ -36,6 +36,10 @@ [LibraryClasses]
   #
   Socket775LgaLib|QuarkPort/Include/Library/SocketLga775Lib.h
 
+  ##  @libraryclass  SMM CPU Platform Hook Library
+  #
+  SmmCpuPlatformHookLib|QuarkPort/Include/Library/SmmCpuPlatformHookLib.h
+
   ## OvmfPkg's own library classes are listed below.
   #
 
-- 
1.8.3.1


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to