pandora-u-boot.git
2 months agoarch/x86/lib: Fix CONFIG_X86_64 usage in zimage.c
Jeremy Compostella [Tue, 18 Mar 2025 17:40:34 +0000 (10:40 -0700)]
arch/x86/lib: Fix CONFIG_X86_64 usage in zimage.c

Correct the preprocessor directive used to check for 64-bit kernel
support in the `zboot_go` function. The code previously checked for
`CONFIG_X86_RUN_64BIT`, which is not the correct configuration option
for determining if the kernel should run in 64-bit mode. The correct
option is `CONFIG_X86_64`.

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 months agoarch/x86/cpu: Call x86_cpu_reinit_f for 64-bits
Jeremy Compostella [Tue, 18 Mar 2025 17:40:03 +0000 (10:40 -0700)]
arch/x86/cpu: Call x86_cpu_reinit_f for 64-bits

As both CONFIG_X86_RUN_64BIT and X86_RUN_64BIT_NO_SPL cases run U-Boot
in 64-bit mode with the CPU fully initialized already.

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 months agoarch/x86: Add 64-bit U-Boot configuration without SPL
Jeremy Compostella [Tue, 18 Mar 2025 17:39:40 +0000 (10:39 -0700)]
arch/x86: Add 64-bit U-Boot configuration without SPL

This commit introduces a new configuration option X86_RUN_64BIT_NO_SPL
to allow building U-Boot as a 64-bit binary without using the SPL
(Secondary Program Loader). The motivation is to simplify the boot
process for certain x86-based platforms that do not require SPL, such as
those booting directly from a 64-bit coreboot firmware.

This update revises the `X86_RUN_64BIT` configuration to more accurately
describe its role as "32-bit SPL followed by 64-bit U-Boot." It
clarifies the sequence of operations during the boot process, where the
system transitions from a 32-bit SPL (Secondary Program Loader) to the
main 64-bit U-Boot.

Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 months agoMerge patch series "cmd: fuse: Introduce fuse writebuff sub-system and clean up"
Tom Rini [Fri, 4 Apr 2025 18:25:11 +0000 (12:25 -0600)]
Merge patch series "cmd: fuse: Introduce fuse writebuff sub-system and clean up"

Harsha Vardhan V M <h-vm@ti.com> says:

This patch series introduces the fuse writebuff sub-system command and
makes improvements to the existing fuse implementation by removing the
custom string functions. The patches are required to be applied in
sequence.

The series consists of the following changes:
Patch 1 removes custom string functions and replaces them with standard
string functions.
Patch 2 introduces fuse.rst documentation for fuse commands.
Patch 3 introduces the fuse writebuff sub-system command, allowing to
write a structured buffer in memory to fuses, and implementing the
necessary function calls.
Patch 4 enables the fuse sub-system in the K3 platform.
Patch 5 updates the fuse.rst documentation to include details about the
new fuse writebuff command.

These changes aim to improve the fuse sub-system by the removal of
custom string functions and the addition of the fuse writebuff
command improves fuse programming workflows by allowing to write a
structured buffer in memory to efuses.

Link: https://lore.kernel.org/r/20250319084714.335777-1-h-vm@ti.com
2 months agodoc: cmd: Add fuse writebuff cmd documentation
Harsha Vardhan V M [Wed, 19 Mar 2025 08:47:14 +0000 (14:17 +0530)]
doc: cmd: Add fuse writebuff cmd documentation

Add fuse writebuff sub-system command documentation.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
2 months agodrivers: k3_fuse: Add fuse sub-system func calls
Harsha Vardhan V M [Wed, 19 Mar 2025 08:47:13 +0000 (14:17 +0530)]
drivers: k3_fuse: Add fuse sub-system func calls

Add K3_FUSE config option to add and enable fuse sub-system
implementation function calls.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 months agocmd: fuse: Add fuse writebuff sub-system command
Harsha Vardhan V M [Wed, 19 Mar 2025 08:47:12 +0000 (14:17 +0530)]
cmd: fuse: Add fuse writebuff sub-system command

Add CMD_FUSE_WRITEBUFF config option to add and enable fuse writebuff
sub-system command. Add fuse_writebuff function to be invoked on
writebuff command.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 months agodoc: cmd: Add documentation for fuse command
Harsha Vardhan V M [Wed, 19 Mar 2025 08:47:11 +0000 (14:17 +0530)]
doc: cmd: Add documentation for fuse command

Add documentation for the 'fuse' sub-system commands in
doc/usage/cmd/fuse.rst file.
Remove doc/README.fuse file.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
2 months agocmd: fuse: Remove custom string functions
Harsha Vardhan V M [Wed, 19 Mar 2025 08:47:10 +0000 (14:17 +0530)]
cmd: fuse: Remove custom string functions

Remove custom string functions and replace them with normal string
functions. Remove the custom strtou32 and replace it with
simple_strtoul.

Signed-off-by: Harsha Vardhan V M <h-vm@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 months agoarm64: Fix page permissions for platforms running at EL2
Ilias Apalodimas [Wed, 19 Mar 2025 07:22:02 +0000 (09:22 +0200)]
arm64: Fix page permissions for platforms running at EL2

We currently set both and print both PXN and UXN bits when removing
execution for pages. This happens even in the existing per platform
definitions of 'struct mm_region'.

That's not entirely correct though. For stage-1 translations, if a
platform runs on a translation regime with a single privilege level or the
the translation regime supports two privilege levels and we are not
in EL1&0 with HCR_EL2.{NV, NV1} = {1, 1} only BIT54 (XN) is needed
and BIT53(PXN) is reserved 0.

Currently we support Non-Secure EL2, Non-secure EL2&0 and Non-secure
EL1&0.

We already have get_effective_el() which returns 1 if we are
- Running in EL1 so we assume an EL1 translation regime but without
  checking HCR_EL2.{NV, NV1} != {1,1}
- Running in EL2 with HCR_EL2.E2H = 1

