From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.120]) by mx.groups.io with SMTP id smtpd.web10.951.1587409390208849737 for ; Mon, 20 Apr 2020 12:03:10 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZMCWLwSL; spf=pass (domain: redhat.com, ip: 205.139.110.120, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587409389; 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=zj8dY76P4wPKlp9hKyS4JTfr075Atja5dS08i6WJLnM=; b=ZMCWLwSLAZpX3RBRzVCiljHzI04ll54v/4wmEXlAU4pI+G8s/cd1/3ZzKQyKfO1ks5P7B7 ek3Fl/W839CJwPXphXv8+j1g2EjAcMeIAE1dpF0xIsxTt5QG2MzXbeMJmDHI8qYokeHEis Kr5nw5vYLobgu5nZfZm7CmCuQoxhn/w= 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-386-NdYH_6geNp2QPM0nw0UAEA-1; Mon, 20 Apr 2020 15:03:03 -0400 X-MC-Unique: NdYH_6geNp2QPM0nw0UAEA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E3A488017F6; Mon, 20 Apr 2020 19:03:01 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-114-228.ams2.redhat.com [10.36.114.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E15460C87; Mon, 20 Apr 2020 19:02:59 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH v4 13/13] 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: <20200414173813.7715-1-nikita.leshchenko@oracle.com> <20200414173813.7715-14-nikita.leshchenko@oracle.com> From: "Laszlo Ersek" Message-ID: <8b9adec8-9353-0278-7f3b-f0cbffc7d201@redhat.com> Date: Mon, 20 Apr 2020 21:02:59 +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: <20200414173813.7715-14-nikita.leshchenko@oracle.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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/14/20 19:38, 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 > --- > 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); > +} (1) Please copy the DEBUG_VERBOSE message seen in PvScsiExitBoot() into this function. With that: Reviewed-by: Laszlo Ersek Thanks, Laszlo > 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 ( >