Blame SOURCES/libhugetlbfs-2.17-aarch64.patch

f4a552
diff --git a/Makefile b/Makefile
f4a552
index 48205af..0e61701 100644
f4a552
--- a/Makefile
f4a552
+++ b/Makefile
f4a552
@@ -57,6 +57,12 @@ TMPLIB32 = lib
f4a552
 ELF32 += armelf_linux_eabi
f4a552
 CUSTOM_LDSCRIPTS = no
f4a552
 else
f4a552
+ifeq ($(ARCH),aarch64)
f4a552
+CC64 = gcc
f4a552
+ELF64 = aarch64elf
f4a552
+TMPLIB64 = lib64
f4a552
+CUSTOM_LDSCRIPTS = no
f4a552
+else
f4a552
 ifeq ($(ARCH),i386)
f4a552
 CC32 = gcc
f4a552
 ELF32 = elf_i386
f4a552
@@ -100,6 +106,7 @@ endif
f4a552
 endif
f4a552
 endif
f4a552
 endif
f4a552
+endif
f4a552
 
f4a552
 ifdef CC32
f4a552
 OBJDIRS += obj32
f4a552
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
f4a552
index d6d12c4..ba9e00a 100755
f4a552
--- a/ld.hugetlbfs
f4a552
+++ b/ld.hugetlbfs
f4a552
@@ -79,11 +79,6 @@ if [ -n "$HTLB_LINK" ]; then
f4a552
     HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
f4a552
     LDSCRIPT="$EMU.x$HTLB_LINK"
f4a552
     HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
f4a552
-
f4a552
-    if [ "$EMU" == "armelf_linux_eabi" ]; then
f4a552
-        echo "Please use --hugetlbfs-align when targeting ARM."
f4a552
-	exit -1
f4a552
-    fi
f4a552
 fi
f4a552
 
f4a552
 MB=$((1024*1024))
f4a552
@@ -91,7 +86,7 @@ case "$EMU" in
f4a552
 elf32ppclinux|elf64ppc)	HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
f4a552
 elf_i386|elf_x86_64)	HPAGE_SIZE=$((4*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
f4a552
 elf_s390|elf64_s390)	HPAGE_SIZE=$((1*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
f4a552
-armelf_linux_eabi)	HPAGE_SIZE=$((2*$MB)) SLICE_SIZE=$HPAGE_SIZE ;;
f4a552
+armelf_linux_eabi|aarch64elf)	HPAGE_SIZE=$((2*MB)) SLICE_SIZE=$HPAGE_SIZE ;;
f4a552
 esac
f4a552
 
f4a552
 if [ "$HTLB_ALIGN" == "slice" ]; then
f4a552
diff --git a/sys-aarch64elf.S b/sys-aarch64elf.S
f4a552
new file mode 100644
f4a552
index 0000000..54799d3
f4a552
--- /dev/null
f4a552
+++ b/sys-aarch64elf.S
f4a552
@@ -0,0 +1,34 @@
f4a552
+/*
f4a552
+ * libhugetlbfs - Easy use of Linux hugepages
f4a552
+ * Copyright (C) 2013 Linaro Ltd.
f4a552
+ *
f4a552
+ * This library is free software; you can redistribute it and/or
f4a552
+ * modify it under the terms of the GNU Lesser General Public License
f4a552
+ * version 2.1 as published by the Free Software Foundation.
f4a552
+ *
f4a552
+ * This library is distributed in the hope that it will be useful, but
f4a552
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
f4a552
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
f4a552
+ * Lesser General Public License for more details.
f4a552
+ *
f4a552
+ * You should have received a copy of the GNU Lesser General Public
f4a552
+ * License along with this library; if not, write to the Free Software
f4a552
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
f4a552
+ */
f4a552
+
f4a552
+        .text
f4a552
+
f4a552
+        .globl  direct_syscall
f4a552
+
f4a552
+
f4a552
+direct_syscall:
f4a552
+	uxtw	x8, w0
f4a552
+	mov	x0, x1
f4a552
+	mov	x1, x2
f4a552
+	mov	x2, x3
f4a552
+	mov	x3, x4
f4a552
+	mov	x4, x5
f4a552
+	mov	x5, x6
f4a552
+	mov	x6, x7
f4a552
+	svc	0x0
f4a552
+	ret
f4a552
diff --git a/tests/Makefile b/tests/Makefile
f4a552
index 231e3b0..9140e72 100644
f4a552
--- a/tests/Makefile
f4a552
+++ b/tests/Makefile
f4a552
@@ -54,7 +54,7 @@ ifeq ($(CUSTOM_LDSCRIPTS),yes)
f4a552
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
f4a552
 	$(HUGELINK_TESTS:%=xBDT.%)
f4a552
 else
f4a552
-TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS)
f4a552
+TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_RW_TESTS)
f4a552
 endif
