summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mm/internal.h1
-rw-r--r--mm/memblock.c5
-rw-r--r--mm/mm_init.c5
3 files changed, 11 insertions, 0 deletions
diff --git a/mm/internal.h b/mm/internal.h
index 5a03bc4782a2..a037b1b37f6d 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1022,6 +1022,7 @@ static inline bool gup_must_unshare(struct vm_area_struct *vma,
}
extern bool mirrored_kernelcore;
+extern bool memblock_has_mirror(void);
static inline bool vma_soft_dirty_enabled(struct vm_area_struct *vma)
{
diff --git a/mm/memblock.c b/mm/memblock.c
index f9e61e565a53..913b2520a9a0 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -161,6 +161,11 @@ static int memblock_can_resize __initdata_memblock;
static int memblock_memory_in_slab __initdata_memblock;
static int memblock_reserved_in_slab __initdata_memblock;
+bool __init_memblock memblock_has_mirror(void)
+{
+ return system_has_some_mirror;
+}
+
static enum memblock_flags __init_memblock choose_memblock_flags(void)
{
return system_has_some_mirror ? MEMBLOCK_MIRROR : MEMBLOCK_NONE;
diff --git a/mm/mm_init.c b/mm/mm_init.c
index a2fbaa8d917f..2a19f3151661 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -376,6 +376,11 @@ static void __init find_zone_movable_pfns_for_nodes(void)
if (mirrored_kernelcore) {
bool mem_below_4gb_not_mirrored = false;
+ if (!memblock_has_mirror()) {
+ pr_warn("The system has no mirror memory, ignore kernelcore=mirror.\n");
+ goto out;
+ }
+
for_each_mem_region(r) {
if (memblock_is_mirror(r))
continue;