diff mbox series

board: freescale: imx93_evk: Fix MMC environment offset boot conflict.

Message ID AS8PR08MB7991E5845AE39CCAEDFC99DCEC9A9@AS8PR08MB7991.eurprd08.prod.outlook.com
State Accepted
Commit dbdf4a06ec4994e1492ae5dbb691509adfb4ce5a
Delegated to: Stefano Babic
Headers show
Series board: freescale: imx93_evk: Fix MMC environment offset boot conflict. | expand

Commit Message

Ken Sloat April 11, 2023, 8:40 p.m. UTC
From 734bfa4e4556976fe85c741f13ae94161cae97e6 Mon Sep 17 00:00:00 2001
From: Ken Sloat <ken.s@variscite.com>
Date: Tue, 11 Apr 2023 16:05:31 -0400

Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
chosen environment offset in the config is 0x400000. Unless the user
programs the associated fuses, this offset is the default secondary boot
image offset used by the i.MX 93 ROM bootloader. With certain
combinations of environmental variables, the CRC and beginning of the
environment can potentially falsely appear as a valid boot image
container header. If the expected "sw_version" offset within this
mistaken boot image container is greater than the primary's, the ROM
bootloader can skip booting of the primary image altogether and attempt
to boot with the content of the environment data. This will then hang
the system.

To fix this, move the environment from 0x400000 to 0x700000 reserving up
to 3 MB at 0x400000 for any actual secondary user image container.

Signed-off-by: Ken Sloat <ken.s@variscite.com>
---
 configs/imx93_11x11_evk_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ken Sloat April 20, 2023, 1:45 p.m. UTC | #1
Hi Peng,

I wanted to follow-up with you to see if you had time to review this patch.

Thanks

Sincerely,
Ken Sloat


From: Ken Sloat
Sent: Tuesday, April 11, 2023 4:40 PM
To: peng.fan@nxp.com <peng.fan@nxp.com>; u-boot@lists.denx.de <u-boot@lists.denx.de>; Ken Sloat <ken.s@variscite.com>
Cc: Nate Drude <Nate.D@variscite.com>
Subject: [PATCH] board: freescale: imx93_evk: Fix MMC environment offset boot conflict. 
 
From 734bfa4e4556976fe85c741f13ae94161cae97e6 Mon Sep 17 00:00:00 2001
From: Ken Sloat <ken.s@variscite.com>
Date: Tue, 11 Apr 2023 16:05:31 -0400

Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
chosen environment offset in the config is 0x400000. Unless the user
programs the associated fuses, this offset is the default secondary boot
image offset used by the i.MX 93 ROM bootloader. With certain
combinations of environmental variables, the CRC and beginning of the
environment can potentially falsely appear as a valid boot image
container header. If the expected "sw_version" offset within this
mistaken boot image container is greater than the primary's, the ROM
bootloader can skip booting of the primary image altogether and attempt
to boot with the content of the environment data. This will then hang
the system.

To fix this, move the environment from 0x400000 to 0x700000 reserving up
to 3 MB at 0x400000 for any actual secondary user image container.

Signed-off-by: Ken Sloat <ken.s@variscite.com>
---
 configs/imx93_11x11_evk_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/imx93_11x11_evk_defconfig b/configs/imx93_11x11_evk_defconfig
index 4f8777161e..db94bbfdd1 100644
--- a/configs/imx93_11x11_evk_defconfig
+++ b/configs/imx93_11x11_evk_defconfig
@@ -7,7 +7,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_ENV_SIZE=0x4000
-CONFIG_ENV_OFFSET=0x400000
+CONFIG_ENV_OFFSET=0x700000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx93-11x11-evk"
 CONFIG_SPL_TEXT_BASE=0x2049A000
Peng Fan (OSS) April 20, 2023, 1:46 p.m. UTC | #2
On 4/12/2023 4:40 AM, Ken Sloat wrote:
>  From 734bfa4e4556976fe85c741f13ae94161cae97e6 Mon Sep 17 00:00:00 2001
> From: Ken Sloat <ken.s@variscite.com>
> Date: Tue, 11 Apr 2023 16:05:31 -0400
> 
> Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
> chosen environment offset in the config is 0x400000. Unless the user
> programs the associated fuses, this offset is the default secondary boot
> image offset used by the i.MX 93 ROM bootloader. With certain
> combinations of environmental variables, the CRC and beginning of the
> environment can potentially falsely appear as a valid boot image
> container header. If the expected "sw_version" offset within this
> mistaken boot image container is greater than the primary's, the ROM
> bootloader can skip booting of the primary image altogether and attempt
> to boot with the content of the environment data. This will then hang
> the system.
> 
> To fix this, move the environment from 0x400000 to 0x700000 reserving up
> to 3 MB at 0x400000 for any actual secondary user image container.
> 
> Signed-off-by: Ken Sloat <ken.s@variscite.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> ---
>   configs/imx93_11x11_evk_defconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configs/imx93_11x11_evk_defconfig b/configs/imx93_11x11_evk_defconfig
> index 4f8777161e..db94bbfdd1 100644
> --- a/configs/imx93_11x11_evk_defconfig
> +++ b/configs/imx93_11x11_evk_defconfig
> @@ -7,7 +7,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
>   CONFIG_SPL_LIBGENERIC_SUPPORT=y
>   CONFIG_NR_DRAM_BANKS=2
>   CONFIG_ENV_SIZE=0x4000
> -CONFIG_ENV_OFFSET=0x400000
> +CONFIG_ENV_OFFSET=0x700000
>   CONFIG_DM_GPIO=y
>   CONFIG_DEFAULT_DEVICE_TREE="imx93-11x11-evk"
>   CONFIG_SPL_TEXT_BASE=0x2049A000
Ken Sloat June 26, 2023, 2:08 p.m. UTC | #3
From: Peng Fan <peng.fan@oss.nxp.com>
Sent: Thursday, April 20, 2023 9:46 AM
To: Ken Sloat <ken.s@variscite.com>; Peng Fan <peng.fan@nxp.com>; u-boot@lists.denx.de <u-boot@lists.denx.de>
Cc: Nate Drude <Nate.D@variscite.com>
Subject: Re: [PATCH] board: freescale: imx93_evk: Fix MMC environment offset boot conflict. 
 
