aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/nommu.c52
-rw-r--r--mm/percpu.c3
2 files changed, 40 insertions, 15 deletions
diff --git a/mm/nommu.c b/mm/nommu.c
index cb86e7d5e7f5..c4c542c736a9 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1971,21 +1971,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1971} 1971}
1972EXPORT_SYMBOL(filemap_fault); 1972EXPORT_SYMBOL(filemap_fault);
1973 1973
1974/* 1974static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
1975 * Access another process' address space. 1975 unsigned long addr, void *buf, int len, int write)
1976 * - source/target buffer must be kernel space
1977 */
1978int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
1979{ 1976{
1980 struct vm_area_struct *vma; 1977 struct vm_area_struct *vma;
1981 struct mm_struct *mm;
1982
1983 if (addr + len < addr)
1984 return 0;
1985
1986 mm = get_task_mm(tsk);
1987 if (!mm)
1988 return 0;
1989 1978
1990 down_read(&mm->mmap_sem); 1979 down_read(&mm->mmap_sem);
1991 1980
@@ -2010,6 +1999,43 @@ int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, in
2010 } 1999 }
2011 2000
2012 up_read(&mm->mmap_sem); 2001 up_read(&mm->mmap_sem);
2002
2003 return len;
2004}
2005
2006/**
2007 * @access_remote_vm - access another process' address space
2008 * @mm: the mm_struct of the target address space
2009 * @addr: start address to access
2010 * @buf: source or destination buffer
2011 * @len: number of bytes to transfer
2012 * @write: whether the access is a write
2013 *
2014 * The caller must hold a reference on @mm.
2015 */
2016int access_remote_vm(struct mm_struct *mm, unsigned long addr,
2017 void *buf, int len, int write)
2018{
2019 return __access_remote_vm(NULL, mm, addr, buf, len, write);
2020}
2021
2022/*
2023 * Access another process' address space.
2024 * - source/target buffer must be kernel space
2025 */
2026int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
2027{
2028 struct mm_struct *mm;
2029
2030 if (addr + len < addr)
2031 return 0;
2032
2033 mm = get_task_mm(tsk);
2034 if (!mm)
2035 return 0;
2036
2037 len = __access_remote_vm(tsk, mm, addr, buf, len, write);
2038
2013 mmput(mm); 2039 mmput(mm);
2014 return len; 2040 return len;
2015} 2041}
diff --git a/mm/percpu.c b/mm/percpu.c
index 3f930018aa60..55d4d113fbd3 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1008,8 +1008,7 @@ phys_addr_t per_cpu_ptr_to_phys(void *addr)
1008 } 1008 }
1009 1009
1010 if (in_first_chunk) { 1010 if (in_first_chunk) {
1011 if ((unsigned long)addr < VMALLOC_START || 1011 if (!is_vmalloc_addr(addr))
1012 (unsigned long)addr >= VMALLOC_END)
1013 return __pa(addr); 1012 return __pa(addr);
1014 else 1013 else
1015 return page_to_phys(vmalloc_to_page(addr)); 1014 return page_to_phys(vmalloc_to_page(addr));