platform/kernel/u-boot.git
23 months agoimx8mn_evk: Add Ethernet support to the LPDDR4 variant
Fabio Estevam [Tue, 17 May 2022 16:23:09 +0000 (13:23 -0300)]
imx8mn_evk: Add Ethernet support to the LPDDR4 variant

The imx8mn-ddr4-evk board has Ethernet support already, but the
lpddr4 board does not.

Add Ethernet support for the LPDDR4 variant too.

Signed-off-by: Fabio Estevam <festevam@denx.de>
23 months agoboard: apalis-imx8: add new 8gb product variant
Philippe Schenker [Mon, 9 May 2022 16:58:16 +0000 (18:58 +0200)]
board: apalis-imx8: add new 8gb product variant

Add the new Apalis iMX8 product variant

0067: Apalis iMX8 QuadMax 8GB Wi-Fi / BT IT

the only difference to the product

0037 Apalis iMX8 QuadMax 4GB Wi-Fi / BT IT

is the 8gb of RAM. Toradex strategy to choose the correct RAM timing in
SCFW is by fuses in the user area telling which RAM timing to load.

This commit makes use of this information to set the correct size of
the RAM and therefore distinguish between the new 0067 and 0037 product

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
23 months agotoradex: tdx-cfg-block: add new 8gb apalis-imx8
Philippe Schenker [Mon, 9 May 2022 16:58:15 +0000 (18:58 +0200)]
toradex: tdx-cfg-block: add new 8gb apalis-imx8

0067: Apalis iMX8 QuadMax 8GB Wi-Fi / BT IT

This module is identical to its 4GB counterpart
0037: Apalis iMX8 QuadMax 4GB Wi-Fi / BT IT
except for the RAM size.

Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
23 months agoimx8mn_evk: Add the missing spl.bin entry
Fabio Estevam [Tue, 3 May 2022 19:03:04 +0000 (16:03 -0300)]
imx8mn_evk: Add the missing spl.bin entry

The generated flash.bin does not boot the imx8mn evk LPDDR4 variant
as it misses the spl.bin description in binman.

Add its entry to fix the boot on the imx8mn evk LPDDR4 variant.

Signed-off-by: Fabio Estevam <festevam@denx.de>
Tested-by: Arti Zirk <art@zirk.me>
Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
23 months agodtoc: Update test_src_scan.py for new tegra compatibles
Tom Rini [Tue, 14 Jun 2022 17:59:23 +0000 (13:59 -0400)]
dtoc: Update test_src_scan.py for new tegra compatibles

This test was written to match up with the list of compatibles in
drivers/i2c/tegra_i2c.c so adding another one requires the test to be
updated to match.

