Commit Graph

98782 Commits

Author SHA1 Message Date
Simon Glass
dfa072fd07 test: Move image creation to test/py/img
Rather than having this code mixed with the tests, it seems better to
put it up one level. Move the directory and tidy up references.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 15:32:25 -06:00
Simon Glass
244f7436ce Merge branch 'maked' into 'master'
sandbox: Fix memory corruption around 1MB

See merge request u-boot/u-boot!153
2025-08-17 21:14:40 +00:00
Simon Glass
0d523d8d55 sandbox: Abort if a partition memory map is detected
This can indicate that something is horribly wrong. It seems better to
abort, rather than just print a message which might not be noticed.

If the mapping does not map exactly, abort.

Series-to: concept
Cover-letter:
sandbox: Fix memory corruption around 1MB
After many hours of debugging, it turns out that the PCI EA driver is
mapping itself into RAM at 1MB. This happens to be where the kernel
ends up, with the vbe_abrec_os bootmeth. Since measurement is enabled,
bootm_measure() calls map_sysmem() on the kernel in order to measure it.

easurement takes place, although of course using the wrong data. Then,
through a strange sequence of events, which I have found very hard to
narrow down, the malloc() heap is corrupted.

This series provides a fix.

To repeat this problem:

  NO_LTO=1 ./test/py/test.py --bd sandbox --build -k
     "(ut or vbe) and not efi and not slow and not dm"

which dies when running vbe_test_abrec_oem_norun:

   ...
   => echo $?
   0
   => host bind 0 [...]/build-sandbox/persistent-data/vbe1.img
   => ut -f bootstd vbe_test_abrec_oem_norun
   Test: bootstd_setup_for_tests: bootstd_common.c
   common/dlmalloc.c:793: do_check_free_chunk:
      Assertion `next->prev_size == sz' failed.
   resetting ...

With this series, the above now passes.
END
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 14:37:25 -06:00
Simon Glass
5ef5e6a8cc test: pci: Use the exact mapping size for PCI EA tests
Update the sizes to the expected size of the device's mapping in each
case, to avoid a warning in map_physmem() about a partial map.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 14:37:22 -06:00
Simon Glass
fbb05dc0d1 sandbox: Use the exact mapping size for PCI in pmc
Update the size to the expected size of the device's mapping, to avoid
a warning in map_physmem() about a partial map.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 14:37:22 -06:00
Simon Glass
9932bb407a sandbox: Move PCI EA space out of RAM
The address chosen for testing this feature is 1MB which is part of the
sandbox RAM. When devices access this, e.g. with map_sysmem(), the
memory is mapped to a PCI device. Any changes then apply to that device
and are not written to memory. Reads also come from the device.

It is not safe to use RAM space in this way.

A symptom that something is wrong is the log message:

   map_physmem: Warning: partial map at 100000, wanted 4, got 2000

Move the memory out of the way and document it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 21ebbafde8 ("test: dm: Add a test for PCI Enhanced Allocation")
2025-08-17 14:37:22 -06:00
Simon Glass
dcfec7fd37 sandbox: Swap the wanted and got messages in map_physmem()
The ordering is reversed. Fix it, to avoid confusion.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 14:37:22 -06:00
Simon Glass
f85258951d Merge branch 'makea' into 'master'
test: Move towards using a fixture for test images

See merge request u-boot/u-boot!152
2025-08-17 12:49:58 +00:00
Simon Glass
a2b4596ccf test/py: Update test_ut_dm_init_bootstd() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Series-to: concept
Cover-letter:
test: Move towards using a fixture for test images
There are quite a few test images created by the test system. Most are
needed for bootstd tests.

At present these are created by a test, called test_ut_dm_init_bootstd()
which runs before the test_ut() tests.

This means that it is possible to create the images once, then iterate
on a test without the images being recreated each time.

While this is not a terrible approach, it does have some drawbacks:

- If an image is missing or corrupted for some reason, the test fails
- The relationship between the images and the tests is not obvious
- Images are often created even if the tests to be run do not need them

Overall, it seems worthwhile to explore moving to using a fixture for
the images.

Another problem is that 'make qcheck' and 'make pcheck' are not tested
in CI, so can break over time. The latter is a good way of seeing
whether each test is independent, e.g. not reliant on files created by
another test.

Overall this area of U-Boot could use some attention. This series makes
a very small start on this:

- Update test_fdt_add_pubkey() to work without test_vboot_base()
- Fix 'make qcheck' so that it passes
- Minor fixes to a few tests
- Pass separate fixtures to the image-setup functions instead of the
  overall ubman fixture
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:10:27 -06:00
Simon Glass
b667fd9e0c test/py: Update setup_vbe_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:10:26 -06:00
Simon Glass
eafa440c59 test/py: Update setup_localboot_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
71cd1eddea test/py: Update setup_cedit_file() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
9bec0b3fad test/py: Update setup_efi_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
6665d9fa38 test/py: Update setup_android_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
e6dde985e6 test/py: Update setup_cros_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
da2c60ff34 test/py: Update setup_ubuntu_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
f4b979eae4 test/py: Update setup_fedora_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
13c72bfea0 test/py: Update setup_extlinux_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
f03a3b2c37 test/py: Update setup_bootmenu_image() to avoid ubman
Pass in the two fixtures this function actually requires, rather than
ubman, which is a function-scoped fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
6f664d8445 test/py: Provide a run_and_log() function that uses log
The normal function requires a ubman but only uses it to find the log
fixture. This is a pain since the ubman is a function-level fixture.

Provide a version that takes a log directory, so that it can be called
from a session fixture.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
06aed09ed0 test: Update test_fdt_add_pubkey() to create its own files
This test should create its own files rather than relying on those
created by test_vboot_base(). Copy the code in the test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
bddede757b test: Move create_rsa_pair() out of test_vboot_base()
At present test_fdt_add_pubkey() relies on the vboot test having already
run, since its makes use of the files that test produces.

This means that the tests cannot run in parallel (make pcheck).

As a first step to resolving this, move the required common code out to
a standalone function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
7e4bad3225 test: Correct implementation of Spawn() in ConsoleSandbox
Now that this base-class function is called, it can produce an error on
test failure, since it passes an empty list for the arguments.

Rename the reset() function to prepare_for_spawn() and use that instead.

See also: ca30385c61 ("Correct implementation of Spawn() in ConsoleBase")

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
69f4226ca5 test: Mark the sleep tests as slow
These tests do take quite a bit of time, so mark them as such.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
834d847610 test: vbe: Avoid using fdt_util to compile a devicetree
The VBE test uses fdt_util to compile a devicetree.

Other tests log the output of the dtc tool, which can be helpful when
a test fails.

For reasons which are unclear, using fdt_util means that the path to dtc
ends up being './scripts/dtc/dtc' when run from 'make qcheck'. This
causes a failure to set up the image required for the VBE test.

Update the test to use the normal run_and_log() method instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 06:02:16 -06:00
Simon Glass
a32b0df1f7 test: vbe: Free the bootflow after use
The bootflow contains fields which are connected to the struct. It
should be freed when it is finished with.

It isn't exactly clear why this fixes the problem, which shows up as:

   => ut -f bootstd vbe_test_abrec_oem_norun
   Test: bootstd_setup_for_tests: bootstd_common.c
   common/dlmalloc.c:793: do_check_free_chunk:
     Assertion `next->prev_size == sz' failed.

