Skip to content

Commit caecde1

Browse files
leitaoctmarinas
authored andcommitted
arm64/irqflags: __always_inline the arch_local_irq_*() helpers
The arch_local_irq_*() wrappers in <asm/irqflags.h> dispatch between two underlying primitives: the __daif_* path on most systems, and the __pmr_* path on builds that use GIC PMR-based masking (Pseudo-NMI). The leaf primitives are already __always_inline, but the wrappers themselves are plain "static inline". That is unsafe for noinstr callers: nothing prevents the compiler from emitting an out-of-line copy of e.g. arch_local_irq_disable(), and an out-of-line copy can be instrumented (ftrace, kcov, sanitizers), which breaks the noinstr contract on the entry/idle paths that rely on these helpers. x86 hit and fixed exactly this class of bug in commit 7a745be ("x86/entry: __always_inline irqflags for noinstr"). Force-inline all of the arch_local_irq_*() wrappers so they cannot be emitted out-of-line: - arch_local_irq_enable() - arch_local_irq_disable() - arch_local_save_flags() - arch_irqs_disabled_flags() - arch_irqs_disabled() - arch_local_irq_save() - arch_local_irq_restore() The primary motivation is noinstr safety. There is a useful side effect for fleet-wide profiling: when the wrapper is emitted out-of-line, samples taken inside it during the post-WFI IRQ unmask in default_idle_call() are attributed to arch_local_irq_enable rather than default_idle_call(), and the FP-unwinder loses default_idle_call() from the chain. Signed-off-by: Breno Leitao <leitao@debian.org> Reviewed-by: Leonardo Bras <leo.bras@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 4023b74 commit caecde1

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

arch/arm64/include/asm/irqflags.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static __always_inline void __pmr_local_irq_enable(void)
4040
barrier();
4141
}
4242

43-
static inline void arch_local_irq_enable(void)
43+
static __always_inline void arch_local_irq_enable(void)
4444
{
4545
if (system_uses_irq_prio_masking()) {
4646
__pmr_local_irq_enable();
@@ -68,7 +68,7 @@ static __always_inline void __pmr_local_irq_disable(void)
6868
barrier();
6969
}
7070

71-
static inline void arch_local_irq_disable(void)
71+
static __always_inline void arch_local_irq_disable(void)
7272
{
7373
if (system_uses_irq_prio_masking()) {
7474
__pmr_local_irq_disable();
@@ -90,7 +90,7 @@ static __always_inline unsigned long __pmr_local_save_flags(void)
9090
/*
9191
* Save the current interrupt enable state.
9292
*/
93-
static inline unsigned long arch_local_save_flags(void)
93+
static __always_inline unsigned long arch_local_save_flags(void)
9494
{
9595
if (system_uses_irq_prio_masking()) {
9696
return __pmr_local_save_flags();
@@ -109,7 +109,7 @@ static __always_inline bool __pmr_irqs_disabled_flags(unsigned long flags)
109109
return flags != GIC_PRIO_IRQON;
110110
}
111111

112-
static inline bool arch_irqs_disabled_flags(unsigned long flags)
112+
static __always_inline bool arch_irqs_disabled_flags(unsigned long flags)
113113
{
114114
if (system_uses_irq_prio_masking()) {
115115
return __pmr_irqs_disabled_flags(flags);
@@ -128,7 +128,7 @@ static __always_inline bool __pmr_irqs_disabled(void)
128128
return __pmr_irqs_disabled_flags(__pmr_local_save_flags());
129129
}
130130

131-
static inline bool arch_irqs_disabled(void)
131+
static __always_inline bool arch_irqs_disabled(void)
132132
{
133133
if (system_uses_irq_prio_masking()) {
134134
return __pmr_irqs_disabled();
@@ -160,7 +160,7 @@ static __always_inline unsigned long __pmr_local_irq_save(void)
160160
return flags;
161161
}
162162

163-
static inline unsigned long arch_local_irq_save(void)
163+
static __always_inline unsigned long arch_local_irq_save(void)
164164
{
165165
if (system_uses_irq_prio_masking()) {
166166
return __pmr_local_irq_save();
@@ -187,7 +187,7 @@ static __always_inline void __pmr_local_irq_restore(unsigned long flags)
187187
/*
188188
* restore saved IRQ state
189189
*/
190-
static inline void arch_local_irq_restore(unsigned long flags)
190+
static __always_inline void arch_local_irq_restore(unsigned long flags)
191191
{
192192
if (system_uses_irq_prio_masking()) {
193193
__pmr_local_irq_restore(flags);

0 commit comments

Comments
 (0)