]> err.no Git - linux-2.6/blobdiff - include/asm-x86_64/system.h
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland...
[linux-2.6] / include / asm-x86_64 / system.h
index bd376bc8c4ab26b5702bf667ad84f18f38fb5184..02175aa1d16a8aea903a51e6b5e1c71fda57d075 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <linux/kernel.h>
 #include <asm/segment.h>
-#include <asm/alternative.h>
+#include <asm/cmpxchg.h>
 
 #ifdef __KERNEL__
 
@@ -39,7 +39,7 @@
                       [threadrsp] "i" (offsetof(struct task_struct, thread.rsp)), \
                       [ti_flags] "i" (offsetof(struct thread_info, flags)),\
                       [tif_fork] "i" (TIF_FORK),                         \
-                      [thread_info] "i" (offsetof(struct task_struct, thread_info)), \
+                      [thread_info] "i" (offsetof(struct task_struct, stack)), \
                       [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent))   \
                     : "memory", "cc" __EXTRA_CLOBBER)
     
@@ -75,143 +75,69 @@ static inline unsigned long read_cr0(void)
        unsigned long cr0;
        asm volatile("movq %%cr0,%0" : "=r" (cr0));
        return cr0;
-} 
+}
 
 static inline void write_cr0(unsigned long val) 
 { 
        asm volatile("movq %0,%%cr0" :: "r" (val));
-} 
+}
+
+static inline unsigned long read_cr2(void)
+{
+       unsigned long cr2;
+       asm("movq %%cr2,%0" : "=r" (cr2));
+       return cr2;
+}
+
+static inline void write_cr2(unsigned long val)
+{
+       asm volatile("movq %0,%%cr2" :: "r" (val));
+}
 
 static inline unsigned long read_cr3(void)
 { 
        unsigned long cr3;
        asm("movq %%cr3,%0" : "=r" (cr3));
        return cr3;
-} 
+}
+
+static inline void write_cr3(unsigned long val)
+{
+       asm volatile("movq %0,%%cr3" :: "r" (val) : "memory");
+}
 
 static inline unsigned long read_cr4(void)
 { 
        unsigned long cr4;
        asm("movq %%cr4,%0" : "=r" (cr4));
        return cr4;
-} 
+}
 
 static inline void write_cr4(unsigned long val)
 { 
-       asm volatile("movq %0,%%cr4" :: "r" (val));
-} 
-
-#define stts() write_cr0(8 | read_cr0())
-
-#define wbinvd() \
-       __asm__ __volatile__ ("wbinvd": : :"memory");
-
-/*
- * On SMP systems, when the scheduler does migration-cost autodetection,
- * it needs a way to flush as much of the CPU's caches as possible.
- */
-static inline void sched_cacheflush(void)
-{
-       wbinvd();
+       asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
 }
 
-#endif /* __KERNEL__ */
-
-#define nop() __asm__ __volatile__ ("nop")
-
-#define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr))))
-
-#define tas(ptr) (xchg((ptr),1))
-
-#define __xg(x) ((volatile long *)(x))
-
-static inline void set_64bit(volatile unsigned long *ptr, unsigned long val)
+static inline unsigned long read_cr8(void)
 {
-       *ptr = val;
+       unsigned long cr8;
+       asm("movq %%cr8,%0" : "=r" (cr8));
+       return cr8;
 }
 
-#define _set_64bit set_64bit
-
-/*
- * Note: no "lock" prefix even on SMP: xchg always implies lock anyway
- * Note 2: xchg has side effect, so that attribute volatile is necessary,
- *       but generally the primitive is invalid, *ptr is output argument. --ANK
- */
-static inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size)
+static inline void write_cr8(unsigned long val)
 {
-       switch (size) {
-               case 1:
-                       __asm__ __volatile__("xchgb %b0,%1"
-                               :"=q" (x)
-                               :"m" (*__xg(ptr)), "0" (x)
-                               :"memory");
-                       break;
-               case 2:
-                       __asm__ __volatile__("xchgw %w0,%1"
-                               :"=r" (x)
-                               :"m" (*__xg(ptr)), "0" (x)
-                               :"memory");
-                       break;
-               case 4:
-                       __asm__ __volatile__("xchgl %k0,%1"
-                               :"=r" (x)
-                               :"m" (*__xg(ptr)), "0" (x)
-                               :"memory");
-                       break;
-               case 8:
-                       __asm__ __volatile__("xchgq %0,%1"
-                               :"=r" (x)
-                               :"m" (*__xg(ptr)), "0" (x)
-                               :"memory");
-                       break;
-       }
-       return x;
+       asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
 }
 
-/*
- * Atomic compare and exchange.  Compare OLD with MEM, if identical,
- * store NEW in MEM.  Return the initial value in MEM.  Success is
- * indicated by comparing RETURN with OLD.
- */
+#define stts() write_cr0(8 | read_cr0())
 
-#define __HAVE_ARCH_CMPXCHG 1
+#define wbinvd() \
+       __asm__ __volatile__ ("wbinvd": : :"memory")
 
-static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
-                                     unsigned long new, int size)
-{
-       unsigned long prev;
-       switch (size) {
-       case 1:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
-                                    : "=a"(prev)
-                                    : "q"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 2:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
-                                    : "=a"(prev)
-                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 4:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2"
-                                    : "=a"(prev)
-                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       case 8:
-               __asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2"
-                                    : "=a"(prev)
-                                    : "r"(new), "m"(*__xg(ptr)), "0"(old)
-                                    : "memory");
-               return prev;
-       }
-       return old;
-}
+#endif /* __KERNEL__ */
 
-#define cmpxchg(ptr,o,n)\
-       ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
-                                       (unsigned long)(n),sizeof(*(ptr))))
+#define nop() __asm__ __volatile__ ("nop")
 
 #ifdef CONFIG_SMP
 #define smp_mb()       mb()