[ros-bugs] [Bug 6223] New: i386 ExInterlockedAddLargeStatistic broken

ReactOS.Bugzilla at reactos.org ReactOS.Bugzilla at reactos.org
Fri May 6 09:46:12 UTC 2011


http://www.reactos.org/bugzilla/show_bug.cgi?id=6223

           Summary: i386 ExInterlockedAddLargeStatistic broken
           Product: ReactOS
           Version: TRUNK
          Platform: x86 Hardware
        OS/Version: ReactOS
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: Kernel
        AssignedTo: ros-bugs at reactos.org
        ReportedBy: bonzini at gnu.org
         QAContact: ros-bugs at reactos.org


The function is not atomic; concurrent writers are correct, but the reads may
be incorrect if they happen between the add and adc.

A correct implementation would be like this (untested):

   push ebp
   mov  ebp, ecx

Again:
   mov  eax, [ebp]       ;; Load comparand in eax for cmpxchg
   mov  ebx, edx         ;; Compute low word of the result in ebx
   add  ebx, eax
   jc   Slow             ;; Carry needs cmpxchg8b

   ;; Fast path still needs to be atomic, so use cmpxchg and retry if it fails
   ;; Hopefully it will still get through this path :)
   lock cmpxchg [ecx], ebx
   jnz  Again
   pop  ebp
   ret
Slow:
   push edx              ;; save increment across cmpxchg8b
   mov  edx, [ebp+4]     ;; finish loading comparand in edx:eax
   lea  ecx, [edx+1]     ;; result in ecx:ebx (we know there's carry)
   lock cmpxchg8b [ebp]
   pop  edx
   jnz  Again
   pop  ebp
   ret


-- 
Configure bugmail: http://www.reactos.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.



More information about the Ros-bugs mailing list