Author: nwhitehorn
Date: Sun Aug 29 18:17:38 2010
New Revision: 211967
URL: http://svn.freebsd.org/changeset/base/211967

Log:
  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

Modified:
  head/sys/powerpc/aim/mmu_oea64.c

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c    Sun Aug 29 16:38:08 2010        
(r211966)
+++ head/sys/powerpc/aim/mmu_oea64.c    Sun Aug 29 18:17:38 2010        
(r211967)
@@ -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
         */
        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__);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to