x86/setup: Consolidate early memory reservations
authorMike Rapoport <rppt@linux.ibm.com>
Tue, 2 Mar 2021 10:04:05 +0000 (12:04 +0200)
committerBorislav Petkov <bp@suse.de>
Tue, 23 Mar 2021 16:13:17 +0000 (17:13 +0100)
commita799c2bd29d19c565f37fa038b31a0a1d44d0e4d
tree4f83ab3aa674911e59615c5378f46b8c6c68c224
parente14cfb3bdd0f82147d09e9f46bedda6302f28ee1
x86/setup: Consolidate early memory reservations

The early reservations of memory areas used by the firmware, bootloader,
kernel text and data are spread over setup_arch(). Moreover, some of them
happen *after* memblock allocations, e.g trim_platform_memory_ranges() and
trim_low_memory_range() are called after reserve_real_mode() that allocates
memory.

There was no corruption of these memory regions because memblock always
allocates memory either from the end of memory (in top-down mode) or above
the kernel image (in bottom-up mode). However, the bottom up mode is going
to be updated to span the entire memory [1] to avoid limitations caused by
KASLR.

Consolidate early memory reservations in a dedicated function to improve
robustness against future changes. Having the early reservations in one
place also makes it clearer what memory must be reserved before memblock
allocations are allowed.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Baoquan He <bhe@redhat.com>
Acked-by: Borislav Petkov <bp@suse.de>
Acked-by: David Hildenbrand <david@redhat.com>
Link: [1] https://lore.kernel.org/lkml/20201217201214.3414100-2-guro@fb.com
Link: https://lkml.kernel.org/r/20210302100406.22059-2-rppt@kernel.org
arch/x86/kernel/setup.c