+ vmcore-support-mmap-on-proc-vmcore.patch added to -mm tree
Subsystems (2)
[email protected]
maintainerSubject: + vmcore-support-mmap-on-proc-vmcore.patch added to -mm tree
To: [email protected],[email protected],[email protected],[email protected],[email protected],[email protected]
From: [email protected]
Date: Thu, 23 May 2013 17:20:41 -0700
The patch titled
Subject: vmcore: support mmap() on /proc/vmcore
has been added to the -mm tree. Its filename is
vmcore-support-mmap-on-proc-vmcore.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: HATAYAMA Daisuke <[email protected]>
Subject: vmcore: support mmap() on /proc/vmcore
This patch introduces mmap_vmcore().
Don't permit writable nor executable mapping even with mprotect() because this mmap() is aimed at reading crash dump memory. Non-writable mapping is also requirement of remap_pfn_range() when mapping linear pages on non-consecutive physical pages; see is_cow_mapping().
Set VM_MIXEDMAP flag to remap memory by remap_pfn_range and by remap_vmalloc_range_pertial at the same time for a single vma. do_munmap() can correctly clean partially remapped vma with two functions in abnormal case. See zap_pte_range(), vm_normal_page() and their comments for details.
On x86-32 PAE kernels, mmap() supports at most 16TB memory only. This limitation comes from the fact that the third argument of remap_pfn_range(), pfn, is of 32-bit length on x86-32: unsigned long.
---
fs/proc/vmcore.c | 86 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
fs/proc/vmcore.c renamed from fs/proc/vmcore.c~vmcore-support-mmap-on-proc-vmcore +86 -0
@@ -20,6 +20,7 @@#include <linux/init.h> #include <linux/crash_dump.h> #include <linux/list.h> +#include <linux/vmalloc.h> #include <asm/uaccess.h> #include <asm/io.h> #include "internal.h"
@@ -194,9 +195,94 @@ static ssize_t read_vmcore(struct file *return acc; } +static int mmap_vmcore (struct file *file,struct vm_area_struct *vma) +{ +size_t size = vma->vm_end - vma->vm_start; +u64 start, end, len, tsz; +struct vmcore *m; + + start = (u64 )vma->vm_pgoff <<PAGE_SHIFT ; + end = start + size; + +if (size > vmcore_size || end > vmcore_size) +return -EINVAL ; + +if (vma->vm_flags & (VM_WRITE |VM_EXEC )) +return -EPERM ; + + vma->vm_flags &= ~(VM_MAYWRITE |VM_MAYEXEC ); + vma->vm_flags |=VM_MIXEDMAP ; + + len =0 ; + +if (start < elfcorebuf_sz) { +u64 pfn; + + tsz = elfcorebuf_sz - start; +if (size < tsz) + tsz = size; + pfn =__pa (elfcorebuf + start) >>PAGE_SHIFT ; +if (remap_pfn_range (vma, vma->vm_start, pfn, tsz, + vma->vm_page_prot)) +return -EAGAIN ; + size -= tsz; + start += tsz; + len += tsz; + +if (size ==0 ) +return 0 ; + } + +if (start < elfcorebuf_sz + elfnotes_sz) { +void *kaddr; + + tsz = elfcorebuf_sz + elfnotes_sz - start; +if (size < tsz) + tsz = size; + kaddr = elfnotes_buf + start - elfcorebuf_sz; +if (remap_vmalloc_range_partial (vma, vma->vm_start + len, + kaddr, tsz)) { +do_munmap (vma->vm_mm, vma->vm_start, len); +return -EAGAIN ; + } + size -= tsz; + start += tsz; + len += tsz; + +if (size ==0 ) +return 0 ; + } + +list_for_each_entry (m, &vmcore_list, list) { +if (start < m->offset + m->size) { +u64 paddr =0 ; + + tsz = m->offset + m->size - start; +if (size < tsz) + tsz = size; + paddr = m->paddr + start - m->offset; +if (remap_pfn_range (vma, vma->vm_start + len, + paddr >>PAGE_SHIFT , tsz, + vma->vm_page_prot)) { +do_munmap (vma->vm_mm, vma->vm_start, len); +return -EAGAIN ; + } + size -= tsz; + start += tsz; + len += tsz; + +if (size ==0 ) +return 0 ; + } + } + +return 0 ; +} +static const struct file_operations proc_vmcore_operations = { .read = read_vmcore, .llseek = default_llseek, + .mmap = mmap_vmcore, };static struct vmcore *__init get_new_element (void )
_
Patches currently in -mm which might be from [email protected] are
include-linux-mmh-add-page_aligned-helper.patch
vmcore-clean-up-read_vmcore.patch vmcore-allocate-buffer-for-elf-headers-on-page-size-alignment.patch vmcore-allocate-buffer-for-elf-headers-on-page-size-alignment-fix.patch vmcore-treat-memory-chunks-referenced-by-pt_load-program-header-entries-in-page-size-boundary-in-vmcore_list.patch vmalloc-make-find_vm_area-check-in-range.patch vmalloc-introduce-remap_vmalloc_range_partial.patch vmalloc-introduce-remap_vmalloc_range_partial-fix.patch vmcore-allocate-elf-note-segment-in-the-2nd-kernel-vmalloc-memory.patch vmcore-allocate-elf-note-segment-in-the-2nd-kernel-vmalloc-memory-fix.patch vmcore-allow-user-process-to-remap-elf-note-segment-buffer.patch vmcore-allow-user-process-to-remap-elf-note-segment-buffer-fix.patch vmcore-calculate-vmcore-file-size-from-buffer-size-and-total-size-of-vmcore-objects.patch vmcore-support-mmap-on-proc-vmcore.patch
vmcore-support-mmap-on-proc-vmcore-fix.patch