]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/XenHypercallLib: Enable it in PEIM
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 13 Aug 2019 11:31:00 +0000 (12:31 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 21 Aug 2019 16:03:49 +0000 (18:03 +0200)
Allow to use Xen hypercalls earlier, during the PEIM stage, but
XenHypercallLibInit() must be called once the XenInfo HOB is created
with the HyperPage setup.

Change the return value of XenHypercallLibInit so failure can be
detected when the call shouldn't fail, but still have the constructor
always succeed.

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-17-anthony.perard@citrix.com>

OvmfPkg/Include/Library/XenHypercallLib.h
OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
OvmfPkg/Library/XenHypercallLib/XenHypercall.c
OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf

index c43822782b9176a097e1ce39383224bcf6792abe..c1491dd652b3ef14a614714246594b8c966e027d 100644 (file)
 #ifndef __XEN_HYPERCALL_LIB_H__\r
 #define __XEN_HYPERCALL_LIB_H__\r
 \r
+/**\r
+  To call when the gEfiXenInfoGuid HOB became available after the library init\r
+  function has already been executed.\r
+\r
+  This allow to make hypercall in the PEIM stage.\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+XenHypercallLibInit (\r
+  VOID\r
+  );\r
+\r
 /**\r
   Check if the Xen Hypercall library is able to make calls to the Xen\r
   hypervisor.\r
index 27083f924f8b77248b18746d3d930bbc098d6fc1..f779e46470b86ea3d7c929e4d484963950254eb3 100644 (file)
@@ -59,13 +59,7 @@ XenHypercallLibInit (
 \r
   GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
   if (GuidHob == NULL) {\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
+    return RETURN_NOT_FOUND;\r
   }\r
   XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
   HyperPage = XenInfo->HyperPages;\r
index a2c41a2a69b68b08f7bbe5f5791a4a5f788130cd..d4fa802743de22eaae13ccd8f086c82105f602d1 100644 (file)
 #include <Library/DebugLib.h>\r
 #include <Library/XenHypercallLib.h>\r
 \r
+RETURN_STATUS\r
+EFIAPI\r
+XenHypercallLibConstruct (\r
+  VOID\r
+  )\r
+{\r
+  XenHypercallLibInit ();\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()\r
+  // will return FALSE.\r
+  //\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
 UINT64\r
 EFIAPI\r
 XenHypercallHvmGetParam (\r
index 1208f0057a36f3ecb099ef616f57e4161de3dd5c..21ce5b443471106bb26808a991a70cd992080d61 100644 (file)
   FILE_GUID                      = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C\r
   MODULE_TYPE                    = BASE\r
   VERSION_STRING                 = 1.0\r
-  CONSTRUCTOR                    = XenHypercallLibInit\r
+  CONSTRUCTOR                    = XenHypercallLibConstruct\r
 \r
 [Defines.IA32, Defines.X64]\r
-  LIBRARY_CLASS                  = XenHypercallLib|DXE_DRIVER UEFI_DRIVER\r
+  LIBRARY_CLASS                  = XenHypercallLib|PEIM DXE_DRIVER UEFI_DRIVER\r
 \r
 [Defines.ARM, Defines.AARCH64]\r
   LIBRARY_CLASS                  = XenHypercallLib\r