From: Michael Roth <michael.roth@amd.com>
To: <linux-crypto@vger.kernel.org>
Cc: <herbert@gondor.apana.org.au>, <davem@davemloft.net>,
<ackerleytng@google.com>, <thomas.lendacky@amd.com>,
<ashish.kalra@amd.com>, <aik@amd.com>, <seanjc@google.com>,
<pbonzini@redhat.com>
Subject: [PATCH v3 0/1] crypto: ccp - Make sev_cmd_mutex more granular
Date: Wed, 21 Oct 2026 14:15:16 -0500 [thread overview]
Message-ID: <20261021192434.1924950-1-michael.roth@amd.com> (raw)
This patchset is also available at:
https://github.com/amdese/linux/commits/ccp-mutex-rework-v3
and is based on cryptodev-2.6 master (178aff4cf425).
v1: https://lore.kernel.org/linux-crypto/20261014132145.1726322-1-michael.roth@amd.com/
v2: https://lore.kernel.org/linux-crypto/20261016041109.1778673-1-michael.roth@amd.com/
v3:
- drop all unnecessary refactorings to make patches more appropriate for 7.4
(Herbert, Sean)
- retest CCP both with and without kvm/queue in-place conversion support
present, re-verify no deadlocks/regressions. Testing done primarilly with
the following kselftest:
https://github.com/AMDESE/linux/commit/33ddcbd756b3db5bd2bd5737e48c9084e715cd38
- rebase on latest cryptodev master (178aff4cf425)
OVERVIEW
--------
The current code makes very coarse usage of the sev_cmd_mutex; for SEV
firmware ioctls, it is essentially taken upon entry, and ends up wrapping
a lot of potentially time-consuming prep/cleanup work that may need to be
done before/after issuing the actual firmware call, which is the main
thing the mutex is meant to protect.
Additionally, some of that prep work involves
copy_from_user()/copy_to_user() calls which can generate page faults and
unecessarily lead to potential deadlock scenarios. No known case exists
in current upstream, but with the upcoming KVM/guest_memfd support for
in-place conversion of the same PFN between shared/private state (which
is currently targeted for kernel 7.4), a special fault handler is added
that could theoretically deadlock if a malicious user tries to use
guest_memfd pages as the source/target of target of said
copy_from_user()/copy_to_user() scenarios[1].
So this series is a prereq to enabling the above-mentioned KVM/guest_memfd
in-place conversion support on SNP-enabled hosts, as well as a cleanup
for SEV ioctls in general.
Thank you to Sean for suggesting this approach and Ackerley for wrangling
the changes into a (hopefully) presentable patchset.
REFERENCES
----------
[1] https://lore.kernel.org/kvm/asz8GKNO9aQANr5E@google.com/
Thanks!
-Mike
----------------------------------------------------------------
Michael Roth (1):
crypto: ccp - Make usage of sev_cmd_mutex more granular
drivers/crypto/ccp/sev-dev.c | 101 ++++++++++++++++++++++++++++++++-----------
1 file changed, 76 insertions(+), 25 deletions(-)
next reply other threads:[~2026-10-21 19:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 19:15 Michael Roth [this message]
2026-10-21 19:15 ` [PATCH v3 1/1] crypto: ccp - Make usage of sev_cmd_mutex more granular Michael Roth
2026-10-22 16:18 ` Sean Christopherson
2026-10-22 21:09 ` Tom Lendacky
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=20261021192434.1924950-1-michael.roth@amd.com \
--to=michael.roth@amd.com \
--cc=ackerleytng@google.com \
--cc=aik@amd.com \
--cc=ashish.kalra@amd.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=thomas.lendacky@amd.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