Skip to content

Commit

Permalink
LoongArch: Call early_init_fdt_scan_reserved_mem() earlier
Browse files Browse the repository at this point in the history
commit 9fa304b upstream.

The unflatten_and_copy_device_tree() function contains a call to
memblock_alloc(). This means that memblock is allocating memory before
any of the reserved memory regions are set aside in the arch_mem_init()
function which calls early_init_fdt_scan_reserved_mem(). Therefore,
there is a possibility for memblock to allocate from any of the
reserved memory regions.

Hence, move the call to early_init_fdt_scan_reserved_mem() to be earlier
in the init sequence, so that the reserved memory regions are set aside
before any allocations are done using memblock.

Cc: stable@vger.kernel.org
Fixes: 88d4d95 ("LoongArch: Add FDT booting support from efi system table")
Signed-off-by: Oreoluwa Babatunde <quic_obabatun@quicinc.com>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
chenhuacai authored and gregkh committed Mar 1, 2024
1 parent 5029790 commit ea459e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/loongarch/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ void __init platform_init(void)
acpi_gbl_use_default_register_widths = false;
acpi_boot_table_init();
#endif

early_init_fdt_scan_reserved_mem();
unflatten_and_copy_device_tree();

#ifdef CONFIG_NUMA
Expand Down Expand Up @@ -400,8 +402,6 @@ static void __init arch_mem_init(char **cmdline_p)

check_kernel_sections_mem();

early_init_fdt_scan_reserved_mem();

/*
* In order to reduce the possibility of kernel panic when failed to
* get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate
Expand Down

0 comments on commit ea459e6

Please sign in to comment.