Bladeren bron

OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables

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>
Anthony PERARD 4 jaren geleden
bovenliggende
commit
833cd3e0c0
5 gewijzigde bestanden met toevoegingen van 94 en 0 verwijderingen
  1. 1 0
      Maintainers.txt
  2. 2 0
      OvmfPkg/OvmfXen.dsc
  3. 1 0
      OvmfPkg/OvmfXen.fdf
  4. 54 0
      OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
  5. 36 0
      OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf

+ 1 - 0
Maintainers.txt

@@ -382,6 +382,7 @@ F: OvmfPkg/PlatformPei/Xen.*
 F: OvmfPkg/SmbiosPlatformDxe/*Xen.c
 F: OvmfPkg/XenBusDxe/
 F: OvmfPkg/XenIoPciDxe/
+F: OvmfPkg/XenIoPvhDxe/
 F: OvmfPkg/XenPlatformPei/
 F: OvmfPkg/XenPvBlkDxe/
 F: OvmfPkg/XenResetVector/

+ 2 - 0
OvmfPkg/OvmfXen.dsc

@@ -195,6 +195,7 @@
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
   XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
   XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf
+  XenIoMmioLib|OvmfPkg/Library/XenIoMmioLib/XenIoMmioLib.inf
 
   Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf
   TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf
@@ -583,6 +584,7 @@
       NULL|OvmfPkg/Csm/LegacyBootMaintUiLib/LegacyBootMaintUiLib.inf
 !endif
   }
+  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
   OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
   OvmfPkg/XenBusDxe/XenBusDxe.inf
   OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf

+ 1 - 0
OvmfPkg/OvmfXen.fdf

@@ -309,6 +309,7 @@ INF  MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf
 INF  MdeModulePkg/Universal/Metronome/Metronome.inf
 INF  PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
 
+INF  OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf
 INF  OvmfPkg/XenIoPciDxe/XenIoPciDxe.inf
 INF  OvmfPkg/XenBusDxe/XenBusDxe.inf
 INF  OvmfPkg/XenPvBlkDxe/XenPvBlkDxe.inf

+ 54 - 0
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c

@@ -0,0 +1,54 @@
+/** @file
+
+  Driver for the XenIo protocol
+
+  This driver simply allocate space for the grant tables.
+
+  Copyright (c) 2019, Citrix Systems, Inc.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
+#include <Library/XenIoMmioLib.h>
+#include <Library/XenPlatformLib.h>
+
+EFI_STATUS
+EFIAPI
+InitializeXenIoPvhDxe (
+  IN EFI_HANDLE       ImageHandle,
+  IN EFI_SYSTEM_TABLE *SystemTable
+  )
+{
+  VOID          *Allocation;
+  EFI_STATUS    Status;
+  EFI_HANDLE    XenIoHandle;
+
+  Allocation = NULL;
+  XenIoHandle = NULL;
+
+  if (!XenPvhDetected ()) {
+    return EFI_UNSUPPORTED;
+  }
+
+  Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));
+  if (Allocation == NULL) {
+    Status = EFI_OUT_OF_RESOURCES;
+    goto Error;
+  }
+
+  Status = XenIoMmioInstall (&XenIoHandle, (UINTN) Allocation);
+  if (EFI_ERROR (Status)) {
+    goto Error;
+  }
+
+  return EFI_SUCCESS;
+
+Error:
+  if (Allocation != NULL) {
+    FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));
+  }
+  return Status;
+}

+ 36 - 0
OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.inf

@@ -0,0 +1,36 @@
+## @file
+#  Driver for the XenIo protocol
+#
+#  Copyright (c) 2019, Citrix Systems, Inc.
+#
+#  SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+  INF_VERSION               = 0x00010005
+  BASE_NAME                 = XenIoPvhDxe
+  FILE_GUID                 = 7a567cc4-0e75-4d7a-a305-c3db109b53ad
+  MODULE_TYPE               = DXE_DRIVER
+  VERSION_STRING            = 1.0
+  ENTRY_POINT               = InitializeXenIoPvhDxe
+
+[Packages]
+  MdePkg/MdePkg.dec
+  OvmfPkg/OvmfPkg.dec
+
+[Sources]
+  XenIoPvhDxe.c
+
+[LibraryClasses]
+  MemoryAllocationLib
+  PcdLib
+  UefiDriverEntryPoint
+  XenIoMmioLib
+  XenPlatformLib
+
+[FixedPcd]
+  gUefiOvmfPkgTokenSpaceGuid.PcdXenGrantFrames
+
+[Depex]
+  TRUE