The only problem with the above is that if we are in EL1&0 and
HCR_EL2.{NV1, NV} == {1, 1}, then
- Bit[54] holds the PXN instead of the UXN
- The Effective value of UXN is 0
- Bit[53] is RES0

So let's re-use that function and set PXN only when we are in
and EL[2|1]&0 translation regime.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2 months agoMerge patch series "membuff: Add tests and update to support a flag for empty/full"
Tom Rini [Thu, 3 Apr 2025 22:54:59 +0000 (16:54 -0600)]
Merge patch series "membuff: Add tests and update to support a flag for empty/full"

Simon Glass <sjg@chromium.org> says:

The membuff implementation curently has no tests. It also assumes that
head and tail can never correspond unless the buffer is empty.

This series provides a compile-time flag to support a 'full' flag. It
also adds some tests of the main routines.

The data structure is also renamed to membuf which fits better with
U-Boot.

There may be some cases in the code which could be optimised a little,
but the implementation is functional.

Link: https://lore.kernel.org/r/20250318152059.1464369-1-sjg@chromium.org
2 months agomembuf: Minor code-style improvements
Simon Glass [Tue, 18 Mar 2025 15:20:48 +0000 (16:20 +0100)]
membuf: Minor code-style improvements

Show the start in end in the comment. Comment a missing variable in
membuf_readline() and fix its line length.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuf: Add some tests
Simon Glass [Tue, 18 Mar 2025 15:20:47 +0000 (16:20 +0100)]
membuf: Add some tests

Add tests for the membuf implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuf: Correct implementation of membuf_dispose()
Simon Glass [Tue, 18 Mar 2025 15:20:46 +0000 (16:20 +0100)]
membuf: Correct implementation of membuf_dispose()

This should free the pointer, not the address of the pointer. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuf: Include stdbool
Simon Glass [Tue, 18 Mar 2025 15:20:45 +0000 (16:20 +0100)]
membuf: Include stdbool

This uses a bool type so include the required header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuf: Rename struct
Simon Glass [Tue, 18 Mar 2025 15:20:44 +0000 (16:20 +0100)]
membuf: Rename struct

Rename the struct to match the function prefix and filenames.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuff: Rename the files to membuf
Simon Glass [Tue, 18 Mar 2025 15:20:43 +0000 (16:20 +0100)]
membuff: Rename the files to membuf

Rename the C and header files to use the membuf basename, to match the
functions.

Add a MAINTAINERS entry while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agomembuff: Rename functions to have membuf_ prefix
Simon Glass [Tue, 18 Mar 2025 15:20:42 +0000 (16:20 +0100)]
membuff: Rename functions to have membuf_ prefix

The double 'f' is not necessary and is a bit annoying as elsewhere in
U-Boot we use 'buf'. Rename all the functions before it is used more
widely.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoMerge patch series "x86: Improve operation under QEMU"
Tom Rini [Thu, 3 Apr 2025 17:43:38 +0000 (11:43 -0600)]
Merge patch series "x86: Improve operation under QEMU"

Simon Glass <sjg@chromium.org> says:

U-Boot can start and boot an OS in both qemu-x86 and qemu-x86_64 but it
is not perfect.

With both builds, executing the VESA ROM causes an intermittent hang, at
least on some AMD CPUs.

With qemu-x86_64 kvm cannot be used since the move to long mode (64-bit)
is done in a way that works on real hardware but not with QEMU. This
means that performance is 4-5x slower than it could be, at least on my
CPU.

We can work around the first problem by using Bochs, which is anyway a
better choice than VESA for QEMU. The second can be addressed by using
the same descriptor across the jump to long mode.

With an MTRR fix this allows booting into Ubuntu on qemu-x86_64

In v3 some e820 patches are included to make booting reliable and avoid
ACPI tables being dropped. Also, several MTTR problems are addressed, to
support memory sizes above 4GB reliably.

Link: https://lore.kernel.org/all/20250315142643.2600605-1-sjg@chromium.org/
2 months agotest: Add a test for booting Ubuntu 24.04
Simon Glass [Sat, 15 Mar 2025 14:26:06 +0000 (14:26 +0000)]
test: Add a test for booting Ubuntu 24.04

Now that U-Boot can boot this quickly, using kvm, add a test that the
installer starts up correctly.

Use the qemu-x86_64 board in the SJG lab.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoacpi: Support checking checksums
Simon Glass [Sat, 15 Mar 2025 14:26:05 +0000 (14:26 +0000)]
acpi: Support checking checksums

When the ACPI tables come from an earlier bootloader it is helpful to
see whether the checksums are correct or not. Add a -c flag to the
'acpi list' command to support that.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agotest: acpi: Correct memory leaks
Simon Glass [Sat, 15 Mar 2025 14:26:04 +0000 (14:26 +0000)]
test: acpi: Correct memory leaks

Free the memory used in tests to avoid a leak. Also unmap the addresses
for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 months agoacpi: Add a checksum to the DMAR table
Simon Glass [Sat, 15 Mar 2025 14:26:03 +0000 (14:26 +0000)]
acpi: Add a checksum to the DMAR table

This table lacks a correct checksum at present, so fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 months agosandbox: acpi: Correct mapping in FADT
Simon Glass [Sat, 15 Mar 2025 14:26:02 +0000 (14:26 +0000)]
sandbox: acpi: Correct mapping in FADT

The values in the FADT are pointers so should not go through sandbox's
normal addr<->pointer mapping. Fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agosandbox: acpi: Avoid a warning about FADT
Simon Glass [Sat, 15 Mar 2025 14:26:01 +0000 (14:26 +0000)]
sandbox: acpi: Avoid a warning about FADT

Add a condition for sandbox, to match that of x86, to avoid the warning
"FADT not ACPI-hardware-reduced-compliant".

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoboot: Support IO UARTs for earlycon and console
Simon Glass [Sat, 15 Mar 2025 14:26:00 +0000 (14:26 +0000)]
boot: Support IO UARTs for earlycon and console

