[v5,1/4] ccp: Name -1 return value as SEV_RET_NO_FW_CALL

Message ID 20221102151836.1310509-2-dionnaglaze@google.com
State New
Headers
Series Add throttling detection to sev-guest |

Commit Message

Dionna Amalie Glaze Nov. 2, 2022, 3:18 p.m. UTC
  The PSP can return a "firmware error" code of -1 in circumstances where
the PSP is not actually called. To make this protocol unambiguous, we
add a constant naming the return value.

From: Peter Gonda <pgonda@google.com>
Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Andy Lutomirsky <luto@kernel.org>

Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
---
 drivers/crypto/ccp/sev-dev.c | 2 +-
 include/uapi/linux/psp-sev.h | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
  

Comments

Tom Lendacky Nov. 2, 2022, 5:30 p.m. UTC | #1
On 11/2/22 10:43, Peter Gonda wrote:
> From: Dionna Glaze <dionnaglaze@google.com>
> 
> The PSP can return a "firmware error" code of -1 in circumstances where
> the PSP is not actually called. To make this protocol unambiguous, we
> add a constant naming the return value.
> 
> From: Peter Gonda <pgonda@google.com>
> Cc: Thomas Lendacky <Thomas.Lendacky@amd.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Joerg Roedel <jroedel@suse.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: Andy Lutomirsky <luto@kernel.org>
> 
> Signed-off-by: Dionna Glaze <dionnaglaze@google.com>
> 
> I think you can modify the author of this commit to be 'Peter Gonda
> <pgonda@google.com>' then include my Signed-off-by.
> 

Since you have to resend for the proper Signed-off-by: chain, the subject 
line should really be: crypto: ccp - Name -1 ...

and you missed copying the other CCP driver maintainer.

It's always good to do a git log on the file(s) you're updating to get an 
idea of the appropriate prefix to use.

Thanks,
Tom

>
  
Borislav Petkov Nov. 2, 2022, 6:46 p.m. UTC | #2
On Wed, Nov 02, 2022 at 12:30:17PM -0500, Tom Lendacky wrote:
> It's always good to do a git log on the file(s) you're updating to get an
> idea of the appropriate prefix to use.

You mean:

git show <commit id> | ./scripts/get_maintainer.pl 
Brijesh Singh <brijesh.singh@amd.com> (supporter:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...)
Tom Lendacky <thomas.lendacky@amd.com> (supporter:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...)
John Allen <john.allen@amd.com> (supporter:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER)
Herbert Xu <herbert@gondor.apana.org.au> (maintainer:CRYPTO API)
"David S. Miller" <davem@davemloft.net> (maintainer:CRYPTO API)
linux-crypto@vger.kernel.org (open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - SE...)
linux-kernel@vger.kernel.org (open list)

Btw, I think we need to remove Brijesh...
  

Patch

diff --git a/drivers/crypto/ccp/sev-dev.c b/drivers/crypto/ccp/sev-dev.c
index 06fc7156c04f..97eb3544ab36 100644
--- a/drivers/crypto/ccp/sev-dev.c
+++ b/drivers/crypto/ccp/sev-dev.c
@@ -444,7 +444,7 @@  static int __sev_platform_init_locked(int *error)
 {
 	struct psp_device *psp = psp_master;
 	struct sev_device *sev;
-	int rc = 0, psp_ret = -1;
+	int rc = 0, psp_ret = SEV_RET_NO_FW_CALL;
 	int (*init_function)(int *error);
 
 	if (!psp || !psp->sev_data)
diff --git a/include/uapi/linux/psp-sev.h b/include/uapi/linux/psp-sev.h
index 91b4c63d5cbf..1ad7f0a7e328 100644
--- a/include/uapi/linux/psp-sev.h
+++ b/include/uapi/linux/psp-sev.h
@@ -36,6 +36,13 @@  enum {
  * SEV Firmware status code
  */
 typedef enum {
+	/*
+	 * This error code is not in the SEV spec but is added to convey that
+	 * there was an error that prevented the SEV Firmware from being called.
+	 * This is (u32)-1 since the firmware error code is represented as a
+	 * 32-bit integer.
+	 */
+	SEV_RET_NO_FW_CALL = 0xffffffff,
 	SEV_RET_SUCCESS = 0,
 	SEV_RET_INVALID_PLATFORM_STATE,
 	SEV_RET_INVALID_GUEST_STATE,