[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Implement cmpxchg_user for ia64 (hopefully correct :-)



ChangeSet 1.1713.2.9, 2005/06/17 17:11:01-06:00, djm@xxxxxxxxxxxxxxx

        Implement cmpxchg_user for ia64 (hopefully correct :-)
        
        Signed-off-by: Dan Magenheimer <dan.magenheimer@xxxxxx>



 arch/ia64/grant_table.c      |    5 +----
 include/asm-ia64/xensystem.h |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 4 deletions(-)


diff -Nru a/xen/arch/ia64/grant_table.c b/xen/arch/ia64/grant_table.c
--- a/xen/arch/ia64/grant_table.c       2005-06-23 07:03:34 -04:00
+++ b/xen/arch/ia64/grant_table.c       2005-06-23 07:03:34 -04:00
@@ -35,10 +35,7 @@
 #ifdef __ia64__
 #define __addr_ok(a) 1 // FIXME-ia64: a variant of access_ok??
 // FIXME-ia64: need to implement real cmpxchg_user on ia64
-#define cmpxchg_user(_p,_o,_n) ((*_p == _o) ? ((*_p = _n), 0) : ((_o = *_p), 
0))
-// FIXME-ia64: the following are meaningless on ia64? move to some header file
-#define put_page(x) do { } while (0)
-#define put_page_type(x) do { } while (0)
+//#define cmpxchg_user(_p,_o,_n) ((*_p == _o) ? ((*_p = _n), 0) : ((_o = *_p), 
0))
 // FIXME-ia64: these belong in an asm/grant_table.h... PAGE_SIZE different
 #undef ORDER_GRANT_FRAMES
 //#undef NUM_GRANT_FRAMES
diff -Nru a/xen/include/asm-ia64/xensystem.h b/xen/include/asm-ia64/xensystem.h
--- a/xen/include/asm-ia64/xensystem.h  2005-06-23 07:03:34 -04:00
+++ b/xen/include/asm-ia64/xensystem.h  2005-06-23 07:03:34 -04:00
@@ -61,5 +61,37 @@
 } while (0)
 #endif // CONFIG_VTI
 
+#define __cmpxchg_user(ptr, new, old, _size)                           \
+({                                                                     \
+       register long __gu_r8 asm ("r8");                               \
+       register long __gu_r9 asm ("r9");                               \
+       asm volatile ("mov ar.ccv=%0;;" :: "rO"(old));                  \
+       asm volatile ("mov %2=r0;;\n"                                   \
+               "[1:]\tcmpxchg"_size".acq %0=[%3],%4,ar.ccv\n"          \
+               "\t.xdata4 \"__ex_table\", 1b-., 1f.+4\n"               \
+               "[1:]"                                                  \
+               : "=r"(old), "=r"(__gu_r9), "=r"(__gu_r8) :             \
+               "r"(ptr), "r"(new) : "memory");                         \
+       (old) = __gu_r9;                                                \
+       __gu_r8;                                                        \
+})
+
+
+// NOTE: Xen defines args as pointer,old,new whereas ia64 uses pointer,new,old
+//  so reverse them here
+#define cmpxchg_user(_p,_o,_n)                                 \
+({                                                             \
+       register long _rc;                                      \
+       ia64_mf();                                              \
+       switch ( sizeof(*(_p)) ) {                              \
+           case 1: _rc = __cmpxchg_user(_p,_n,_o,"1"); break;  \
+           case 2: _rc = __cmpxchg_user(_p,_n,_o,"2"); break;  \
+           case 4: _rc = __cmpxchg_user(_p,_n,_o,"4"); break;  \
+           case 8: _rc = __cmpxchg_user(_p,_n,_o,"8"); break;  \
+       }                                                       \
+       ia64_mf();                                              \
+       _rc;                                                    \
+})
+
 #endif // __ASSEMBLY__
 #endif // _ASM_IA64_XENSYSTEM_H

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.