From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) by mx.groups.io with SMTP id smtpd.web10.15226.1585152498924858036 for ; Wed, 25 Mar 2020 09:08:19 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=M4FWQ67v; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: liran.alon@oracle.com) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02PG8IGa031110; Wed, 25 Mar 2020 16:08:18 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=z3/t8zloFJ4wluSFCwlo/Ojn4vWr2P8zK7Abtj/W03o=; b=M4FWQ67vAT0MNmCxhYYW43yYo7Ub0cw2P8edaPpLgTzfFMnFYamsIz2IMnzqx4mG4W8Z 0O+5OCCerDkjj6WDzRIfG4aOyhv8/vkfCAYjtuGr5VIx9L0zMga6tarNZXqZsnWUxYyM BxKJnTHeIctBIPWK4kKUG/ETGxYcsXs3B26r2wgSJ8K2MaCGXWo9nlkLZyJyAPGEpAX2 cYwt+X7iw/BhOoEwepdQ8HPXM3jnTGEzamBor2w7Bb3vWb2PlyVfUwkdK3a3SM8oSpqH aWsaZn0xAs5x+WAbZoXErC/KsG2AuIQ0ragnDTlxtit/0BY94lo0KOx45x4juEss3f+P 2w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 3005kv9pjr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:08:18 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02PG2VKp083885; Wed, 25 Mar 2020 16:08:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3030.oracle.com with ESMTP id 2yxw4rrv1s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 Mar 2020 16:08:12 +0000 Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 02PG8BSX027157; Wed, 25 Mar 2020 16:08:11 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 25 Mar 2020 09:08:11 -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 v2 16/17] OvmfPkg/PvScsiDxe: Reset device on ExitBootServices() Date: Wed, 25 Mar 2020 18:10:04 +0200 Message-Id: <20200325161005.16743-17-liran.alon@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200325161005.16743-1-liran.alon@oracle.com> References: <20200325161005.16743-1-liran.alon@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250128 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9571 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 impostorscore=0 spamscore=0 adultscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 mlxscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003250129 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 de4122e39a81..42a18494efb7 100644 --- a/OvmfPkg/PvScsiDxe/PvScsi.c +++ b/OvmfPkg/PvScsiDxe/PvScsi.c @@ -1225,6 +1225,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. 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. + // + PvScsiWriteCmdDesc (Dev, PvScsiCmdAdapterReset, NULL, 0); +} + // // Driver Binding // @@ -1318,6 +1343,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 // @@ -1329,11 +1365,14 @@ PvScsiDriverBindingStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } return EFI_SUCCESS; +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: PvScsiUninit (Dev); @@ -1388,6 +1427,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 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; -- 2.20.1