提交 19ab5d6d 编写于 作者: C Chen Zhou 提交者: Xie XiuQi

arm64: kdump: support reserving crashkernel above 4G

hulk inclusion
category: feature
bugzilla: 12800
CVE: NA

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

When crashkernel is reserved above 4G in memory, kernel should
reserve some amount of low memory for swiotlb and some DMA buffers.

Kernel would try to allocate at least 256M below 4G automatically
as x86_64 if crashkernel is above 4G. Meanwhile, support
crashkernel=X,[high,low] in arm64.
Signed-off-by: NChen Zhou <chenzhou10@huawei.com>
Reviewed-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 ca2e5195
...@@ -28,6 +28,9 @@ ...@@ -28,6 +28,9 @@
#define KEXEC_ARCH KEXEC_ARCH_AARCH64 #define KEXEC_ARCH KEXEC_ARCH_AARCH64
/* 2M alignment for crash kernel regions */
#define CRASH_ALIGN SZ_2M
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
/** /**
......
...@@ -253,6 +253,9 @@ static void __init request_standard_resources(void) ...@@ -253,6 +253,9 @@ static void __init request_standard_resources(void)
request_resource(res, &kernel_data); request_resource(res, &kernel_data);
#ifdef CONFIG_KEXEC_CORE #ifdef CONFIG_KEXEC_CORE
/* Userspace will find "Crash kernel" region in /proc/iomem. */ /* Userspace will find "Crash kernel" region in /proc/iomem. */
if (crashk_low_res.end && crashk_low_res.start >= res->start &&
crashk_low_res.end <= res->end)
request_resource(res, &crashk_low_res);
if (crashk_res.end && crashk_res.start >= res->start && if (crashk_res.end && crashk_res.start >= res->start &&
crashk_res.end <= res->end) crashk_res.end <= res->end)
request_resource(res, &crashk_res); request_resource(res, &crashk_res);
......
...@@ -94,20 +94,30 @@ early_param("initrd", early_initrd); ...@@ -94,20 +94,30 @@ early_param("initrd", early_initrd);
static void __init reserve_crashkernel(void) static void __init reserve_crashkernel(void)
{ {
unsigned long long crash_base, crash_size; unsigned long long crash_base, crash_size;
bool high = false;
int ret; int ret;
ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(), ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
&crash_size, &crash_base); &crash_size, &crash_base);
/* no crashkernel= or invalid value specified */ /* no crashkernel= or invalid value specified */
if (ret || !crash_size) if (ret || !crash_size) {
return; /* crashkernel=X,high */
ret = parse_crashkernel_high(boot_command_line,
memblock_phys_mem_size(),
&crash_size, &crash_base);
if (ret || !crash_size)
return;
high = true;
}
crash_size = PAGE_ALIGN(crash_size); crash_size = PAGE_ALIGN(crash_size);
if (crash_base == 0) { if (crash_base == 0) {
/* Current arm64 boot protocol requires 2MB alignment */ /* Current arm64 boot protocol requires 2MB alignment */
crash_base = memblock_find_in_range(0, ARCH_LOW_ADDRESS_LIMIT, crash_base = memblock_find_in_range(0,
crash_size, SZ_2M); high ? memblock_end_of_DRAM()
: ARCH_LOW_ADDRESS_LIMIT,
crash_size, CRASH_ALIGN);
if (crash_base == 0) { if (crash_base == 0) {
pr_warn("cannot allocate crashkernel (size:0x%llx)\n", pr_warn("cannot allocate crashkernel (size:0x%llx)\n",
crash_size); crash_size);
...@@ -125,13 +135,18 @@ static void __init reserve_crashkernel(void) ...@@ -125,13 +135,18 @@ static void __init reserve_crashkernel(void)
return; return;
} }
if (!IS_ALIGNED(crash_base, SZ_2M)) { if (!IS_ALIGNED(crash_base, CRASH_ALIGN)) {
pr_warn("cannot reserve crashkernel: base address is not 2MB aligned\n"); pr_warn("cannot reserve crashkernel: base address is not 2MB aligned\n");
return; return;
} }
} }
memblock_reserve(crash_base, crash_size); memblock_reserve(crash_base, crash_size);
if (crash_base >= SZ_4G && reserve_crashkernel_low()) {
memblock_free(crash_base, crash_size);
return;
}
pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n", pr_info("crashkernel reserved: 0x%016llx - 0x%016llx (%lld MB)\n",
crash_base, crash_base + crash_size, crash_size >> 20); crash_base, crash_base + crash_size, crash_size >> 20);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册