powerpc/64s/hash: Fix 512T hint detection to use >= 128T
authorMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Nov 2017 12:17:28 +0000 (23:17 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 13 Nov 2017 12:34:06 +0000 (23:34 +1100)
Currently userspace is able to request mmap() search between 128T-512T
by specifying a hint address that is greater than 128T. But that means
a hint of 128T exactly will return an address below 128T, which is
confusing and wrong.

So fix the logic to check the hint is greater than *or equal* to 128T.

Fixes: f4ea6dcb08ea ("powerpc/mm: Enable mappings above 128TB")
Cc: stable@vger.kernel.org # v4.12+
Suggested-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Suggested-by: Nicholas Piggin <npiggin@gmail.com>
[mpe: Split out of Nick's bigger patch]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/mm/slice.c

index 45f6740dd407dae752c25a19ad2ae4a804a19858..48a5312103a1f27af8f304df532629bb26a3f164 100644 (file)
@@ -419,7 +419,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
        /*
         * Check if we need to expland slice area.
         */
-       if (unlikely(addr > mm->context.addr_limit &&
+       if (unlikely(addr >= mm->context.addr_limit &&
                     mm->context.addr_limit != TASK_SIZE)) {
                mm->context.addr_limit = TASK_SIZE;
                on_each_cpu(slice_flush_segments, mm, 1);
@@ -427,7 +427,7 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
        /*
         * This mmap request can allocate upt to 512TB
         */
-       if (addr > DEFAULT_MAP_WINDOW)
+       if (addr >= DEFAULT_MAP_WINDOW)
                high_limit = mm->context.addr_limit;
        else
                high_limit = DEFAULT_MAP_WINDOW;