WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] Need cmpxchg_user for ia64

To: <xen-ia64-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-ia64-devel] Need cmpxchg_user for ia64
From: "Magenheimer, Dan (HP Labs Fort Collins)" <dan.magenheimer@xxxxxx>
Date: Fri, 10 Jun 2005 11:11:41 -0700
Delivery-date: Fri, 10 Jun 2005 18:11:36 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: DIscussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
Thread-index: AcVt59oEzQD7TBMATL2E2XUOUsr19w==
Thread-topic: Need cmpxchg_user for ia64
Anybody want to write a fancy macro?  I need a cmpxchg_user() macro
that corresponds to the following x86 code used in grant_table.c
and defined in include/asm-x86/system.h, but (of course) works
for ia64.  It must also conform to the ia64 __ex_table convention.

Please include a Signed-off-by as this will be new code for Xen.

Thanks!
Dan

/*
 * This function causes value _o to be changed to _n at location _p.
 * If this access causes a fault then we return 1, otherwise we return
0.
 * If no fault occurs then _o is updated to the value we saw at _p. If
this
 * is the same as the initial value of _o then _n is written to location
_p.
 */
#define __cmpxchg_user(_p,_o,_n,_isuff,_oppre,_regtype)
\
    __asm__ __volatile__ (
\
        "1: " LOCK_PREFIX "cmpxchg"_isuff" %"_oppre"2,%3\n"
\
        "2:\n"
\
        ".section .fixup,\"ax\"\n"
\
        "3:     movl $1,%1\n"
\
        "       jmp 2b\n"
\
        ".previous\n"
\
        ".section __ex_table,\"a\"\n"
\
        "       .align 4\n"
\
        "       .long 1b,3b\n"
\
        ".previous"
\
        : "=a" (_o), "=r" (_rc)
\
        : _regtype (_n), "m" (*__xg((volatile void *)_p)), "0" (_o), "1"
(0) \
        : "memory");
#define cmpxchg_user(_p,_o,_n)
\
({
\
    int _rc;
\
    switch ( sizeof(*(_p)) ) {
\
    case 1:
\
        __cmpxchg_user(_p,_o,_n,"b","b","q");
\
        break;
\
    case 2:
\
        __cmpxchg_user(_p,_o,_n,"w","w","r");
\
        break;
\
    case 4:
\
        __cmpxchg_user(_p,_o,_n,"l","","r");
\
        break;
\
    case 8:
\
        __asm__ __volatile__ (
\
            "1: " LOCK_PREFIX "cmpxchg8b %4\n"
\
            "2:\n"
\
            ".section .fixup,\"ax\"\n"
\
            "3:     movl $1,%1\n"
\
            "       jmp 2b\n"
\
            ".previous\n"
\
            ".section __ex_table,\"a\"\n"
\
            "       .align 4\n"
\
            "       .long 1b,3b\n"
\
            ".previous"
\
            : "=A" (_o), "=r" (_rc)
\
            : "c" ((u32)((u64)(_n)>>32)), "b" ((u32)(_n)),
\
              "m" (*__xg((volatile void *)(_p))), "0" (_o), "1" (0)
\
            : "memory");
\
        break;
\
    }
\
    _rc;
\
})

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] Need cmpxchg_user for ia64, Magenheimer, Dan (HP Labs Fort Collins) <=