From 39b93626e1e9bc988cfe8366ed16d52e3789c3a1 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 30 2018 05:08:35 +0000 Subject: import libhugetlbfs-2.16-13.el7 --- 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 +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 +--- + 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: +In-Reply-To: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com> +References: <192ac21a3c057c5dedca4cdd1bf700f38992030c.1496667760.git.jstancek@redhat.com> +From: Jan Stancek +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 +--- + 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 + #include + #include ++#include + + #include + #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.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 +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 + Signed-off-by: Eric B Munson + +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/SPECS/libhugetlbfs.spec b/SPECS/libhugetlbfs.spec index c548021..3616de7 100644 --- a/SPECS/libhugetlbfs.spec +++ b/SPECS/libhugetlbfs.spec @@ -1,6 +1,6 @@ Name: libhugetlbfs Version: 2.16 -Release: 12%{?dist} +Release: 13%{?dist} Summary: A library which provides easy access to huge pages of memory Group: System Environment/Libraries License: LGPLv2+ @@ -18,6 +18,10 @@ 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 @@ -63,6 +67,9 @@ pool size control. pagesize lists page sizes available on the machine. %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 @@ -126,6 +133,10 @@ rm -fr $RPM_BUILD_ROOT/%{_sbindir}/ %exclude /usr/lib/perl5/TLBC %changelog +* Thu Aug 02 2018 Rafael Aquini - 2.16-13 +- tests/stack_grow_into libhugetlbfs test fixes (#1422960) +- PPC vm/hugepage/libhugetlbfs test fix (#1515365) + * Tue Jun 07 2016 Petr holasek - 2.16-12 - linkhuge_rw test fix (#1240568) - hugeadm fix for firestone ppc systems (#1258622)