summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c4
-rw-r--r--OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c8
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.c5
3 files changed, 16 insertions, 1 deletions
diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
index 98022354c..467cb27a3 100644
--- a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
+++ b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
@@ -40,6 +40,10 @@ SerialPortInitialize (
VOID
)
{
+ if (! XenHypercallIsAvailable ()) {
+ return RETURN_NOT_FOUND;
+ }
+
if (!mXenConsoleInterface) {
mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN);
mXenConsoleInterface = (struct xencons_interface *)(UINTN)
diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
index 67892bcf3..7cb7f46c9 100644
--- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
+++ b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
@@ -65,7 +65,13 @@ XenHypercallLibInit (
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
if (GuidHob == NULL) {
- return RETURN_NOT_FOUND;
+ //
+ // 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;
}
XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
HyperPage = XenInfo->HyperPages;
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
index 2c4a08673..439b060dd 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.c
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
@@ -165,6 +165,7 @@ XenBusDxeUnload (
@param SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The operation completed successfully.
+ @retval EFI_ABORTED Xen hypercalls are not available.
@retval Others An unexpected error occurred.
**/
EFI_STATUS
@@ -176,6 +177,10 @@ XenBusDxeDriverEntryPoint (
{
EFI_STATUS Status;
+ if (! XenHypercallIsAvailable ()) {
+ return EFI_ABORTED;
+ }
+
//
// Install UEFI Driver Model protocol(s).
//