mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-23 13:36:05 +00:00
fconf: Add TBBR disable_authentication property
Use fconf to retrieve the `disable_authentication` property. Move this access from arm dynamic configuration to bl common. Change-Id: Ibf184a5c6245d04839222f5457cf5e651f252b86 Signed-off-by: Louis Mayencourt <louis.mayencourt@arm.com>
This commit is contained in:
parent
25ac87940c
commit
ce8528411a
7 changed files with 69 additions and 71 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved.
|
* Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved.
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,4 +12,14 @@
|
||||||
/* TBBR related getter */
|
/* TBBR related getter */
|
||||||
#define tbbr__cot_getter(id) cot_desc_ptr[id]
|
#define tbbr__cot_getter(id) cot_desc_ptr[id]
|
||||||
|
|
||||||
|
#define tbbr__dyn_config_getter(id) tbbr_dyn_config.id
|
||||||
|
|
||||||
|
struct tbbr_dyn_config_t {
|
||||||
|
uint32_t disable_auth;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct tbbr_dyn_config_t tbbr_dyn_config;
|
||||||
|
|
||||||
|
int fconf_populate_tbbr_dyn_config(uintptr_t config);
|
||||||
|
|
||||||
#endif /* FCONF_TBBR_GETTER_H */
|
#endif /* FCONF_TBBR_GETTER_H */
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
/* Function declarations */
|
/* Function declarations */
|
||||||
int arm_dyn_tb_fw_cfg_init(void *dtb, int *node);
|
int arm_dyn_tb_fw_cfg_init(void *dtb, int *node);
|
||||||
int arm_dyn_get_disable_auth(void *dtb, int node, uint32_t *disable_auth);
|
|
||||||
int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
|
int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
|
||||||
size_t *heap_size);
|
size_t *heap_size);
|
||||||
int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr,
|
int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr,
|
||||||
|
|
56
lib/fconf/fconf_tbbr_getter.c
Normal file
56
lib/fconf/fconf_tbbr_getter.c
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019-2020, ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
*/
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include <common/bl_common.h>
|
||||||
|
#include <common/debug.h>
|
||||||
|
#include <common/fdt_wrappers.h>
|
||||||
|
#include <lib/fconf/fconf_tbbr_getter.h>
|
||||||
|
#include <libfdt.h>
|
||||||
|
|
||||||
|
struct tbbr_dyn_config_t tbbr_dyn_config;
|
||||||
|
|
||||||
|
int fconf_populate_tbbr_dyn_config(uintptr_t config)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
int node;
|
||||||
|
|
||||||
|
/* As libfdt use void *, we can't avoid this cast */
|
||||||
|
const void *dtb = (void *)config;
|
||||||
|
|
||||||
|
/* Assert the node offset point to "arm,tb_fw" compatible property */
|
||||||
|
const char *compatible_str = "arm,tb_fw";
|
||||||
|
node = fdt_node_offset_by_compatible(dtb, -1, compatible_str);
|
||||||
|
if (node < 0) {
|
||||||
|
ERROR("FCONF: Can't find %s compatible in dtb\n", compatible_str);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Locate the disable_auth cell and read the value */
|
||||||
|
err = fdtw_read_cells(dtb, node, "disable_auth", 1, &tbbr_dyn_config.disable_auth);
|
||||||
|
if (err < 0) {
|
||||||
|
WARN("FCONF: Read cell failed for `disable_auth`\n");
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the value is boolean */
|
||||||
|
if ((tbbr_dyn_config.disable_auth != 0U) && (tbbr_dyn_config.disable_auth != 1U)) {
|
||||||
|
WARN("Invalid value for `disable_auth` cell %d\n", tbbr_dyn_config.disable_auth);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(DYN_DISABLE_AUTH)
|
||||||
|
if (tbbr_dyn_config.disable_auth == 1)
|
||||||
|
dyn_disable_auth();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VERBOSE("FCONF:tbbr.disable_auth cell found with value = %d\n",
|
||||||
|
tbbr_dyn_config.disable_auth);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
FCONF_REGISTER_POPULATOR(tbbr, fconf_populate_tbbr_dyn_config);
|
|
@ -273,7 +273,8 @@ ifneq (${TRUSTED_BOARD_BOOT},0)
|
||||||
# Include common TBB sources
|
# Include common TBB sources
|
||||||
AUTH_SOURCES := drivers/auth/auth_mod.c \
|
AUTH_SOURCES := drivers/auth/auth_mod.c \
|
||||||
drivers/auth/crypto_mod.c \
|
drivers/auth/crypto_mod.c \
|
||||||
drivers/auth/img_parser_mod.c
|
drivers/auth/img_parser_mod.c \
|
||||||
|
lib/fconf/fconf_tbbr_getter.c
|
||||||
|
|
||||||
# Include the selected chain of trust sources.
|
# Include the selected chain of trust sources.
|
||||||
ifeq (${COT},tbbr)
|
ifeq (${COT},tbbr)
|
||||||
|
|
|
@ -207,27 +207,4 @@ void arm_bl2_dyn_cfg_init(void)
|
||||||
*/
|
*/
|
||||||
cfg_mem_params->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING;
|
cfg_mem_params->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TRUSTED_BOARD_BOOT && defined(DYN_DISABLE_AUTH)
|
|
||||||
uint32_t disable_auth = 0;
|
|
||||||
void *tb_fw_cfg_dtb;
|
|
||||||
int err, tb_fw_node;
|
|
||||||
|
|
||||||
dtb_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
|
|
||||||
tb_fw_cfg_dtb = (void *)dtb_info->config_addr;
|
|
||||||
|
|
||||||
err = arm_dyn_tb_fw_cfg_init(tb_fw_cfg_dtb, &tb_fw_node);
|
|
||||||
if (err < 0) {
|
|
||||||
ERROR("Invalid TB_FW_CONFIG passed from BL1\n");
|
|
||||||
panic();
|
|
||||||
}
|
|
||||||
|
|
||||||
err = arm_dyn_get_disable_auth(tb_fw_cfg_dtb, tb_fw_node,
|
|
||||||
&disable_auth);
|
|
||||||
if (err < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (disable_auth == 1)
|
|
||||||
dyn_disable_auth();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,51 +15,6 @@
|
||||||
#define DTB_PROP_MBEDTLS_HEAP_ADDR "mbedtls_heap_addr"
|
#define DTB_PROP_MBEDTLS_HEAP_ADDR "mbedtls_heap_addr"
|
||||||
#define DTB_PROP_MBEDTLS_HEAP_SIZE "mbedtls_heap_size"
|
#define DTB_PROP_MBEDTLS_HEAP_SIZE "mbedtls_heap_size"
|
||||||
|
|
||||||
/*******************************************************************************
|
|
||||||
* Helper to read the `disable_auth` property in config DTB. This function
|
|
||||||
* expects the following properties to be present in the config DTB.
|
|
||||||
* name : disable_auth size : 1 cell
|
|
||||||
*
|
|
||||||
* Arguments:
|
|
||||||
* void *dtb - pointer to the TB_FW_CONFIG in memory
|
|
||||||
* int node - The node offset to appropriate node in the
|
|
||||||
* DTB.
|
|
||||||
* uint64_t *disable_auth - The value of `disable_auth` property on
|
|
||||||
* successful read. Must be 0 or 1.
|
|
||||||
*
|
|
||||||
* Returns 0 on success and -1 on error.
|
|
||||||
******************************************************************************/
|
|
||||||
int arm_dyn_get_disable_auth(void *dtb, int node, uint32_t *disable_auth)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
assert(dtb != NULL);
|
|
||||||
assert(disable_auth != NULL);
|
|
||||||
|
|
||||||
/* Check if the pointer to DT is correct */
|
|
||||||
assert(fdt_check_header(dtb) == 0);
|
|
||||||
|
|
||||||
/* Assert the node offset point to "arm,tb_fw" compatible property */
|
|
||||||
assert(node == fdt_node_offset_by_compatible(dtb, -1, "arm,tb_fw"));
|
|
||||||
|
|
||||||
/* Locate the disable_auth cell and read the value */
|
|
||||||
err = fdtw_read_cells(dtb, node, "disable_auth", 1, disable_auth);
|
|
||||||
if (err < 0) {
|
|
||||||
WARN("Read cell failed for `disable_auth`\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if the value is boolean */
|
|
||||||
if ((*disable_auth != 0U) && (*disable_auth != 1U)) {
|
|
||||||
WARN("Invalid value for `disable_auth` cell %d\n", *disable_auth);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
VERBOSE("Dyn cfg: `disable_auth` cell found with value = %d\n",
|
|
||||||
*disable_auth);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Validate the tb_fw_config is a valid DTB file and returns the node offset
|
* Validate the tb_fw_config is a valid DTB file and returns the node offset
|
||||||
* to "arm,tb_fw" property.
|
* to "arm,tb_fw" property.
|
||||||
|
|
Loading…
Add table
Reference in a new issue