Update the string to take account of UARTs which are connected on I/O
ports, as on x86.

Fix a typo in an error message in the same command, while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoboot: Handle running out of labels
Simon Glass [Sat, 15 Mar 2025 14:25:59 +0000 (14:25 +0000)]
boot: Handle running out of labels

If only a single label is provided in the list, bootdev_next_label()
does not operate correctly and reads beyond the end of the pointer list.

Fix this by adding a new check. Also add a note to convert this array
to an alist

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoboot: Consider non-bootable partitions
Simon Glass [Sat, 15 Mar 2025 14:25:58 +0000 (14:25 +0000)]
boot: Consider non-bootable partitions

Any 'bootable' flag in a DOS partition causes boostd to only scan
bootable partitions for that media. This can mean that extlinux.conf
files on the root disk are missed.

Put this logic behind a flag and update the documentation.

For now, the flag is enabled, to preserve the existing behaviour of
bootstd which is to ignore non-bootable partitions so long as there is
at least one bootable partition on the disk.  Future work may provide a
command (or some other mechanism) to control this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoacpi: Mark struct acpi_rsdp as packed
Simon Glass [Sat, 15 Mar 2025 14:25:57 +0000 (14:25 +0000)]
acpi: Mark struct acpi_rsdp as packed

At present the size of this struct is too large on 64-bit machines.
Annotate it with __packed to fix this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Support a 64-bit ramdisk address
Simon Glass [Sat, 15 Mar 2025 14:25:56 +0000 (14:25 +0000)]
x86: Support a 64-bit ramdisk address

Add some missing pieces to bootparams so that a 64-bit ramdisk address
can be used. Tidy up the logging while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: emulation: Support BLOBLIST_TABLES properly
Simon Glass [Sat, 15 Mar 2025 14:25:55 +0000 (14:25 +0000)]
x86: emulation: Support BLOBLIST_TABLES properly

The existing QEMU implementation mostly ignored BLOBLIST_TABLES and
allocates the bulk of the tables with malloc(). Update it to place all
tables in the bloblist. Since QEMU declares a size of 128KB regardless
of the size of its tables, this requires a larger bloblist.

Fix up the e820 table to handle this, keeping the old code as an option
for now, to assist with any future bug-fixing.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: qemu: Use the new e820 API
Simon Glass [Sat, 15 Mar 2025 14:25:54 +0000 (14:25 +0000)]
x86: qemu: Use the new e820 API

Move over to use this API before making the code even more complicated.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Add a new API for e820
Simon Glass [Sat, 15 Mar 2025 14:25:53 +0000 (14:25 +0000)]
x86: Add a new API for e820

The existing mechanism is pretty painful as it requires manual
calculations for anything but a trivial setup.

Add a new API for adding e820 entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: e820: Add a function to dump the e820 table
Simon Glass [Sat, 15 Mar 2025 14:25:52 +0000 (14:25 +0000)]
x86: e820: Add a function to dump the e820 table

There is already code for this in zimage. Move it to the e820 file so
it can be used elsewhere.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agotest/py: Allow tests to be filtered by role
Simon Glass [Sat, 15 Mar 2025 14:25:51 +0000 (14:25 +0000)]
test/py: Allow tests to be filtered by role

Some test can only be run by a particular board in a lab, e.g. because
they are loaded with an OS image used by the test. Add a way to specify
this in tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agotest/py: Add a helper to send characters
Simon Glass [Sat, 15 Mar 2025 14:25:50 +0000 (14:25 +0000)]
test/py: Add a helper to send characters

The existing run_command() method is not great for sending things other
than U-Boot commands. Add a helper for sending arbitrary strings as well
as control characters.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 months agotest/py: Correct sizing of created disks
Simon Glass [Sat, 15 Mar 2025 14:25:49 +0000 (14:25 +0000)]
test/py: Correct sizing of created disks

At present the disks end up being 1MB shorter than they should be,
since dd truncates by default.

Move the code into a function and update it to avoid truncation.

This resolves various warnings when running sandbox tests, of the form:

   mmc_bread() MMC: block number 0x9801 exceeds max(0x9800)

caused by the FAT partition being scanning.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: qemu: Support environment and cat command
Simon Glass [Sat, 15 Mar 2025 14:25:48 +0000 (14:25 +0000)]
x86: qemu: Support environment and cat command

Add support for an environment stored in the first partition of the
disk, which is assumed to hold a FAT filesystem.

Support the 'cat' command as it is useful for looking at extlinux.conf
files.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: emulation: Set an MTRR for the RAM
Simon Glass [Sat, 15 Mar 2025 14:25:47 +0000 (14:25 +0000)]
x86: emulation: Set an MTRR for the RAM

QEMU likes to have an MTRR set up, just like real machines. Add an MTRR
which covers the total RAM size.

This does nothing on machines without MTRRs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Allow adding non-aligned size for MTRR
Simon Glass [Sat, 15 Mar 2025 14:25:46 +0000 (14:25 +0000)]
x86: Allow adding non-aligned size for MTRR

At present mtrr_add_request() requires that the size is a power of two.
This is too limiting for machines with 4GB (or more) of RAM, since they
often must take account of a memory hole at 3GB.

Update the function to automatically deal with an unaligned size, using
more MTRRs as required.

The algorithm is taken from coreboot commit 60bce10750

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Correct msr operation on amd64
Simon Glass [Sat, 15 Mar 2025 14:25:45 +0000 (14:25 +0000)]
x86: Correct msr operation on amd64

The CONFIG option is no-longer correct since we can have SPL and PPL
with different bitness.

Fix this and sync up with Linux 6.13 in this area, since this is where
the code came from many years ago.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Update cpuid_eax et al to work on amd64
Simon Glass [Sat, 15 Mar 2025 14:25:44 +0000 (14:25 +0000)]
x86: Update cpuid_eax et al to work on amd64

The existing functions work but the register clobbers are wrong, so
strange bugs results.

