From nobody Sun May 19 20:13:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+41893+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41893+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1559684681; cv=none; d=zoho.com; s=zohoarc; b=oRHfM6aY77VP0ye8oWFD5J+2k+iirwc1gN4sCOPH34ES2KmisrcUpE+ENLK7fn/fzIt0rLAYekJC0JkljwRgLs6QZeEfkSBX2HuSHbH80afdttX3skMB/4eT+9TZHJPGu80JRyez5mH5qYy1aVKEwW1OUAHuoWEOOn6Cr57JbQw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559684681; h=Content-Transfer-Encoding:Cc:Date:From:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To:ARC-Authentication-Results; bh=DPGhmASeq5xnqDsiNIj7wOqsZLgC0MyhVViTof/teEY=; b=Dxu0pMWXjM8Zcg56lPxQiN88WvrjBdkgQzEBCBlp4nYF6zLOfE9WAW84sfopD+GJoETvhoTOC0tfrYZLMkkQ/gCBNaAxVP31LfOiG1HNL+OQPOqMO43226I6rQ6yNvt6Bd2L04DdZoacIG3LOn9K53BPhlVPIGU48PN8Jt6tizg= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+41893+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1559684681615442.51759870059925; Tue, 4 Jun 2019 14:44:41 -0700 (PDT) Return-Path: X-Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Tue, 04 Jun 2019 14:44:41 -0700 X-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 mx1.redhat.com (Postfix) with ESMTPS id 56A1FA3B64; Tue, 4 Jun 2019 21:44:30 +0000 (UTC) X-Received: from lacos-laptop-7.usersys.redhat.com (ovpn-117-251.ams2.redhat.com [10.36.117.251]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0BCA19C69; Tue, 4 Jun 2019 21:44:26 +0000 (UTC) From: "Laszlo Ersek" To: edk2-devel-groups-io Cc: Alex Williamson , Hao A Wu , Jian J Wang , Ray Ni , Star Zeng Subject: [edk2-devel] [PATCH for-next] MdeModulePkg/PciBusDxe: catch unimplemented extended config space reads Date: Tue, 4 Jun 2019 23:44:24 +0200 Message-Id: <20190604214424.456-1-lersek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 04 Jun 2019 21:44:35 +0000 (UTC) Precedence: Bulk List-Unsubscribe: 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,lersek@redhat.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1559684681; bh=kkscG//Vd5s8y+T6Ua84k0fcN+PPqoDcy6NEyM1z6Kw=; h=Cc:Date:From:Reply-To:Subject:To; b=sSNUa3O48TLFK3t7esMPsXiWuxf54uWdav2FvRFoAtH4IISHth5qVQJNqo3MMc2ZcpV nni4OcNty6r2Dsi8PyYn6IdIs/JbMOUqH0rcnNzrzwvKtvNjBxfXdqjeaCKaMXnT7nTt9 sM6SScDL81iK6rFXlFSHQ/j6DHEajHHgLF0= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" When assigning a physical PCIe device to a QEMU/KVM guest, PciBusDxe may find that the extended config space is not (fully) implemented. In LocatePciExpressCapabilityRegBlock(), "CapabilityEntry" may be read as 0xFFFF_FFFF at a given config space offset, after which the loop gets stuck spinning on offset 0xFFC (the read at offset 0xFFC returns 0xFFFF_FFFF most likely as well). Another scenario (not related to virtualization) for triggering the above is when a Conventional PCI bus -- exposed by a PCIe-to-PCI bridge in the topology -- intervenes between a PCI Express Root Port and a PCI Express Endpoint. The Conventional PCI bus limits the accessible config space of the PCI Express Endpoint, even though the endpoint advertizes the PCI Express capability. Here's a diagram, courtesy of Alex Williamson: [PCIe Root Port]--[PCIe-to-PCI]--[PCI-to-PCIe]--[PCIe EP] ->| |<- Conventional PCI bus Catch reads of 0xFFFF_FFFF in LocatePciExpressCapabilityRegBlock(), and break out of the scan with a warning message. The function will return EFI_NOT_FOUND. Cc: Alex Williamson Cc: Hao A Wu Cc: Jian J Wang Cc: Ray Ni Cc: Star Zeng Signed-off-by: Laszlo Ersek Acked-by: Ard Biesheuvel Acked-by: Hao A Wu Reviewed-by: Philippe Mathieu-Daude Reviewed-by: Ray Ni --- Notes: Repo: https://github.com/lersek/edk2.git Branch: pcibus_no_ext_conf MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c b/MdeModulePkg/Bus= /Pci/PciBusDxe/PciCommand.c index 214aeecdd40a..6283d602207c 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c @@ -236,6 +236,19 @@ LocatePciExpressCapabilityRegBlock ( break; } =20 + if (CapabilityEntry =3D=3D MAX_UINT32) { + DEBUG (( + DEBUG_WARN, + "%a: [%02x|%02x|%02x] failed to access config space at offset 0x%x= \n", + __FUNCTION__, + PciIoDevice->BusNumber, + PciIoDevice->DeviceNumber, + PciIoDevice->FunctionNumber, + CapabilityPtr + )); + break; + } + CapabilityID =3D (UINT16) CapabilityEntry; =20 if (CapabilityID =3D=3D CapId) { --=20 2.19.1.3.g30247aa5d201 -=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 (#41893): https://edk2.groups.io/g/devel/message/41893 Mute This Topic: https://groups.io/mt/31931246/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-