f4a552
 
f4a552
 endif
f4a552
diff --git a/tests/icache-hygiene.c b/tests/icache-hygiene.c
f4a552
index 51792b3..876ce10 100644
f4a552
--- a/tests/icache-hygiene.c
f4a552
+++ b/tests/icache-hygiene.c
f4a552
@@ -54,7 +54,7 @@ static void cacheflush(void *p)
f4a552
 {
f4a552
 #if defined(__powerpc__)
f4a552
 	asm volatile("dcbst 0,%0; sync; icbi 0,%0; isync" : : "r"(p));
f4a552
-#elif defined(__arm__)
f4a552
+#elif defined(__arm__) || defined(__aarch64__)
f4a552
 	__clear_cache(p, p + COPY_SIZE);
f4a552
 #endif
f4a552
 }
f4a552
@@ -87,8 +87,9 @@ static void *sig_expected;
f4a552
 static void sig_handler(int signum, siginfo_t *si, void *uc)
f4a552
 {
f4a552
 #if defined(__powerpc__) || defined(__powerpc64__) || defined(__ia64__) || \
f4a552
-    defined(__s390__) || defined(__s390x__) || defined(__sparc__)
f4a552
-	/* On powerpc and ia64 and s390, 0 bytes are an illegal
f4a552
+    defined(__s390__) || defined(__s390x__) || defined(__sparc__) || \
f4a552
+    defined(__aarch64__)
f4a552
+	/* On powerpc, ia64, s390 and Aarch64, 0 bytes are an illegal
f4a552
 	 * instruction, so, if the icache is cleared properly, we SIGILL
f4a552
 	 * as soon as we jump into the cleared page */
f4a552
 	if (signum == SIGILL) {
f4a552
diff --git a/tests/mprotect.c b/tests/mprotect.c
f4a552
index aa4673e..db6a662 100644
f4a552
--- a/tests/mprotect.c
f4a552
+++ b/tests/mprotect.c
f4a552
@@ -213,5 +213,11 @@ int main(int argc, char *argv[])
f4a552
 	test_mprotect(fd, "RW->R 1/2", 2*hpage_size, PROT_READ|PROT_WRITE,
f4a552
 		      hpage_size, PROT_READ);
f4a552
 
f4a552
+	/* PROT_NONE tests */
f4a552
+	test_mprotect(fd, "NONE->R", hpage_size, PROT_NONE,
f4a552
+		      hpage_size, PROT_READ);
f4a552
+	test_mprotect(fd, "NONE->RW", hpage_size, PROT_NONE,
f4a552
+		      hpage_size, PROT_READ|PROT_WRITE);
f4a552
+
f4a552
 	PASS();
f4a552
 }
f4a552
diff --git a/tests/mremap-expand-slice-collision.c b/tests/mremap-expand-slice-collision.c
f4a552
index c25f4c6..853f3c3 100644
f4a552
--- a/tests/mremap-expand-slice-collision.c
f4a552
+++ b/tests/mremap-expand-slice-collision.c
f4a552
@@ -38,7 +38,7 @@ void init_slice_boundary(int fd)
f4a552
 	unsigned long slice_size;
f4a552
 	void *p1, *p2, *heap;
f4a552
 	int slices_ok, i, rc;
f4a552
-#ifdef __LP64__
f4a552
+#if defined(__LP64__) && !defined(__aarch64__)
f4a552
 	/* powerpc: 1TB slices starting at 1 TB */
f4a552
 	slice_boundary = 0x10000000000;
f4a552
 	slice_size = 0x10000000000;