[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH for-4.22 2/2] x86/mcfg: relax memory map checks on newer firmware


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 4 Jun 2026 12:46:04 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kAVeWHi2hK4nsn3NUTrNBgVlZCJB1Kkd6GoF1JGVuVw=; b=fONuqrgE/qI77YH9UVXppC1+BVvDGAxvfAkBLMdhlHA7Df+IS+ybqUiheSduTmqdC56z6srGJTkVyPPYzTZO3ehq33aIXUwf7y639+5xLBtZ7hdwYD3JM6jNFMFbThy5JtEa6hKbjG9bLEMZMfW8Ii90nq9JhWDoQ3zZrD9Ia5uQWW22tYy0D38ff1EcxtzsHfjSdRADD0u949ILFOHLmKWf9DRCSY5qY1PVJMjfoV8+Qh564LqoAwvqTN8PwgxHhyKGclYWSCIbcRE3jmfMTOadhHAjgHTtvonMw680JK+T00/U/XvpGIqe2sYGRgKHw3tK5QJaio2N0T8TzwvVEw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GPY2mxspc/kmNYGitFkuimCP5DhEm1AmrNdCxt3H2YRCo7vxB5qEXBAN0xacdY57jeJceHY3Xg86tkM5z+qMEUScaOpJKhNmKe3QRUdllP7p8JPGFkDKmflguDred8UUx7Ih42p7bj6tAWa7fyLCFSY/3bzBpiI4PmoVRbX94jwJOXu0JA4+U1m7TYk3DKnIWnlBixtthGeTeZaE+vgrnWedkpW/V0gjScBmsiP/jyp6Ck/evKIIXPAFPSbsIY5+ELOk6DrBN3xwK1KIfg4OxZq653nPIY9alPrKhDH3Uo37Lv6jg0SQTkol9c39nXze6JvCTbXdLwg6VqczC46Hxw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Thu, 04 Jun 2026 10:46:32 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Per PCI Firmware 3.3 specification, section 4.1.2, ECAM space must be
reserved by declaring a motherboard resource, but there's no requirement to
mention it in E820, so we shouldn't look at E820 to validate the ECAM space
described by MCFG.  The specification additionally states that: the
resources can optionally be returned in Int15 E820h or EFIGetMemoryMap as
reserved memory.

The more strict logic was introduced in Linux in 2006 as 946f2ee5c731
("[PATCH] i386/x86-64: Check that MCFG points to an e820 reserved area").
This was picked up by Xen when MCFG support was added in 3b35911d709e
("Enable pci mmcfg and ATS for x86_64").  Apply the same approach that
Linux has done in 199f968f1484 ("x86/pci: Skip early E820 check for ECAM
region") and relax the strict reserved region checking so it's only done
for firmware manufactured prior to 2016.

When dom0 is booted it can always prevent access to misconfigured MCFG
regions by using the PHYSDEVOP_pci_mmcfg_reserved hypercall.  This brings
Xen's early usage of MCFG (prior to ACPI AML parsing) in line with the
implementation in Linux.

This fixes an issue with detection of extended capabilities when running
Xen on a Lenovo system that doesn't list the MCFG area as an
EfiMemoryMappedIO region in the EFI memory map.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
I'm not sure what's the best way to attribute the logic here with the
Linux commit that introduced this, more than referencing it in the commit
message text.  The code is too different for me to attempt to label this
change as a backport of the original Linux commit.
---
 xen/arch/x86/x86_64/mmconfig-shared.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/x86_64/mmconfig-shared.c 
b/xen/arch/x86/x86_64/mmconfig-shared.c
index d0cbc151705d..e24a78c8d1d3 100644
--- a/xen/arch/x86/x86_64/mmconfig-shared.c
+++ b/xen/arch/x86/x86_64/mmconfig-shared.c
@@ -13,6 +13,7 @@
  */
 
 #include <xen/acpi.h>
+#include <xen/dmi.h>
 #include <xen/init.h>
 #include <xen/mm.h>
 #include <xen/param.h>
@@ -369,12 +370,15 @@ static bool __init pci_mmcfg_reject_broken(void)
     typeof(pci_mmcfg_config[0]) *cfg;
     int i;
     bool valid = true;
+    int year;
 
     if ((pci_mmcfg_config_num == 0) ||
         (pci_mmcfg_config == NULL) ||
         (pci_mmcfg_config[0].address == 0))
         return 0;
 
+    dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL);
+
     for (i = 0; i < pci_mmcfg_config_num; i++) {
         u64 addr, size;
 
@@ -390,7 +394,13 @@ static bool __init pci_mmcfg_reject_broken(void)
                (unsigned int)cfg->start_bus_number,
                (unsigned int)cfg->end_bus_number);
 
-        if ( !is_mmconf_reserved(addr, size, i, cfg) ||
+        /*
+         * For firmware from 2016 or later relax the checking and also consider
+         * MCFG regions in holes on the memory map as valid.
+         */
+        if ( ((year < 2016 || !is_memory_hole(maddr_to_mfn(addr),
+                                              maddr_to_mfn(addr + size - 1))) 
&&
+              !is_mmconf_reserved(addr, size, i, cfg)) ||
              pci_mmcfg_arch_enable(i) < 0 )
         {
             pci_mmcfg_arch_disable(i);
-- 
2.53.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.