]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/include/asm/irqflags.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _X86_IRQFLAGS_H_
3 #define _X86_IRQFLAGS_H_
5 #include <asm/processor-flags.h>
9 /* Provide __cpuidle; we can't safely include <linux/cpu.h> */
10 #define __cpuidle __attribute__((__section__(".cpuidle.text")))
16 static inline unsigned long native_save_fl(void)
21 * "=rm" is safe here, because "pop" adjusts the stack before
22 * it evaluates its effective address -- this is part of the
23 * documented behavior of the "pop" instruction.
25 asm volatile("# __raw_save_flags\n\t"
34 static inline void native_restore_fl(unsigned long flags
)
36 asm volatile("push %0 ; popf"
42 static inline void native_irq_disable(void)
44 asm volatile("cli": : :"memory");
47 static inline void native_irq_enable(void)
49 asm volatile("sti": : :"memory");
52 static inline __cpuidle
void native_safe_halt(void)
54 asm volatile("sti; hlt": : :"memory");
57 static inline __cpuidle
void native_halt(void)
59 asm volatile("hlt": : :"memory");
64 #ifdef CONFIG_PARAVIRT
65 #include <asm/paravirt.h>
68 #include <linux/types.h>
70 static inline notrace
unsigned long arch_local_save_flags(void)
72 return native_save_fl();
75 static inline notrace
void arch_local_irq_restore(unsigned long flags
)
77 native_restore_fl(flags
);
80 static inline notrace
void arch_local_irq_disable(void)
85 static inline notrace
void arch_local_irq_enable(void)
91 * Used in the idle loop; sti takes one instruction cycle
94 static inline __cpuidle
void arch_safe_halt(void)
100 * Used when interrupts are already enabled or to
101 * shutdown the processor:
103 static inline __cpuidle
void halt(void)
109 * For spinlocks, etc:
111 static inline notrace
unsigned long arch_local_irq_save(void)
113 unsigned long flags
= arch_local_save_flags();
114 arch_local_irq_disable();
119 #define ENABLE_INTERRUPTS(x) sti
120 #define DISABLE_INTERRUPTS(x) cli
123 #define SWAPGS swapgs
125 * Currently paravirt can't handle swapgs nicely when we
126 * don't have a stack we can rely on (such as a user space
127 * stack). So we either find a way around these or just fault
128 * and emulate if a guest tries to call swapgs directly.
130 * Either way, this is a good way to document that we don't
131 * have a reliable stack. x86_64 only.
133 #define SWAPGS_UNSAFE_STACK swapgs
135 #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */
137 #define INTERRUPT_RETURN jmp native_iret
138 #define USERGS_SYSRET64 \
141 #define USERGS_SYSRET32 \
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 static inline int arch_irqs_disabled_flags(unsigned long flags
)
158 return !(flags
& X86_EFLAGS_IF
);
161 static inline int arch_irqs_disabled(void)
163 unsigned long flags
= arch_local_save_flags();
165 return arch_irqs_disabled_flags(flags
);
167 #endif /* !__ASSEMBLY__ */
170 #ifdef CONFIG_TRACE_IRQFLAGS
171 # define TRACE_IRQS_ON call trace_hardirqs_on_thunk;
172 # define TRACE_IRQS_OFF call trace_hardirqs_off_thunk;
174 # define TRACE_IRQS_ON
175 # define TRACE_IRQS_OFF
177 #ifdef CONFIG_DEBUG_LOCK_ALLOC
178 # ifdef CONFIG_X86_64
179 # define LOCKDEP_SYS_EXIT call lockdep_sys_exit_thunk
180 # define LOCKDEP_SYS_EXIT_IRQ \
183 call lockdep_sys_exit_thunk; \
187 # define LOCKDEP_SYS_EXIT \
191 call lockdep_sys_exit; \
195 # define LOCKDEP_SYS_EXIT_IRQ
198 # define LOCKDEP_SYS_EXIT
199 # define LOCKDEP_SYS_EXIT_IRQ
201 #endif /* __ASSEMBLY__ */