[uClinux-dev] Re: uClinux-dist-test-20050808 released for testing

Zhang, Sonic Sonic.Zhang at analog.com
Wed Oct 12 21:42:50 EDT 2005


The change from MAP_SHARED to MAP_PRIVATE in kernel only affects memory
mapping on a valid file descriptor.
It is better to walk around it in kernel, because other applications
except for the module operations may also do this mapping.

Your opinion?

Sonic Zhang

-----Original Message-----
From: Greg Ungerer [mailto:gerg at snapgear.com] 
Sent: Wednesday, October 12, 2005 9:42 AM
To: Robin Getz
Cc: Matt Waddel; uclinux-dev at uclinux.org; sonicz at blackfin.uclinux.org
Subject: Re: [uClinux-dev] Re: uClinux-dist-test-20050808 released for

Hi Robin,

Robin Getz wrote:
> According to Matt Waddel, Greg Ungerer wrote:
>>  > Has anybody tried loadable modules in the 20050906  > 2.6.x 
>> release?
>> The underlying mmap implementation for uClinux changed a couple of 
>> 2.6 kernels back. I suspect this stems from those changes. But I'll 
>> need to dig deeper.
> We ran into this as well. And Sonic dug into it, and got a temporary 
> solution.
> According to the description in file Documentation/nommu-mmap.txt, the

> mmap infrastructure for shared memory map in NOMMU architecture was 
> changed in kernel 2.6.12.
> To provide shareable character device support, a driver must provide a
> file->f_op->get_unmapped_area() operation. It should also provide 
> file->backing
> device information with capabilities set to indicate the permitted 
> types of mapping on such devices.
> But most of the filesystem drivers don't implement the necessary 
> callback function and configuration in kernel 2.6.12. System call to 
> mmap with MAP_SHARED flag will fail for most uClinux architectures 
> (including blackfin).

I can't imagine many filesystems ever will actually do this...

> So, Sonic worked around this issue in our cvs by changing flag 
> MAP_SHARED to MAP_PRIVATE. Then, modules work just as they were in 
> older kernels.
> Quick and dirty hack:

Or a cleaner way to do this is just change the call to mmap in
busybox/modutils/insmod.c to:

diff -u -r1.7 insmod.c
--- insmod.c    5 Aug 2005 01:08:49 -0000       1.7
+++ insmod.c    12 Oct 2005 01:32:14 -0000
@@ -4095,7 +4095,7 @@

         fstat(fd, &st);
         len = st.st_size;
-       map = mmap(NULL, len, PROT_READ, MAP_SHARED, fd, 0);
+       map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0);
         if (map == MAP_FAILED) {
                 bb_perror_msg_and_die("cannot mmap `%s'", filename);

At least you are only effecting the mmap call that we know is a problem
currently :-)

David (Howells) is it the case that the busybox/insmod should be using


Greg Ungerer  --  Chief Software Dude       EMAIL:     gerg at snapgear.com
SnapGear -- a CyberGuard Company            PHONE:       +61 7 3435 2888
825 Stanley St,                             FAX:         +61 7 3891 3630
Woolloongabba, QLD, 4102, Australia         WEB: http://www.SnapGear.com

More information about the uClinux-dev mailing list