Author: nwhitehorn
Date: Wed Sep  8 16:58:06 2010
New Revision: 212322
URL: http://svn.freebsd.org/changeset/base/212322

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

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

Modified: head/sys/powerpc/aim/mmu_oea.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea.c      Wed Sep  8 16:34:08 2010        
(r212321)
+++ head/sys/powerpc/aim/mmu_oea.c      Wed Sep  8 16:58:06 2010        
(r212322)
@@ -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;

Modified: head/sys/powerpc/aim/mmu_oea64.c
==============================================================================
--- head/sys/powerpc/aim/mmu_oea64.c    Wed Sep  8 16:34:08 2010        
(r212321)
+++ head/sys/powerpc/aim/mmu_oea64.c    Wed Sep  8 16:58:06 2010        
(r212322)
@@ -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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to