From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.120]) by mx.groups.io with SMTP id smtpd.web11.3995.1588240130120373859 for ; Thu, 30 Apr 2020 02:48:50 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fzk2be4o; spf=pass (domain: redhat.com, ip: 207.211.31.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588240129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6/qDNf8AlJyYfrDjZsOZjFhtkR6ITxyRBY0Oih6png0=; b=fzk2be4oMWkV77J2GG+eSKuNKd5E9mDzqkJrC1O/+i6k0tZbvAFiRnpMCszNMGIvXuxI23 dK7txSY1AUtNf8PF4P+7YLGa3eUZhkNSHIazlF7EObhsSt3H9GTPuw63YWl3/7oW+YLj1W r+uy2944LBu88QaAVigEMFwfzux45Xo= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-I02XOepTMCKxJvQxnlx8_A-1; Thu, 30 Apr 2020 05:48:45 -0400 X-MC-Unique: I02XOepTMCKxJvQxnlx8_A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B88F41005510; Thu, 30 Apr 2020 09:48:43 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-115-57.ams2.redhat.com [10.36.115.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 651CC196AE; Thu, 30 Apr 2020 09:48:42 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v5 12/12] OvmfPkg/MptScsiDxe: Reset device on ExitBootServices() To: devel@edk2.groups.io, nikita.leshchenko@oracle.com Cc: liran.alon@oracle.com, aaron.young@oracle.com, Jordan Justen , Ard Biesheuvel References: <20200424175927.41210-1-nikita.leshchenko@oracle.com> <20200424175927.41210-13-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: Date: Thu, 30 Apr 2020 11:48:41 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200424175927.41210-13-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 04/24/20 19:59, Nikita Leshenko wrote: > 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(-) Thanks for the update, my R-b stands. Laszlo > > diff --git a/OvmfPkg/MptScsiDxe/MptScsi.c b/OvmfPkg/MptScsiDxe/MptScsi.c > index 9cb5088bfbf9..d8649cf45541 100644 > --- a/OvmfPkg/MptScsiDxe/MptScsi.c > +++ b/OvmfPkg/MptScsiDxe/MptScsi.c > @@ -57,6 +57,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; > @@ -750,6 +751,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 > @@ -943,6 +958,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 > // > @@ -967,11 +993,14 @@ MptScsiControllerStart ( > &Dev->PassThru > ); > if (EFI_ERROR (Status)) { > - goto UninitDev; > + goto CloseExitBoot; > } > > return EFI_SUCCESS; > > +CloseExitBoot: > + gBS->CloseEvent (Dev->ExitBoot); > + > UninitDev: > MptScsiReset (Dev); > > @@ -1047,6 +1076,8 @@ MptScsiControllerStop ( > return Status; > } > > + gBS->CloseEvent (Dev->ExitBoot); > + > MptScsiReset (Dev); > > Dev->PciIo->Unmap ( >