Commit Graph

96700 Commits

Author SHA1 Message Date
Simon Glass
58099a4a5b RFC: efi: Attempt to support automatically running SCT
This is a feeble attempt to update the qemu script to run a selection of
UEFI tests. It copies a .seq file into the disk so it can be read by
SCT.

It doesn't seem to work and I am not sure why. I am posting it in case
someone else has ideas or wants to pic it up.

Once Ilias' CI solution is in place, I can perhaps come back to this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 16:30:05 -07:00
Simon Glass
55b2afb9f5 Merge branch 'ci' into 'master'
efi: Tidy up confusion between pointers and addresses

See merge request u-boot/u-boot!15
2024-12-17 18:37:27 +00:00
Simon Glass
d93fd416c3 efi_loader: Simplify efi_dp_from_mem()
This function should take a pointer, not an address. Update it along
with all users.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:59:09 -07:00
Simon Glass
a92beb14c9 efi_bootmgr: Avoid casts in try_load_from_uri_path()
Update this function to use map_sysmem() so that it can work correctly
on sandbox

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:59:09 -07:00
Simon Glass
ad0c01de70 efi_loader: Drop comments about incorrect addresses
Now that these problems have been resolved, drop the comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:59:09 -07:00
Simon Glass
887013b0ca efi_loader: Correct address-usage in copy_fdt()
Update this function to work correctly with sandbox

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:59:09 -07:00
Simon Glass
448ef82da3 efi_loader: Update to use addresses internally
This collects together several v3 patches into one, to avoid any
temporary test-breakage which would make future bisecting difficult.

For efi_memory, the efi_allocate_pool() call uses a pointer to refer to
memory, but efi_allocate_pages() uses an int. This causes quite a bit of
confusion, since sandbox has a distinction between pointers and
addresses. Adjust efi_allocate/free_pages_ext() to handle the
conversions.

Update efi_add_memory_map() function and its friend to use an address
rather than a pointer cast to an integer.

For lmb, now that efi_add_memory_map_pg() uses a address rather than a
pointer cast to an int, we can simplify the code here.

For efi_reserve_memory(), use addresses rather than pointers, so that it
doesn't have to use mapmem.

In general this simplifies the code, but the main benefit is that casts
are no-longer needed in most places, so the compiler can check that we
are doing the right thing.

For efi_add_runtime_mmio(), now that efi_add_memory_map() takes an
address rather than a pointer, do the mapping in this function.

Update the memset() parameter to be a char while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:59:08 -07:00
Simon Glass
eb0c02d5e3 efi_loader: Don't try to add sandbox runtime code
This cannot work since the code is not present in the emulated memory.
In any case, sandbox cannot make use of the runtime code.

For now, just drop it from sandbox. We can always adjust things to copy
it into memory, if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
1238b0bb80 efi_loader: Show the address for pool allocations
When logging pool allocations, show the address of the pointer, not the
pointer itself. This makes it easier to debug with sandbox

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
183027892e efi_loader: Use correct type in efi_add_runtime_mmio()
This function is passed the address of a void * so update the argument
to match. It is better to have casts in the caller than introduce
confusion as to what is passed in.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
192f48da42 efi_loader: Rename physical_start to base
The word 'physical' suggests that there is an associated virtual address
but there is not. Use 'base' since this is the base address of a region.

Change some uint64_t and remove some brackets to keep checkpatch happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
58c6e4d0b3 efi_loader: Rename struct efi_mem_list to mem_node
This struct is really a node in the list, not a list itself. Also it
doesn't need an efi_ prefix. Rename it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
764b9ae523 efi_loader: Move struct efi_mem_list fields together
We don't need a separate struct for the values in this node. Move
everything in together, so that there is just one struct to consider.

Add a comment about physical_start, so it is clear that it is really
a pointer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
f6f2ccdf34 efi_loader: Avoid assigning desc in efi_mem_carve_out()
Rather than assigning desc and then changing two fields, assign all four
fields, for clarity.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
a298d539ba efi_loader: Use the enum for the memory type in priv_mem_desc
We can make use of the enum now, since this struct is not exported to
the EFI app.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
deec2674ea efi_loader: Drop reserved from priv_mem_desc
This field is not used. Drop it and set the value to 0 when the
memory-map is requested.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
6f771f86aa efi_loader: Drop virtual_start from priv_mem_desc
This field is always the same as physical_start, so keeping track of it
separately is unnecessary and confusing. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
d25caaca61 efi_loader: Use a separate struct for memory nodes
At present efi_memory uses struct efi_mem_desc for each node of its
memory list. This is convenient but is not ideal, since:

- it means that the fields are under a 'desc' sub-structure
- it includes an unused 'reserved' field
- it includes virtual_start which is confusing as it is always the same
  as physical_start
- we must use u64 to store pointers, since that is how they are returned
  by calls to efi_get_memory_map()

As a first step to tidying this up, create a new, private struct to hold
these fields.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
1afecc2db1 doc: efi: Add the EFI-loader API documentation
Bring in the documentation from the efi_loader.h header file, so we can
see the API defined there.

