Skip to content

Commit

Permalink
x86/irqflags: Provide native versions of the local_irq_save()/restore()
Browse files Browse the repository at this point in the history
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 <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/c4c33c0d07200164a3dd8cfd6da0344f57732648.1717600736.git.thomas.lendacky@amd.com
  • Loading branch information
Tom Lendacky authored and Borislav Petkov (AMD) committed Jun 11, 2024
1 parent c3f38fa commit b547fc2
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions arch/x86/include/asm/irqflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,26 @@ static __always_inline void native_halt(void)
asm volatile("hlt": : :"memory");
}

static __always_inline int native_irqs_disabled_flags(unsigned long flags)
{
return !(flags & X86_EFLAGS_IF);
}

static __always_inline unsigned long native_local_irq_save(void)
{
unsigned long flags = native_save_fl();

native_irq_disable();

return flags;
}

static __always_inline void native_local_irq_restore(unsigned long flags)
{
if (!native_irqs_disabled_flags(flags))
native_irq_enable();
}

#endif

#ifdef CONFIG_PARAVIRT_XXL
Expand Down

0 comments on commit b547fc2

Please sign in to comment.