vserver 2.0 rc7
[linux-2.6.git] / include / asm-i386 / msr.h
index 3589c36..c76fce8 100644 (file)
@@ -32,6 +32,21 @@ static inline void wrmsrl (unsigned long msr, unsigned long long val)
        wrmsr (msr, lo, hi);
 }
 
+/* wrmsr with exception handling */
+#define wrmsr_safe(msr,a,b) ({ int ret__;                                              \
+       asm volatile("2: wrmsr ; xorl %0,%0\n"                                          \
+                    "1:\n\t"                                                           \
+                    ".section .fixup,\"ax\"\n\t"                                       \
+                    "3:  movl %4,%0 ; jmp 1b\n\t"                                      \
+                    ".previous\n\t"                                                    \
+                    ".section __ex_table,\"a\"\n"                                      \
+                    "   .align 4\n\t"                                                  \
+                    "   .long  2b,3b\n\t"                                              \
+                    ".previous"                                                        \
+                    : "=a" (ret__)                                                     \
+                    : "c" (msr), "0" (a), "d" (b), "i" (-EFAULT));\
+       ret__; })
+
 #define rdtsc(low,high) \
      __asm__ __volatile__("rdtsc" : "=a" (low), "=d" (high))