|
From: <sv...@va...> - 2005-09-30 00:37:12
|
Author: sewardj
Date: 2005-09-30 01:37:04 +0100 (Fri, 30 Sep 2005)
New Revision: 4823
Log:
Changes to sys_mmap2 wrapper:
- update comment re offset scaling
- ppc32 offset is in bytes, not pages
- don't deal with MAP_FIXED case directly here; instead uniformly pass
all requests to VG_(am_get_advisory), so that layout policy is controll=
ed
from one place only.
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-30 00:06:09 UTC (re=
v 4822)
+++ trunk/coregrind/m_syswrap/syswrap-linux.c 2005-09-30 00:37:04 UTC (re=
v 4823)
@@ -550,14 +550,18 @@
=20
PRE(sys_mmap2)
{
- Addr advised;
- SysRes sres;
- OffT offset;
+ Addr advised;
+ SysRes sres;
+ OffT offset;
+ MapRequest mreq;
+ Bool mreq_ok;
=20
// Exactly like old_mmap() in x86-linux except:
// - all 6 args are passed in regs, rather than in a memory-block.
- // - the file offset is specified in pagesize units rather than byte=
s,
- // so that it can be used for files bigger than 2^32 bytes.
+ // - on x86-linux, the file offset is specified in pagesize units
+ // rather than bytes, so that it can be used for files bigger=20
+ // than 2^32 bytes. On amd64-linux and ppc32-linux it appears
+ // to be in bytes.
PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )",
ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
PRE_REG_READ6(long, "mmap2",
@@ -572,7 +576,7 @@
return;
}
=20
- if (/*(ARG4 & VKI_MAP_FIXED) && */ (0 !=3D (ARG1 & (VKI_PAGE_SIZE-1))=
)) {
+ if (!VG_IS_PAGE_ALIGNED(ARG1)) {
/* zap any misaligned addresses. */
/* SuSV3 says misaligned addresses only cause the MAP_FIXED case
to fail. Here, we catch them all. */
@@ -582,44 +586,34 @@
=20
/* Figure out what kind of allocation constraints there are
(fixed/hint/any), and ask aspacem what we should do. */
+ mreq.start =3D ARG1;
+ mreq.len =3D ARG2;
if (ARG4 & VKI_MAP_FIXED) {
- if (!ML_(valid_client_addr)(ARG1, ARG2, tid, "mmap2")) {
- SET_STATUS_Failure( VKI_EINVAL );
- return;
- }
-
- advised =3D ARG1;
+ mreq.rkind =3D MFixed;
+ } else
+ if (ARG1 !=3D 0) {
+ mreq.rkind =3D MHint;
} else {
- MapRequest mreq;
- Bool mreq_ok;
+ mreq.rkind =3D MAny;
+ }
=20
- mreq.start =3D ARG1;
- mreq.len =3D ARG2;
-
- if (ARG1 !=3D 0) {
- mreq.rkind =3D MHint;
- } else {
- mreq.rkind =3D MAny;
- }
-
- /* Enquire ... */
- advised =3D VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok =
);
- if (!mreq_ok) {
- /* Our request was bounced, so we'd better fail. */
- SET_STATUS_Failure( VKI_EINVAL );
- return;
- }
+ /* Enquire ... */
+ advised =3D VG_(am_get_advisory)( &mreq, True/*client*/, &mreq_ok );
+ if (!mreq_ok) {
+ /* Our request was bounced, so we'd better fail. */
+ SET_STATUS_Failure( VKI_EINVAL );
+ return;
}
=20
vg_assert(! FAILURE);
=20
-#if defined(VGP_x86_linux) || defined(VGP_ppc32_linux)
+# if defined(VGP_x86_linux)
offset =3D ARG6 * VKI_PAGE_SIZE;
-#elif defined(VGP_amd64_linux)
+# elif defined(VGP_amd64_linux) || defined(VGP_ppc32_linux)
offset =3D ARG6;
-#elif
-# error Unknown platform
-#endif
+# else
+# error Unknown platform
+# endif
=20
/* Otherwise we're OK (so far). Install aspacem's choice of
address, and let the mmap go through. */
|