]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] nasty bug in free_pgtables() (for ia64)
authorDavid Mosberger <davidm@napali.hpl.hp.com>
Thu, 20 Jun 2002 05:24:19 +0000 (22:24 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 20 Jun 2002 05:24:19 +0000 (22:24 -0700)
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.

mm/mmap.c

index 4c884e4bcb6fcd58973ccc89e658455a2bfc5095..c05c85452e76a680cd6ad2fca788304e2b6af67e 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -781,6 +781,8 @@ static void free_pgtables(mmu_gather_t *tlb, struct vm_area_struct *prev,
                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.