Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
438e7894
Unverified
Commit
438e7894
authored
Sep 07, 2018
by
Dimitris Papastamos
Committed by
GitHub
Sep 07, 2018
Browse files
Merge pull request #1563 from jts-arm/mbed
Improvements to Mbed TLS shared heap code
parents
2013523c
2dac2c0b
Changes
3
Show whitespace changes
Inline
Side-by-side
include/plat/arm/board/common/board_arm_def.h
View file @
438e7894
...
@@ -102,7 +102,7 @@
...
@@ -102,7 +102,7 @@
* little space for growth.
* little space for growth.
*/
*/
#if TRUSTED_BOARD_BOOT
#if TRUSTED_BOARD_BOOT
# define PLAT_ARM_MAX_BL2_SIZE 0x1
C
000
# define PLAT_ARM_MAX_BL2_SIZE 0x1
D
000
#else
#else
# define PLAT_ARM_MAX_BL2_SIZE 0x11000
# define PLAT_ARM_MAX_BL2_SIZE 0x11000
#endif
#endif
...
...
plat/arm/common/arm_dyn_cfg.c
View file @
438e7894
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
/* Variable to store the address of TB_FW_CONFIG file */
/* Variable to store the address of TB_FW_CONFIG file */
static
void
*
tb_fw_cfg_dtb
;
static
void
*
tb_fw_cfg_dtb
;
static
size_t
tb_fw_cfg_dtb_size
;
#if TRUSTED_BOARD_BOOT
#if TRUSTED_BOARD_BOOT
...
@@ -62,11 +63,15 @@ int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
...
@@ -62,11 +63,15 @@ int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size)
int
err
;
int
err
;
/* If in BL2, retrieve the already allocated heap's info from DTB */
/* If in BL2, retrieve the already allocated heap's info from DTB */
if
(
tb_fw_cfg_dtb
!=
NULL
)
{
err
=
arm_get_dtb_mbedtls_heap_info
(
tb_fw_cfg_dtb
,
heap_addr
,
err
=
arm_get_dtb_mbedtls_heap_info
(
tb_fw_cfg_dtb
,
heap_addr
,
heap_size
);
heap_size
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"BL2: unable to retrieve shared Mbed TLS heap "
ERROR
(
"BL2: unable to retrieve shared Mbed TLS heap information from DTB
\n
"
);
"information from DTB
\n
"
);
panic
();
}
}
else
{
ERROR
(
"BL2: DTB missing, cannot get Mbed TLS heap
\n
"
);
panic
();
panic
();
}
}
#endif
#endif
...
@@ -98,10 +103,16 @@ void arm_bl1_set_mbedtls_heap(void)
...
@@ -98,10 +103,16 @@ void arm_bl1_set_mbedtls_heap(void)
err
=
arm_set_dtb_mbedtls_heap_info
(
tb_fw_cfg_dtb
,
err
=
arm_set_dtb_mbedtls_heap_info
(
tb_fw_cfg_dtb
,
mbedtls_heap_addr
,
mbedtls_heap_size
);
mbedtls_heap_addr
,
mbedtls_heap_size
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"BL1: unable to write shared Mbed TLS heap "
ERROR
(
"BL1: unable to write shared Mbed TLS heap information to DTB
\n
"
);
"information to DTB
\n
"
);
panic
();
panic
();
}
}
/*
* Ensure that the info written to the DTB is visible to other
* images. It's critical because BL2 won't be able to proceed
* without the heap info.
*/
flush_dcache_range
((
uintptr_t
)
tb_fw_cfg_dtb
,
tb_fw_cfg_dtb_size
);
}
}
}
}
...
@@ -122,7 +133,8 @@ void arm_load_tb_fw_config(void)
...
@@ -122,7 +133,8 @@ void arm_load_tb_fw_config(void)
SET_STATIC_PARAM_HEAD
(
image_info
,
PARAM_IMAGE_BINARY
,
SET_STATIC_PARAM_HEAD
(
image_info
,
PARAM_IMAGE_BINARY
,
VERSION_2
,
image_info_t
,
0
),
VERSION_2
,
image_info_t
,
0
),
.
image_info
.
image_base
=
ARM_TB_FW_CONFIG_BASE
,
.
image_info
.
image_base
=
ARM_TB_FW_CONFIG_BASE
,
.
image_info
.
image_max_size
=
ARM_TB_FW_CONFIG_LIMIT
-
ARM_TB_FW_CONFIG_BASE
,
.
image_info
.
image_max_size
=
ARM_TB_FW_CONFIG_LIMIT
-
ARM_TB_FW_CONFIG_BASE
};
};
VERBOSE
(
"BL1: Loading TB_FW_CONFIG
\n
"
);
VERBOSE
(
"BL1: Loading TB_FW_CONFIG
\n
"
);
...
@@ -136,6 +148,7 @@ void arm_load_tb_fw_config(void)
...
@@ -136,6 +148,7 @@ void arm_load_tb_fw_config(void)
/* At this point we know that a DTB is indeed available */
/* At this point we know that a DTB is indeed available */
config_base
=
arm_tb_fw_info
.
image_info
.
image_base
;
config_base
=
arm_tb_fw_info
.
image_info
.
image_base
;
tb_fw_cfg_dtb
=
(
void
*
)
config_base
;
tb_fw_cfg_dtb
=
(
void
*
)
config_base
;
tb_fw_cfg_dtb_size
=
(
size_t
)
arm_tb_fw_info
.
image_info
.
image_max_size
;
/* The BL2 ep_info arg0 is modified to point to TB_FW_CONFIG */
/* The BL2 ep_info arg0 is modified to point to TB_FW_CONFIG */
image_desc
=
bl1_plat_get_image_desc
(
BL2_IMAGE_ID
);
image_desc
=
bl1_plat_get_image_desc
(
BL2_IMAGE_ID
);
...
...
plat/arm/common/arm_dyn_cfg_helpers.c
View file @
438e7894
...
@@ -167,8 +167,6 @@ int arm_dyn_tb_fw_cfg_init(void *dtb, int *node)
...
@@ -167,8 +167,6 @@ int arm_dyn_tb_fw_cfg_init(void *dtb, int *node)
return
0
;
return
0
;
}
}
#if TRUSTED_BOARD_BOOT && LOAD_IMAGE_V2
/*
/*
* Reads and returns the Mbed TLS shared heap information from the DTB.
* Reads and returns the Mbed TLS shared heap information from the DTB.
* This function is supposed to be called *only* when a DTB is present.
* This function is supposed to be called *only* when a DTB is present.
...
@@ -187,8 +185,7 @@ int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
...
@@ -187,8 +185,7 @@ int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
/* Verify the DTB is valid and get the root node */
/* Verify the DTB is valid and get the root node */
err
=
arm_dyn_tb_fw_cfg_init
(
dtb
,
&
dtb_root
);
err
=
arm_dyn_tb_fw_cfg_init
(
dtb
,
&
dtb_root
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"%s: Invalid TB_FW_CONFIG. Cannot retrieve Mbed TLS "
ERROR
(
"Invalid TB_FW_CONFIG. Cannot retrieve Mbed TLS heap information from DTB
\n
"
);
"heap information from DTB
\n
"
,
__func__
);
return
-
1
;
return
-
1
;
}
}
...
@@ -196,14 +193,14 @@ int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
...
@@ -196,14 +193,14 @@ int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr,
err
=
fdtw_read_cells
(
dtb
,
dtb_root
,
err
=
fdtw_read_cells
(
dtb
,
dtb_root
,
DTB_PROP_MBEDTLS_HEAP_ADDR
,
2
,
heap_addr
);
DTB_PROP_MBEDTLS_HEAP_ADDR
,
2
,
heap_addr
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"
%s: e
rror while reading %s from DTB
\n
"
,
__func__
,
ERROR
(
"
E
rror while reading %s from DTB
\n
"
,
DTB_PROP_MBEDTLS_HEAP_ADDR
);
DTB_PROP_MBEDTLS_HEAP_ADDR
);
return
-
1
;
return
-
1
;
}
}
err
=
fdtw_read_cells
(
dtb
,
dtb_root
,
err
=
fdtw_read_cells
(
dtb
,
dtb_root
,
DTB_PROP_MBEDTLS_HEAP_SIZE
,
1
,
heap_size
);
DTB_PROP_MBEDTLS_HEAP_SIZE
,
1
,
heap_size
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"
%s: e
rror while reading %s from DTB
\n
"
,
__func__
,
ERROR
(
"
E
rror while reading %s from DTB
\n
"
,
DTB_PROP_MBEDTLS_HEAP_SIZE
);
DTB_PROP_MBEDTLS_HEAP_SIZE
);
return
-
1
;
return
-
1
;
}
}
...
@@ -234,8 +231,7 @@ int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size)
...
@@ -234,8 +231,7 @@ int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size)
*/
*/
err
=
arm_dyn_tb_fw_cfg_init
(
dtb
,
&
dtb_root
);
err
=
arm_dyn_tb_fw_cfg_init
(
dtb
,
&
dtb_root
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"%s: Invalid TB_FW_CONFIG loaded. Unable to get "
ERROR
(
"Invalid TB_FW_CONFIG loaded. Unable to get root node
\n
"
);
"root node
\n
"
,
__func__
);
return
-
1
;
return
-
1
;
}
}
...
@@ -249,19 +245,18 @@ int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size)
...
@@ -249,19 +245,18 @@ int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size)
err
=
fdtw_write_inplace_cells
(
dtb
,
dtb_root
,
err
=
fdtw_write_inplace_cells
(
dtb
,
dtb_root
,
DTB_PROP_MBEDTLS_HEAP_ADDR
,
2
,
&
heap_addr
);
DTB_PROP_MBEDTLS_HEAP_ADDR
,
2
,
&
heap_addr
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"
%s: u
nable to write DTB property %s
\n
"
,
ERROR
(
"
U
nable to write DTB property %s
\n
"
,
__func__
,
DTB_PROP_MBEDTLS_HEAP_ADDR
);
DTB_PROP_MBEDTLS_HEAP_ADDR
);
return
-
1
;
return
-
1
;
}
}
err
=
fdtw_write_inplace_cells
(
dtb
,
dtb_root
,
err
=
fdtw_write_inplace_cells
(
dtb
,
dtb_root
,
DTB_PROP_MBEDTLS_HEAP_SIZE
,
1
,
&
heap_size
);
DTB_PROP_MBEDTLS_HEAP_SIZE
,
1
,
&
heap_size
);
if
(
err
<
0
)
{
if
(
err
<
0
)
{
ERROR
(
"
%s: u
nable to write DTB property %s
\n
"
,
ERROR
(
"
U
nable to write DTB property %s
\n
"
,
__func__
,
DTB_PROP_MBEDTLS_HEAP_SIZE
);
DTB_PROP_MBEDTLS_HEAP_SIZE
);
return
-
1
;
return
-
1
;
}
}
return
0
;
return
0
;
}
}
#endif
/* TRUSTED_BOARD_BOOT && LOAD_IMAGE_V2 */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment