[PATCH 4/5] Add linkhuge_rw test to 64 bit && !CUSTOM_LDSCIPTS

2013-09-10 Thread Steve Capper
If one compiles 64 bit with CUSTOM_LDSCRIPTS==no, then the linkhuge_rw
test is not compiled even though the logic to build it exists. For
32 bit targets these tests are compiled.

This patch adds $(HUGELINK_RW_TESTS) to the set of tests that are
compiled for 64 bit in this case.

Signed-off-by: Steve Capper 
---
 tests/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/Makefile b/tests/Makefile
index 231e3b0..9140e72 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -54,7 +54,7 @@ ifeq ($(CUSTOM_LDSCRIPTS),yes)
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
$(HUGELINK_TESTS:%=xBDT.%)
 else
-TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS)
+TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_RW_TESTS)
 endif
 
 endif
-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 1/5] Aarch64 support.

2013-09-10 Thread Steve Capper
This patch adds support for Aarch64.

As with ARMv7, We do not add the xBT/xBDT style linker scripts as
these have been deprecated in favour of adjusting the page sizes
via command line parameter to ld.

Signed-off-by: Steve Capper 
---
 Makefile |  7 +++
 ld.hugetlbfs |  2 +-
 sys-aarch64elf.S | 34 ++
 3 files changed, 42 insertions(+), 1 deletion(-)
 create mode 100644 sys-aarch64elf.S

diff --git a/Makefile b/Makefile
index 48205af..0e61701 100644
--- a/Makefile
+++ b/Makefile
@@ -57,6 +57,12 @@ TMPLIB32 = lib
 ELF32 += armelf_linux_eabi
 CUSTOM_LDSCRIPTS = no
 else
+ifeq ($(ARCH),aarch64)
+CC64 = gcc
+ELF64 = aarch64elf
+TMPLIB64 = lib64
+CUSTOM_LDSCRIPTS = no
+else
 ifeq ($(ARCH),i386)
 CC32 = gcc
 ELF32 = elf_i386
@@ -100,6 +106,7 @@ endif
 endif
 endif
 endif
+endif
 
 ifdef CC32
 OBJDIRS += obj32
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index d6d12c4..5128aa2 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -91,7 +91,7 @@ case "$EMU" in
 elf32ppclinux|elf64ppc)HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) 
;;
 elf_i386|elf_x86_64)   HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
 elf_s390|elf64_s390)   HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
