]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: replace strict XenHypercallLib construction with explicit query
authorLaszlo Ersek <lersek@redhat.com>
Tue, 3 Mar 2015 08:13:40 +0000 (08:13 +0000)
committerlersek <lersek@Edk2>
Tue, 3 Mar 2015 08:13:40 +0000 (08:13 +0000)
XenHypercallLib has two clients at the moment: XenBusDxe and
XenConsoleSerialPortLib. Currently, when XenBusDxe starts on a non-Xen X86
platform (ie. as part of OVMF not running on Xen), the X86XenHypercallLib
instance built into it fails to initialize, which triggers an ASSERT() in
auto-generated code.

Instead, let's call XenHypercallIsAvailable() in the driver's entry point,
and exit cleanly when the driver is started on a non-Xen platform.

Modify the constructor of XenConsoleSerialPortLib similarly; we shouldn't
proceed if Xen is not available. In practice this check should never fail,
because XenConsoleSerialPortLib is only used on ARM, and
ArmXenHypercallLib is always available; but nonetheless we should be
pedantic.

Reported-by: Gabriel L. Somlo <gsomlo@gmail.com>
Suggested-by: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17001 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
OvmfPkg/XenBusDxe/XenBusDxe.c

index 98022354cf31003d259ff63ede1961fa73e7bb7b..467cb27a30c48a75e5b9a7f88b3def1608e7bd76 100644 (file)
@@ -40,6 +40,10 @@ SerialPortInitialize (
   VOID\r
   )\r
 {\r
+  if (! XenHypercallIsAvailable ()) {\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+\r
   if (!mXenConsoleInterface) {\r
     mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN);\r
     mXenConsoleInterface = (struct xencons_interface *)(UINTN)\r
index 67892bcf37e48b8b95756e0a94b8dff29d17bb62..7cb7f46c9b7917342d21029fe46d0775a3f2ae19 100644 (file)
@@ -65,7 +65,13 @@ XenHypercallLibInit (
 \r
   GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
   if (GuidHob == NULL) {\r
-    return RETURN_NOT_FOUND;\r
+    //\r
+    // We don't fail library construction, since that has catastrophic\r
+    // consequences for client modules (whereas those modules may easily be\r
+    // running on a non-Xen platform). Instead, XenHypercallIsAvailable() above\r
+    // will return FALSE.\r
+    //\r
+    return RETURN_SUCCESS;\r
   }\r
   XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
   HyperPage = XenInfo->HyperPages;\r
index 2c4a08673ce64ff8a81c721ae4ee34cfa7d23a33..439b060ddcea545e845e7e1724cfb0254fdf7c97 100644 (file)
@@ -165,6 +165,7 @@ XenBusDxeUnload (
   @param  SystemTable           A pointer to the EFI System Table.\r
 \r
   @retval EFI_SUCCESS           The operation completed successfully.\r
+  @retval EFI_ABORTED           Xen hypercalls are not available.\r
   @retval Others                An unexpected error occurred.\r
 **/\r
 EFI_STATUS\r
@@ -176,6 +177,10 @@ XenBusDxeDriverEntryPoint (
 {\r
   EFI_STATUS  Status;\r
 \r
+  if (! XenHypercallIsAvailable ()) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
   //\r
   // Install UEFI Driver Model protocol(s).\r
   //\r