From owner-svn-src-head@FreeBSD.ORG Sun Aug 29 18:17:38 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C4D510656B8; Sun, 29 Aug 2010 18:17:38 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5C2E78FC15; Sun, 29 Aug 2010 18:17:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o7TIHccl070981; Sun, 29 Aug 2010 18:17:38 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7TIHcT5070979; Sun, 29 Aug 2010 18:17:38 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201008291817.o7TIHcT5070979@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 29 Aug 2010 18:17:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211967 - head/sys/powerpc/aim X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 29 Aug 2010 18:17:38 -0000 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__); }