lkml.org 
[lkml]   [2009]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH] NOMMU: add support for Memory Protection Units (MPU)
    On Tue, Jul 14, 2009 at 12:14, Johannes Weiner wrote:
    > On Tue, Jul 14, 2009 at 10:22:20AM -0400, Mike Frysinger wrote:
    >> --- a/mm/nommu.c
    >> +++ b/mm/nommu.c
    >> @@ -640,11 +641,23 @@ static void add_vma_to_mm(struct mm_struct *mm, struct vm_area_struct *vma)
    >>       struct vm_area_struct *pvma, **pp;
    >>       struct address_space *mapping;
    >>       struct rb_node **p, *parent;
    >> +#ifdef CONFIG_MPU
    >> +     long start;
    >> +#endif
    >>
    >>       kenter(",%p", vma);
    >>
    >>       BUG_ON(!vma->vm_region);
    >>
    >> +#ifdef CONFIG_MPU
    >> +     start = vma->vm_start & PAGE_MASK;
    >> +     while (start < vma->vm_end) {
    >> +             protect_page(mm, start, vma->vm_flags);
    >> +             start += PAGE_SIZE;
    >> +     }
    >> +     update_protections(mm);
    >> +#endif
    >> +
    >>       mm->map_count++;
    >>       vma->vm_mm = mm;
    >>
    >> @@ -707,9 +720,21 @@ static void delete_vma_from_mm(struct vm_area_struct *vma)
    >>       struct vm_area_struct **pp;
    >>       struct address_space *mapping;
    >>       struct mm_struct *mm = vma->vm_mm;
    >> +#ifdef CONFIG_MPU
    >> +     long start;
    >> +#endif
    >>
    >>       kenter("%p", vma);
    >>
    >> +#ifdef CONFIG_MPU
    >> +     start = vma->vm_start & PAGE_MASK;
    >> +     while (start < vma->vm_end) {
    >> +             protect_page(mm, start, 0);
    >> +             start += PAGE_SIZE;
    >> +     }
    >> +     update_protections(mm);
    >> +#endif
    >
    > How about refactoring that into one function?  Saves all but one
    > #ifdef.

    makes sense to me, thanks
    -mike
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2009-07-14 18:51    [W:2.984 / U:0.172 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site