-armelf_linux_eabi) HPAGE_SIZE=$((2*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
+armelf_linux_eabi|aarch64elf)  HPAGE_SIZE=$((2*MB)) SLICE_SIZE=$HPAGE_SIZE ;;
 esac
 
 if [ "$HTLB_ALIGN" == "slice" ]; then
diff --git a/sys-aarch64elf.S b/sys-aarch64elf.S
new file mode 100644
index 000..54799d3
--- /dev/null
+++ b/sys-aarch64elf.S
@@ -0,0 +1,34 @@
+/*
+ * libhugetlbfs - Easy use of Linux hugepages
+ * Copyright (C) 2013 Linaro Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+.text
+
+.globl  direct_syscall
+
+
+direct_syscall:
+   uxtwx8, w0
+   mov x0, x1
+   mov x1, x2
+   mov x2, x3
+   mov x3, x4
+   mov x4, x5
+   mov x5, x6
+   mov x6, x7
+   svc 0x0
+   ret
-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 0/5] libhugetlbfs - Aarch64 support and some fixes

2013-09-10 Thread Steve Capper
Hello,
This series adds Aarch64 support and makes some minor tweaks.

The first two patches of this series add Aarch64 support to
libhugetlbfs. (Starting from 3.11-rc1, the Linux Kernel supports
HugeTLB and THP for ARM64).

Some general changes are also made:
PROT_NONE is added to the mprotect unit test, and the
linkhuge_rw test is enabled for 64 bit where there aren't any
custom ldscripts.

The final patch clears up the superfluous ARM ld.hugetlbfs
HTLB_LINK logic.

Any comments would be appreciated.

Cheers,
--
Steve

Steve Capper (5):
  Aarch64 support.
  Aarch64 unit test fixes.
  Add PROT_NONE to the mprotect test.
  Add linkhuge_rw test to 64 bit && !CUSTOM_LDSCIPTS
  Cleanup ARM ld.hugetlbfs HTLB_LINK logic

 Makefile  |  7 +++
 ld.hugetlbfs  |  7 +--
 sys-aarch64elf.S  | 34 ++
 tests/Makefile|  2 +-
 tests/icache-hygiene.c|  7 ---
 tests/mprotect.c  |  6 ++
 tests/mremap-expand-slice-collision.c |  2 +-
 7 files changed, 54 insertions(+), 11 deletions(-)
 create mode 100644 sys-aarch64elf.S

-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 2/5] Aarch64 unit test fixes.

2013-09-10 Thread Steve Capper
On Aarch64, zero bytes are illegal instructions, this is added to
the icache-hygiene test.

In mremap-expand-slice-collision, if __LP64__ is defined then
mappings are attempted at 1TB boundaries which are outside the
allowable mmap region for Aarch64. For __aarch64__ we change this
mapping back to 256MB slices.

Signed-off-by: Steve Capper 
---
 tests/icache-hygiene.c| 7 ---
 tests/mremap-expand-slice-collision.c | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/tests/icache-hygiene.c b/tests/icache-hygiene.c
index 51792b3..876ce10 100644
--- a/tests/icache-hygiene.c
+++ b/tests/icache-hygiene.c
@@ -54,7 +54,7 @@ static void cacheflush(void *p)
 {
 #if defined(__powerpc__)
asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
-#elif defined(__arm__)
+#elif defined(__arm__) || defined(__aarch64__)
__clear_cache(p, p + COPY_SIZE);
 #endif
 }
@@ -87,8 +87,9 @@ static void *sig_expected;
 static void sig_handler(int signum, siginfo_t *si, void *uc)
 {
 #if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \
-defined(__s390__) || defined(__s390x__) || defined(__sparc__)
-   /* On powerpc and ia64 and s390, 0 bytes are an illegal
+defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \
+defined(__aarch64__)
+   /* On powerpc, ia64, s390 and Aarch64, 0 bytes are an illegal
 * instruction, so, if the icache is cleared properly, we SIGILL
 * as soon as we jump into the cleared page */
if (signum == SIGILL) {
diff --git a/tests/mremap-expand-slice-collision.c 
b/tests/mremap-expand-slice-collision.c
index c25f4c6..853f3c3 100644
--- a/tests/mremap-expand-slice-collision.c
+++ b/tests/mremap-expand-slice-collision.c
@@ -38,7 +38,7 @@ void init_slice_boundary(int fd)
unsigned long slice_size;
void *p1, *p2, *heap;
int slices_ok, i, rc;
-#ifdef __LP64__
+#if defined(__LP64__) && !defined(__aarch64__)
/* powerpc: 1TB slices starting at 1 TB */
slice_boundary = 0x100;
slice_size = 0x100;
-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 3/5] Add PROT_NONE to the mprotect test.

2013-09-10 Thread Steve Capper
The mprotect unit test checks PROT_READ and PROT_READ | PROT_WRITE
protections. We recently found that PROT_NONE wasn't properly
supported in an early version of our huge page kernel code.

This patch adds PROT_NONE tests to mprotect. The expected behaviour
is that neither reads nor writes should succeed.

Signed-off-by: Steve Capper 
---
 tests/mprotect.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/mprotect.c b/tests/mprotect.c
index aa4673e..db6a662 100644
--- a/tests/mprotect.c
+++ b/tests/mprotect.c
@@ -213,5 +213,11 @@ int main(int argc, char *argv[])
test_mprotect(fd, "RW->R 1/2", 2*hpage_size, PROT_READ|PROT_WRITE,
  hpage_size, PROT_READ);
 
+   /* PROT_NONE tests */
+   test_mprotect(fd, "NONE->R", hpage_size, PROT_NONE,
+ hpage_size, PROT_READ);
+   test_mprotect(fd, "NONE->RW", hpage_size, PROT_NONE,
+ hpage_size, PROT_READ|PROT_WRITE);
+
PASS();
 }
-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev


[PATCH 5/5] Cleanup ARM ld.hugetlbfs HTLB_LINK logic

2013-09-10 Thread Steve Capper
When ld.hugetlbfs is executed with --hugetlbfs-link, there is code
to check for the ARM platform and warn that this is not supported.

There is also code to check for CUSTOM_LDSCRIPTS being false and
give a similar warning.

This patch removes the ARM check as the CUSTOM_LDSCRIPTS check will
catch this.

Signed-off-by: Steve Capper 
---
 ld.hugetlbfs | 5 -
 1 file changed, 5 deletions(-)

diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index 5128aa2..ba9e00a 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -79,11 +79,6 @@ if [ -n "$HTLB_LINK" ]; then
 HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
 LDSCRIPT="$EMU.x$HTLB_LINK"
 HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
-
-if [ "$EMU" == "armelf_linux_eabi" ]; then
-echo "Please use --hugetlbfs-align when targeting ARM."
-   exit -1
-fi
 fi
 
 MB=$((1024*1024))
-- 
1.8.1.4


___
linaro-dev mailing list
linaro-dev@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/linaro-dev