NetBSD Problem Report #17548

Received: (qmail 3178 invoked by uid 605); 10 Jul 2002 16:38:25 -0000
Message-Id: <20020710163820.C5EBB7DA9@yeah-baby.shagadelic.org>
Date: Wed, 10 Jul 2002 09:38:20 -0700 (PDT)
From: thorpej@shagadelic.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: thorpej@shagadelic.org
To: gnats-bugs@gnats.netbsd.org
Subject: LL/SC emulation is incorrect
X-Send-Pr-Version: 3.95

>Number:         17548
>Category:       port-mips
>Synopsis:       LL/SC emulation is incorrect
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    gmcgarry
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jul 10 16:39:00 +0000 2002
>Closed-Date:    Fri May 02 06:40:51 +0000 2003
>Last-Modified:  Fri May 02 06:40:51 +0000 2003
>Originator:     Jason R Thorpe
>Release:        NetBSD 1.6D
>Organization:
Wasabi Systems, Inc.
>Environment:
>Description:

The LL/SC emulation which was recently added has a few problems that
need to be fixed:

        1. You only compile it in for MIPS1.  This is incorrect.  It
           needs to be there for MIPS2 and MIPS3, as well, since there
           are some processors with those ISAs that don't have LL/SC.

        2. The looping around emulation of the LL/SC insn (in what
           appears to be an optimization to reduce trap overhead)
           is incorrect.  See bullet #3.

        3. From inspection, this LL/SC emulation simply treats these
           instructions as normal load/store.  This is incorrect.  

           The point of LL/SC is that the SC will detect if the datum
           at the memory location has changed since the LL (at least,
           that is by far the most common usage). 

           So, what you need to do is: 
                a. In LL emulation, remember the process (lwp), address,
                   and value involved in the LL.  

                b. When you perform the SC emulation, check to make sure
                   the process and the address are the same as from the  
                   LL emulation.  If not, make the SC fail.

                   At this point, unlatch the LL emulation by clearing
                   the remembered process pointer.

                   Then fetch the value at the address, and compare it to
                   the value you remered from the LL.  If they are not
                   the same, make the SC fail.

                   Otherwise, all is clear; write the new value to the
                   memory location and indicate success.

           Note this is incompatible with emulating them in a loop.
           LL/SC can't really be used as the loop assumes anyway.

>How-To-Repeat:
	Code inspection.

>Fix:
	Not provided.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: gmcgarry 
State-Changed-When: Sat Jul 20 22:48:39 PDT 2002 
State-Changed-Why:  
Issues have been addressed. 


Responsible-Changed-From-To: port-mips-maintainer->gmcgarry 
Responsible-Changed-By: gmcgarry 
Responsible-Changed-When: Sat Jul 20 22:48:39 PDT 2002 
Responsible-Changed-Why:  
State-Changed-From-To: feedback->closed 
State-Changed-By: gmcgarry 
State-Changed-When: Fri May 2 06:39:48 UTC 2003 
State-Changed-Why:  
Changes were implemented and tested.  Finally time to close. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.