Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 98beda74 authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Michael Ellerman
Browse files

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: default avatarPaul Mackerras <paulus@ozlabs.org>
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent b42279f0
Loading
Loading
Loading
Loading
+2 −3
Original line number Original line Diff line number Diff line
@@ -83,11 +83,10 @@ static struct slice_mask slice_range_to_mask(unsigned long start,
	struct slice_mask ret = { 0, 0 };
	struct slice_mask ret = { 0, 0 };


	if (start < SLICE_LOW_TOP) {
	if (start < SLICE_LOW_TOP) {
		unsigned long mend = min(end, SLICE_LOW_TOP);
		unsigned long mend = min(end, (SLICE_LOW_TOP - 1));
		unsigned long mstart = min(start, SLICE_LOW_TOP);


		ret.low_slices = (1u << (GET_LOW_SLICE_INDEX(mend) + 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)
	if ((start + len) > SLICE_LOW_TOP)