]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: clone SmmCpuPlatformHookLib from UefiCpuPkg
authorLaszlo Ersek <lersek@redhat.com>
Wed, 26 Feb 2020 22:11:43 +0000 (23:11 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 4 Mar 2020 12:22:07 +0000 (12:22 +0000)
Clone the Null instance of SmmCpuPlatformHookLib from UefiCpuPkg to
OvmfPkg. In this patch, customize the lib instance only with the following
no-op steps:

- Replace Null/NULL references in filenames and comments with Qemu/QEMU
  references.
- Update copyright notices.
- Clean up and rewrap comment blocks.
- Update INF_VERSION to the latest INF spec version (1.29).
- Update FILE_GUID.
- Drop the UNI file.

This patch is best reviewed with:

$ git show --find-copies=43 --find-copies-harder

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1512
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200226221156.29589-4-lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
Tested-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c [new file with mode: 0644]
OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf [new file with mode: 0644]
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc

diff --git a/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.c
new file mode 100644 (file)
index 0000000..257e1d3
--- /dev/null
@@ -0,0 +1,108 @@
+/** @file\r
+SMM CPU Platform Hook library instance for QEMU.\r
+\r
+Copyright (c) 2020, Red Hat, Inc.\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+#include <PiSmm.h>\r
+#include <Library/SmmCpuPlatformHookLib.h>\r
+\r
+/**\r
+  Checks if platform produces a valid SMI.\r
+\r
+  This function checks if platform produces a valid SMI. This function is\r
+  called at SMM entry to detect if this is a spurious SMI. This function\r
+  must be implemented in an MP safe way because it is called by multiple CPU\r
+  threads.\r
+\r
+  @retval TRUE              There is a valid SMI\r
+  @retval FALSE             There is no valid SMI\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+PlatformValidSmi (\r
+  VOID\r
+  )\r
+{\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Clears platform top level SMI status bit.\r
+\r
+  This function clears platform top level SMI status bit.\r
+\r
+  @retval TRUE              The platform top level SMI status is cleared.\r
+  @retval FALSE             The platform top level SMI status cannot be\r
+                            cleared.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ClearTopLevelSmiStatus (\r
+  VOID\r
+  )\r
+{\r
+  return TRUE;\r
+}\r
+\r
+/**\r
+  Performs platform specific way of SMM BSP election.\r
+\r
+  This function performs platform specific way of SMM BSP election.\r
+\r
+  @param  IsBsp             Output parameter. TRUE: the CPU this function\r
+                            executes on is elected to be the SMM BSP. FALSE:\r
+                            the CPU this function executes on is to be SMM AP.\r
+\r
+  @retval EFI_SUCCESS       The function executes successfully.\r
+  @retval EFI_NOT_READY     The function does not determine whether this CPU\r
+                            should be BSP or AP. This may occur if hardware\r
+                            init sequence to enable the determination is yet to\r
+                            be done, or the function chooses not to do BSP\r
+                            election and will let SMM CPU driver to use its\r
+                            default BSP election process.\r
+  @retval EFI_DEVICE_ERROR  The function cannot determine whether this CPU\r
+                            should be BSP or AP due to hardware error.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformSmmBspElection (\r
+  OUT BOOLEAN     *IsBsp\r
+  )\r
+{\r
+  return EFI_NOT_READY;\r
+}\r
+\r
+/**\r
+  Get platform page table attribute.\r
+\r
+  This function gets page table attribute of platform.\r
+\r
+  @param  Address        Input parameter. Obtain the page table entries\r
+                         attribute on this address.\r
+  @param  PageSize       Output parameter. The size of the page.\r
+  @param  NumOfPages     Output parameter. Number of page.\r
+  @param  PageAttribute  Output parameter. Paging Attributes (WB, UC, etc).\r
+\r
+  @retval EFI_SUCCESS      The platform page table attribute from the address\r
+                           is determined.\r
+  @retval EFI_UNSUPPORTED  The platform does not support getting page table\r
+                           attribute for the address.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetPlatformPageTableAttribute (\r
+  IN  UINT64                Address,\r
+  IN OUT SMM_PAGE_SIZE_TYPE *PageSize,\r
+  IN OUT UINTN              *NumOfPages,\r
+  IN OUT UINTN              *PageAttribute\r
+  )\r
+{\r
+  return EFI_UNSUPPORTED;\r
+}\r
diff --git a/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf b/OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf
new file mode 100644 (file)
index 0000000..82edeca
--- /dev/null
@@ -0,0 +1,29 @@
+## @file\r
+#  SMM CPU Platform Hook library instance for QEMU.\r
+#\r
+#  Copyright (c) 2020, Red Hat, Inc.\r
+#  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 1.29\r
+  BASE_NAME                      = SmmCpuPlatformHookLibQemu\r
+  FILE_GUID                      = 154D6D26-54B8-45BC-BA3A-CBAA20C02A6A\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = SmmCpuPlatformHookLib\r
+\r
+#\r
+# The following information is for reference only and not required by the build\r
+# tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  SmmCpuPlatformHookLibQemu.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
index b5ee44bc7810b1da86588648bf49ef8faf8c8d36..c2d727730c04fd2dcc85c366cdb42e526c44b0f0 100644 (file)
   }\r
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {\r
     <LibraryClasses>\r
-      SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf\r
+      SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf\r
       SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf\r
   }\r
 \r
index 28fc4cbec66d19cd02e8e8aa044f31181f0911bc..7d862232b23efdca98d1e42f86695a02035b4581 100644 (file)
   }\r
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {\r
     <LibraryClasses>\r
-      SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf\r
+      SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf\r
       SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf\r
   }\r
 \r
index 880d9d21e86bfd4c4bcac9de51ddf214055becc7..c49703c994b3b3c26cc4882e0cf44bf052e2f4b9 100644 (file)
   }\r
   UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {\r
     <LibraryClasses>\r
-      SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf\r
+      SmmCpuPlatformHookLib|OvmfPkg/Library/SmmCpuPlatformHookLibQemu/SmmCpuPlatformHookLibQemu.inf\r
       SmmCpuFeaturesLib|OvmfPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf\r
   }\r
 \r