* [PATCH 2/2] crypto: ccp: Update return values for some unit tests
2024-02-07 21:54 [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() Mario Limonciello
@ 2024-02-07 21:54 ` Mario Limonciello
2024-02-08 17:24 ` [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() Tim Van Patten
2024-02-09 19:05 ` Tom Lendacky
2 siblings, 0 replies; 4+ messages in thread
From: Mario Limonciello @ 2024-02-07 21:54 UTC (permalink / raw)
To: Herbert Xu
Cc: Mario Limonciello, Tom Lendacky, John Allen,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - DB...,
open list
Until authenticated the platform enforces a state machine. Adjust
unit tests with this in mind.
Correct the return codes for all the states the unit tests ends up
hitting:
* Set Param / Get Param: DBC_ERROR_BAD_STATE
* Set UID: DBC_ERROR_SIGNATURE_INVALID
* Authencitated Nonce: DBC_ERROR_BAD_PARAMETERS
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
tools/crypto/ccp/test_dbc.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/crypto/ccp/test_dbc.py b/tools/crypto/ccp/test_dbc.py
index 79de3638a01a..bb0e671be96d 100755
--- a/tools/crypto/ccp/test_dbc.py
+++ b/tools/crypto/ccp/test_dbc.py
@@ -138,12 +138,14 @@ class TestInvalidSignature(DynamicBoostControlTest):
def test_authenticated_nonce(self) -> None:
"""fetch authenticated nonce"""
+ get_nonce(self.d, None)
with self.assertRaises(OSError) as error:
get_nonce(self.d, self.signature)
- self.assertEqual(error.exception.errno, 1)
+ self.assertEqual(error.exception.errno, 22)
def test_set_uid(self) -> None:
"""set uid"""
+ get_nonce(self.d, None)
with self.assertRaises(OSError) as error:
set_uid(self.d, self.uid, self.signature)
self.assertEqual(error.exception.errno, 1)
@@ -152,13 +154,13 @@ class TestInvalidSignature(DynamicBoostControlTest):
"""fetch a parameter"""
with self.assertRaises(OSError) as error:
process_param(self.d, PARAM_GET_SOC_PWR_CUR, self.signature)
- self.assertEqual(error.exception.errno, 1)
+ self.assertEqual(error.exception.errno, 11)
def test_set_param(self) -> None:
"""set a parameter"""
with self.assertRaises(OSError) as error:
process_param(self.d, PARAM_SET_PWR_CAP, self.signature, 1000)
- self.assertEqual(error.exception.errno, 1)
+ self.assertEqual(error.exception.errno, 11)
class TestUnFusedSystem(DynamicBoostControlTest):
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg()
2024-02-07 21:54 [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() Mario Limonciello
2024-02-07 21:54 ` [PATCH 2/2] crypto: ccp: Update return values for some unit tests Mario Limonciello
@ 2024-02-08 17:24 ` Tim Van Patten
2024-02-09 19:05 ` Tom Lendacky
2 siblings, 0 replies; 4+ messages in thread
From: Tim Van Patten @ 2024-02-08 17:24 UTC (permalink / raw)
To: Mario Limonciello
Cc: Herbert Xu, Tom Lendacky, John Allen,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - DB...,
open list
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>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg()
2024-02-07 21:54 [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() Mario Limonciello
2024-02-07 21:54 ` [PATCH 2/2] crypto: ccp: Update return values for some unit tests Mario Limonciello
2024-02-08 17:24 ` [PATCH 1/2] crypto: ccp: Avoid discarding errors in psp_send_platform_access_msg() Tim Van Patten
@ 2024-02-09 19:05 ` Tom Lendacky
2 siblings, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2024-02-09 19:05 UTC (permalink / raw)
To: Mario Limonciello, Herbert Xu
Cc: John Allen,
open list:AMD CRYPTOGRAPHIC COPROCESSOR (CCP) DRIVER - DB...,
open list, Tim Van Patten
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;
^ permalink raw reply [flat|nested] 4+ messages in thread