From owner-p4-projects@FreeBSD.ORG Sun May 6 12:28:28 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 11C1A16A402; Sun, 6 May 2007 12:28:28 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A02B116A409 for ; Sun, 6 May 2007 12:28:27 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 905BB13C4AE for ; Sun, 6 May 2007 12:28:27 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l46CSRUE090746 for ; Sun, 6 May 2007 12:28:27 GMT (envelope-from rdivacky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l46CSRlt090743 for perforce@freebsd.org; Sun, 6 May 2007 12:28:27 GMT (envelope-from rdivacky@FreeBSD.org) Date: Sun, 6 May 2007 12:28:27 GMT Message-Id: <200705061228.l46CSRlt090743@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rdivacky@FreeBSD.org using -f From: Roman Divacky To: Perforce Change Reviews Cc: Subject: PERFORCE change 119326 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 May 2007 12:28:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=119326 Change 119326 by rdivacky@rdivacky_witten on 2007/05/06 12:28:12 Raceless linux_support.s for i386. This should be a final version. Submitted by: kib Affected files ... .. //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_support.s#3 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_futex/sys/i386/linux/linux_support.s#3 (text+ko) ==== @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1993 The Regents of the University of California. + * Copyright (c) 2006,2007 The FreeBSD Project * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,8 +29,8 @@ * $FreeBSD$ */ -#include "linux_assym.h" /* system definitions */ -#include /* miscellaneous asm macros */ +#include "linux_assym.h" /* system definitions */ +#include /* miscellaneous asm macros */ #include "assym.s" @@ -38,110 +38,94 @@ /* linux_futex support */ /*****************************************************************************/ -/* we return -EFAULT in a case of a fault */ +futex_fault_decx: + movl PCPU(CURPCB),%ecx futex_fault: movl $0,PCB_ONFAULT(%ecx) movl $-EFAULT,%eax ret ENTRY(futex_xchgl) - /* set fault address */ movl PCPU(CURPCB),%ecx movl $futex_fault,PCB_ONFAULT(%ecx) - movl 12(%esp),%ebx + movl 4(%esp),%eax + movl 8(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx ja futex_fault - movl 8(%esp),%edx - /* - * use now free eax and do: - * *oldval = *uaddr - */ - movl (%edx),%eax - movl %eax,(%ebx) - movl 4(%esp),%eax - - /* perform the operation */ -#ifdef SMP - lock -#endif xchgl %eax,(%edx) - /* and return 0 */ + movl 12(%esp),%edx + movl %eax,(%edx) xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) + movl %eax,PCB_ONFAULT(%ecx) ret ENTRY(futex_addl) movl PCPU(CURPCB),%ecx movl $futex_fault,PCB_ONFAULT(%ecx) + movl 4(%esp),%eax movl 8(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx ja futex_fault - movl 12(%esp),%ebx - movl (%edx),%eax - movl %eax,(%ebx) - movl 4(%esp),%eax - #ifdef SMP lock #endif xaddl %eax,(%edx) + movl 12(%esp),%edx + movl %eax,(%edx) xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) + movl %eax,PCB_ONFAULT(%ecx) ret ENTRY(futex_orl) movl PCPU(CURPCB),%ecx - movl $futex_fault,PCB_ONFAULT(%ecx) + movl $futex_fault_decx,PCB_ONFAULT(%ecx) movl 8(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx ja futex_fault - movl 12(%esp),%ebx movl (%edx),%eax - movl %eax,(%ebx) - movl 4(%esp),%eax - +1: movl %eax,%ecx + orl 4(%esp),%ecx #ifdef SMP lock #endif - orl %eax,(%edx) + cmpxchgl %ecx,(%edx) + jnz 1b +futex_tail: + movl 12(%esp),%edx + movl %eax,(%edx) xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) + movl PCPU(CURPCB),%ecx + movl %eax,PCB_ONFAULT(%ecx) ret ENTRY(futex_andl) movl PCPU(CURPCB),%ecx - movl $futex_fault,PCB_ONFAULT(%ecx) + movl $futex_fault_decx,PCB_ONFAULT(%ecx) movl 8(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx ja futex_fault - movl 12(%esp),%ebx movl (%edx),%eax - movl %eax,(%ebx) - movl 4(%esp),%eax - +1: movl %eax,%ecx + andl 4(%esp),%ecx #ifdef SMP lock #endif - andl %eax,(%edx) - xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) - ret + cmpxchgl %ecx,(%edx) + jnz 1b + jmp futex_tail ENTRY(futex_xorl) movl PCPU(CURPCB),%ecx - movl $futex_fault,PCB_ONFAULT(%ecx) + movl $futex_fault_decx,PCB_ONFAULT(%ecx) movl 8(%esp),%edx cmpl $VM_MAXUSER_ADDRESS-4,%edx ja futex_fault - movl 12(%esp),%ebx movl (%edx),%eax - movl %eax,(%ebx) - movl 4(%esp),%eax - +1: movl %eax,%ecx + xorl 4(%esp),%ecx #ifdef SMP lock #endif - xorl %eax,(%edx) - xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) - ret + cmpxchgl %ecx,(%edx) + jnz 1b + jmp futex_tail