diff mbox series

[v2] sandbox: Fix set_working_fdt_addr users

Message ID 20180926130219.3551-1-agraf@suse.de
State Accepted
Commit eaac4fb296b1899369e49d941f2c0d346c7f5c7a
Headers show
Series [v2] sandbox: Fix set_working_fdt_addr users | expand

Commit Message

Alexander Graf Sept. 26, 2018, 1:02 p.m. UTC
When running sandbox with the new pointer sanitization we just recently
introduced, we're running into a case with FIT images where we end up
interpreting pointers as addresses.

What happened is that most callers of set_working_fdt_addr() simply
convert pointers into addresses without taking into account that they
might be 2 separate address spaces. Fix the callers up to map their
pointers into addresses.

This makes sandbox tests pass for me again.

Signed-off-by: Alexander Graf <agraf@suse.de>

---

v1 -> v2:

  - convert callers instead of API, as the main user of
    set_working_fdt_addr() is address based
---
 common/bootm.c     | 2 +-
 common/image-fdt.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Glass Sept. 27, 2018, 1:41 p.m. UTC | #1
On 26 September 2018 at 06:02, Alexander Graf <agraf@suse.de> wrote:
> When running sandbox with the new pointer sanitization we just recently
> introduced, we're running into a case with FIT images where we end up
> interpreting pointers as addresses.
>
> What happened is that most callers of set_working_fdt_addr() simply
> convert pointers into addresses without taking into account that they
> might be 2 separate address spaces. Fix the callers up to map their
> pointers into addresses.
>
> This makes sandbox tests pass for me again.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
>
> ---
>
> v1 -> v2:
>
>   - convert callers instead of API, as the main user of
>     set_working_fdt_addr() is address based
> ---
>  common/bootm.c     | 2 +-
>  common/image-fdt.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/common/bootm.c b/common/bootm.c
index e517d9f118..8bf84ebcb7 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -262,7 +262,7 @@  int bootm_find_images(int flag, int argc, char * const argv[])
 		puts("Could not find a valid device tree\n");
 		return 1;
 	}
-	set_working_fdt_addr((ulong)images.ft_addr);
+	set_working_fdt_addr(map_to_sysmem(images.ft_addr));
 #endif
 
 #if IMAGE_ENABLE_FIT
diff --git a/common/image-fdt.c b/common/image-fdt.c
index 9b41f16248..95748f0ae1 100644
--- a/common/image-fdt.c
+++ b/common/image-fdt.c
@@ -193,7 +193,7 @@  int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
 	*of_flat_tree = of_start;
 	*of_size = of_len;
 
-	set_working_fdt_addr((ulong)*of_flat_tree);
+	set_working_fdt_addr(map_to_sysmem(*of_flat_tree));
 	return 0;
 
 error: