]> git.hungrycats.org Git - linux/commitdiff
MIPS: init: Ensure reserved memory regions are not added to bootmem
authorMarcin Nowakowski <marcin.nowakowski@imgtec.com>
Wed, 23 Nov 2016 13:43:44 +0000 (14:43 +0100)
committerSasha Levin <alexander.levin@verizon.com>
Thu, 7 Dec 2017 02:20:13 +0000 (21:20 -0500)
[ Upstream commit e89ef66d7682f031f026eee6bba03c8c2248d2a9 ]

Memories managed through boot_mem_map are generally expected to define
non-crossing areas. However, if part of a larger memory block is marked
as reserved, it would still be added to bootmem allocator as an
available block and could end up being overwritten by the allocator.

Prevent this by explicitly marking the memory as reserved it if exists
in the range used by bootmem allocator.

Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/14608/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
arch/mips/kernel/setup.c

index db8c5cc684474958bdbc599e270b861799c30cb5..51e77841f9f6fdbf4006c2d31c01e0cad720f469 100644 (file)
@@ -496,6 +496,10 @@ static void __init bootmem_init(void)
                        continue;
                default:
                        /* Not usable memory */
+                       if (start > min_low_pfn && end < max_low_pfn)
+                               reserve_bootmem(boot_mem_map.map[i].addr,
+                                               boot_mem_map.map[i].size,
+                                               BOOTMEM_DEFAULT);
                        continue;
                }