1 #ifndef _X86_IRQFLAGS_H_
2 #define _X86_IRQFLAGS_H_
4 #include <asm/processor-flags.h>
8 /* Provide __cpuidle; we can't safely include <linux/cpu.h> */
9 #define __cpuidle __attribute__((__section__(".cpuidle.text")))
15 static inline unsigned long native_save_fl(void)
20 * "=rm" is safe here, because "pop" adjusts the stack before
21 * it evaluates its effective address -- this is part of the
22 * documented behavior of the "pop" instruction.
24 asm volatile("# __raw_save_flags\n\t"
33 static inline void native_restore_fl(unsigned long flags
)
35 asm volatile("push %0 ; popf"
41 static inline void native_irq_disable(void)
43 asm volatile("cli": : :"memory");
46 static inline void native_irq_enable(void)
48 asm volatile("sti": : :"memory");
51 static inline __cpuidle
void native_safe_halt(void)
53 asm volatile("sti; hlt": : :"memory");
56 static inline __cpuidle
void native_halt(void)
58 asm volatile("hlt": : :"memory");
63 #ifdef CONFIG_PARAVIRT
64 #include <asm/paravirt.h>
67 #include <linux/types.h>
69 static inline notrace
unsigned long arch_local_save_flags(void)
71 return native_save_fl();
74 static inline notrace
void arch_local_irq_restore(unsigned long flags
)
76 native_restore_fl(flags
);
79 static inline notrace
void arch_local_irq_disable(void)
84 static inline notrace
void arch_local_irq_enable(void)
90 * Used in the idle loop; sti takes one instruction cycle
93 static inline __cpuidle
void arch_safe_halt(void)
99 * Used when interrupts are already enabled or to
100 * shutdown the processor:
102 static inline __cpuidle
void halt(void)
108 * For spinlocks, etc:
110 static inline notrace
unsigned long arch_local_irq_save(void)
112 unsigned long flags
= arch_local_save_flags();
113 arch_local_irq_disable();
118 #define ENABLE_INTERRUPTS(x) sti
119 #define DISABLE_INTERRUPTS(x) cli
122 #define SWAPGS swapgs
124 * Currently paravirt can't handle swapgs nicely when we
125 * don't have a stack we can rely on (such as a user space
126 * stack). So we either find a way around these or just fault
127 * and emulate if a guest tries to call swapgs directly.
129 * Either way, this is a good way to document that we don't
130 * have a reliable stack. x86_64 only.
132 #define SWAPGS_UNSAFE_STACK swapgs
134 #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */
136 #define INTERRUPT_RETURN jmp native_iret
137 #define USERGS_SYSRET64 \
140 #define USERGS_SYSRET32 \
145 #define INTERRUPT_RETURN iret
146 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
147 #define GET_CR0_INTO_EAX movl %cr0, %eax
151 #endif /* __ASSEMBLY__ */
152 #endif /* CONFIG_PARAVIRT */
155 static inline int arch_irqs_disabled_flags(unsigned long flags
)
157 return !(flags
& X86_EFLAGS_IF
);
160 static inline int arch_irqs_disabled(void)
162 unsigned long flags
= arch_local_save_flags();
164 return arch_irqs_disabled_flags(flags
);
166 #endif /* !__ASSEMBLY__ */
169 #ifdef CONFIG_TRACE_IRQFLAGS
170 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk;
171 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk;
173 # define TRACE_IRQS_ON
174 # define TRACE_IRQS_OFF
176 #ifdef CONFIG_DEBUG_LOCK_ALLOC
177 # ifdef CONFIG_X86_64
178 # define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
179 # define LOCKDEP_SYS_EXIT_IRQ \
182 call lockdep_sys_exit_thunk; \
186 # define LOCKDEP_SYS_EXIT \
190 call lockdep_sys_exit; \
194 # define LOCKDEP_SYS_EXIT_IRQ
197 # define LOCKDEP_SYS_EXIT
198 # define LOCKDEP_SYS_EXIT_IRQ
200 #endif /* __ASSEMBLY__ */