From owner-svn-src-head@FreeBSD.ORG Sat Apr 4 22:23:03 2009 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 D5553106566C; Sat, 4 Apr 2009 22:23:03 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C2F378FC14; Sat, 4 Apr 2009 22:23:03 +0000 (UTC) (envelope-from marcel@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n34MN33o082678; Sat, 4 Apr 2009 22:23:03 GMT (envelope-from marcel@svn.freebsd.org) Received: (from marcel@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n34MN3RG082677; Sat, 4 Apr 2009 22:23:03 GMT (envelope-from marcel@svn.freebsd.org) Message-Id: <200904042223.n34MN3RG082677@svn.freebsd.org> From: Marcel Moolenaar Date: Sat, 4 Apr 2009 22:23:03 +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: r190704 - 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: Sat, 04 Apr 2009 22:23:04 -0000 Author: marcel Date: Sat Apr 4 22:23:03 2009 New Revision: 190704 URL: http://svn.freebsd.org/changeset/base/190704 Log: Perform a dummy stwcx. when we switch contexts. The context being switched out may hold a reservation. The stwcx. will clear the reservation. This is architecturally recommended. The scenario this addresses is as follows: 1. Thread 1 performs a lwarx and as such holds a reservation. 2. Thread 1 gets switched out (before doing the matching stwcx.) and thread 2 is switched in. 3. Thread 2 performs a stwcx. to the same reservation granule. This will succeed because the processor has the reservation even though thread 2 didn't do the lwarx. Note that on some processors the address given the stwcx. is not checked. On these processors the mere condition of having a reservation would cause the stwcx. to succeed, irrespective of whether the addresses are the same. The dummy stwcx. is especially important for those processors. Modified: head/sys/powerpc/aim/swtch.S Modified: head/sys/powerpc/aim/swtch.S ============================================================================== --- head/sys/powerpc/aim/swtch.S Sat Apr 4 22:05:36 2009 (r190703) +++ head/sys/powerpc/aim/swtch.S Sat Apr 4 22:23:03 2009 (r190704) @@ -155,6 +155,12 @@ cpu_switchin: mtsr USER_SR,%r5 isync lwz %r1,PCB_SP(%r3) /* Load the stack pointer */ + /* + * Perform a dummy stwcx. to clear any reservations we may have + * inherited from the previous thread. It doesn't matter if the + * stwcx succeeds or not. pcb_context[0] can be clobbered. + */ + stwcx. %r1, 0, %r3 blr /*