linux-stable/arch/x86
Mike Rapoport f1d4d47c58 x86/setup: Always reserve the first 1M of RAM
There are BIOSes that are known to corrupt the memory under 1M, or more
precisely under 640K because the memory above 640K is anyway reserved
for the EGA/VGA frame buffer and BIOS.

To prevent usage of the memory that will be potentially clobbered by the
kernel, the beginning of the memory is always reserved. The exact size
of the reserved area is determined by CONFIG_X86_RESERVE_LOW build time
and the "reservelow=" command line option. The reserved range may be
from 4K to 640K with the default of 64K. There are also configurations
that reserve the entire 1M range, like machines with SandyBridge graphic
devices or systems that enable crash kernel.

In addition to the potentially clobbered memory, EBDA of unknown size may
be as low as 128K and the memory above that EBDA start is also reserved
early.

It would have been possible to reserve the entire range under 1M unless for
the real mode trampoline that must reside in that area.

To accommodate placement of the real mode trampoline and keep the memory
safe from being clobbered by BIOS, reserve the first 64K of RAM before
memory allocations are possible and then, after the real mode trampoline
is allocated, reserve the entire range from 0 to 1M.

Update trim_snb_memory() and reserve_real_mode() to avoid redundant
reservations of the same memory range.

Also make sure the memory under 1M is not getting freed by
efi_free_boot_services().

 [ bp: Massage commit message and comments. ]

Fixes: a799c2bd29 ("x86/setup: Consolidate early memory reservations")
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Hugh Dickins <hughd@google.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=213177
Link: https://lkml.kernel.org/r/20210601075354.5149-2-rppt@kernel.org
2021-06-03 19:57:55 +02:00
..
boot x86/boot/compressed: Enable -Wundef 2021-05-12 21:39:56 +02:00
configs
crypto
entry quota: Disable quotactl_path syscall 2021-05-17 14:39:56 +02:00
events perf/x86/lbr: Remove cpuc->lbr_xsave allocation from atomic context 2021-05-18 12:53:47 +02:00
hyperv
ia32
include x86/cpufeatures: Force disable X86_FEATURE_ENQCMD and remove update_pasid() 2021-06-03 16:33:09 +02:00
kernel x86/setup: Always reserve the first 1M of RAM 2021-06-03 19:57:55 +02:00
kvm - Enable -Wundef for the compressed kernel build stage 2021-05-16 09:31:06 -07:00
lib
math-emu
mm x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG 2021-05-10 07:51:38 +02:00
net
pci x86/msr: Rename MSR_K8_SYSCFG to MSR_AMD64_SYSCFG 2021-05-10 07:51:38 +02:00
platform x86/setup: Always reserve the first 1M of RAM 2021-06-03 19:57:55 +02:00
power
purgatory
ras
realmode x86/setup: Always reserve the first 1M of RAM 2021-06-03 19:57:55 +02:00
tools
um
video
xen x86/Xen: swap NX determination and GDT setup on BSP 2021-05-21 09:53:52 +02:00
.gitignore
Kbuild
Kconfig x86/Kconfig: introduce ARCH_MHP_MEMMAP_ON_MEMORY_ENABLE 2021-05-05 11:27:27 -07:00
Kconfig.assembler
Kconfig.cpu
Kconfig.debug
Makefile x86/build: Fix location of '-plugin-opt=' flags 2021-05-19 13:05:53 +02:00
Makefile.um
Makefile_32.cpu