提交 6075cf62 编写于 作者: P Peng Liu 提交者: Zheng Zengkai

arm64: Add memmap reserve range check to avoid conflict

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I59AN8
CVE: NA

--------------------------------

The user specificed memmap-reserve range may overlap in-use memory
region, and users are hard to avoid this due to KASLR. Thus, the
reduplicative memmap-reserve range should be ignored. Furthermore,
to be consistent with INITRD, the range that not in a memory region
will also be ignored.

Fixes: d05cfbd9 ("arm64: Add support for memmap kernel parameters")
Signed-off-by: NPeng Liu <liupeng256@huawei.com>
Reviewed-by: NKefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 acba9828
......@@ -2838,7 +2838,8 @@
[KNL,ACPI] Mark specific memory as reserved.
Region of memory to be reserved is from ss to ss+nn.
For ARM64, reserved memory must be in the range of
existed memory.
existed memory and do not overlap in-use memory region,
otherwise request will be ignored.
Example: Exclude memory from 0x18690000-0x1869ffff
memmap=64K$0x18690000
or
......
......@@ -298,7 +298,27 @@ static void __init reserve_memmap_regions(void)
for (i = 0; i < mbk_memmap_cnt; i++) {
base = mbk_memmap_regions[i].base;
size = mbk_memmap_regions[i].size;
memblock_reserve(base, size);
if (!memblock_is_region_memory(base, size)) {
pr_warn("memmap reserve: 0x%08llx - 0x%08llx is not a memory region - ignore\n",
base, base + size);
continue;
}
if (memblock_is_region_reserved(base, size)) {
pr_warn("memmap reserve: 0x%08llx - 0x%08llx overlaps in-use memory region - ignore\n",
base, base + size);
continue;
}
if (memblock_reserve(base, size)) {
pr_warn("memmap reserve: 0x%08llx - 0x%08llx failed\n",
base, base + size);
continue;
}
pr_info("memmap reserved: 0x%08llx - 0x%08llx (%lld MB)",
base, base + size, size >> 20);
memblock_mark_memmap(base, size);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册