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.web10.728.1586885763465725986 for ; Tue, 14 Apr 2020 10:36:03 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=XwgBazwX; spf=pass (domain: oracle.com, ip: 156.151.31.86, mailfrom: nikita.leshchenko@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 03EHAoGd141445; Tue, 14 Apr 2020 17:36:00 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=RwIuZgjOWaIlzaDQaQ/cFyTjGFg0SMIdp/ZkaL4lJ4g=; b=XwgBazwXT2+d1gGE+zIOzovX6OXA4muXjqHKI869O2FmvohxzZOTAQAQg3lKhe1xV5yr szdZcyEq20M10KwFg5awJI3OYA+lOeEcT8/Cq0gKzDZZ6qXTZ2TCbYSZRKp3wkRjoTjG Ks8hgHRMMA8kJAqc+lkKnfJzZi0GMLhuYQfHHmguSoBDrgVfIDiIfC2YbMlG2rfN61n1 UduZ+uHs4scKQPzt7NAhLchqhvMwIsBmU05H2I4Xz1w+Eqt61iGyRW1drlmFXdQNcWC0 UDZyDdPiKb6WB/HhBOzMisP71qy/7doZ8xF4wRwv7nbD32cR03+MTBnrAGS3jg3o/6/p Fg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 30b5ar68s7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:36:00 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 03EH7RE1130567; Tue, 14 Apr 2020 17:35:59 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 30bqm2e2pm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Apr 2020 17:35:59 +0000 Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 03EHZwr5026975; Tue, 14 Apr 2020 17:35:58 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 14 Apr 2020 10:35:58 -0700 From: "Nikita Leshenko" To: devel@edk2.groups.io Cc: Nikita Leshenko , liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Laszlo Ersek , Ard Biesheuvel Subject: [PATCH v4 13/13] OvmfPkg/MptScsiDxe: Reset device on ExitBootServices() Date: Tue, 14 Apr 2020 20:38:13 +0300 Message-Id: <20200414173813.7715-14-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200414173813.7715-1-nikita.leshchenko@oracle.com> References: <20200414173813.7715-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 phishscore=0 malwarescore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9591 signatures=668686 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 impostorscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 phishscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2004140131 Content-Transfer-Encoding: 8bit This causes the device to forget about the reply frame. We allocated the reply frame in EfiBootServicesData type memory, and code executing after ExitBootServices() is permitted to overwrite it. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2390 Signed-off-by: Nikita Leshenko --- OvmfPkg/MptScsiDxe/MptScsi.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 3ea08857df5d..e632b076fc4a 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -45,6 +45,7 @@ typedef struct { EFI_EXT_SCSI_PASS_THRU_MODE PassThruMode; EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; + EFI_EVENT ExitBoot; UINT32 StallPerPollUsec; UINT8 MaxTarget; MPT_SCSI_DMA_BUFFER *Dma; @@ -696,6 +697,19 @@ MptScsiResetChannel ( return EFI_UNSUPPORTED; } +STATIC +VOID +EFIAPI +MptScsiExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + MPT_SCSI_DEV *Dev; + + Dev = Context; + MptScsiReset (Dev); +} STATIC EFI_STATUS EFIAPI @@ -861,6 +875,17 @@ MptScsiControllerStart ( goto Unmap; } + Status = gBS->CreateEvent ( + EVT_SIGNAL_EXIT_BOOT_SERVICES, + TPL_CALLBACK, + &MptScsiExitBoot, + Dev, + &Dev->ExitBoot + ); + if (EFI_ERROR (Status)) { + goto UninitDev; + } + // // Host adapter channel, doesn't exist // @@ -885,11 +910,14 @@ MptScsiControllerStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } return EFI_SUCCESS; +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: MptScsiReset (Dev); @@ -964,6 +992,8 @@ MptScsiControllerStop ( return Status; } + gBS->CloseEvent (Dev->ExitBoot); + MptScsiReset (Dev); Dev->PciIo->Unmap ( -- 2.20.1