Commit feed5ede authored by David Howells's avatar David Howells Committed by Linus Torvalds

[PATCH] FRV: Better mmap support in uClinux

The attached patch changes mm/nommu.c to better support mmap() when MMU
support is disabled (as it is in uClinux).

This was discussed on the uclibc mailing list in a thread revolving around the
following message:

	Date: Thu, 1 Apr 2004 12:05:50 +1000
	From: David McCullough <davidm@snapgear.com>
	To: David Howells <dhowells@redhat.com>
	Cc: Alexandre Oliva <aoliva@redhat.com>, uclibc@uclibc.org
	Subject: Re: [uClibc] mmaps for malloc should be private
	Message-ID: <20040401020550.GG3150@beast>

The revised rules are:

 (1) Anonymous mappings can be shared or private, read or write.

 (2) Chardevs can be mapped shared, provided they supply a get_unmapped_area()
     file operation and use that to set the address of the mapping (as a frame
     buffer driver might do, for instance).

 (3) Files (and blockdevs) cannot be mapped shared since it is not really
     possible to honour this by writing any changes back to the backing device.

 (4) Files (or sections thereof) can be mapped read-only private, in which case
     the mapped bit will be read into memory and shared, and its address will
     be returned. Any excess beyond EOF will be cleared.

 (5) Files (or sections thereof) can be mapped writable private, in which case
     a private copy of the mapped bit will be read into a new bit memory, and
     its address will be returned. Any excess beyond EOF will be cleared.

Mappings are per MM structure still. You can only unmap what you've mapped.

Fork semantics are irrelevant, since there's no fork.

A global list of VMA's is maintained to keep track of the bits of memory
currently mapped on the system.

The new binfmt makes use of (4) to implement shared libraries.
Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4236031c
...@@ -58,6 +58,7 @@ extern int sysctl_legacy_va_layout; ...@@ -58,6 +58,7 @@ extern int sysctl_legacy_va_layout;
* space that has a special rule for the page-fault handlers (ie a shared * space that has a special rule for the page-fault handlers (ie a shared
* library, the executable area etc). * library, the executable area etc).
*/ */
#ifdef CONFIG_MMU
struct vm_area_struct { struct vm_area_struct {
struct mm_struct * vm_mm; /* The address space we belong to. */ struct mm_struct * vm_mm; /* The address space we belong to. */
unsigned long vm_start; /* Our start address within vm_mm. */ unsigned long vm_start; /* Our start address within vm_mm. */
...@@ -111,6 +112,31 @@ struct vm_area_struct { ...@@ -111,6 +112,31 @@ struct vm_area_struct {
#endif #endif
}; };
#else
struct vm_area_struct {
struct list_head vm_link; /* system object list */
atomic_t vm_usage; /* count of refs */
unsigned long vm_start;
unsigned long vm_end;
pgprot_t vm_page_prot; /* access permissions of this VMA */
unsigned long vm_flags;
unsigned long vm_pgoff;
struct file *vm_file; /* file or device mapped */
};
struct mm_tblock_struct {
struct mm_tblock_struct *next;
struct vm_area_struct *vma;
};
extern struct list_head nommu_vma_list;
extern struct rw_semaphore nommu_vma_sem;
extern unsigned int kobjsize(const void *objp);
#endif
/* /*
* vm_flags.. * vm_flags..
*/ */
...@@ -603,6 +629,10 @@ int FASTCALL(set_page_dirty(struct page *page)); ...@@ -603,6 +629,10 @@ int FASTCALL(set_page_dirty(struct page *page));
int set_page_dirty_lock(struct page *page); int set_page_dirty_lock(struct page *page);
int clear_page_dirty_for_io(struct page *page); int clear_page_dirty_for_io(struct page *page);
extern unsigned long do_mremap(unsigned long addr,
unsigned long old_len, unsigned long new_len,
unsigned long flags, unsigned long new_addr);
/* /*
* Prototype to add a shrinker callback for ageable caches. * Prototype to add a shrinker callback for ageable caches.
* *
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment