Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2088040ybp; Thu, 10 Oct 2019 01:59:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyG/zG2pXLa40J6vhzY9EJN2c7rHZYDOXaH23sShHT6C0rw7yt1rD4dMFiPcseqrJSPTJl X-Received: by 2002:aa7:de02:: with SMTP id h2mr7058096edv.212.1570697984467; Thu, 10 Oct 2019 01:59:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570697984; cv=none; d=google.com; s=arc-20160816; b=OQEW6M10aEawIARfrk0xnqfSvKbY/WsKeKybF5PuxGEClZKYhgqMTxTb74wa1ke9hB LpIV+2Rj071Oxc9xSWi8cDPu9OCvtWpKyIox79RvdPPAiHJzNVLzE9m8g9la4wuhd3TY fbyvZDrRZNB+aubZcQRiaRdYY5EOHiQaS1IikOqz1MZvXC59zpFvH5Zm6QubtjZ69gxV AO4+z9+yodV7uZpIdXg4DOp3ZwUugOtjibACrAi3HkGoi0vRA/pXp0JA6rcuGumBd0UP GxJyBMz01kKYPanZwnC4utiuoWEUb9mEkNiKyYxIYD1/s/OHJdY8DsgDGTj1nmVBlmpI Tdrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=h+db85ZKvv/00JgVGcAqO2QssCNoRDb7mSWZDwgy1o0=; b=WqSP3kqgxGHJXH42FUQ3qlqTvwUfWeLiSHSj7Kqv8mAfho5II3NbNj3gjzM3diIbOO n8N+XsgZbvi85x4hbKkUYhykBMLjrJrk2KrH6VvfSCMGUkGieMVEFQaa+KwofN7NeeuA lVa5VBGC1K8tBOXtcmJa8wwuvXKLJ1krZczltSHJZA096FzwgmGMAMofteov8YB4zbva btg/dVxFCB/1iiMl6vWBHbOZpczDFEOSQ2l5o4DPm9E8+dhhKwxCFKO8twOnB1Dpzh0N x0RKTSZkYwcOO1l9SN64Rcyj26hVde925TOmlfkHN8sGWFV6mKnmMrFIVAMV4r/Kz1/j bD2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1nR4odW2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s20si2939729ejx.223.2019.10.10.01.59.21; Thu, 10 Oct 2019 01:59:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1nR4odW2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389325AbfJJI5e (ORCPT + 99 others); Thu, 10 Oct 2019 04:57:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:52428 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389330AbfJJIqg (ORCPT ); Thu, 10 Oct 2019 04:46:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 47213218AC; Thu, 10 Oct 2019 08:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570697195; bh=6EyxsEqBJ2oOZtJcJw9OqpnSifZ1fmKpzk8Q4zKakk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1nR4odW2RfL0O7SWJ8mMRPzw78+lYNIikokeYywIhtgAiXoNZIKuMC8lyatB9qiOP qk9IyKdYgRpXr+MjM1HejV2ifd4fGzC/0hGepobJ/eBtJYmeZRnUBmiikk8KxNIWLd 3uHgVX1MZkQSjgfjz6//jSorB/Znt/hMKCnSpHtA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Igor Druzhinin , Boris Ostrovsky , Sasha Levin Subject: [PATCH 4.19 054/114] xen/pci: reserve MCFG areas earlier Date: Thu, 10 Oct 2019 10:36:01 +0200 Message-Id: <20191010083608.449377759@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191010083544.711104709@linuxfoundation.org> References: <20191010083544.711104709@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Igor Druzhinin [ Upstream commit a4098bc6eed5e31e0391bcc068e61804c98138df ] 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 in 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 as well. 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 register MCFG areas earlier upon the first invocation of xen_add_device(). It should be safe to do once since all the boot time buses must have their MCFG areas in MCFG table already and we don't support PCI bus hot-plug. Signed-off-by: Igor Druzhinin Reviewed-by: Boris Ostrovsky Signed-off-by: Boris Ostrovsky Signed-off-by: Sasha Levin --- drivers/xen/pci.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drivers/xen/pci.c b/drivers/xen/pci.c index 7494dbeb4409c..db58aaa4dc598 100644 --- a/drivers/xen/pci.c +++ b/drivers/xen/pci.c @@ -29,6 +29,8 @@ #include "../pci/pci.h" #ifdef CONFIG_PCI_MMCONFIG #include + +static int xen_mcfg_late(void); #endif static bool __read_mostly pci_seg_supported = true; @@ -40,7 +42,18 @@ static int xen_add_device(struct device *dev) #ifdef CONFIG_PCI_IOV struct pci_dev *physfn = pci_dev->physfn; #endif - +#ifdef CONFIG_PCI_MMCONFIG + static bool pci_mcfg_reserved = false; + /* + * Reserve MCFG areas in Xen on first invocation due to this being + * potentially called from inside of acpi_init immediately after + * MCFG table has been finally parsed. + */ + 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; @@ -252,8 +265,4 @@ static int __init xen_mcfg_late(void) } return 0; } -/* - * Needs to be done after acpi_init which are subsys_initcall. - */ -subsys_initcall_sync(xen_mcfg_late); #endif -- 2.20.1