]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 13 Aug 2019 11:31:17 +0000 (12:31 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 21 Aug 2019 16:03:50 +0000 (18:03 +0200)
XenIoPvhDxe use XenIoMmioLib to reserve some space to be use by the
Grant Tables.

The call is only done if it is necessary, we simply detect if the
guest is PVH, as in this case there is currently no PCI bus, and no
PCI Xen platform device which would start the XenIoPciDxe and allocate
the space for the Grant Tables.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190813113119.14804-34-anthony.perard@citrix.com>

Maintainers.txt
OvmfPkg/OvmfXen.dsc
OvmfPkg/OvmfXen.fdf
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c [new file with mode: 0644]
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf [new file with mode: 0644]

index 78e9f889abf64b5a22e7b99dc8246417cb8b3f46..79defd13bf81513374f2d826aa45335bfd7a3718 100644 (file)
@@ -382,6 +382,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c\r
 F: OvmfPkg/XenBusDxe/\r
 F: OvmfPkg/XenIoPciDxe/\r
+F: OvmfPkg/XenIoPvhDxe/\r
 F: OvmfPkg/XenPlatformPei/\r
 F: OvmfPkg/XenPvBlkDxe/\r
 F: OvmfPkg/XenResetVector/\r
index e719a168f81e180bc127783c159e4cd7589d15a2..5e07b372797f257da7ed8ca1c89190a2f854cae6 100644 (file)
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf\r
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf\r
   XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf\r
+  XenIoMmioLib|OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf\r
 \r
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf\r
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf\r
       NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf\r
 !endif\r
   }\r
+  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf\r
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf\r
   OvmfPkg/XenBusDxe/XenBusDxe.inf\r
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf\r
index 5c1a925d6a88231ceef18ec5d3d0be0f2153d85a..517a492f1452393d3b4b2f61ebec0ebf5118e540 100644 (file)
@@ -309,6 +309,7 @@ INF  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
 INF  MdeModulePkg/Universal/Metronome/Metronome.inf\r
 INF  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
 \r
+INF  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf\r
 INF  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf\r
 INF  OvmfPkg/XenBusDxe/XenBusDxe.inf\r
 INF  OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf\r
diff --git a/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
new file mode 100644 (file)
index 0000000..9264a85
--- /dev/null
@@ -0,0 +1,54 @@
+/** @file\r
+\r
+  Driver for the XenIo protocol\r
+\r
+  This driver simply allocate space for the grant tables.\r
+\r
+  Copyright (c) 2019, Citrix Systems, Inc.\r
+\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/XenIoMmioLib.h>\r
+#include <Library/XenPlatformLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeXenIoPvhDxe (\r
+  IN EFI_HANDLE       ImageHandle,\r
+  IN EFI_SYSTEM_TABLE *SystemTable\r
+  )\r
+{\r
+  VOID          *Allocation;\r
+  EFI_STATUS    Status;\r
+  EFI_HANDLE    XenIoHandle;\r
+\r
+  Allocation = NULL;\r
+  XenIoHandle = NULL;\r
+\r
+  if (!XenPvhDetected ()) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));\r
+  if (Allocation == NULL) {\r
+    Status = EFI_OUT_OF_RESOURCES;\r
+    goto Error;\r
+  }\r
+\r
+  Status = XenIoMmioInstall (&XenIoHandle, (UINTN) Allocation);\r
+  if (EFI_ERROR (Status)) {\r
+    goto Error;\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+\r
+Error:\r
+  if (Allocation != NULL) {\r
+    FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));\r
+  }\r
+  return Status;\r
+}\r
diff --git a/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf b/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
new file mode 100644 (file)
index 0000000..1c27f8a
--- /dev/null
@@ -0,0 +1,36 @@
+## @file\r
+#  Driver for the XenIo protocol\r
+#\r
+#  Copyright (c) 2019, Citrix Systems, Inc.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION               = 0x00010005\r
+  BASE_NAME                 = XenIoPvhDxe\r
+  FILE_GUID                 = 7a567cc4-0e75-4d7a-a305-c3db109b53ad\r
+  MODULE_TYPE               = DXE_DRIVER\r
+  VERSION_STRING            = 1.0\r
+  ENTRY_POINT               = InitializeXenIoPvhDxe\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[Sources]\r
+  XenIoPvhDxe.c\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  PcdLib\r
+  UefiDriverEntryPoint\r
+  XenIoMmioLib\r
+  XenPlatformLib\r
+\r
+[FixedPcd]\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames\r
+\r
+[Depex]\r
+  TRUE\r