The original functions were taken from a very old version of Linux.
Update them from Linux 6.13

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Update mtrr command to support 64-bit values
Simon Glass [Sat, 15 Mar 2025 14:25:43 +0000 (14:25 +0000)]
x86: Update mtrr command to support 64-bit values

The MTRR registers have 64-bit values. Update the command to use 64-bit
values so that memory larger than 4GB can be handled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Add functions to convert between mtrr size and mask
Simon Glass [Sat, 15 Mar 2025 14:25:42 +0000 (14:25 +0000)]
x86: Add functions to convert between mtrr size and mask

Rather than repeating the same code in several places, add some
functions which can do the conversion.

Use the cpu_phys_address_size() function to obtain the physical-address
size, since it is more reliable with kvm, where the host CPU may have a
different value from the emulation CPU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Support CPU functions in long mode
Simon Glass [Sat, 15 Mar 2025 14:25:41 +0000 (14:25 +0000)]
x86: Support CPU functions in long mode

At present it is not possible to find out the physical-address size in
long mode, so a predefined value is used.

Update the macros to support this properly, since it is important when
programming MTRRs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Rename the _D dirty flag
Simon Glass [Sat, 15 Mar 2025 14:25:40 +0000 (14:25 +0000)]
x86: Rename the _D dirty flag

This value happens to be used by ctype.h so chose a different name.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Use a simple jump into long mode
Simon Glass [Sat, 15 Mar 2025 14:25:39 +0000 (14:25 +0000)]
x86: Use a simple jump into long mode

With the 64-bit descriptor we can use a jump instruction, rather than
pushing things on the stack.

Since the processor is in 64-bit mode by this point, pop a 64-bit value
from the stack, containing the target address.

This simplifies the code slightly, in particular its use of the stack.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Use the same GDT when jumping to long mode
Simon Glass [Sat, 15 Mar 2025 14:25:38 +0000 (14:25 +0000)]
x86: Use the same GDT when jumping to long mode

Make use the existing GDT which now includes entries for 64-bit code.
Leave the interrupt descriptors alone. They can be tidied up once U-Boot
starts up.

With this, kvm mode works with QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/31

2 months agox86: Disable paging before changing to long mode
Simon Glass [Sat, 15 Mar 2025 14:25:37 +0000 (14:25 +0000)]
x86: Disable paging before changing to long mode

This is required as part of the procedure. The existing code works
because it changes the GDT at the same time, but this makes kvm
unhappy.

Update the algorithm to disable and then re-enable paging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Tidy up the GDT size in start/16.S
Simon Glass [Sat, 15 Mar 2025 14:25:36 +0000 (14:25 +0000)]
x86: Tidy up the GDT size in start/16.S

Use a symbol to select the size of the GDT, rather than hard-coding a
value. This matches how it is done in start64

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Include stdbool.h in interrupt header
Simon Glass [Sat, 15 Mar 2025 14:25:35 +0000 (14:25 +0000)]
x86: Include stdbool.h in interrupt header

This makes use of a 'bool' type, so include the required header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Drop the message about features missing in 64-bit
Simon Glass [Sat, 15 Mar 2025 14:25:34 +0000 (14:25 +0000)]
x86: Drop the message about features missing in 64-bit

This functions normally and has done for a while, so drop this scary
message.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: spl: Drop duplicate CPU init
Simon Glass [Sat, 15 Mar 2025 14:25:33 +0000 (14:25 +0000)]
x86: spl: Drop duplicate CPU init

x86_cpu_init_f() is called by arch_cpu_init() a few lines below this
code. Drop the duplicate call.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Use defines for the cache flags
Simon Glass [Sat, 15 Mar 2025 14:25:32 +0000 (14:25 +0000)]
x86: Use defines for the cache flags

Use some named flags when setting up the cache, so it is easier to see
what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Add 64-bit entries to the GDT
Simon Glass [Sat, 15 Mar 2025 14:25:31 +0000 (14:25 +0000)]
x86: Add 64-bit entries to the GDT

At present it is not possible to execution 64-bit code without
installing an entire new Global Descriptor Table. This is inconvenient
since kvm does not seem to like switching into long mode with a new
table.

It isn't actually necessary, since we can just extend the existing
table. Add some new entries to this effect.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Avoid clearing the VESA display
Simon Glass [Sat, 15 Mar 2025 14:25:30 +0000 (14:25 +0000)]
x86: Avoid clearing the VESA display

U-Boot clears the display when it starts up, so there is no need to ask
the VESA driver to do this. Fix this and add a comment explaining the
flags.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Drop use of CONFIG_REALMODE_DEBUG
Simon Glass [Sat, 15 Mar 2025 14:25:29 +0000 (14:25 +0000)]
x86: Drop use of CONFIG_REALMODE_DEBUG

This option is not actually defined in Kconfig anymore. Use a normal
debug print instead, which has a similar effect.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2 months agox86: Add some log categories
Simon Glass [Sat, 15 Mar 2025 14:25:28 +0000 (14:25 +0000)]
x86: Add some log categories

Add categories for i8259 and bios files, so that log statements have the
right category.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: Drop mpspec from the SPL build
Simon Glass [Sat, 15 Mar 2025 14:25:27 +0000 (14:25 +0000)]
x86: Drop mpspec from the SPL build

This is not needed in SPL, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: qemu: Avoid accessing BSS too early
Simon Glass [Sat, 15 Mar 2025 14:25:26 +0000 (14:25 +0000)]
x86: qemu: Avoid accessing BSS too early

BSS is placed in DRAM which is actually available early with QEMU. But
it is cleared by the init sequence, so values stored there are lost.

Move the system-type flag into a function, instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: qemu: Enable dhrystone
Simon Glass [Sat, 15 Mar 2025 14:25:25 +0000 (14:25 +0000)]
x86: qemu: Enable dhrystone

Provide the 'dhry' command, which helps to check that kvm is being used
properly with QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agox86: qemu: Switch to bochs display
Simon Glass [Sat, 15 Mar 2025 14:25:24 +0000 (14:25 +0000)]
x86: qemu: Switch to bochs display

