]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(xilinx): handle CRC failure in IPI
authorNaman Trivedi Manojbhai <naman.trivedimanojbhai@amd.com>
Tue, 7 Mar 2023 07:11:11 +0000 (12:41 +0530)
committerAkshay Belsare <akshay.belsare@amd.com>
Thu, 9 Mar 2023 09:33:50 +0000 (15:03 +0530)
Currently, if CRC validation fails during IPI communication,
pm_ipi_buff_read() logs error message but don't return error
code to upper layers.

Added CRC failure specific error code which will be returned by
pm_ipi_buff_read() if CRC validation fails.

Signed-off-by: Naman Trivedi Manojbhai <naman.trivedimanojbhai@amd.com>
Change-Id: I33be330f276973471f4ce4115d1e1609ed8fb754

plat/xilinx/common/pm_service/pm_ipi.c
plat/xilinx/versal/pm_service/pm_defs.h
plat/xilinx/zynqmp/pm_service/pm_defs.h

index a3c3a6f234839bfd701f9e4083ff0bc727054ee5..81f1939f44cd6f1f835cd0474796bcf112b10413 100644 (file)
@@ -136,7 +136,9 @@ static enum pm_ret_status pm_ipi_buff_read(const struct pm_proc *proc,
                                           uint32_t *value, size_t count)
 {
        size_t i;
+       enum pm_ret_status ret;
 #if IPI_CRC_CHECK
+       uint32_t *payload_ptr = value;
        size_t j;
        uint32_t response_payload[PAYLOAD_ARG_CNT];
 #endif
@@ -155,6 +157,8 @@ static enum pm_ret_status pm_ipi_buff_read(const struct pm_proc *proc,
                *value = mmio_read_32(buffer_base + (i * PAYLOAD_ARG_SIZE));
                value++;
        }
+
+       ret = mmio_read_32(buffer_base);
 #if IPI_CRC_CHECK
        for (j = 0; j < PAYLOAD_ARG_CNT; j++) {
                response_payload[j] = mmio_read_32(buffer_base +
@@ -165,10 +169,15 @@ static enum pm_ret_status pm_ipi_buff_read(const struct pm_proc *proc,
                        calculate_crc(response_payload, IPI_W0_TO_W6_SIZE)) {
                NOTICE("ERROR in CRC response payload value:0x%x\n",
                                        response_payload[PAYLOAD_CRC_POS]);
+               ret = PM_RET_ERROR_INVALID_CRC;
+               /* Payload data is invalid as CRC validation failed
+                * Clear the payload to avoid leakage of data to upper layers
+                */
+               memset(payload_ptr, 0, count);
        }
 #endif
 
-       return mmio_read_32(buffer_base);
+       return ret;
 }
 
 /**
index 2922b5dd0bcb90b11c862e7b309119cc6ef341f8..dbc801c661e272e89365348500a35352d9633b51 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved.
+ * Copyright (c) 2022-2023, Advanced Micro Devices Inc. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -115,11 +116,13 @@ typedef enum {
        XPM_SUBSYSID_MAX,
 } XPm_SubsystemId;
 
+/* TODO: move pm_ret_status from device specific location to common location */
 /**
  * @PM_RET_SUCCESS:            success
  * @PM_RET_ERROR_ARGS:         illegal arguments provided (deprecated)
  * @PM_RET_ERROR_NOTSUPPORTED: feature not supported  (deprecated)
  * @PM_RET_ERROR_NOFEATURE:    feature is not available
+ * @PM_RET_ERROR_INVALID_CRC:  invalid crc in IPI communication
  * @PM_RET_ERROR_INTERNAL:     internal error
  * @PM_RET_ERROR_CONFLICT:     conflict
  * @PM_RET_ERROR_ACCESS:       access rights violation
@@ -134,6 +137,7 @@ enum pm_ret_status {
        PM_RET_ERROR_ARGS = 1,
        PM_RET_ERROR_NOTSUPPORTED = 4,
        PM_RET_ERROR_NOFEATURE = 19,
+       PM_RET_ERROR_INVALID_CRC = 301,
        PM_RET_ERROR_INTERNAL = 2000,
        PM_RET_ERROR_CONFLICT = 2001,
        PM_RET_ERROR_ACCESS = 2002,
index 008cfdc905a0e2b2f4e7ca14c45c35836c316dd3..f00ab4b1cdaeefafb19d84a06cb13d5bdb8b7c5d 100644 (file)
@@ -243,11 +243,13 @@ enum pm_opchar_type {
        PM_OPCHAR_TYPE_LATENCY,
 };
 
+/* TODO: move pm_ret_status from device specific location to common location */
 /**
  * @PM_RET_SUCCESS:            success
  * @PM_RET_ERROR_ARGS:         illegal arguments provided (deprecated)
  * @PM_RET_ERROR_NOTSUPPORTED: feature not supported  (deprecated)
  * @PM_RET_ERROR_NOT_ENABLED:  feature is not enabled
+ * @PM_RET_ERROR_INVALID_CRC:  invalid crc in IPI communication
  * @PM_RET_ERROR_INTERNAL:     internal error
  * @PM_RET_ERROR_CONFLICT:     conflict
  * @PM_RET_ERROR_ACCESS:       access rights violation
@@ -262,6 +264,7 @@ enum pm_ret_status {
        PM_RET_ERROR_ARGS = (1U),
        PM_RET_ERROR_NOTSUPPORTED = (4U),
        PM_RET_ERROR_NOT_ENABLED = (29U),
+       PM_RET_ERROR_INVALID_CRC = (301U),
        PM_RET_ERROR_INTERNAL = (2000U),
        PM_RET_ERROR_CONFLICT = (2001U),
        PM_RET_ERROR_ACCESS = (2002U),