All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally
@ 2019-05-03 19:19 Simon Goldschmidt
  2019-05-04  7:04 ` Lokesh Vutla
  2019-05-10 11:12 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Goldschmidt @ 2019-05-03 19:19 UTC (permalink / raw)
  To: u-boot

This function merely relocates the fdt blob, so don't let it alter
it by adding reservations that didn't exist before.

Instead, if the memory used for the fdt blob has been reserved
before calling this function, ensure the relocated memory is
marked as reserved instead.

Reported-by: Keerthy <j-keerthy@ti.com>
Reported-by: Lokesh Vutla <lokeshvutla@ti.com>
Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 common/fdt_support.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/common/fdt_support.c b/common/fdt_support.c
index ab08a0114f..4e7cf6ebe9 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -597,6 +597,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
 	uint64_t addr, size;
 	int total, ret;
 	uint actualsize;
+	int fdt_memrsv = 0;
 
 	if (!blob)
 		return 0;
@@ -606,6 +607,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
 		fdt_get_mem_rsv(blob, i, &addr, &size);
 		if (addr == (uintptr_t)blob) {
 			fdt_del_mem_rsv(blob, i);
+			fdt_memrsv = 1;
 			break;
 		}
 	}
@@ -627,10 +629,12 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
 	/* Change the fdt header to reflect the correct size */
 	fdt_set_totalsize(blob, actualsize);
 
-	/* Add the new reservation */
-	ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize);
-	if (ret < 0)
-		return ret;
+	if (fdt_memrsv) {
+		/* Add the new reservation */
+		ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize);
+		if (ret < 0)
+			return ret;
+	}
 
 	return actualsize;
 }
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally
  2019-05-03 19:19 [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally Simon Goldschmidt
@ 2019-05-04  7:04 ` Lokesh Vutla
  2019-05-10 11:12 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Lokesh Vutla @ 2019-05-04  7:04 UTC (permalink / raw)
  To: u-boot



On 04/05/19 12:49 AM, Simon Goldschmidt wrote:
> This function merely relocates the fdt blob, so don't let it alter
> it by adding reservations that didn't exist before.
> 
> Instead, if the memory used for the fdt blob has been reserved
> before calling this function, ensure the relocated memory is
> marked as reserved instead.
> 
> Reported-by: Keerthy <j-keerthy@ti.com>
> Reported-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

> ---
> 
>  common/fdt_support.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index ab08a0114f..4e7cf6ebe9 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -597,6 +597,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
>  	uint64_t addr, size;
>  	int total, ret;
>  	uint actualsize;
> +	int fdt_memrsv = 0;
>  
>  	if (!blob)
>  		return 0;
> @@ -606,6 +607,7 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
>  		fdt_get_mem_rsv(blob, i, &addr, &size);
>  		if (addr == (uintptr_t)blob) {
>  			fdt_del_mem_rsv(blob, i);
> +			fdt_memrsv = 1;
>  			break;
>  		}
>  	}
> @@ -627,10 +629,12 @@ int fdt_shrink_to_minimum(void *blob, uint extrasize)
>  	/* Change the fdt header to reflect the correct size */
>  	fdt_set_totalsize(blob, actualsize);
>  
> -	/* Add the new reservation */
> -	ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize);
> -	if (ret < 0)
> -		return ret;
> +	if (fdt_memrsv) {
> +		/* Add the new reservation */
> +		ret = fdt_add_mem_rsv(blob, map_to_sysmem(blob), actualsize);
> +		if (ret < 0)
> +			return ret;
> +	}
>  
>  	return actualsize;
>  }
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally
  2019-05-03 19:19 [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally Simon Goldschmidt
  2019-05-04  7:04 ` Lokesh Vutla
@ 2019-05-10 11:12 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2019-05-10 11:12 UTC (permalink / raw)
  To: u-boot

On Fri, May 03, 2019 at 09:19:03PM +0200, Simon Goldschmidt wrote:

> This function merely relocates the fdt blob, so don't let it alter
> it by adding reservations that didn't exist before.
> 
> Instead, if the memory used for the fdt blob has been reserved
> before calling this function, ensure the relocated memory is
> marked as reserved instead.
> 
> Reported-by: Keerthy <j-keerthy@ti.com>
> Reported-by: Lokesh Vutla <lokeshvutla@ti.com>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190510/2f695d10/attachment.sig>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-10 11:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 19:19 [U-Boot] [PATCH] fdt_shrink_to_minimum: do not mark fdt space reserved unconditionally Simon Goldschmidt
2019-05-04  7:04 ` Lokesh Vutla
2019-05-10 11:12 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.