The vesa display is widely used on hardware, but it is a bit of a pain
with QEMU. It requires executing option ROMs, which either doesn't work
with kvm, or is difficult to do in a kvm/QEMU-friendly way.

THe bochs display is probably better anyway, so switch to that. It works
fine with kvm as it doesn't need an option ROM.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/31

2 months agox86: Expand x86_64 early memory
Simon Glass [Sat, 15 Mar 2025 14:25:23 +0000 (14:25 +0000)]
x86: Expand x86_64 early memory

The SPL and pre-reloc malloc()-space is not large enough to start up
with a display. Expand it.

Switch the order of SPL_SYS_MALLOC_F_LEN and SPL_TEXT_BASE since this
matches what 'savedefconfig' gives us.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agosandbox: Correct a typo in mapmem
Simon Glass [Sat, 15 Mar 2025 14:25:22 +0000 (14:25 +0000)]
sandbox: Correct a typo in mapmem

This should say 'cast', not 'case', so fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 months agoMerge patch series "acpi_table: Fix IORT RC node"
Tom Rini [Thu, 3 Apr 2025 17:38:22 +0000 (11:38 -0600)]
Merge patch series "acpi_table: Fix IORT RC node"

This series from Patrick Rudolph <patrick.rudolph@9elements.com> brings
in an assortment of ACPI related fixes.

Link: https://lore.kernel.org/r/20250316083300.2692377-1-patrick.rudolph@9elements.com
2 months agotest: acpi: Add IORT tests
Patrick Rudolph [Sun, 16 Mar 2025 08:32:56 +0000 (09:32 +0100)]
test: acpi: Add IORT tests

Add tests for IORT table generation:
- SMMU_V3 node
- RC node

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2 months agoacpi: Conditionally set mapping_offset in IORT
Patrick Rudolph [Sun, 16 Mar 2025 08:32:55 +0000 (09:32 +0100)]
acpi: Conditionally set mapping_offset in IORT

The spec recommends to set the mapping_offset only when there are
ID mappings as indicated by the mapping_count field.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2 months agoacpi: Clear reserved bits in IORT
Patrick Rudolph [Sun, 16 Mar 2025 08:32:54 +0000 (09:32 +0100)]
acpi: Clear reserved bits in IORT

The IORT spec says that reserved bits must be set to zero, thus clear
all fields of the struct before starting to fill out non-reserved
fields.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2 months agoacpi_table: Add asserts in IORT
Patrick Rudolph [Sun, 16 Mar 2025 08:32:53 +0000 (09:32 +0100)]
acpi_table: Add asserts in IORT

Check that the provided offsets are really pointing to a node
that have been previously written and are of the correct type.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2 months agoacpi_table: Fix IORT RC node
Patrick Rudolph [Sun, 16 Mar 2025 08:32:52 +0000 (09:32 +0100)]
acpi_table: Fix IORT RC node

Even though the RC node has the correct size and the ID mappings
are written to the end of the node, the ID 'mapping offset' and
'mapping count' are not written in the IORT RC node header, thus it
looks like that the RC node has no ID mappings.
The Linux kernel doesn't complain about the invalid IORT RC node,
even though the spec says that each RC node must have an ID mapping.
The kernel will fail to use MSI IRQs and fall back to a legacy IRQ
mechanism that's not working either.
Finally it will show strange behaviour around PCI interrupts, making it
hard to trace back to an invalid IORT RC nodes.

Add the missing ID mapping count and mapping offset.

TEST: Fixes IRQ usage of PCI devices on qemu/sbsa-ref.
Fixes: bf5d37662da5 "acpi: acpi_table: Add IORT support"

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2 months agoMerge patch series "Introduce J742S2 SoC and EVM"
Tom Rini [Thu, 3 Apr 2025 17:37:57 +0000 (11:37 -0600)]
Merge patch series "Introduce J742S2 SoC and EVM"

Manorit Chawdhry <m-chawdhry@ti.com> says:

The series adds support for J742S2 family of SoCs. Also adds J742S2 EVM
Support and re-uses most of the stuff from the superset device J784s4.

This device is a subset of J784S4 and shares the same memory map and
thus the code is being reused from J784S4 to avoid duplication.

It initially cleans up the J784s4 and AM69 files so that they can be
re-usable for j742s2 and then it introduces J742S2.

The DT for the following SoC will be coming to U-boot during 6.13 Sync
so the series is kept as RFC till then.

Here are some of the salient features of the J742S2 automotive grade
application processor:

The J742S2 SoC belongs to the K3 Multicore SoC architecture platform,
providing advanced system integration in automotive, ADAS and industrial
applications requiring AI at the network edge. This SoC extends the K3
Jacinto 7 family of SoCs with focus on raising performance and
integration while providing interfaces, memory architecture and compute
performance for multi-sensor, high concurrency applications.

Some changes that this devices has from J784S4 are:
* 4x Cortex-A72 vs 8x Cortex-A72
* 3x C7x DSP vs 4x C7x DSP
* 4 port ethernet switch vs 8 port ethernet switch
* 2 DDR controller vs 4 DDR controller

Test logs:
https://gist.github.com/manorit2001/f7df0e8cca1e9973b4361f0559c6f53d

Link: https://lore.kernel.org/r/20250317-b4-upstream-j742s2-v4-0-4ba88bfd357a@ti.com
2 months agoconfigs: Introduce configs for J742S2
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:27 +0000 (10:24 +0530)]
configs: Introduce configs for J742S2

Based off j784s4 configs with delta changes for J742S2

[ Add AVS support for J742S2 ]

Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agoarm: dts: Introduce J742S2 U-boot DTS files
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:26 +0000 (10:24 +0530)]
arm: dts: Introduce J742S2 U-boot DTS files

Include the U-boot device tree files needed to boot the board.

[ DDR config ]

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agoboard: ti: Introduce basic board files for the J742S2 family
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:25 +0000 (10:24 +0530)]
board: ti: Introduce basic board files for the J742S2 family

