From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 1/3 v3] x86/irq: local_irq_restore() should not blindly popf Date: Tue, 22 Oct 2013 11:14:35 +0100 Message-ID: <1382436875-11790-1-git-send-email-andrew.cooper3@citrix.com> References: <5266616F02000078000FCA45@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5266616F02000078000FCA45@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Keir Fraser , Jan Beulich List-Id: xen-devel@lists.xenproject.org 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 CC: Keir Fraser CC: Jan Beulich --- Change in v3: * asm tweaks --- xen/include/asm-x86/system.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h index 6ab7d56..7d9f31b 100644 --- a/xen/include/asm-x86/system.h +++ b/xen/include/asm-x86/system.h @@ -3,6 +3,7 @@ #include #include +#include #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\n\t" : : "ri" ( ~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 -- 1.7.10.4