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>
#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
\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
#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
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