|
From: <sv...@va...> - 2005-09-29 23:26:09
|
Author: tom
Date: 2005-09-30 00:26:06 +0100 (Fri, 30 Sep 2005)
New Revision: 4821
Log:
On x86 and ppc32 the offset argument to mmap2 is specified in pages
not bytes. This is a horrible kludge of a fix and it should probably
be fixed properly with a separate sys_mmap for amd64.
Modified:
trunk/coregrind/m_syswrap/syswrap-linux.c
Modified: trunk/coregrind/m_syswrap/syswrap-linux.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-linux.c 2005-09-29 21:20:41 UTC (re=
v 4820)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2005-09-29 23:26:06 UTC (re=
v 4821)
@@ -552,6 +552,7 @@
{
Addr advised;
SysRes sres;
+ OffT offset;
=20
// Exactly like old_mmap() in x86-linux except:
// - all 6 args are passed in regs, rather than in a memory-block.
@@ -612,11 +613,17 @@
=20
vg_assert(! FAILURE);
=20
+#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux)
+ offset =3D ARG6 * VKI_PAGE_SIZE;
+#else
+ offset =3D ARG6;
+#endif
+
/* Otherwise we're OK (so far). Install aspacem's choice of
address, and let the mmap go through. */
sres =3D VG_(am_do_mmap_NO_NOTIFY)(advised, ARG2, ARG3,
ARG4 | VKI_MAP_FIXED,
- ARG5, ARG6);
+ ARG5, offset);
SET_STATUS_from_SysRes(sres);
=20
if (!sres.isError) {
@@ -625,7 +632,7 @@
(Addr)sres.val, /* addr kernel actually assigned */
ARG2, ARG3,=20
ARG4, /* the original flags value */
- ARG5, ARG6=20
+ ARG5, offset
);
/* Load symbols? */
VG_(di_notify_mmap)( (Addr)sres.val );
|
|
From: Julian S. <js...@ac...> - 2005-09-30 00:38:23
|
> On x86 and ppc32 the offset argument to mmap2 is specified in pages > not bytes. This is a horrible kludge of a fix and it should probably > be fixed properly with a separate sys_mmap for amd64. > + OffT offset; Nice but .. there's kind of an awkward hole here. On x86, OffT is 32 bits and so if ARG6 >= 2^20 then offset is going to be wrong. Implication is that all mmap offsets should be represented in 64 bits regardless of the platform. (sigh) I'll think this through a bit more and see how this afflicts aspacem. > +#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux) > + offset = ARG6 * VKI_PAGE_SIZE; Also .. utterly illogically .. on ppc32 multiplying by page size causes everything to crash horribly. So on ppc32 I guess it's byte-indexed; but the implication is you can't do offsets of more than 4G on ppc32. /me mystified. J |
|
From: Tom H. <to...@co...> - 2005-09-30 08:11:48
|
In message <200...@ac...>
Julian Seward <js...@ac...> wrote:
>> On x86 and ppc32 the offset argument to mmap2 is specified in pages
>> not bytes. This is a horrible kludge of a fix and it should probably
>> be fixed properly with a separate sys_mmap for amd64.
>
>> + OffT offset;
>
> Nice but .. there's kind of an awkward hole here. On x86, OffT is
> 32 bits and so if ARG6 >= 2^20 then offset is going to be wrong.
> Implication is that all mmap offsets should be represented in 64
> bits regardless of the platform. (sigh)
Well maybe OffT should always be 64 bits - even 32 bit platforms
support large files and can have 64 bit offsets.
>> +#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux)
>> + offset = ARG6 * VKI_PAGE_SIZE;
>
> Also .. utterly illogically .. on ppc32 multiplying by page size
> causes everything to crash horribly. So on ppc32 I guess it's
> byte-indexed; but the implication is you can't do offsets of
> more than 4G on ppc32. /me mystified.
I had checked the kernel, and noted that ppc32 was passing the offset
to mmap2 as pages which is why I did what I did.
It turns out however that we were trying to use the sys_mmap2 handler
for both mmap and mmap2 on ppc32 which is wrong - they both pass the
arguments in the normal way (unlike x86) but one passes the offset in
bytes and one in pages.
I have attempted to rationalise all this and have committed a fix...
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|