@@ -264,6 +264,8 @@ NotifyExitBoot (
Dev = Context;
+ Dev->ExitBootNotified = TRUE;
+
//
// First, ask every driver using xenbus to disconnect without
// deallocating memory.
@@ -79,6 +79,7 @@ struct _XENBUS_DEVICE {
EFI_HANDLE ControllerHandle;
XENIO_PROTOCOL *XenIo;
EFI_EVENT ExitBootEvent;
+ BOOLEAN ExitBootNotified;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
LIST_ENTRY ChildList;
@@ -401,17 +401,22 @@ XenStoreWaitForEvent (
EFI_EVENT TimerEvent;
EFI_EVENT WaitList[2];
+ //
+ // If the ExitBootServices event have been signaled, simply allow to have
+ // busy loop in the caller.
+ //
+ if (xs.Dev->ExitBootNotified) {
+ return EFI_SUCCESS;
+ }
+
gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimerEvent);
gBS->SetTimer (TimerEvent, TimerRelative, Timeout);
WaitList[0] = xs.EventChannelEvent;
WaitList[1] = TimerEvent;
Status = gBS->WaitForEvent (2, WaitList, &Index);
- ASSERT (Status != EFI_INVALID_PARAMETER);
+ ASSERT_EFI_ERROR (Status);
gBS->CloseEvent (TimerEvent);
- if (Status == EFI_UNSUPPORTED) {
- return EFI_SUCCESS;
- }
if (Index == 1) {
return EFI_TIMEOUT;
} else {
XenStoreWaitForEvent is going to be called when the ExitBootServices is signaled, but both CreateEvent and WaitForEvent can't be used. CreateEvent allocate some memory and WaitForEvent can only be used when TPL is TPL_APPLICATION. When ExitBootServices has been called, simply return immediately and let caller of XenStoreWaitForEvent do a busy loop. Also cleanup error handling in XenStoreWaitForEvent, WaitForEvent shouldn't return EFI_UNSUPPORTED anymore. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2190 Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> --- OvmfPkg/XenBusDxe/XenBusDxe.c | 2 ++ OvmfPkg/XenBusDxe/XenBusDxe.h | 1 + OvmfPkg/XenBusDxe/XenStore.c | 13 +++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-)