From 880f49cfa5ae4762e59e0d1c6b1c70b9889edbdb Mon Sep 17 00:00:00 2001 From: TuxSH Date: Mon, 7 May 2018 23:57:56 +0200 Subject: [PATCH] Fix inverted condition issue in check_32bit_address_range_loadable --- fusee/fusee-primary/src/stage2.c | 2 +- fusee/fusee-primary/src/utils.h | 2 +- fusee/fusee-secondary/src/utils.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fusee/fusee-primary/src/stage2.c b/fusee/fusee-primary/src/stage2.c index f58bd3592..59c214878 100644 --- a/fusee/fusee-primary/src/stage2.c +++ b/fusee/fusee-primary/src/stage2.c @@ -90,7 +90,7 @@ void load_stage2(const char *bct0) { } if (!check_32bit_address_range_loadable(config.load_address, size)) { - printk("Error: Stage2 has an invalid load address & size combination!\n"); + printk("Error: Stage2 has an invalid load address & size combination (0x%08x 0x%08x)!\n", config.load_address, size); generic_panic(); } diff --git a/fusee/fusee-primary/src/utils.h b/fusee/fusee-primary/src/utils.h index 3d60797b9..246c3acea 100644 --- a/fusee/fusee-primary/src/utils.h +++ b/fusee/fusee-primary/src/utils.h @@ -78,7 +78,7 @@ static inline bool check_32bit_address_loadable(uintptr_t addr) { static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) { return - __builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */ + !__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */ check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */ !(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */ ; diff --git a/fusee/fusee-secondary/src/utils.h b/fusee/fusee-secondary/src/utils.h index fca9039aa..413a4bdf4 100644 --- a/fusee/fusee-secondary/src/utils.h +++ b/fusee/fusee-secondary/src/utils.h @@ -78,7 +78,7 @@ static inline bool check_32bit_address_loadable(uintptr_t addr) { static inline bool check_32bit_address_range_loadable(uintptr_t addr, size_t size) { return - __builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */ + !__builtin_add_overflow_p(addr, size, (uintptr_t)0) && /* the range doesn't overflow */ check_32bit_address_loadable(addr) && check_32bit_address_loadable(addr + size) && /* bounds are valid */ !(addr >= 0x40010000u && addr + size >= 0x40040000u) /* the range doesn't cross MMIO */ ;