Fix it by adding a bootflow_free() at the end, which is good practice in
any case.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 07f5b96985 ("boot: test: Add a test for the VBE OS flow")
2025-08-17 06:01:25 -06:00
Simon Glass
fdffab6ea9 test: Disable LTO with make qcheck
When LTO is used it seems to miss some line-number information, so the
event_dump.py tool does not fully work, thus causing test_event_dump to
fail.

Disable LTO to prevent this problem. It speeds up the build in any case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-16 16:14:11 -06:00
Simon Glass
a633c1d1d2 Merge branch 'loadn' into 'master'
efi: Support booting an OS with the EFI app on ARM

See merge request u-boot/u-boot!151
2025-08-14 19:09:00 +00:00
Simon Glass
67526ce699 CI: Provide a QEMU instance for efi-arm_app64
Add a new board which can run the EFI app and boot an OS.

Series-to: concept
Series-cc: heinrich
Series-version: 2
Cover-letter:
efi: Support booting an OS with the EFI app on ARM
The ARM EFI app does not successfully boot an OS at present. This series
includes patches to allow it to boot an OS via extlinux:

The main changes are:

- Call exit-boot-services before jumping to the OS
- Write the physical-memory info to the FDT
- Tidy up some Kconfig options
- Improve keyboard compatibility

Note that QEMU 8.2 does not boot Ubuntu 24.04 with this series[1]. The
kernel dies quite early with:

ERROR:target/arm/internals.h:767:regime_is_user: code should not be reached
Bail out! ERROR:target/arm/internals.h:767:regime_is_user: code should not be reached

QEMU 9.2 resolves this problem.

[1] https://lists.opensuse.org/archives/list/bugs@lists.opensuse.org/
    message/XVO4M4LDEFOORP5M4ZFINZDX36DWO3G5/
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:26 -06:00
Simon Glass
c1e0847bc6 test: Provide a test for the ARM EFI app booting Ubuntu
Build the app and use it to boot Ubuntu 2025.04 so that we can ensure
this continues to work.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
c999c238be efi: arm: Increase the cyclic timeout
The video sync sometimes takes 8ms on this board when running under
emulation, so increase the limit to 15ms.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
5cd3f28e09 efi: arm: Add the memory map to the FDT
Before booting using extlinux we must add the memory map to the FDT.
Provide a ft_system_setup() function to handle this.

