From: Sean Christopherson <seanjc@google.com>
To: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Dionna Amalie Glaze <dionnaglaze@google.com>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-coco@lists.linux.dev, Ashish Kalra <ashish.kalra@amd.com>,
John Allen <john.allen@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Michael Roth <michael.roth@amd.com>,
Luis Chamberlain <mcgrof@kernel.org>,
Russ Weight <russ.weight@linux.dev>,
Danilo Krummrich <dakr@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Tianfei zhang <tianfei.zhang@intel.com>,
Alexey Kardashevskiy <aik@amd.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v5 09/10] KVM: SVM: Use new ccp GCTX API
Date: Wed, 13 Nov 2024 10:22:38 -0800 [thread overview]
Message-ID: <ZzTubiWtfmNTPlLK@google.com> (raw)
In-Reply-To: <308f26c5-d47c-df63-19eb-59ebbf1e16dd@amd.com>
On Tue, Nov 12, 2024, Tom Lendacky wrote:
> On 11/12/24 13:33, Dionna Amalie Glaze wrote:
> >>> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> >>> index cea41b8cdabe4..d7cef84750b33 100644
> >>> --- a/arch/x86/kvm/svm/sev.c
> >>> +++ b/arch/x86/kvm/svm/sev.c
> >>> @@ -89,7 +89,7 @@ static unsigned int nr_asids;
> >>> static unsigned long *sev_asid_bitmap;
> >>> static unsigned long *sev_reclaim_asid_bitmap;
> >>>
> >>> -static int snp_decommission_context(struct kvm *kvm);
> >>> +static int kvm_decommission_snp_context(struct kvm *kvm);
> >>
> >> Why the name change? It seems like it just makes the patch a bit harder
> >> to follow since there are two things going on.
> >>
> >
> > KVM and ccp both seem to like to name their functions starting with
> > sev_ or snp_, and it's particularly hard to determine provenance.
> >
> > snp_decommision_context and sev_snp_guest_decommission... which is
> > from where? It's weird to me.
>
> I guess I don't see the problem, a quick git grep -w of the name will
> show you where each is. Its a static function in the file, so if
> anything just changing/shortening the name to decommission_snp_context()
Eh, that creates just as many problems as it solves, because it mucks up the
namespace and leads to discontinuity between the decommission helper and things
like snp_launch_update_vmsa() and snp_launch_finish().
I agree that there isn't a strong need to fixup static symbols. That said, I do
think drivers/crypto/ccp/sev-dev.c in particular needs a different namespace, and
needs to use it consistently, to make it somewhat obvious that it's (almost) all
about the PSP/ASP.
But IMO, an even bigger mess in that area is the lack of consistency in the APIs
themselves. E.g. this code where KVM uses sev_do_cmd() directly for SNP, but
bounces through a wrapper for !SNP. Eww.
wbinvd_on_all_cpus();
if (sev_snp_enabled)
ret = sev_do_cmd(SEV_CMD_SNP_DF_FLUSH, NULL, &error);
else
ret = sev_guest_df_flush(&error);
up_write(&sev_deactivate_lock);
And then KVM has snp_page_reclaim(), but the PSP/ASP driver has snp_reclaim_pages().
So if we want to start renaming things, I vote to go a step further and clean up
the APIs, e.g. with a goal of eliminating sev_do_cmd(), and possibly of making
the majority of the PSP-defined structures in include/linux/psp-sev.h "private"
to the PSP/ASP driver.
> would be better (especially since nothing in the svm directory should
> have a name that starts with kvm_).
+1 to not using "kvm_". KVM often uses "kvm_" to differentiate globally visible
symbols from local (static) symbols. I.e. prepending "kvm_" just trades one
confusing name for another.
next prev parent reply other threads:[~2024-11-13 18:22 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 23:24 [PATCH v5 00/10] Add SEV firmware hotloading Dionna Glaze
2024-11-07 23:24 ` [PATCH v5 01/10] KVM: SVM: Fix gctx page leak on invalid inputs Dionna Glaze
2024-11-07 23:24 ` [PATCH v5 02/10] KVM: SVM: Fix snp_context_create error reporting Dionna Glaze
2024-11-07 23:24 ` [PATCH v5 03/10] firmware_loader: Move module refcounts to allow unloading Dionna Glaze
2024-11-07 23:24 ` [PATCH v5 04/10] crypto: ccp: Fix uapi definitions of PSP errors Dionna Glaze
2024-11-08 16:14 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-07 23:24 ` [PATCH v5 05/10] crypto: ccp: Add GCTX API to track ASID assignment Dionna Glaze
2024-11-08 17:24 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-11 17:13 ` Tom Lendacky
2024-11-11 21:16 ` Kalra, Ashish
2024-11-11 21:35 ` Dionna Amalie Glaze
2024-11-11 21:48 ` Kalra, Ashish
2024-11-07 23:24 ` [PATCH v5 06/10] crypto: ccp: Add DOWNLOAD_FIRMWARE_EX support Dionna Glaze
2024-11-08 15:42 ` Dionna Amalie Glaze
2024-11-08 17:44 ` Tom Lendacky
2024-11-08 22:13 ` Dionna Amalie Glaze
2024-11-11 22:10 ` Kalra, Ashish
2024-11-11 22:37 ` Dionna Amalie Glaze
2024-11-07 23:24 ` [PATCH v5 07/10] crypto: ccp: Add preferred access checking method Dionna Glaze
2024-11-11 22:46 ` Tom Lendacky
2024-11-12 19:47 ` Dionna Amalie Glaze
2024-11-12 21:08 ` Tom Lendacky
2024-11-07 23:24 ` [PATCH v5 08/10] KVM: SVM: move sev_issue_cmd_external_user to new API Dionna Glaze
2024-11-12 15:52 ` Tom Lendacky
2024-11-12 19:30 ` Dionna Amalie Glaze
2024-11-12 22:06 ` Tom Lendacky
2024-11-07 23:24 ` [PATCH v5 09/10] KVM: SVM: Use new ccp GCTX API Dionna Glaze
2024-11-12 15:53 ` Tom Lendacky
2024-11-12 19:33 ` Dionna Amalie Glaze
2024-11-12 21:26 ` Tom Lendacky
2024-11-13 18:22 ` Sean Christopherson [this message]
2024-11-07 23:24 ` [PATCH v5 10/10] KVM: SVM: Delay legacy platform initialization on SNP Dionna Glaze
2024-11-12 15:56 ` 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=ZzTubiWtfmNTPlLK@google.com \
--to=seanjc@google.com \
--cc=aik@amd.com \
--cc=ashish.kalra@amd.com \
--cc=bp@alien8.de \
--cc=dakr@redhat.com \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dionnaglaze@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rafael@kernel.org \
--cc=russ.weight@linux.dev \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tianfei.zhang@intel.com \
--cc=x86@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.