Re: [PATCH] sparc64: Read qemu,hwcap-list from the OF cpu node on sun4u
From: Eric Biggers
Date: Tue Nov 17 2026 - 23:39:01 EST
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@xxxxxxxxxx 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@xxxxxxxxxx/
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@xxxxxxxxxx>
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