fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / include / asm-x86_64 / mach-xen / asm / system.h
index 7d8b882..3fdf16b 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <linux/kernel.h>
 #include <asm/segment.h>
+#include <asm/alternative.h>
 #include <asm/synch_bitops.h>
 #include <asm/hypervisor.h>
 #include <xen/interface/arch-x86_64.h>
 #define __RESTORE(reg,offset) "movq (14-" #offset ")*8(%%rsp),%%" #reg "\n\t"
 
 /* frame pointer must be last for get_wchan */
-#define SAVE_CONTEXT    "pushq %%rbp ; movq %%rsi,%%rbp\n\t"
-#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp\n\t"
+#define SAVE_CONTEXT    "pushf ; pushq %%rbp ; movq %%rsi,%%rbp\n\t"
+#define RESTORE_CONTEXT "movq %%rbp,%%rsi ; popq %%rbp ; popf\t"
 
 #define __EXTRA_CLOBBER  \
        ,"rcx","rbx","rdx","r8","r9","r10","r11","r12","r13","r14","r15"
 
+/* Save restore flags to clear handle leaking NT */
 #define switch_to(prev,next,last) \
        asm volatile(SAVE_CONTEXT                                                   \
                     "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */       \
@@ -50,8 +52,7 @@
                       [pda_pcurrent] "i" (offsetof(struct x8664_pda, pcurrent))   \
                     : "memory", "cc" __EXTRA_CLOBBER)
     
-
-extern void load_gs_index(unsigned);
+extern void load_gs_index(unsigned); 
 
 /*
  * Load a segment. Fall back on loading the zero
@@ -90,11 +91,12 @@ static inline void write_cr0(unsigned long val)
        asm volatile("movq %0,%%cr0" :: "r" (val));
 } 
 
-#define read_cr3() ({ \
-       unsigned long __dummy; \
-       asm("movq %%cr3,%0" : "=r" (__dummy)); \
-       machine_to_phys(__dummy); \
-})
+static inline unsigned long read_cr3(void)
+{ 
+       unsigned long cr3;
+       asm("movq %%cr3,%0" : "=r" (cr3));
+       return machine_to_phys(cr3);
+} 
 
 static inline unsigned long read_cr4(void)
 {