1 #ifndef _X86_IRQFLAGS_H_
2 #define _X86_IRQFLAGS_H_
4 #include <asm/processor-flags.h>
11 static inline unsigned long native_save_fl(void)
16 * "=rm" is safe here, because "pop" adjusts the stack before
17 * it evaluates its effective address -- this is part of the
18 * documented behavior of the "pop" instruction.
20 asm volatile("# __raw_save_flags\n\t"
29 static inline void native_restore_fl(unsigned long flags
)
31 asm volatile("push %0 ; popf"
37 static inline void native_irq_disable(void)
39 asm volatile("cli": : :"memory");
42 static inline void native_irq_enable(void)
44 asm volatile("sti": : :"memory");
47 static inline void native_safe_halt(void)
49 asm volatile("sti; hlt": : :"memory");
52 static inline void native_halt(void)
54 asm volatile("hlt": : :"memory");
59 #ifdef CONFIG_PARAVIRT
60 #include <asm/paravirt.h>
64 static inline unsigned long __raw_local_save_flags(void)
66 return native_save_fl();
69 static inline void raw_local_irq_restore(unsigned long flags
)
71 native_restore_fl(flags
);
74 static inline void raw_local_irq_disable(void)
79 static inline void raw_local_irq_enable(void)
85 * Used in the idle loop; sti takes one instruction cycle
88 static inline void raw_safe_halt(void)
94 * Used when interrupts are already enabled or to
95 * shutdown the processor:
97 static inline void halt(void)
103 * For spinlocks, etc:
105 static inline unsigned long __raw_local_irq_save(void)
107 unsigned long flags
= __raw_local_save_flags();
109 raw_local_irq_disable();
115 #define ENABLE_INTERRUPTS(x) sti
116 #define DISABLE_INTERRUPTS(x) cli
119 #define SWAPGS swapgs
121 * Currently paravirt can't handle swapgs nicely when we
122 * don't have a stack we can rely on (such as a user space
123 * stack). So we either find a way around these or just fault
124 * and emulate if a guest tries to call swapgs directly.
126 * Either way, this is a good way to document that we don't
127 * have a reliable stack. x86_64 only.
129 #define SWAPGS_UNSAFE_STACK swapgs
131 #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */
133 #define INTERRUPT_RETURN iretq
134 #define USERGS_SYSRET64 \
137 #define USERGS_SYSRET32 \
140 #define ENABLE_INTERRUPTS_SYSEXIT32 \
146 #define INTERRUPT_RETURN iret
147 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
148 #define GET_CR0_INTO_EAX movl %cr0, %eax
152 #endif /* __ASSEMBLY__ */
153 #endif /* CONFIG_PARAVIRT */
156 #define raw_local_save_flags(flags) \
157 do { (flags) = __raw_local_save_flags(); } while (0)
159 #define raw_local_irq_save(flags) \
160 do { (flags) = __raw_local_irq_save(); } while (0)
162 static inline int raw_irqs_disabled_flags(unsigned long flags
)
164 return !(flags
& X86_EFLAGS_IF
);
167 static inline int raw_irqs_disabled(void)
169 unsigned long flags
= __raw_local_save_flags();
171 return raw_irqs_disabled_flags(flags
);
177 #define ARCH_LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
178 #define ARCH_LOCKDEP_SYS_EXIT_IRQ \
188 #define ARCH_LOCKDEP_SYS_EXIT \
192 call lockdep_sys_exit; \
197 #define ARCH_LOCKDEP_SYS_EXIT_IRQ
200 #ifdef CONFIG_TRACE_IRQFLAGS
201 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk;
202 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk;
204 # define TRACE_IRQS_ON
205 # define TRACE_IRQS_OFF
207 #ifdef CONFIG_DEBUG_LOCK_ALLOC
208 # define LOCKDEP_SYS_EXIT ARCH_LOCKDEP_SYS_EXIT
209 # define LOCKDEP_SYS_EXIT_IRQ ARCH_LOCKDEP_SYS_EXIT_IRQ
211 # define LOCKDEP_SYS_EXIT
212 # define LOCKDEP_SYS_EXIT_IRQ
215 #endif /* __ASSEMBLY__ */