debuggers.hg
changeset 18942:f4c1a347311b
x86: unify local_irq_XXX()
This also removes an inconsistency in that x86-64's __save_flags() had
a memory clobber, while x86_32's didn't.
It further adds type checking since blindly using {pop,push}{l,q} on a
memory operand of unknown size bares the risk of corrupting other
data.
Finally, it eliminates the redundant (with local_irq_restore())
__restore_flags() macro and renames __save_flags() to
local_save_flags(), making the naming consistent with Linux (again?).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
This also removes an inconsistency in that x86-64's __save_flags() had
a memory clobber, while x86_32's didn't.
It further adds type checking since blindly using {pop,push}{l,q} on a
memory operand of unknown size bares the risk of corrupting other
data.
Finally, it eliminates the redundant (with local_irq_restore())
__restore_flags() macro and renames __save_flags() to
local_save_flags(), making the naming consistent with Linux (again?).
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author | Keir Fraser <keir.fraser@citrix.com> |
---|---|
date | Thu Dec 11 11:36:00 2008 +0000 (2008-12-11) |
parents | 68555b9a7d98 |
children | c15244125a69 |
files | xen/include/asm-x86/system.h xen/include/asm-x86/x86_32/system.h xen/include/asm-x86/x86_64/system.h |
line diff
1.1 --- a/xen/include/asm-x86/system.h Thu Dec 11 11:32:39 2008 +0000 1.2 +++ b/xen/include/asm-x86/system.h Thu Dec 11 11:36:00 2008 +0000 1.3 @@ -1,8 +1,7 @@ 1.4 #ifndef __ASM_SYSTEM_H 1.5 #define __ASM_SYSTEM_H 1.6 1.7 -#include <xen/config.h> 1.8 -#include <xen/types.h> 1.9 +#include <xen/lib.h> 1.10 #include <asm/bitops.h> 1.11 1.12 #define read_segment_register(name) \ 1.13 @@ -171,10 +170,27 @@ static always_inline unsigned long __cmp 1.14 /* used when interrupts are already enabled or to shutdown the processor */ 1.15 #define halt() asm volatile ( "hlt" : : : "memory" ) 1.16 1.17 +#define local_save_flags(x) \ 1.18 +({ \ 1.19 + BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ 1.20 + asm volatile ( "pushf" __OS " ; pop" __OS " %0" : "=g" (x)); \ 1.21 +}) 1.22 +#define local_irq_save(x) \ 1.23 +({ \ 1.24 + local_save_flags(x); \ 1.25 + local_irq_disable(); \ 1.26 +}) 1.27 +#define local_irq_restore(x) \ 1.28 +({ \ 1.29 + BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ 1.30 + asm volatile ( "push" __OS " %0 ; popf" __OS \ 1.31 + : : "g" (x) : "memory", "cc" ); \ 1.32 +}) 1.33 + 1.34 static inline int local_irq_is_enabled(void) 1.35 { 1.36 unsigned long flags; 1.37 - __save_flags(flags); 1.38 + local_save_flags(flags); 1.39 return !!(flags & (1<<9)); /* EFLAGS_IF */ 1.40 } 1.41
2.1 --- a/xen/include/asm-x86/x86_32/system.h Thu Dec 11 11:32:39 2008 +0000 2.2 +++ b/xen/include/asm-x86/x86_32/system.h Thu Dec 11 11:36:00 2008 +0000 2.3 @@ -101,14 +101,4 @@ static inline void atomic_write64(uint64 2.4 #define mb() \ 2.5 asm volatile ( "lock; addl $0,0(%%esp)" : : : "memory" ) 2.6 2.7 -#define __save_flags(x) \ 2.8 - asm volatile ( "pushfl ; popl %0" : "=g" (x) : ) 2.9 -#define __restore_flags(x) \ 2.10 - asm volatile ( "pushl %0 ; popfl" : : "g" (x) : "memory", "cc" ) 2.11 - 2.12 -#define local_irq_save(x) \ 2.13 - asm volatile ( "pushfl ; popl %0 ; cli" : "=g" (x) : : "memory" ) 2.14 -#define local_irq_restore(x) \ 2.15 - __restore_flags(x) 2.16 - 2.17 #endif /* __X86_32_SYSTEM_H__ */
3.1 --- a/xen/include/asm-x86/x86_64/system.h Thu Dec 11 11:32:39 2008 +0000 3.2 +++ b/xen/include/asm-x86/x86_64/system.h Thu Dec 11 11:36:00 2008 +0000 3.3 @@ -55,14 +55,4 @@ static inline void atomic_write64(uint64 3.4 #define mb() \ 3.5 asm volatile ( "mfence" : : : "memory" ) 3.6 3.7 -#define __save_flags(x) \ 3.8 - asm volatile ( "pushfq ; popq %q0" : "=g" (x) : :"memory" ) 3.9 -#define __restore_flags(x) \ 3.10 - asm volatile ( "pushq %0 ; popfq" : : "g" (x) : "memory", "cc" ) 3.11 - 3.12 -#define local_irq_save(x) \ 3.13 - asm volatile ( "pushfq ; popq %0 ; cli" : "=g" (x) : : "memory" ) 3.14 -#define local_irq_restore(x) \ 3.15 - __restore_flags(x) 3.16 - 3.17 #endif /* __X86_64_SYSTEM_H__ */