Skip to content

Commit 8aa83e6

Browse files
jgross1suryasaimadhu
authored andcommitted
x86/setup: Call early_reserve_memory() earlier
Commit in Fixes introduced early_reserve_memory() to do all needed initial memblock_reserve() calls in one function. Unfortunately, the call of early_reserve_memory() is done too late for Xen dom0, as in some cases a Xen hook called by e820__memory_setup() will need those memory reservations to have happened already. Move the call of early_reserve_memory() before the call of e820__memory_setup() in order to avoid such problems. Fixes: a799c2b ("x86/setup: Consolidate early memory reservations") Reported-by: Marek Marczykowski-Górecki <[email protected]> Signed-off-by: Juergen Gross <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Tested-by: Marek Marczykowski-Górecki <[email protected]> Tested-by: Nathan Chancellor <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected]
1 parent d4ffd5d commit 8aa83e6

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

arch/x86/kernel/setup.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,20 @@ void __init setup_arch(char **cmdline_p)
830830

831831
x86_init.oem.arch_setup();
832832

833+
/*
834+
* Do some memory reservations *before* memory is added to memblock, so
835+
* memblock allocations won't overwrite it.
836+
*
837+
* After this point, everything still needed from the boot loader or
838+
* firmware or kernel text should be early reserved or marked not RAM in
839+
* e820. All other memory is free game.
840+
*
841+
* This call needs to happen before e820__memory_setup() which calls the
842+
* xen_memory_setup() on Xen dom0 which relies on the fact that those
843+
* early reservations have happened already.
844+
*/
845+
early_reserve_memory();
846+
833847
iomem_resource.end = (1ULL << boot_cpu_data.x86_phys_bits) - 1;
834848
e820__memory_setup();
835849
parse_setup_data();
@@ -876,18 +890,6 @@ void __init setup_arch(char **cmdline_p)
876890

877891
parse_early_param();
878892

879-
/*
880-
* Do some memory reservations *before* memory is added to
881-
* memblock, so memblock allocations won't overwrite it.
882-
* Do it after early param, so we could get (unlikely) panic from
883-
* serial.
884-
*
885-
* After this point everything still needed from the boot loader or
886-
* firmware or kernel text should be early reserved or marked not
887-
* RAM in e820. All other memory is free game.
888-
*/
889-
early_reserve_memory();
890-
891893
#ifdef CONFIG_MEMORY_HOTPLUG
892894
/*
893895
* Memory used by the kernel cannot be hot-removed because Linux

0 commit comments

Comments
 (0)