lmb_alloc_base() is just calling lmb_alloc_base_flags() with LMB_NONE.
There's not much we gain from this abstraction, so let's remove the
former add the flags argument to lmb_alloc_base() and make the code
a bit easier to follow.
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 3075708017)
lmb_reserve() is just calling lmb_reserve_flags() with LMB_NONE.
There's not much we gain from this abstraction.
So let's remove the latter, add the flags argument to lmb_reserve()
and make the code a bit easier to follow.
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 900a8951c3)
LMB flags is not an enum anymore. It's currently used as a bitmask
in various places of our code. So make it a u32 which is more
appropriate when dealing with masks.
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 3d56c06551)
This patch was written before the XPL change-over. Update the Makefile
condition to the new way.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: ae3b5928d6 ("x86: coreboot: Allow building an expo for...")
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
(cherry picked from commit 315fd02729)
The boot_fdt_add_mem_rsv_regions() function can be called twice, e.g.
first time during the board init (as a part of LMB init), and then when
booting the OS with 'booti' command:
lmb_add_region_flags
lmb_reserve_flags
boot_fdt_reserve_region
boot_fdt_add_mem_rsv_regions
^
|
+-----------------------+
| (1) | (2)
lmb_reserve_common image_setup_linux
lmb_init ...
initr_lmb do_booti
board_init_r 'booti'
That consequently leads to the attempt of reserving the same memory
areas (described in the 'reserved-memory' dts node) in LMB. The
lmb_add_region_flags() returns -EEXIST error code in such cases, but
boot_fdt_reserve_region() handles all negative error codes as a failure
to reserve fdt memory region, printing corresponding error messages,
which are essentially harmless, but misleading. For example, this is the
output of 'booti' command on E850-96 board:
=> booti $loadaddr - $fdtaddr
...
ERROR: reserving fdt memory region failed
(addr=bab00000 size=5500000 flags=2)
ERROR: reserving fdt memory region failed
(addr=f0000000 size=200000 flags=4)
...
Starting kernel ...
The mentioned false positive error messages are observed starting with
commit 1d9aa4a283 ("lmb: Fix the allocation of overlapping memory
areas with !LMB_NONE"), which removes the check for the already added
memory regions in lmb_add_region_flags(), making it return -1 for
!LMB_NONE cases. Another commit 827dee587b ("fdt: lmb: add reserved
regions as no-overwrite") changes flags used for reserving memory in
boot_fdt_add_mem_rsv_regions() from LMB_NONE to LMB_NOOVERWRITE. So
together with the patch mentioned earlier, it makes
lmb_add_region_flags() return -1 when called from
boot_fdt_reserve_region().
Since then, the different patch was implemented, returning -EEXIST error
code in described cases, which is:
lmb: Return -EEXIST in lmb_add_region_flags() if region already added
Handle -EEXIST error code as a normal (successful) case in
lmb_reserve_flags() and don't print any messages.
Fixes: 1d9aa4a283 ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
(cherry picked from commit 5a6aa7d591)
Switch away from a pre-derived key so that LUKS2 partitions can be
unlocked. Update the ulock message to be more generic.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The unlock process is quite different with a TKey, since we need to load
the signing app with the user's passphrase as the USS. If the TKey is
not already in firmware mode we must prompt the user to remove and
re-insert it.
The easiest way to implement this is via a state machine. Add the
required logic:
- detect key presence and absence
- prompt for removal and insertion
- send the app, while keeping the UI responsive
- unlock the disk once the TKey provides a key
- report success or failure to the user
Ensure that the logic is only used if CONFIG_TKEY and CONFIG_LUKS are
both enabled.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Tidy up the code style for checking the result of read_images() and drop
some commented-out debug lines.
Also fix a shadowed variable while we are here.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Selecting an OS may cause the UI to change, so give it a chance to show
those changes before booting.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
When unlocking an encrypted disk with a TKey we need a few more UI
operations:
- allow the password-entry textline to be shown/hidden
- allow showing instructions to the user, as well as unlock result
- obtain the password entered by the user
Add these to the API and implement them in the multi UI.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Set up a textline object to allow the user to enter a passphrase and a
text object to display messages for the user.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The bootctl tests are currently disabled due to some image
incompatibilities: the multi UI uses one image and the simple UI uses a
different one.
Update the logic to switch between these logos when the layout changes.
For now, use the U-Boot logo in both cases.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The SCENEOF_PASSWORD flag is set on the textline object, but the
rendering code checks the flag on the text object being rendered. Set
the flag on the edit text object so the passphrase renders as asterisks
instead of showing the actual characters.
Mark the textline object as hidden while we are here, so it disappears
when switching to the simple bootmenu.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Since scene_calc_dims() is done by scene_arrange(), we don't need to do
an explicit call to scene_calc_dims() first. Drop it from both UIs.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
When the user types in an unlock password then presses 'enter', select
the item containing the password. This avoids needing to click on an
item as well.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move textline key handling outside the loop so keys are always sent
to the highlighted textline, regardless of whether it is open. This
allows the textline to respond to keyboard input even if not in a popup
expo.
Otherwise continue to send keys to menus as now.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
When a textline is open, we must render the edit string and show the
cursor. The easiest way to do this is to draw the string again, then
move the cursor back to the correct place.
There is no need to change the font, since the rendering function
handles this.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a function to render a single object by its ID. This provides a
convenient way to render individual objects without needing to look up
the object pointer first.
Assume that text mode is not used.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The highlight_id needs to be considered for non-popup expos as well. As
a first step, use the variable 'cur' for the current object, i.e. the
one that is highlighted.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The edit text object for the passphrase textline is created with an
empty string literal "", rather than pointing to the textline's buffer.
This means that when the user types, tline->buf is updated but the text
object still displays the original empty string.
Fix this by creating the edit text object with abuf_data(&tline->buf) so
it points to the textline's buffer. This matches how expo_build.c
creates textlines for cedit.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Use descriptive names like "item0.label", "item0.desc", "item0.pass"
instead of generic "label", "desc", "passphrase". This makes debugging
easier when multiple bootflow items exist.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Use the parent object name as a prefix for child objects, so they
have descriptive names like "cpu-speed.title" instead of generic
"title". This makes debugging easier when multiple objects exist.
Update add_txt_str() and add_txt_str_list() to take separate
property name and object name parameters.
Also set the scene's prompt_id when building from devicetree.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a prompt_id field to struct scene to track the prompt text object.
Update cedit_arange() to use title_id and prompt_id directly instead
of looking up objects by name, which is more robust.
Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Change expo_dump() to output object IDs in hex format. This matches the
normal convention in U-Boot.
Also add key_id and preview_id to the menu item dump output while we are
here.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add string.h to files that use string functions like strdup, strcmp,
strcpy, etc. These are implicitly available through the malloc.h header
but that will soon change.
For bouncebuf, take this opportunity to sort the headers correctly.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Replace fdt_next_node() with depth tracking with fdt_for_each_subnode()
which has been available for some time.
This also fixes a latent bug where the default configuration was being
read from the wrong node offset. It happened to work before because
noffset ended up at the right value after the images loop.
Series-to: concept
Series-cc: heinrich
Cover-letter:
fit: Improve and test the code to print FIT info
The code for printing information about FITs is fairly old and not that
easy to maintain. It also lacks tests.
This series adds some tests, moves the code into its own file and then
adds a series of helpers to deal with the intricacies of printing each
item.
This provides a binary-size reduction of about 320 bytes on aarch64.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The pattern for iterating through and processing hash/signature subnodes
is repeated in two places. Add a new process_subnodes() helper to reduce
code duplication.
Drop the now-unused ndepth and noffset local variables.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a boolean variable 'loadable' that combines the common type check
for kernel, standalone, and ramdisk images.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add emit_addr() to handle printing load an entry addresses.
The helper takes a 'valid' boolean parameter to determine whether to
print the address value or 'unavailable'.
Combine the two separate if() blocks for the load address.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add emit_desc() which handles getting and printing descriptions from FIT
nodes. Handle the "unavailable" case when a description is missing.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a emit_stringlist() helper function to simplify printing stringlist
properties in FIT configurations.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a new emit_timestamp() helper function to handle printing timestamps
in FITs.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a new emit_prop() helper function to simplify printing optional
properties in FIT configurations.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Refactor the printing of multi-line properties to use the
emit_label_val() helper function instead of custom formatting.
Update emit_label() to deal with an empty label and not show a colon in
that case.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Line up the values witht the FIT Description and Created items at the
top. This looks a little nicer.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Change the indent field in fit_print_ctx from a string pointer to an int
number of spaces to indent.
Set the initial indent value to 3 to match IMAGE_INDENT_STRING
Drop indentation from the debug() calls since these are not visible to
users.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a new emit_label_val() helper function that combines emit_label()
and printf() for simple label-value pairs.
Make use of it where appropriate.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update fit_conf_print() to use the emit_label() helper function for
printing labels.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Update fit_image_print() to use the emit_label() helper function for
printing labels. This avoids various manual printf() calls and spacing
logic.
Set ctx->tab to 19 to align values at the correct column position.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The current code is quite fiddly with manually spaced labels. Add helper
functions for printing labels (with or without a type prefix) with a
cofigurable tab width for the value that folows.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Move the indent string into struct fit_print_ctx so it is available to
the printing functions. This avoids having to pass it as a separate
parameter.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Create a struct fit_print_ctx to hold the FIT pointer and pass it to all
printing functions instead of passing the FIT pointer directly. This
provides a foundation for adding additional context in the future.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
This is actually not defined by the spec. The 'required' property is for
use by the verifying code. Having it in the FIT does not help size an
attacker could potentially remove it.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
There is enough code here that it makes sense to put it in its own file.
Create a new fit_print.c file, before undertaking future refactoring.
Printing is only included in the main build if CONFIG_FIT_PRINT is
enabled, although it is always included in the tools build.
Add static inlines for existing callers.
Make a few small code-style adjustments, including fixing checkpatch
warnings about over-use of brackets.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>