mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Bastian Krause <bst@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>, barebox@lists.infradead.org
Cc: lst@pengutronix.de
Subject: Re: [RFT PATCH master 1/2] ARM: MXS: fix breakage for non-DT boards
Date: Mon, 10 Oct 2022 11:53:35 +0200	[thread overview]
Message-ID: <cef33a0d-c2d3-d954-ed74-320cfbba6500@pengutronix.de> (raw)
In-Reply-To: <20221010061235.2084562-1-a.fatoum@pengutronix.de>

On 10/10/22 08:12, Ahmad Fatoum wrote:
> boarddata, the third argument passed from barebox PBL to barebox proper,
> is usually either a pointer to an optionally compressed flattened device tree
> or a machien type integer casted to a pointer.
> 
> In order to support device trees located in the first 8192 bytes of
> address space, barebox has been trying to dereference boarddata, before
> falling back to treating it as integer.
> 
> This resulted in breakage as boarddata may be an integer not divisible
> by 4 and thus an unaligned exception would occur.
> 
> The already existing barebox_arm_boarddata mechanism sidesteps this
> issue: With it, the machine type integer is not passed as is, but the
> address of a suitably aligned structure that contains it is passed
> instead.
> 
> Searching for MACHINE_TYPE in arch/arm/boards shows 5 boards to be
> affected in-tree, which are all fixed with this commit.

No matches for MACHINE_TYPE in arch/arm/boards. The search string should
probably be something like ".machine =", right?

> 
> Fixes: 390bc7834ffc ("ARM: start: check for machine type last")
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> @Bastian, could you give this a test on your i.MX23 board?

This does not work, yet. The board code is not executed.

Regards,
Bastian

