On 06/14/2015 10:22 PM, Matt Bennett wrote:
> On Sun, 2015-06-14 at 22:01 -0700, John Reiser wrote:
>>> mmap(0x802001000, 4194304, PROT_READ|PROT_WRITE|PROT_EXEC,
>>> MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, 0, 0) = -1 EINVAL (Invalid argument)
>>
>> What is SHMLBA for this configuration? [grep -sr SHMLBA /usr/include]
>
> /usr/include/valgrind/vki/vki-mips32-linux.h:#define VKI_SHMLBA 0x40000
> /usr/include/valgrind/vki/vki-mips64-linux.h:#define VKI_SHMLBA 0x40000
[Note that 0x40000 is 256KiB, which is rather large and likely to cause
noticeable fragmentation of address space.]
Notice that all those files are from /usr/include/valgrind/vki/.
Your compilation environment apparently lacked the definitions
that correspond to the target hardware [these for x86_64]:
-----
/usr/include/bits/shm.h:#define SHM_RND 020000 /* round attach
address to SHMLBA */
/usr/include/bits/shm.h:#define SHMLBA (__getpagesize ())
/usr/include/linux/shm.h:#define SHM_RND 020000 /* round attach
address to SHMLBA boundary */
/usr/include/asm-generic/shmparam.h:#define SHMLBA PAGE_SIZE /* attach addr
a multiple of this */
-----
>
>> And on the same topic, what is the page size? [grep -sr PAGE_SIZE
>> /usr/include]
>
> /usr/include/valgrind/pub_tool_libcbase.h:#define VG_IS_PAGE_ALIGNED(aaa_p)
> (0 == (((Addr)(aaa_p)) & ((Addr)(VKI_PAGE_SIZE-1))))
> /usr/include/valgrind/pub_tool_libcbase.h:#define VG_PGROUNDDN(p)
> VG_ROUNDDN(p, VKI_PAGE_SIZE)
> /usr/include/valgrind/pub_tool_libcbase.h:#define VG_PGROUNDUP(p)
> VG_ROUNDUP(p, VKI_PAGE_SIZE)
> /usr/include/valgrind/vki/vki-mips32-linux.h:#define VKI_PAGE_SIZE
> (1UL << VKI_PAGE_SHIFT)
> /usr/include/valgrind/vki/vki-mips32-linux.h:#define VKI_PAGE_MASK
> (~(VKI_PAGE_SIZE-1))
> /usr/include/valgrind/vki/vki-mips32-linux.h:#define VKI_MAX_PAGE_SIZE
> VKI_PAGE_SIZE
> /usr/include/valgrind/vki/vki-mips64-linux.h:#define VKI_PAGE_SIZE (1UL <<
> VKI_PAGE_SHIFT)
> /usr/include/valgrind/vki/vki-mips64-linux.h:#define VKI_PAGE_MASK
> (~(VKI_PAGE_SIZE-1))
> /usr/include/valgrind/vki/vki-mips64-linux.h:#define VKI_MAX_PAGE_SIZE
> VKI_PAGE_SIZE
Well, what is VKI_PAGE_SHIFT; and does one of {vki-mips32-linux.h,
vki-mips64-linux.h}
actually apply to the target machine?
>
>> Every successful mmap() return value happens to be a multiple of 0x2000
>> (8KiB);
>> there are no odd multiples of 0x1000 (4KiB).
>> [Some ARM machines have an SHMLBA of 0x4000 (16KiB) even though the page
>> size is 0x1000 (4KiB).]
>
> This is on a MIPS chip, specifically Cavium (cnMIPS). The kernel page size is
> configured to 8kB and since I didn't configure the page size when
> cross compiling valgrind it looks like it took the page size of my local
> machine (4kB). Looking at the upstream source code it appears that
> 8kB page size isn't currently supported however there are some patches here
> that may make it work. https://bugs.kde.org/show_bug.cgi?id=342356
>
> Either way if this is indeed the issue here perhaps this is something that
> should be fixed upstream (supporting 8k and 32k pages)?
Some of the blame belongs to you and the marketing/sales/support team
that sold you the chips. Sometimes inexpensive hardware is *TOO* cheap!
In this case it looks like Cavium (cnMIPS) is an architectural variant
that does not have all the properties previously promised by MIPS.
Also, successful cross-compiling requires setting the declarations
and #includes correctly. Nothing in the valgrind source can prevent
operator error in this department.
Therefore: arrange for the proper definitions of VKI_PAGE_SHIFT and VKI_SHMLBA,
and tell us the numerical values. (Write a test program which prints them!)
If valgrind attempts MAP_FIXED at an address such as 0x802001000 which is not
a multiple of the hardware page size (apparently 8KiB) then that is a clue
that the compilation environment is not correct. If necessary, edit the
definitions by hand _after_ performing "automatic configuration" and
_before_ compiling.
Look carefully at ARM:
/usr/include/valgrind/vki/vki-arm-linux.h:#define VKI_SHMLBA (4 *
VKI_PAGE_SIZE)
which does work, and contrast with your case.
--
------------------------------------------------------------------------------
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users