From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by mx.groups.io with SMTP id smtpd.web12.14067.1585425555064701815 for ; Sat, 28 Mar 2020 12:59:15 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=rVDo/euN; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: liran.alon@oracle.com) 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 02SJnOrC014136; Sat, 28 Mar 2020 19:59:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2020-01-29; bh=ySfHBnO0M9Fv01DN6DOP4np6eEWhtNt5fM0OMetH1a4=; b=rVDo/euNxy8x5YnAK0eIDucFy5zfVcBoxQ7pzXXqXr+xBYaGwP74wMtctfmK4kbaInAU tyN9Xu1vDXllxwFUfjLrjuXKHbwPUffiuVATBjoZtnVKQyxlY/e44SX3gu94QPXMKrrJ t0rwSGk4VaZHkuhOtx0VW9k4HOEjg7FowZsfAcCkC+g6JGSza2m3TyZHwDE59ev/jtSF 3E69tvBQjxdL5m1MsvcASvLAoL/kXH04FuZ7jJNR1FLKV9nPl35ONDChDdqT7lqlNs83 bVefjRb8ZJKSKC/BBDyZQcjp0MMs+8qbS7bdtz13Z5kdiIvXxcjW6F+GMsRo1t13jHrY 7Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 301x0qsj8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:14 +0000 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 02SJpHaf050098; Sat, 28 Mar 2020 19:59:13 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3020.oracle.com with ESMTP id 301xd211et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 28 Mar 2020 19:59:13 +0000 Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02SJxD5x017199; Sat, 28 Mar 2020 19:59:13 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 28 Mar 2020 12:59:13 -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: [PATCH v3 16/17] OvmfPkg/PvScsiDxe: Reset device on ExitBootServices() Date: Sat, 28 Mar 2020 23:00:59 +0300 Message-Id: <20200328200100.60786-17-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200328200100.60786-1-liran.alon@oracle.com> References: <20200328200100.60786-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 phishscore=0 suspectscore=0 mlxscore=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9574 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 clxscore=1015 adultscore=0 mlxscore=0 priorityscore=1501 lowpriorityscore=0 mlxlogscore=999 bulkscore=0 phishscore=0 spamscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003280189 Content-Transfer-Encoding: 8bit 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=2567 Reviewed-by: Laszlo Ersek Signed-off-by: Liran Alon --- OvmfPkg/PvScsiDxe/PvScsi.c | 43 +++++++++++++++++++++++++++++++++++++- OvmfPkg/PvScsiDxe/PvScsi.h | 1 + 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PvScsiDxe/PvScsi.c b/OvmfPkg/PvScsiDxe/PvScsi.c index da3535c75220..d7f0d3c8790c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -1221,6 +1221,31 @@ PvScsiUninit ( PvScsiRestorePciAttributes (Dev); } +/** + Event notification called by ExitBootServices() +**/ +STATIC +VOID +EFIAPI +PvScsiExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + PVSCSI_DEV *Dev; + + Dev = Context; + DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context)); + + // + // Reset the device to stop device usage of the rings. + // + // We allocated said rings in EfiBootServicesData type memory, and code + // executing after ExitBootServices() is permitted to overwrite it. + // + PvScsiResetAdapter (Dev); +} + // // Driver Binding // @@ -1314,6 +1339,17 @@ PvScsiDriverBindingStart ( goto ClosePciIo; } + Status = 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 interface // @@ -1325,11 +1361,14 @@ PvScsiDriverBindingStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } return EFI_SUCCESS; +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: PvScsiUninit (Dev); @@ -1384,6 +1423,8 @@ PvScsiDriverBindingStop ( return Status; } + gBS->CloseEvent (Dev->ExitBoot); + PvScsiUninit (Dev); gBS->CloseProtocol ( diff --git a/OvmfPkg/PvScsiDxe/PvScsi.h b/OvmfPkg/PvScsiDxe/PvScsi.h index 02feac734743..544359ebc05c 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.h +++ b/OvmfPkg/PvScsiDxe/PvScsi.h @@ -51,6 +51,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; -- 2.20.1