2003-02-08 23:42:48

by Jerome de Vivie

[permalink] [raw]
Subject: mmap inside kernel memory.


"mmap" seems to be design for mapping file or device inside a process
memory. Is it possible to map a file into the kernel virtual memory ?

kind regards,

j.

--
J?r?me de Vivie


2003-02-08 23:50:41

by Rik van Riel

[permalink] [raw]
Subject: Re: mmap inside kernel memory.

On Sun, 9 Feb 2003, Jerome de Vivie wrote:

> "mmap" seems to be design for mapping file or device inside a process
> memory. Is it possible to map a file into the kernel virtual memory ?

In theory yes (using vmalloc space), but you really don't want to.

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/ http://guru.conectiva.com/
Current spamtrap: <a href=mailto:"[email protected]">[email protected]</a>

2003-02-09 00:34:57

by Jerome de Vivie

[permalink] [raw]
Subject: Re: mmap inside kernel memory.

Rik van Riel wrote:
>
> On Sun, 9 Feb 2003, Jerome de Vivie wrote:
>
> > "mmap" seems to be design for mapping file or device inside a process
> > memory. Is it possible to map a file into the kernel virtual memory ?
>
> In theory yes (using vmalloc space), but you really don't want to.

Yes, it's very tricky ! I have (na?vly) try this:

vaddr=vmalloc(len);
do_mmap(file ,kvaddr ,len ,PROT_READ|PROT_WRITE ,MAP_FIXED|MAP_PRIVATE
,0);

Here, do_mmap check if the addresse match inside current process and
return me -ENOMEM. Are there others functions which i could use to
associate this file and a vmalloc'ed space ?


j.

--
J?r?me de Vivie

2003-02-09 01:42:17

by Rik van Riel

[permalink] [raw]
Subject: Re: mmap inside kernel memory.

On Sun, 9 Feb 2003, Jerome de Vivie wrote:

> Here, do_mmap check if the addresse match inside current process and
> return me -ENOMEM. Are there others functions which i could use to
> associate this file and a vmalloc'ed space ?

As I said, you don't want to mmap a file in kernel memory.
You only have 128 MB of vmalloc space and you don't want to
waste it.

If you know which addresses within the file you want to
access, why don't you access them through the page cache
functions ?

regards,

Rik
--
Bravely reimplemented by the knights who say "NIH".
http://www.surriel.com/ http://guru.conectiva.com/
Current spamtrap: <a href=mailto:"[email protected]">[email protected]</a>

2003-02-09 12:27:32

by Jerome de Vivie

[permalink] [raw]
Subject: Re: mmap inside kernel memory.

Rik van Riel wrote:
>
> On Sun, 9 Feb 2003, Jerome de Vivie wrote:
>
> > Here, do_mmap check if the addresse match inside current process and
> > return me -ENOMEM. Are there others functions which i could use to
> > associate this file and a vmalloc'ed space ?
>
> As I said, you don't want to mmap a file in kernel memory.
> You only have 128 MB of vmalloc space and you don't want to
> waste it.
>
> If you know which addresses within the file you want to
> access, why don't you access them through the page cache
> functions ?

Ok. I will go through the page cache.

regards,

j.

--
J?r?me de Vivie