diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5eea465
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+SOURCES/libhugetlbfs-2.16.tar.gz
diff --git a/.libhugetlbfs.metadata b/.libhugetlbfs.metadata
new file mode 100644
index 0000000..35c2a4d
--- /dev/null
+++ b/.libhugetlbfs.metadata
@@ -0,0 +1 @@
+4dd1c44990d0d8d480419ba371928ab2e0bede7c SOURCES/libhugetlbfs-2.16.tar.gz
diff --git a/SOURCES/0001-testutils-fix-range_is_mapped.patch b/SOURCES/0001-testutils-fix-range_is_mapped.patch
new file mode 100644
index 0000000..2b3e9d6
--- /dev/null
+++ b/SOURCES/0001-testutils-fix-range_is_mapped.patch
@@ -0,0 +1,68 @@
+From 192ac21a3c057c5dedca4cdd1bf700f38992030c Mon Sep 17 00:00:00 2001
+Message-Id: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com>
+From: Jan Stancek <jstancek@redhat.com>
+Date: Thu, 1 Jun 2017 09:48:41 +0200
+Subject: [PATCH v2 1/2] testutils: fix range_is_mapped()
+
+It doesn't return correct value when tested region is
+completely inside existing mapping:
+
+  +--------------------------------------+
+  ^ start                                ^ end
+           +----------------+
+           ^ low            ^ high
+
+Rather than testing for all combinations of 2 regions overlapping,
+flip the condition and test if they don't overlap.
+
+Signed-off-by: Jan Stancek <jstancek@redhat.com>
+---
+ tests/testutils.c | 22 ++++++++++++++++------
+ 1 file changed, 16 insertions(+), 6 deletions(-)
+
+This is a v2 series for:
+  https://groups.google.com/forum/#!topic/libhugetlbfs/tAsWjuJ7x8k
+
+diff --git a/tests/testutils.c b/tests/testutils.c
+index 629837045465..f42852e1938b 100644
+--- a/tests/testutils.c
++++ b/tests/testutils.c
+@@ -190,19 +190,29 @@ int range_is_mapped(unsigned long low, unsigned long high)
+ 			return -1;
+ 		}
+ 
+-		if ((start >= low) && (start < high)) {
++		/*
++		 * (existing mapping)    (tested region)
++		 * +----------------+      +.......+
++		 * ^start           ^end   ^ low   ^high
++		 */
++		if (low >= end) {
+ 			fclose(f);
+-			return 1;
++			return 0;
+ 		}
+-		if ((end >= low) && (end < high)) {
++
++		/*
++		 * (tested region)  (existing mapping)
++		 *     +.....+      +----------------+
++		 *     ^low  ^high  ^ start          ^end
++		 */
++		if (high <= start) {
+ 			fclose(f);
+-			return 1;
++			return 0;
+ 		}
+-
+ 	}
+ 
+ 	fclose(f);
+-	return 0;
++	return 1;
+ }
+ 
+ /*
+-- 
+1.8.3.1
+
diff --git a/SOURCES/0002-stack_grow_into_huge-don-t-clobber-existing-mappings.patch b/SOURCES/0002-stack_grow_into_huge-don-t-clobber-existing-mappings.patch
new file mode 100644
index 0000000..2d121fd
--- /dev/null
+++ b/SOURCES/0002-stack_grow_into_huge-don-t-clobber-existing-mappings.patch
@@ -0,0 +1,173 @@
+From a329008ea54056f0ed9d85cc3d0d9129474f7cd5 Mon Sep 17 00:00:00 2001
+Message-Id: <a329008ea54056f0ed9d85cc3d0d9129474f7cd5.1496667760.git.jstancek@redhat.com>
+In-Reply-To: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com>
+References: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com>
+From: Jan Stancek <jstancek@redhat.com>
+Date: Thu, 1 Jun 2017 10:00:47 +0200
+Subject: [PATCH v2 2/2] stack_grow_into_huge: don't clobber existing mappings
+
+This test allocates hugepages above stack using MAP_FIXED and then
+grows stack while it can. If a MAP_FIXED request is successful,
+then mapping established by mmap() replaces any previous mappings
+for the process' pages. If there's anything important there (libc
+mappings), these can get clobbered as described here:
+  http://marc.info/?l=linux-arm-kernel&m=149036535209519&w=2.
+
+This patch is creating extra stack for new child and maps
+one hugepage above it. The search starts at heap until it
+hits existing mapping or until it can successfully map
+huge page and stack below it.
+
+If suitable place can't be found, test PASSes as inconclusive.
+
+Signed-off-by: Jan Stancek <jstancek@redhat.com>
+---
+ tests/stack_grow_into_huge.c | 101 ++++++++++++++++++++++++++++---------------
+ 1 file changed, 67 insertions(+), 34 deletions(-)
+
+This is a v2 series for:
+  https://groups.google.com/forum/#!topic/libhugetlbfs/tAsWjuJ7x8k
+
+diff --git a/tests/stack_grow_into_huge.c b/tests/stack_grow_into_huge.c
+index a380da063264..9b8ea8d74887 100644
+--- a/tests/stack_grow_into_huge.c
++++ b/tests/stack_grow_into_huge.c
+@@ -25,6 +25,7 @@
+ #include <sys/mman.h>
+ #include <sys/resource.h>
+ #include <sys/wait.h>
++#include <sched.h>
+ 
+ #include <hugetlbfs.h>
+ #include "hugetests.h"
+@@ -54,7 +55,10 @@
+ #define STACK_ALLOCATION_SIZE	(16*1024*1024)
+ #endif
+ 
+-void do_child(void *stop_address)
++#define MIN_CHILD_STACK (2*1024*1024)
++#define STEP (STACK_ALLOCATION_SIZE)
++
++int do_child(void *stop_address)
+ {
+ 	struct rlimit r;
+ 	volatile int *x;
+@@ -71,15 +75,68 @@ void do_child(void *stop_address)
+ 		x = alloca(STACK_ALLOCATION_SIZE);
+ 		*x = 1;
+ 	} while ((void *)x >= stop_address);
++
++	return 0;
++}
++
++void *try_setup_stack_and_huge(int fd, void *hint)
++{
++	void *mmap_address, *stack_start, *tmp;
++	long hpage_size = gethugepagesize();
++	void *stop = alloca(1);
++
++	/*
++	 * Find a spot for huge page. We start at "hint" and
++	 * keep going down in "STEP" increments until we find
++	 * a place where we can mmap huge page.
++	 */
++	mmap_address = PALIGN(hint, hpage_size);
++	do {
++		mmap_address += STEP;
++		if (mmap_address >= stop)
++			return NULL;
++		if (range_is_mapped((unsigned long)mmap_address,
++			(unsigned long)mmap_address + hpage_size))
++			continue;
++		tmp = mmap(mmap_address, hpage_size,
++			PROT_READ|PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
++	} while (tmp == MAP_FAILED);
++	verbose_printf("huge page is at: %p-%p\n",
++		mmap_address, mmap_address + hpage_size);
++
++	/*
++	 * Find a spot for stack below huge page. We start at end of
++	 * huge page we found above and keep trying to mmap stack
++	 * below. Because stack needs to grow into hugepage, we
++	 * also have to make sure nothing is mapped in gap between
++	 * stack and huge page.
++	 */
++	stack_start = mmap_address + hpage_size;
++	do {
++		if (range_is_mapped((unsigned long)stack_start,
++			(unsigned long)stack_start + STEP + MIN_CHILD_STACK)) {
++			verbose_printf("range is mapped: %p-%p\n", stack_start,
++				stack_start + STEP + MIN_CHILD_STACK);
++			munmap(mmap_address, hpage_size);
++			return NULL;
++		}
++		stack_start += STEP;
++		if (stack_start >= stop)
++			return NULL;
++		tmp = mmap(stack_start, MIN_CHILD_STACK, PROT_READ|PROT_WRITE,
++			MAP_GROWSDOWN|MAP_PRIVATE|MAP_ANONYMOUS|MAP_FIXED, -1, 0);
++	} while (tmp == MAP_FAILED);
++
++	verbose_printf("Child stack is at %p-%p\n",
++		stack_start, stack_start + MIN_CHILD_STACK);
++	return stack_start + MIN_CHILD_STACK;
+ }
+ 
+ int main(int argc, char *argv[])
+ {
+ 	int fd, pid, s, ret;
+ 	struct rlimit r;
+-	char *b;
+-	long hpage_size = gethugepagesize();
+-	void *stack_address, *mmap_address, *heap_address;
++	void *stack_end;
+ 
+ 	test_init(argc, argv);
+ 
+@@ -94,37 +151,13 @@ int main(int argc, char *argv[])
+ 	if (fd < 0)
+ 		CONFIG("Couldn't get hugepage fd");
+ 
+-	stack_address = alloca(0);
+-	heap_address = sbrk(0);
++	stack_end = try_setup_stack_and_huge(fd, sbrk(0));
++	if (!stack_end)
++		PASS_INCONCLUSIVE();
+ 
+-	/*
+-	 * paranoia: start mapping two hugepages below the start of the stack,
+-	 * in case the alignment would cause us to map over something if we
+-	 * only used a gap of one hugepage.
+-	 */
+-	mmap_address = PALIGN(stack_address - 2 * hpage_size, hpage_size);
+-
+-	do {
+-		b = mmap(mmap_address, hpage_size, PROT_READ|PROT_WRITE,
+-						MAP_FIXED|MAP_SHARED, fd, 0);
+-		mmap_address -= hpage_size;
+-		/*
+-		 * if we get all the way down to the heap, stop trying
+-		 */
+-		if (mmap_address <= heap_address)
+-			break;
+-	} while (b == MAP_FAILED);
+-
+-	if (b == MAP_FAILED)
+-		FAIL("mmap: %s", strerror(errno));
+-
+-	if ((pid = fork()) < 0)
+-		FAIL("fork: %s", strerror(errno));
+-
+-	if (pid == 0) {
+-		do_child(mmap_address);
+-		exit(0);
+-	}
++	pid = clone(do_child, stack_end, SIGCHLD, 0);
++	if (pid < 0)
++		FAIL("clone: %s", strerror(errno));
+ 
+ 	ret = waitpid(pid, &s, 0);
+ 	if (ret == -1)
+-- 
+1.8.3.1
+
diff --git a/SOURCES/libhugetlbfs-2.15-fortify.patch b/SOURCES/libhugetlbfs-2.15-fortify.patch
new file mode 100644
index 0000000..0f89a2c
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.15-fortify.patch
@@ -0,0 +1,12 @@
+diff -up libhugetlbfs-2.15/Makefile.fortify libhugetlbfs-2.15/Makefile
+--- libhugetlbfs-2.15/Makefile.fortify	2012-12-12 11:33:54.725402249 +0100
++++ libhugetlbfs-2.15/Makefile	2012-12-12 11:34:24.130531531 +0100
+@@ -30,7 +30,7 @@ INSTALL = install
+ LDFLAGS += -Wl,-z,noexecstack -ldl
+ CFLAGS ?= -O2 -g
+ CFLAGS += -Wall -fPIC
+-CPPFLAGS += -D__LIBHUGETLBFS__
++CPPFLAGS += -D__LIBHUGETLBFS__ -DFORTIFY_SOURCE
+ 
+ ARCH = $(shell uname -m | sed -e s/i.86/i386/)
+ 
diff --git a/SOURCES/libhugetlbfs-2.16-makefile_cflags.patch b/SOURCES/libhugetlbfs-2.16-makefile_cflags.patch
new file mode 100644
index 0000000..de95b12
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-makefile_cflags.patch
@@ -0,0 +1,12 @@
+diff -up libhugetlbfs-2.16/Makefile.orig libhugetlbfs-2.16/Makefile
+--- libhugetlbfs-2.16/Makefile.orig	2014-03-03 12:50:43.408107252 +0100
++++ libhugetlbfs-2.16/Makefile	2014-03-03 12:52:01.070230134 +0100
+@@ -29,7 +29,7 @@ INSTALL = install
+ 
+ LDFLAGS += -Wl,-z,noexecstack -ldl
+ CFLAGS ?= -O2 -g
+-CFLAGS += -Wall -fPIC
++CFLAGS += -Wall -fPIC -fstack-protector-strong
+ CPPFLAGS += -D__LIBHUGETLBFS__ -DFORTIFY_SOURCE
+ 
+ ARCH = $(shell uname -m | sed -e s/i.86/i386/)
diff --git a/SOURCES/libhugetlbfs-2.16-makefile_segments.patch b/SOURCES/libhugetlbfs-2.16-makefile_segments.patch
new file mode 100644
index 0000000..85751b4
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-makefile_segments.patch
@@ -0,0 +1,11 @@
+diff -up libhugetlbfs-2.16/Makefile.orig libhugetlbfs-2.16/Makefile
+--- libhugetlbfs-2.16/Makefile.orig	2014-07-29 17:25:28.126626119 +0200
++++ libhugetlbfs-2.16/Makefile	2014-07-29 17:25:47.249662564 +0200
+@@ -50,6 +50,7 @@ ifeq ($(ARCH),ppc)
+ CC32 = gcc -m32
+ ELF32 = elf32ppclinux
+ TMPLIB32 = lib
++CPPFLAGS += -DPPC_NO_SEGMENTS
+ else
+ ifeq ($(ARCH),armv7l)
+ CC32 = gcc
diff --git a/SOURCES/libhugetlbfs-2.16-map_high_truncate.patch b/SOURCES/libhugetlbfs-2.16-map_high_truncate.patch
new file mode 100644
index 0000000..a420a2e
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-map_high_truncate.patch
@@ -0,0 +1,42 @@
+commit f008e0d18a4ba8ac26b67c5989efde3406bce535
+Author: Jan Stancek <jstancek@redhat.com>
+Date:   Fri Dec 5 13:57:04 2014 +0100
+
+    lower mmap size of map_high_truncate_2 on 32bit s390
+    
+    The low and high limit passed to vm_unmapped_area() in
+    hugetlb_get_unmapped_area() is (TASK_UNMAPPED_BASE, TASK_SIZE).
+    
+    On 64-bit kernel this is defined as:
+      #define TASK_UNMAPPED_BASE (test_thread_flag(TIF_31BIT) ? \
+                                 (1UL << 30) : (1UL << 41))
+      #define TASK_SIZE_OF(tsk)  ((tsk)->mm->context.asce_limit)
+    
+    For 32-bit (-m31) process, this can be as small as
+    (0x40000000, 0x80000000), which is 0x40000000 bytes long area.
+    This testcase however is trying to allocate 0x60000000 and fails:
+      FAIL mmap() 1: Cannot allocate memory
+    
+    Lower mmap size to ~0x20000000, which is more likely to suit
+    address space constraints of 32-bit s390.
+    
+    Signed-off-by: Jan Stancek <jstancek@redhat.com>
+    Signed-off-by: Eric B Munson <emunson@mgebm.net>
+
+diff --git a/tests/map_high_truncate_2.c b/tests/map_high_truncate_2.c
+index daabd00..2a2560b 100644
+--- a/tests/map_high_truncate_2.c
++++ b/tests/map_high_truncate_2.c
+@@ -50,7 +50,11 @@
+  * 856fc29505556cf263f3dcda2533cf3766c14ab6.
+  */
+ #define MAP_LENGTH	(4 * hpage_size)
+-#define TRUNCATE_POINT	0x60000000UL
++#if defined(__s390__) && __WORDSIZE == 32
++#define TRUNCATE_POINT 0x20000000UL
++#else
++#define TRUNCATE_POINT 0x60000000UL
++#endif
+ #define HIGH_ADDR	0xa0000000UL
+ 
+ int main(int argc, char *argv[])
diff --git a/SOURCES/libhugetlbfs-2.16-misalign_test.patch b/SOURCES/libhugetlbfs-2.16-misalign_test.patch
new file mode 100644
index 0000000..a831955
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-misalign_test.patch
@@ -0,0 +1,96 @@
+commit fd430caf7126228cd7e208547ae83b335400e040
+Author: Jan Stancek <jstancek@redhat.com>
+Date:   Mon Feb 10 21:18:05 2014 -0500
+
+    [PATCH] misalign: misaligned length allowed on kernels >= 3.10-rc1
+    
+    Startin with 3.10-rc1, length passed in mmap() doesn't need
+    to be aligned because commit af73e4d9506d3b797509f3c030e7dcd554f7d9c4
+    added ALIGN() to kernel side, in mmap_pgoff(), when mapping huge
+    page files.
+    
+    This patch treats successful mmap() with misaligned length on
+    kernels >= 3.10 as PASS.
+    
+    See also:
+    Bug 56881 - MAP_HUGETLB mmap fails for certain sizes
+    https://bugzilla.kernel.org/show_bug.cgi?id=56881
+    
+    Signed-off-by: Jan Stancek <jstancek@redhat.com>
+    Signed-off-by: Eric Munson <emunson@mgebm.net>
+
+diff --git a/tests/misalign.c b/tests/misalign.c
+index de85be6..de1bf98 100644
+--- a/tests/misalign.c
++++ b/tests/misalign.c
+@@ -23,6 +23,7 @@
+ #include <errno.h>
+ #include <signal.h>
+ #include <sys/mman.h>
++#include <sys/utsname.h>
+ 
+ #include <hugetlbfs.h>
+ 
+@@ -40,6 +41,11 @@
+  * necessary checks for the hugepage paths.  This testcase ensures
+  * that attempted hugepage mappings with parameters which are not
+  * correctly hugepage aligned are rejected.
++ *
++ * However starting with 3.10-rc1, length passed in mmap() doesn't need
++ * to be aligned because commit af73e4d9506d3b797509f3c030e7dcd554f7d9c4
++ * added ALIGN() to kernel side, in mmap_pgoff(), when mapping huge page
++ * files.
+  */
+ int main(int argc, char *argv[])
+ {
+@@ -47,9 +53,13 @@ int main(int argc, char *argv[])
+ 	int fd;
+ 	void *p, *q;
+ 	int err;
++	struct utsname buf;
+ 
+ 	test_init(argc, argv);
+ 
++	if (uname(&buf) != 0)
++		FAIL("uname failed %s", strerror(errno));
++
+ 	page_size = getpagesize();
+ 	hpage_size = check_hugepagesize();
+ 
+@@ -92,16 +102,30 @@ int main(int argc, char *argv[])
+ 
+ 	/* 3) Try a misaligned length */
+ 	q = mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+-	if (q != MAP_FAILED)
+-		FAIL("mmap() with misaligned length 0x%lx succeeded",
+-		     page_size);
++
++	if (test_compare_kver(buf.release, "3.10.0") < 0) {
++		if (q != MAP_FAILED)
++			FAIL("mmap() with misaligned length 0x%lx succeeded",
++				page_size);
++	} else {
++		if (q == MAP_FAILED)
++			FAIL("mmap() with misaligned length 0x%lx failed",
++				page_size);
++	}
+ 
+ 	/* 4) Try a misaligned length with MAP_FIXED */
+ 	q = mmap(p, page_size, PROT_READ|PROT_WRITE,
+ 		 MAP_PRIVATE|MAP_FIXED, fd, 0);
+-	if (q != MAP_FAILED)
+-		FAIL("mmap() MAP_FIXED with misaligned length 0x%lx succeeded",
+-		     page_size);
++
++	if (test_compare_kver(buf.release, "3.10.0") < 0) {
++		if (q != MAP_FAILED)
++			FAIL("mmap() MAP_FIXED with misaligned length 0x%lx "
++				"succeeded", page_size);
++	} else {
++		if (q == MAP_FAILED)
++			FAIL("mmap() MAP_FIXED with misaligned length 0x%lx "
++				"failed", page_size);
++	}
+ 
+ 	/* 5) Try a misaligned offset */
+ 	q = mmap(NULL, hpage_size, PROT_READ|PROT_WRITE,
diff --git a/SOURCES/libhugetlbfs-2.16-mounts_warning.patch b/SOURCES/libhugetlbfs-2.16-mounts_warning.patch
new file mode 100644
index 0000000..cbfee14
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-mounts_warning.patch
@@ -0,0 +1,28 @@
+diff -up libhugetlbfs-2.16/hugeadm.c.orig libhugetlbfs-2.16/hugeadm.c
+--- libhugetlbfs-2.16/hugeadm.c.orig	2014-07-29 18:36:06.572447296 +0200
++++ libhugetlbfs-2.16/hugeadm.c	2014-07-29 18:36:40.877511388 +0200
+@@ -517,6 +517,8 @@ int mount_dir(char *path, char *options,
+ 	struct mntent entry;
+ 	FILE *mounts;
+ 	struct mount_list *list, *previous;
++	char dummy;
++	int useMtab;
+ 
+ 	list = collect_active_mounts(NULL);
+ 
+@@ -552,6 +554,15 @@ int mount_dir(char *path, char *options,
+ 			return 1;
+ 		}
+ 
++	/* Check if mtab is a symlink */
++	useMtab = (readlink(MOUNTED, &dummy, 1) < 0);
++	if (!useMtab) {
++		/* No need updating mtab */
++		return 0;
++	}
++
++
++
+ 		mounts = setmntent(MOUNTED, "a+");
+ 		if (mounts) {
+ 			entry.mnt_fsname = FS_NAME;
diff --git a/SOURCES/libhugetlbfs-2.16-plt_extrasz_fix.patch b/SOURCES/libhugetlbfs-2.16-plt_extrasz_fix.patch
new file mode 100644
index 0000000..ce3fcd3
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-plt_extrasz_fix.patch
@@ -0,0 +1,13 @@
+diff -up libhugetlbfs-2.16/Makefile.orig libhugetlbfs-2.16/Makefile
+--- libhugetlbfs-2.16/Makefile.orig	2014-11-06 23:06:07.605004158 +0100
++++ libhugetlbfs-2.16/Makefile	2014-11-06 23:07:07.354883338 +0100
+@@ -150,6 +150,9 @@ endif
+ ifeq ($(ELF64),elf64ppc)
+ LIBOBJS64 += obj64/$(ELF64).o
+ endif
++ifeq ($(ELF64),elf64lppc)
++LIBOBJS64 += obj64/$(ELF64).o
++endif
+ LIBOBJS32 += $(LIBOBJS:%=obj32/%)
+ LIBOBJS64 += $(LIBOBJS:%=obj64/%)
+ 
diff --git a/SOURCES/libhugetlbfs-2.16-ppc64le-support.patch b/SOURCES/libhugetlbfs-2.16-ppc64le-support.patch
new file mode 100644
index 0000000..df61f46
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-ppc64le-support.patch
@@ -0,0 +1,81 @@
+Backport of https://www.mail-archive.com/libhugetlbfs-devel@lists.sourceforge.net/msg13914.html
+
+--
+diff --git a/Makefile b/Makefile
+index 9500fd5..fab7607 100644
+--- a/Makefile
++++ b/Makefile
+@@ -46,6 +46,12 @@ CC32 = gcc -m32
+ ELF32 = elf32ppclinux
+ endif
+ else
++ifeq ($(ARCH),ppc64le)
++CC64 = $(CC) -m64
++ELF64 = elf64lppc
++TMPLIB64 = lib64
++CUSTOM_LDSCRIPTS = no
++else
+ ifeq ($(ARCH),ppc)
+ CC32 = gcc -m32
+ ELF32 = elf32ppclinux
+@@ -117,6 +123,7 @@ endif
+ endif
+ endif
+ endif
++endif
+ 
+ ifdef CC32
+ OBJDIRS += obj32
+diff --git a/contrib/tlbmiss_cost.sh b/contrib/tlbmiss_cost.sh
+index 1f1e234..8fbf798 100755
+--- a/contrib/tlbmiss_cost.sh
++++ b/contrib/tlbmiss_cost.sh
+@@ -44,7 +44,7 @@ cpumhz() {
+ 	FNAME="cpu MHz"
+ 	FINDEX=4
+ 	case "`uname -m`" in
+-		ppc64)
++		ppc64|ppc64le)
+ 			FNAME="clock"
+ 			FINDEX=3
+ 			;;
+diff --git a/ld.hugetlbfs b/ld.hugetlbfs
+index ba9e00a..df446dd 100755
+--- a/ld.hugetlbfs
++++ b/ld.hugetlbfs
+@@ -84,6 +84,7 @@ fi
+ MB=$((1024*1024))
+ case "$EMU" in
+ elf32ppclinux|elf64ppc)	HPAGE_SIZE=$((16*$MB)) SLICE_SIZE=$((256*$MB)) ;;
++elf64lppc)		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|aarch64elf)	HPAGE_SIZE=$((2*MB)) SLICE_SIZE=$HPAGE_SIZE ;;
+diff --git a/sys-elf64ppc.S b/sys-elf64ppc.S
+index 1b63ff0..d50f4a6 100644
+--- a/sys-elf64ppc.S
++++ b/sys-elf64ppc.S
+@@ -20,7 +20,7 @@
+  */
+ 
+ 	.text
+-
++#if _CALL_ELF != 2
+ 	.align	2
+ 	.globl	direct_syscall
+ 	.globl	.direct_syscall
+@@ -32,6 +32,11 @@ direct_syscall:
+ 	.previous
+ 	.type	.direct_syscall,@function
+ .direct_syscall:
++#else
++	.globl	direct_syscall
++	.type	direct_syscall,@function
++direct_syscall:
++#endif
+ 	mr	0,3
+ 	mr	3,4
+ 	mr	4,5
+-- 
+1.8.3.1
+
diff --git a/SOURCES/libhugetlbfs-2.16-s390.patch b/SOURCES/libhugetlbfs-2.16-s390.patch
new file mode 100644
index 0000000..1523468
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.16-s390.patch
@@ -0,0 +1,32 @@
+diff -up libhugetlbfs-2.16/Makefile.s390 libhugetlbfs-2.16/Makefile
+--- libhugetlbfs-2.16/Makefile.s390	2013-05-12 08:49:28.160883455 +0200
++++ libhugetlbfs-2.16/Makefile	2013-05-12 08:49:39.586906994 +0200
+@@ -84,17 +84,26 @@ CFLAGS += -DNO_ELFLINK
+ else
+ ifeq ($(ARCH),s390x)
+ CC64 = gcc -m64
+-CC32 = gcc -m31
+-ELF32 = elf_s390
+ ELF64 = elf64_s390
+ TMPLIB64 = lib64
+ TMPLIB32 = lib
+ CUSTOM_LDSCRIPTS = no
++ifneq ($(BUILDTYPE),NATIVEONLY)
++CC32 = gcc -m31
++ELF32 = elf_s390
++endif
++else
++ifeq ($(ARCH),s390)
++CC32 = gcc -m31
++ELF32 = elf_s390
++TMPLIB32 = lib
++CUSTOM_LDSCRIPTS = no
+ else
+ $(error "Unrecognized architecture ($(ARCH))")
+ endif
+ endif
+ endif
++endif
+ endif
+ endif
+ endif
diff --git a/SOURCES/libhugetlbfs-2.17-aarch64.patch b/SOURCES/libhugetlbfs-2.17-aarch64.patch
new file mode 100644
index 0000000..7d1db49
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.17-aarch64.patch
@@ -0,0 +1,157 @@
+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..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))
+@@ -91,7 +86,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 0000000..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:
++	uxtw	x8, 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
+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
+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/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();
+ }
+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 = 0x10000000000;
+ 	slice_size = 0x10000000000;
diff --git a/SOURCES/libhugetlbfs-2.20-defined-task-size-value-to-be-512T-if-it-is-more-than-64Tb.patch b/SOURCES/libhugetlbfs-2.20-defined-task-size-value-to-be-512T-if-it-is-more-than-64Tb.patch
new file mode 100644
index 0000000..a0b1f96
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.20-defined-task-size-value-to-be-512T-if-it-is-more-than-64Tb.patch
@@ -0,0 +1,28 @@
+commit 02df38e93e25e07f4d54edae94fb4ec90b7a2824
+Author: Santhosh G <santhog4@linux.vnet.ibm.com>
+Date:   Thu Jul 27 13:10:37 2017 +0530
+
+    Defined task size value to be 512T if it is more that 64Tb.
+    
+    The Test case needs to loop till 512Tb to get the TASK_SIZE value.
+    This patch defines the value to be 512T if the test tries to loop
+    above 64T.
+    
+    Signed-off-by: Santhosh G <santhog4@linux.vnet.ibm.com>
+    Signed-off-by: Eric B Munson <emunson@mgebm.net>
+
+diff --git a/tests/task-size-overrun.c b/tests/task-size-overrun.c
+index 0ab76c7..dc9ce0e 100644
+--- a/tests/task-size-overrun.c
++++ b/tests/task-size-overrun.c
+@@ -82,6 +82,10 @@ static unsigned long find_task_size(void)
+ 		}
+ 		munmap(p, getpagesize());
+ 		addr += getpagesize();
++#if defined(__powerpc64__)
++		if (addr > (1UL << 46) && addr < (1UL << 49))
++			addr = 1UL << 49;
++#endif
+ #if defined(__s390x__)
+ 		if (addr > (1UL << 42) && addr < (1UL << 53))
+ 			addr = 1UL << 53;
diff --git a/SOURCES/libhugetlbfs-2.20-do-not-assume-default-huge-page-size-is-first.patch b/SOURCES/libhugetlbfs-2.20-do-not-assume-default-huge-page-size-is-first.patch
new file mode 100644
index 0000000..5497a25
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.20-do-not-assume-default-huge-page-size-is-first.patch
@@ -0,0 +1,42 @@
+commit 77cf8bdf8f523c1417e5dc54db72fb74c8c15f56
+Author: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
+Date:   Tue Sep 1 12:26:59 2015 -0700
+
+    huge_page_setup_helper: do not assume default huge page size is first
+    
+    The helper script currently implicitly assumes that `hugeadm
+    --pool-list` will emit the default size first, as it assumes every line
+    has 5 fields in it. But only the default field does, and if `hugeadm
+    --pool-list` were to output:
+    
+    hugeadm --pool-list
+          Size  Minimum  Current  Maximum  Default
+       1048576        0        0        0
+      16777216        0        0        0        *
+    17179869184        0        0        0
+    
+    we receive an error from the script:
+     # ./huge_page_setup_helper.py
+    Traceback (most recent call last):
+      File "./huge_page_setup_helper.py", line 51, in <module>
+        if line.split()[4] == '*':
+    IndexError: list index out of range
+    
+    Just check for the '*' character to determine the default line.
+    
+    Signed-off-by: Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
+    Signed-off-by: Eric B Munson <emunson@mgebm.net>
+
+diff --git a/huge_page_setup_helper.py b/huge_page_setup_helper.py
+index 8bfef14..43c9916 100755
+--- a/huge_page_setup_helper.py
++++ b/huge_page_setup_helper.py
+@@ -48,7 +48,7 @@ if memTotal == 0:
+ # Pick the default huge page size and see how many pages are allocated
+ poolList = os.popen("/usr/bin/hugeadm --pool-list").readlines()
+ for line in poolList:
+-    if line.split()[4] == '*':
++    if '*' in line:
+         hugePageSize = int(line.split()[0])
+         hugePages = int(line.split()[2])
+         break
diff --git a/SOURCES/libhugetlbfs-2.20-tests-linkhuge_rw-function-ptr-may-not-refer-to-text.patch b/SOURCES/libhugetlbfs-2.20-tests-linkhuge_rw-function-ptr-may-not-refer-to-text.patch
new file mode 100644
index 0000000..f854fd1
--- /dev/null
+++ b/SOURCES/libhugetlbfs-2.20-tests-linkhuge_rw-function-ptr-may-not-refer-to-text.patch
@@ -0,0 +1,196 @@
+commit 9dbe121e3132630e9094d36c2b0624404b75beea
+Author: Jan Stancek <jstancek@redhat.com>
+Date:   Tue Sep 1 15:49:35 2015 +0200
+
+    tests/linkhuge_rw: function ptr may not refer to .text
+    
+    On some ABIs function pointer may not refer to .text section.
+    For example on powerPC 64-bit ABI, function pointer may refer
+    to a call stub from .opd section.
+    
+    This creates a problem for linkhuge_rw tests which run with
+    HUGETLB_ELFMAP=R, because test is expecting that address of
+    function pointer will be backed by huge pages. But because
+    .opd section is from RW PT_LOAD segment, this doens't happen,
+    since libhugetlbfs is instructed to map only R segments via
+    HUGETLB_ELFMAP=R.
+    
+    This patch is replacing use of function pointer with address
+    returned by gcc's __builtin_return_address(), that is called
+    by the function itself. This should provide an address that
+    is from an actual code, residing in .text section.
+    
+    Signed-off-by: Jan Stancek <jstancek@redhat.com>
+    Cc: Adam Litke <agl@us.ibm.com>
+    Cc: Eric B Munson <emunson@mgebm.net>
+    Cc: Petr Holasek <pholasek@redhat.com>
+    Signed-off-by: Eric B Munson <emunson@mgebm.net>
+
+diff --git a/tests/linkhuge_rw.c b/tests/linkhuge_rw.c
+index f58fff2..c1c2e96 100644
+--- a/tests/linkhuge_rw.c
++++ b/tests/linkhuge_rw.c
+@@ -31,7 +31,8 @@
+ #include "hugetests.h"
+ 
+ #define BLOCK_SIZE	16384
+-#define CONST	0xdeadbeef
++#define CONST		0xdeadbeef
++#define RETURN_ADDRESS	0x0
+ 
+ #define BIG_INIT	{ \
+ 	[0] = CONST, [17] = CONST, [BLOCK_SIZE-1] = CONST, \
+@@ -45,13 +46,49 @@ static int big_bss[BLOCK_SIZE];
+ const int small_const = CONST;
+ const int big_const[BLOCK_SIZE] = BIG_INIT;
+ 
+-static int static_func(int x)
++/*
++ * Turn function pointer into address from .text.
++ *
++ * On some ABIs function pointer may not refer to .text section. For example
++ * on powerPC 64-bit ABI, function pointer may refer to call stub from
++ * .opd section.
++ *
++ * This function expects that parameter data is a function pointer of type:
++ * long f(long), and when called with special parameter, it returns an address
++ * corresponding to actual code of the function. Current implementation relies
++ * on gcc's __builtin_return_address, see get_pc() below.
++ */
++static inline void *get_text_addr(void *data)
++{
++	long (*gettext)(long) = data;
++
++	return (void *)gettext(RETURN_ADDRESS);
++}
++
++static void __attribute__ ((noinline)) *get_pc(void)
++{
++#if defined(__s390__) && __WORDSIZE == 32
++	/* taken from sysdeps/unix/sysv/linux/s390/s390-32/profil-counter.h
++	 * 31-bit s390 pointers don't use the 32th bit, however integers do,
++	 * so wrap the value around at 31 bits */
++	return (void *)
++		((unsigned long) __builtin_return_address(0) & 0x7fffffffUL);
++#else
++	return __builtin_return_address(0);
++#endif
++}
++
++static long static_func(long x)
+ {
++	if (x == RETURN_ADDRESS)
++		return (long)get_pc();
+ 	return x;
+ }
+ 
+-int global_func(int x)
++long global_func(long x)
+ {
++	if (x == RETURN_ADDRESS)
++		return (long)get_pc();
+ 	return x;
+ }
+ 
+@@ -59,27 +96,28 @@ static struct test_entry {
+ 	const char *name;
+ 	void *data;
+ 	int size;
+-	int writable, execable;
++	int writable;
++	int execable;
+ 	int is_huge;
+ } testtab[] = {
+-#define ENT(name, exec)	{ #name, (void *)&name, sizeof(name), 0, exec, }
++#define ENT(entry_name, exec) { \
++	.name = #entry_name, \
++	.data = (void *)&entry_name, \
++	.size = sizeof(entry_name), \
++	.writable = 0, \
++	.execable = exec }
++
+ 	ENT(small_data, 0),
+ 	ENT(big_data, 0),
+ 	ENT(small_bss, 0),
+ 	ENT(big_bss, 0),
+ 	ENT(small_const, 0),
+ 	ENT(big_const, 0),
+-
+-	/*
+-	 * XXX: Due to the way functions are defined in the powerPC 64-bit ABI,
+-	 * the following entries will point to a call stub in the data segment
+-	 * instead of to the code as one might think.  Therefore, test coverage
+-	 * is not quite as good as it could be for ppc64.
+-	 */
+ 	ENT(static_func, 1),
+ 	ENT(global_func, 1),
+ };
+ 
++
+ #define NUM_TESTS	(sizeof(testtab) / sizeof(testtab[0]))
+ 
+ static
+@@ -116,12 +154,18 @@ static void check_if_writable(struct test_entry *te)
+ {
+ 	int pid, ret, status;
+ 
+-
+ 	pid = fork();
+ 	if (pid < 0)
+ 		FAIL("fork: %s", strerror(errno));
+ 	else if (pid == 0) {
+-		(*(char *) te->data) = 0;
++		void *data;
++
++		if (te->execable)
++			data = get_text_addr(te->data);
++		else
++			data = te->data;
++
++		(*(char *)data) = 0;
+ 		exit (0);
+ 	} else {
+ 		ret = waitpid(pid, &status, 0);
+@@ -137,11 +181,15 @@ static void check_if_writable(struct test_entry *te)
+ static void do_test(struct test_entry *te)
+ {
+ 	int i;
+-	volatile int *p = te->data;
++	void *data = te->data;
+ 
+ 	check_if_writable(te);
++	verbose_printf("entry: %s, data: %p, writable: %d\n",
++		te->name, data, te->writable);
+ 
+ 	if (te->writable) {
++		volatile int *p = data;
++
+ 		for (i = 0; i < (te->size / sizeof(*p)); i++)
+ 			p[i] = CONST ^ i;
+ 
+@@ -151,17 +199,23 @@ static void do_test(struct test_entry *te)
+ 			if (p[i] != (CONST ^ i))
+ 				FAIL("mismatch on %s", te->name);
+ 	} else if (te->execable) {
+-		int (*pf)(int) = te->data;
++		long (*pf)(long) = data;
++
++		data = get_text_addr(data);
+ 
+ 		if ((*pf)(CONST) != CONST)
+ 			FAIL("%s returns incorrect results", te->name);
+ 	} else {
+ 		/* Otherwise just read touch it */
++		volatile int *p = data;
++
+ 		for (i = 0; i < (te->size / sizeof(*p)); i++)
+ 			p[i];
+ 	}
+ 
+-	te->is_huge = (test_addr_huge(te->data) == 1);
++	te->is_huge = (test_addr_huge(data) == 1);
++	verbose_printf("entry: %s, data: %p, is_huge: %d\n",
++		te->name, data, te->is_huge);
+ }
+ 
+ int main(int argc, char *argv[])
diff --git a/SPECS/libhugetlbfs.spec b/SPECS/libhugetlbfs.spec
new file mode 100644
index 0000000..3616de7
--- /dev/null
+++ b/SPECS/libhugetlbfs.spec
@@ -0,0 +1,281 @@
+Name: libhugetlbfs
+Version: 2.16
+Release: 13%{?dist}
+Summary: A library which provides easy access to huge pages of memory
+Group: System Environment/Libraries
+License: LGPLv2+
+URL: http://libhugetlbfs.sourceforge.net/
+Source0: http://downloads.sourceforge.net/libhugetlbfs/%{name}-%{version}.tar.gz
+Patch0: libhugetlbfs-2.16-s390.patch
+Patch1: libhugetlbfs-2.15-fortify.patch
+Patch2: libhugetlbfs-2.16-misalign_test.patch
+Patch3: libhugetlbfs-2.17-aarch64.patch
+Patch4: libhugetlbfs-2.16-makefile_cflags.patch
+Patch5: libhugetlbfs-2.16-makefile_segments.patch
+Patch6: libhugetlbfs-2.16-mounts_warning.patch
+Patch7: libhugetlbfs-2.16-ppc64le-support.patch
+Patch8: libhugetlbfs-2.16-plt_extrasz_fix.patch
+Patch9: libhugetlbfs-2.16-map_high_truncate.patch
+Patch10:libhugetlbfs-2.20-tests-linkhuge_rw-function-ptr-may-not-refer-to-text.patch
+Patch11:libhugetlbfs-2.20-do-not-assume-default-huge-page-size-is-first.patch
+Patch12:libhugetlbfs-2.20-defined-task-size-value-to-be-512T-if-it-is-more-than-64Tb.patch
+# downstream patches for bz#1422960
+Patch13: 0001-testutils-fix-range_is_mapped.patch
+Patch14: 0002-stack_grow_into_huge-don-t-clobber-existing-mappings.patch
+
+BuildRequires: glibc-devel
+BuildRequires: glibc-static
+
+%define ldscriptdir %{_datadir}/%{name}/ldscripts
+
+%description
+libhugetlbfs is a library which provides easy access to huge pages of memory.
+It is a wrapper for the hugetlbfs file system. Applications can use huge pages
+to fulfill malloc() requests without being recompiled by using LD_PRELOAD.
+Alternatively, applications can be linked against libhugetlbfs without source
+modifications to load BSS or BSS, data, and text segments into large pages.
+
+%package devel
+Summary:	Header files for libhugetlbfs
+Group:		Development/Libraries
+Requires:	%{name} = %{version}-%{release}
+%description devel
+Contains header files for building with libhugetlbfs.
+
+%package utils
+Summary:	Userspace utilities for configuring the hugepage environment
+Group:		Applications/System
+Requires:	%{name} = %{version}-%{release}
+%description utils
+This packages contains a number of utilities that will help administrate the
+use of huge pages on your system.  hugeedit modifies binaries to set default
+segment remapping behavior. hugectl sets environment variables for using huge
+pages and then execs the target program. hugeadm gives easy access to huge page
+pool size control. pagesize lists page sizes available on the machine.
+
+%prep
+%setup -q -n %{name}-%{version}
+%patch0 -p1 -b .s390
+%patch1 -p1 -b .fortify
+%patch2 -p1 -b .misalign_test
+%patch3 -p1 -b .aarch64
+%patch4 -p1 -b .makefile_cflags
+%patch5 -p1 -b .makefile_segments
+%patch6 -p1 -b .mounts_warning
+%patch7 -p1 -b .ppc64le_support
+%patch8 -p1 -b .plt_extrasz_fix
+%patch9 -p1 -b .map_high_truncate
+%patch10 -p1 -b .linkhuge_rw-func
+%patch11 -p1 -b .default-huge-page
+%patch12 -p1 -b .defined-task-size
+%patch13 -p1 -b .bz1422960.patch-1
+%patch14 -p1 -b .bz1422960.patch-2
+
+%build
+ln -s sys-elf64ppc.S sys-elf64lppc.S
+ln -s elf64ppc.c elf64lppc.c
+# Parallel builds are not reliable
+make BUILDTYPE=NATIVEONLY
+
+%install
+make install PREFIX=%{_prefix} DESTDIR=$RPM_BUILD_ROOT LDSCRIPTDIR=%{ldscriptdir} BUILDTYPE=NATIVEONLY
+make install-helper PREFIX=%{_prefix} DESTDIR=$RPM_BUILD_ROOT LDSCRIPTDIR=%{ldscriptdir} BUILDTYPE=NATIVEONLY
+mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d
+touch $RPM_BUILD_ROOT%{_sysconfdir}/security/limits.d/hugepages.conf
+
+# remove statically built libraries:
+rm -f $RPM_BUILD_ROOT/%{_libdir}/*.a
+# remove unused sbin directory
+rm -fr $RPM_BUILD_ROOT/%{_sbindir}/
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%{_libdir}/libhugetlbfs.so*
+%{_datadir}/%{name}/
+%{_mandir}/man7/libhugetlbfs.7.gz
+%ghost %config(noreplace) %{_sysconfdir}/security/limits.d/hugepages.conf
+%exclude %{_libdir}/libhugetlbfs_privutils.so
+%doc README HOWTO LGPL-2.1 NEWS
+
+%files devel
+%{_includedir}/hugetlbfs.h
+%{_mandir}/man3/getpagesizes.3.gz
+%{_mandir}/man3/free_huge_pages.3.gz
+%{_mandir}/man3/get_huge_pages.3.gz
+%{_mandir}/man3/gethugepagesize.3.gz
+%{_mandir}/man3/gethugepagesizes.3.gz
+%{_mandir}/man3/free_hugepage_region.3.gz
+%{_mandir}/man3/get_hugepage_region.3.gz
+%{_mandir}/man3/hugetlbfs_find_path.3.gz
+%{_mandir}/man3/hugetlbfs_find_path_for_size.3.gz
+%{_mandir}/man3/hugetlbfs_test_path.3.gz
+%{_mandir}/man3/hugetlbfs_unlinked_fd.3.gz
+%{_mandir}/man3/hugetlbfs_unlinked_fd_for_size.3.gz
+
+%files utils
+%{_bindir}/hugeedit
+%{_bindir}/hugeadm
+%{_bindir}/hugectl
+%{_bindir}/pagesize
+%{_bindir}/huge_page_setup_helper.py
+%exclude %{_bindir}/cpupcstat
+%exclude %{_bindir}/oprofile_map_events.pl
+%exclude %{_bindir}/oprofile_start.sh
+%{_mandir}/man8/hugeedit.8.gz
+%{_mandir}/man8/hugectl.8.gz
+%{_mandir}/man8/hugeadm.8.gz
+%{_mandir}/man1/pagesize.1.gz
+%{_mandir}/man1/ld.hugetlbfs.1.gz
+%exclude %{_mandir}/man8/cpupcstat.8.gz
+%exclude /usr/lib/perl5/TLBC
+
+%changelog
+* Thu Aug 02 2018 Rafael Aquini <aquini@redhat.com> - 2.16-13
+- tests/stack_grow_into libhugetlbfs test fixes (#1422960)
+- PPC vm/hugepage/libhugetlbfs test fix (#1515365)
+
+* Tue Jun 07 2016 Petr holasek <pholasek@redhat.com> - 2.16-12
+- linkhuge_rw test fix (#1240568)
+- hugeadm fix for firestone ppc systems (#1258622)
+
+* Mon Dec 15 2014 Petr Holasek <pholasek@redhat.com> - 2.16-11
+- map_high_truncate_2 test fix (#1161677)
+
+* Thu Nov 06 2014 Petr Holasek <pholasek@redhat.com> - 2.16-10
+- fix plt_extrasz() always returning 0 on ppc64le (#1160217)
+
+* Wed Aug 13 2014 Petr Holasek <pholasek@redhat.com> - 2.16-9
+- ppc64le support (#1125576)
+
+* Tue Jul 29 2014 Petr Holasek <pholasek@redhat.com> - 2.16-8
+- Fixed malloc failures in testsuite
+- Fixed warning when /etc/mtab is symlink
+
+* Mon Mar 03 2014 Petr Holasek <pholasek@redhat.com> - 2.16-7
+- Compiling with -fstack-protector-strong flag (#1070772)
+
+* Wed Feb 12 2014 Petr Holasek <pholasek@redhat.com> - 2.16-6
+- Backport patches from 2.17 for AArch64 support.
+
+* Tue Feb 11 2014 Petr Holasek <pholasek@redhat.com> - 2.16-5
+- Fix of misalign test (#1034549)
+
+* Fri Jan 24 2014 Daniel Mach <dmach@redhat.com> - 2.16-4
+- Mass rebuild 2014-01-24
+
+* Fri Dec 27 2013 Daniel Mach <dmach@redhat.com> - 2.16-3
+- Mass rebuild 2013-12-27
+
+* Sun May 12 2013 Anton Arapov <anton@redhat.com> - 2.16-2
+- Fortify code
+- Fix s390 build issues (#960107)
+
+* Mon Apr 29 2013 Peter Robinson <pbrobinson@fedoraproject.org> - 2.16-1
+- Upstream 2.16 release (adds ARM support)
+
+* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.15-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
+
+* Sat Dec 08 2012 Eric B Munson <emunson@mgebm.net> - 2.15
+- Update for upstream 2.15 release
+
+* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.13-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
+* Sat Mar 24 2012 Eric B Munson <emunson@mgebm.net>
+- Update for upstream 2.13 release
+
+* Wed Jul 20 2011 Eric B Munson <emunson@mgebm.net>
+- Update for upstream 2.12 release
+
+* Tue Feb 08 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.9-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Mon Apr 05 2010 Eric B Munson <ebmunson@us.ibm.com> 2.8-1
+- Update for upstream 2.8 release
+
+* Wed Feb 10 2010 Eric B Munson <ebmunson@us.ibm.com> 2.7-2
+- Include patch that fixes build on ppc
+
+* Tue Jan 05 2010 Eric B Munson <ebmunson@us.ibm.com> 2.7-1
+- Update for upstream 2.7 release
+
+* Fri Oct 02 2009 Jarod Wilson <jarod@redhat.com> 2.6-3
+- Add hopefully-about-to-be-merged-upstream hugeadm enhancements
+- Add huge pages setup helper script, using new hugeadm enhancements
+
+* Thu Sep 03 2009 Nils Philippsen <nils@redhat.com> 2.6-2
+- fix building on s390x
+
+* Mon Aug 31 2009 Eric Munson <ebmunson@us.ibm.com> 2.6-1
+- Updating for the libhugetlbfs-2.6 release
+
+* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 2.5-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
+
+* Mon Jul 20 2009 Eric Munson <ebmunson@us.ibm.com> 2.5-2
+- Update Group for -utils package to Applications/System
+
+* Tue Jun 30 2009 Eric Munson <ebmunson@us.ibm.com> 2.5-1
+- Updating for the libhugetlbfs-2.5 release
+
+* Tue Jun 02 2009 Eric Munson <ebmunson@us.ibm.com> 2.4-2
+- Adding patch to remove S390 32 bit build
+
+* Fri May 29 2009 Eric Munson <ebmunson@us.ibm.com> 2.4-1
+- Updating for the libhugetlbfs-2.4 release
+
+* Wed Apr 15 2009 Eric Munson <ebmunson@us.ibm.com> 2.3-1
+- Updating for the libhugetlbfs-2.3 release
+
+* Wed Feb 11 2009 Eric Munson <ebmunson@us.ibm.com> 2.2-1
+- Updating for the libhugetlbfs-2.2 release
+
+* Fri Dec 19 2008 Eric Munson <ebmunson@us.ibm.com> 2.1.2-1
+- Updating for libhugetlbfs-2.1.2 release
+
+* Fri Dec 19 2008 Eric Munson <ebmunson@us.ibm.com> 2.1.1-1
+- Updating for libhugetlbfs-2.1.1 release
+
+* Thu Dec 18 2008 Josh Boyer <jwboyer@gmail.com> 2.1-2
+- Fix broken dependency caused by just dropping -test
+  subpackage
+
+* Thu Oct 16 2008 Eric Munson <ebmunson@us.ibm.com> 2.1-1
+- Updating for libhuge-2.1 release
+- Adding -devel and -utils subpackages for various utilities
+  and devel files.
+
+* Wed May 14 2008 Eric Munson <ebmunson@us.ibm.com> 1.3-1
+- Updating for libhuge-1.3 release
+
+* Tue Mar 25 2008 Eric Munson <ebmunson@us.ibm.com> 1.2-1
+- Removing test rpm target, and excluding test files
+
+* Mon Mar 26 2007 Steve Fox <drfickle@k-lug.org> - 1.1-1
+- New release (1.1)
+- Fix directory ownership
+
+* Wed Aug 30 2006 Steve Fox <drfickle@k-lug.org> - 0.20060825-1
+- New release (1.0-preview4)
+- patch0 (Makefile-ldscript.diff) merged upstream
+
+* Tue Jul 25 2006 Steve Fox <drfickle@k-lug.org> - 0.20060706-4
+- Bump for build system
+
+* Tue Jul 25 2006 Steve Fox <drfickle@k-lug.org> - 0.20060706-3
+- Don't use parallel build as it has random failures
+
+* Thu Jul 20 2006 Steve Fox <drfickle@k-lug.org> - 0.20060706-2
+- Fix the Makefile so that the ld.hugetlbfs script doesn't store the
+  DESTDIR in the path to the ldscripts dir
+
+* Fri Jul 7 2006 Steve Fox <drfickle@k-lug.org> - 0.20060706-1
+- New release which includes a fix for the syscall macro removal in the
+  Rawhide kernels
+
+* Thu Jun 29 2006 Steve Fox <drfickle@k-lug.org> - 0.20060628-1
+- First Fedora package