From nobody Mon Feb 9 07:55:45 2026 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-