Fix efi_alloc() to avoid a warning.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-12-17 10:58:19 -07:00
Simon Glass
ca2203ca86 efi_loader: Move some memory-function comments to header
Exported functions should be documented in the header file, not the
implementation. We tend to make such updates on a piecemeal basis to
avoid a 'flag day'. Move some comments related to memory allocation to
follow the convention.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
d9b45a2d53 efi_loader: Update startimage_exit self-test to check error
Check for an error returned from the decompress() function, just in
case.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-12-17 10:58:19 -07:00
Simon Glass
c636e69159 efi_loader: Show the resulting memory address from an alloc
Update efi_allocate_pool_ext() to log the pointer returned from this
call, which can be helpful when debugging.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
fb2081fc3b efi_loader: Add comments where incorrect addresses are used
Some functions are passing addresses instead of pointers to the
efi_add_memory_map() function. This confusion is understandable since
the function arguments indicate an address.

Make a note of the 8 places where there are problems, which would break
usage in sandbox tests.

Future work will resolve these problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
3f2cb29c8a efi_loader: Fix typos in enum efi_allocate_type
Fix 'indicatged' and 'adress' typos.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-12-17 10:58:19 -07:00
Simon Glass
aa7ec78ed7 efi: Define fields in struct efi_mem_desc
There is quite a bit of confusion in the EFI code as to whether a field
contains an address or a pointer. As a first step towards resolving
this, document the memory-descriptor struct, indicating that it holds
pointers, not addresses.

Dro the same for efi_add_memory_map() as it is widely used, as well as
efi_add_memory_map_pg() which is only used by lmb

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 10:58:19 -07:00
Simon Glass
b456c88526 Merge branch 'ci2' into 'master'
sandbox: efi_loader: Correct use of addresses as pointers

See merge request u-boot/u-boot!11
2024-12-17 14:31:52 +00:00
Tom Rini
9fd0011dfa Merge patch series "CI: Set up for an arm64 runner"
Tom Rini <trini@konsulko.com> says:

Hey all,

This is picking up Simon's v5 of the above-named series and making a few
more changes so that the follow-up series I have leads to arm64 being
supported for almost all jobs. To quote Simon's cover letter:

All gitlab runners are currently amd64 machines. This series attempts to
create a docker image which can also support arm64 so that sandbox tests
can be run on it.

The TARGET_... environment variables for grub could perhaps be adjusted,
using the new variables, but I have not done that for now.

Adding to what Simon said, we now build grub for all architectures as
the reason to install it was to be able to use the binaries in QEMU.
That won't provide us with amd64 binaries on arm64 hosts so we can't use
that shortcut anymore.

Link: https://lore.kernel.org/r/20241127172247.1488685-1-trini@konsulko.com
2024-12-17 06:53:19 -07:00
Simon Glass
f8be0f2f1c CI: Add platform variable
Add a list of possible platforms that can be used by gitlab runners.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-12-17 06:53:19 -07:00
Simon Glass
1c29b715d8 docker: Install toolchains on arm64 host
Refactor the code to support downloading toolchains for arm64 as well as
x86_64

There doesn't seem to be an xtensa toolchain for arm64 at the same
location, so download that only on x86

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-12-17 06:53:19 -07:00
Simon Glass
422b4a8e4f docker: Fix LegacyKeyValueFormat warning with PYTHONPATH
Fix a warning due to the syntax used for PYTHONPATH:

   LegacyKeyValueFormat: "ENV key=value" should be used instead of
      legacy "ENV key value" format (line 304)

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-12-17 06:53:19 -07:00
Simon Glass
c09cd13285 docker: Adjust installed packages slightly
We no longer need to install libc6-i386 so we can drop that. Switch to
installing linux-image-generic as that will be available on all hosts,
to provide the /boot/vmlinu* file that's requires for various tools.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-12-17 06:53:19 -07:00
Simon Glass
9e6d0c3900 docker: Support building for multiple architectures
Add instructions on how to build the file for multiple architectures.
Add a message indicating what is happening.

Update the documentation as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2024-12-17 06:53:19 -07:00
Tom Rini
be9046df51 docker: Use cache mounts for apt
Instead of deleting /var/lib/apt/lists after each relevant RUN line, use
a cache mount as is the current best practices.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-17 06:53:19 -07:00
Tom Rini
3d0daa37c5 docker: Build grub for all architectures
For consistency now, and future ease of testing with non-amd64 hosts,
build grub for all architectures rather than relying on host binaries
for i386/x86_64.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-17 06:53:19 -07:00
Tom Rini
21be1f619f docker: Update to grub-2.12
The current release of grub is 2.12 and it will be good to pick this up
now so that we can update other parts of our stack.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-17 06:53:19 -07:00
Tom Rini
c9c854638b docker: Use "make -j$(nproc)" when invoking make
We had a few places that were not using "make -j$(nproc)" but instead
just plain "make" and so slowing down the overall build.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-17 06:53:19 -07:00
Tom Rini
edf2a2f85c docker: Add kernel.org x86_64 toolchain
Add in the x86_64 toolchain, but do not enforce using it for sandbox.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-17 06:53:19 -07:00
Simon Glass
0b9b5fde55 test: Adjust print_ut test to use unsigned char
Since char is unsigned on arm64, this test currently fails. It seems
better to use unsigned anyway, since 0xff is written into the string at
the start. Update the terminator-assert to use a character instead of a
byte.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Changes in v6:
- Re-introduce

