Blame SOURCES/libhugetlbfs-2.17-aarch64.patch

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