diff options
author | Manish V Badarkhe <Manish.Badarkhe@arm.com> | 2022-06-21 09:41:32 +0100 |
---|---|---|
committer | Manish V Badarkhe <Manish.Badarkhe@arm.com> | 2022-10-05 15:25:28 +0100 |
commit | 1436e37dcb894a539a22da48a34ef01566ae728b (patch) | |
tree | 0f5d07381fd3f252f6c8c8f11a27173bf2c797f9 | |
parent | 586f60cc571f0f3b6d20eb5033717e9b0cc66af4 (diff) | |
download | arm-trusted-firmware-1436e37dcb894a539a22da48a34ef01566ae728b.tar.gz |
feat(drtm): add remediation driver support in DRTM
Added remediation driver for DRTM to set/get the error
from non-volatile memory
Change-Id: I8f0873dcef4936693e0f39a3c95096cb689c04b7
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Signed-off-by: Lucian Paul-Trifu <lucian.paultrifu@gmail.com>
-rw-r--r-- | bl31/bl31.mk | 1 | ||||
-rw-r--r-- | services/std_svc/drtm/drtm_main.c | 5 | ||||
-rw-r--r-- | services/std_svc/drtm/drtm_remediation.c | 59 | ||||
-rw-r--r-- | services/std_svc/drtm/drtm_remediation.h | 15 |
4 files changed, 78 insertions, 2 deletions
diff --git a/bl31/bl31.mk b/bl31/bl31.mk index 9f7d96e86..4c93a55ad 100644 --- a/bl31/bl31.mk +++ b/bl31/bl31.mk @@ -152,6 +152,7 @@ BL31_SOURCES += services/std_svc/drtm/drtm_main.c \ services/std_svc/drtm/drtm_dma_prot.c \ services/std_svc/drtm/drtm_res_address_map.c \ services/std_svc/drtm/drtm_measurements.c \ + services/std_svc/drtm/drtm_remediation.c \ ${MBEDTLS_SOURCES} endif diff --git a/services/std_svc/drtm/drtm_main.c b/services/std_svc/drtm/drtm_main.c index d971901a7..9878887e5 100644 --- a/services/std_svc/drtm/drtm_main.c +++ b/services/std_svc/drtm/drtm_main.c @@ -19,6 +19,7 @@ #include <common/runtime_svc.h> #include <drivers/auth/crypto_mod.h> #include "drtm_main.h" +#include "drtm_remediation.h" #include <lib/psci/psci_lib.h> #include <lib/xlat_tables/xlat_tables_v2.h> #include <plat/common/platform.h> @@ -512,12 +513,12 @@ uint64_t drtm_smc_handler(uint32_t smc_fid, case ARM_DRTM_SVC_GET_ERROR: INFO("DRTM service handler: get error\n"); - SMC_RET2(handle, SMC_OK, 0); + drtm_get_error(handle); break; /* not reached */ case ARM_DRTM_SVC_SET_ERROR: INFO("DRTM service handler: set error\n"); - SMC_RET1(handle, SMC_OK); + drtm_set_error(x1, handle); break; /* not reached */ case ARM_DRTM_SVC_SET_TCB_HASH: diff --git a/services/std_svc/drtm/drtm_remediation.c b/services/std_svc/drtm/drtm_remediation.c new file mode 100644 index 000000000..696b4ea6a --- /dev/null +++ b/services/std_svc/drtm/drtm_remediation.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + * DRTM support for DRTM error remediation. + * + */ +#include <inttypes.h> +#include <stdint.h> + +#include <common/debug.h> +#include <common/runtime_svc.h> +#include "drtm_main.h" +#include <plat/common/platform.h> + +uint64_t drtm_set_error(uint64_t x1, void *ctx) +{ + int rc; + + rc = plat_set_drtm_error(x1); + + if (rc != 0) { + SMC_RET1(ctx, INTERNAL_ERROR); + } + + SMC_RET1(ctx, SUCCESS); +} + +uint64_t drtm_get_error(void *ctx) +{ + uint64_t error_code; + int rc; + + rc = plat_get_drtm_error(&error_code); + + if (rc != 0) { + SMC_RET1(ctx, INTERNAL_ERROR); + } + + SMC_RET2(ctx, SUCCESS, error_code); +} + +void drtm_enter_remediation(uint64_t err_code, const char *err_str) +{ + int rc = plat_set_drtm_error(err_code); + + if (rc != 0) { + ERROR("%s(): drtm_error_set() failed unexpectedly rc=%d\n", + __func__, rc); + panic(); + } + + ERROR("DRTM: entering remediation of error:\n%" PRIu64 "\t\'%s\'\n", + err_code, err_str); + + ERROR("%s(): system reset is not yet supported\n", __func__); + plat_system_reset(); +} diff --git a/services/std_svc/drtm/drtm_remediation.h b/services/std_svc/drtm/drtm_remediation.h new file mode 100644 index 000000000..8f965f1cd --- /dev/null +++ b/services/std_svc/drtm/drtm_remediation.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2022 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + * + */ +#ifndef DRTM_REMEDIATION_H +#define DRTM_REMEDIATION_H + +uint64_t drtm_set_error(uint64_t x1, void *ctx); +uint64_t drtm_get_error(void *ctx); + +void drtm_enter_remediation(uint64_t error_code, const char *error_str); + +#endif /* DRTM_REMEDIATION_H */ |