Hi Stefano,

On 4/12/2023 4:40 AM, Ken Sloat wrote:
>  From 734bfa4e4556976fe85c741f13ae94161cae97e6 Mon Sep 17 00:00:00 2001
> From: Ken Sloat <ken.s@variscite.com>
> Date: Tue, 11 Apr 2023 16:05:31 -0400
> 
> Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
> chosen environment offset in the config is 0x400000. Unless the user
> programs the associated fuses, this offset is the default secondary boot
> image offset used by the i.MX 93 ROM bootloader. With certain
> combinations of environmental variables, the CRC and beginning of the
> environment can potentially falsely appear as a valid boot image
> container header. If the expected "sw_version" offset within this
> mistaken boot image container is greater than the primary's, the ROM
> bootloader can skip booting of the primary image altogether and attempt
> to boot with the content of the environment data. This will then hang
> the system.
> 
> To fix this, move the environment from 0x400000 to 0x700000 reserving up
> to 3 MB at 0x400000 for any actual secondary user image container.
> 
> Signed-off-by: Ken Sloat <ken.s@variscite.com>

Reviewed-by: Peng Fan <peng.fan@nxp.com>

> ---
>   configs/imx93_11x11_evk_defconfig | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configs/imx93_11x11_evk_defconfig b/configs/imx93_11x11_evk_defconfig
> index 4f8777161e..db94bbfdd1 100644
> --- a/configs/imx93_11x11_evk_defconfig
> +++ b/configs/imx93_11x11_evk_defconfig
> @@ -7,7 +7,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
>   CONFIG_SPL_LIBGENERIC_SUPPORT=y
>   CONFIG_NR_DRAM_BANKS=2
>   CONFIG_ENV_SIZE=0x4000
> -CONFIG_ENV_OFFSET=0x400000
> +CONFIG_ENV_OFFSET=0x700000
>   CONFIG_DM_GPIO=y
>   CONFIG_DEFAULT_DEVICE_TREE="imx93-11x11-evk"
>   CONFIG_SPL_TEXT_BASE=0x2049A000

Looks like this may have been forgotten about? Just checking...

Thanks

Sincerely,
Ken Sloat
Fabio Estevam June 26, 2023, 2:22 p.m. UTC | #4
On Tue, Apr 11, 2023 at 8:55 PM Ken Sloat <ken.s@variscite.com> wrote:
>
> From 734bfa4e4556976fe85c741f13ae94161cae97e6 Mon Sep 17 00:00:00 2001
> From: Ken Sloat <ken.s@variscite.com>
> Date: Tue, 11 Apr 2023 16:05:31 -0400
>
> Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
> chosen environment offset in the config is 0x400000. Unless the user
> programs the associated fuses, this offset is the default secondary boot
> image offset used by the i.MX 93 ROM bootloader. With certain
> combinations of environmental variables, the CRC and beginning of the
> environment can potentially falsely appear as a valid boot image
> container header. If the expected "sw_version" offset within this
> mistaken boot image container is greater than the primary's, the ROM
> bootloader can skip booting of the primary image altogether and attempt
> to boot with the content of the environment data. This will then hang
> the system.
>
> To fix this, move the environment from 0x400000 to 0x700000 reserving up
> to 3 MB at 0x400000 for any actual secondary user image container.
>
> Signed-off-by: Ken Sloat <ken.s@variscite.com>

Reviewed-by: Fabio Estevam <festevam@denx.de>
Tom Rini June 29, 2023, 10:58 p.m. UTC | #5
On Tue, Apr 11, 2023 at 04:05:31PM -0400, Ken Sloat wrote:

> Currently, the imx93_evk is configured with CONFIG_ENV_IS_IN_MMC and the
> chosen environment offset in the config is 0x400000. Unless the user
> programs the associated fuses, this offset is the default secondary boot
> image offset used by the i.MX 93 ROM bootloader. With certain
> combinations of environmental variables, the CRC and beginning of the
> environment can potentially falsely appear as a valid boot image
> container header. If the expected "sw_version" offset within this
> mistaken boot image container is greater than the primary's, the ROM
> bootloader can skip booting of the primary image altogether and attempt
> to boot with the content of the environment data. This will then hang
> the system.
> 
> To fix this, move the environment from 0x400000 to 0x700000 reserving up
> to 3 MB at 0x400000 for any actual secondary user image container.
> 
> Signed-off-by: Ken Sloat <ken.s@variscite.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Reviewed-by: Fabio Estevam <festevam@denx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/configs/imx93_11x11_evk_defconfig b/configs/imx93_11x11_evk_defconfig
index 4f8777161e..db94bbfdd1 100644
--- a/configs/imx93_11x11_evk_defconfig
+++ b/configs/imx93_11x11_evk_defconfig
@@ -7,7 +7,7 @@  CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_NR_DRAM_BANKS=2
 CONFIG_ENV_SIZE=0x4000
-CONFIG_ENV_OFFSET=0x400000
+CONFIG_ENV_OFFSET=0x700000
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx93-11x11-evk"
 CONFIG_SPL_TEXT_BASE=0x2049A000