[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH for-4.22 2/2] x86/mcfg: relax memory map checks on newer firmware
- To: Roger Pau Monne <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Thu, 4 Jun 2026 12:08:30 +0100
- 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=L+5Fkv3BNPIn3Dsc2L3UOsQ4qtsGY4Ec4uuse+XI9ig=; b=wnK7I/QqzyVZjlxcqK3+U6GeyhBKquHQEj7ea9AlCrRKUl5OrOrBcb6gq/MjKvWf5JWs8bbYfZKkPsdF20W8MMV6QcSIXiFFbBcBpeUzyi9hvtbq5rh5wqgU9ihb43xjjoBPNMgKSLFirub9A35FhTcvfvVGkVDHbebkm8vaaZzotPfCMtWdtTWNtXBTmorvwLKhCS6XXcY8yoV+ThQkVGIqAhZMMCMRqHI8pf55cn2aHvY4J87SOTtd0xAvDwtWzij7MnRU1o8wTak6glnUyQP0VuoIko/cTPzbnZXE5Ql4ZE1ssVc3AP3DnnkvDIJ/eumdLOpMn+HAI5V1MpoxBg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mR61+RZLS/CgkBZX8//CyAXSLoK7OLnHjZh38UK59JrXbpnl7nwQlzYKGtWzLZiZsxYvv+nLCGonYiqCaPrv/HwpB8oJUfCT72fkUAuInV581iO7rZ9CPtcX/2V1GBbOBocZMGwotE71M2YZv83vzyfOA7fBrLyc/7RDbWDZQLaynaotBxkxpkhP/cnu2qCHMIq1UqHiNznmLyD566fT2d1mk3uHXNOPq9r+AGDAurY1fR5apJ4KKzdZ1rFu1b09UVMg3QuxKp22Dm8/4c9hZ3pEA34SP+JM5a0FoB6ttLi+ZLmXP6L5I+u7S3PRlzgKzKbHD5X8Hok0YSl8L/Yl3w==
- 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;
- Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4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hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
- Delivery-date: Thu, 04 Jun 2026 11:08:48 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 04/06/2026 11:46 am, Roger Pau Monne wrote:
> 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.
I'd take out the ", so we shouldn't ..." clause. I see it came from the
Linux commit, but it wasn't great there either. It's a piece of opinion
in the middle of quotes from a spec.
Then, I think you want a new paragraph between these two, saying
explicitly that some Lenvovo systems do not mark MMCFG in the memory map.
> 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.
I think your commit message is adequate. It does provide all the reasoning.
> ---
> 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)) ||
This comment is half stale already, as "relax" is really only relevant
to the prior behaviour.
"For firmwares prior to 2016, confirm that MMCFG is marked as reserved.
For 2016 and later, also allow MMCFG being in a hole."
It's also worth saying that this fix is different to Linux's. Linux
simply ignores the E820 on anything newer than 2016. Personally I
prefer the more cautious approach of saying reserved-or-hole, but this
should be called out in the commit message, I think.
~Andrew
|