mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
feat(tc): add DPE context handle node to device tree
Child software components are inheriting their first valid DPE context handle from their parent components (who loaded and measured them). The context handle is shared through the device tree object the following way: - BL1 -> BL2 via TB_FW_CONFIG - BL2 -> BL33 via NT_FW_CONFIG Signed-off-by: Tamas Ban <tamas.ban@arm.com> Change-Id: I9bf7808fb13a310ad7ca1895674a0c7e6725e08b
This commit is contained in:
parent
e7f1181f8a
commit
1f47a7133f
8 changed files with 193 additions and 2 deletions
|
@ -290,6 +290,12 @@ void arm_bl1_set_mbedtls_heap(void);
|
|||
int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size);
|
||||
|
||||
#if MEASURED_BOOT
|
||||
#if DICE_PROTECTION_ENVIRONMENT
|
||||
int arm_set_nt_fw_info(int *ctx_handle);
|
||||
int arm_set_tb_fw_info(int *ctx_handle);
|
||||
int arm_get_tb_fw_info(int *ctx_handle);
|
||||
#else
|
||||
/* Specific to event log backend */
|
||||
int arm_set_tos_fw_info(uintptr_t log_addr, size_t log_size);
|
||||
int arm_set_nt_fw_info(
|
||||
/*
|
||||
|
@ -304,6 +310,7 @@ int arm_set_tb_fw_info(uintptr_t log_addr, size_t log_size,
|
|||
size_t log_max_size);
|
||||
int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size,
|
||||
size_t *log_max_size);
|
||||
#endif /* DICE_PROTECTION_ENVIRONMENT */
|
||||
#endif /* MEASURED_BOOT */
|
||||
|
||||
/*
|
||||
|
|
11
plat/arm/board/tc/fdts/dice_prot_env.dtsi
Normal file
11
plat/arm/board/tc/fdts/dice_prot_env.dtsi
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/* DICE Protection Environment Client Config */
|
||||
dice_protection_environment: context_handle {
|
||||
compatible = "arm,dpe_ctx_handle";
|
||||
dpe_ctx_handle = <0x0>;
|
||||
};
|
|
@ -30,5 +30,10 @@
|
|||
max-size = <PLAT_HW_CONFIG_DTB_SIZE>;
|
||||
id = <HW_CONFIG_ID>;
|
||||
};
|
||||
nt_fw-config {
|
||||
load-address = <0x0 (PLAT_HW_CONFIG_DTB_BASE + PLAT_HW_CONFIG_DTB_SIZE)>;
|
||||
max-size = <0x1000>;
|
||||
id = <NT_FW_CONFIG_ID>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
13
plat/arm/board/tc/fdts/tc_nt_fw_config.dts
Normal file
13
plat/arm/board/tc/fdts/tc_nt_fw_config.dts
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright (c) 2024, Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
#if DICE_PROTECTION_ENVIRONMENT
|
||||
#include "dice_prot_env.dtsi"
|
||||
#endif
|
||||
};
|
|
@ -82,4 +82,7 @@
|
|||
#endif
|
||||
#endif /* ARM_BL2_SP_LIST_DTS */
|
||||
};
|
||||
#if DICE_PROTECTION_ENVIRONMENT
|
||||
#include "dice_prot_env.dtsi"
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
* | DTB |
|
||||
* | (32K) |
|
||||
* 0x8000_8000 ------------------
|
||||
* | NT_FW_CONFIG |
|
||||
* | (4KB) |
|
||||
* 0x8000_9000 ------------------
|
||||
* | ... |
|
||||
* 0xf8a0_0000 ------------------ TC_NS_FWU_BASE
|
||||
* | FWU shmem |
|
||||
|
|
|
@ -137,14 +137,18 @@ BL31_SOURCES += ${FDT_WRAPPERS_SOURCES}
|
|||
|
||||
# Add the FDT_SOURCES and options for Dynamic Config
|
||||
FDT_SOURCES += ${TC_BASE}/fdts/${PLAT}_fw_config.dts \
|
||||
${TC_BASE}/fdts/${PLAT}_tb_fw_config.dts
|
||||
${TC_BASE}/fdts/${PLAT}_tb_fw_config.dts \
|
||||
${TC_BASE}/fdts/${PLAT}_nt_fw_config.dts
|
||||
FW_CONFIG := ${BUILD_PLAT}/fdts/${PLAT}_fw_config.dtb
|
||||
TB_FW_CONFIG := ${BUILD_PLAT}/fdts/${PLAT}_tb_fw_config.dtb
|
||||
FVP_NT_FW_CONFIG := ${BUILD_PLAT}/fdts/${PLAT}_nt_fw_config.dtb
|
||||
|
||||
# Add the FW_CONFIG to FIP and specify the same to certtool
|
||||
$(eval $(call TOOL_ADD_PAYLOAD,${FW_CONFIG},--fw-config,${FW_CONFIG}))
|
||||
# Add the TB_FW_CONFIG to FIP and specify the same to certtool
|
||||
$(eval $(call TOOL_ADD_PAYLOAD,${TB_FW_CONFIG},--tb-fw-config,${TB_FW_CONFIG}))
|
||||
# Add the NT_FW_CONFIG to FIP and specify the same to certtool
|
||||
$(eval $(call TOOL_ADD_PAYLOAD,${FVP_NT_FW_CONFIG},--nt-fw-config,${FVP_NT_FW_CONFIG}))
|
||||
|
||||
ifeq (${SPD},spmd)
|
||||
ifeq ($(ARM_SPMC_MANIFEST_DTS),)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2023, Arm Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2018-2024, Arm Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -124,6 +124,150 @@ int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size)
|
|||
}
|
||||
|
||||
#if MEASURED_BOOT
|
||||
#if DICE_PROTECTION_ENVIRONMENT
|
||||
|
||||
#include <common/desc_image_load.h>
|
||||
|
||||
#define DTB_PROP_DPE_CTX_HANDLE "dpe_ctx_handle"
|
||||
|
||||
static int arm_set_dpe_context_handle(uintptr_t config_base,
|
||||
int *ctx_handle)
|
||||
{
|
||||
/* As libfdt uses void *, we can't avoid this cast */
|
||||
void *dtb = (void *)config_base;
|
||||
const char *compatible = "arm,dpe_ctx_handle";
|
||||
int err, node;
|
||||
|
||||
/*
|
||||
* Verify that the DTB is valid, before attempting to write to it,
|
||||
* and get the DTB root node.
|
||||
*/
|
||||
|
||||
/* Check if the pointer to DT is correct */
|
||||
err = fdt_check_header(dtb);
|
||||
if (err < 0) {
|
||||
WARN("Invalid DTB file passed\n");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Assert the node offset point to compatible property */
|
||||
node = fdt_node_offset_by_compatible(dtb, -1, compatible);
|
||||
if (node < 0) {
|
||||
WARN("The compatible property '%s' not%s", compatible,
|
||||
" found in the config\n");
|
||||
return node;
|
||||
}
|
||||
|
||||
VERBOSE("Dyn cfg: '%s'%s", compatible, " found in the config\n");
|
||||
|
||||
err = fdtw_write_inplace_cells(dtb, node,
|
||||
DTB_PROP_DPE_CTX_HANDLE, 1, ctx_handle);
|
||||
if (err < 0) {
|
||||
ERROR("%sDTB property '%s'\n",
|
||||
"Unable to write ", DTB_PROP_DPE_CTX_HANDLE);
|
||||
} else {
|
||||
/*
|
||||
* Ensure that the info written to the DTB is visible
|
||||
* to other images.
|
||||
*/
|
||||
flush_dcache_range(config_base, fdt_totalsize(dtb));
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function writes the DPE context handle value to the NT_FW_CONFIG DTB.
|
||||
*
|
||||
* This function is supposed to be called only by BL2.
|
||||
*
|
||||
* Returns:
|
||||
* 0 = success
|
||||
* < 0 = error
|
||||
*/
|
||||
int arm_set_nt_fw_info(int *ctx_handle)
|
||||
{
|
||||
uintptr_t config_base;
|
||||
const bl_mem_params_node_t *cfg_mem_params;
|
||||
|
||||
/* Get the config load address and size from NT_FW_CONFIG */
|
||||
cfg_mem_params = get_bl_mem_params_node(NT_FW_CONFIG_ID);
|
||||
assert(cfg_mem_params != NULL);
|
||||
|
||||
config_base = cfg_mem_params->image_info.image_base;
|
||||
|
||||
/* Write the context handle value in the DTB */
|
||||
return arm_set_dpe_context_handle(config_base, ctx_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function writes the DPE context handle value to the TB_FW_CONFIG DTB.
|
||||
*
|
||||
* This function is supposed to be called only by BL1.
|
||||
*
|
||||
* Returns:
|
||||
* 0 = success
|
||||
* < 0 = error
|
||||
*/
|
||||
int arm_set_tb_fw_info(int *ctx_handle)
|
||||
{
|
||||
/*
|
||||
* Read tb_fw_config device tree for Event Log properties
|
||||
* and write the Event Log address and its size in the DTB
|
||||
*/
|
||||
const struct dyn_cfg_dtb_info_t *tb_fw_config_info;
|
||||
uintptr_t tb_fw_cfg_dtb;
|
||||
|
||||
tb_fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
|
||||
assert(tb_fw_config_info != NULL);
|
||||
|
||||
tb_fw_cfg_dtb = tb_fw_config_info->config_addr;
|
||||
|
||||
/* Write the context handle value in the DTB */
|
||||
return arm_set_dpe_context_handle(tb_fw_cfg_dtb, ctx_handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* This function reads the initial DPE context handle from TB_FW_CONFIG DTB.
|
||||
*
|
||||
* This function is supposed to be called only by BL2.
|
||||
*
|
||||
* Returns:
|
||||
* 0 = success
|
||||
* < 0 = error
|
||||
*/
|
||||
|
||||
int arm_get_tb_fw_info(int *ctx_handle)
|
||||
{
|
||||
/* As libfdt uses void *, we can't avoid this cast */
|
||||
const struct dyn_cfg_dtb_info_t *tb_fw_config_info;
|
||||
int node, rc;
|
||||
|
||||
tb_fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
|
||||
assert(tb_fw_config_info != NULL);
|
||||
|
||||
void *dtb = (void *)tb_fw_config_info->config_addr;
|
||||
const char *compatible = "arm,dpe_ctx_handle";
|
||||
|
||||
/* Assert the node offset point to compatible property */
|
||||
node = fdt_node_offset_by_compatible(dtb, -1, compatible);
|
||||
if (node < 0) {
|
||||
WARN("The compatible property '%s'%s", compatible,
|
||||
" not specified in TB_FW config.\n");
|
||||
return node;
|
||||
}
|
||||
|
||||
VERBOSE("Dyn cfg: '%s'%s", compatible, " found in the config\n");
|
||||
|
||||
rc = fdt_read_uint32(dtb, node, DTB_PROP_DPE_CTX_HANDLE, (uint32_t *)ctx_handle);
|
||||
if (rc != 0) {
|
||||
ERROR("%s%s", DTB_PROP_DPE_CTX_HANDLE,
|
||||
" not specified in TB_FW config.\n");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* Write the Event Log address and its size in the DTB.
|
||||
*
|
||||
|
@ -393,4 +537,5 @@ int arm_get_tb_fw_info(uint64_t *log_addr, size_t *log_size,
|
|||
|
||||
return rc;
|
||||
}
|
||||
#endif /* DICE_PROTECTION_ENVIRONMENT */
|
||||
#endif /* MEASURED_BOOT */
|
||||
|
|
Loading…
Add table
Reference in a new issue