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.web12.15912.1588626186324179560 for ; Mon, 04 May 2020 14:03:06 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=rDNKL4n+; spf=pass (domain: oracle.com, ip: 156.151.31.85, mailfrom: nikita.leshchenko@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 044Kve0m074437; Mon, 4 May 2020 21:03:03 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=z1d/cW6ysxOe4084q8a327im/DMJe2uCVSlckflIIuU=; b=rDNKL4n+5eOECVfnKpWpa25K4+AlIsEu6+123OnE9HDiTtKBNzaMK5rcU5gBLsvf1hLl nJ58ft4BgK03fN0vhuExoHtqaeFerW0shDEcvmIhzeUxBDLqa23QDVnjPB1jxJQ20iF/ DXg47dwILdGTwDkqtzxPNpL4Tog5W1KN5qZEgUQ6vn41uZvQvcuk4wkbVbYalfT3AUE7 1hkjSHaO/KovyFwNx0x5UP7lryc7NASYSRw/QAVEJy3ADxaAZgZZnO9kCAr/SDNyQfT8 pvK3cOPdlxc8G0Ru7JVU/YHGZHXwCGdo+xS93uZ1NLK+UlqG6+ycbKI3C34vkCv7zjke hw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 30s1gn165v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 May 2020 21:03:03 +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 044L2aTx179666; Mon, 4 May 2020 21:03:03 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 30sjjwubhh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 04 May 2020 21:03:03 +0000 Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 044L31lL012127; Mon, 4 May 2020 21:03:01 GMT Received: from spark.ravello.local (/213.57.127.2) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 04 May 2020 14:03:01 -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 v6 12/12] OvmfPkg/MptScsiDxe: Reset device on ExitBootServices() Date: Tue, 5 May 2020 00:06:07 +0300 Message-Id: <20200504210607.144434-13-nikita.leshchenko@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200504210607.144434-1-nikita.leshchenko@oracle.com> References: <20200504210607.144434-1-nikita.leshchenko@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005040164 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9611 signatures=668687 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 phishscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005040163 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 Reviewed-by: Laszlo Ersek --- OvmfPkg/MptScsiDxe/MptScsi.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c index 842c5a1b5921..a1e2d90cee05 100644 --- a/OvmfPkg/MptScsiDxe/MptScsi.c +++ b/OvmfPkg/MptScsiDxe/MptScsi.c @@ -59,6 +59,7 @@ typedef struct { UINT32 StallPerPollUsec; EFI_PCI_IO_PROTOCOL *PciIo; UINT64 OriginalPciAttributes; + EFI_EVENT ExitBoot; MPT_SCSI_DMA_BUFFER *Dma; EFI_PHYSICAL_ADDRESS DmaPhysical; VOID *DmaMapping; @@ -762,6 +763,20 @@ MptScsiResetChannel ( return EFI_UNSUPPORTED; } +STATIC +VOID +EFIAPI +MptScsiExitBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + MPT_SCSI_DEV *Dev; + + Dev = Context; + DEBUG ((DEBUG_VERBOSE, "%a: Context=0x%p\n", __FUNCTION__, Context)); + MptScsiReset (Dev); +} STATIC EFI_STATUS EFIAPI @@ -955,6 +970,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 // @@ -979,11 +1005,14 @@ MptScsiControllerStart ( &Dev->PassThru ); if (EFI_ERROR (Status)) { - goto UninitDev; + goto CloseExitBoot; } return EFI_SUCCESS; +CloseExitBoot: + gBS->CloseEvent (Dev->ExitBoot); + UninitDev: MptScsiReset (Dev); @@ -1059,6 +1088,8 @@ MptScsiControllerStop ( return Status; } + gBS->CloseEvent (Dev->ExitBoot); + MptScsiReset (Dev); Dev->PciIo->Unmap ( -- 2.20.1