iwlwifi: mvm: fix version check for GEO_TX_POWER_LIMIT support
[linux/fpc-iii.git] / arch / x86 / include / asm / irqflags.h
blobc99c66b41e53261e14c9bb3ab081e181d326d689
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _X86_IRQFLAGS_H_
3 #define _X86_IRQFLAGS_H_
5 #include <asm/processor-flags.h>
7 #ifndef __ASSEMBLY__
9 #include <asm/nospec-branch.h>
11 /* Provide __cpuidle; we can't safely include <linux/cpu.h> */
12 #define __cpuidle __attribute__((__section__(".cpuidle.text")))
15 * Interrupt control:
18 /* Declaration required for gcc < 4.9 to prevent -Werror=missing-prototypes */
19 extern inline unsigned long native_save_fl(void);
20 extern inline unsigned long native_save_fl(void)
22 unsigned long flags;
25 * "=rm" is safe here, because "pop" adjusts the stack before
26 * it evaluates its effective address -- this is part of the
27 * documented behavior of the "pop" instruction.
29 asm volatile("# __raw_save_flags\n\t"
30 "pushf ; pop %0"
31 : "=rm" (flags)
32 : /* no input */
33 : "memory");
35 return flags;
38 extern inline void native_restore_fl(unsigned long flags);
39 extern inline void native_restore_fl(unsigned long flags)
41 asm volatile("push %0 ; popf"
42 : /* no output */
43 :"g" (flags)
44 :"memory", "cc");
47 static inline void native_irq_disable(void)
49 asm volatile("cli": : :"memory");
52 static inline void native_irq_enable(void)
54 asm volatile("sti": : :"memory");
57 static inline __cpuidle void native_safe_halt(void)
59 mds_idle_clear_cpu_buffers();
60 asm volatile("sti; hlt": : :"memory");
63 static inline __cpuidle void native_halt(void)
65 mds_idle_clear_cpu_buffers();
66 asm volatile("hlt": : :"memory");
69 #endif
71 #ifdef CONFIG_PARAVIRT
72 #include <asm/paravirt.h>
73 #else
74 #ifndef __ASSEMBLY__
75 #include <linux/types.h>
77 static inline notrace unsigned long arch_local_save_flags(void)
79 return native_save_fl();
82 static inline notrace void arch_local_irq_restore(unsigned long flags)
84 native_restore_fl(flags);
87 static inline notrace void arch_local_irq_disable(void)
89 native_irq_disable();
92 static inline notrace void arch_local_irq_enable(void)
94 native_irq_enable();
98 * Used in the idle loop; sti takes one instruction cycle
99 * to complete:
101 static inline __cpuidle void arch_safe_halt(void)
103 native_safe_halt();
107 * Used when interrupts are already enabled or to
108 * shutdown the processor:
110 static inline __cpuidle void halt(void)
112 native_halt();
116 * For spinlocks, etc:
118 static inline notrace unsigned long arch_local_irq_save(void)
120 unsigned long flags = arch_local_save_flags();
121 arch_local_irq_disable();
122 return flags;
124 #else
126 #define ENABLE_INTERRUPTS(x) sti
127 #define DISABLE_INTERRUPTS(x) cli
129 #ifdef CONFIG_X86_64
130 #define SWAPGS swapgs
132 * Currently paravirt can't handle swapgs nicely when we
133 * don't have a stack we can rely on (such as a user space
134 * stack). So we either find a way around these or just fault
135 * and emulate if a guest tries to call swapgs directly.
137 * Either way, this is a good way to document that we don't
138 * have a reliable stack. x86_64 only.
140 #define SWAPGS_UNSAFE_STACK swapgs
142 #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */
144 #define INTERRUPT_RETURN jmp native_iret
145 #define USERGS_SYSRET64 \
146 swapgs; \
147 sysretq;
148 #define USERGS_SYSRET32 \
149 swapgs; \
150 sysretl
152 #ifdef CONFIG_DEBUG_ENTRY
153 #define SAVE_FLAGS(x) pushfq; popq %rax
154 #endif
155 #else
156 #define INTERRUPT_RETURN iret
157 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
158 #define GET_CR0_INTO_EAX movl %cr0, %eax
159 #endif
162 #endif /* __ASSEMBLY__ */
163 #endif /* CONFIG_PARAVIRT */
165 #ifndef __ASSEMBLY__
166 static inline int arch_irqs_disabled_flags(unsigned long flags)
168 return !(flags & X86_EFLAGS_IF);
171 static inline int arch_irqs_disabled(void)
173 unsigned long flags = arch_local_save_flags();
175 return arch_irqs_disabled_flags(flags);
177 #endif /* !__ASSEMBLY__ */
179 #ifdef __ASSEMBLY__
180 #ifdef CONFIG_TRACE_IRQFLAGS
181 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk;
182 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk;
183 #else
184 # define TRACE_IRQS_ON
185 # define TRACE_IRQS_OFF
186 #endif
187 #ifdef CONFIG_DEBUG_LOCK_ALLOC
188 # ifdef CONFIG_X86_64
189 # define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
190 # define LOCKDEP_SYS_EXIT_IRQ \
191 TRACE_IRQS_ON; \
192 sti; \
193 call lockdep_sys_exit_thunk; \
194 cli; \
195 TRACE_IRQS_OFF;
196 # else
197 # define LOCKDEP_SYS_EXIT \
198 pushl %eax; \
199 pushl %ecx; \
200 pushl %edx; \
201 call lockdep_sys_exit; \
202 popl %edx; \
203 popl %ecx; \
204 popl %eax;
205 # define LOCKDEP_SYS_EXIT_IRQ
206 # endif
207 #else
208 # define LOCKDEP_SYS_EXIT
209 # define LOCKDEP_SYS_EXIT_IRQ
210 #endif
211 #endif /* __ASSEMBLY__ */
213 #endif