From 48b3ff047929aa5bd4f94128c9a3ac04d6b3b31b Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 3 Mar 2015 08:13:40 +0000 Subject: 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 Suggested-by: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Jordan Justen Reviewed-by: Ard Biesheuvel Tested-by: Ard Biesheuvel git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17001 6f19259b-4bc3-4df7-8a09-765794883524 --- OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'OvmfPkg/Library/XenConsoleSerialPortLib/XenConsoleSerialPortLib.c') 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) -- cgit v1.2.3