Introduce the basic files needed to support the TI J742S2 family of SoCs.

Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agoarm: mach-k3: j742s2: Introduce clock and device files for J742S2 SoC
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:24 +0000 (10:24 +0530)]
arm: mach-k3: j742s2: Introduce clock and device files for J742S2 SoC

Re-use j784s4 clocks and power domains for j742s2 family of device.

Reviewed-by: Udit Kumar <u-kumar1@ti.com>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agosoc: Add information to identify the J742S2 SoC family
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:23 +0000 (10:24 +0530)]
soc: Add information to identify the J742S2 SoC family

J742S2 has the same part number as J784S4 but JTAG_DEVICE_ID has a
PKG bit that tells about J742S2.

Add support for reading JTAG_DEVICE_ID and set family as J742S2 based
on that.

Link: https://www.ti.com/lit/pdf/spruje3
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agoarm: dts: k3-j784s4-ddr: Refactor J784s4 ddr file to a common file
Manorit Chawdhry [Mon, 17 Mar 2025 04:54:22 +0000 (10:24 +0530)]
arm: dts: k3-j784s4-ddr: Refactor J784s4 ddr file to a common file

Refactor J784s4 ddr file to a common file which uses the
superset device to allow reuse in j742s2-evm which uses the subset part.

Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agoarm: dts: k3-j784s4-binman.dtsi: Clean up and templatize boot binaries
Neha Malcom Francis [Mon, 17 Mar 2025 04:54:21 +0000 (10:24 +0530)]
arm: dts: k3-j784s4-binman.dtsi: Clean up and templatize boot binaries

Clean up templatized boot binaries for j784s4 soc. This includes
modifying the k3-j784s4-binman.dtsi to use SPL_BOARD_DTB,
BOARD_DESCRIPTION and UBOOT_BOARD_DESCRIPTION from the files that
include it to further reuse code.

k3-j784s4-binman.dtsi will contain only templates. Only required boot
binaries can be built from the templates in the boards' respective
-u-boot.dtsi file (or k3-<board>-binman.dtsi if it exists). This allows
clear distinction between the SoC common stuff vs. what is additionally
needed to boot up a specific board.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
[ Do it only for j784s4 ]
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2 months agotools: binman: control.py: Delete template nodes after parsing
Neha Malcom Francis [Mon, 17 Mar 2025 04:54:20 +0000 (10:24 +0530)]
tools: binman: control.py: Delete template nodes after parsing

Dynamically going through the subnode array and deleting leads to
templates being skipped from deletion when templates are consecutive in
the subnode list. Prevent this from happening by first parsing the DT
and then deleting the nodes. Add a testcase as well for this cornercase.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
2 months agoarm64: Add MIDR entries for Cortex-A55, A73 and A75
Peter Robinson [Sun, 16 Mar 2025 14:59:52 +0000 (14:59 +0000)]
arm64: Add MIDR entries for Cortex-A55, A73 and A75

Add MIDR entries for Cortex-A55, Cortex-A73 and
Cortex-A75 cores and update the is_coretex_a entries.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
2 months agoMerge patch series "fs: exfat: Add exfat port based on exfat-fuse"
Tom Rini [Thu, 3 Apr 2025 02:01:14 +0000 (20:01 -0600)]
Merge patch series "fs: exfat: Add exfat port based on exfat-fuse"

Marek Vasut <marex@denx.de> says:

Import exfat-fuse libexfat, add U-Boot filesystem layer porting glue
code and wire exfat support into generic filesystem support code. This
adds exfat support to U-Boot.

Fill in generic filesystem interface for mkdir and rm commands.
Make filesystem tests test the generic interface as well as exfat,
to make sure this code does not fall apart.

Link: https://github.com/relan/exfat/commits/0b41c6d3560d
Link: https://lore.kernel.org/r/20250317031418.223019-1-marex@denx.de
2 months agotest_fs: Add exfat tests
Marek Vasut [Mon, 17 Mar 2025 03:12:50 +0000 (04:12 +0100)]
test_fs: Add exfat tests

Add tests for the exfat filesystem. These tests are largely an
extension of the FS_GENERIC tests with the following notable
exceptions.

The filesystem image for exfat tests is generated using combination
of exfatprogs mkfs.exfat and python fattools. The fattols are capable
of generating exfat filesystem images too, but this is not used, the
fattools are only used as a replacement for dosfstools 'mcopy' and
'mdir', which are used to insert files and directories into existing
fatfs images and list existing fatfs images respectively, without the
need for superuser access to mount such images.

The exfat filesystem has no filesystem specific command, there is only
the generic filesystem command interface, therefore check_ubconfig()
has to special case exfat and skip check for CONFIG_CMD_EXFAT and
instead check for CONFIG_FS_EXFAT.

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agoconfigs: sandbox: Enable exfat support
Marek Vasut [Mon, 17 Mar 2025 03:12:49 +0000 (04:12 +0100)]
configs: sandbox: Enable exfat support

Enable exfat support in sandbox and sandbox64 to assure build and
test coverage of this filesystem on both 32bit and 64bit builds.

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agofs: exfat: Demote filesystem detection failure message to debug()
Marek Vasut [Mon, 17 Mar 2025 03:12:48 +0000 (04:12 +0100)]
fs: exfat: Demote filesystem detection failure message to debug()

Demote "exFAT file system is not found" message to debug(). This is
printed when U-Boot attempts to auto-detect the filesystem via generic
filesystem API by attempting to mount the device, and fails to do so
because there is another filesystem in place. The libexfat-fuse code
prints this an error, which interferes with 'test_gpt' test. Demote
the message to debug().

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2 months agofs: exfat: Fix conversion overflow errors
Marek Vasut [Mon, 17 Mar 2025 03:12:47 +0000 (04:12 +0100)]
fs: exfat: Fix conversion overflow errors

