platform/kernel/u-boot.git
2 years agodm: core: convert of_machine_is_compatible to livetree
Patrick Delaunay [Tue, 17 May 2022 12:37:05 +0000 (14:37 +0200)]
dm: core: convert of_machine_is_compatible to livetree

Replace in the function of_machine_is_compatible(), the used API
fdt_node_check_compatible() by ofnode_device_is_compatible()
to support a live tree.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
2 years agomkimage: Support signing 'auto' FITs
Sean Anderson [Mon, 16 May 2022 20:11:08 +0000 (16:11 -0400)]
mkimage: Support signing 'auto' FITs

This adds support for signing images in auto-generated FITs. To do this,
we need to add a signature node. The algorithm name property already has
its own option, but we need one for the key name hint. We could have
gone the -G route and added an explicit name for the public key (like
what is done for the private key). However, many places assume the
public key can be constructed from the key dir and hint, and I don't
want to do the refactoring necessary.

As a consequence of this, it is now easier to add public keys to an
existing image without signing something. This could be done all along,
but now you don't have to create an its just to do it. Ideally, we
wouldn't create a FIT at the end. This could be done by calling
fit_image_setup_sig/info.crypto->add_verify_data directly.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agomkimage: Document more misc options
Sean Anderson [Mon, 16 May 2022 20:11:07 +0000 (16:11 -0400)]
mkimage: Document more misc options

Document -G and the secondary image types which can be used with -R.
Also reword the documentation of -s for clarity.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
2 years agoevent: fix static events for CONFIG_NEEDS_MANUAL_RELOC
Ovidiu Panait [Sun, 15 May 2022 18:40:29 +0000 (21:40 +0300)]
event: fix static events for CONFIG_NEEDS_MANUAL_RELOC

Static events do not currently work post-relocation for boards that enable
CONFIG_NEEDS_MANUAL_RELOC. Relocate event handler pointers for all event
spies to fix this.

Tested on Microblaze.

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
2 years agoevent: remove CONFIG_EVENT_DYNAMIC check in event_register()
Ovidiu Panait [Sun, 15 May 2022 18:40:28 +0000 (21:40 +0300)]
event: remove CONFIG_EVENT_DYNAMIC check in event_register()

The whole event_register() function is wrapped in EVENT_DYNAMIC #ifdef
checks, so the inner check is not needed:

 #if CONFIG_IS_ENABLED(EVENT_DYNAMIC)
 ...
 int event_register(...)
 {
     ...
     if (!CONFIG_IS_ENABLED(EVENT_DYNAMIC))
         return -ENOSYS;
 }
 #endif

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
2 years agomtd: mtdpart: Change size type from fdt_addr_t to fdt_size_t
Pali Rohár [Fri, 13 May 2022 20:24:51 +0000 (22:24 +0200)]
mtd: mtdpart: Change size type from fdt_addr_t to fdt_size_t

Set correct type for 3rd argument of ofnode_get_addr_size_index_notrans()
function. It expects fdt_size_t * and not fdt_addr_t *.

When these two types do not have same size then U-Boot throw compile
warning:

    drivers/mtd/mtdpart.c: In function ‘add_mtd_partitions_of’:
    drivers/mtd/mtdpart.c:906:57: warning: passing argument 3 of ‘ofnode_get_addr_size_index_notrans’ from incompatible pointer type [-Wincompatible-pointer-types]
       offset = ofnode_get_addr_size_index_notrans(child, 0, &size);
                                                             ^~~~~
    In file included from include/dm/device.h:13,
                     from include/linux/mtd/mtd.h:26,
                     from include/ubi_uboot.h:28,
                     from drivers/mtd/mtdpart.c:27:
    include/dm/ofnode.h:530:25: note: expected ‘fdt_size_t *’ {aka ‘long long unsigned int *’} but argument is of type ‘fdt_addr_t *’ {aka ‘long unsigned int *’}
                 fdt_size_t *size);
                 ~~~~~~~~~~~~^~~~

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
2 years agoscripts: Introduce {quiet_,}cmd_bin2c
Pierre-Clément Tosi [Wed, 11 May 2022 09:36:07 +0000 (10:36 +0100)]
scripts: Introduce {quiet_,}cmd_bin2c

Add a make command to compile binary files as C data through bin2c with

    $(call,bin2c,<data_name_prefix>)

Note that this requires BUILD_BIN2C=y.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Pierre-Clément Tosi <ptosi@google.com>
2 years agofs/squashfs: fix sqfs_read_sblk()
Heinrich Schuchardt [Tue, 10 May 2022 19:53:25 +0000 (21:53 +0200)]
fs/squashfs: fix sqfs_read_sblk()

Setting sblk = NULL has no effect on the caller.
We want to set *sblk = NULL if an error occurrs to avoid usage after free.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agobtrfs: simplify lookup_data_extent()
Heinrich Schuchardt [Tue, 10 May 2022 19:43:38 +0000 (21:43 +0200)]
btrfs: simplify lookup_data_extent()

After returning if ret <= 0 we know that ret > 0. No need to check it.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain>
2 years agozlib: Port fix for CVE-2018-25032 to U-Boot
Tom Rini [Tue, 10 May 2022 18:36:59 +0000 (14:36 -0400)]
zlib: Port fix for CVE-2018-25032 to U-Boot

