Avoid a race in the allocation of new segment IDs that could result in

memory corruption on heavily loaded SMP systems.

MFC after:	2 weeks
This commit is contained in:
Nathan Whitehorn 2010-08-29 18:17:38 +00:00
parent da881cad07
commit 7eeda62ca9
1 changed files with 5 additions and 0 deletions

View File

@ -285,6 +285,7 @@ extern void bs_remap_earlyboot(void);
* Lock for the pteg and pvo tables.
*/
struct mtx moea64_table_mutex;
struct mtx moea64_slb_mutex;
/*
* PTEG data.
@ -1068,6 +1069,7 @@ moea64_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
*/
mtx_init(&moea64_table_mutex, "pmap table", NULL, MTX_DEF |
MTX_RECURSE);
mtx_init(&moea64_slb_mutex, "SLB table", NULL, MTX_DEF);
/*
* Initialize the TLBIE lock. TLBIE can only be executed by one CPU.
@ -2054,6 +2056,7 @@ moea64_get_unique_vsid(void) {
entropy = 0;
__asm __volatile("mftb %0" : "=r"(entropy));
mtx_lock(&moea64_slb_mutex);
for (i = 0; i < NVSIDS; i += VSID_NBPW) {
u_int n;
@ -2083,9 +2086,11 @@ moea64_get_unique_vsid(void) {
hash |= i;
}
moea64_vsid_bitmap[n] |= mask;
mtx_unlock(&moea64_slb_mutex);
return (hash);
}
mtx_unlock(&moea64_slb_mutex);
panic("%s: out of segments",__func__);
}