mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] FIT: support kernel images with type = "kernel_noload"
@ 2023-11-29 20:31 Ahmad Fatoum
  2023-12-05  7:56 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2023-11-29 20:31 UTC (permalink / raw)
  To: barebox; +Cc: Simon Glass, Ahmad Fatoum

U-Boot interprets "kernel_noload" to mean that the load and entry
addresses shall be ignored[1] and that the kernel image should be executed
in-place, unless compressed[2]. The entry and load addresses are still
mandatory and need to be initialized to some dummy value according to
spec[3].

barebox, which is unaware of any special semantics for the kernel_noload
type, would thus try to place a kernel_noload image at the dummy load
address specified and fail if that's not possible. Fix this by treating
type = "kernel_noload" as if load and entry properties were omitted,
in which case barebox falls back to find a suitable memory region at
runtime.

This change is motivated by the Linux kernel series adding FIT as
additional Kbuild target for ARM64[4]. With the change here, it's possible
to consume these FIT images in barebox as well.

[1]: U-Boot commit b9b50e89d317 ("image: Implement IH_TYPE_KERNEL_NOLOAD")
[2]: https://patchwork.ozlabs.org/project/uboot/list/?series=382849&state=*
[3]: https://github.com/open-source-firmware/flat-image-tree/releases/download/v0.8/fit-specification-v0.8.pdf
[4]: https://lore.kernel.org/linux-arm-kernel/20231129172200.430674-1-sjg@chromium.org/T/#meb5bda548de8d8d403c67ee90f639923c8a182fa

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/image-fit.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/common/image-fit.c b/common/image-fit.c
index 0352dc5cbd0c..5ef5013bd41d 100644
--- a/common/image-fit.c
+++ b/common/image-fit.c
@@ -545,6 +545,7 @@ int fit_get_image_address(struct fit_handle *handle, void *configuration,
 {
 	struct device_node *image;
 	const char *unit = name;
+	const char *type;
 	int ret;
 
 	if (!address || !property || !name)
@@ -554,6 +555,11 @@ int fit_get_image_address(struct fit_handle *handle, void *configuration,
 	if (ret)
 		return ret;
 
+	/* Treat type = "kernel_noload" as if entry/load address is missing */
+	ret = of_property_read_string(image, "type", &type);
+	if (!ret && !strcmp(type, "kernel_noload"))
+	    return -ENOENT;
+
 	ret = fit_get_address(image, property, address);
 
 	return ret;
-- 
2.39.2




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

* Re: [PATCH] FIT: support kernel images with type = "kernel_noload"
  2023-11-29 20:31 [PATCH] FIT: support kernel images with type = "kernel_noload" Ahmad Fatoum
@ 2023-12-05  7:56 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2023-12-05  7:56 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, Simon Glass

On Wed, Nov 29, 2023 at 09:31:06PM +0100, Ahmad Fatoum wrote:
> U-Boot interprets "kernel_noload" to mean that the load and entry
> addresses shall be ignored[1] and that the kernel image should be executed
> in-place, unless compressed[2]. The entry and load addresses are still
> mandatory and need to be initialized to some dummy value according to
> spec[3].
> 
> barebox, which is unaware of any special semantics for the kernel_noload
> type, would thus try to place a kernel_noload image at the dummy load
> address specified and fail if that's not possible. Fix this by treating
> type = "kernel_noload" as if load and entry properties were omitted,
> in which case barebox falls back to find a suitable memory region at
> runtime.
> 
> This change is motivated by the Linux kernel series adding FIT as
> additional Kbuild target for ARM64[4]. With the change here, it's possible
> to consume these FIT images in barebox as well.
> 
> [1]: U-Boot commit b9b50e89d317 ("image: Implement IH_TYPE_KERNEL_NOLOAD")
> [2]: https://patchwork.ozlabs.org/project/uboot/list/?series=382849&state=*
> [3]: https://github.com/open-source-firmware/flat-image-tree/releases/download/v0.8/fit-specification-v0.8.pdf
> [4]: https://lore.kernel.org/linux-arm-kernel/20231129172200.430674-1-sjg@chromium.org/T/#meb5bda548de8d8d403c67ee90f639923c8a182fa
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/image-fit.c | 6 ++++++
>  1 file changed, 6 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/common/image-fit.c b/common/image-fit.c
> index 0352dc5cbd0c..5ef5013bd41d 100644
> --- a/common/image-fit.c
> +++ b/common/image-fit.c
> @@ -545,6 +545,7 @@ int fit_get_image_address(struct fit_handle *handle, void *configuration,
>  {
>  	struct device_node *image;
>  	const char *unit = name;
> +	const char *type;
>  	int ret;
>  
>  	if (!address || !property || !name)
> @@ -554,6 +555,11 @@ int fit_get_image_address(struct fit_handle *handle, void *configuration,
>  	if (ret)
>  		return ret;
>  
> +	/* Treat type = "kernel_noload" as if entry/load address is missing */
> +	ret = of_property_read_string(image, "type", &type);
> +	if (!ret && !strcmp(type, "kernel_noload"))
> +	    return -ENOENT;
> +
>  	ret = fit_get_address(image, property, address);
>  
>  	return ret;
> -- 
> 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] 2+ messages in thread

end of thread, other threads:[~2023-12-05  7:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 20:31 [PATCH] FIT: support kernel images with type = "kernel_noload" Ahmad Fatoum
2023-12-05  7:56 ` Sascha Hauer

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