linux/arch/x86
Hans de Goede 7f7b4236f2 x86/PCI: Ignore E820 reservations for bridge windows on newer systems
Some BIOS-es contain a bug where they add addresses which map to system
RAM in the PCI host bridge window returned by the ACPI _CRS method, see
commit 4dc2287c18 ("x86: avoid E820 regions when allocating address
space").

To work around this bug Linux excludes E820 reserved addresses when
allocating addresses from the PCI host bridge window since 2010.

Recently (2019) some systems have shown-up with E820 reservations which
cover the entire _CRS returned PCI bridge memory window, causing all
attempts to assign memory to PCI BARs which have not been setup by the
BIOS to fail. For example here are the relevant dmesg bits from a
Lenovo IdeaPad 3 15IIL 81WE:

 [mem 0x000000004bc50000-0x00000000cfffffff] reserved
 pci_bus 0000:00: root bus resource [mem 0x65400000-0xbfffffff window]

The ACPI specifications appear to allow this new behavior:

The relationship between E820 and ACPI _CRS is not really very clear.
ACPI v6.3, sec 15, table 15-374, says AddressRangeReserved means:

  This range of addresses is in use or reserved by the system and is
  not to be included in the allocatable memory pool of the operating
  system's memory manager.

and it may be used when:

  The address range is in use by a memory-mapped system device.

Furthermore, sec 15.2 says:

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

A PCI host bridge qualifies as a baseboard memory-mapped I/O device,
and its apertures are in use and certainly should not be included in
the general allocatable pool, so the fact that some BIOS-es reports
the PCI aperture as "reserved" in E820 doesn't seem like a BIOS bug.

So it seems that the excluding of E820 reserved addresses is a mistake.

Ideally Linux would fully stop excluding E820 reserved addresses,
but then the old systems this was added for will regress.
Instead keep the old behavior for old systems, while ignoring
the E820 reservations for any systems from now on.

Old systems are defined here as BIOS year < 2018, this was chosen to make
sure that E820 reservations will not be used on the currently affected
systems, while at the same time also taking into account that the systems
for which the E820 checking was originally added may have received BIOS
updates for quite a while (esp. CVE related ones), giving them a more
recent BIOS year then 2010.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=206459
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1868899
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1871793
BugLink: https://bugs.launchpad.net/bugs/1878279
BugLink: https://bugs.launchpad.net/bugs/1931715
BugLink: https://bugs.launchpad.net/bugs/1932069
BugLink: https://bugs.launchpad.net/bugs/1921649
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-01-11 16:22:37 +01:00
..
boot - A fix for cross-compiling the compressed stub on arm64 with clang 2022-01-10 10:18:58 -08:00
configs configs: remove the obsolete CONFIG_INPUT_POLLDEV 2021-09-08 11:50:28 -07:00
crypto lib/crypto: blake2s: include as built-in 2022-01-07 00:25:25 +01:00
entry x86/vdso: Remove -nostdlib compiler flag 2021-12-30 14:08:20 +01:00
events - The mandatory set of random minor cleanups all over tip 2022-01-10 10:02:27 -08:00
hyperv x86/hyperv: Move required MSRs check to initial platform probing 2021-11-15 12:37:08 +00:00
ia32 audit/stable-5.16 PR 20211101 2021-11-01 21:17:39 -07:00
include - First part of a series to move the AMD address translation code from 2022-01-10 11:43:09 -08:00
kernel x86/PCI: Ignore E820 reservations for bridge windows on newer systems 2022-01-11 16:22:37 +01:00
kvm - Add support for decoding instructions which do MMIO accesses in order 2022-01-10 10:00:03 -08:00
lib - First part of a series to move the AMD address translation code from 2022-01-10 11:43:09 -08:00
math-emu x86/math-emu: Convert to fpstate 2021-10-20 23:57:54 +02:00
mm slab changes for 5.17 2022-01-10 11:58:12 -08:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-12-31 14:35:40 +00:00
pci xen: branch for v5.16-rc1 2021-11-10 11:14:21 -08:00
platform - A DT compatibility fix for the Intel media processor CE4100 driver 2022-01-10 09:21:36 -08:00
power x86/fpu: Replace the includes of fpu/internal.h 2021-10-20 15:27:29 +02:00
purgatory x86/purgatory: Remove -nostdlib compiler flag 2021-12-30 14:13:06 +01:00
ras
realmode - Flush *all* mappings from the TLB after switching to the trampoline 2022-01-10 09:51:38 -08:00
tools x86/build: Use the proper name CONFIG_FW_LOADER 2021-12-29 22:20:38 +01:00
um um: fix stub location calculation 2021-08-26 22:28:03 +02:00
video
xen x86/xen: Add xenpv_restore_regs_and_return_to_usermode() 2021-12-03 19:21:15 +01:00
.gitignore
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig - Add support for handling hw errors in SGX pages: poisoning, recovering 2022-01-10 09:44:09 -08:00
Kconfig.assembler
Kconfig.cpu x86/CPU: Add support for Vortex CPUs 2021-10-21 15:49:07 +02:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile Kbuild updates for v5.16 2021-11-08 09:15:45 -08:00
Makefile_32.cpu x86/build: Do not add -falign flags unconditionally for clang 2021-09-19 10:35:53 +09:00
Makefile.um