From: Tom Lendacky <thomas.lendacky@amd.com>
To: Ashish Kalra <Ashish.Kalra@amd.com>,
seanjc@google.com, pbonzini@redhat.com, tglx@linutronix.de,
mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
x86@kernel.org, hpa@zytor.com, john.allen@amd.com,
herbert@gondor.apana.org.au, davem@davemloft.net,
joro@8bytes.org, suravee.suthikulpanit@amd.com, will@kernel.org,
robin.murphy@arm.com
Cc: michael.roth@amd.com, dionnaglaze@google.com,
vasant.hegde@amd.com, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
linux-coco@lists.linux.dev, iommu@lists.linux.dev
Subject: Re: [PATCH 2/4] crypto: ccp: Add external API interface for PSP module initialization
Date: Wed, 22 Jan 2025 09:53:14 -0600 [thread overview]
Message-ID: <a65c1d6b-63eb-064f-b947-aa09e5580c05@amd.com> (raw)
In-Reply-To: <2a2c2b55c2b137b777ef5beab8e2a814f0c268a7.1737505394.git.ashish.kalra@amd.com>
On 1/21/25 19:00, Ashish Kalra wrote:
> From: Sean Christopherson <seanjc@google.com>
>
> Add a new external API interface for PSP module initialization which
> allows PSP SEV driver to be initialized explicitly before proceeding
> with SEV/SNP initialization with KVM if KVM is built-in as the
> dependency between modules is not supported/handled by the initcall
> infrastructure and the dependent PSP module is not implicitly loaded
> before KVM module if KVM module is built-in.
This is big run on sentence. Please start off describing the issue and
why this fixes it.
>
> Co-developed-by: Ashish Kalra <ashish.kalra@amd.com>
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Your SOB should come after Sean's.
> Signed-off-by: Sean Christopherson <seanjc@google.com>
> ---
> drivers/crypto/ccp/sp-dev.c | 12 ++++++++++++
> drivers/crypto/ccp/sp-dev.h | 1 +
> include/linux/psp-sev.h | 11 +++++++++++
> 3 files changed, 24 insertions(+)
>
> diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
> index 7eb3e4668286..a0cdc03984cb 100644
> --- a/drivers/crypto/ccp/sp-dev.c
> +++ b/drivers/crypto/ccp/sp-dev.c
> @@ -253,8 +253,12 @@ struct sp_device *sp_get_psp_master_device(void)
> static int __init sp_mod_init(void)
> {
> #ifdef CONFIG_X86
> + static bool initialized;
This definition is within CONFIG_X86, but...
> int ret;
>
> + if (initialized)
> + return 0;
> +
> ret = sp_pci_init();
> if (ret)
> return ret;
> @@ -263,6 +267,7 @@ static int __init sp_mod_init(void)
> psp_pci_init();
> #endif
>
> + initialized = true;
Add a blank line.
> return 0;
> #endif
>
> @@ -279,6 +284,13 @@ static int __init sp_mod_init(void)
> return -ENODEV;
> }
>
> +#if IS_BUILTIN(CONFIG_KVM_AMD) && IS_ENABLED(CONFIG_KVM_AMD_SEV)
> +int __init sev_module_init(void)
> +{
> + return sp_mod_init();
> +}
> +#endif
> +
> static void __exit sp_mod_exit(void)
> {
> #ifdef CONFIG_X86
> diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h
> index 6f9d7063257d..3f5f7491bec1 100644
> --- a/drivers/crypto/ccp/sp-dev.h
> +++ b/drivers/crypto/ccp/sp-dev.h
> @@ -148,6 +148,7 @@ int sp_request_psp_irq(struct sp_device *sp, irq_handler_t handler,
> const char *name, void *data);
> void sp_free_psp_irq(struct sp_device *sp, void *data);
> struct sp_device *sp_get_psp_master_device(void);
> +int __init sev_module_init(void);
Why is this declared both here and below? Please just have it one place.
>
> #ifdef CONFIG_CRYPTO_DEV_SP_CCP
>
> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
> index 903ddfea8585..1cf197fca93d 100644
> --- a/include/linux/psp-sev.h
> +++ b/include/linux/psp-sev.h
> @@ -814,6 +814,15 @@ struct sev_data_snp_commit {
>
> #ifdef CONFIG_CRYPTO_DEV_SP_PSP
>
> +/**
> + * sev_module_init - perform PSP module initialization
> + *
> + * Returns:
> + * 0 if the PSP module is successfully initialized
> + * -%ENODEV if the PSP module initialization fails
There are more possible return values in the sp_mod_init() path than
just ENODEV. So maybe just say that it returns a negative value on error
unless you want to chase them all down.
> + */
> +int __init sev_module_init(void);
> +
> /**
> * sev_platform_init - perform SEV INIT command
> *
> @@ -948,6 +957,8 @@ void snp_free_firmware_page(void *addr);
>
> #else /* !CONFIG_CRYPTO_DEV_SP_PSP */
>
> +static inline int __init sev_module_init(void) { return -ENODEV }
Remove the "__init".
Although I'm not sure this is even needed since it will only be called
by KVM and CONFIG_KVM_AMD_SEV depends on CONFIG_CRYPTO_DEV_SP_PSP. Plus,
the function itself is only defined under a specific config.
Thanks,
Tom
> +
> static inline int
> sev_platform_status(struct sev_user_data_status *status, int *error) { return -ENODEV; }
>
next prev parent reply other threads:[~2025-01-22 15:53 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 0:59 [PATCH 0/4] Fix broken SNP support with KVM module built-in Ashish Kalra
2025-01-22 1:00 ` [PATCH 1/4] iommu/amd: Check SNP support before enabling IOMMU Ashish Kalra
2025-01-22 15:22 ` Tom Lendacky
2025-01-22 17:07 ` Vasant Hegde
2025-01-24 21:46 ` Kalra, Ashish
2025-01-25 0:39 ` Sean Christopherson
2025-01-27 20:43 ` Kalra, Ashish
2025-01-27 21:12 ` Sean Christopherson
2025-01-29 9:24 ` Vasant Hegde
2025-01-22 1:00 ` [PATCH 2/4] crypto: ccp: Add external API interface for PSP module initialization Ashish Kalra
2025-01-22 15:53 ` Tom Lendacky [this message]
2025-01-22 1:00 ` [PATCH 3/4] KVM: SVM: Ensure PSP module initialized before built-in KVM module Ashish Kalra
2025-01-22 15:58 ` Tom Lendacky
2025-01-22 1:00 ` [PATCH 4/4] x86/sev: Fix broken SNP support with KVM module built-in Ashish Kalra
2025-01-22 16:07 ` 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=a65c1d6b-63eb-064f-b947-aa09e5580c05@amd.com \
--to=thomas.lendacky@amd.com \
--cc=Ashish.Kalra@amd.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=dionnaglaze@google.com \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux.dev \
--cc=john.allen@amd.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=robin.murphy@arm.com \
--cc=seanjc@google.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tglx@linutronix.de \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
--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 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®