Linux SNPS ARC Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Yury Norov <yury.norov@gmail.com>
Cc: Rasmus Villemoes <ravi@prevas.dk>,
	kernel test robot <lkp@intel.com>,
	Vineet Gupta <vgupta@kernel.org>,
	linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] arc: Fix __fls() const-foldability via __builtin_clzl()
Date: Tue, 26 Aug 2025 19:13:03 -0700	[thread overview]
Message-ID: <202508261911.ECB628656@keescook> (raw)
In-Reply-To: <aK5eNDa5H-PNGHpj@yury>

On Tue, Aug 26, 2025 at 09:24:04PM -0400, Yury Norov wrote:
> On Tue, Aug 26, 2025 at 09:56:06AM -0700, Kees Cook wrote:
> > On Tue, Aug 26, 2025 at 03:08:59PM +0200, Rasmus Villemoes wrote:
> > > If __builtin_arc_fls() simply doesn't qualify for attr_const for
> > > $reason, I think it would be good to have that documented in the commit
> > > msg. If it does, I think a gcc ticket and link to that would be in order.
> > 
> > I already sent the patch to fix it. :)
> > 
> > https://gcc.gnu.org/pipermail/gcc-patches/2025-August/693273.html
> 
> I'm OK taking the patch if it fixes real problem for you, but it looks
> more like a GCC problem, right? Is Clang also affected?

Without it, KUnit testing of ffs/fls fails on arc. Clang is not
affected. Even with the GCC fix landed, all older GCCs with still fail,
and since it provides a improved code generation for arc, it seems worth
it (compile-time-calculable values will be emitted instead of always
running the arc instructions).

> If, say, Clang is not affected, and you expect that newer GCC versions
> will not be affected too, let's protect the new code with a proper
> ifdefery, so that it will be easier to drop the workaround later?

I think the codegen benefit is worth it as I have it.

-- 
Kees Cook

_______________________________________________
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc

  reply	other threads:[~2025-08-27  2:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-26  3:43 [PATCH] arc: Fix __fls() const-foldability via __builtin_clzl() Kees Cook
2025-08-26 13:08 ` Rasmus Villemoes
2025-08-26 16:56   ` Kees Cook
2025-08-27  1:24     ` Yury Norov
2025-08-27  2:13       ` Kees Cook [this message]
2025-08-27  3:41         ` Yury Norov

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=202508261911.ECB628656@keescook \
    --to=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-snps-arc@lists.infradead.org \
    --cc=lkp@intel.com \
    --cc=ravi@prevas.dk \
    --cc=vgupta@kernel.org \
    --cc=yury.norov@gmail.com \
    /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