[SRU][N:linux-gcp][PATCH v2 01/24] x86/irqflags: Provide native versions of the local_irq_save()/restore()
Ian Whitfield
ian.whitfield at canonical.com
Mon Jun 23 20:47:59 UTC 2025
From: Tom Lendacky <thomas.lendacky at amd.com>
BugLink: https://bugs.launchpad.net/bugs/2111956
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 at amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp at alien8.de>
Link: https://lore.kernel.org/r/c4c33c0d07200164a3dd8cfd6da0344f57732648.1717600736.git.thomas.lendacky@amd.com
(cherry picked from commit b547fc2c9927a95808ef93d7fbd5dd70679fb501)
Signed-off-by: Ian Whitfield <ian.whitfield at canonical.com>
---
arch/x86/include/asm/irqflags.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
index 9acfe2bcf1fd..1c2db11a2c3c 100644
--- a/arch/x86/include/asm/irqflags.h
+++ b/arch/x86/include/asm/irqflags.h
@@ -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
#ifndef CONFIG_PARAVIRT
--
2.43.0
More information about the kernel-team
mailing list