Skip to content

Commit

Permalink
core: calculate size/address cells with overlay
Browse files Browse the repository at this point in the history
In case an external device tree overlay is configured within OP-TEE,
fdt_{size,address}_cells will return the defaults from the device tree
specification. These will be wrong for 32-bit ARM platforms, instead
calculate them from the paddr_t size instead.

Signed-off-by: Rouven Czerwinski <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
  • Loading branch information
Emantor authored and jforissier committed Jan 24, 2020
1 parent 9c619b2 commit e9866d8
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions core/arch/arm/kernel/generic_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <arm.h>
#include <assert.h>
#include <compiler.h>
#include <config.h>
#include <console.h>
#include <crypto/crypto.h>
#include <inttypes.h>
Expand Down Expand Up @@ -839,12 +840,17 @@ static int add_res_mem_dt_node(struct dt_descriptor *dt, const char *name,
offs = 0;
}

len_size = fdt_size_cells(dt->blob, offs);
if (len_size < 0)
return -1;
addr_size = fdt_address_cells(dt->blob, offs);
if (addr_size < 0)
return -1;
if (IS_ENABLED(CFG_EXTERNAL_DTB_OVERLAY)) {
len_size = sizeof(paddr_t) / sizeof(uint32_t);
addr_size = sizeof(paddr_t) / sizeof(uint32_t);
} else {
len_size = fdt_size_cells(dt->blob, offs);
if (len_size < 0)
return -1;
addr_size = fdt_address_cells(dt->blob, offs);
if (addr_size < 0)
return -1;
}

if (!found) {
offs = add_dt_path_subnode(dt, "/", "reserved-memory");
Expand Down

0 comments on commit e9866d8

Please sign in to comment.