Strictly speaking, this patch is needed only for arches which use
discontiguous virtual address bits for the PGD index.
When we originally worked on this code (~ 2 years ago or so, in
response to a bug report & patch from an Intel guy), I had myself
convinced that the code is correct, but of course I missed the fact
that:
pgd_index(first) < pgd_index(last)
does NOT imply that:
first < last
For example, with a 16KB page size on ia64, we might end up with:
first =
6000100f80003fff => first_idx = 0x300
last =
60000fffffff8000 => last_idx = 0x3ff
Note here that first_idx < last_idx even though first > last. This is
because pgd_index() ignores bits 44..60.
I suppose we could put the extra check inside #ifdef __ia64__, but
that would be rather ugly and would really mean that Linux does not
support discontiguous PGD indices.
break;
}
no_mmaps:
+ if (last < first) /* needed for arches with discontiguous pgd indices */
+ return;
/*
* If the PGD bits are not consecutive in the virtual address, the
* old method of shifting the VA >> by PGDIR_SHIFT doesn't work.