From 555551c98856c7a43ae9ab78bba11a2d5058fd81 Mon Sep 17 00:00:00 2001 From: Felix Held Date: Tue, 22 Oct 2024 23:06:34 +0200 Subject: soc/amd/common/block/psp: fix logic bug in psp_get_* functions The functions psp_get_ftpm_capabilties, psp_get_hsti_state, and psp_get_psp_capabilities which were added in commit 5e7ab1a23346 ("soc/amd/common/psp: add helper functions to retrieve capability bits") have a bug in the 'cmd_status' error handling logic. In case of an error, 'cmd_status' is non-zero, while the check somehow expected the opposite. Fix the bug by returning an error if 'cmd_status' is non-zero. Change-Id: Iafcd185ec4a8a4c0e463b0ac5bac3ef78a0af305 Signed-off-by: Felix Held Reviewed-on: https://review.coreboot.org/c/coreboot/+/84836 Reviewed-by: Ana Carolina Cabral Tested-by: build bot (Jenkins) Reviewed-by: Elyes Haouas --- src/soc/amd/common/block/psp/psp.c | 4 ++-- src/soc/amd/common/block/psp/psp_gen2.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src/soc') diff --git a/src/soc/amd/common/block/psp/psp.c b/src/soc/amd/common/block/psp/psp.c index 008052b729..9ad04e1ce6 100644 --- a/src/soc/amd/common/block/psp/psp.c +++ b/src/soc/amd/common/block/psp/psp.c @@ -71,7 +71,7 @@ enum cb_err psp_get_ftpm_capabilties(uint32_t *capabilities) /* buffer's status shouldn't change but report it if it does */ psp_print_cmd_status(cmd_status, &buffer.header); - if (!cmd_status) + if (cmd_status) return CB_ERR; *capabilities = read32(&buffer.capabilities); @@ -94,7 +94,7 @@ enum cb_err psp_get_hsti_state(uint32_t *state) /* buffer's status shouldn't change but report it if it does */ psp_print_cmd_status(cmd_status, &buffer.header); - if (!cmd_status) + if (cmd_status) return CB_ERR; *state = read32(&buffer.state); diff --git a/src/soc/amd/common/block/psp/psp_gen2.c b/src/soc/amd/common/block/psp/psp_gen2.c index 2113b5725b..21c1f2a735 100644 --- a/src/soc/amd/common/block/psp/psp_gen2.c +++ b/src/soc/amd/common/block/psp/psp_gen2.c @@ -193,7 +193,7 @@ enum cb_err psp_get_psp_capabilities(uint32_t *capabilities) /* buffer's status shouldn't change but report it if it does */ psp_print_cmd_status(cmd_status, &buffer.header); - if (!cmd_status) + if (cmd_status) return CB_ERR; *capabilities = read32(&buffer.capabilities); -- cgit v1.2.3