To determine the memory size, scan the memory map looking for entries
that look like real memory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
af34860c2d efi: arm: Expand app to use 512M of memory
When booting an OS with a large ramdisk, we need enough memory to load
it. Expand the app's memory to 512M to allow this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
ed46c28b48 efi: Update the ARM app to boot from extlinux
When extlinux is used, the boot partition is often 2, which is ignored.
Use the 'bootflow scan' -p flag to resolve this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
ea30e7c267 efi: boot: Correct calculation of load address in app
The conversion to using an event was not done correctly, with the
result that it has no effect. Fix it, by passing in the length and
actually using the returned address.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 207bf34de7 ("boot: efi: Use an event to relocate the OS")
2025-08-14 07:45:25 -06:00
Simon Glass
4bccd4ea31 efi: Set the FDT address for QEMU
When running under QEMU the FDT is available at the start of RAM. Set
fdt_addr to this address, so that the FDT can be passed onto the OS.

If the OS provides its own devicetree, that is used instead of the QEMU
one.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
10e31d38f8 efi: Exit EFI boot-services before starting the next app
When the app is booting a kernel without using EFI, it must first exit
the boot services provided by EFI. Add a hook for this, using
bootm_final()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
082666ec3e efi: Rename efi_block_device driver
This driver name conflicts with another driver in U-Boot. Rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
cb6bd231b7 efi: Run happily without a video display
It is common to run the EFI app without a display, e.g. for testing.
Drop the unwanted warnings about this:

   EFI graphics output protocol not found (err=-524)
   No video mode configured in EFI!

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
d07934b67e efi: Add a function to obtain the memory type as a string
It is sometimes useful to display the memory type in logs, etc. Add a
function to convert it to a string, which is more user-friendly than a
number.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
02e141912b efi: Move memory-map dumping into a common file
The 'efi mem' command dumps out the memory map. This is useful within
the app, even if commands are not enabled, so move it to a common file.
Rename it from 'print' to 'dump' since most things that dump information
use that word.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
7fb1c0760e efi: Add a few more GUIDs
We can never hope to have a definitive list of GUIDs, but add four more,
discovered when booting from QEMU on ARM.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
41d386529a efi: Use the same format for all EFI_GUID() declarations
The declarations in efi_api.h are inconsistent. Tidy them up, so that
the final 8 bytes appear on their own line aways.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:25 -06:00
Simon Glass
22d39d1c53 efi: Adjust serial to work better on real devices
The EFI serial driver checks for keypresses but does not allow other
events to be processed. For devices which have a USB keyboard, the USB
message must be processed before any keys can emerge for the serial
driver to pick up.

Add a periodic timer to the list of events. This allows the keyboard to
work on Qualcomm laptops, for example.

Series-changes: 2
- Add a comment to serial_efi_get_key() about the 1ms delay

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-14 07:45:06 -06:00
Simon Glass
bd5194356b efi: Move efi_store_memory_map() to the stub
This function is not called from the app at present. Even if it were, it
would be called later, after stdio is working, so there is no need to
use printhex2() and the like.

Move the function into the stub.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-12 13:41:07 -06:00
Simon Glass
c6883b8a71 scripts: Add an option for the build directory
When running in CI it is better to specify the build directory rather
than provide a device. Add a --build-dir option.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-12 13:41:05 -06:00
Simon Glass
c7e33a6646 treewide: Correct paramters typo
This typo appears a handful of times in U-Boot. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 15:01:27 -06:00
Simon Glass
97a083c86c Merge branch 'loadm' into 'master'
boot: Allow lmb-allocation of compression buffer with booti

See merge request u-boot/u-boot!150
2025-08-11 19:48:17 +00:00
Simon Glass
6916ad7d21 boot: Emit an event just before starting the OS
In some cases a board may wish to do some final processing before
starting the OS. An example is the EFI app, which may wish to call
exit-boot-services.

Add an event to permit this.

Series-to: concept
Cover-letter:
boot: Allow lmb-allocation of compression buffer with booti
ARM 'booti' images (as created by Linux 'make Image') typically need to
be compressed. At present the decompression buffer is described by a
pair of environment variables: kernel_comp_addr_r and kernel_comp_size

This is quite inflexible, since the buffer size and location must be
pre-set in the environment, before the OS size is known.

For the EFI app, it is quite difficult to work with a fixed buffer. It
is not in control of the memory map so it may be that the requested
buffer address is not available.

This series updates the boot implementation to allow the variables to
be omitted, with lmb allocations done in this case. This resolves the
problem in the EFI app, with kernels which come from extlinux.conf

When the EFI app loads another app, a similar problem is present, but
with the EFI bootmeth, also resolved in this series.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:06:11 -06:00
Simon Glass
e7d72484f7 boot: Correct a comment in image_setup_libfdt()
Unfortunately no one else has taken up this migration. For now, reword a
a comment to more correctly describe what the event uses.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-11 10:04:39 -06:00