diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-12-11 11:36:00 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-12-11 11:36:00 +0000 |
commit | 3bc61439add8aa6386afcff33a46a85d2247b960 (patch) | |
tree | 32bc8a298cefe09025dffc909c296e0bd6c83084 /xen/include/asm-x86/system.h | |
parent | 3245eb0237a6cdf5252efad3dda8030f8e97240a (diff) | |
download | xen-3bc61439add8aa6386afcff33a46a85d2247b960.tar.gz xen-3bc61439add8aa6386afcff33a46a85d2247b960.tar.bz2 xen-3bc61439add8aa6386afcff33a46a85d2247b960.zip |
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>
Diffstat (limited to 'xen/include/asm-x86/system.h')
-rw-r--r-- | xen/include/asm-x86/system.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/xen/include/asm-x86/system.h b/xen/include/asm-x86/system.h index c257513dad..ced68d0633 100644 --- a/xen/include/asm-x86/system.h +++ b/xen/include/asm-x86/system.h @@ -1,8 +1,7 @@ #ifndef __ASM_SYSTEM_H #define __ASM_SYSTEM_H -#include <xen/config.h> -#include <xen/types.h> +#include <xen/lib.h> #include <asm/bitops.h> #define read_segment_register(name) \ @@ -171,10 +170,27 @@ static always_inline unsigned long __cmpxchg( /* used when interrupts are already enabled or to shutdown the processor */ #define halt() asm volatile ( "hlt" : : : "memory" ) +#define local_save_flags(x) \ +({ \ + BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ + asm volatile ( "pushf" __OS " ; pop" __OS " %0" : "=g" (x)); \ +}) +#define local_irq_save(x) \ +({ \ + local_save_flags(x); \ + local_irq_disable(); \ +}) +#define local_irq_restore(x) \ +({ \ + BUILD_BUG_ON(sizeof(x) != sizeof(long)); \ + asm volatile ( "push" __OS " %0 ; popf" __OS \ + : : "g" (x) : "memory", "cc" ); \ +}) + static inline int local_irq_is_enabled(void) { unsigned long flags; - __save_flags(flags); + local_save_flags(flags); return !!(flags & (1<<9)); /* EFLAGS_IF */ } |