Skip to content

Commit b547fc2

Browse files
tlendackybp3tk0v
authored andcommitted
x86/irqflags: Provide native versions of the local_irq_save()/restore()
Functions that need to disable IRQs, but are common to both early boot and post-boot execution, are unable to deal with paravirt support associated with local_irq_save() and local_irq_restore(). Create native versions of these for use in these situations. Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Link: https://lore.kernel.org/r/c4c33c0d07200164a3dd8cfd6da0344f57732648.1717600736.git.thomas.lendacky@amd.com
1 parent c3f38fa commit b547fc2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

arch/x86/include/asm/irqflags.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,26 @@ static __always_inline void native_halt(void)
5454
asm volatile("hlt": : :"memory");
5555
}
5656

57+
static __always_inline int native_irqs_disabled_flags(unsigned long flags)
58+
{
59+
return !(flags & X86_EFLAGS_IF);
60+
}
61+
62+
static __always_inline unsigned long native_local_irq_save(void)
63+
{
64+
unsigned long flags = native_save_fl();
65+
66+
native_irq_disable();
67+
68+
return flags;
69+
}
70+
71+
static __always_inline void native_local_irq_restore(unsigned long flags)
72+
{
73+
if (!native_irqs_disabled_flags(flags))
74+
native_irq_enable();
75+
}
76+
5777
#endif
5878

5979
#ifdef CONFIG_PARAVIRT_XXL

0 commit comments

Comments
 (0)