Skip to content

Commit 76103d1

Browse files
Pnina Federakpm00
authored andcommitted
kernel: vmcoreinfo: allocate vmcoreinfo_data based on VMCOREINFO_BYTES
Patch series "vmcoreinfo: support VMCOREINFO_BYTES larger than PAGE_SIZE". VMCOREINFO_BYTES is defined as a configurable size, but multiple code paths implicitly assume it always fits into a single page. This series removes that assumption by allocating and mapping vmcoreinfo based on its actual size. Patch 1 updates vmcoreinfo allocation to use get_order(VMCOREINFO_BYTES). Patch 2 updates crash kernel handling to correctly allocate and map multiple pages when copying vmcoreinfo. This makes vmcoreinfo size consistent across the kernel and avoids future breakage if VMCOREINFO_BYTES grows. (No functional change when VMCOREINFO_BYTES == PAGE_SIZE.) This patch (of 2): VMCOREINFO_BYTES defines the size of vmcoreinfo data, but the current implementation assumes a single page allocation. Allocate vmcoreinfo_data using get_order(VMCOREINFO_BYTES) so that vmcoreinfo can safely grow beyond PAGE_SIZE. This avoids hidden assumptions and keeps vmcoreinfo size consistent across the kernel. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Pnina Feder <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Baoquan He <[email protected]> Cc: Dave Young <[email protected]> Cc: Vivek Goyal <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 61e9210 commit 76103d1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

kernel/vmcore_info.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ EXPORT_SYMBOL_GPL(hwerr_log_error_type);
137137

138138
static int __init crash_save_vmcoreinfo_init(void)
139139
{
140-
vmcoreinfo_data = (unsigned char *)get_zeroed_page(GFP_KERNEL);
140+
int order;
141+
order = get_order(VMCOREINFO_BYTES);
142+
vmcoreinfo_data = (unsigned char *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
141143
if (!vmcoreinfo_data) {
142144
pr_warn("Memory allocation for vmcoreinfo_data failed\n");
143145
return -ENOMEM;
@@ -146,7 +148,7 @@ static int __init crash_save_vmcoreinfo_init(void)
146148
vmcoreinfo_note = alloc_pages_exact(VMCOREINFO_NOTE_SIZE,
147149
GFP_KERNEL | __GFP_ZERO);
148150
if (!vmcoreinfo_note) {
149-
free_page((unsigned long)vmcoreinfo_data);
151+
free_pages((unsigned long)vmcoreinfo_data, order);
150152
vmcoreinfo_data = NULL;
151153
pr_warn("Memory allocation for vmcoreinfo_note failed\n");
152154
return -ENOMEM;

0 commit comments

Comments
 (0)