Skip to content

Commit efb339a

Browse files
pgondabp3tk0v
authored andcommitted
crypto: ccp - Name -1 return value as SEV_RET_NO_FW_CALL
The PSP can return a "firmware error" code of -1 in circumstances where the PSP has not actually been called. To make this protocol unambiguous, name the value SEV_RET_NO_FW_CALL. [ bp: Massage a bit. ] Signed-off-by: Peter Gonda <pgonda@google.com> Signed-off-by: Dionna Glaze <dionnaglaze@google.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Link: https://lore.kernel.org/r/20221207010210.2563293-2-dionnaglaze@google.com
1 parent e8d018d commit efb339a

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

Documentation/virt/coco/sev-guest.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ along with a description:
4040
The guest ioctl should be issued on a file descriptor of the /dev/sev-guest device.
4141
The ioctl accepts struct snp_user_guest_request. The input and output structure is
4242
specified through the req_data and resp_data field respectively. If the ioctl fails
43-
to execute due to a firmware error, then fw_err code will be set otherwise the
44-
fw_err will be set to 0x00000000000000ff.
43+
to execute due to a firmware error, then fw_err code will be set. Otherwise, fw_err
44+
will be set to 0x00000000ffffffff, i.e., the lower 32-bits are -1.
4545

4646
The firmware checks that the message sequence counter is one greater than
4747
the guests message sequence counter. If guest driver fails to increment message

drivers/crypto/ccp/sev-dev.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ static int __sev_init_ex_locked(int *error)
444444

445445
static int __sev_platform_init_locked(int *error)
446446
{
447+
int rc = 0, psp_ret = SEV_RET_NO_FW_CALL;
447448
struct psp_device *psp = psp_master;
448-
struct sev_device *sev;
449-
int rc = 0, psp_ret = -1;
450449
int (*init_function)(int *error);
450+
struct sev_device *sev;
451451

452452
if (!psp || !psp->sev_data)
453453
return -ENODEV;
@@ -475,9 +475,11 @@ static int __sev_platform_init_locked(int *error)
475475
* initialization function should succeed by replacing the state
476476
* with a reset state.
477477
*/
478-
dev_err(sev->dev, "SEV: retrying INIT command because of SECURE_DATA_INVALID error. Retrying once to reset PSP SEV state.");
478+
dev_err(sev->dev,
479+
"SEV: retrying INIT command because of SECURE_DATA_INVALID error. Retrying once to reset PSP SEV state.");
479480
rc = init_function(&psp_ret);
480481
}
482+
481483
if (error)
482484
*error = psp_ret;
483485

include/uapi/linux/psp-sev.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ enum {
3636
* SEV Firmware status code
3737
*/
3838
typedef enum {
39+
/*
40+
* This error code is not in the SEV spec. Its purpose is to convey that
41+
* there was an error that prevented the SEV firmware from being called.
42+
* The SEV API error codes are 16 bits, so the -1 value will not overlap
43+
* with possible values from the specification.
44+
*/
45+
SEV_RET_NO_FW_CALL = -1,
3946
SEV_RET_SUCCESS = 0,
4047
SEV_RET_INVALID_PLATFORM_STATE,
4148
SEV_RET_INVALID_GUEST_STATE,

0 commit comments

Comments
 (0)