@@ -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;
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;
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
@@ -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);
#ifdef CONFIG_CRYPTO_DEV_SP_CCP
@@ -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
+ */
+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 }
+
static inline int
sev_platform_status(struct sev_user_data_status *status, int *error) { return -ENODEV; }