Re: [PATCH v2 13/25] crypto: ccp: Add support to initialize the AMD-SP for SEV-SNP

Borislav Petkov
2024-01-29T17:58:56Z

On Thu, Jan 25, 2024 at 10:11:13PM -0600, Michael Roth wrote:
> diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
> index 006e4cdbeb78..8128de17f0f4 100644
> --- a/include/linux/psp-sev.h
> +++ b/include/linux/psp-sev.h
> @@ -790,10 +790,23 @@ struct sev_data_snp_shutdown_ex {
>
> #ifdef CONFIG_CRYPTO_DEV_SP_PSP
>
> +/**
> + * struct sev_platform_init_args
> + *
> + * @error: SEV firmware error code
> + * @probe: True if this is being called as part of CCP module probe, which
> + * will defer SEV_INIT/SEV_INIT_EX firmware initialization until needed
> + * unless psp_init_on_probe module param is set
> + */
> +struct sev_platform_init_args {
> + int error;
> + bool probe;
> +};

This struct definition cannot be under the ifdef, otherwise:

arch/x86/kvm/svm/sev.c: In function ‘sev_guest_init’:
arch/x86/kvm/svm/sev.c:267:33: error: passing argument 1 of ‘sev_platform_init’ from incompatible pointer type [-Werror=incompatible-pointer-types]
267 | ret = sev_platform_init(&init_args);
| ^~~~~~~~~~
| |
| struct sev_platform_init_args *
In file included from arch/x86/kvm/svm/sev.c:16:
./include/linux/psp-sev.h:952:42: note: expected ‘int *’ but argument is of type ‘struct sev_platform_init_args *’
952 | static inline int sev_platform_init(int *error) { return -ENODEV; }
| ~~~~~^~~~~
cc1: all warnings being treated as errors

---

on a 32-bit allmodconfig.

Build fix:

---

diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index beba10d6b39c..d0e184db9d37 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -797,8 +797,6 @@ struct sev_data_snp_commit {
u32 len;
} __packed;

-#ifdef CONFIG_CRYPTO_DEV_SP_PSP
-
/**
* struct sev_platform_init_args
*
@@ -812,6 +810,8 @@ struct sev_platform_init_args {
bool probe;
};

+#ifdef CONFIG_CRYPTO_DEV_SP_PSP
+
/**
* sev_platform_init - perform SEV INIT command
*
@@ -949,7 +949,7 @@ void snp_free_firmware_page(void *addr);
static inline int
sev_platform_status(struct sev_user_data_status *status, int *error) { return -ENODEV; }

-static inline int sev_platform_init(int *error) { return -ENODEV; }
+static inline int sev_platform_init(struct sev_platform_init_args *args) { return -ENODEV; }

static inline int
sev_guest_deactivate(struct sev_data_deactivate *data, int *error) { return -ENODEV; }

--
Regards/Gruss,
Boris.