From nobody Sun May 19 17:22:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98784+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98784+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1674033248; cv=none; d=zohomail.com; s=zohoarc; b=BUnQnFJvGgNUq1MUXEQ1ALZsH8K6rimkwb28UH+7wJ22Bc5Roz4GSIgPFeHuLw7/4Cq8bjGwTp153tNnS+Gr/1Eqq5a7mbQoUVJ6gIO+vl7ukdPJ+E0wqLHXs18jJ5fjuD+XIDfNcFG5jRyCPpiFqtMdHKz+JdBXaSUclnd0XDk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674033248; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=YoLzzhpHij52H35xG5BDOBR6ZMzSPxVLebFrBfh3QGM=; b=iQbZFs/CheNd9TkdzM88UjfXxBoT4DBfK/SFHhJe4GKuctLbEDCOOn7CpPqqeFtAIbJ8EYN0q2dWbFpNTJlUOzOprIiJXc+juK4ulEMebjSf4st65sfB/bLW8V+GmZb6PYysuiVBiB+sK9L7TRlF7cJnPjcEJJxq+eRa+Zl89tw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98784+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1674033248238335.2674240363185; Wed, 18 Jan 2023 01:14:08 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Eg6QYY1788612x9NEupw8r1w; Wed, 18 Jan 2023 01:14:07 -0800 X-Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) by mx.groups.io with SMTP id smtpd.web10.11149.1674033246963268812 for ; Wed, 18 Jan 2023 01:14:07 -0800 X-Received: by mail-pl1-f201.google.com with SMTP id m7-20020a170902db0700b00194bd3c810aso419640plx.23 for ; Wed, 18 Jan 2023 01:14:06 -0800 (PST) X-Gm-Message-State: E8q66pCBZM5HISfpmetiKRazx1787277AA= X-Google-Smtp-Source: AMrXdXvC9PAcT+HFL+4dNLXNB9DPa9bE0Tf+JCGy71b4Tw5w0M41/2XrBzPTvhHkJTtjYitQuP7sKiVQdMM= X-Received: from yuanyu.kir.corp.google.com ([2620:15c:29:204:1cbf:6a8c:60ac:298c]) (user=yuanyu job=sendgmr) by 2002:a17:902:8f82:b0:189:959a:84d8 with SMTP id z2-20020a1709028f8200b00189959a84d8mr641145plo.38.1674033246146; Wed, 18 Jan 2023 01:14:06 -0800 (PST) Date: Wed, 18 Jan 2023 01:14:01 -0800 In-Reply-To: <20230118091402.931498-1-yuanyu@google.com> Mime-Version: 1.0 References: <20230118091402.931498-1-yuanyu@google.com> Message-ID: <20230118091402.931498-2-yuanyu@google.com> Subject: [edk2-devel] [PATCH v1 1/2] MdeModulePkg: Fix bug in ScsiBusDxe/ScsiBus.c From: "Yuan Yu via groups.io" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Liming Gao , Hao A Wu , Ray Ni , Sivaparvathi chellaiah Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanyu@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1674033247; bh=gOovC74AYhUYVHWtE5z6cuhgieI88B/8YEzOop9HbuA=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=qnTU677t33R+Lx7SoLvZt3zATYUOXRZLXIOq0wC/hfcgLLZ80MEFCKvDnEDo3yx/Qp5 mVGnATqytucDcQFpJ5qpYYu8xlIoQSuCHiEyvAxjYS7/nJ91QHkn1yxplcYMIHe6qZeYw F7IaXdKV0Vg1bmshVPkGxdRLFK+dqR7eq84= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1674033248901100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A while loop in SCSIBusDriverBindingStart() is supposed to scan all the possible Puns in the SCSI channel by calling ScsiScanCreateDevice() for each of them. Therefore, we should not abort the loop even when one of the Puns is disconnected. The following is one of the scenarios. SCSIBusDriverBindingStart() > ScsiScanCreateDevice() > DiscoverScsiDevice() > ScsiInquiryCommand() > ... > ParseResponse() When virtio-scsi returns VIRTIO_SCSI_S_BAD_TARGET, ParseResponse() in VirtioScsi.c will return EFI_TIMEOUT: case VIRTIO_SCSI_S_BAD_TARGET: // // This is non-intuitive but explicitly required by the // EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() specification for // disconnected (but otherwise valid) target / LUN addresses. // Packet->HostAdapterStatus =3D EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND; return EFI_TIMEOUT; This will eventually cause DiscoverScsiDevice() to return FALSE, which will cause ScsiScanCreateDevice() to return EFI_OUT_OF_RESOURCES: if (!DiscoverScsiDevice (ScsiIoDevice)) { Status =3D EFI_OUT_OF_RESOURCES; goto ErrorExit; } In sum, "disconnected (but otherwise valid) target / LUN addresses" can result in EFI_OUT_OF_RESOURCES and when this happens the while loop in SCSIBusDriverBindingStart() should continue, not abort. Without this fix, the loop can terminate prematurely with good devices not having a chance to be discovered. If this good device is the boot device, boot will fail. Cc: Ard Biesheuvel Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Cc: Sivaparvathi chellaiah Signed-off-by: Yuan Yu --- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c b/MdeModulePkg/Bus/= Scsi/ScsiBusDxe/ScsiBus.c index fbe14c772496..2ed816da4abe 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c +++ b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c @@ -533,9 +533,6 @@ SCSIBusDriverBindingStart ( // then create handle and install scsi i/o protocol. // Status =3D ScsiScanCreateDevice (This, Controller, &ScsiTargetId, Lun,= ScsiBusDev); - if (Status =3D=3D EFI_OUT_OF_RESOURCES) { - goto ErrorExit; - } } =20 return EFI_SUCCESS; --=20 2.39.0.314.g84b9a713c41-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98784): https://edk2.groups.io/g/devel/message/98784 Mute This Topic: https://groups.io/mt/96350422/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 19 17:22:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+98785+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98785+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1674033249; cv=none; d=zohomail.com; s=zohoarc; b=P7ATPithiYW+OuijeTaZUdBN6nTv/+NWPlqPZDNqg7hJXc2nZO47IukDuWrlSbMP4HSkwRRVdHkQq5pjbXdVpgVgTIB2+5tzybGHPg/4GIr840kimGOMwv/SinSphyCd0C1vnBBKP2zF997RnEVSdp9hbXTlAhTv/r7ghkDQmTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1674033249; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=pCFGej3f376DB9KDQVKoXOx7MZxvjadzcAOlnnxJ9fg=; b=Tq5KWKIllAfgqPNTgebyTVcw3qgauwQYooXpgSPe5SPsMBFFKjMERn+qqEABV85JXVEIm6YJorRIMoORS04bWMmXzqrv+qYtJsZdfGV+g8j8LQX6V7ADiyH+nN00eTJRUoBZucnXLfcAm9rXLk+coJi1f81If03cipmUZx2WI+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+98785+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167403324981873.54110506231552; Wed, 18 Jan 2023 01:14:09 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id bcV0YY1788612xipzyLdmdZh; Wed, 18 Jan 2023 01:14:09 -0800 X-Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by mx.groups.io with SMTP id smtpd.web10.11150.1674033249028343398 for ; Wed, 18 Jan 2023 01:14:09 -0800 X-Received: by mail-yb1-f201.google.com with SMTP id k204-20020a256fd5000000b007b8b040bc50so34916457ybc.1 for ; Wed, 18 Jan 2023 01:14:08 -0800 (PST) X-Gm-Message-State: FAc42zhQpQiKceTmi1ENmTp8x1787277AA= X-Google-Smtp-Source: AMrXdXsZgqFMu2+Qe/rz1uSTCiMeGSQolE7wDHbD40yyI/M6I0cfg8u5dL82WNlmpuUykdIWdGAtOPiM4QE= X-Received: from yuanyu.kir.corp.google.com ([2620:15c:29:204:1cbf:6a8c:60ac:298c]) (user=yuanyu job=sendgmr) by 2002:a0d:f584:0:b0:4dd:35c1:f523 with SMTP id e126-20020a0df584000000b004dd35c1f523mr741719ywf.431.1674033248114; Wed, 18 Jan 2023 01:14:08 -0800 (PST) Date: Wed, 18 Jan 2023 01:14:02 -0800 In-Reply-To: <20230118091402.931498-1-yuanyu@google.com> Mime-Version: 1.0 References: <20230118091402.931498-1-yuanyu@google.com> Message-ID: <20230118091402.931498-3-yuanyu@google.com> Subject: [edk2-devel] [PATCH v1 2/2] MdeModulePkg: Clean up unused Status. From: "Yuan Yu via groups.io" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Liming Gao , Hao A Wu , Ray Ni , Sivaparvathi chellaiah Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanyu@google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1674033249; bh=GaG3Oehi7oAJK0er71get2GbQa0fXi6ODFA2Y7f3M/c=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=T+i0NvB22SrkdKVk4HdKWp7jCBedODHuAgK+b7d89b2AG4EtQRpGS98xkMC9vAHKrpI +aeFG46ma6upELsuAaZsCUMuI9FFVYKX1ZoCaoK1tY638OnubVu/9ezgFT6aPlEQqAG8/ rV6wUMTCr2qp7ocXNl7I2E/8ls3sr3lKXjE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1674033250842100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Logically, the while loop that contains ScsiScanCreateDevice() should continue regardless what the returned Status is, because the purpose of the while loop is to scan all possible Puns in the SCSI channel. Without this fix, some static analyzer may complain about the unused return value. Cc: Ard Biesheuvel Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Cc: Sivaparvathi chellaiah Signed-off-by: Yuan Yu --- MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c b/MdeModulePkg/Bus/= Scsi/ScsiBusDxe/ScsiBus.c index 2ed816da4abe..7f133253a256 100644 --- a/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c +++ b/MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.c @@ -532,7 +532,7 @@ SCSIBusDriverBindingStart ( // Scan for the scsi device, if it attaches to the scsi bus, // then create handle and install scsi i/o protocol. // - Status =3D ScsiScanCreateDevice (This, Controller, &ScsiTargetId, Lun,= ScsiBusDev); + ScsiScanCreateDevice (This, Controller, &ScsiTargetId, Lun, ScsiBusDev= ); } =20 return EFI_SUCCESS; --=20 2.39.0.314.g84b9a713c41-goog -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#98785): https://edk2.groups.io/g/devel/message/98785 Mute This Topic: https://groups.io/mt/96350423/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-