> ---
>   arch/arm/boards/chumby_falconwing/lowlevel.c     | 10 +++++++++-
>   arch/arm/boards/crystalfontz-cfa10036/lowlevel.c | 10 +++++++++-
>   arch/arm/boards/freescale-mx23-evk/lowlevel.c    | 10 +++++++++-
>   arch/arm/boards/imx233-olinuxino/lowlevel.c      | 10 +++++++++-
>   arch/arm/boards/karo-tx28/lowlevel.c             | 10 +++++++++-
>   5 files changed, 45 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/boards/chumby_falconwing/lowlevel.c b/arch/arm/boards/chumby_falconwing/lowlevel.c
> index 091dd1955260..367f348ee829 100644
> --- a/arch/arm/boards/chumby_falconwing/lowlevel.c
> +++ b/arch/arm/boards/chumby_falconwing/lowlevel.c
> @@ -7,8 +7,16 @@
>   #include <mach/imx23-regs.h>
>   #include <generated/mach-types.h>
>   
> +static struct barebox_arm_boarddata boarddata = {
> +	.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
> +	.machine = MACH_TYPE_CHUMBY,
> +};
> +
>   ENTRY_FUNCTION(start_chumby_falconwing, r0, r1, r2)
>   {
> +	void *bd = &boarddata;
> +
>   	arm_cpu_lowlevel_init();
> -	barebox_arm_entry(IMX_MEMORY_BASE, SZ_64M, (void *)MACH_TYPE_CHUMBY);
> +	barebox_arm_entry(IMX_MEMORY_BASE, SZ_64M,
> +			  bd + get_runtime_offset());
>   }
> diff --git a/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c b/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
> index 92b42aa89350..794cbd89a13a 100644
> --- a/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
> +++ b/arch/arm/boards/crystalfontz-cfa10036/lowlevel.c
> @@ -7,8 +7,16 @@
>   #include <mach/imx28-regs.h>
>   #include <generated/mach-types.h>
>   
> +static struct barebox_arm_boarddata boarddata = {
> +	.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
> +	.machine = MACH_TYPE_CFA10036,
> +};
> +
>   ENTRY_FUNCTION(start_cfa10036, r0, r1, r2)
>   {
> +	void *bd = &boarddata;
> +
>   	arm_cpu_lowlevel_init();
> -	barebox_arm_entry(IMX_MEMORY_BASE, SZ_128M, (void *)MACH_TYPE_CFA10036);
> +	barebox_arm_entry(IMX_MEMORY_BASE, SZ_128M,
> +			  bd + get_runtime_offset());
>   }
> diff --git a/arch/arm/boards/freescale-mx23-evk/lowlevel.c b/arch/arm/boards/freescale-mx23-evk/lowlevel.c
> index 62560bbff733..c795019d8b76 100644
> --- a/arch/arm/boards/freescale-mx23-evk/lowlevel.c
> +++ b/arch/arm/boards/freescale-mx23-evk/lowlevel.c
> @@ -7,8 +7,16 @@
>   #include <asm/barebox-arm.h>
>   #include <mach/imx23-regs.h>
>   
> +static struct barebox_arm_boarddata boarddata = {
> +	.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
> +	.machine = MACH_TYPE_MX23EVK,
> +};
> +
>   ENTRY_FUNCTION(start_imx23_evk, r0, r1, r2)
>   {
> +	void *bd = &boarddata;
> +
>   	arm_cpu_lowlevel_init();
> -	barebox_arm_entry(IMX_MEMORY_BASE, SZ_32M, (void *)MACH_TYPE_MX23EVK);
> +	barebox_arm_entry(IMX_MEMORY_BASE, SZ_32M,
> +			  bd + get_runtime_offset());
>   }
> diff --git a/arch/arm/boards/imx233-olinuxino/lowlevel.c b/arch/arm/boards/imx233-olinuxino/lowlevel.c
> index 71fc379f0487..9dd45e78062b 100644
> --- a/arch/arm/boards/imx233-olinuxino/lowlevel.c
> +++ b/arch/arm/boards/imx233-olinuxino/lowlevel.c
> @@ -11,9 +11,17 @@
>   #include <mach/iomux.h>
>   #include <generated/mach-types.h>
>   
> +static struct barebox_arm_boarddata boarddata = {
> +	.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
> +	.machine = MACH_TYPE_IMX233_OLINUXINO,
> +};
> +
>   ENTRY_FUNCTION(start_barebox_olinuxino_imx23, r0, r1, r2)
>   {
> -	barebox_arm_entry(IMX_MEMORY_BASE, SZ_64M, (void *)MACH_TYPE_IMX233_OLINUXINO);
> +	void *bd = &boarddata;
> +
> +	barebox_arm_entry(IMX_MEMORY_BASE, SZ_64M,
> +			  bd + get_runtime_offset());
>   }
>   
>   static const uint32_t pad_setup[] = {
> diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
> index 28d96f3e1a5f..868218f83b86 100644
> --- a/arch/arm/boards/karo-tx28/lowlevel.c
> +++ b/arch/arm/boards/karo-tx28/lowlevel.c
> @@ -15,9 +15,17 @@
>   #include <stmp-device.h>
>   #include <generated/mach-types.h>
>   
> +static struct barebox_arm_boarddata boarddata = {
> +	.magic = BAREBOX_ARM_BOARDDATA_MAGIC,
> +	.machine = MACH_TYPE_TX28,
> +};
> +
>   ENTRY_FUNCTION(start_barebox_karo_tx28, r0, r1, r2)
>   {
> -	barebox_arm_entry(IMX_MEMORY_BASE, SZ_128M, (void *)MACH_TYPE_TX28);
> +	void *bd = &boarddata;
> +
> +	barebox_arm_entry(IMX_MEMORY_BASE, SZ_128M,
> +			  bd + get_runtime_offset());
>   }
>   
>   static const uint32_t iomux_pads[] = {

-- 
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 |




      parent reply	other threads:[~2022-10-10  9:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10  6:12 Ahmad Fatoum
2022-10-10  6:12 ` [RFT PATCH 2/2] ARM: start: drop support for machine type casted to boarddata pointer Ahmad Fatoum
2022-10-10  9:53 ` Bastian Krause [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cef33a0d-c2d3-d954-ed74-320cfbba6500@pengutronix.de \
    --to=bst@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=lst@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox