Message ID | 20240207215439.95871-1-mario.limonciello@amd.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Herbert Xu |
Headers | show |
Series | [1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() | expand |
On Wed, Feb 7, 2024 at 2:55 PM Mario Limonciello <mario.limonciello@amd.com> wrote: > > When the PSP_CMDRESP_STS field has an error set, the details of the > error are in `req->header->status`, and the caller will want to look > at them. But if there is no error set then caller may want to check > `req->header->status` separately. > > Stop discarding these errors. > > Reported-by: Tim Van Patten <timvp@google.com> > Fixes: 7ccc4f4e2e50 ("crypto: ccp - Add support for an interface for platform features") > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > drivers/crypto/ccp/platform-access.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c > index 94367bc49e35..792ae8d5b11a 100644 > --- a/drivers/crypto/ccp/platform-access.c > +++ b/drivers/crypto/ccp/platform-access.c > @@ -120,7 +120,8 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, > > /* Store the status in request header for caller to investigate */ > cmd_reg = ioread32(cmd); > - req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); > + if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg)) > + req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); > if (req->header.status) { > ret = -EIO; > goto unlock; > -- > 2.34.1 > Tested-by: Tim Van Patten <timvp@google.com>
On 2/7/24 15:54, Mario Limonciello wrote: > When the PSP_CMDRESP_STS field has an error set, the details of the > error are in `req->header->status`, and the caller will want to look > at them. But if there is no error set then caller may want to check > `req->header->status` separately. > > Stop discarding these errors. This needs a more thorough commit message. It took me a bit to understand that the value in the request header could be set to something specific to the request even though the command response status comes back as zero. Which also indicates that the code below should have a nice comment about why you only set req->header.status when PSP_CMDRESP_STS is non-zero (in other words the existing comment needs to be re-worded). Thanks, Tom > > Reported-by: Tim Van Patten <timvp@google.com> > Fixes: 7ccc4f4e2e50 ("crypto: ccp - Add support for an interface for platform features") > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > drivers/crypto/ccp/platform-access.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c > index 94367bc49e35..792ae8d5b11a 100644 > --- a/drivers/crypto/ccp/platform-access.c > +++ b/drivers/crypto/ccp/platform-access.c > @@ -120,7 +120,8 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, > > /* Store the status in request header for caller to investigate */ > cmd_reg = ioread32(cmd); > - req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); > + if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg)) > + req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); > if (req->header.status) { > ret = -EIO; > goto unlock;
diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c index 94367bc49e35..792ae8d5b11a 100644 --- a/drivers/crypto/ccp/platform-access.c +++ b/drivers/crypto/ccp/platform-access.c @@ -120,7 +120,8 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, /* Store the status in request header for caller to investigate */ cmd_reg = ioread32(cmd); - req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); + if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg)) + req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg); if (req->header.status) { ret = -EIO; goto unlock;
When the PSP_CMDRESP_STS field has an error set, the details of the error are in `req->header->status`, and the caller will want to look at them. But if there is no error set then caller may want to check `req->header->status` separately. Stop discarding these errors. Reported-by: Tim Van Patten <timvp@google.com> Fixes: 7ccc4f4e2e50 ("crypto: ccp - Add support for an interface for platform features") Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> --- drivers/crypto/ccp/platform-access.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)