diff mbox series

[v1,14/26] crypto: ccp: Provide API to issue SEV and SNP commands

Message ID 20231230161954.569267-15-michael.roth@amd.com
State Superseded
Headers show
Series Add AMD Secure Nested Paging (SEV-SNP) Initialization Support | expand

Commit Message

Michael Roth Dec. 30, 2023, 4:19 p.m. UTC
From: Brijesh Singh <brijesh.singh@amd.com>

Export sev_do_cmd() as a generic API for the hypervisor to issue
commands to manage an SEV and SNP guest. The commands for SEV and SNP
are defined in the SEV and SEV-SNP firmware specifications.

Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
[mdr: kernel-doc fixups]
Signed-off-by: Michael Roth <michael.roth@amd.com>
---
 drivers/crypto/ccp/sev-dev.c |  3 ++-
 include/linux/psp-sev.h      | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

Comments

Borislav Petkov Jan. 17, 2024, 9:48 a.m. UTC | #1
On Sat, Dec 30, 2023 at 10:19:42AM -0600, Michael Roth wrote:
> +/**
> + * sev_do_cmd - issue an SEV or an SEV-SNP command
> + *
> + * @cmd: SEV or SEV-SNP firmware command to issue
> + * @data: arguments for firmware command
> + * @psp_ret: SEV command return code
> + *
> + * Returns:
> + * 0 if the SEV successfully processed the command

More forgotten feedback:

---
diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index 0581f194cdd0..a356a7b7408e 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -922,7 +922,7 @@ int sev_guest_decommission(struct sev_data_decommission *data, int *error);
  * @psp_ret: SEV command return code
  *
  * Returns:
- * 0 if the SEV successfully processed the command
+ * 0 if the SEV device successfully processed the command
  * -%ENODEV    if the PSP device is not available
  * -%ENOTSUPP  if PSP device does not support SEV
  * -%ETIMEDOUT if the SEV command timed out

---

Also, pls add it to your TODO list as a very low prio item to fixup all
this complains about:

./scripts/kernel-doc -none include/linux/psp-sev.h

Thx.
diff mbox series

Patch

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 85634d4f8cfe..767f0ec3d5bb 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -431,7 +431,7 @@  static int __sev_do_cmd_locked(int cmd, void *data, int *psp_ret)
 	return ret;
 }
 
-static int sev_do_cmd(int cmd, void *data, int *psp_ret)
+int sev_do_cmd(int cmd, void *data, int *psp_ret)
 {
 	int rc;
 
@@ -441,6 +441,7 @@  static int sev_do_cmd(int cmd, void *data, int *psp_ret)
 
 	return rc;
 }
+EXPORT_SYMBOL_GPL(sev_do_cmd);
 
 static int __sev_init_locked(int *error)
 {
diff --git a/include/linux/psp-sev.h b/include/linux/psp-sev.h
index a39a9e5b5bc4..0581f194cdd0 100644
--- a/include/linux/psp-sev.h
+++ b/include/linux/psp-sev.h
@@ -914,6 +914,22 @@  int sev_guest_df_flush(int *error);
  */
 int sev_guest_decommission(struct sev_data_decommission *data, int *error);
 
+/**
+ * sev_do_cmd - issue an SEV or an SEV-SNP command
+ *
+ * @cmd: SEV or SEV-SNP firmware command to issue
+ * @data: arguments for firmware command
+ * @psp_ret: SEV command return code
+ *
+ * Returns:
+ * 0 if the SEV successfully processed the command
+ * -%ENODEV    if the PSP device is not available
+ * -%ENOTSUPP  if PSP device does not support SEV
+ * -%ETIMEDOUT if the SEV command timed out
+ * -%EIO       if PSP device returned a non-zero return code
+ */
+int sev_do_cmd(int cmd, void *data, int *psp_ret);
+
 void *psp_copy_user_blob(u64 uaddr, u32 len);
 
 #else	/* !CONFIG_CRYPTO_DEV_SP_PSP */
@@ -929,6 +945,9 @@  sev_guest_deactivate(struct sev_data_deactivate *data, int *error) { return -ENO
 static inline int
 sev_guest_decommission(struct sev_data_decommission *data, int *error) { return -ENODEV; }
 
+static inline int
+sev_do_cmd(int cmd, void *data, int *psp_ret) { return -ENODEV; }
+
 static inline int
 sev_guest_activate(struct sev_data_activate *data, int *error) { return -ENODEV; }