x86/irq: local_irq_restore() should not blindly popf
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 22 Oct 2013 15:11:16 +0000 (17:11 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Oct 2013 15:11:16 +0000 (17:11 +0200)
local_irq_restore() should only be concerned with possibly changing the
interrupt flag.  A blind popf could corrupt other system flags.

While playing in this area, fixup an opencoded use of X86_EFLAGS_IF.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/include/asm-x86/system.h

index 6ab7d56fbd42706c05ae2cb0966bdf65de2091ac..e9602aa3d8b1b16074f2cc1a1c3e3c0f9355461d 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <xen/lib.h>
 #include <xen/bitops.h>
+#include <asm/processor.h>
 
 #define read_segment_register(name)                             \
 ({  u16 __sel;                                                  \
@@ -159,15 +160,19 @@ static always_inline unsigned long __cmpxchg(
 #define local_irq_restore(x)                                     \
 ({                                                               \
     BUILD_BUG_ON(sizeof(x) != sizeof(long));                     \
-    asm volatile ( "push" __OS " %0 ; popf" __OS                 \
-                   : : "g" (x) : "memory", "cc" );               \
+    asm volatile ( "pushfq\n\t"                                  \
+                   "andq %0, (%%rsp)\n\t"                        \
+                   "orq  %1, (%%rsp)\n\t"                        \
+                   "popfq"                                       \
+                   : : "i?r" ( ~X86_EFLAGS_IF ),                 \
+                       "ri" ( (x) & X86_EFLAGS_IF ) );           \
 })
 
 static inline int local_irq_is_enabled(void)
 {
     unsigned long flags;
     local_save_flags(flags);
-    return !!(flags & (1<<9)); /* EFLAGS_IF */
+    return !!(flags & X86_EFLAGS_IF);
 }
 
 #define BROKEN_ACPI_Sx          0x0001