From: "H. Peter Anvin" <hpa@zytor.com>
To: Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: More annoying code generation by clang
Date: Mon, 08 Apr 2024 06:41:12 -0700 [thread overview]
Message-ID: <A120A8EC-AB1E-44FB-AEAB-09DFE282CCF8@zytor.com> (raw)
In-Reply-To: <20240408084934.GC21904@noisy.programming.kicks-ass.net>
On April 8, 2024 1:49:34 AM PDT, Peter Zijlstra <peterz@infradead.org> wrote:
>On Thu, Apr 04, 2024 at 03:53:49PM -0700, Linus Torvalds wrote:
>
>> diff --git a/arch/x86/include/asm/barrier.h b/arch/x86/include/asm/barrier.h
>> index 66e57c010392..6159d2cbbfde 100644
>> --- a/arch/x86/include/asm/barrier.h
>> +++ b/arch/x86/include/asm/barrier.h
>> @@ -33,20 +33,15 @@
>> * Returns:
>> * 0 - (index < size)
>> */
>> +#define array_index_mask_nospec(idx,sz) ({ \
>> + typeof((idx)+(sz)) __idx = (idx); \
>> + typeof(__idx) __sz = (sz); \
>> + typeof(__idx) __mask; \
>> + asm volatile ("cmp %1,%2; sbb %0,%0" \
>> + :"=r" (__mask) \
>> + :"ir"(__sz),"r" (__idx) \
>> + :"cc"); \
>> + __mask; })
>
>Should this not carry a comment about the "ir" constraint wanting to be
>"g" except for clang being daft?
>
>(I really wish clang would go fix this, it keeps coming up time and
>again).
>
>>
>> /* Prevent speculative execution past this barrier. */
>> #define barrier_nospec() asm volatile("lfence":::"memory")
>
If the only reason for "ir" as opposed to "g" (= "irm") is clang then it really needs to be called out. Or better yet, don't do anything and let the clang people actually fix their code generation.
next prev parent reply other threads:[~2024-04-08 13:41 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-04 22:53 Linus Torvalds
2024-04-06 10:56 ` Ingo Molnar
2024-04-06 12:30 ` Uros Bizjak
2024-04-06 15:39 ` Linus Torvalds
2024-04-06 16:04 ` Linus Torvalds
2024-04-08 8:49 ` Peter Zijlstra
2024-04-08 13:41 ` H. Peter Anvin [this message]
2024-04-08 18:32 ` Linus Torvalds
2024-04-08 19:42 ` Linus Torvalds
2024-04-09 10:45 ` Peter Zijlstra
2024-04-09 15:37 ` Nick Desaulniers
2024-04-10 19:23 ` Bill Wendling
2024-04-10 8:11 ` David Laight
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=A120A8EC-AB1E-44FB-AEAB-09DFE282CCF8@zytor.com \
--to=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--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®