summaryrefslogtreecommitdiffstats
path: root/OvmfPkg
diff options
context:
space:
mode:
authorAnthony PERARD <anthony.perard@citrix.com>2019-08-13 12:31:00 +0100
committerLaszlo Ersek <lersek@redhat.com>2019-08-21 18:03:49 +0200
commit68f4599dfc6ae841308e3fbce9121cbd311994f3 (patch)
tree2ee07f83adc2b222d40476193b9620057e90c13a /OvmfPkg
parent2a4a6242b71721024971df56d4f28e0aa63dd4d8 (diff)
downloadedk2-68f4599dfc6ae841308e3fbce9121cbd311994f3.tar.gz
edk2-68f4599dfc6ae841308e3fbce9121cbd311994f3.tar.bz2
edk2-68f4599dfc6ae841308e3fbce9121cbd311994f3.zip
OvmfPkg/XenHypercallLib: Enable it in PEIM
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>
Diffstat (limited to 'OvmfPkg')
-rw-r--r--OvmfPkg/Include/Library/XenHypercallLib.h12
-rw-r--r--OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c8
-rw-r--r--OvmfPkg/Library/XenHypercallLib/XenHypercall.c16
-rw-r--r--OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf4
4 files changed, 31 insertions, 9 deletions
diff --git a/OvmfPkg/Include/Library/XenHypercallLib.h b/OvmfPkg/Include/Library/XenHypercallLib.h
index c43822782b..c1491dd652 100644
--- a/OvmfPkg/Include/Library/XenHypercallLib.h
+++ b/OvmfPkg/Include/Library/XenHypercallLib.h
@@ -11,6 +11,18 @@
#define __XEN_HYPERCALL_LIB_H__
/**
+ To call when the gEfiXenInfoGuid HOB became available after the library init
+ function has already been executed.
+
+ This allow to make hypercall in the PEIM stage.
+**/
+RETURN_STATUS
+EFIAPI
+XenHypercallLibInit (
+ VOID
+ );
+
+/**
Check if the Xen Hypercall library is able to make calls to the Xen
hypervisor.
diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
index 27083f924f..f779e46470 100644
--- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
+++ b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
@@ -59,13 +59,7 @@ XenHypercallLibInit (
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
if (GuidHob == NULL) {
- //
- // We don't fail library construction, since that has catastrophic
- // consequences for client modules (whereas those modules may easily be
- // running on a non-Xen platform). Instead, XenHypercallIsAvailable() above
- // will return FALSE.
- //
- return RETURN_SUCCESS;
+ return RETURN_NOT_FOUND;
}
XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
HyperPage = XenInfo->HyperPages;
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
index a2c41a2a69..d4fa802743 100644
--- a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
+++ b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
@@ -15,6 +15,22 @@
#include <Library/DebugLib.h>
#include <Library/XenHypercallLib.h>
+RETURN_STATUS
+EFIAPI
+XenHypercallLibConstruct (
+ VOID
+ )
+{
+ XenHypercallLibInit ();
+ //
+ // We don't fail library construction, since that has catastrophic
+ // consequences for client modules (whereas those modules may easily be
+ // running on a non-Xen platform). Instead, XenHypercallIsAvailable()
+ // will return FALSE.
+ //
+ return RETURN_SUCCESS;
+}
+
UINT64
EFIAPI
XenHypercallHvmGetParam (
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
index 1208f0057a..21ce5b4434 100644
--- a/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
+++ b/OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
@@ -12,10 +12,10 @@
FILE_GUID = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C
MODULE_TYPE = BASE
VERSION_STRING = 1.0
- CONSTRUCTOR = XenHypercallLibInit
+ CONSTRUCTOR = XenHypercallLibConstruct
[Defines.IA32, Defines.X64]
- LIBRARY_CLASS = XenHypercallLib|DXE_DRIVER UEFI_DRIVER
+ LIBRARY_CLASS = XenHypercallLib|PEIM DXE_DRIVER UEFI_DRIVER
[Defines.ARM, Defines.AARCH64]
LIBRARY_CLASS = XenHypercallLib