Fix a typo in the original import of this code from NetBSD that caused the

wrong element of the VSID bitmap array to be examined after a collision,
leading to reallocation of in-use VSIDs under some circumstances, with
attendant memory corruption. Also add an assert to check for this kind of
problem in the future.

MFC after:	4 days
This commit is contained in:
Nathan Whitehorn 2010-09-08 16:58:06 +00:00
parent 670a090971
commit 0dfddf6e65
2 changed files with 4 additions and 2 deletions

View File

@ -1618,7 +1618,7 @@ moea_pinit(mmu_t mmu, pmap_t pmap)
entropy = (moea_vsidcontext >> 20);
continue;
}
i = ffs(~moea_vsid_bitmap[i]) - 1;
i = ffs(~moea_vsid_bitmap[n]) - 1;
mask = 1 << i;
hash &= 0xfffff & ~(VSID_NBPW - 1);
hash |= i;

View File

@ -2080,11 +2080,13 @@ moea64_get_unique_vsid(void) {
entropy = (moea64_vsidcontext >> 20);
continue;
}
i = ffs(~moea64_vsid_bitmap[i]) - 1;
i = ffs(~moea64_vsid_bitmap[n]) - 1;
mask = 1 << i;
hash &= VSID_HASHMASK & ~(VSID_NBPW - 1);
hash |= i;
}
KASSERT(!(moea64_vsid_bitmap[n] & mask),
("Allocating in-use VSID %#x\n", hash));
moea64_vsid_bitmap[n] |= mask;
mtx_unlock(&moea64_slb_mutex);
return (hash);