Fix the following conversion overflow errors. The UTF8-to-UTF16
conversion is done through 32bit wchar_t, but U-Boot codebase is
built with -fshort-wchar which limits wchar_t to 16bit. Replace
the built-in wchar_t with u32 to assure the intermediate type is
32bit.

"
fs/exfat/utf.c: In function ‘utf8_to_wchar’:
fs/exfat/utf.c:165:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 18 & 1835008’ to ‘0’ [-Woverflow]
  165 |                 *wc = ((wchar_t) input[0] & 0x07) << 18;
      |                       ^
fs/exfat/utf.c:170:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 24 & 50331648’ to ‘0’ [-Woverflow]
  170 |                 *wc = ((wchar_t) input[0] & 0x03) << 24;
      |                       ^
fs/exfat/utf.c:175:23: warning: overflow in conversion from ‘int’ to ‘wchar_t’ {aka ‘short unsigned int’} changes value from ‘(int)(short unsigned int)*input << 30 & 1073741824’ to ‘0’ [-Woverflow]
  175 |                 *wc = ((wchar_t) input[0] & 0x01) << 30;
      |                       ^
"

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agofs: exfat: Add U-Boot porting layer
Marek Vasut [Mon, 17 Mar 2025 03:12:46 +0000 (04:12 +0100)]
fs: exfat: Add U-Boot porting layer

Add U-Boot adjustments to the libexfat code and integrate
the result into U-Boot filesystem layer. This provides full
read-write exfat support for U-Boot available via generic
filesystem interface.

FS_DIRENT_NAME_LEN is increased to 1024 in case exfat is
enabled, because EXFAT can use UTF16 names, which do not
fit into current FS_DIRENT_NAME_LEN. To avoid affecting
every configuration, increase FS_DIRENT_NAME_LEN only in
case EXFAT is enabled.

Example usage via sandbox, assuming disk.img with one exfat partition:

Drive info:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; host info 0'
dev       blocks  blksz label           path
  0       262144    512 0               ../disk.img

List files:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 /api'
      475   Kconfig
      230   Makefile
     1873   README
     ...
10 file(s), 0 dir(s)

Load and checksum a file:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \
                crc32 $loadaddr $filesize'
56724 bytes read in 1 ms (54.1 MiB/s)
crc32 for 00000000 ... 0000dd93 ==> b2e847c9

$ crc32 .config
b2e847c9

Load .config file to RAM, store the file into FS as /newconfig,
load the /newconfig into RAM and checksum the file:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; load host 0:1 $loadaddr .config ; \
save host 0:1 $loadaddr /newconfig $filesize ; \
load host 0:1 0x10000 /newconfig ; \
crc32 0x10000 $filesize'
56724 bytes read in 1 ms (54.1 MiB/s)
56724 bytes written in 0 ms
56724 bytes read in 0 ms
crc32 for 00010000 ... 0001dd93 ==> b2e847c9

Remove file 3.txt and create new directory /newdir:
$ ./u-boot -Tc 'host bind 0 ../disk.img ; ls host 0:1 / ; \
                rm host 0:1 3.txt ; mkdir host 0:1 /newdir ; \
ls host 0:1 /'
...
        0   1.txt
        0   2.txt
        0   3.txt
        0   4.txt
        0   5.txt

7 file(s), 4 dir(s)
...
        0   1.txt
        0   2.txt
            newdir/
        0   4.txt
        0   5.txt

6 file(s), 5 dir(s)

Acked-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2 months agofs: exfat: Import libexfat from fuse-exfat
Marek Vasut [Mon, 17 Mar 2025 03:12:45 +0000 (04:12 +0100)]
fs: exfat: Import libexfat from fuse-exfat

Import most of libexfat from [1] except for log.c verbatim. The code
does not even compile and further adjustments and integration into
U-Boot filesystem code is in the next patch.

[1] https://github.com/relan/exfat
    0b41c6d3560d ("CI: bump FreeBSD to 13.1.")

Acked-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2 months agofs: Add generic fs_devread() implementation
Marek Vasut [Mon, 17 Mar 2025 03:12:44 +0000 (04:12 +0100)]
fs: Add generic fs_devread() implementation

Add generic implementation of write into a block device to be used
by filesystem implementations. This is a pair function for already
existing fs_devread().

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agolinux: Add generic struct stat {}
Marek Vasut [Mon, 17 Mar 2025 03:12:43 +0000 (04:12 +0100)]
linux: Add generic struct stat {}

Add generic implementation of struct stat {} imported from Linux 6.13.y
commit 27560b371ab8 ("fs: pack struct kstat better"). This can be used
by filesystem code imported from elsewhere. Now struct stat {} becomes
available on all supported architectures.

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agotest_fs: Allow testing FS_GENERIC
Marek Vasut [Mon, 17 Mar 2025 03:12:42 +0000 (04:12 +0100)]
test_fs: Allow testing FS_GENERIC

The generic filesystem interface was so far untested. The interface
is similar to the FS specific interfaces with FS specific prefixes,
like ext4ls, fatmkdir, ... but it does not have any prefixes, i.e.
it provides plain ls, mkdir, ... commands.

Extend the test parameters to include 'fs_cmd_prefix' and optionally
'fs_cmd_write' parameters. The 'fs_cmd_prefix' allow specifying the
filesystem specific command prefix, like 'ext4' in 'ext4ls'. The
'fs_cmd_write' allows selecting between 'write'/'save' command name
for storing files into the filesystem, see last paragraph.

Introduce new 'fs_generic' fs_type which is used to parametrize existing
tests and run them without any prefixes if detected, thus testing the
generic filesystem interface. Use the fatfs as the backing store for the
generic FS tests.

The check_ubconfig needs to be slightly adjusted to avoid test for
CMD_FS_GENERIC_WRITE which does not exist separately from CMD_FS_GENERIC.

The CMD_FS_GENERIC does not provide generic 'write' command, instead
the generic equivalent command is called 'save' . Add simple ternary
oeprator to use 'save' command for CMD_FS_GENERIC tests and '..write'
commands for filesystem specific tests.

