From 7eeda62ca92329b3b4eaedad61e03c782bc5e38a Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sun, 29 Aug 2010 18:17:38 +0000 Subject: [PATCH] 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 --- sys/powerpc/aim/mmu_oea64.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c index 962e8ec528b..c1c2651c5c0 100644 --- a/sys/powerpc/aim/mmu_oea64.c +++ b/sys/powerpc/aim/mmu_oea64.c @@ -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__); }