Changes in v2:
- Use '\0' instead of 0

 test/print_ut.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
2024-12-17 06:53:19 -07:00
Simon Glass
2ea15e57a0 sandbox: efi_loader: Correct use of addresses as pointers
The cache-flush function is incorrect which causes a crash in the
remoteproc tests with arm64.

Fix both problems by using map_sysmem() to convert an address to a
pointer and map_to_sysmem() to convert a pointer to an address.

Also update the image-loader's cache-flushing logic.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 3286d223fd ("sandbox: implement invalidate_icache_all()")
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Changes in v6:
- Re-introduce

Changes in v2:
- Drop message about EFI_LOADER

 arch/sandbox/cpu/cache.c              |  8 +++++++-
 drivers/remoteproc/rproc-elf-loader.c | 18 +++++++++++-------
 lib/efi_loader/efi_image_loader.c     |  3 ++-
 3 files changed, 20 insertions(+), 9 deletions(-)
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2024-12-17 06:53:19 -07:00
Simon Glass
cd63c1697e Merge branch 'ci' into 'master'
fdtdec: Correct devicetree symbol for EFI app

See merge request u-boot/u-boot!13
2024-12-17 13:18:18 +00:00
Simon Glass
27a5f244ce efi: Switch over to OF_SEPARATE for the app
Now that we can support a separate devicetree, enable this for the
EFI-app builds.

Drop the Makefile-warning exception since we don't need it anymore.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 05:34:41 -07:00
Simon Glass
c4b3bc4593 efi: Support an embedded DTB for the 32-bit app
While this is not likely to be used these days, it seems best to keep it
in sync with the 64-bit app. Update the linker script to support a
separate devicetree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-12-17 05:34:41 -07:00
Simon Glass
e6eed34cc7 efi: Correct logic for OF_EMBED and OF_SEPARATE co-existing
While we do plan to switch to OF_SEPARATE now it is supported, it seems
worth at least showing how OF_EMBED could be used instead, just for the
record.

So make the Makefile rule conditional on OF_SEPARATE and adjust fdtdec
to avoid a build error when OF_EMBED is used.

Finally. the dtb symbol has a double underscore, so update it to avoid a
build warning.

With future patches, OF_EMBED will no-longer be used with the EFI app,
so it is expected that it will eventually stop working.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 2e7bf25f6b ("Support separate DTB files with the UEFI app")
2024-12-17 05:34:41 -07:00
Simon Glass
dbc41e68b7 Merge branch 'labb' into 'master'
test/py: Always use the current dir as the source tree

See merge request u-boot/u-boot!14
2024-12-11 13:20:20 +00:00
Simon Glass
bcfc8e8d38 test/py: Always use the current dir as the source tree
The logic in get_details() retrieves the default source directory from
the Labgrid settings. This is convenient for interactive use, since it
allows pytests to be run from any directory and still find the source
tree.

However, it is not actually correct.

Gitlab sets the current directory to the source tree and expects that to
be used. At present it is ignored. The result is that Gitlab builds
whatever happens to be in the default source directory, ignoring the
tree it is supposed to be building.

Fix this by using the directory of the source tree, always. This is
obtained by looking at the grandparent of the conftest.py file.

Series-to: u-boot
Series-cc: trini

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
Fixes: bf89a8f1fc ("test: Introduce the concept of a role")
2024-12-11 06:18:31 -07:00
Simon Glass
f605eae75f Merge branch 'ci' into 'master'
Add EFI handover support to bootm

See merge request u-boot/u-boot!10
2024-12-08 15:28:01 +00:00
Matthew Garrett
652a64a686 Add command to set an environment variable to an EFI variable
We may want to make things conditional on EFI variable state

Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-08 07:44:33 -07:00
Janis Danisevskis
de05434022 Fix efi_bind_block.
efi_bind_block had two issues.
1. A pointer to a the stack was inserted as plat structure and thus used
beyond its life time.
2. Only the first segment of the device path was copied into the
platfom data structure resulting in an unterminated device path.

Signed-off-by: Janis Danisevskis <jdanisevskis@aurora.tech>
Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-08 07:44:33 -07:00
Matthew Garrett
cad355ebe0 Use the correct ramdisk address
CONFIG_SYS_BOOT_RAMDISK_HIGH copies the initrd out of the FIT and into
correctly aligned RAM, but the addresses used for this are then discarded
by the x86 bootm code. Fix that.

Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-08 07:44:33 -07:00
Matthew Garrett
2e7bf25f6b Support separate DTB files with the UEFI app
The UEFI app is an actual executable with things like section headers,
so just gluing the DTB onto the end of it won't work. Add an additional
section to contain this and allocate some space, and then during build
copy the DTB into that section.

Signed-off-by: Matthew Garrett <mgarrett@aurora.tech>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-08 07:44:33 -07:00