From nobody Mon Feb 9 22:37:55 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+55871+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55871+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1584373398; cv=none; d=zohomail.com; s=zohoarc; b=JNb2f63D5pENMubVegaWEDWIFscfoDc9Vq4Kb+vXWl3CLf4Yx96jGNFL5NBOUTvFecpGNNJRrMyaPCkdd4Zt8FJ1eZXXDO3rEkD6/xbAGSp3bTEi3dcNBgDZPpQfFVIAkHbOryuKFwHR7Fq0+nqCD4ypaxZHv3fl6XSJUhUrKGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1584373398; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=pF5eAJ8AdazSkD+pyWG0VYo+sJ9H//Q1RT2IewRYGnQ=; b=j17GOWaFOcWyrZ+bpJlqRtHmCoUOabU1+Vp58hwornvXsKDwm9kJa2WvdS3IZ9qlrk5ivY4lx15YocV2jVycLRpPReJ/EK5ySEfCTsOXUP2GHu7hJGzcTntml/ZfkEV3F0PG9WQJJHhEKWEeAPifBT0uEXu63tpWMFZwqk7AnD4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+55871+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1584373398707193.51974830036158; Mon, 16 Mar 2020 08:43:18 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id KZmEYY1788612xWzt3e60X7a; Mon, 16 Mar 2020 08:43:18 -0700 X-Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.69788.1584370847580385851 for ; Mon, 16 Mar 2020 08:00:47 -0700 X-Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GEqiOK088812; Mon, 16 Mar 2020 15:00:47 GMT X-Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2yrppqyfep-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:45 +0000 X-Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02GEpSq7074323; Mon, 16 Mar 2020 15:00:44 GMT X-Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserp3020.oracle.com with ESMTP id 2ys929uur7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Mar 2020 15:00:44 +0000 X-Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02GF0gKA011699; Mon, 16 Mar 2020 15:00:43 GMT X-Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Mar 2020 08:00:42 -0700 From: "Liran Alon" To: devel@edk2.groups.io, lersek@redhat.com Cc: nikita.leshchenko@oracle.com, aaron.young@oracle.com, jordan.l.justen@intel.com, ard.biesheuvel@linaro.org, Liran Alon Subject: [edk2-devel] [PATCH 16/17] OvmfPkg/PvScsiDxe: Reset device on ExitBootServices() Date: Mon, 16 Mar 2020 17:01:12 +0200 Message-Id: <20200316150113.104630-17-liran.alon@oracle.com> In-Reply-To: <20200316150113.104630-1-liran.alon@oracle.com> References: <20200316150113.104630-1-liran.alon@oracle.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,liran.alon@oracle.com X-Gm-Message-State: Ffu5wMczPOII9ZWAtyPL1pSix1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1584373398; bh=zYAfo29kldkeuEs7iTizZD5KKjGVcP2iCd1RQH1SDYc=; h=Cc:Date:From:Reply-To:Subject:To; b=FVc/GUzbaz6xRPhsvlLdXowxksywU0K9E3Qk0XxgOb8F/jmZ3Is4ZaMuj8NZ+UtxlhQ y/VpjKp7wr6XLaTWk3y1903x3vY9MxcyHltHjy5acTeLY7zVm1RQBqAVmTJilGIoXVpAa TOc5afT3IoC5CRFTxpvHcEGXw74eo8/n5i8= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" This causes the device to forget about the request/completion rings. We allocated said rings in EfiBootServicesData type memory, and code executing after ExitBootServices() is permitted to overwrite it. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2567 Reviewed-by: Nikita Leshenko Signed-off-by: Liran Alon Reviewed-by: Laszlo Ersek --- OvmfPkg/PvScsiDxe/PvScsi.c | 42 +++++++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index e7d0a23db6ab..33167c177b42 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -1156,6 +1156,30 @@ PvScsiUninit ( } } =20 +// +// Event notification called by ExitBootServices() +// +STATIC +VOID +EFIAPI +PvScsiExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + PVSCSI_DEV *Dev; + + Dev =3D Context; + + // + // Reset the device. This causes the device to forget about the + // request/completion rings. We allocated said rings in EfiBootServicesD= ata + // type memory, and code executing after ExitBootServices() is permitted= to + // overwrite it. + // + PvScsiWriteCmdDesc (Dev, PVSCSI_CMD_ADAPTER_RESET, NULL, 0); +} + // // Driver Binding // @@ -1249,6 +1273,17 @@ PvScsiDriverBindingStart ( goto ClosePciIo; } =20 + Status =3D gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + &PvScsiExitBoot, + Dev, + &Dev->ExitBoot + ); + if (EFI_ERROR (Status)) { + goto UninitDev; + } + // // Setup complete, attempt to export the driver instance's PassThru inte= rface // @@ -1260,11 +1295,14 @@ PvScsiDriverBindingStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } =20 return EFI_SUCCESS; =20 +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: PvScsiUninit (Dev); =20 @@ -1319,6 +1357,8 @@ PvScsiDriverBindingStop ( return Status; } =20 + gBS->CloseEvent (Dev->ExitBoot); + PvScsiUninit (Dev); =20 gBS->CloseProtocol ( diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 08e876b75930..e68a7dedf71f 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -41,6 +41,7 @@ typedef struct { typedef struct { UINT32 Signature; EFI_PCI_IO_PROTOCOL *PciIo; + EFI_EVENT ExitBoot; UINT64 OriginalPciAttributes; PVSCSI_RING_DESC RingDesc; PVSCSI_DMA_BUFFER *DmaBuf; --=20 2.20.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#55871): https://edk2.groups.io/g/devel/message/55871 Mute This Topic: https://groups.io/mt/72001273/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-