While our copy of zlib is missing upstream commit 263b1a05b04e ("Allow
deflatePrime() to insert bits in the middle of a stream.") we do have
Z_FIXED support, and so the majority of the code changes in 5c44459c3b28
("Fix a bug that can crash deflate on some input when using Z_FIXED.")
apply here directly and cleanly.  As this has been assigned a CVE, lets
go and apply these changes.

Link: https://github.com/madler/zlib/commit/5c44459c3b28a9bd3283aaceab7c615f8020c531
Reported-by: "Gan, Yau Wai" <yau.wai.gan@intel.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agomisc: Correct Kconfig dependencies for a number of options
Tom Rini [Tue, 10 May 2022 16:51:47 +0000 (12:51 -0400)]
misc: Correct Kconfig dependencies for a number of options

We have many cases of SPL (or TPL or VPL) drivers that don't depend on
SPL_MISC (and so on) but rather just MISC.

Cc: Sean Anderson <sean.anderson@seco.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Sean Anderson <sean.anderson@seco.com>
2 years agodoc: regulator: Add regulator-force-boot-off binding
Chris Packham [Mon, 9 May 2022 21:58:28 +0000 (09:58 +1200)]
doc: regulator: Add regulator-force-boot-off binding

The actual support was added in commit fec8c900c8b2 ("power: regulator:
Add support for regulator-force-boot-off"), update the docs to include
this.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
2 years agocmd: dm: migrate dm command to use U_BOOT_CMD_WITH_SUBCMDS()
Ovidiu Panait [Sun, 8 May 2022 10:01:42 +0000 (13:01 +0300)]
cmd: dm: migrate dm command to use U_BOOT_CMD_WITH_SUBCMDS()

Migrate dm command to use U_BOOT_CMD_WITH_SUBCMDS() helper macro, to reduce
duplicated code. We can also drop the CONFIG_NEEDS_MANUAL_RELOC exception,
as the command list is updated post relocation in board_r.c initcall
initr_manual_reloc_cmdtable().

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
2 years agodm: fix DM_EVENT dependencies
Heinrich Schuchardt [Sat, 7 May 2022 20:39:01 +0000 (22:39 +0200)]
dm: fix DM_EVENT dependencies

CONFIG_DM_EVENT without CONFIG_EVENT is non-functional.
Let CONFIG_DM_EVENT depend on CONFIG_EVENT.

Remove superfluous stub in include/event.h.

Fixes: 5b896ed5856f ("event: Add events for device probe/remove")
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoboot: image-pre-load: drop unused CONFIG_SYS_BOOTM_LEN
Peng Fan [Sat, 7 May 2022 13:23:05 +0000 (21:23 +0800)]
boot: image-pre-load: drop unused CONFIG_SYS_BOOTM_LEN

CONFIG_SYS_BOOTM_LEN is not used in this file, drop it.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 years agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 6 Jun 2022 16:13:29 +0000 (12:13 -0400)]
configs: Resync with savedefconfig

Rsync all defconfig files using moveconfig.py

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMerge branch '2022-06-06-finish-SPL-Kconfig-migration' into next
Tom Rini [Mon, 6 Jun 2022 16:09:41 +0000 (12:09 -0400)]
Merge branch '2022-06-06-finish-SPL-Kconfig-migration' into next

- Bring in a number of series of patches that migrate all remaining
  CONFIG_SPL symbols to Kconfig, remove some dead code that this
  uncovered and then start to tighten the dependencies in Kconfig now
  that everything is migrated and these relationships can be clearly
  expressed.

2 years agospl: Rework and tighten some dependencies
Tom Rini [Tue, 31 May 2022 14:24:55 +0000 (10:24 -0400)]
spl: Rework and tighten some dependencies

- In a few places, add missing "depends on" that can be implied from the
  option name (i.e. SPL_DM_xxx depends on SPL_DM).
- Make less use of "if SPL_xxx ... endif" clauses as most of the time
  this reads better as depends on.  In the case of UBI however, move it
  all to a sub-menu.
- Rework SPL_NO_CPU_SUPPORT as it's very specific to the
  non-SPL_FRAMEWORK implementation used on those platforms, and a
  tangent to how CONFIG_SPL_START_S_PATH was used.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agospl: Rework Kconfig to be more menu driven
Tom Rini [Mon, 30 May 2022 21:11:23 +0000 (17:11 -0400)]
spl: Rework Kconfig to be more menu driven

Make it so that all of SPL, TPL and VPL are proper menus hidden behind a
gating question.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agospl: Move all VPL, TPL and PowerPC specific CONFIG options to separate files
Tom Rini [Mon, 30 May 2022 21:01:22 +0000 (17:01 -0400)]
spl: Move all VPL, TPL and PowerPC specific CONFIG options to separate files

- Move all PowerPC (and some shared with Layerscape) options to
  common/spl/Kconfig.nxp
- Move all other TPL related options to common/spl/Kconfig.tpl
- Move all VPL related options to common/spl/Kconfig.vpl

This makes the whole of common/spl/Kconfig slightly more readable.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: mvebu: Remove CONFIG_SPL_BOOT_DEVICE
Chris Packham [Sat, 28 May 2022 23:13:18 +0000 (11:13 +1200)]
arm: mvebu: Remove CONFIG_SPL_BOOT_DEVICE

CONFIG_SPL_BOOT_DEVICE was made obsolete by
CONFIG_MVEBU_SPL_BOOT_DEVICE_{SPI,MMC,SATA,UART}.
CONFIG_MVEBU_SPL_BOOT_DEVICE_SPI is the default so existing users of
CONFIG_SPL_BOOT_DEVICE can simply have the option removed.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoConvert CONFIG_FIXED_SDHCI_ALIGNED_BUFFER to Kconfig
Chris Packham [Sat, 28 May 2022 23:13:17 +0000 (11:13 +1200)]
Convert CONFIG_FIXED_SDHCI_ALIGNED_BUFFER to Kconfig

CONFIG_FIXED_SDHCI_ALIGNED_BUFFER is needed on some Marvell SoCs when
booting from MMC. All existing usages of this have the same value so
make this the default and have the Kconfig option depend on SPL &&
MVEBU_SPL_BOOT_DEVICE_MMC.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoarm: mvebu: Use MVEBU_SPL_BOOT_DEVICE instead of SPL_BOOT_DEVICE
Chris Packham [Sat, 28 May 2022 23:13:16 +0000 (11:13 +1200)]
arm: mvebu: Use MVEBU_SPL_BOOT_DEVICE instead of SPL_BOOT_DEVICE

Update the way KWB_CFG_SEC_BOOT_DEV is determined to use
CONFIG_MVEBU_SPL_BOOT_DEVICE_{SPI,MMC} instead of
CONFIG_SPL_BOOT_DEVICE.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoriotboard, syzygy_hub: Disable SPL_FALCON_BOOT_MMCSD
Tom Rini [Sun, 29 May 2022 13:34:42 +0000 (09:34 -0400)]
riotboard, syzygy_hub: Disable SPL_FALCON_BOOT_MMCSD

Looking at the git history and values used for the raw kernel/args
location, it's clear these platforms only ever did Falcon Mode via
filesystem images and not raw MMC/SD locations.  Disable
CONFIG_SPL_FALCON_BOOT_MMCSD.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR et al to Kconfig
Tom Rini [Sat, 28 May 2022 21:21:03 +0000 (17:21 -0400)]
Convert CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR
   CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_NAND_SPL_KERNEL_OFFS to Kconfig
Tom Rini [Sat, 28 May 2022 20:43:53 +0000 (16:43 -0400)]
Convert CONFIG_SYS_NAND_SPL_KERNEL_OFFS to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_NAND_SPL_KERNEL_OFFS

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agospl: Remove CONFIG_SPL_START_S_PATH and rework the logic behind it
Tom Rini [Sat, 28 May 2022 16:40:40 +0000 (12:40 -0400)]
spl: Remove CONFIG_SPL_START_S_PATH and rework the logic behind it

In some cases, when we don't use CONFIG_SPL_FRAMEWORK nor are we on
PowerPC using their specific SPL/TPL framework, we need to specify the
start.S file to use for these typically very constrained systems.  Do
this within the Makefile logic, rather than introducing a string-based
CONFIG option, as this would get slightly complex to do in Kconfig for a
very limited number of users.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoDrop CONFIG_SPL_SIZE
Tom Rini [Sat, 28 May 2022 16:07:26 +0000 (12:07 -0400)]
Drop CONFIG_SPL_SIZE

We do not reference CONFIG_SPL_SIZE in the code, remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoax25-ae350: Move CONFIG_SYS_FDT_BASE to Kconfig
Tom Rini [Sat, 28 May 2022 13:13:59 +0000 (09:13 -0400)]
ax25-ae350: Move CONFIG_SYS_FDT_BASE to Kconfig

The address where the device tree will be passed in to U-Boot at is now
moved to the Kconfig file.  If this is user configurable, it needs to be
exposed rather than hidden, and should probably be renamed as well.

Reviewed-by: Rick Chen <rick@andestech.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_SPL_ARGS_ADDR to Kconfig
Tom Rini [Sat, 28 May 2022 02:06:52 +0000 (22:06 -0400)]
Convert CONFIG_SYS_SPL_ARGS_ADDR to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_SPL_ARGS_ADDR

In doing so, we also consistently use this variable for SPL_OS_BOOT and
not CONFIG_SYS_FDT_BASE in some cases.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_TARGET to Kconfig
Tom Rini [Fri, 27 May 2022 21:13:52 +0000 (17:13 -0400)]
Convert CONFIG_SPL_TARGET to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_TARGET

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoRemove CONFIG_SPL_STACK_SIZE
Tom Rini [Fri, 27 May 2022 20:56:13 +0000 (16:56 -0400)]
Remove CONFIG_SPL_STACK_SIZE

This is not used anywhere, drop it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoDrop CONFIG_SPL_SPI_FLASH_MINIMAL
Tom Rini [Fri, 27 May 2022 20:34:14 +0000 (16:34 -0400)]
Drop CONFIG_SPL_SPI_FLASH_MINIMAL

There are no users of CONFIG_SPL_SPI_FLASH_MINIMAL only platforms
defining it, drop it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_GD_ADDR to Kconfig
Tom Rini [Fri, 27 May 2022 20:19:05 +0000 (16:19 -0400)]
Convert CONFIG_SPL_GD_ADDR to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_GD_ADDR

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoetamin: Remove CONFIG_SPL_CMT defines
Tom Rini [Fri, 27 May 2022 19:20:11 +0000 (15:20 -0400)]
etamin: Remove CONFIG_SPL_CMT defines

These are presumably private to non-upstream code, remove.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoRemove CONFIG_SYS_SPL_LEN largely
Tom Rini [Fri, 27 May 2022 19:18:06 +0000 (15:18 -0400)]
Remove CONFIG_SYS_SPL_LEN largely

This is mostly unused.  In the case where it is currently used, it means
the same as CONFIG_SPL_PAD_TO, which is already set for the platform.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_SPL_MALLOC_SIZE et al to Kconfig
Tom Rini [Fri, 27 May 2022 16:48:32 +0000 (12:48 -0400)]
Convert CONFIG_SYS_SPL_MALLOC_SIZE et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_SPL_MALLOC_SIZE
   CONFIG_SYS_SPL_MALLOC_START

We introduce a default value here as well, and CONFIG_SYS_SPL_MALLOC to
control if we have a malloc pool or not.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_BSS_START_ADDR to Kconfig
Tom Rini [Fri, 27 May 2022 14:19:45 +0000 (10:19 -0400)]
Convert CONFIG_SPL_BSS_START_ADDR to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_BSS_START_ADDR

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_RELOC_TEXT_BASE et al to Kconfig
Tom Rini [Thu, 26 May 2022 20:59:30 +0000 (16:59 -0400)]
Convert CONFIG_SPL_RELOC_TEXT_BASE et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_RELOC_TEXT_BASE
   CONFIG_SPL_RELOC_STACK
   CONFIG_SPL_RELOC_MALLOC_ADDR
   CONFIG_SPL_RELOC_MALLOC_SIZE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_TPL_NAND_INIT to Kconfig
Tom Rini [Thu, 26 May 2022 18:31:57 +0000 (14:31 -0400)]
Convert CONFIG_TPL_NAND_INIT to Kconfig

This converts the following to Kconfig:
   CONFIG_TPL_NAND_INIT

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoimx7: Update CONFIG_SPL_STACK defaults in Kconfig
Tom Rini [Thu, 26 May 2022 17:46:32 +0000 (13:46 -0400)]
imx7: Update CONFIG_SPL_STACK defaults in Kconfig

Update the Kconfig entry to have the correct defaults for i.MX7
platforms, and move the existing large comment from imx7_spl.h to
doc/imx/common/imx7.txt so that it's not lost.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoimx6: Update CONFIG_SPL_STACK defaults in Kconfig
Tom Rini [Thu, 26 May 2022 17:36:17 +0000 (13:36 -0400)]
imx6: Update CONFIG_SPL_STACK defaults in Kconfig

Update the Kconfig entry to have the correct defaults for i.MX6
platforms, and move the existing large comment from imx6_spl.h to
doc/imx/common/imx6.txt so that it's not lost.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_STACK to Kconfig
Tom Rini [Thu, 26 May 2022 17:13:21 +0000 (13:13 -0400)]
Convert CONFIG_SPL_STACK to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_STACK

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoMigrate CUSTOM_SYS_INIT_SP_ADDR to Kconfig using system-constants.h
Tom Rini [Wed, 25 May 2022 16:16:03 +0000 (12:16 -0400)]
Migrate CUSTOM_SYS_INIT_SP_ADDR to Kconfig using system-constants.h

- Make all users of CUSTOM_SYS_INIT_SP_ADDR reference SYS_INIT_SP_ADDR
- Introduce HAS_CUSTOM_SYS_INIT_SP_ADDR to allow for setting the stack
  pointer directly, otherwise we use the common calculation.
- On some platforms that were using the standard calculation but did not
  set CONFIG_SYS_INIT_RAM_SIZE / CONFIG_SYS_INIT_RAM_ADDR, set them.
- On a small number of platforms that were not subtracting
  GENERATED_GBL_DATA_SIZE do so now via the standard calculation.
- CONFIG_SYS_INIT_SP_OFFSET is now widely unused, so remove it from most
  board config header files.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoIntroduce include/system-constants.h
Tom Rini [Wed, 25 May 2022 14:16:18 +0000 (10:16 -0400)]
Introduce include/system-constants.h

We have a number of CONFIG symbols today that are of the form:
SYM1 = CONST1 + CONST2
or other static math operations (shifts, etc).  The issue is that by
moving these to Kconfig we no longer have the ability to calculate these
values, so they become less flexible and useful.  It's also the case
that sometimes a platform will just define SYM1 directly or perform a
slightly different set of calculations.  We introduce this header now to
have a place to start to handle these cases.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agostih410-b2260: Switch to using GENERATED_GBL_DATA_SIZE
Tom Rini [Tue, 24 May 2022 18:18:11 +0000 (14:18 -0400)]
stih410-b2260: Switch to using GENERATED_GBL_DATA_SIZE

We have GENERATED_GBL_DATA_SIZE to tell us how large the generated
global data is, so do not use a hard-coded value of 1024 for it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agopowerpc: Switch to using CONFIG_SYS_INIT_SP_OFFSET from CONFIG_SYS_GBL_DATA_OFFSET
Tom Rini [Tue, 24 May 2022 18:14:02 +0000 (14:14 -0400)]
powerpc: Switch to using CONFIG_SYS_INIT_SP_OFFSET from CONFIG_SYS_GBL_DATA_OFFSET

In the places where PowerPC references CONFIG_SYS_GBL_DATA_OFFSET it
does so as (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET).  And
it defines CONFIG_SYS_GBL_DATA_OFFSET in the same manner that other
architectures define CONFIG_SYS_INIT_SP_OFFSET. Other architectures
define CONFIG_SYS_INIT_SP_ADDR as (CONFIG_SYS_INIT_RAM_ADDR +
CONFIG_SYS_INIT_SP_OFFSET) typically.  Rename things within PowerPC for
consistency with other architectures.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agompc85xx: Switch to setting the initial stack pointer more clearly
Tom Rini [Tue, 24 May 2022 17:49:56 +0000 (13:49 -0400)]
mpc85xx: Switch to setting the initial stack pointer more clearly

Currently, since we know that in the combination of
CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET all of the "high"
bits are in CONFIG_SYS_INIT_RAM_ADDR and "low" bits are in
CONFIG_SYS_GBL_DATA_OFFSET we reference this separately in start.S, but
added together everywhere else.  For clarity consistency, reference the
combined value here instead.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agom68k: Stop using CONFIG_SYS_GBL_DATA_OFFSET
Tom Rini [Tue, 24 May 2022 17:40:05 +0000 (13:40 -0400)]
m68k: Stop using CONFIG_SYS_GBL_DATA_OFFSET

This value is only referenced by PowerPC code in a way other than
directly as CONFIG_SYS_INIT_SP_ADDR.  Switch to CONFIG_SYS_INIT_SP_ADDR
directly.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: Stop using CONFIG_SYS_GBL_DATA_OFFSET
Tom Rini [Tue, 24 May 2022 17:23:40 +0000 (13:23 -0400)]
arm: Stop using CONFIG_SYS_GBL_DATA_OFFSET

This value is only referenced by PowerPC code in a way other than
directly as CONFIG_SYS_INIT_SP_ADDR.  Switch to CONFIG_SYS_INIT_SP_ADDR
directly.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: Use CONFIG_SPL_STACK or CONFIG_SYS_INIT_SP_ADDR directly.
Tom Rini [Tue, 24 May 2022 17:11:41 +0000 (13:11 -0400)]
arm: Use CONFIG_SPL_STACK or CONFIG_SYS_INIT_SP_ADDR directly.

In some cases, we define CONFIG_SYS_INIT_SP_ADDR differently for SPL or
full U-Boot.  This case should be making use of CONFIG_SPL_STACK, as
that's what that variable is for.  In a few other cases we define
CONFIG_SPL_STACK directly to CONFIG_SYS_INIT_SP_ADDR, but do not need to
as the code handles this correctly, normally.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agomvebu: Use CONFIG_SPL_STACK + 4 directly for bootparam location
Tom Rini [Tue, 24 May 2022 13:57:18 +0000 (09:57 -0400)]
mvebu: Use CONFIG_SPL_STACK + 4 directly for bootparam location

The definition of CONFIG_SPL_BOOTROM_SAVE is always a fixed
CONFIG_SPL_STACK + 4, while CONFIG_SPL_STACK is not constant.  This
change will make it clear where the location is still, once
CONFIG_SPL_STACK moves to Kconfig.

Cc: Stefan Roese <sr@denx.de>
Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: pxa: Remove CONFIG_CPU_PXA25X
Tom Rini [Wed, 25 May 2022 20:13:48 +0000 (16:13 -0400)]
arm: pxa: Remove CONFIG_CPU_PXA25X

There are no platforms that set this, remove the code.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agom68k: Remove dead code
Tom Rini [Wed, 25 May 2022 19:11:18 +0000 (15:11 -0400)]
m68k: Remove dead code

There are no mcf5227x platforms, remove the CPU code.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_COMMON_INIT_DDR to Kconfig
Tom Rini [Sat, 21 May 2022 18:44:28 +0000 (14:44 -0400)]
Convert CONFIG_SPL_COMMON_INIT_DDR to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_COMMON_INIT_DDR

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoppc / layerscape: Clean up CONFIG_SYS_CCSR_DO_NOT_RELOCATE usage
Tom Rini [Sat, 21 May 2022 15:26:27 +0000 (11:26 -0400)]
ppc / layerscape: Clean up CONFIG_SYS_CCSR_DO_NOT_RELOCATE usage

A number of PowerPC platforms define this, for SPL.  To move this to
Kconfig, it needs to be CONFIG_SPL_SYS_CCSR_DO_NOT_RELOCATE, so use
CONFIG_IS_ENABLED() to check for usage.  A number of layerscape
platforms bring this logic from PowerPC, but only need a small part of
it, for the fman driver.  Remove their unused portion at least.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_SYS_MALLOC_SIMPLE to Kconfig
Tom Rini [Fri, 20 May 2022 16:36:05 +0000 (12:36 -0400)]
Convert CONFIG_SPL_SYS_MALLOC_SIMPLE to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_SYS_MALLOC_SIMPLE

The problem here is that a few platforms have been doing:
#ifdef CONFIG_SPL_BUILD
#define CONFIG_SYS_MALLOC_SIMPLE
#endif

instead of defining CONFIG_SPL_SYS_MALLOC_SIMPLE directly.  Correct this
and update the documentation in a few places to match usage.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_BSS_MAX_SIZE et al to Kconfig
Tom Rini [Thu, 19 May 2022 19:09:22 +0000 (15:09 -0400)]
Convert CONFIG_SPL_BSS_MAX_SIZE et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_BSS_MAX_SIZE
   CONFIG_SPL_MAX_FOOTPRINT

Note that the da850evm platforms were violating the "only use one" rule
here, and so now hard-code their BSS limit.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_PAD_TO et al to Kconfig
Tom Rini [Mon, 16 May 2022 21:20:26 +0000 (17:20 -0400)]
Convert CONFIG_SPL_PAD_TO et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_PAD_TO
   CONFIG_SPL_MAX_SIZE
   CONFIG_TPL_PAD_TO
   CONFIG_TPL_MAX_SIZE

Note that we need to make TPL_MAX_SIZE be hex, and so move and convert the
existing places.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_FS_LOAD_PAYLOAD_NAME et al to Kconfig
Tom Rini [Fri, 13 May 2022 21:12:35 +0000 (17:12 -0400)]
Convert CONFIG_SPL_FS_LOAD_PAYLOAD_NAME et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_FS_LOAD_ARGS_NAME
   CONFIG_SPL_FS_LOAD_KERNEL_NAME
   CONFIG_SPL_FS_LOAD_PAYLOAD_NAME

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_NAND_RAW_ONLY et al to Kconfig
Tom Rini [Fri, 13 May 2022 16:46:23 +0000 (12:46 -0400)]
Convert CONFIG_SPL_NAND_RAW_ONLY et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_NAND_RAW_ONLY
   CONFIG_SPL_NAND_SOFTECC

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SPL_INIT_MINIMAL et al to Kconfig
Tom Rini [Fri, 13 May 2022 16:26:35 +0000 (12:26 -0400)]
Convert CONFIG_SPL_INIT_MINIMAL et al to Kconfig

This converts the following to Kconfig:
   CONFIG_SPL_INIT_MINIMAL
   CONFIG_SPL_FLUSH_IMAGE
   CONFIG_SPL_SKIP_RELOCATE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_CFI_FLASH_STATUS_POLL to Kconfig
Tom Rini [Fri, 13 May 2022 13:36:03 +0000 (09:36 -0400)]
Convert CONFIG_SYS_CFI_FLASH_STATUS_POLL to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_CFI_FLASH_STATUS_POLL

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_FLASH_CFI_WIDTH to Kconfig
Tom Rini [Fri, 13 May 2022 13:18:27 +0000 (09:18 -0400)]
Convert CONFIG_SYS_FLASH_CFI_WIDTH to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_FLASH_CFI_WIDTH

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agospl: Remove CONFIG_SPL_SATA_BOOT_DEVICE
Tom Rini [Fri, 13 May 2022 17:37:30 +0000 (13:37 -0400)]
spl: Remove CONFIG_SPL_SATA_BOOT_DEVICE

This is only referenced in non-SPL_DM cases, of which there are
currently none.  Remove this option and slightly re-organize the code is
there is now never an if/else at the start of spl_sata_load_image()

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agofsl-layerscape: Remove CONFIG_SPL_PBL_PAD
Tom Rini [Fri, 13 May 2022 16:42:13 +0000 (12:42 -0400)]
fsl-layerscape: Remove CONFIG_SPL_PBL_PAD

This option is not referenced in code, remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoP1010RDB: Remove CONFIG_SPL_NAND_MINIMAL
Tom Rini [Fri, 13 May 2022 16:14:07 +0000 (12:14 -0400)]
P1010RDB: Remove CONFIG_SPL_NAND_MINIMAL

This symbol is not used anywhere, remove it.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agospl: Remove CONFIG_SPL_BOARD_LOAD_IMAGE
Tom Rini [Thu, 12 May 2022 21:35:40 +0000 (17:35 -0400)]
spl: Remove CONFIG_SPL_BOARD_LOAD_IMAGE

This symbol has been unused in code for some time now, remove
the final references.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: omap2plus: Move CONFIG_SYS_PTV out of CONFIG namespace
Tom Rini [Thu, 12 May 2022 21:22:26 +0000 (17:22 -0400)]
arm: omap2plus: Move CONFIG_SYS_PTV out of CONFIG namespace

This is always defined to 2, and referenced in two places.  Move the
define to <asm/omap_common.h> and make sure the code that uses this
includes that file.  Make <asm/arch-omap*/clock.h> not include that
file, as we don't need to be doing so.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_BOOTPARAMS_LEN to Kconfig
Tom Rini [Thu, 12 May 2022 20:45:08 +0000 (16:45 -0400)]
Convert CONFIG_SYS_BOOTPARAMS_LEN to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_BOOTPARAMS_LEN

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_HUSH_INIT_VAR to Kconfig
Tom Rini [Thu, 12 May 2022 20:12:16 +0000 (16:12 -0400)]
Convert CONFIG_HUSH_INIT_VAR to Kconfig

This converts the following to Kconfig:
   CONFIG_HUSH_INIT_VAR

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_BARGSIZE to Kconfig
Tom Rini [Thu, 12 May 2022 14:02:06 +0000 (10:02 -0400)]
Convert CONFIG_SYS_BARGSIZE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_BARGSIZE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_CBSIZE to Kconfig
Tom Rini [Wed, 11 May 2022 22:01:06 +0000 (18:01 -0400)]
Convert CONFIG_SYS_CBSIZE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_CBSIZE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_PBSIZE to Kconfig
Tom Rini [Wed, 11 May 2022 21:38:09 +0000 (17:38 -0400)]
Convert CONFIG_SYS_PBSIZE to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_PBSIZE

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoConvert CONFIG_SYS_MAXARGS to Kconfig
Tom Rini [Wed, 11 May 2022 20:21:06 +0000 (16:21 -0400)]
Convert CONFIG_SYS_MAXARGS to Kconfig

This converts the following to Kconfig:
   CONFIG_SYS_MAXARGS

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoPrepare v2022.07-rc4
Tom Rini [Mon, 6 Jun 2022 14:25:13 +0000 (10:25 -0400)]
Prepare v2022.07-rc4

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoconfigs: fsl: add missing SYS_FMAN_FW_ADDR defines
Camelia Groza [Thu, 2 Jun 2022 13:47:09 +0000 (16:47 +0300)]
configs: fsl: add missing SYS_FMAN_FW_ADDR defines

Two defconfigs were missed when transitioning the SYS_FMAN_FW_ADDR
symbol to Kconfig. CONFIG_SYS_FMAN_FW_ADDR is currently initialized to
0 by default on these builds, which prevents the firmware from loading.

Add the correct symbols to these defconfigs.

Fixes: a97a071d10d2b ("configs: fsl: migrate FMAN/QE specific defines to Kconfig")
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
2 years agodoc: update mail author for st-dt.rst
Patrick Delaunay [Thu, 2 Jun 2022 16:34:49 +0000 (18:34 +0200)]
doc: update mail author for st-dt.rst

Update author email address with the one dedicated to
upstream activities.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2 years agoMerge tag 'efi-2022-07-rc4-4' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Sat, 4 Jun 2022 13:38:56 +0000 (09:38 -0400)]
Merge tag 'efi-2022-07-rc4-4' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc4-4

