From nobody@FreeBSD.org  Sat Jan 24 15:38:49 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id B128716A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 24 Jan 2004 15:38:49 -0800 (PST)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 0080C43D48
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 24 Jan 2004 15:38:49 -0800 (PST)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.10/8.12.10) with ESMTP id i0ONcmdL079115
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 24 Jan 2004 15:38:48 -0800 (PST)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.10/8.12.10/Submit) id i0ONcmfu079114;
	Sat, 24 Jan 2004 15:38:48 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200401242338.i0ONcmfu079114@www.freebsd.org>
Date: Sat, 24 Jan 2004 15:38:48 -0800 (PST)
From: Stephan Uphoff <ups@tree.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: i386 pmap SMP race condition can cause lost page modification.
X-Send-Pr-Version: www-2.0

>Number:         61852
>Category:       i386
>Synopsis:       i386 pmap SMP race condition can cause lost page modification.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    alc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jan 24 15:40:08 PST 2004
>Closed-Date:    Fri Nov 16 22:21:20 UTC 2007
>Last-Modified:  Fri Nov 16 22:21:20 UTC 2007
>Originator:     Stephan Uphoff
>Release:        current
>Organization:
>Environment:
N/A 
>Description:
The current i386 pmap does not always atomically change ptes.
( Only clearing a pte is currently atomic)
This causes a window where setting of PG_A or PG_M of the pte
caused by page access of a second CPU can be ignored or overwritten 
and lost.

Lost PG_M bits can cause data loss. 
(Page not written to backing storage)


>How-To-Repeat:
      
>Fix:
Import the pte update logic from the newest NetBSD pmap.
The NetBSD pmap also tries to avoid unnecessary TLB shootdowns.

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-i386->alc 
Responsible-Changed-By: phk 
Responsible-Changed-When: Wed Jun 16 08:20:32 GMT 2004 
Responsible-Changed-Why:  
This sounds like Allans department 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61852 

From: "Alan L. Cox" <alc@imimic.com>
To: freebsd-gnats-submit@FreeBSD.org, ups@tree.com
Cc:  
Subject: Re: i386/61852: i386 pmap SMP race condition can cause lost page
 modification.
Date: Wed, 08 Sep 2004 14:10:30 -0500

 Most of the cases have been dealt with in HEAD and RELENG_5.  The most 
 recent being today:
 
 alc         2004-09-08 18:58:29 UTC
 
    FreeBSD src repository
 
    Modified files:
      sys/amd64/amd64      pmap.c
      sys/i386/i386        pmap.c
    Log:
    Use atomic ops in pmap_clear_ptes() to prevent SMP races that could
    result in the loss of an accessed or modified bit from the pte.
 
    In collaboration with: tegge@
 
    MT5 candidate
 
    Revision  Changes    Path
    1.497     +7 -4      src/sys/amd64/amd64/pmap.c
    1.501     +13 -3     src/sys/i386/i386/pmap.c
 
 There are, however, two cases remaining:
 
 pmap_protect: No locked read-modify-write instruction to clear PG_RW.
 Another CPU might perform a write to a page, setting the modified bit
 after "pbits = *pte", but before "pte_store(pte, pbits)" has
 completed.  The modified bit will be lost.
 
 pmap_enter: Similar when tightening permission.

From: "Alan L. Cox" <alc@imimic.com>
To: freebsd-gnats-submit@FreeBSD.org, ups@tree.com
Cc:  
Subject: Re: i386/61852: i386 pmap SMP race condition can cause lost page
 modification.
Date: Sun, 10 Oct 2004 14:33:02 -0500

 Corrections to pmap_enter() and pmap_protect() have been committed to 
 HEAD and RELENG_5.
 
 RELENG_4 has similar problems.  No patches addressing this problem have 
 been committed there.
State-Changed-From-To: open->patched 
State-Changed-By: alc 
State-Changed-When: Sun Oct 10 20:49:21 GMT 2004 
State-Changed-Why:  
Corrective patches have been applied to HEAD and RELENG_5.  I am not 
closing this PR as a reminder that RELENG_4 has not been patched.  At 
present, I have no plans to port these patches to RELENG_4.  I leave 
that to others. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61852 

From: Gavin Atkinson <gavin.atkinson@ury.york.ac.uk>
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: i386/61852: i386 pmap SMP race condition can cause lost page
	modification.
Date: Mon, 14 May 2007 18:14:03 +0100

 ups@ is planning to MFC this to RELENG_4 soon.
State-Changed-From-To: patched->closed 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 22:21:04 UTC 2007 
State-Changed-Why:  

RELENG_4 is EOL. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=61852 
>Unformatted:
