From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.85.128.67, mailfrom: philmd@redhat.com) Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by groups.io with SMTP; Wed, 05 Jun 2019 02:12:42 -0700 Received: by mail-wm1-f67.google.com with SMTP id t5so1457910wmh.3 for ; Wed, 05 Jun 2019 02:12:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sGHhXf1SqJZocbD8tTVpSQf6X3quuSeNF+1GuFXX2LM=; b=NzMMml4XVZ3NiwJTXRbRSWCTV3O1W7nLLC70HcEJv7EEddmRZQGulef6rgayyFGQq8 VSL831B/2BXAGgQtZPoAg7ZpeZbnRKuDoMWRDeLZlAGsihLPj1lfu1QovOYD9zbHLyfB IYvqQpxiwVKea9lg5ePFz01Rscyf7rUPOZ7qvV/tgGA4S/3H10zIoZsTolpl8jJJ7aZx OHFX7gmBVZpJ8IUlBdaBMSbvBGyCffCd5Ym/vbPbAmiphOBqde264xjEWg/t4Ues2HTA egt5vtYxhrr2RufTynMgpP01gTbMlJ3xW1Nx7dHybmHRlqeWB4Lr+dtJVWszBRRCY1o9 1vfw== X-Gm-Message-State: APjAAAUMOTSpZPtS7MamoRZSbpRDIG2U7Xjt5VIsf85At88F8Jtrz5Wj 9Ec7gKrvxn5clgI6bkN+roKF9g== X-Google-Smtp-Source: APXvYqyTuIPd4XNQaRrJfR1q2mXtYP46oUwB3kFkY4FZRFRF8YNsJJxFS5g74Ht0ZVwFVg7gK7krBw== X-Received: by 2002:a7b:c057:: with SMTP id u23mr21937443wmc.29.1559725960364; Wed, 05 Jun 2019 02:12:40 -0700 (PDT) Return-Path: Received: from [192.168.1.38] (183.red-88-21-202.staticip.rima-tde.net. [88.21.202.183]) by smtp.gmail.com with ESMTPSA id o3sm16030178wrv.94.2019.06.05.02.12.39 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 02:12:39 -0700 (PDT) Subject: Re: [edk2-devel] [PATCH for-next] MdeModulePkg/PciBusDxe: catch unimplemented extended config space reads To: devel@edk2.groups.io, lersek@redhat.com Cc: Alex Williamson , Hao A Wu , Jian J Wang , Ray Ni , Star Zeng References: <20190604214424.456-1-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Openpgp: id=89C1E78F601EE86C867495CBA2A3FD6EDEADC0DE; url=http://pgp.mit.edu/pks/lookup?op=get&search=0xA2A3FD6EDEADC0DE Message-ID: <47a436df-6d81-8927-511f-11ddf95af91d@redhat.com> Date: Wed, 5 Jun 2019 11:12:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190604214424.456-1-lersek@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 6/4/19 11:44 PM, Laszlo Ersek wrote: > 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 > --- > > 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; > } > > + if (CapabilityEntry == 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 = (UINT16) CapabilityEntry; > > if (CapabilityID == CapId) { > Reviewed-by: Philippe Mathieu-Daude