UEFI:

* Fix the implementation of the firmware management protocol
* Fix the unit tests for signed update capsules

2 years agoefi: test/py: authenticate fit capsules
Vincent Stehlé [Tue, 31 May 2022 07:55:34 +0000 (09:55 +0200)]
efi: test/py: authenticate fit capsules

Add support for the authentication of UEFI capsules containing FIT images.

The authentication code is moved out of the function handling raw images
into a new function efi_firmware_capsule_authenticate(). The special case
for the FMP header coming from edk2 tools is preserved. There is no
functional change for capsules containing raw images.

The python test for signed capsules with raw images is renamed with no
functional change and a new test is added for signed capsules containing
FIT images.

This can be tested with sandbox64_defconfig or sandbox_flattree_defconfig,
plus CONFIG_EFI_CAPSULE_AUTHENTICATE=y.

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agotest/py: efi_capsule: repair image authentication test
Vincent Stehlé [Tue, 31 May 2022 07:55:33 +0000 (09:55 +0200)]
test/py: efi_capsule: repair image authentication test

Repair the python tests for authenticated EFI capsules, which can be run
with sandbox_defconfig plus CONFIG_EFI_CAPSULE_AUTHENTICATE=y.

- Account for the reset changes done by commit 3e6f81000672 ("efi_loader:
  test/py: Reset system after capsule update on disk").
- Fix the capsule GUID typo introduced by commit 2e9c3c6965ba ("test:
  capsule: Modify the capsule tests to use GUID values for sandbox").

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agoEFI: Update the documentation to reflect the correct value of OsIndications
Sughosh Ganu [Tue, 31 May 2022 07:15:35 +0000 (12:45 +0530)]
EFI: Update the documentation to reflect the correct value of OsIndications

The OsIndications is a 64 bit variable, and the current code expects
the value of the variable to be 64 bit. Update the documentation to
reflect this fact.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoEFI: Populate descriptor_count value only when image_info_size is not zero
Sughosh Ganu [Tue, 31 May 2022 07:15:33 +0000 (12:45 +0530)]
EFI: Populate descriptor_count value only when image_info_size is not zero

The GetImageInfo function of the Firmware Mangement Protocol(FMP) gets
called initially to query the size of the image descriptor array that
would have to be allocated. During this call, the rest of the function
arguments, specifically pointers might be passed as NULL. Do not
populate the descriptor_count value before it is known that the call
to GetImageInfo has been made with the allocated buffer for the image
descriptors.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: environment: Fix typo
Chris Packham [Wed, 25 May 2022 01:08:51 +0000 (13:08 +1200)]
doc: environment: Fix typo

"valu" should be "value".

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoMerge branch '2022-06-03-assorted-fixes'
Tom Rini [Fri, 3 Jun 2022 19:42:13 +0000 (15:42 -0400)]
Merge branch '2022-06-03-assorted-fixes'

- armv8 TCR write bugfix, ubifs bugfix, imx8mq clk bugfixes, two network
  fixes, Add U-Boot version to chosen node, update TI AM64x board
  maintainers

2 years agoboard: ti: am64x: Update MAINTAINERS
Dave Gerlach [Fri, 3 Jun 2022 19:30:20 +0000 (14:30 -0500)]
board: ti: am64x: Update MAINTAINERS

Move maintainership of TI AM64x boards to Vignesh.

Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
2 years agosquashfs: Fix compilation on big endian systems
Pali Rohár [Wed, 6 Apr 2022 21:31:53 +0000 (23:31 +0200)]
squashfs: Fix compilation on big endian systems

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
2 years agoimx: imx8mq: select CONFIG_CMD_CLK
Peng Fan [Mon, 23 May 2022 11:38:28 +0000 (19:38 +0800)]
imx: imx8mq: select CONFIG_CMD_CLK

select CONFIG_CMD_CLK to enable dump clk in uboot shell

Signed-off-by: Peng Fan <peng.fan@nxp.com>
2 years agoimx: imx8mq: default select CLK_IMX8MQ
Peng Fan [Mon, 23 May 2022 11:38:27 +0000 (19:38 +0800)]
imx: imx8mq: default select CLK_IMX8MQ

Since the power domain driver default select CONFIG_CLK, so we will
meet lots failures without CLK_IMX8MQ, so default select it.

Fixes: commit 4eb82c2e56a7c ("imx: power-domain: Get rid of SMCCC dependency")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
2 years agofdt: Add U-Boot version to chosen node
Francesco Dolcini [Thu, 19 May 2022 14:22:26 +0000 (16:22 +0200)]
fdt: Add U-Boot version to chosen node

Add a new device tree property "u-boot,version" in the chosen node to
pass the U-Boot version to the operating system.
This can be useful to implement a firmware upgrade procedure from the
operating system.

Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 years agonet: Check for the minimum IP fragmented datagram size
Fabio Estevam [Thu, 26 May 2022 14:14:37 +0000 (11:14 -0300)]
net: Check for the minimum IP fragmented datagram size

Nicolas Bidron and Nicolas Guigo reported the two bugs below:

"
----------BUG 1----------

In compiled versions of U-Boot that define CONFIG_IP_DEFRAG, a value of
`ip->ip_len` (IP packet header's Total Length) higher than `IP_HDR_SIZE`
and strictly lower than `IP_HDR_SIZE+8` will lead to a value for `len`
comprised between `0` and `7`. This will ultimately result in a
truncated division by `8` resulting value of `0` forcing the hole
metadata and fragment to point to the same location. The subsequent
memcopy will overwrite the hole metadata with the fragment data. Through
a second fragment, this can be exploited to write to an arbitrary offset
controlled by that overwritten hole metadata value.

This bug is only exploitable locally as it requires crafting two packets
the first of which would most likely be dropped through routing due to
its unexpectedly low Total Length. However, this bug can potentially be
exploited to root linux based embedded devices locally.

```C
static struct ip_udp_hdr *__net_defragment(struct ip_udp_hdr *ip, int *lenp)
{
     static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
     static u16 first_hole, total_len;
     struct hole *payload, *thisfrag, *h, *newh;
     struct ip_udp_hdr *localip = (struct ip_udp_hdr *)pkt_buff;
     uchar *indata = (uchar *)ip;
     int offset8, start, len, done = 0;
     u16 ip_off = ntohs(ip->ip_off);

     /* payload starts after IP header, this fragment is in there */
     payload = (struct hole *)(pkt_buff + IP_HDR_SIZE);
     offset8 =  (ip_off & IP_OFFS);
     thisfrag = payload + offset8;
     start = offset8 * 8;
     len = ntohs(ip->ip_len) - IP_HDR_SIZE;
```

The last line of the previous excerpt from `u-boot/net/net.c` shows how
the attacker can control the value of `len` to be strictly lower than
`8` by issuing a packet with `ip_len` between `21` and `27`
(`IP_HDR_SIZE` has a value of `20`).

Also note that `offset8` here is `0` which leads to `thisfrag = payload`.

```C
     } else if (h >= thisfrag) {
         /* overlaps with initial part of the hole: move this hole */
         newh = thisfrag + (len / 8);
         *newh = *h;
         h = newh;
         if (h->next_hole)
             payload[h->next_hole].prev_hole = (h - payload);
         if (h->prev_hole)
             payload[h->prev_hole].next_hole = (h - payload);
         else
             first_hole = (h - payload);

     } else {
```

Lower down the same function, execution reaches the above code path.
Here, `len / 8` evaluates to `0` leading to `newh = thisfrag`. Also note
that `first_hole` here is `0` since `h` and `payload` point to the same
location.

```C
     /* finally copy this fragment and possibly return whole packet */
     memcpy((uchar *)thisfrag, indata + IP_HDR_SIZE, len);
```

Finally, in the above excerpt the `memcpy` overwrites the hole metadata
since `thisfrag` and `h` both point to the same location. The hole
metadata is effectively overwritten with arbitrary data from the
fragmented IP packet data. If `len` was crafted to be `6`, `last_byte`,
`next_hole`, and `prev_hole` of the `first_hole` can be controlled by
the attacker.

Finally the arbitrary offset write occurs through a second fragment that
only needs to be crafted to write data in the hole pointed to by the
previously controlled hole metadata (`next_hole`) from the first packet.

 ### Recommendation

Handle cases where `len` is strictly lower than 8 by preventing the
overwrite of the hole metadata during the memcpy of the fragment. This
could be achieved by either:
* Moving the location where the hole metadata is stored when `len` is
lower than `8`.
* Or outright rejecting fragmented IP datagram with a Total Length
(`ip_len`) lower than 28 bytes which is the minimum valid fragmented IP
datagram size (as defined as the minimum fragment of 8 octets in the IP
Specification Document:
[RFC791](https://datatracker.ietf.org/doc/html/rfc791) page 25).

----------BUG 2----------

In compiled versions of U-Boot that define CONFIG_IP_DEFRAG, a value of
`ip->ip_len` (IP packet header's Total Length) lower than `IP_HDR_SIZE`
will lead to a negative value for `len` which will ultimately result in
a buffer overflow during the subsequent `memcpy` that uses `len` as it's
`count` parameter.

This bug is only exploitable on local ethernet as it requires crafting
an invalid packet to include an unexpected `ip_len` value in the IP UDP
header that's lower than the minimum accepted Total Length of a packet
(21 as defined in the IP Specification Document:
[RFC791](https://datatracker.ietf.org/doc/html/rfc791)). Such packet
would in all likelihood be dropped while being routed to its final
destination through most routing equipment and as such requires the
attacker to be in a local position in order to be exploited.

```C
static struct ip_udp_hdr *__net_defragment(struct ip_udp_hdr *ip, int *lenp)
{
     static uchar pkt_buff[IP_PKTSIZE] __aligned(PKTALIGN);
     static u16 first_hole, total_len;
     struct hole *payload, *thisfrag, *h, *newh;
     struct ip_udp_hdr *localip = (struct ip_udp_hdr *)pkt_buff;
     uchar *indata = (uchar *)ip;
     int offset8, start, len, done = 0;
     u16 ip_off = ntohs(ip->ip_off);

     /* payload starts after IP header, this fragment is in there */
     payload = (struct hole *)(pkt_buff + IP_HDR_SIZE);
     offset8 =  (ip_off & IP_OFFS);
     thisfrag = payload + offset8;
     start = offset8 * 8;
     len = ntohs(ip->ip_len) - IP_HDR_SIZE;
```

The last line of the previous excerpt from `u-boot/net/net.c` shows
where the underflow to a negative `len` value occurs if `ip_len` is set
to a value strictly lower than 20 (`IP_HDR_SIZE` being 20). Also note
that in the above excerpt the `pkt_buff` buffer has a size of
`CONFIG_NET_MAXDEFRAG` which defaults to 16 KB but can range from 1KB to
64 KB depending on configurations.

```C
     /* finally copy this fragment and possibly return whole packet */
     memcpy((uchar *)thisfrag, indata + IP_HDR_SIZE, len);
```

In the above excerpt the `memcpy` overflows the destination by
attempting to make a copy of nearly 4 gigabytes in a buffer that's
designed to hold `CONFIG_NET_MAXDEFRAG` bytes at most which leads to a DoS.

 ### Recommendation

Stop processing of the packet if `ip_len` is lower than 21 (as defined
by the minimum length of a data carrying datagram in the IP
Specification Document:
[RFC791](https://datatracker.ietf.org/doc/html/rfc791) page 34)."

Add a check for ip_len lesser than 28 and stop processing the packet
in this case.

Such a check covers the two reported bugs.

Reported-by: Nicolas Bidron <nicolas.bidron@nccgroup.com>
Signed-off-by: Fabio Estevam <festevam@denx.de>
2 years agoarmv8: Fix TCR 64-bit writes
Andre Przywara [Mon, 9 May 2022 16:08:49 +0000 (17:08 +0100)]
armv8: Fix TCR 64-bit writes

The AArch64 TCR_ELx register is a 64-bit register, and many newer
architecture features use bits in the upper half. So far U-Boot was
igorant of those bits, trying to leave them alone.
However, in an effort to set bit 31 to 1, it failed doing so, because
the compiler sign-extended "1 << 31", so that all bits[63:31] got set.

Older ARMv8.0 cores don't define anything dangerous up there, but newer
architecture revisions do, and setting all those bits will end badly:
=================
$ qemu-system-aarch64 -cpu max ....
U-Boot 2022.07-rc1 (May 09 2022 - 15:21:00 +0100)

DRAM:  1.5 GiB
=================  (hangs here)

Defining TCR_ELx_RSVD to "1U << 31" avoids the sign-extension, so all
upper bits stay at a safe 0 value. This means no more surprises when
U-Boot runs on a more capable CPU core.

Reported-by: Balaji Anandapadmanaban <Balaji.Anandapadmanaban@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Peter Collingbourne <pcc@google.com>
Reviewed-by: Peter Collingbourne <pcc@google.com>
2 years agonet: enetc: unregister mdiobus
Michael Walle [Tue, 31 May 2022 16:36:16 +0000 (18:36 +0200)]
net: enetc: unregister mdiobus

If the device fails to probe - for example, when there is no
ethaddr set - then the private data is automatically freed
but the mdiobus remains registered.

Fixes: 1e354cb39314 ("drivers: net: fsl_enetc: register internal MDIO bus")
Signed-off-by: Michael Walle <michael@walle.cc>
2 years agoubifs: Fix lockup/crash when reading files
Pali Rohár [Tue, 17 May 2022 20:45:28 +0000 (22:45 +0200)]
ubifs: Fix lockup/crash when reading files

Commit b1a14f8a1c2e ("UBIFS: Change ubifsload to not read beyond the
requested size") added optimization to do not read more bytes than it is
really needed. But this commit introduced incorrect handling of the hole at
the end of file. This logic cause U-Boot to crash or lockup when trying to
read from the ubifs filesystem.

When read_block() call returns -ENOENT error (not an error, but the hole)
then dn-> structure is not filled and contain garbage. So using of dn->size
for memcpy() argument cause that U-Boot tries to copy unspecified amount of
bytes from possible unmapped memory. Which randomly cause lockup of P2020
CPU.

Fix this issue by copying UBIFS_BLOCK_SIZE bytes from read buffer when
dn->size is not available. UBIFS_BLOCK_SIZE is the size of the buffer
itself and read_block() fills buffer by zeros when it returns -ENOENT.

This patch fixes ubifsload on P2020.

Fixes: b1a14f8a1c2e ("UBIFS: Change ubifsload to not read beyond the requested size")
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2 years agoMerge tag 'efi-2022-07-rc4-3' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Tue, 31 May 2022 17:05:53 +0000 (13:05 -0400)]
Merge tag 'efi-2022-07-rc4-3' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc4-3

UEFI:

* fix a problem in loading an image from a short-path
* fix building the bootmenu command for CONFIG_EFI_LOADER=n
* correct the bootefi command syntax
* add firmware management protocol to the documentation

Others:

* bootmenu: fix bootmenu title handling

Tested-by: Pali Rohár <pali@kernel.org> [n900, for bootmenu working as before]
2 years agobootmenu: use utf-8 for menu title
Masahisa Kojima [Sun, 29 May 2022 01:52:43 +0000 (10:52 +0900)]
bootmenu: use utf-8 for menu title

The commit a3d0aa87acbe ("bootmenu: update bootmenu_entry structure")
changes the bootmenu title type from char to u16(UTF16 string)
to support EFI based system. If EFI_LOADER is not enabled,
printf("%ls") is not supported, so bootmenu does not appear
correctly.

This commit changes the type of menu title from u16(UTF16) to
utf-8 string and EFI strings is conveted into utf-8.

Fixes: a3d0aa87acbe ("bootmenu: update bootmenu_entry structure")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Tested-by: Pali Rohar <pali@kernel.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc/efi: add firmware management protocol to the documentation
Vincent Stehlé [Wed, 25 May 2022 09:20:21 +0000 (11:20 +0200)]
doc/efi: add firmware management protocol to the documentation

The firmware management protocol can be used to manage device firmware.
U-Boot can be configured to provide an implementation.

Document the related functions in the API section.

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi: fix documentation warnings
Vincent Stehlé [Wed, 25 May 2022 09:20:22 +0000 (11:20 +0200)]
efi: fix documentation warnings

This fixes the following warnings:

  ./lib/efi_loader/efi_firmware.c:283: warning: Function parameter or member 'package_version' not described in 'efi_firmware_fit_get_image_info'
  ./lib/efi_loader/efi_firmware.c:283: warning: Function parameter or member 'package_version_name' not described in 'efi_firmware_fit_get_image_info'
  ./lib/efi_loader/efi_firmware.c:369: warning: bad line: firmware image
  ./lib/efi_loader/efi_firmware.c:395: warning: Function parameter or member 'package_version' not described in 'efi_firmware_raw_get_image_info'
  ./lib/efi_loader/efi_firmware.c:395: warning: Function parameter or member 'package_version_name' not described in 'efi_firmware_raw_get_image_info'

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agolib/charset: fix compile warnings
Masahisa Kojima [Mon, 16 May 2022 11:00:42 +0000 (20:00 +0900)]
lib/charset: fix compile warnings

This commit fixes the following compile warnings
for the documentation.

./include/charset.h:276: warning: Function parameter or member 'size' not described in 'u16_strlcat'
./include/charset.h:276: warning: Excess function parameter 'count' description in 'u16_strlcat'

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoefi_loader: bootmgr: fix a problem in loading an image from a short-path
AKASHI Takahiro [Thu, 12 May 2022 02:29:02 +0000 (11:29 +0900)]
efi_loader: bootmgr: fix a problem in loading an image from a short-path

Booting from a short-form device path which starts with the first element
being a File Path Media Device Path failed because it doesn't contain
any valid device with simple file system protocol and efi_dp_find_obj()
in efi_load_image_from_path() will return NULL.
For instance,
/VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/Scsi(0,0)/\helloworld.efi
-> shortened version: /\helloworld.efi

With this patch applied, all the media devices with simple file system
protocol are enumerated and the boot manager attempts to boot temporarily
generated device paths one-by-one.

This new implementation is still a bit incompatible with the UEFI
specification in terms of:
* not creating real boot options
* not try
  "If a device does not support the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, but
  supports the EFI_BLOCK_IO_PROTOCOL protocol, then the EFI Boot Service
  ConnectController must be called for this device with DriverImageHandle
  and RemainingDevicePath set to NULL and the Recursive flag is set to TRUE."
(See section 3.1.2 "Load Option Processing".)

But it still gives us a closer and better solution than the current.

Fixes: commit 9cdf470274ff ("efi_loader: support booting via short-form device-path")
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>