Revision: 17001
http://sourceforge.net/p/edk2/code/17001
Author: lersek
Date: 2015-03-03 08:13:40 +0000 (Tue, 03 Mar 2015)
Log Message:
-----------
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 <[email protected]>
Suggested-by: Jordan Justen <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Ard Biesheuvel <[email protected]>
Tested-by: Ard Biesheuvel <[email protected]>
Modified Paths:
--------------
trunk/edk2/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
trunk/edk2/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
trunk/edk2/OvmfPkg/XenBusDxe/XenBusDxe.c
Modified:
trunk/edk2/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
===================================================================
---
trunk/edk2/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
2015-03-03 08:13:30 UTC (rev 17000)
+++
trunk/edk2/OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c
2015-03-03 08:13:40 UTC (rev 17001)
@@ -40,6 +40,10 @@
VOID
)
{
+ if (! XenHypercallIsAvailable ()) {
+ return RETURN_NOT_FOUND;
+ }
+
if (!mXenConsoleInterface) {
mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam
(HVM_PARAM_CONSOLE_EVTCHN);
mXenConsoleInterface = (struct xencons_interface *)(UINTN)
Modified: trunk/edk2/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
===================================================================
--- trunk/edk2/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
2015-03-03 08:13:30 UTC (rev 17000)
+++ trunk/edk2/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
2015-03-03 08:13:40 UTC (rev 17001)
@@ -65,7 +65,13 @@
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;
Modified: trunk/edk2/OvmfPkg/XenBusDxe/XenBusDxe.c
===================================================================
--- trunk/edk2/OvmfPkg/XenBusDxe/XenBusDxe.c 2015-03-03 08:13:30 UTC (rev
17000)
+++ trunk/edk2/OvmfPkg/XenBusDxe/XenBusDxe.c 2015-03-03 08:13:40 UTC (rev
17001)
@@ -165,6 +165,7 @@
@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 @@
{
EFI_STATUS Status;
+ if (! XenHypercallIsAvailable ()) {
+ return EFI_ABORTED;
+ }
+
//
// Install UEFI Driver Model protocol(s).
//
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits