From patchwork Fri Sep 13 14:51:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 11144889 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD6B714DB for ; Fri, 13 Sep 2019 15:12:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9953220640 for ; Fri, 13 Sep 2019 15:12:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="e0WzgLkx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9953220640 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i8nDW-0008GI-PZ; Fri, 13 Sep 2019 15:10:34 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i8nDV-0008G8-4V for xen-devel@lists.xenproject.org; Fri, 13 Sep 2019 15:10:33 +0000 X-Inumbo-ID: 9f57229d-d638-11e9-95ae-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9f57229d-d638-11e9-95ae-12813bfff9fa; Fri, 13 Sep 2019 15:10:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1568387430; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ITFjy2x5OkCUAwDcBerVqJU99vxj+sJ3ZPgRNJRyHgA=; b=e0WzgLkxhsvTzVA1LIZc8PPhRHABtCRkpGcydQRmSKLoMGXxFKjDaxex alVkNPs9iTdV6cD9W+3awNu/xmO2LkWy4AgE5GsNEEVQLpGN2HAPsnmII jD637lHnPSMOh/Y9fc68CQ23mOhUk5Iav6l2ACTPA3XRj+0arMeMhCJwB M=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=anthony.perard@citrix.com; spf=Pass smtp.mailfrom=anthony.perard@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of anthony.perard@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of anthony.perard@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="anthony.perard@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="anthony.perard@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: PUnTOLPs7rYqw+c+YwXX8tZtyXnY5cBfdAscbIj91Eq/nzPnOuK1SD3HhKlSe6GNvBVJwNYVzZ WBjQh6+m1mpmXKa3xQ3Ys3Uw+MKjJpVzQIINYuTbIzTsnwzEZoLYB38EJK02c4+T4qFYVPGaBh uyX6Cck5/AsUjg1ANjuuOnvayEa6qVjZn9InIWCyxNbr7im2Fl8+toiBEWxLY0r393iNuF/Vrr HXqr1oeCJEswBs5476XmRCCdfLpGqiCerwnlaFZz+VKxfpb/eD5sEB5/HvRdMUoeuocu3/pwg7 soc= X-SBRS: 2.7 X-MesageID: 5740999 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,501,1559534400"; d="scan'208";a="5740999" From: Anthony PERARD To: Date: Fri, 13 Sep 2019 15:51:00 +0100 Message-ID: <20190913145100.303433-12-anthony.perard@citrix.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190913145100.303433-1-anthony.perard@citrix.com> References: <20190913145100.303433-1-anthony.perard@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 11/11] OvmfPkg/XenBusDxe: Fix XenStoreWaitForEvent use during EBS X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel , Jordan Justen , Julien Grall , Anthony Perard , xen-devel@lists.xenproject.org, Laszlo Ersek Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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 --- OvmfPkg/XenBusDxe/XenBusDxe.c | 2 ++ OvmfPkg/XenBusDxe/XenBusDxe.h | 1 + OvmfPkg/XenBusDxe/XenStore.c | 13 +++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c index c71966a666..eb1503ad2b 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.c +++ b/OvmfPkg/XenBusDxe/XenBusDxe.c @@ -264,6 +264,8 @@ NotifyExitBoot ( Dev = Context; + Dev->ExitBootNotified = TRUE; + // // First, ask every driver using xenbus to disconnect without // deallocating memory. diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.h b/OvmfPkg/XenBusDxe/XenBusDxe.h index 0e91c24338..80162fc3ff 100644 --- a/OvmfPkg/XenBusDxe/XenBusDxe.h +++ b/OvmfPkg/XenBusDxe/XenBusDxe.h @@ -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; diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c index 4026c8a829..4f126109d4 100644 --- a/OvmfPkg/XenBusDxe/XenStore.c +++ b/OvmfPkg/XenBusDxe/XenStore.c @@ -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 {