[PATCH] NOMMU: Use find_vma() rather than reimplementing a VMA search



From: David Howells <dhowells@xxxxxxxxxx>

Use find_vma() in the NOMMU version of access_process_vm() rather than
reimplementing it.

Signed-Off-By: David Howells <dhowells@xxxxxxxxxx>
---

mm/nommu.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/mm/nommu.c b/mm/nommu.c
index 663ec1c..51e17b9 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1039,6 +1039,7 @@ unsigned long do_mremap(unsigned long ad

/*
* Look up the first VMA which satisfies addr < vm_end, NULL if none
+ * - should be called with mm->mmap_sem at least readlocked
*/
struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
{
@@ -1213,7 +1214,6 @@ struct page *filemap_nopage(struct vm_ar
*/
int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
{
- struct vm_list_struct *vml;
struct vm_area_struct *vma;
struct mm_struct *mm;

@@ -1227,13 +1227,8 @@ int access_process_vm(struct task_struct
down_read(&mm->mmap_sem);

/* the access must start within one of the target process's mappings */
- for (vml = mm->context.vmlist; vml; vml = vml->next)
- if (addr >= vml->vma->vm_start && addr < vml->vma->vm_end)
- break;
-
- if (vml) {
- vma = vml->vma;
-
+ vma = find_vma(mm, addr);
+ if (vma) {
/* don't overrun this mapping */
if (addr + len >= vma->vm_end)
len = vma->vm_end - addr;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [RFC/PATCH] nommu: fix ksize() abuse
    ... Does kobjsize exisst for!nommu? ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH] CONFIG_PACKET_MMAP should depend on MMU
    ... I will apply this patch. ... vm_insert_pagein the noMMU case? ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [PATCH] [2/2] x86_64: Fix CONFIG_IOMMU_DEBUG
    ... where no HW IOMMU is present in the machine and we end up using nommu, ... leaving force_iommu set to 1 causes dma_alloc_coherent to do the wrong ... Therefore, if we end up using nommu, make sure force_iommu is ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)