summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2010-09-08 16:58:06 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2010-09-08 16:58:06 +0000
commite956a1ec841f76873b0d4264392a95705f127888 (patch)
treeac9b8b05887a21f7aa457d0b32daed65ec480afc /sys/powerpc
parent26d5f66d9476f898f33a6e749020ccc9f24e12bc (diff)
downloadFreeBSD-src-e956a1ec841f76873b0d4264392a95705f127888.zip
FreeBSD-src-e956a1ec841f76873b0d4264392a95705f127888.tar.gz
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
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/aim/mmu_oea.c2
-rw-r--r--sys/powerpc/aim/mmu_oea64.c4
2 files changed, 4 insertions, 2 deletions
diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c
index d3a2459..2ade00f 100644
--- a/sys/powerpc/aim/mmu_oea.c
+++ b/sys/powerpc/aim/mmu_oea.c
@@ -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;
diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index c1b6f2c..8cf8349 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -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);
OpenPOWER on IntegriCloud