mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] common: bootm: support locating kernel in FIT image in zero page
@ 2023-07-18 10:02 Ahmad Fatoum
  2023-07-18 11:22 ` Steffen Trumtrar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2023-07-18 10:02 UTC (permalink / raw)
  To: barebox; +Cc: Steffen Trumtrar, Ahmad Fatoum, Michael Tretter

Since commit 7e2f6a1ffd64 ("uimage: disable zero page when loading to
SDRAM at address 0x0"), we allow locating images loaded from files at
address zero if that's within the SDRAM. This only applied to images
loaded with file_to_sdram() and images that were already in RAM were
still not allowed to overlap the zero page.

Fix this by doing in bootm_load_os() as was done in file_to_sdram(),
namely, disabling zero page trapping for the duration of the memcpy.
We need no further zero page handling afterwards, because kernel is
booted after paging is disabled.

Cc: Michael Tretter <m.tretter@pengutronix.de>
Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/bootm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/common/bootm.c b/common/bootm.c
index 791d6b8fbbf1..4845c40958ae 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -13,6 +13,7 @@
 #include <linux/stat.h>
 #include <magicvar.h>
 #include <uncompress.h>
+#include <zero_page.h>
 
 static LIST_HEAD(handler_list);
 
@@ -119,7 +120,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
 				(unsigned long long)load_address + kernel_size - 1);
 			return -ENOMEM;
 		}
-		memcpy((void *)load_address, kernel, kernel_size);
+		zero_page_memcpy((void *)load_address, kernel, kernel_size);
 		return 0;
 	}
 
-- 
2.39.2




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

* Re: [PATCH] common: bootm: support locating kernel in FIT image in zero page
  2023-07-18 10:02 [PATCH] common: bootm: support locating kernel in FIT image in zero page Ahmad Fatoum
@ 2023-07-18 11:22 ` Steffen Trumtrar
  2023-07-21  7:03 ` Michael Tretter
  2023-07-26 10:17 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Steffen Trumtrar @ 2023-07-18 11:22 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Michael Tretter

On Tue, Jul 18, 2023 at 12:02:48PM +0200, Ahmad Fatoum wrote:
> Since commit 7e2f6a1ffd64 ("uimage: disable zero page when loading to
> SDRAM at address 0x0"), we allow locating images loaded from files at
> address zero if that's within the SDRAM. This only applied to images
> loaded with file_to_sdram() and images that were already in RAM were
> still not allowed to overlap the zero page.
> 
> Fix this by doing in bootm_load_os() as was done in file_to_sdram(),
> namely, disabling zero page trapping for the duration of the memcpy.
> We need no further zero page handling afterwards, because kernel is
> booted after paging is disabled.
> 
> Cc: Michael Tretter <m.tretter@pengutronix.de>
> Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/bootm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 791d6b8fbbf1..4845c40958ae 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -13,6 +13,7 @@
>  #include <linux/stat.h>
>  #include <magicvar.h>
>  #include <uncompress.h>
> +#include <zero_page.h>
>  
>  static LIST_HEAD(handler_list);
>  
> @@ -119,7 +120,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
>  				(unsigned long long)load_address + kernel_size - 1);
>  			return -ENOMEM;
>  		}
> -		memcpy((void *)load_address, kernel, kernel_size);
> +		zero_page_memcpy((void *)load_address, kernel, kernel_size);
>  		return 0;
>  	}
>  
> -- 

This works for me \o/

Tested-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>


Thanks,
Steffen

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] common: bootm: support locating kernel in FIT image in zero page
  2023-07-18 10:02 [PATCH] common: bootm: support locating kernel in FIT image in zero page Ahmad Fatoum
  2023-07-18 11:22 ` Steffen Trumtrar
@ 2023-07-21  7:03 ` Michael Tretter
  2023-07-26 10:17 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Tretter @ 2023-07-21  7:03 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Steffen Trumtrar

On Tue, 18 Jul 2023 12:02:48 +0200, Ahmad Fatoum wrote:
> Since commit 7e2f6a1ffd64 ("uimage: disable zero page when loading to
> SDRAM at address 0x0"), we allow locating images loaded from files at
> address zero if that's within the SDRAM. This only applied to images
> loaded with file_to_sdram() and images that were already in RAM were
> still not allowed to overlap the zero page.
> 
> Fix this by doing in bootm_load_os() as was done in file_to_sdram(),
> namely, disabling zero page trapping for the duration of the memcpy.
> We need no further zero page handling afterwards, because kernel is
> booted after paging is disabled.
> 
> Cc: Michael Tretter <m.tretter@pengutronix.de>
> Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>

Reviewed-by: Michael Tretter <m.tretter@pengutronix.de>

> ---
>  common/bootm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 791d6b8fbbf1..4845c40958ae 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -13,6 +13,7 @@
>  #include <linux/stat.h>
>  #include <magicvar.h>
>  #include <uncompress.h>
> +#include <zero_page.h>
>  
>  static LIST_HEAD(handler_list);
>  
> @@ -119,7 +120,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
>  				(unsigned long long)load_address + kernel_size - 1);
>  			return -ENOMEM;
>  		}
> -		memcpy((void *)load_address, kernel, kernel_size);
> +		zero_page_memcpy((void *)load_address, kernel, kernel_size);
>  		return 0;
>  	}
>  
> -- 
> 2.39.2
> 
> 



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

* Re: [PATCH] common: bootm: support locating kernel in FIT image in zero page
  2023-07-18 10:02 [PATCH] common: bootm: support locating kernel in FIT image in zero page Ahmad Fatoum
  2023-07-18 11:22 ` Steffen Trumtrar
  2023-07-21  7:03 ` Michael Tretter
@ 2023-07-26 10:17 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2023-07-26 10:17 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Steffen Trumtrar, Michael Tretter

On Tue, Jul 18, 2023 at 12:02:48PM +0200, Ahmad Fatoum wrote:
> Since commit 7e2f6a1ffd64 ("uimage: disable zero page when loading to
> SDRAM at address 0x0"), we allow locating images loaded from files at
> address zero if that's within the SDRAM. This only applied to images
> loaded with file_to_sdram() and images that were already in RAM were
> still not allowed to overlap the zero page.
> 
> Fix this by doing in bootm_load_os() as was done in file_to_sdram(),
> namely, disabling zero page trapping for the duration of the memcpy.
> We need no further zero page handling afterwards, because kernel is
> booted after paging is disabled.
> 
> Cc: Michael Tretter <m.tretter@pengutronix.de>
> Reported-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/bootm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/common/bootm.c b/common/bootm.c
> index 791d6b8fbbf1..4845c40958ae 100644
> --- a/common/bootm.c
> +++ b/common/bootm.c
> @@ -13,6 +13,7 @@
>  #include <linux/stat.h>
>  #include <magicvar.h>
>  #include <uncompress.h>
> +#include <zero_page.h>
>  
>  static LIST_HEAD(handler_list);
>  
> @@ -119,7 +120,7 @@ int bootm_load_os(struct image_data *data, unsigned long load_address)
>  				(unsigned long long)load_address + kernel_size - 1);
>  			return -ENOMEM;
>  		}
> -		memcpy((void *)load_address, kernel, kernel_size);
> +		zero_page_memcpy((void *)load_address, kernel, kernel_size);
>  		return 0;
>  	}
>  
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

end of thread, other threads:[~2023-07-26 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-18 10:02 [PATCH] common: bootm: support locating kernel in FIT image in zero page Ahmad Fatoum
2023-07-18 11:22 ` Steffen Trumtrar
2023-07-21  7:03 ` Michael Tretter
2023-07-26 10:17 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox