The fixed address passed to mmap() should be aligned to the value of SHMLBA
as defined in sys/shm.h.
See Documentation/cachetlb.txt in the kernel for the explanation behind this.
On most architectures this value is the page size, but not on all.

Regards,
Martin

        Signed-off-by: Martin Habets <[EMAIL PROTECTED]>

Index: ltp/testcases/kernel/syscalls/mmap/mmap01.c
===================================================================
--- ltp.orig/testcases/kernel/syscalls/mmap/mmap01.c    2008-05-01 
21:03:51.000000000 +0100
+++ ltp/testcases/kernel/syscalls/mmap/mmap01.c 2008-05-01 21:10:45.000000000 
+0100
@@ -81,6 +81,7 @@
 #include <stdint.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <sys/shm.h>
 
 #include "test.h"
 #include "usctest.h"
@@ -267,14 +268,16 @@
        }
 
        /*
-        * Initialize addr to align with the first page boundary above the
-        * break address of the process.
+        * Initialize addr to align with the first segment boundary address
+        * above the break address of the process.
         */
-       addr = (void *) (((intptr_t)sbrk(0) + (page_sz - 1)) & ~(page_sz - 1));
+       addr = (void *) (((intptr_t)sbrk(0) + (SHMLBA - 1)) & ~(SHMLBA - 1));
 
-       /* Increase the break address of the process by 2 page size bytes */
-       if ((intptr_t)sbrk(2 * page_sz) == -1) {
-               tst_brkm(TFAIL, cleanup, "sbrk(2 * page_sz) failed");
+       /* Set the break address of the process to the addr plus one
+        * page size.
+        */
+       if ((intptr_t)sbrk(SHMLBA + page_sz) == -1) {
+               tst_brkm(TFAIL, cleanup, "sbrk(SHMLBA + page_sz) failed");
        }
 
        /* Initialize one page region from addr with 'A' */

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to