The existing library code enforces classic PPC segment restrictons on the
alignment and allocation of hugepages.  BookE Freescale processors
don't have this restriction and allowing it to remain in place
is overly restrictive on 32-bit processors.  Define PPC_NO_SEGMENTS to
turn this off.

Signed-off-by: Becky Bruce <bec...@kernel.crashing.org>
Signed-off-by: Chunrong Guo <b40...@freescale.com>
---
 Makefile                   |    2 +-
 elflink.c                  |    7 ++++---
 libhugetlbfs_internal.h    |    3 ++-
 morecore.c                 |    2 +-
 tests/brk_near_huge.c      |    2 +-
 tests/truncate_above_4GB.c |    6 ++++--
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 48205af..2d0d7ac 100644
--- a/Makefile
+++ b/Makefile
@@ -30,7 +30,7 @@ INSTALL = install
 LDFLAGS += -Wl,-z,noexecstack -ldl
 CFLAGS ?= -O2 -g
 CFLAGS += -Wall -fPIC
-CPPFLAGS += -D__LIBHUGETLBFS__
+CPPFLAGS += -D__LIBHUGETLBFS__ -DPPC_NO_SEGMENTS
 
 ARCH = $(shell uname -m | sed -e s/i.86/i386/)
 
diff --git a/elflink.c b/elflink.c
index b746b26..e6eca4d 100644
--- a/elflink.c
+++ b/elflink.c
@@ -552,7 +552,8 @@ bail2:
        seg->extrasz = end_orig - start;
 }
 
-#if defined(__powerpc64__) || defined (__powerpc__)
+#if defined(__powerpc64__) || \
+       (defined(__powerpc__) && !defined(PPC_NO_SEGMENTS))
 #define SLICE_LOW_TOP          (0x100000000UL)
 #define SLICE_LOW_SIZE         (1UL << SLICE_LOW_SHIFT)
 #define SLICE_HIGH_SIZE                (1UL << SLICE_HIGH_SHIFT)
@@ -574,7 +575,7 @@ static unsigned long hugetlb_slice_start(unsigned long addr)
                return SLICE_LOW_TOP;
        else
                return ALIGN_DOWN(addr, SLICE_HIGH_SIZE);
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
        return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
 #else
        return ALIGN_DOWN(addr, gethugepagesize());
@@ -588,7 +589,7 @@ static unsigned long hugetlb_slice_end(unsigned long addr)
                return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
        else
                return ALIGN_UP(addr, SLICE_HIGH_SIZE) - 1;
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
        return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
 #else
        return ALIGN_UP(addr, gethugepagesize()) - 1;
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index ae8d7bc..2df2ffc 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -49,7 +49,8 @@
 #define ALIGN_UP(x,a)  ALIGN(x,a)
 #define ALIGN_DOWN(x,a) ((x) & ~((a) - 1))
 
-#if defined(__powerpc64__) || defined (__powerpc__)
+#if defined(__powerpc64__) || \
+       (defined(__powerpc__) && !defined(PPC_NO_SEGMENTS))
 #define SLICE_LOW_SHIFT                28
 #define SLICE_HIGH_SHIFT       40
 #elif defined(__ia64__)
diff --git a/morecore.c b/morecore.c
index c02b11a..62ad252 100644
--- a/morecore.c
+++ b/morecore.c
@@ -44,7 +44,7 @@ static long hugetlbfs_next_addr(long addr)
 {
 #if defined(__powerpc64__)
        return ALIGN(addr, 1L << SLICE_HIGH_SHIFT);
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
        return ALIGN(addr, 1L << SLICE_LOW_SHIFT);
 #elif defined(__ia64__)
        if (addr < (1UL << SLICE_HIGH_SHIFT))
diff --git a/tests/brk_near_huge.c b/tests/brk_near_huge.c
index 71eb803..f6d1e07 100644
--- a/tests/brk_near_huge.c
+++ b/tests/brk_near_huge.c
@@ -47,7 +47,7 @@ void *next_chunk(void *addr)
                /* 1TB segments above */
                return PALIGN(addr, 0x10000000000UL);
 }
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) && !defined(PPC_NO_SEGMENTS)
 void *next_chunk(void *addr)
 {
        return PALIGN(addr, 0x10000000UL);
diff --git a/tests/truncate_above_4GB.c b/tests/truncate_above_4GB.c
index 5b8c08f..4c427fc 100644
--- a/tests/truncate_above_4GB.c
+++ b/tests/truncate_above_4GB.c
@@ -102,11 +102,13 @@ int main(int argc, char *argv[])
        *qi = 0;
 
        /* This part of the test makes the problem more obvious, but
-        * is not essential.  It can't be done on powerpc, where
+        * is not essential.  It can't be done on segmented powerpc, where
         * segment restrictions prohibit us from performing such a
         * mapping, so skip it there. Similarly, ia64's address space
         * restrictions prevent this. */
-#if !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__ia64__)
+#if (defined(__powerpc__) && defined(PPC_NO_SEGMENTS)) \
+       || !defined(__powerpc__) && !defined(__powerpc64__) \
+       && !defined(__ia64__)
        /* Replace middle hpage by tinypage mapping to trigger
         * nr_ptes BUG */
        verbose_printf("Replacing map at %p-%p...", q + hpage_size,
-- 
1.7.5.4



------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to