linux/arch/x86/pci
Hans de Goede 0ae084d5a6 x86/PCI: Disable E820 reserved region clipping starting in 2023
Some firmware includes unusable space (host bridge registers, hidden PCI
device BARs, etc) in PCI host bridge _CRS.  As far as we know, there's
nothing in the ACPI, UEFI, or PCI Firmware spec that requires the OS to
remove E820 reserved regions from _CRS, so this seems like a firmware
defect.

As a workaround, 4dc2287c18 ("x86: avoid E820 regions when allocating
address space") has clipped out the unusable space in the past.  This is
required for machines like the following:

  - Dell Precision T3500 (the original motivator for 4dc2287c18); see
    https://bugzilla.kernel.org/show_bug.cgi?id=16228

  - Asus C523NA (Coral) Chromebook; see
    https://lore.kernel.org/all/4e9fca2f-0af1-3684-6c97-4c35befd5019@redhat.com/

  - Lenovo ThinkPad X1 Gen 2; see:
    https://bugzilla.redhat.com/show_bug.cgi?id=2029207

But other firmware supplies E820 reserved regions that cover entire _CRS
windows, and clipping throws away the entire window, leaving none for
hot-added or uninitialized devices.  This clipping breaks a whole range of
Lenovo IdeaPads, Yogas, Yoga Slims, and notebooks, as well as Acer Spin 5
and Clevo X170KM-G Barebone machines.

E820 reserved entries that cover a memory-mapped PCI host bridge, including
its registers and memory/IO windows, are probably *not* a firmware defect.
Per ACPI v5.4, sec 15.2, the E820 memory map may include:

  Address ranges defined for baseboard memory-mapped I/O devices, such as
  APICs, are returned as reserved.

Disable the E820 clipping by default for all post-2022 machines.  We
already have quirks to disable clipping for pre-2023 machines, and we'll
likely need quirks to *enable* clipping for post-2022 machines that
incorrectly include unusable space in _CRS, including Chromebooks and
Lenovo ThinkPads.

Here's the rationale for doing this.  If we do nothing, and continue
clipping by default:

  - Future systems like the Lenovo IdeaPads, Yogas, etc, Acer Spin, and
    Clevo Barebones will require new quirks to disable clipping.

  - The problem here is E820 entries that cover entire _CRS windows that
    should not be clipped out.

  - I think these E820 entries are legal per spec, and it would be hard to
    get BIOS vendors to change them.

  - We will discover new systems that need clipping disabled piecemeal as
    they are released.

  - Future systems like Lenovo X1 Carbon and the Chromebooks (probably
    anything using coreboot) will just work, even though their _CRS is
    incorrect, so we will not notice new ones that rely on the clipping.

  - BIOS updates will not require new quirks unless they change the DMI
    model string.

If we add the date check in this commit that disables clipping, e.g., "no
clipping when date >= 2023":

  - Future systems like Lenovo *IIL*, Acer Spin, and Clevo Barebones will
    just work without new quirks.

  - Future systems like Lenovo X1 Carbon and the Chromebooks will require
    new quirks to *enable* clipping.

  - The problem here is that _CRS contains regions that are not usable by
    PCI devices, and we rely on the E820 kludge to clip them out.

  - I think this use of E820 is clearly a firmware bug, so we have a
    fighting chance of getting it changed eventually.

  - BIOS updates after the cutoff date *will* require quirks, but only for
    systems like Lenovo X1 Carbon and Chromebooks that we already think
    have broken firmware.

It seems to me like it's better to add quirks for firmware that we think is
broken than for firmware that seems unusual but correct.

[bhelgaas: comment and commit log]
Link: https://lore.kernel.org/linux-pci/20220518220754.GA7911@bhelgaas/
Link: https://lore.kernel.org/r/20220519152150.6135-4-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Cc: Benoit Grégoire <benoitg@coeus.ca>
Cc: Hui Wang <hui.wang@canonical.com>
2022-05-19 16:56:24 -05:00
..
acpi.c x86/PCI: Disable E820 reserved region clipping starting in 2023 2022-05-19 16:56:24 -05:00
amd_bus.c x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG 2021-05-10 07:51:38 +02:00
broadcom_bus.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
bus_numa.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bus_numa.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ce4100.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 334 2019-06-05 17:37:06 +02:00
common.c x86/PCI: Add kernel cmdline options to use/ignore E820 reserved regions 2022-05-19 14:26:55 -05:00
direct.c x86/pci: Simplify code by using the new dmi_get_bios_year() helper 2018-02-23 08:20:30 +01:00
early.c PCI: Make early dump functionality generic 2018-06-29 20:06:07 -05:00
fixup.c PCI/sysfs: Find shadow ROM before static attribute initialization 2022-01-26 10:41:21 -06:00
i386.c x86/PCI: Make a kernel-doc comment a normal one 2020-11-27 13:43:09 +01:00
init.c x86/pci: Create PCI/MSI irqdomain after x86_init.pci.arch_init() 2021-02-10 22:06:47 +01:00
intel_mid_pci.c x86/PCI: Describe @reg for type1_access_ok() 2021-02-15 20:10:30 +01:00
irq.c x86: Avoid magic number with ELCR register accesses 2021-08-10 23:31:43 +02:00
legacy.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
Makefile x86/PCI: Replace deprecated EXTRA_CFLAGS with ccflags-y 2019-11-21 07:49:27 -06:00
mmconfig_32.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 387 2019-06-05 17:37:11 +02:00
mmconfig_64.c remove ioremap_nocache and devm_ioremap_nocache 2020-01-06 09:45:59 +01:00
mmconfig-shared.c x86/pci: Return true/false (not 1/0) from bool functions 2021-05-27 18:51:17 -05:00
numachip.c x86/PCI: Add pci_numachip_init() declaration 2021-08-12 14:07:31 -05:00
olpc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
pcbios.c maccess: rename probe_kernel_address to get_kernel_nofault 2020-06-18 11:14:40 -07:00
sta2x11-fixup.c x86/PCI: sta2x11: switch from 'pci_' to 'dma_' API 2021-09-02 11:36:56 -05:00
xen.c x86/pci/xen: Use msi_for_each_desc() 2021-12-16 22:22:18 +01:00