* syscall __NR_mmap2
@ 2003-07-07 21:00 Richard B. Johnson
2003-07-07 21:32 ` Ulrich Drepper
2003-07-08 0:36 ` Jamie Lokier
0 siblings, 2 replies; 10+ messages in thread
From: Richard B. Johnson @ 2003-07-07 21:00 UTC (permalink / raw)
To: Linux kernel
Is anybody using __NR_mmap2 function call? It doesn't work in Linux
2.4.20. It returns nice values, but the address returned does not
have any relationship to what's really there!!
write(1, "Addr = 000b8000\n", 16) = 16
open("/dev/mem", O_RDWR) = 3
mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
write(1, "000B8000 FF FF FF FF FF FF FF F"..., 77) = 77
write(1, "000B8010 FF FF FF FF FF FF FF F"..., 77) = 77
write(1, "000B8020 FF FF FF FF FF FF FF F"..., 77) = 77
close(3) = 0
munmap(0xb8000, 8192) = 0
This should be displaying screen memory (it doesn't).
Does anybody care? Isn't this supposed to replace old_mmap() using
__NR_mmap? `strace` seems to think I have the right values in
the right registers. The returned value is correct, but as a
caddr_t, it doesn't point to what it's supposed to point to.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-07 21:00 syscall __NR_mmap2 Richard B. Johnson
@ 2003-07-07 21:32 ` Ulrich Drepper
2003-07-08 11:56 ` Richard B. Johnson
2003-07-08 0:36 ` Jamie Lokier
1 sibling, 1 reply; 10+ messages in thread
From: Ulrich Drepper @ 2003-07-07 21:32 UTC (permalink / raw)
To: root; +Cc: Linux kernel
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Richard B. Johnson wrote:
> write(1, "Addr = 000b8000\n", 16) = 16
> open("/dev/mem", O_RDWR) = 3
> mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
mmap64() (and if you compile glibc with an adequate minimal kernel
requirement mmap as well) is implemented using mmap2. It works nicely.
Admittedly, I haven't used the stock 2.4 kernel. And I also haven't
used /dev/mem. But at least for the first part I would expect to see
problem reports since the code is used and glibc wouldn't work.
In your code, assuming this is x86, do you really want to read the
memory starting at address 0xb8000000? This is what your code does. I
don't know enough about the kernel memory layout to say whether
something is supposed to be there or not.
- --
- --------------. ,-. 444 Castro Street
Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA
Red Hat `--' drepper at redhat.com `---------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/Cebv2ijCOnn/RHQRAukcAKCbI3cTMvmAsHxRWX2ralSqUlcp8ACfTBRU
PNoh4p0/XrWFWXk9JnbnNyk=
=DQ6S
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-07 21:32 ` Ulrich Drepper
@ 2003-07-08 11:56 ` Richard B. Johnson
0 siblings, 0 replies; 10+ messages in thread
From: Richard B. Johnson @ 2003-07-08 11:56 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Linux kernel
On Mon, 7 Jul 2003, Ulrich Drepper wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Richard B. Johnson wrote:
>
> > write(1, "Addr = 000b8000\n", 16) = 16
> > open("/dev/mem", O_RDWR) = 3
> > mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
>
> mmap64() (and if you compile glibc with an adequate minimal kernel
> requirement mmap as well) is implemented using mmap2. It works nicely.
> Admittedly, I haven't used the stock 2.4 kernel. And I also haven't
> used /dev/mem. But at least for the first part I would expect to see
> problem reports since the code is used and glibc wouldn't work.
>
> In your code, assuming this is x86, do you really want to read the
> memory starting at address 0xb8000000? This is what your code does. I
> don't know enough about the kernel memory layout to say whether
> something is supposed to be there or not.
>
Yes. Thanks. There is no known documentation that states that
the address to the function is in PAGES. Certainly, this will
work once I use pages instead of bytes.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-07 21:00 syscall __NR_mmap2 Richard B. Johnson
2003-07-07 21:32 ` Ulrich Drepper
@ 2003-07-08 0:36 ` Jamie Lokier
2003-07-08 11:54 ` Richard B. Johnson
1 sibling, 1 reply; 10+ messages in thread
From: Jamie Lokier @ 2003-07-08 0:36 UTC (permalink / raw)
To: Richard B. Johnson; +Cc: Linux kernel
Richard B. Johnson wrote:
> mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
You meant to write:
mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE,
MAP_SHARED|MAP_FIXED, 3, 0xb8000 >> 12);
The offset argument to mmap2 is divided by PAGE_SIZE.
That is the whole point of mmap2 :)
-- Jamie
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 0:36 ` Jamie Lokier
@ 2003-07-08 11:54 ` Richard B. Johnson
2003-07-08 13:59 ` Kurt Wall
2003-07-08 14:05 ` Jamie Lokier
0 siblings, 2 replies; 10+ messages in thread
From: Richard B. Johnson @ 2003-07-08 11:54 UTC (permalink / raw)
To: Jamie Lokier; +Cc: Linux kernel
On Tue, 8 Jul 2003, Jamie Lokier wrote:
> Richard B. Johnson wrote:
> > mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
>
> You meant to write:
>
> mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE,
> MAP_SHARED|MAP_FIXED, 3, 0xb8000 >> 12);
>
> The offset argument to mmap2 is divided by PAGE_SIZE.
> That is the whole point of mmap2 :)
>
> -- Jamie
Okay. Do you know where that's documented? Nothing in linux/Documentation,
and nothing in any headers. Do you have to read the code to find out?
So, the address is now the offset in PAGES, not bytes. Seems logical,
but there is no clue in any documentation.
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 11:54 ` Richard B. Johnson
@ 2003-07-08 13:59 ` Kurt Wall
2003-07-08 14:05 ` Jamie Lokier
1 sibling, 0 replies; 10+ messages in thread
From: Kurt Wall @ 2003-07-08 13:59 UTC (permalink / raw)
To: Richard B. Johnson; +Cc: Jamie Lokier, Linux kernel
Quoth Richard B. Johnson:
> On Tue, 8 Jul 2003, Jamie Lokier wrote:
>
> > Richard B. Johnson wrote:
> > > mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED, 3, 0xb8000) = 0xb8000
> >
> > You meant to write:
> >
> > mmap2(0xb8000, 8192, PROT_READ|PROT_WRITE,
> > MAP_SHARED|MAP_FIXED, 3, 0xb8000 >> 12);
> >
> > The offset argument to mmap2 is divided by PAGE_SIZE.
> > That is the whole point of mmap2 :)
> >
> > -- Jamie
>
> Okay. Do you know where that's documented? Nothing in linux/Documentation,
> and nothing in any headers. Do you have to read the code to find out?
>
> So, the address is now the offset in PAGES, not bytes. Seems logical,
> but there is no clue in any documentation.
With the possible exception of the man mmap2 ;-)
DESCRIPTION
The function mmap2 operates in exactly the same way as
mmap(2), except that the final argument specifies the off
set into the file in units of the system page size
(instead of bytes). This enables applications that use a
--
"I have a very firm grasp on reality! I can reach out and strangle it
any time!"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 11:54 ` Richard B. Johnson
2003-07-08 13:59 ` Kurt Wall
@ 2003-07-08 14:05 ` Jamie Lokier
2003-07-08 14:40 ` Richard B. Johnson
1 sibling, 1 reply; 10+ messages in thread
From: Jamie Lokier @ 2003-07-08 14:05 UTC (permalink / raw)
To: Richard B. Johnson; +Cc: Linux kernel
Richard B. Johnson wrote:
> > The offset argument to mmap2 is divided by PAGE_SIZE.
> > That is the whole point of mmap2 :)
>
> Okay. Do you know where that's documented? Nothing in linux/Documentation,
> and nothing in any headers. Do you have to read the code to find out?
>
> So, the address is now the offset in PAGES, not bytes. Seems logical,
> but there is no clue in any documentation.
I found this great command which really helps. Only 1337 kernel
gnurus know about it, now u can be 1 2 :)
$ man mmap2
[...]
The function mmap2 operates in exactly the same way as mmap(2), except
that the final argument specifies the offset into the file in units of
the system page size (instead of bytes).
-- Jamie
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 14:05 ` Jamie Lokier
@ 2003-07-08 14:40 ` Richard B. Johnson
2003-07-08 14:49 ` Randy.Dunlap
2003-07-08 14:51 ` Kurt Wall
0 siblings, 2 replies; 10+ messages in thread
From: Richard B. Johnson @ 2003-07-08 14:40 UTC (permalink / raw)
To: Jamie Lokier; +Cc: Linux kernel
On Tue, 8 Jul 2003, Jamie Lokier wrote:
> Richard B. Johnson wrote:
> > > The offset argument to mmap2 is divided by PAGE_SIZE.
> > > That is the whole point of mmap2 :)
> >
> > Okay. Do you know where that's documented? Nothing in linux/Documentation,
> > and nothing in any headers. Do you have to read the code to find out?
> >
> > So, the address is now the offset in PAGES, not bytes. Seems logical,
> > but there is no clue in any documentation.
>
> I found this great command which really helps. Only 1337 kernel
> gnurus know about it, now u can be 1 2 :)
>
> $ man mmap2
> [...]
> The function mmap2 operates in exactly the same way as mmap(2), except
> that the final argument specifies the offset into the file in units of
> the system page size (instead of bytes).
>
> -- Jamie
>
Yeah? So the Linux kernel now requires a specific vendor distribution?
Since when?
So, to get the proper documentation of the Linux Kernel, I now
need to purchase a vendor's distribution??? I think not. I think
the sys-calls need to be documented and I think that I have established
proof of that supposition.
Script started on Tue Jul 8 10:35:05 2003
# man mmap2
No manual entry for mmap2
# mmap
# man map
MMAP(2) Linux Programmer's Manual MMAP(2)
NAME
mmap, munmap - map or unmap files or devices into memory
SYNOPSIS
#include <sys/types.h>
#include <sys/mman.h>
caddr_t mmap(caddr_t addr, size_t len, int prot , int
flags, int fd, off_t offset );
int munmap(caddr_t addr, size_t len);
DESCRIPTION
WARNING: This is a BSD man page. Linux 0.99.11 can't map
files, and can't do other things documented here.
The mmap function causes the pages starting at addr and
continuing for at most len bytes to be mapped from the
object described by fd, starting at byte offset offset.
If offset or len is not a multiple of the pagesize, the
mapped region may extend past the specified range.
line 1
#
#
# exit
exit
Script done on Tue Jul 8 10:35:29 2003
Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 14:40 ` Richard B. Johnson
@ 2003-07-08 14:49 ` Randy.Dunlap
2003-07-08 14:51 ` Kurt Wall
1 sibling, 0 replies; 10+ messages in thread
From: Randy.Dunlap @ 2003-07-08 14:49 UTC (permalink / raw)
To: root; +Cc: jamie, linux-kernel
On Tue, 8 Jul 2003 10:40:15 -0400 (EDT) "Richard B. Johnson" <root@chaos.analogic.com> wrote:
| On Tue, 8 Jul 2003, Jamie Lokier wrote:
|
| > Richard B. Johnson wrote:
| > > > The offset argument to mmap2 is divided by PAGE_SIZE.
| > > > That is the whole point of mmap2 :)
| > >
| > > Okay. Do you know where that's documented? Nothing in linux/Documentation,
| > > and nothing in any headers. Do you have to read the code to find out?
| > >
| > > So, the address is now the offset in PAGES, not bytes. Seems logical,
| > > but there is no clue in any documentation.
| >
| > I found this great command which really helps. Only 1337 kernel
| > gnurus know about it, now u can be 1 2 :)
| >
| > $ man mmap2
| > [...]
| > The function mmap2 operates in exactly the same way as mmap(2), except
| > that the final argument specifies the offset into the file in units of
| > the system page size (instead of bytes).
| >
| > -- Jamie
| >
|
| Yeah? So the Linux kernel now requires a specific vendor distribution?
| Since when?
|
| So, to get the proper documentation of the Linux Kernel, I now
| need to purchase a vendor's distribution??? I think not. I think
| the sys-calls need to be documented and I think that I have established
| proof of that supposition.
I can read that mmap2 man page by downloading the latest tarball
from http://www.kernel.org/pub/linux/docs/manpages/ ,
regardless of my distro.
And if what you want/need isn't there, aeb accepts contributions
to it as well.
--
~Randy
| http://developer.osdl.org/rddunlap/ | http://www.xenotime.net/linux/ |
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: syscall __NR_mmap2
2003-07-08 14:40 ` Richard B. Johnson
2003-07-08 14:49 ` Randy.Dunlap
@ 2003-07-08 14:51 ` Kurt Wall
1 sibling, 0 replies; 10+ messages in thread
From: Kurt Wall @ 2003-07-08 14:51 UTC (permalink / raw)
To: Linux kernel
Quoth Richard B. Johnson:
[...]
> Yeah? So the Linux kernel now requires a specific vendor distribution?
> Since when?
I don't think this vendor specific. The mmap2() man page I have comes
from the man pages package maintained by Andries Brouwer (release 1.56).
The LSM file says you can get them at
ftp://ftp.win.tue.nl/pub/linux-local/manpages
> So, to get the proper documentation of the Linux Kernel, I now
> need to purchase a vendor's distribution??? I think not. I think
No.
> the sys-calls need to be documented and I think that I have established
> proof of that supposition.
>
> Script started on Tue Jul 8 10:35:05 2003
> # man mmap2
> No manual entry for mmap2
> # mmap
> # man map
>
> MMAP(2) Linux Programmer's Manual MMAP(2)
>
> NAME
> mmap, munmap - map or unmap files or devices into memory
>
> SYNOPSIS
> #include <sys/types.h>
> #include <sys/mman.h>
>
> caddr_t mmap(caddr_t addr, size_t len, int prot , int
> flags, int fd, off_t offset );
> int munmap(caddr_t addr, size_t len);
>
> DESCRIPTION
> WARNING: This is a BSD man page. Linux 0.99.11 can't map
> files, and can't do other things documented here.
I'd say your man pages are woefully out of date.
Kurt
--
Do infants have as much fun in infancy as adults do in adultery?
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-07-08 14:37 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-07 21:00 syscall __NR_mmap2 Richard B. Johnson
2003-07-07 21:32 ` Ulrich Drepper
2003-07-08 11:56 ` Richard B. Johnson
2003-07-08 0:36 ` Jamie Lokier
2003-07-08 11:54 ` Richard B. Johnson
2003-07-08 13:59 ` Kurt Wall
2003-07-08 14:05 ` Jamie Lokier
2003-07-08 14:40 ` Richard B. Johnson
2003-07-08 14:49 ` Randy.Dunlap
2003-07-08 14:51 ` Kurt Wall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).