From: Eric Biggers <ebiggers@kernel.org>
To: Pavitrakumar Managutte <pavitrakumarm@vayavyalabs.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
linux-crypto@vger.kernel.org, "Derwig, Ruud" <ruud.derwig@gf.com>,
Ross Bannerman <Ross.Bannerman@synopsys.com>,
Nazim Khan <nazim.khan@vayavyalabs.com>,
Navami R Telsang <navami.telsang@vayavyalabs.com>
Subject: Re: CMAC fallback failures from SPAcc driver
Date: Wed, 7 Oct 2026 12:24:57 +0200 [thread overview]
Message-ID: <20261007102457.GA1695@quark> (raw)
In-Reply-To: <CALxtO0nT-a44-HkocT5C69=sqPurEg4G-S=1BbFPWRVVjuV1eQ@mail.gmail.com>
On Wed, Oct 07, 2026 at 02:51:00PM +0530, Pavitrakumar Managutte wrote:
> Hi Eric,
> While bringing up the SPAcc async ahash hardware driver against
> 7.3-rc1, cmac(aes) and xcbc(aes) fail their self-tests during TFM
> allocation.
>
> I did some digging and it looks like this is due to the missing
> export_core/import_core functions in the cmac software
> implementations. I see that all other hash algos have
> export_core/import_core functions except cmacs. Is it intentional?
>
> For cmac(aes)/xcbc(aes) it fails. In crypto/ahash.c,
> crypto_ahash_init_tfm() allocates the fallback with:
>
> fb = crypto_alloc_ahash(name, CRYPTO_ALG_REQ_VIRT,
> CRYPTO_ALG_ASYNC | CRYPTO_ALG_REQ_VIRT |
> CRYPTO_AHASH_ALG_NO_EXPORT_CORE);
>
> i.e. it requires a fallback that is synchronous, virtual-address
> capable, and has NO_EXPORT_CORE clear.
>
> On our tree no cmac(aes)/xcbc(aes) provider satisfies that: with both
> CONFIG_CRYPTO_CMAC/XCBC=y and CONFIG_CRYPTO_LIB_AES_CBC_MACS=y,
> neither the classic crypto/cmac.c template nor the new AES-CMAC
> library shash implements export_core/import_core, so both report
> NO_EXPORT_CORE. The allocation finds no fallback candidate and returns
> -EINVAL:
>
> alg: hash: failed to allocate transform for spacc-cmac(aes): -22
>
> BTW for SPAcc incremental(init/update/final) path, we always use the
> software fallbacks since SPAcc hardware cannot export or import the
> intermediate MAC state. Herbert suggested this.
In hash algorithms like "cmac-aes-lib" that XOR pending data into the
state, there's no meaningful concept of the "core" state. So I do not
think cmac-aes-lib needs to be, or should, be changed.
crypto/cmac.c does buffer data separately from the state for some
reason. So sure, you could update it to support exporting and importing
the "core" state.
But the whole concept of drivers calling into crypto_ahash recursively
is broken anyway, as is the "core" state thing. A better way to
implement the fallback would be to just use the library functions.
Or just do not support this algorithm in the driver, as the CPU-based
implementation is almost always better than drivers like these anyway.
- Eric
prev parent reply other threads:[~2026-10-07 10:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 9:21 CMAC fallback failures from SPAcc driver Pavitrakumar Managutte
2026-10-07 10:24 ` 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=20261007102457.GA1695@quark \
--to=ebiggers@kernel.org \
--cc=Ross.Bannerman@synopsys.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=navami.telsang@vayavyalabs.com \
--cc=nazim.khan@vayavyalabs.com \
--cc=pavitrakumarm@vayavyalabs.com \
--cc=ruud.derwig@gf.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