Skip to content

Commit 0e8fca2

Browse files
superm1herbertx
authored andcommitted
crypto: ccp - Avoid discarding errors in psp_send_platform_access_msg()
Errors can potentially occur in the "processing" of PSP commands or commands can be processed successfully but still return an error code in the header. This second case was being discarded because PSP communication worked but the command returned an error code in the payload header. Capture both cases and return them to the caller as -EIO for the caller to investigate. The caller can detect the latter by looking at `req->header->status`. Reported-and-tested-by: Tim Van Patten <timvp@google.com> Fixes: 7ccc4f4 ("crypto: ccp - Add support for an interface for platform features") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 53cc9ba commit 0e8fca2

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

drivers/crypto/ccp/platform-access.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,16 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg,
118118
goto unlock;
119119
}
120120

121-
/* Store the status in request header for caller to investigate */
121+
/*
122+
* Read status from PSP. If status is non-zero, it indicates an error
123+
* occurred during "processing" of the command.
124+
* If status is zero, it indicates the command was "processed"
125+
* successfully, but the result of the command is in the payload.
126+
* Return both cases to the caller as -EIO to investigate.
127+
*/
122128
cmd_reg = ioread32(cmd);
123-
req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg);
129+
if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg))
130+
req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg);
124131
if (req->header.status) {
125132
ret = -EIO;
126133
goto unlock;

0 commit comments

Comments
 (0)