mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:04:51 +01:00
kernel/crash: handle multi-page vmcoreinfo in crash kernel copy
kimage_crash_copy_vmcoreinfo() currently assumes vmcoreinfo fits in a single page. This breaks if VMCOREINFO_BYTES exceeds PAGE_SIZE. Allocate the required order of control pages and vmap all pages needed to safely copy vmcoreinfo into the crash kernel image. Link: https://lkml.kernel.org/r/20251216132801.807260-3-pnina.feder@mobileye.com Signed-off-by: Pnina Feder <pnina.feder@mobileye.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Baoquan He <bhe@redhat.com> Cc: Dave Young <dyoung@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
76103d1b26
commit
b5bfcc1ffe
1 changed files with 13 additions and 4 deletions
|
|
@ -44,9 +44,15 @@ note_buf_t __percpu *crash_notes;
|
|||
|
||||
int kimage_crash_copy_vmcoreinfo(struct kimage *image)
|
||||
{
|
||||
struct page *vmcoreinfo_page;
|
||||
struct page *vmcoreinfo_base;
|
||||
struct page *vmcoreinfo_pages[DIV_ROUND_UP(VMCOREINFO_BYTES, PAGE_SIZE)];
|
||||
unsigned int order, nr_pages;
|
||||
int i;
|
||||
void *safecopy;
|
||||
|
||||
nr_pages = DIV_ROUND_UP(VMCOREINFO_BYTES, PAGE_SIZE);
|
||||
order = get_order(VMCOREINFO_BYTES);
|
||||
|
||||
if (!IS_ENABLED(CONFIG_CRASH_DUMP))
|
||||
return 0;
|
||||
if (image->type != KEXEC_TYPE_CRASH)
|
||||
|
|
@ -61,12 +67,15 @@ int kimage_crash_copy_vmcoreinfo(struct kimage *image)
|
|||
* happens to generate vmcoreinfo note, hereby we rely on
|
||||
* vmap for this purpose.
|
||||
*/
|
||||
vmcoreinfo_page = kimage_alloc_control_pages(image, 0);
|
||||
if (!vmcoreinfo_page) {
|
||||
vmcoreinfo_base = kimage_alloc_control_pages(image, order);
|
||||
if (!vmcoreinfo_base) {
|
||||
pr_warn("Could not allocate vmcoreinfo buffer\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
safecopy = vmap(&vmcoreinfo_page, 1, VM_MAP, PAGE_KERNEL);
|
||||
for (i = 0; i < nr_pages; i++)
|
||||
vmcoreinfo_pages[i] = vmcoreinfo_base + i;
|
||||
|
||||
safecopy = vmap(vmcoreinfo_pages, nr_pages, VM_MAP, PAGE_KERNEL);
|
||||
if (!safecopy) {
|
||||
pr_warn("Could not vmap vmcoreinfo buffer\n");
|
||||
return -ENOMEM;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue