|
From: <sv...@va...> - 2006-12-30 02:46:13
|
Author: sewardj
Date: 2006-12-30 02:46:07 +0000 (Sat, 30 Dec 2006)
New Revision: 6457
Log:
Support 64k pages on ppc32/64-linux (Jakub Jelink, Dave Nomura)
Modified:
branches/VALGRIND_3_2_BRANCH/coregrind/m_aspacemgr/aspacemgr.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_main.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_replacemalloc/vg_replace_mall=
oc.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc32-linux.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc64-linux.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c
branches/VALGRIND_3_2_BRANCH/coregrind/m_ume.c
branches/VALGRIND_3_2_BRANCH/coregrind/pub_core_aspacemgr.h
branches/VALGRIND_3_2_BRANCH/include/vki-amd64-linux.h
branches/VALGRIND_3_2_BRANCH/include/vki-ppc32-linux.h
branches/VALGRIND_3_2_BRANCH/include/vki-ppc64-linux.h
branches/VALGRIND_3_2_BRANCH/include/vki-x86-linux.h
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_aspacemgr/aspacemgr.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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_aspacemgr/aspacemgr.c 2006-1=
2-28 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_aspacemgr/aspacemgr.c 2006-1=
2-30 02:46:07 UTC (rev 6457)
@@ -443,8 +443,9 @@
SysRes res;
aspacem_assert(VG_IS_PAGE_ALIGNED(offset));
# if defined(VGP_x86_linux) || defined(VGP_ppc32_linux)
+ /* mmap2 uses 4096 chunks even if actual page size is bigger. */
res =3D VG_(do_syscall6)(__NR_mmap2, (UWord)start, length,
- prot, flags, fd, offset / VKI_PAGE_SIZE);
+ prot, flags, fd, offset / 4096);
# elif defined(VGP_amd64_linux) || defined(VGP_ppc64_linux)
res =3D VG_(do_syscall6)(__NR_mmap, (UWord)start, length,=20
prot, flags, fd, offset);
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_main.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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_main.c 2006-12-28 20:26:08 U=
TC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_main.c 2006-12-30 02:46:07 U=
TC (rev 6457)
@@ -1672,6 +1672,11 @@
LibVEX_ppVexArch ( vex_arch ),
LibVEX_ppVexHwCaps ( vex_arch, vex_archinfo.hwcaps )
);
+ VG_(message)(
+ Vg_DebugMsg,=20
+ "Page sizes: currently %d, max supported %d\n",=20
+ (Int)VKI_PAGE_SIZE, (Int)VKI_MAX_PAGE_SIZE
+ );
VG_(message)(Vg_DebugMsg, "Valgrind library directory: %s", VG_(li=
bdir));
}
}
@@ -2033,6 +2038,9 @@
// p: logging, plausible-stack
//--------------------------------------------------------------
VG_(debugLog)(1, "main", "Starting the address space manager\n");
+ vg_assert(VKI_PAGE_SIZE =3D=3D 4096 || VKI_PAGE_SIZE =3D=3D 6=
5536);
+ vg_assert(VKI_MAX_PAGE_SIZE =3D=3D 4096 || VKI_MAX_PAGE_SIZE =3D=3D 6=
5536);
+ vg_assert(VKI_PAGE_SIZE <=3D VKI_MAX_PAGE_SIZE);
clstack_top =3D VG_(am_startup)( sp_at_startup );
VG_(debugLog)(1, "main", "Address space manager is running\n");
=20
@@ -2956,6 +2964,11 @@
#error "_start: needs implementation on this platform"
#endif
=20
+#if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
+unsigned long VKI_PAGE_SHIFT =3D 12;
+unsigned long VKI_PAGE_SIZE =3D (1UL << 12);
+#endif
+
/* Avoid compiler warnings: this fn _is_ used, but labelling it
'static' causes gcc to complain it isn't. */
void _start_in_C ( UWord* pArgc );
@@ -2966,6 +2979,24 @@
HChar** argv =3D (HChar**)&pArgc[1];
HChar** envp =3D (HChar**)&pArgc[1+argc+1];
sp_at_startup =3D (Addr)pArgc;
+
+# if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
+ {
+ UWord *sp =3D &pArgc[1+argc+1];
+ /* ppc/ppc64 can be configured with different page sizes.
+ Determine this early. */
+ while (*sp++ !=3D 0);
+ for (; *sp !=3D AT_NULL && *sp !=3D AT_PAGESZ; sp +=3D 2);
+ if (*sp =3D=3D AT_PAGESZ) {
+ VKI_PAGE_SIZE =3D sp[1];
+ for (VKI_PAGE_SHIFT =3D 12;
+ VKI_PAGE_SHIFT <=3D VKI_MAX_PAGE_SHIFT; VKI_PAGE_SHIFT++)
+ if (VKI_PAGE_SIZE =3D=3D (1UL << VKI_PAGE_SHIFT))
+ break;
+ }
+ }
+# endif
+
r =3D main( (Int)argc, argv, envp );
VG_(exit)(r);
}
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_replacemalloc/vg_repla=
ce_malloc.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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_replacemalloc/vg_replace_mal=
loc.c 2006-12-28 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_replacemalloc/vg_replace_mal=
loc.c 2006-12-30 02:46:07 UTC (rev 6457)
@@ -337,7 +337,11 @@
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ); \
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) ( SizeT size ) \
{ \
- return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)(VKI_PAGE_SIZE, =
size); \
+ static int pszB =3D 0; \
+ extern int getpagesize (void); \
+ if (pszB =3D=3D 0) \
+ pszB =3D getpagesize(); \
+ return VG_REPLACE_FUNCTION_ZU(libcZdsoZa,memalign)((SizeT)pszB, si=
ze); \
}
=20
VALLOC(m_libc_dot_so_star, valloc);
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc32-=
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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc32-linux.=
c 2006-12-28 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc32-linux.=
c 2006-12-30 02:46:07 UTC (rev 6457)
@@ -673,7 +673,7 @@
SysRes r;
=20
// Exactly like old_mmap() except:
- // - the file offset is specified in pagesize units rather than byte=
s,
+ // - the file offset is specified in 4K units rather than bytes,
// so that it can be used for files bigger than 2^32 bytes.
PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )",
ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
@@ -683,7 +683,7 @@
unsigned long, fd, unsigned long, offset);
=20
r =3D ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5,=20
- VKI_PAGE_SIZE * (Off64T)ARG6 );
+ 4096 * (Off64T)ARG6 );
SET_STATUS_from_SysRes(r);
}
=20
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc64-=
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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc64-linux.=
c 2006-12-28 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-ppc64-linux.=
c 2006-12-30 02:46:07 UTC (rev 6457)
@@ -701,7 +701,7 @@
//zz SysRes r;
//zz=20
//zz // Exactly like old_mmap() except:
-//zz // - the file offset is specified in pagesize units rather than=
bytes,
+//zz // - the file offset is specified in 4K units rather than bytes=
,
//zz // so that it can be used for files bigger than 2^32 bytes.
//zz PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )",
//zz ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
@@ -711,7 +711,7 @@
//zz unsigned long, fd, unsigned long, offset);
//zz=20
//zz r =3D ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, AR=
G5,=20
-//zz VKI_PAGE_SIZE * (Off64T)ARG6=
);
+//zz 4096 * (Off64T)ARG6 );
//zz SET_STATUS_from_SysRes(r);
//zz }
//zz=20
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-x86-li=
nux.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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c =
2006-12-28 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_syswrap/syswrap-x86-linux.c =
2006-12-30 02:46:07 UTC (rev 6457)
@@ -1300,6 +1300,9 @@
// - 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.
+ // pagesize or 4K-size units in offset? For ppc32/64-linux, this is
+ // 4K-sized. Assert that the page size is 4K here for safety.
+ vg_assert(VKI_PAGE_SIZE =3D=3D 4096);
PRINT("sys_mmap2 ( %p, %llu, %d, %d, %d, %d )",
ARG1, (ULong)ARG2, ARG3, ARG4, ARG5, ARG6 );
PRE_REG_READ6(long, "mmap2",
@@ -1308,7 +1311,7 @@
unsigned long, fd, unsigned long, offset);
=20
r =3D ML_(generic_PRE_sys_mmap)( tid, ARG1, ARG2, ARG3, ARG4, ARG5,=20
- VKI_PAGE_SIZE * (Off64T)ARG6 );
+ 4096 * (Off64T)ARG6 );
SET_STATUS_from_SysRes(r);
}
=20
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/m_ume.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
--- branches/VALGRIND_3_2_BRANCH/coregrind/m_ume.c 2006-12-28 20:26:08 UT=
C (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/m_ume.c 2006-12-30 02:46:07 UT=
C (rev 6457)
@@ -553,7 +553,7 @@
/* returns: 0 =3D success, non-0 is failure */
static Int load_script(Int fd, const HChar* name, ExeInfo* info)
{
- Char hdr[VKI_PAGE_SIZE];
+ Char hdr[VKI_MAX_PAGE_SIZE];
Int len =3D VKI_PAGE_SIZE;
Int eol;
Char* interp;
@@ -628,7 +628,7 @@
{
Int fd, ret;
SysRes res;
- Char buf[VKI_PAGE_SIZE];
+ Char buf[VKI_MAX_PAGE_SIZE];
SizeT bufsz =3D VKI_PAGE_SIZE, fsz;
=20
// Check it's readable
Modified: branches/VALGRIND_3_2_BRANCH/coregrind/pub_core_aspacemgr.h
=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
--- branches/VALGRIND_3_2_BRANCH/coregrind/pub_core_aspacemgr.h 2006-12-2=
8 20:26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/coregrind/pub_core_aspacemgr.h 2006-12-3=
0 02:46:07 UTC (rev 6457)
@@ -293,8 +293,13 @@
// stacks. The address space manager provides and suitably
// protects such stacks.
=20
-#define VG_STACK_GUARD_SZB 8192 // 2 pages
-#define VG_STACK_ACTIVE_SZB 65536 // 16 pages
+#if defined(VGP_ppc32_linux) || defined(VGP_ppc64_linux)
+# define VG_STACK_GUARD_SZB 65536 // 1 .. 16 pages
+# define VG_STACK_ACTIVE_SZB 131072 // 2 .. 32 pages
+#else
+# define VG_STACK_GUARD_SZB 8192 // 2 pages
+# define VG_STACK_ACTIVE_SZB 65536 // 16 pages
+#endif
=20
typedef
struct {
Modified: branches/VALGRIND_3_2_BRANCH/include/vki-amd64-linux.h
=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
--- branches/VALGRIND_3_2_BRANCH/include/vki-amd64-linux.h 2006-12-28 20:=
26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/include/vki-amd64-linux.h 2006-12-30 02:=
46:07 UTC (rev 6457)
@@ -59,6 +59,8 @@
=20
#define VKI_PAGE_SHIFT 12
#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
+#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
=20
//----------------------------------------------------------------------
// From linux-2.6.9/include/asm-x86_64/signal.h
Modified: branches/VALGRIND_3_2_BRANCH/include/vki-ppc32-linux.h
=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
--- branches/VALGRIND_3_2_BRANCH/include/vki-ppc32-linux.h 2006-12-28 20:=
26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/include/vki-ppc32-linux.h 2006-12-30 02:=
46:07 UTC (rev 6457)
@@ -61,9 +61,11 @@
// From linux-2.6.9/include/asm-ppc/page.h
//----------------------------------------------------------------------
=20
-/* PAGE_SHIFT determines the page size */
-#define VKI_PAGE_SHIFT 12
-#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
+/* PAGE_SHIFT determines the page size, unfortunately
+ page size might vary between 32-bit and 64-bit ppc kernels */
+extern unsigned long VKI_PAGE_SHIFT, VKI_PAGE_SIZE;
+#define VKI_MAX_PAGE_SHIFT 16
+#define VKI_MAX_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
=20
//----------------------------------------------------------------------
// From linux-2.6.9/include/asm-ppc/signal.h
Modified: branches/VALGRIND_3_2_BRANCH/include/vki-ppc64-linux.h
=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
--- branches/VALGRIND_3_2_BRANCH/include/vki-ppc64-linux.h 2006-12-28 20:=
26:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/include/vki-ppc64-linux.h 2006-12-30 02:=
46:07 UTC (rev 6457)
@@ -62,9 +62,11 @@
// From linux-2.6.13/include/asm-ppc64/page.h
//----------------------------------------------------------------------
=20
-/* PAGE_SHIFT determines the page size */
-#define VKI_PAGE_SHIFT 12
-#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
+/* PAGE_SHIFT determines the page size, unfortunately
+ page size might vary between 32-bit and 64-bit ppc kernels */
+extern unsigned long VKI_PAGE_SHIFT, VKI_PAGE_SIZE;
+#define VKI_MAX_PAGE_SHIFT 16
+#define VKI_MAX_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
=20
//----------------------------------------------------------------------
// From linux-2.6.13/include/asm-ppc64/signal.h
Modified: branches/VALGRIND_3_2_BRANCH/include/vki-x86-linux.h
=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
--- branches/VALGRIND_3_2_BRANCH/include/vki-x86-linux.h 2006-12-28 20:26=
:08 UTC (rev 6456)
+++ branches/VALGRIND_3_2_BRANCH/include/vki-x86-linux.h 2006-12-30 02:46=
:07 UTC (rev 6457)
@@ -60,6 +60,8 @@
/* PAGE_SHIFT determines the page size */
#define VKI_PAGE_SHIFT 12
#define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
+#define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
+#define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
=20
//----------------------------------------------------------------------
// From linux-2.6.8.1/include/asm-i386/signal.h
|