diff options
author | Laszlo Ersek <lersek@redhat.com> | 2015-03-03 08:13:40 +0000 |
---|---|---|
committer | lersek <lersek@Edk2> | 2015-03-03 08:13:40 +0000 |
commit | 48b3ff047929aa5bd4f94128c9a3ac04d6b3b31b (patch) | |
tree | 0c9f56342687fd008565e919c3bac05a90b5b03b /OvmfPkg | |
parent | 02f69a25f0aa9f6dda38e2b72789136574928f93 (diff) | |
download | edk2-platforms-48b3ff047929aa5bd4f94128c9a3ac04d6b3b31b.tar.xz |
OvmfPkg: replace strict XenHypercallLib construction with explicit query
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
Diffstat (limited to 'OvmfPkg')
-rw-r--r-- | OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c | 4 | ||||
-rw-r--r-- | OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c | 8 | ||||
-rw-r--r-- | OvmfPkg/XenBusDxe/XenBusDxe.c | 5 |
3 files changed, 16 insertions, 1 deletions
diff --git a/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c b/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c index 98022354cf..467cb27a30 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 67892bcf37..7cb7f46c9b 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 2c4a08673c..439b060ddc 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).
//
|