mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Stian Halseth <stian@itx.no>
Cc: sashiko-reviews@lists.linux.dev, sparclinux@vger.kernel.org,
	Andreas Larsson <andreas@gaisler.com>,
	"David S . Miller" <davem@davemloft.net>,
	Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sparc64: Read qemu,hwcap-list from the OF cpu node on sun4u
Date: Tue, 17 Nov 2026 20:38:57 -0800	[thread overview]
Message-ID: <20261118043857.GA3400@sol> (raw)
In-Reply-To: <8c0c3734b9ad1ba0072ce1fbcf895b544563798f.camel@itx.no>

Hi Stian,

On Tue, Nov 17, 2026 at 01:44:14PM +0100, Stian Halseth wrote:
> Hi all,
> 
> On Tue, 2026-11-17 at 11:46 +0000, sashiko-bot@kernel.org wrote:
> > 
> > [Severity: High]
> > This problem wasn't introduced by this patch, but can hwcap_list_caps()
> > read out of bounds and loop forever [1] if the property buffer is not
> > null-terminated?
> 
> Yes, and we can fix that in v2. As it stands the parser trusts the list
> to end with a NUL, which is not guaranteed if a QEMU user supplies a
> fw_cfg file directly.
> 
> > 
> > [Severity: High]
> > Does setting HWCAP_SPARC_CRYPTO in sparc64_elf_hwcap on sun4u cause a
> > regression where the sparc64 skcipher drivers corrupt FPU state and round
> > keys across skcipher_walk_done()?
> > 
> 
> This might be a bit worse than I first thought. I was aware of the
> self-test failures, as noted in my patch notes, but it looks like this
> could also cause some data corruption. Only QEMU can hit it, since no
> real sun4u CPU has the crypto opcodes.
> 
> I have not reproduced it myself, and before spending time on that,
> I would like to get Eric's take on removing the glue code altogether.
> If not, we could fix the glue itself, for example by dropping the FP
> state before skcipher_walk_done(). IMO that would be maintaining code
> that probably should be removed. Not my call, though.
> 
> Andreas, please don't apply this patch as-is for now. I will wait for
> Eric's reply before proceeding.

The following series migrates the remaining SPARC crypto opcodes
accelerated AES modes into lib/crypto/:
https://lore.kernel.org/linux-crypto/20261118041033.50014-1-ebiggers@kernel.org/

There we have more control over the bounce buffering, and I set the size
to 128 bytes (rather than crypto/skcipher.c's PAGE_SIZE) to keep it
below the size threshold at which memcpy() uses the FPU registers.

I tested this patch with that series and the QEMU support you added, and
everything seems to work.  And Camellia is not supported in QEMU, so
that is not an issue either (and really it's time to just delete the
kernel's Camellia code anyway, as no one uses it).  So feel free to add:

    Tested-by: Eric Biggers <ebiggers@kernel.org>

We should be fine as long as my series is merged too (and I plan to take
it via libcrypto-next in 7.5).

I think this is the only case where a Linux architecture has
restrictions on when memcpy() can be called, though.  It would be worth
finding a way to remove that footgun, e.g. making memcpy() automatically
fall back to scalar code if the FPU is already in use.  It seems that
some of the SPARC memcpy() implementations already do that, in fact.

Thanks,

- Eric

      reply	other threads:[~2026-11-18  4:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 11:29 Stian Halseth
     [not found] ` <sashiko-outbox-218725@kernel.org>
2026-11-17 12:44   ` Stian Halseth
2026-11-18  4:38     ` Eric Biggers [this message]

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=20261118043857.GA3400@sol \
    --to=ebiggers@kernel.org \
    --cc=andreas@gaisler.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sparclinux@vger.kernel.org \
    --cc=stian@itx.no \
    /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®