* [PATCH] mm/nommu.c: fix mmap failed due to the vm_region codes
@ 2009-09-24 11:37 graff.yang
2009-09-24 12:29 ` David Howells
0 siblings, 1 reply; 2+ messages in thread
From: graff.yang @ 2009-09-24 11:37 UTC (permalink / raw)
To: dhowells, linux-kernel; +Cc: akpm, uclinux-dist-devel, graf.yang, Graff Yang
From: Graff Yang <graff.yang@gmail.com>
Due to the new vm_region codes, mmap will failed if it is MAP_PRIVATE,
or the get_unmapped_area() not do actual things.
Signed-off-by: Graff Yang <graff.yang@gmail.com>
---
mm/nommu.c | 30 +++++++++++++++++++++++-------
1 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 8d48424..3a5e989 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1067,13 +1067,22 @@ static unsigned long determine_vm_flags(struct file *file,
* set up a shared mapping on a file (the driver or filesystem provides and
* pins the storage)
*/
-static int do_mmap_shared_file(struct vm_area_struct *vma)
+static int do_mmap_shared_file(struct vm_area_struct *vma,
+ struct vm_region *region,
+ unsigned long len)
{
int ret;
ret = vma->vm_file->f_op->mmap(vma->vm_file, vma);
if (ret == 0) {
- vma->vm_region->vm_top = vma->vm_region->vm_end;
+ vma->vm_region->vm_top = vma->vm_end;
+ if (region) {
+ if (!region->vm_start)
+ region->vm_start = vma->vm_start;
+ if (!region->vm_end)
+ region->vm_end = vma->vm_end;
+ add_nommu_region(region);
+ }
return ret;
}
if (ret != -ENOSYS)
@@ -1107,7 +1116,12 @@ static int do_mmap_private(struct vm_area_struct *vma,
if (ret == 0) {
/* shouldn't return success if we're not sharing */
BUG_ON(!(vma->vm_flags & VM_MAYSHARE));
- vma->vm_region->vm_top = vma->vm_region->vm_end;
+ vma->vm_region->vm_top = vma->vm_end;
+ if (!region->vm_start)
+ region->vm_start = vma->vm_start;
+ if (!region->vm_end)
+ region->vm_end = vma->vm_end;
+ add_nommu_region(region);
return ret;
}
if (ret != -ENOSYS)
@@ -1187,6 +1201,7 @@ static int do_mmap_private(struct vm_area_struct *vma,
memset(base, 0, rlen);
}
+ add_nommu_region(region);
return 0;
error_free:
@@ -1325,7 +1340,7 @@ unsigned long do_mmap_pgoff(struct file *file,
vma->vm_flags |= VM_MAPPED_COPY;
} else {
kdebug("share mmap");
- ret = do_mmap_shared_file(vma);
+ ret = do_mmap_shared_file(vma, NULL, 0);
if (ret < 0) {
vma->vm_region = NULL;
vma->vm_start = 0;
@@ -1370,11 +1385,10 @@ unsigned long do_mmap_pgoff(struct file *file,
}
vma->vm_region = region;
- add_nommu_region(region);
/* set up the mapping */
if (file && vma->vm_flags & VM_SHARED)
- ret = do_mmap_shared_file(vma);
+ ret = do_mmap_shared_file(vma, region, len);
else
ret = do_mmap_private(vma, region, len);
if (ret < 0)
@@ -1397,7 +1411,9 @@ share:
return result;
error_put_region:
- __put_nommu_region(region);
+ up_write(&nommu_region_sem);
+ fput(region->vm_file);
+ kmem_cache_free(vm_region_jar, region);
if (vma) {
if (vma->vm_file) {
fput(vma->vm_file);
--
1.6.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mm/nommu.c: fix mmap failed due to the vm_region codes
2009-09-24 11:37 [PATCH] mm/nommu.c: fix mmap failed due to the vm_region codes graff.yang
@ 2009-09-24 12:29 ` David Howells
0 siblings, 0 replies; 2+ messages in thread
From: David Howells @ 2009-09-24 12:29 UTC (permalink / raw)
To: graff.yang; +Cc: dhowells, linux-kernel, akpm, uclinux-dist-devel, graf.yang
<graff.yang@gmail.com> wrote:
> Due to the new vm_region codes, mmap will failed if it is MAP_PRIVATE,
> or the get_unmapped_area() not do actual things.
Hmmm... Seems one of my debugging patches had a work around for this - all it
did was #ifdef-out the first if-statement in do_mmap_private(). That, however,
prevents XIP.
Sadly, your patch doesn't completely fix the problem either. The BUG in
add_nommu_region() barks.
Let me poke at it some more.
David
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-24 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-24 11:37 [PATCH] mm/nommu.c: fix mmap failed due to the vm_region codes graff.yang
2009-09-24 12:29 ` David Howells
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox