From: Eric Dumazet <edumazet@google.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, linux-kernel <linux-kernel@vger.kernel.org>,
Eric Dumazet <eric.dumazet@gmail.com>
Subject: Re: [PATCH] x86/irqflags: Force a register output in native_save_fl()
Date: Thu, 18 Dec 2025 11:58:25 +0100 [thread overview]
Message-ID: <CANn89i+3F6O30Tg5kh-+O2nFa3xJMsverm1bTh-K1G0vk=-gig@mail.gmail.com> (raw)
In-Reply-To: <20251218102256.GP3707891@noisy.programming.kicks-ass.net>
On Thu, Dec 18, 2025 at 11:22 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Thu, Dec 18, 2025 at 11:15:37AM +0100, Eric Dumazet wrote:
>
> > > >--- a/arch/x86/include/asm/irqflags.h
> > > >+++ b/arch/x86/include/asm/irqflags.h
> > > >@@ -18,14 +18,9 @@ extern __always_inline unsigned long native_save_fl(void)
> > > > {
> > > > unsigned long flags;
> > > >
> > > >- /*
> > > >- * "=rm" is safe here, because "pop" adjusts the stack before
> > > >- * it evaluates its effective address -- this is part of the
> > > >- * documented behavior of the "pop" instruction.
> > > >- */
> > > > asm volatile("# __raw_save_flags\n\t"
> > > > "pushf ; pop %0"
> > > >- : "=rm" (flags)
> > > >+ : "=r" (flags)
> > > > : /* no input */
> > > > : "memory");
> > > >
> > >
> > > Maybe report a bug to the clang team?
> >
> > This has been done 8 years ago. No progress so far...
> >
> > They claim we should use __builtin_ia32_readeflags_u64 /
> > __builtin_ia32_writeeflags_u64, which seems unlikely to please x86
> > maintainers ?
>
> Yeah, because the "rm" thing not being supported properly goes way
> further than just this one case. And it really is abysmal that clang
> hasn't managed to implement it in all that time :/
Let me know if you prefer a V2 with this instead. It saves ~190 bytes
more with clang ;)
Thanks !
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
index b30e5474c18e1be63b7c69354c26ae6a6cb02731..0209ae149f2b5f9ddacc6c8066a6d3191696ec42
100644
--- a/arch/x86/include/asm/irqflags.h
+++ b/arch/x86/include/asm/irqflags.h
@@ -16,20 +16,11 @@
extern inline unsigned long native_save_fl(void);
extern __always_inline unsigned long native_save_fl(void)
{
- unsigned long flags;
-
- /*
- * "=rm" is safe here, because "pop" adjusts the stack before
- * it evaluates its effective address -- this is part of the
- * documented behavior of the "pop" instruction.
- */
- asm volatile("# __raw_save_flags\n\t"
- "pushf ; pop %0"
- : "=rm" (flags)
- : /* no input */
- : "memory");
-
- return flags;
+#ifdef CONFIG_X86_64
+ return __builtin_ia32_readeflags_u64();
+#else
+ return __builtin_ia32_readeflags_u32();
+#endif
}
static __always_inline void native_irq_disable(void)
next prev parent reply other threads:[~2025-12-18 10:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 9:54 Eric Dumazet
2025-12-18 10:12 ` H. Peter Anvin
2025-12-18 10:15 ` Eric Dumazet
2025-12-18 10:21 ` Eric Dumazet
2025-12-18 10:22 ` Peter Zijlstra
2025-12-18 10:58 ` Eric Dumazet [this message]
2025-12-18 17:41 ` Uros Bizjak
2025-12-19 8:35 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CANn89i+3F6O30Tg5kh-+O2nFa3xJMsverm1bTh-K1G0vk=-gig@mail.gmail.com' \
--to=edumazet@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=eric.dumazet@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®