From: Ralf Lici <ralf@mandelbit.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, Antoine Tenart <atenart@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH crypto 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions
Date: Wed, 23 Sep 2026 11:13:17 +0200 [thread overview]
Message-ID: <20260923091318.194633-1-ralf@mandelbit.com> (raw)
In-Reply-To: <arOOmSnC1NxvG1nw@gondor.apana.org.au>
On Wed, 23 Sep 2026 18:32:25 +1000, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> On Wed, Sep 23, 2026 at 09:26:46AM +0200, Ralf Lici wrote:
> >
> > No, the regions do not need to occupy separate sg entries, the patch
> > selects the direction conservatively for the whole entry.
> >
> > For a completely linear in-place request, the entry overlaps the output
> > range and is therefore mapped DMA_BIDIRECTIONAL. For an out-of-place
> > request, the source is mapped DMA_TO_DEVICE. For example, a single
> > destination entry covering:
> >
> > [ AAD | ciphertext | tag ]
> >
> > has a logical output range covering only:
> >
> > [ ciphertext | tag ]
> >
> > Since the entry also contains the preserved AAD prefix, it is classified
> > as mixed and mapped DMA_BIDIRECTIONAL. The same applies if an entry
> > extends beyond the end of the output range.
>
> Wait, I think this suggests that the caller is giving us bogus
> input.
>
> If the input is out-of-place, it shouldn't contain overlapping
> data.
>
> Which caller is this?
>
> Thanks,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
>
Sorry, that was a misunderstanding, used "overlap" poorly. I only meant
that one sg entry can contain both the reserved AAD prefix and the bytes
written by the device. I did not mean that the source and destination
share memory.
There is no caller to identify for that particular single-entry layout,
it was only a hypothetical example in response to your question. Even
for out-of-place AEAD, the destination starts with space reserved for
the associated data (as documented in the comment at the top of
include/crypto/aead.h). A single linear destination entry can therefore
contain both that reserved prefix, which the device does not write, and
the ciphertext and tag, which it does write. Because the DMA direction
applies to the whole entry, such a mixed entry is mapped
DMA_BIDIRECTIONAL.
--
Ralf Lici
Mandelbit Srl
prev parent reply other threads:[~2026-09-23 9:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 11:32 [PATCH crypto 0/2] crypto: safexcel: fix AEAD DMA mapping and cleanup Ralf Lici
2026-09-15 11:32 ` [PATCH crypto 1/2] crypto: safexcel - Avoid unmapping failed DMA mappings Ralf Lici
2026-09-15 11:32 ` [PATCH crypto 2/2] crypto: safexcel - Map AEAD buffers with accurate DMA directions Ralf Lici
2026-09-23 5:30 ` Herbert Xu
2026-09-23 7:26 ` Ralf Lici
2026-09-23 8:32 ` Herbert Xu
2026-09-23 9:13 ` Ralf Lici [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=20260923091318.194633-1-ralf@mandelbit.com \
--to=ralf@mandelbit.com \
--cc=atenart@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.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®