From patchwork Wed Sep 4 00:20:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Druzhinin X-Patchwork-Id: 11129105 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9751914DE for ; Wed, 4 Sep 2019 00:23:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 727EC20882 for ; Wed, 4 Sep 2019 00:23:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="BTJKzTwH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 727EC20882 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5J2S-0000Zr-Qp; Wed, 04 Sep 2019 00:20:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1i5J2R-0000Zc-37 for xen-devel@lists.xenproject.org; Wed, 04 Sep 2019 00:20:43 +0000 X-Inumbo-ID: d0d9c824-cea9-11e9-aba8-12813bfff9fa Received: from esa5.hc3370-68.iphmx.com (unknown [216.71.155.168]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id d0d9c824-cea9-11e9-aba8-12813bfff9fa; Wed, 04 Sep 2019 00:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1567556436; h=from:to:cc:subject:date:message-id:mime-version; bh=REnkVIGmDtY7lvGG2M1j0JFI4QkmkQIKYK2dQ3BcqE0=; b=BTJKzTwHl0N5EUxwEqg11ndPM/jEARuMXXjfgWqJ3da3iHRi9ghUhRHt BxMLXVvdWEFPtjrzo5HfX7xjTu7KwjrmKds7rFQRcS1ILfacx2omy4OH8 nQgZbK/+MJJfagQEIqtgGCd7cyQ3nf3vxFHa641LkLJZQq7wpnegEv93Z Q=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=igor.druzhinin@citrix.com; spf=Pass smtp.mailfrom=igor.druzhinin@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of igor.druzhinin@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa5.hc3370-68.iphmx.com: domain of igor.druzhinin@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="igor.druzhinin@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa5.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa5.hc3370-68.iphmx.com; envelope-from="igor.druzhinin@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: ihSSbqvcBHI79WN++CxzfilhADPpkPgRdVrUvsODTRGNlVu/v8KiA/qtX5WBIuXu1jFbgT2T2/ QuuqyfAMPLTt6WApOiA+yLeqvnRRV2g6wFdGB7Mee6A1OMk31Cwzm5hPaIdr9Mv3U0mOwdr75Q OlEFTUgwkSh6O0ZVXRIhzTa0y7KIxJZcjMp4ozQPlmkYHBfGvjr+ZiShLVBIV5+K1VXyvMYfXP zlzwRzURUY3WIyIMoMNx6BaOBXRwRz1OYDLSmlzXBHhZh2XGyTG1U6LyT0zyK+brgZz5NbeqLN 5z0= X-SBRS: 2.7 X-MesageID: 5277025 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,465,1559534400"; d="scan'208";a="5277025" From: Igor Druzhinin To: , Date: Wed, 4 Sep 2019 01:20:31 +0100 Message-ID: <1567556431-9809-1-git-send-email-igor.druzhinin@citrix.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] xen/pci: try to reserve MCFG areas earlier X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: jgross@suse.com, Igor Druzhinin , boris.ostrovsky@oracle.com Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" If MCFG area is not reserved in E820, Xen by default will defer its usage until Dom0 registers it explicitly after ACPI parser recognizes it as a reserved resource in DSDT. Having it reserved in E820 is not mandatory according to "PCI Firmware Specification, rev 3.2" (par. 4.1.2) and firmware is free to keep a hole E820 in that place. Xen doesn't know what exactly is inside this hole since it lacks full ACPI view of the platform therefore it's potentially harmful to access MCFG region without additional checks as some machines are known to provide inconsistent information on the size of the region. Now xen_mcfg_late() runs after acpi_init() which is too late as some basic PCI enumeration starts exactly there. Trying to register a device prior to MCFG reservation causes multiple problems with PCIe extended capability initializations in Xen (e.g. SR-IOV VF BAR sizing). There are no convenient hooks for us to subscribe to so try to register MCFG areas earlier upon the first invocation of xen_add_device(). Keep the existing initcall in case information of MCFG areas is updated later in acpi_init(). Signed-off-by: Igor Druzhinin --- drivers/xen/pci.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c index 7494dbe..800f415 100644 --- a/drivers/xen/pci.c +++ b/drivers/xen/pci.c @@ -29,6 +29,9 @@ #include "../pci/pci.h" #ifdef CONFIG_PCI_MMCONFIG #include + +static int xen_mcfg_late(void); +static bool __read_mostly pci_mcfg_reserved = false; #endif static bool __read_mostly pci_seg_supported = true; @@ -41,6 +44,16 @@ static int xen_add_device(struct device *dev) struct pci_dev *physfn = pci_dev->physfn; #endif +#ifdef CONFIG_PCI_MMCONFIG + /* + * Try to reserve MCFG areas discovered so far early on first invocation + * due to this being potentially called from inside of acpi_init + */ + if (!pci_mcfg_reserved) { + xen_mcfg_late(); + pci_mcfg_reserved = true; + } +#endif if (pci_seg_supported) { struct { struct physdev_pci_device_add add; @@ -213,7 +226,7 @@ static int __init register_xen_pci_notifier(void) arch_initcall(register_xen_pci_notifier); #ifdef CONFIG_PCI_MMCONFIG -static int __init xen_mcfg_late(void) +static int xen_mcfg_late(void) { struct pci_mmcfg_region *cfg; int rc;