Enable generic filesystem tests for basic/extended/mkdir/unlink tests.

Signed-off-by: Marek Vasut <marex@denx.de>
2 months agocmd: fs: Add generic rm implementation
Marek Vasut [Mon, 17 Mar 2025 03:12:41 +0000 (04:12 +0100)]
cmd: fs: Add generic rm implementation

Add generic implementation of the 'rm' command to delete files
from filesystems using the generic filesystem API.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2 months agocmd: fs: Add generic mkdir implementation
Marek Vasut [Mon, 17 Mar 2025 03:12:40 +0000 (04:12 +0100)]
cmd: fs: Add generic mkdir implementation

Add generic implementation of the 'mkdir' command to create directories
in filesystems using the generic filesystem API.

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marex@denx.de>
2 months agoonenand: Remove ONENAND_BOOT option
Tom Rini [Thu, 13 Mar 2025 17:17:29 +0000 (11:17 -0600)]
onenand: Remove ONENAND_BOOT option

The option ONENAND_BOOT is never set, so remove it. The option
SYS_ONENAND_BOOT was never migrated to Kconfig and any platforms which
supported that have long been removed from the code, so remove the
reference there as well.

Signed-off-by: Tom Rini <trini@konsulko.com>
2 months agoMerge patch series "Various toolchain compatibility fixes/improvements"
Tom Rini [Wed, 2 Apr 2025 20:34:08 +0000 (14:34 -0600)]
Merge patch series "Various toolchain compatibility fixes/improvements"

Sam Edwards <cfsworks@gmail.com> says:

This is v2 of my "misc. fixes" series, sent to prepare the codebase for more
direct LLVM support in the near future. This series contains several fixes that
I found in the process of preparing that support and which address issues
independent of any future feature or enhancement. I am sending these now, both
so that their inclusion is not delayed by discussion on my upcoming series and
to make the latter more manageable.

Link: https://lore.kernel.org/r/20250315221813.1265193-1-CFSworks@gmail.com
2 months agospl: Align FDT load address
Sam Edwards [Sat, 15 Mar 2025 22:18:13 +0000 (15:18 -0700)]
spl: Align FDT load address

While the image size is generally a multiple of 8 bytes, this is not
actually guaranteed; some linkers (like LLD) will shave a few bytes off
of the end of output sections if there are no content bytes there. Since
libfdt imposes a hard rule of 8-byte alignment, make the SPL also be
explicit about the alignment when loading the FDT.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2 months agospl: riscv: opensbi: Error on misaligned FDT
Sam Edwards [Sat, 15 Mar 2025 22:18:12 +0000 (15:18 -0700)]
spl: riscv: opensbi: Error on misaligned FDT

libfdt 1.6.1+ requires the FDT to be 8-byte aligned and returns an error
if not. OpenSBI 1.0+ includes this version of libfdt and will also
reject misaligned FDTs.

However, OpenSBI cannot indicate the error to the user: since it cannot
access the serial console, it can only silently hang. This proved very
difficult to diagnose without proper debugging facilities. Therefore,
give the U-Boot SPL, which *can* print error messages, an additional
check for proper FDT alignment. Hopefully this saves a lot of
development cycles if another developer encounters alignment problems.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2 months agoscripts/Makefile.lib: efi: Preserve the .dynstr section as well
Sam Edwards [Sat, 15 Mar 2025 22:18:11 +0000 (15:18 -0700)]
scripts/Makefile.lib: efi: Preserve the .dynstr section as well

This section is required by .dynamic and llvm-objcopy will exit with a
fatal error if it is not also preserved in the output.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
2 months agoefi_loader: Move .dynamic out of .text in EFI
Sam Edwards [Sat, 15 Mar 2025 22:18:10 +0000 (15:18 -0700)]
efi_loader: Move .dynamic out of .text in EFI

EFI applications need to be relocatable. Ordinarily, this is achieved
through a PE-format .reloc section, but since that requires toolchain
tricks to achieve, U-Boot's EFI applications instead embed ELF-flavored
relocation information and use it for self-relocation; thus, the
.dynamic section needs to be preserved.

Before this patch, it was tacked on to the end of .text, but this was
not proper: A .text section is SHT_PROGBITS, while the .dynamic section
is SHT_DYNAMIC. Attempting to combine them like this creates a section
type mismatch. While GNU ld doesn't seem to complain, LLVM's lld
considers this a fatal linking error.

This patch moves .dynamic out to its own section, so that the output ELF
has the correct types. (They're all mashed together when converting to
binary anyway, so this patch causes no change in the final .efi output.)

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Cc: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2 months agoarm: riscv: efi: Export _start symbol from crt0_*_efi stubs
Sam Edwards [Sat, 15 Mar 2025 22:18:09 +0000 (15:18 -0700)]
arm: riscv: efi: Export _start symbol from crt0_*_efi stubs

While the _start label is only intended for use locally to populate the
(hand-written) PE header, the linker script includes ENTRY(_start) which
designates it as the entry point in the output ELF, resulting in linker
warnings under some linkers (e.g. LLVM's lld) due to _start not being a
globally-visible symbol. Since  ELF is only an intermediary build
format, and the aforementioned PE header correctly points to _start, the
ENTRY(_start) directive could easily be removed to silence this warning.

However, since some developers who are debugging EFI by analyzing the
intermediary ELF may appreciate having correct entry-point information,
this patch instead promotes the _start labels to global symbols,
silencing the linker warning and making the intermediary ELF reflect the
true entry point.

This patch doesn't affect the final output binaries in any way.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 months agomakefile: Add READELF command variable
Sam Edwards [Sat, 15 Mar 2025 22:18:08 +0000 (15:18 -0700)]
makefile: Add READELF command variable

This allows setting READELF=llvm-readelf in order to use the LLVM
version of the readelf utility. It also aligns with the practice of not
using $(CROSS_COMPILE) in any build recipes directly, reducing the
number of places where $(CROSS_COMPILE) is used.

Signed-off-by: Sam Edwards <CFSworks@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>