From 40f9219872b6dd906e25dfd421ae6026f1ab2bd7 Mon Sep 17 00:00:00 2001 From: Konstantin Porotchkin Date: Mon, 20 Mar 2017 15:45:08 +0200 Subject: io: Allow image load to address zero Allow zero-address assertion bypass if requested by platform compilation flag PLAT_ALLOW_ZERO_ADDR_COPY. This patch allows loading BL33 (u-boot) to address 0x0 Change-Id: I10518db13466017110358437790ce5212d52d9e6 Signed-off-by: Haim Boot Signed-off-by: Konstantin Porotchkin Reviewed-on: http://vgitil04.il.marvell.com:8080/37914 --- drivers/io/io_fip.c | 2 ++ drivers/io/io_memmap.c | 3 +++ drivers/io/io_storage.c | 5 ++++- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c index 99cf15b9..bdacc9c0 100644 --- a/drivers/io/io_fip.c +++ b/drivers/io/io_fip.c @@ -299,7 +299,9 @@ static int fip_file_read(io_entity_t *entity, uintptr_t buffer, size_t length, uintptr_t backend_handle; assert(entity != NULL); +#ifndef PLAT_ALLOW_ZERO_ADDR_COPY assert(buffer != (uintptr_t)NULL); +#endif assert(length_read != NULL); assert(entity->info != (uintptr_t)NULL); diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c index fe39652b..5aedd010 100644 --- a/drivers/io/io_memmap.c +++ b/drivers/io/io_memmap.c @@ -32,6 +32,7 @@ #include #include #include +#include #include /* As we need to be able to keep state for seek, only one file can be open @@ -185,7 +186,9 @@ static int memmap_block_read(io_entity_t *entity, uintptr_t buffer, file_state_t *fp; assert(entity != NULL); +#ifndef PLAT_ALLOW_ZERO_ADDR_COPY assert(buffer != (uintptr_t)NULL); +#endif assert(length_read != NULL); fp = (file_state_t *)entity->info; diff --git a/drivers/io/io_storage.c b/drivers/io/io_storage.c index 7cb1a6aa..45c3e568 100644 --- a/drivers/io/io_storage.c +++ b/drivers/io/io_storage.c @@ -302,7 +302,10 @@ int io_read(uintptr_t handle, size_t *length_read) { int result = -ENODEV; - assert(is_valid_entity(handle) && (buffer != (uintptr_t)NULL)); + assert(is_valid_entity(handle)); +#ifndef PLAT_ALLOW_ZERO_ADDR_COPY + assert(buffer != (uintptr_t)NULL); +#endif io_entity_t *entity = (io_entity_t *)handle; -- cgit