From: Aneesh Kumar K.V Date: Tue, 21 Mar 2017 17:29:52 +0000 (+0530) Subject: powerpc/mm/slice: Fix off-by-1 error when computing slice mask X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=98beda74de246520653b42147443292d9814426d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git powerpc/mm/slice: Fix off-by-1 error when computing slice mask For low slice, max addr should be less than 4G. Without limiting this correctly we will end up with a low slice mask which has 17th bit set. This is not a problem with the current code because our low slice mask is of type u16. But in later patch I am switching low slice mask to u64 type and having the 17bit set result in wrong slice mask which in turn results in mmap failures. Reviewed-by: Paul Mackerras Signed-off-by: Aneesh Kumar K.V Signed-off-by: Michael Ellerman --- diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c index 2b27458902ee..bf150557dba8 100644 --- a/arch/powerpc/mm/slice.c +++ b/arch/powerpc/mm/slice.c @@ -83,11 +83,10 @@ static struct slice_mask slice_range_to_mask(unsigned long start, struct slice_mask ret = { 0, 0 }; if (start < SLICE_LOW_TOP) { - unsigned long mend = min(end, SLICE_LOW_TOP); - unsigned long mstart = min(start, SLICE_LOW_TOP); + unsigned long mend = min(end, (SLICE_LOW_TOP - 1)); ret.low_slices = (1u << (GET_LOW_SLICE_INDEX(mend) + 1)) - - (1u << GET_LOW_SLICE_INDEX(mstart)); + - (1u << GET_LOW_SLICE_INDEX(start)); } if ((start + len) > SLICE_LOW_TOP)