Fixes: 0d2105ae5e32 ("arm: tegra: Update some DT compatibles")
Signed-off-by: Tom Rini <trini@konsulko.com>
23 months agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-tegra
Tom Rini [Tue, 14 Jun 2022 16:28:58 +0000 (12:28 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-tegra

Signed-off-by: Tom Rini <trini@konsulko.com>
23 months agoboard: apalis_t30/tk1/colibri_t20/t30: integrate mac address via dt
Marcel Ziswiler [Sat, 21 May 2022 10:42:46 +0000 (12:42 +0200)]
board: apalis_t30/tk1/colibri_t20/t30: integrate mac address via dt

Use device tree to set MAC address of the Ethernet chip.

Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
23 months agoarm: tegra: Update some DT compatibles
Peter Robinson [Tue, 3 May 2022 08:32:54 +0000 (09:32 +0100)]
arm: tegra: Update some DT compatibles

Some of the DT compatibles have changed upstream so add new DT compatibles
to ensure things continue to keep working if the device trees are
updated.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
23 months agopci: tegra: Update error prints with new lines
Peter Robinson [Tue, 3 May 2022 08:29:22 +0000 (09:29 +0100)]
pci: tegra: Update error prints with new lines

Add new lines to make errorr messages easier to read.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
23 months agoARM: tegra: XUSB padctl: Add new lines for errors
Peter Robinson [Tue, 3 May 2022 08:29:21 +0000 (09:29 +0100)]
ARM: tegra: XUSB padctl: Add new lines for errors

Add new lines for error messages to make them easier to read.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
Signed-off-by: Tom Warren <twarren@nvidia.com>
23 months agoMerge tag 'efi-2022-07-rc5' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Mon, 13 Jun 2022 13:33:37 +0000 (09:33 -0400)]
Merge tag 'efi-2022-07-rc5' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2022-07-rc5

UEFI:

* Ignore OsIndications if CONFIG_EFI_IGNORE_OSINDICATIONS=y
* Correct UEFI default binary name
* Let efidebug create boot options without file path
* Support booting with a boot option with shortened device only device path

23 months agoefi_loader: create boot options without file path
Heinrich Schuchardt [Sat, 11 Jun 2022 05:22:08 +0000 (05:22 +0000)]
efi_loader: create boot options without file path

Allow the efidebug command to create boot options without file path, e.g.

    efidebug boot add -b 0001 'short dev only' host 0:1 ''
    efidebug boot add -B 0002 'long dev only' host 0:1 ''

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
23 months agoefi_loader: allow booting from short dev only DP
Heinrich Schuchardt [Sat, 11 Jun 2022 05:22:07 +0000 (05:22 +0000)]
efi_loader: allow booting from short dev only DP

Allow booting from a short form device-path without file path, e.g.

    /HD(1,GPT,5ef79931-a1aa-4c70-9d67-611e8f69eafd,0x800,0x1000)

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
23 months agoefi_loader: correctly identify binary name
Heinrich Schuchardt [Fri, 10 Jun 2022 16:24:48 +0000 (18:24 +0200)]
efi_loader: correctly identify binary name

Only on the sandbox the default EFI binary name (e.g. BOOTX64.EFI) must
match the host architecture.

In all other cases we must use the target architecture.

Use #elif where appropriate.

Reported-by: Vagrant Cascadian <vagrant@reproducible-builds.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
23 months agoEFI: FMP: Use a common GetImageInfo function for FIT and raw images
Sughosh Ganu [Wed, 1 Jun 2022 18:00:41 +0000 (23:30 +0530)]
EFI: FMP: Use a common GetImageInfo function for FIT and raw images

The GetImageInfo function definitions for the FIT images and raw
images are the same. Use a common function for the both the Firmware
Management Protocol(FMP) instances for raw and FIT images.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
23 months agoEFI: Do not consider OsIndications variable if CONFIG_EFI_IGNORE_OSINDICATIONS is...
Sughosh Ganu [Wed, 1 Jun 2022 18:00:39 +0000 (23:30 +0530)]
EFI: Do not consider OsIndications variable if CONFIG_EFI_IGNORE_OSINDICATIONS is enabled

The EFI_IGNORE_OSINDICATIONS config symbol was introduced as a
mechanism to have capsule updates work even on platforms where the
SetVariable runtime service was not supported. The current logic
requires the OsIndications variable to have been set to a 64 bit value
even when the EFI_IGNORE_OSINDICATIONS config is enabled. Return an
error code on not being able to read the variable only when
EFI_IGNORE_OSINDICATIONS is not enabled.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
23 months agoMerge https://source.denx.de/u-boot/custodians/u-boot-usb
Tom Rini [Wed, 8 Jun 2022 12:25:30 +0000 (08:25 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-usb

- MediaTek XHCI bugfix, add  USB251xB/xBi driver

2 years agomisc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux
Marek Vasut [Sun, 10 Apr 2022 04:27:14 +0000 (06:27 +0200)]
misc: Port USB251xB/xBi Hi-Speed Hub Controller Driver from Linux

This patch adds a driver for configuration of the Microchip USB251xB/xBi
USB 2.0 hub controller series with USB 2.0 upstream connectivity, SMBus
configuration interface and two to four USB 2.0 downstream ports.

This is ported from Linux as of Linux kernel commit
5c2b9c61ae5d8 ("usb: usb251xb: add boost-up property support")

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Simon Glass <sjg@chromium.org>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-watchdog
Tom Rini [Tue, 7 Jun 2022 12:17:24 +0000 (08:17 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-watchdog

- Fix SPL build with watchdog disabled in asm files (Pali)

2 years agoMerge tag 'xilinx-for-v2022.07-rc4-v2' of https://source.denx.de/u-boot/custodians...
Tom Rini [Tue, 7 Jun 2022 12:17:08 +0000 (08:17 -0400)]
Merge tag 'xilinx-for-v2022.07-rc4-v2' of https://source.denx.de/u-boot/custodians/u-boot-microblaze

Xilinx changes for v2022.07-rc4-v2

- Fix revision name (remove spaces)

2 years agousb: xhci-mtk: disable all ports when disable host controller
Chunfeng Yun [Fri, 27 May 2022 01:52:09 +0000 (09:52 +0800)]
usb: xhci-mtk: disable all ports when disable host controller

This is used to avoid the ports status of IPPC being brought in kernel
stage, it may cause ports error especially when the xhci controller is
a component of dual-role controller.

Reported-by: Yun-Chien Yu <yun-chien.yu@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
2 years agowatchdog: Fix SPL build with watchdog disabled in asm files
Pali Rohár [Thu, 28 Apr 2022 11:33:09 +0000 (13:33 +0200)]
watchdog: Fix SPL build with watchdog disabled in asm files

Allow to compile assembler files in SPL build which calls WATCHDOG_RESET
function when watchdog is disabled in SPL and enabled in U-Boot proper.

This issue was fixed in past by commit 7fbd42f5afc4 ("watchdog: Handle SPL
build with watchdog disabled") for C source files, but not for assembler
source files.

Currently the only assembler source file which calls WATCHDOG_RESET is
arch/powerpc/lib/ticks.S, so this patch affects and fixes powerpc SPL
builds.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
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 agoxilinx: fru: Replace spaces with \0 in detected revision
Michal Simek [Mon, 6 Jun 2022 07:31:27 +0000 (09:31 +0200)]
xilinx: fru: Replace spaces with \0 in detected revision

Also fix board revision field where spaces are used instead of \0.
The same change was done for board name by commit 530560b6f8eb ("xilinx:
fru: Replace spaces with \0 in detected name").

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/e069e5134e57899e859786ad8ba48721df6df752.1653911444.git.michal.simek@amd.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>
2 years agoefi_loader: disk: add efi_disk_is_removable()
AKASHI Takahiro [Thu, 12 May 2022 02:29:01 +0000 (11:29 +0900)]
efi_loader: disk: add efi_disk_is_removable()

This helper function will be used to determine if the device is
removable media, initially for handling a short-path loading.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agocmd/bootefi: correct command syntax
Heinrich Schuchardt [Thu, 19 May 2022 06:00:56 +0000 (08:00 +0200)]
cmd/bootefi: correct command syntax

For indicating the address and size of a memory region other commands use a
<addr>[:<size>] syntax. Do the same for bootefi.

Fixes: 2058983689f0 ("cmd: bootefi: restore ability to boot arbitrary blob")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agotest: don't change console timeout in EFI selftest.
Heinrich Schuchardt [Mon, 9 May 2022 20:02:05 +0000 (22:02 +0200)]
test: don't change console timeout in EFI selftest.

Changing the console timeout to 500 ms without restoring the original value
leads to failures in other tests. As the console timeout change is not
necessary for the text input protocol tests remove it.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agotest: fix pylint warnings in test_efi_selftest.py
Heinrich Schuchardt [Sun, 8 May 2022 08:40:49 +0000 (10:40 +0200)]
test: fix pylint warnings in test_efi_selftest.py

* change format of parameter documentation
* avoid superfluous assignments

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agobootmenu: U-Boot console is enabled as default
Masahisa Kojima [Thu, 26 May 2022 10:09:38 +0000 (19:09 +0900)]
bootmenu: U-Boot console is enabled as default

The commit 2158b0da220c ("bootmenu: add Kconfig option
not to enter U-Boot console") disables to enter U-Boot
console from bootmenu as default, this change affects the
existing bootmenu users.

This commit reverts the default behavior, the bootmenu can
enter U-Boot console same as before.
CMD_BOOTMENU_ENTER_UBOOT_CONSOLE is renamed
BOOTMENU_DISABLE_UBOOT_CONSOLE and depends on
AUTOBOOT_MENU_SHOW.

Fixes: 2158b0da220c ("bootmenu: add Kconfig option not to enter U-Boot console")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Tested-by: Pali Rohar <pali@kernel.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: sandbox: Add additional valgrind documentation
Sean Anderson [Fri, 27 May 2022 14:02:59 +0000 (10:02 -0400)]
doc: sandbox: Add additional valgrind documentation

This documents some additional options which can be used with valgrind, as
well as directions for future work. It also fixes up inline literals to
actually be inline literals (and not italics). The content of this
documentation is primarily adapted from [1].

[1] https://lore.kernel.org/u-boot/57cb4b49-fa30-1194-9ac3-faa53e8033bd@gmail.com/

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc/build/gcc: add more required packages
Heinrich Schuchardt [Thu, 26 May 2022 08:15:58 +0000 (10:15 +0200)]
doc/build/gcc: add more required packages

The following Python packages are used by U-Boot, too:

* python3-asteval
* python3-subunit
* python3-testtools

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodoc: sandbox: Add a note of disabling LTO when using gdb
Bin Meng [Tue, 17 May 2022 16:21:29 +0000 (00:21 +0800)]
doc: sandbox: Add a note of disabling LTO when using gdb

Image created by LTO is not friendly to debugger, let's document this.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Mention CONFIG_CC_OPTIMIZE_FOR_DEBUG and LLDB.
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agodoc: sandbox: Correct the memory size config option
Bin Meng [Tue, 17 May 2022 16:09:17 +0000 (00:09 +0800)]
doc: sandbox: Correct the memory size config option

It should be CONFIG_SANDBOX_RAM_SIZE_MB.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agovalgrind: Disable on Risc-V
Sean Anderson [Fri, 27 May 2022 14:03:00 +0000 (10:03 -0400)]
valgrind: Disable on Risc-V

There are no defined instruction sequences in include/valgrind.h for
Risc-V, so CONFIG_VALGRIND will do nothing on this arch (and possibly won't
compile?). Update Kconfig accordingly.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agotest: restore timeout after bootmenu unit test
Heinrich Schuchardt [Mon, 9 May 2022 19:59:13 +0000 (21:59 +0200)]
test: restore timeout after bootmenu unit test

In the bootmenu unit test the console timeout is set to 500 ms.
Other tests rely on the original timeout. Ensure that the original value
is restored.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agodisk: incorrect message in is_gpt_valid()
Heinrich Schuchardt [Mon, 9 May 2022 19:35:44 +0000 (21:35 +0200)]
disk: incorrect message in is_gpt_valid()

alloc_read_gpt_entries() writes differentiated error messages.
The caller is_gpt_valid() should not write an extra possibly wrong message.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-riscv
Tom Rini [Fri, 27 May 2022 12:50:42 +0000 (08:50 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-riscv

2 years agoMerge branch '2022-05-26-assorted-fixes'
Tom Rini [Fri, 27 May 2022 12:48:47 +0000 (08:48 -0400)]
Merge branch '2022-05-26-assorted-fixes'

- Fixes for pytest timeout in CI, missing dependency on PCI for the
  e1000 driver, fix for CVE-2022-30767 (NFS), TI K3 AM642 DTS bugfix,
  MAINTAINERS updates, mksquashfs version check fix.

2 years agonet: e1000: Depend on CONFIG_PCI
Sean Anderson [Tue, 26 Apr 2022 18:35:33 +0000 (14:35 -0400)]
net: e1000: Depend on CONFIG_PCI

This driver depends on PCI. Update the Kconfig accordingly.

Signed-off-by: Sean Anderson <sean.anderson@seco.com>
Reviewed-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2 years agotest: fix parsing the mksquashfs version number
Heinrich Schuchardt [Tue, 24 May 2022 11:36:21 +0000 (13:36 +0200)]
test: fix parsing the mksquashfs version number

Testing with mksquasshfs 4.5.1 results in an error

    ValueError: could not convert string to float: '4.5.1'

Version 4.10 would be considered to be lower than 4.4.

Fixes: 04c9813e951f ("test/py: rewrite common tools for SquashFS tests")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 years agoboard: freescale: Update MAINTAINERS List
Wasim Khan [Sun, 22 May 2022 05:23:58 +0000 (07:23 +0200)]
board: freescale: Update MAINTAINERS List

Update MAINTAINERS List for LS2088ARDB and LS2088AQDS
platforms

Signed-off-by: Wasim Khan <wasim.khan@nxp.com>
2 years agoarm: dts: k3-am642-*: Mark the memory node with u-boot, dm-spl
Georgi Vlaev [Fri, 20 May 2022 12:30:26 +0000 (15:30 +0300)]
arm: dts: k3-am642-*: Mark the memory node with u-boot, dm-spl

Since commit dffdb1f8eb ("board: ti: am64x: Use fdt functions
for ram and bank init") ddr_init() and dram_bank_init() have
switched to fdtdec for getting the memory configuration from
the am64xx dts files instead of using hardcoded values. This
requires an accessible memory node in SPL as we already have
in k3-am642-r5-evm.dts.

Make the memory node accessible in A53 SPL for both am642-sk
and am642-evm and in am642-sk R5 SPL.

Signed-off-by: Georgi Vlaev <g-vlaev@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 years agoMAINTAINERS: aspeed: Add more files and myself as a reviewer
Joel Stanley [Thu, 19 May 2022 00:36:33 +0000 (10:06 +0930)]
MAINTAINERS: aspeed: Add more files and myself as a reviewer

Add the rest of the ASPEED drivers that are in tree. Most are obvious,
except for ftgmac100 which matches the register layout used in the
ASPEED SoC.

I am the Linux maintainer for the ASPEED kernel port, and help maintain
the fork of u-boot used for OpenBMC, so add myself as a reviewer so I
can stay informed about u-boot changes.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Chia-Wei Wang <chiawei_wang@aspeedtech.com>
2 years agonet: nfs: Fix CVE-2022-30767 (old CVE-2019-14196)
Andrea zi0Black Cappa [Wed, 18 May 2022 16:30:08 +0000 (16:30 +0000)]
net: nfs: Fix CVE-2022-30767 (old CVE-2019-14196)

This patch mitigates the vulnerability identified via CVE-2019-14196.

The previous patch was bypassed/ineffective, and now the vulnerability
is identified via CVE-2022-30767. The patch removes the sanity check
introduced to mitigate CVE-2019-14196 since it's ineffective.
filefh3_length is changed to unsigned type integer, preventing negative
numbers from being used during comparison with positive values during
size sanity checks.

Signed-off-by: Andrea zi0Black Cappa <zi0Black@protonmail.com>
2 years agotest/py: test_part: Correct the test case name
Bin Meng [Tue, 17 May 2022 15:24:45 +0000 (23:24 +0800)]
test/py: test_part: Correct the test case name

Use test_part_types as the name instead of dm_compact.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2 years agotest/py: test_fs: Correct the test case name
Bin Meng [Tue, 17 May 2022 15:24:44 +0000 (23:24 +0800)]
test/py: test_fs: Correct the test case name

Use test_fstypes as the name instead of test_dm_compact.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2 years agotest/py: Reset the console timeout value
Bin Meng [Tue, 17 May 2022 15:24:43 +0000 (23:24 +0800)]
test/py: Reset the console timeout value

Reset the console timeout value as some tests may change its default
value during the execution.

This fixes the random case timeout issue seen in the U-Boot CI.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2 years agoriscv: qemu: Set kernel_comp_addr_r for compressed kernel
Bin Meng [Tue, 24 May 2022 04:31:14 +0000 (12:31 +0800)]
riscv: qemu: Set kernel_comp_addr_r for compressed kernel

Set kernel_comp_addr_r and kernel_comp_size for compressed kernel.
Adjust existing addresses for ramdisk, so that kernel_comp_addr_r
comes before the ramdisk image, since the decompressed kernel size
is known to us. This way we can allow big ramdisk image to be loaded.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoriscv: sifive: unleashed: Set kernel_comp_addr_r for compressed kernel
Bin Meng [Tue, 24 May 2022 04:31:13 +0000 (12:31 +0800)]
riscv: sifive: unleashed: Set kernel_comp_addr_r for compressed kernel

Set kernel_comp_addr_r and kernel_comp_size for compressed kernel.
Adjust existing addresses for ramdisk, so that kernel_comp_addr_r
comes before the ramdisk image, since the decompressed kernel size
is known to us. This way we can allow big ramdisk image to be loaded.

Update unleashed.rst to remove the manual environment configuration
for compressed kernel boot.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoriscv: sifive: unmatched: Adjust for big ramdisk image
Bin Meng [Tue, 24 May 2022 04:31:12 +0000 (12:31 +0800)]
riscv: sifive: unmatched: Adjust for big ramdisk image

Move kernel_comp_addr_r to an address that comes before the ramdisk
image, since the decompressed kernel size is known to us. This way
we can allow big ramdisk image to be loaded.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoriscv: Clean up asm/io.h
Leo Yu-Chi Liang [Thu, 19 May 2022 08:43:31 +0000 (16:43 +0800)]
riscv: Clean up asm/io.h

Clean up asm/io.h by
- removing commented code
- removing outdated comments
- removing unused definitions (for mem_isa, mem_pci)

This massively improves the readability of the file.

Suggested by commits:
7ab2e47d27c9 ("arm: Clean up asm/io.h")
909d0399a519 ("ARM: asm/io.h: kill off confusing #ifdef __mem_pci block")

Signed-off-by: Leo Yu-Chi Liang <ycliang@andestech.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agoriscv: remove CONFIG_ARCH_MAP_SYSMEM from io.h
Michal Simek [Wed, 18 May 2022 10:54:01 +0000 (12:54 +0200)]
riscv: remove CONFIG_ARCH_MAP_SYSMEM from io.h

Commit ba1ed5b022c6 ("Convert CONFIG_ARCH_MAP_SYSMEM to Kconfig") clearly
defined that this option is available for SANDBOX (was also for already
removed NDS32). That's why there is no way how this code can be enabled
with current Kconfig layout for riscv.
Based on this removing this code.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2 years agocmd/sbi: add implementation ID 6 - Coffer
Heinrich Schuchardt [Sat, 7 May 2022 12:42:10 +0000 (14:42 +0200)]
cmd/sbi: add implementation ID 6 - Coffer

The sbi command displays the ID of the implementation of the RISC-V
Supervisor Binary Interface Specification. A new ID for Coffer has recently
been added.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoriscv: ae350: Fix OF_BOARD boot failure
Rick Chen [Wed, 20 Apr 2022 01:23:51 +0000 (09:23 +0800)]
riscv: ae350: Fix OF_BOARD boot failure

Disable BINMAN_FDT for ae350 boards which don't actually use it.

Fixes: 836eac7c6fe3 ("fdt: Make OF_BOARD a bool option")
Signed-off-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoriscv: ae350: Fix OF_BOARD boot failure
Rick Chen [Wed, 20 Apr 2022 01:14:05 +0000 (09:14 +0800)]
riscv: ae350: Fix OF_BOARD boot failure

Enable OF_HAS_PRIOR_STAGE for ae350 boards with OF_BOARD

Fixes: 239d22c79520 ("fdt: Enable OF_HAS_PRIOR_STAGE for most boards with OF_BOARD")
Signed-off-by: Rick Chen <rick@andestech.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
2 years agoMerge tag 'xilinx-for-v2022.07-rc4' of https://source.denx.de/u-boot/custodians/u...
Tom Rini [Wed, 25 May 2022 13:50:08 +0000 (09:50 -0400)]
Merge tag 'xilinx-for-v2022.07-rc4' of https://source.denx.de/u-boot/custodians/u-boot-microblaze

Xilinx changes for v2022.07-rc4

zynqmp:
- Fix DP PLL configuration for zcu102/zcu106 and SOM
- Fix split mode for starting R5s
- DT fixes
- Remove firmware node for mini configurations
- Wire TEE for multi DTB fit image

xilinx:
- Handle board_get_usable_ram_top(0) properly

phy:
- Extend psgtr timeout

mmc:
- Fix mini configuration which misses zynqmp_pm_is_function_supported()

2 years agoMerge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Wed, 25 May 2022 03:29:00 +0000 (23:29 -0400)]
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi

The bulk of it is (finally!) some DT sync from the kernel. We refrained
from syncing one incompatible change, as this would spoil booting Linux
kernels before v5.13 with U-Boot's DT (via UEFI, for instance).
I test booted Linux v5.18 and v5.4 with that new DT on some boards, and
the headless peripherals (MMC, USB, Ethernet) seemed to work.
The rest are fixes:
- silencing missing clock warnings due to the new pinctrl driver
- fixing "UART0 on PortF", allowing UART access through the SD card pins
- add an F1C100s clock driver, to enable MMC support (SPI comes later)
- some cleanups for CONS_INDEX_n in Kconfig

Tested on BananaPi-M1, Pine64-LTS, Pine-H64, X96-Mate (H616) and
OrangePi-Zero.

2 years agoMerge tag 'tpm-24052022' of https://source.denx.de/u-boot/custodians/u-boot-tpm
Tom Rini [Tue, 24 May 2022 13:03:34 +0000 (09:03 -0400)]
Merge tag 'tpm-24052022' of https://source.denx.de/u-boot/custodians/u-boot-tpm

Add support for i2c devices

2 years agoxilinx: zynqmp: Wire tee for Multi DTB use cases
Michal Simek [Wed, 18 May 2022 11:41:31 +0000 (13:41 +0200)]
xilinx: zynqmp: Wire tee for Multi DTB use cases

Fix TEE wiring when MULTI_DTB is selected.

Signed-off-by: Michal Simek <michal.simek@amd.com>
Link: https://lore.kernel.org/r/c8523a89d910ae6b8a9971b4e7b3bda89be3dc27.1652874088.git.michal.simek@amd.com
2 years agoMerge https://gitlab.denx.de/u-boot/custodians/u-boot-socfpga
Tom Rini [Tue, 24 May 2022 02:56:35 +0000 (22:56 -0400)]
Merge https://gitlab.denx.de/u-boot/custodians/u-boot-socfpga

- Add the terasic de10-standard board

2 years agoserial: Remove obsolete CONS_INDEX_n Kconfig options
Samuel Holland [Mon, 9 May 2022 05:10:55 +0000 (00:10 -0500)]
serial: Remove obsolete CONS_INDEX_n Kconfig options

These were only ever implied by sunxi platforms, and that usage has
been removed. Current practice is to specify CONFIG_CONS_INDEX in each
board's defconfig.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Remove obsolete Kconfig selections
Samuel Holland [Mon, 9 May 2022 05:10:54 +0000 (00:10 -0500)]
sunxi: Remove obsolete Kconfig selections

ARCH_SUNXI selects DM_SERIAL, so the condition can never be satisfied.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: board: Fix UART PortF pinmux setup
Andre Przywara [Thu, 5 May 2022 23:34:39 +0000 (00:34 +0100)]
sunxi: board: Fix UART PortF pinmux setup

When CONFIG_UART0_PORT_F is defined, we try to configure two PortF pins
(usually used for the SD card) as UART0. Some SoCs use the mux value of
3 for this, while others use 4.

The combination of Kconfig symbols we currently use was not quite right:
we mis-configure the A31, A64, H6 and H616.

Going through the list in the pinctrl driver, there are only a few older
SoCs that use a value of 4, so revert the #ifdef clause, and name those
explicitly, instead of the other way around.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
2 years agoclk: sunxi: add and use dummy gate clocks
Andre Przywara [Thu, 5 May 2022 00:25:43 +0000 (01:25 +0100)]
clk: sunxi: add and use dummy gate clocks

Some devices enumerate various clocks in their DT, and many drivers
just blanketly try to enable all of them. This creates problems
since we only model a few gate clocks, and the clock driver outputs
a warning when a clock is not described:
=========
sunxi_set_gate: (CLK#3) unhandled
=========

Some clocks don't have an enable bit, or are already enabled in a
different way, so we might want to just ignore them.

Add a CCU_CLK_F_DUMMY_GATE flag that indicates that case, and define
a GATE_DUMMY macro that can be used in the clock description array.
Define a few clocks, used by some pinctrl devices, that way to suppress
the runtime warnings.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
2 years agoclk: sunxi: add PIO bus gate clocks
Andre Przywara [Wed, 4 May 2022 21:10:28 +0000 (22:10 +0100)]
clk: sunxi: add PIO bus gate clocks

The introduction of the DM pinctrl driver made its probe function enable
all clocks enumerated in the DT. This includes the "CLK_BUS_PIO" (and
variations) gate clock. Also CLK_PLL_PERIPH0 is used by the R_CCU device.
So far we didn't describe those clocks in our clock driver.
As we enable them already in the SPL, the devices happen to work, but
the clock driver still complains about not finding those clocks:
=========
sunxi_set_gate: (CLK#58) unhandled
=========

Add the one-liners that are needed to announce the gate bit for those
clocks, to silence that message on the console.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
2 years agoclk: sunxi: h6_r: Correct the driver name
Samuel Holland [Sat, 23 Apr 2022 21:07:16 +0000 (16:07 -0500)]
clk: sunxi: h6_r: Correct the driver name

H6 is from the sun50i family, not sun6i.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agommc: sunxi: Remove unnecessary pinmux option dependency
Samuel Holland [Sun, 10 Apr 2022 05:13:34 +0000 (00:13 -0500)]
mmc: sunxi: Remove unnecessary pinmux option dependency

Now that the pinmux conflict is handled in the board code (by skipping
setup for the one conflicting MMC controller), the driver does not need
to be entirely disabled based on the UART pinmux.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agosunxi: Skip MMC0 init when its pinmux conflicts with UART0
Samuel Holland [Sun, 10 Apr 2022 05:13:33 +0000 (00:13 -0500)]
sunxi: Skip MMC0 init when its pinmux conflicts with UART0

Currently, selecting UART0_PORT_F entirely disables MMC support on sunxi
platforms. But this is a bigger hammer then needed. Muxing UART0 to the
pins on port F only causes a conflict with MMC0, so minimize the impact
by specifically skipping MMC0 init. We can continue to use MMC1/2 if
those are enabled.

Let's also remove the preprocessor check while refacting this function.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2 years agoPrepare v2022.07-rc3
Tom Rini [Mon, 23 May 2022 19:40:41 +0000 (15:40 -0400)]
Prepare v2022.07-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>
2 years agoarm: socfpga: Add the terasic de10-standard board
Humberto Naves [Mon, 23 May 2022 01:54:57 +0000 (21:54 -0400)]
arm: socfpga: Add the terasic de10-standard board

Use the de10-nano files as templates for the de10-standard board.
The files in qts directory are generated by quartus from the GHRD
design.

Signed-off-by: Humberto Naves <hsnaves@gmail.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2 years agoconfigs: Resync with savedefconfig
Tom Rini [Mon, 23 May 2022 17:56:21 +0000 (13:56 -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-05-23-regression-fixes'
Tom Rini [Mon, 23 May 2022 17:52:53 +0000 (13:52 -0400)]
Merge branch '2022-05-23-regression-fixes'

- Fix PowerPC NOR booting, important SPI uclass fixes/updates, gic_v2
  fix when CPU is not in EL3, fsl_esdhc_spl fix, and squashfs fix for
  linking on some architectures, and fix phy_string_for_interface

2 years agonet: fix phy_string_for_interface
Tim Harvey [Tue, 10 May 2022 22:49:10 +0000 (15:49 -0700)]
net: fix phy_string_for_interface

commit ffb0f6f488b9 ("treewide: Rename PHY_INTERFACE_MODE_NONE to
PHY_INTERFACE_MODE_NA") broke the phy_string_for_interface function.
Fix it.

Fixes ffb0f6f488b9 ("treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA")
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Cc: Marek Behún <marek.behun@nic.cz>
Cc: Stefan Roese <sr@denx.de>
Cc: Ramon Fried <rfried.dev@gmail.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
2 years agotpm: add support for TPMv2.x I2C chips
Eddie James [Fri, 13 May 2022 18:30:00 +0000 (13:30 -0500)]
tpm: add support for TPMv2.x I2C chips

Add the tpm2_tis_i2c driver that should support any TPMv2 compliant
I2C chips, such as the NPCT75X chip.

[Ilias rename priv_auto_alloc_size to priv_auto]
Signed-off-by: Eddie James <eajames@linux.ibm.com>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2 years agommc: fsl_esdhc_spl: Fix checking for number of read sectors
Pali Rohár [Wed, 11 May 2022 18:28:28 +0000 (20:28 +0200)]
mmc: fsl_esdhc_spl: Fix checking for number of read sectors

Commit 0980cbba7b3c ("mmc: fsl_esdhc_spl: pre-PBL: implement redundancy
support") changed number of sectors which are read but did not adjusted
error check.

Fix it and check for if correct number of sectors were read.

Fixes: 0980cbba7b3c ("mmc: fsl_esdhc_spl: pre-PBL: implement redundancy support")
Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2 years agoarm: gic_v2: Skip gic_init_secure when cpu is not in el3
Sai Pavan Boddu [Wed, 11 May 2022 08:39:07 +0000 (10:39 +0200)]
arm: gic_v2: Skip gic_init_secure when cpu is not in el3

This would prevent configuring non-secure regs in case gic security
extensions are not emulated in Qemu.

Signed-off-by: Sai Pavan Boddu <sai.pavan.boddu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@amd.com>