Commit graph

3256 commits

Author SHA1 Message Date
Tom Rini
3a7a17dbdc Pull request efi-2023-10-rc1
Documentation:
 
 * enhance UEFI anti-rollback documentation
 
 EFI:
 
 * Reconnect drivers if UninstallProtocol fails
 * Prefer short device paths for boot options
 * Fix error handling when updating boot options for block devices
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAmSyctkACgkQxIHbvCwF
 GsQowA//X8yryuuYnXu1z2/L9GWeIi/467M4xulThHgODq7NaUAZw+hOa/roQ8ND
 HbVzdkU/ZROmYlC/+nAPPCIPodYryvjrLtPflBIxQy1hf4NlVCJGFTqZM+uJGe9b
 kjXuKAd7oAUIbwsDEBF7tBg/lAKn7xhRUbajnd8LGganSWSmYC/kE5ZjPz68Upg+
 K3Smw4BwOI2bdTqJsq2XTMx97k4QDKx8qeAoTkYbHTco/eDTAmMIqKSnl3/rP1lg
 5m1SDAlkxqEvpuyTifaPrQx7chf2b0v5z0iF6yaqDCYb/07GdZLPm3lG3w4stLce
 c0BWS0uCPTW6bvX93QF8hm7ImiEdwzQNMpNl2x+8Zx6RoU0yx/gh4VdtLTTbY7tX
 904m4Tn5Ez6Mtb6/fcAAiVakzTiuf8Zogr7lkDV0jf5UghBrPCM3xqwAwyD5luCX
 huImX6QKzlmiUSM/qzr7i6+PWYp1tMgYwvzwDy9BH1zW9C910HJstiKnvaATdstw
 w3P63x7ryH8hnGV8YjeWs3GBCHHb/8WI5G88dZYjChya0Q1DPsSCA0QzBd+XRhVB
 mb6lGj6pvpmp9UqLP6EQxQpK5jGyIBk5NMs1w2wij0oT6kPeLwcOIQ0uyeKPR2bP
 S4jBa6Qx28uQpcF1R9m8Azs3QJYdeyCAIou2Qz4ndhERCpKKNIc=
 =+qF4
 -----END PGP SIGNATURE-----

Merge tag 'efi-2023-10-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request efi-2023-10-rc1

Documentation:

* enhance UEFI anti-rollback documentation

EFI:

* Reconnect drivers if UninstallProtocol fails
* Prefer short device paths for boot options
* Fix error handling when updating boot options for block devices
2023-07-15 11:19:11 -04:00
Ilias Apalodimas
d9df8a5f37 efi_selftests: add extra testcases on controller handling
We recently fixed a few issues wrt to controller handling.  Add a few
test cases to cover the new code.
- return EFI_DEVICE_ERROR the first time the protocol interface of
  the controller is uninstalled, after all the children have been
  disconnected.  This should make the drivers reconnect
- add tests to verify controllers are reconnected when uninstalling a
  protocol fails
- add tests to make sure EFI_NOT_FOUND is returned if a non existent
  interface is being removed

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15 11:20:41 +02:00
Ilias Apalodimas
748cb553ff efi_loader: fix the return codes of UninstallProtocol
Up to now we did not check the return value of DisconnectController.
A previous patch is fixing that taking into account what happened during
the controller disconnect.  But that check takes place before our code
is trying to figure out if the interface exists to begin with.  In case a
driver is not allowed to unbind -- e.g returning EFI_DEVICE_ERROR, we
will end up returning that error instead of EFI_NOT_FOUND.

Add an extra check on the top of the function to make sure the protocol
interface exists before trying to disconnect any drivers

Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15 11:20:41 +02:00
Ilias Apalodimas
747d16d93c efi_loader: check the status of disconnected drivers
efi_uninstall_protocol() calls efi_disconnect_all_drivers() but never
checks the return value.  Instead it tries to identify protocols that
are still open after closing the ones that were opened with
EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL, EFI_OPEN_PROTOCOL_GET_PROTOCOL
and EFI_OPEN_PROTOCOL_TEST_PROTOCOL.

Instead of doing that,  check the return value early and exit if
disconnecting the drivers failed.  Also reconnect all the drivers of
a handle if protocols are still found on the handle after disconnecting
controllers and closing the remaining protocols.

While at it fix a memory leak and properly free the opened protocol
information when closing a protocol.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-07-15 11:20:41 +02:00
Ilias Apalodimas
239d59a65e efi_loader: reconnect drivers on failure
efi_disconnect_controller() doesn't reconnect drivers in case of
failure.  Reconnect the disconnected drivers properly

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2023-07-15 11:20:41 +02:00
Raymond Mao
7aa022c797 Load option with short device path for boot vars
The boot variables automatically generated for removable medias
should be with short form of device path without device nodes.
This is a requirement for the case that a removable media is
plugged into a different port but is still able to work with the
existing boot variables.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15 11:20:41 +02:00
Raymond Mao
9945bc4f86 Fix incorrect return code of boot option update
Correct the return code for out-of-memory and no boot option found

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15 11:20:41 +02:00
Raymond Mao
339b527bd4 Move bootorder and bootoption apis to lib
Rename and move bootorder and bootoption apis from cmd to lib
for re-use between eficonfig and bootmgr
Fix 'unexpected indentation' when 'make htmldocs' after functions
are moved

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-07-15 11:20:41 +02:00
Christophe Leroy
ad47974707 lzma: Fix decompression speed regression
Uncompressing a 1.7Mbytes FIT image on U-boot 2023.04 takes
approx 7s on a powerpc 8xx.
The same on U-boot 2023.07-rc6 takes approx 28s unless watchdog
is disabled.

During that decompression, LzmaDec_DecodeReal() calls schedule
1.6 million times, that is every 4µs in average.

In the past it used to be a call to WATCHDOG_RESET() which was
just calling hw_watchdog_reset().

But the combination of commit 29caf9305b ("cyclic: Use schedule()
instead of WATCHDOG_RESET()") and commit 26e8ebcd7c ("watchdog:
mpc8xxx: Make it generic") results in an heavier processing.

However, there is absolutely no point in calling schedule() that
often.

By moving and keeping only one call to schedule() in the main
loop the number of calls is reduced to 1.2 million which is still
too much. So add logic to only call schedule every 1024 times.
That leads to a call to schedule approx every 6ms which is still
far enough to entertain the watchdog which has a 1s timeout on
powerpc 8xx.

powerpc 8xx being one of the slowest targets we have today in
U-boot, and most other watchdogs having a timeout of one minutes
instead of one second like the 8xx, this fix should not have
negative impact on other targets.

Fixes: 29caf9305b ("cyclic: Use schedule() instead of WATCHDOG_RESET()")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-14 15:21:08 -04:00
Oleksandr Suvorov
ef402577c2 lib/zlib: Fix a bug when getting a gzip header extra field
This fixes CVE-2022-37434 [1] and bases on 2 commits from Mark
Adler's zlib master repo - the original fix of CVE bug [2] and
the fix for the fix [3].

[1]
https://github.com/advisories/GHSA-cfmr-vrgj-vqwv
[2]
eff308af42
[3]
1eb7682f84

Fixes: e89516f031 ("zlib: split up to match original source tree")
Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov@foundries.io>
2023-07-14 15:21:08 -04:00
Simon Glass
a8f2ac2ae6 fdt: Allow more general use of livetree
At present livetree can only be used for the control FDT. It is useful
to be able to use the ofnode API for other FDTs, e.g. those used by
the upcoming configuration editor.

We already have most of the support present, and tests can be marked with
the UT_TESTF_OTHER_FDT flag to use another FDT as a special case. But
with this change, the functionality becomes more generally available.

Plumb in the require support.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-14 12:54:51 -04:00
Simon Glass
9cf39bbe96 fdt: Align the start of the livetree
Ensure that the block of memory used by live tree is aligned according to
the default for structures. This ensures that the root node appears at
the start of the block, so it can be used with free(), rather than being
4 bytes later in some cases.

This corrects a rather obscure bug in unflatten_device_tree().

Fixes: 8b50d526ea ("dm: Add a function to create a 'live' device tree")

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-14 12:54:51 -04:00
Tom Rini
8e21064cb3 Pull request efi-2023-07-rc7
Documentation:
 
 * Fix links to Linux kernel documentation
 
 UEFI:
 
 * Fix memory leak in efidebug dh subcommand
 * Fix underflow when calculating remaining variable store size
 * Increase default variable store size to 64 KiB
 * mkeficapsule: fix efi_firmware_management_capsule_header data type
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAmSqfx0ACgkQxIHbvCwF
 GsRFeA/+O4zGJ5HnHpJtGjmJzvEzQZFv65pr8y4I72wO9wwY8RhWeBnup39j5Tlm
 hMDLPptqoDw/3eFaDEhxW8Rbi6Pz3hizSg7RP/HNzj5Efrl8sFij2aDwKyTQr7jx
 yjJNuiQZHitWg9iOSHNDzVB79pT+abMNZmvk9ASRcDDtSuiwsy7MZGBxynmBRAJX
 UP8RKa0tmC6/d5DlLRvZtCtnQ5YI4IDMWoZsgIedt1SkIVVj9lZcanHWMOD6Lcrw
 PgLZZdy/cwbK8vl6sIqsJBVpSuZSbhL3yA5ZEAFWmIQWuogcbbaH8PMeYvoHlJPP
 f8mlCTnoF9vCc2LOFUog84KlwGrtQc+qSZMfOP+hBGBgpxf1MmPA7fhhRB6+lfrJ
 27TJUNf0+wnpeuDGtQ+qr6/PXP9fFgopvWMR/G/2XWjZK2xkqsVYK+BH55/V93By
 oZrRBlrBSre5uFZHcWYGAYP5Drddif7Ex++gUJhucbb9Bp6uqGVm2r/k3gscX4kk
 HkbCl9IwRasZCBOK+xCZulJ/OVF5bzV+8zQHtMo6cN8ilz830WyLAmiaFQxROXxN
 f6eXeYTSKQikKiZegFD4+/yG5XgxAezO9YkhJZwd082JcSFuF3RdwrHzk4mKxhRC
 9IVBt855sI4HxAE3V5JlbGgufxCro4wNU7Z6abrcNGI73UxqOSA=
 =p8s8
 -----END PGP SIGNATURE-----

Merge tag 'efi-2023-07-rc7' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request efi-2023-07-rc7

Documentation:

* Fix links to Linux kernel documentation

UEFI:

* Fix memory leak in efidebug dh subcommand
* Fix underflow when calculating remaining variable store size
* Increase default variable store size to 64 KiB
* mkeficapsule: fix efi_firmware_management_capsule_header data type
2023-07-11 13:27:32 -04:00
Alper Nebi Yasak
9fd3f881c6 efi_loader: Increase default variable store size to 64KiB
Debian's arm64 UEFI Secure Boot shim makes the EFI variable store run
out of space while mirroring its MOK database to variables. This can be
observed in QEMU like so:

  $ tools/buildman/buildman -o build/qemu_arm64 --boards=qemu_arm64 -w
  $ cd build/qemu_arm64
  $ curl -L -o debian.iso \
      https://cdimage.debian.org/debian-cd/current/arm64/iso-cd/debian-12.0.0-arm64-netinst.iso
  $ qemu-system-aarch64 \
      -nographic -bios u-boot.bin \
      -machine virt -cpu cortex-a53 -m 1G -smp 2 \
      -drive if=virtio,file=debian.iso,index=0,format=raw,readonly=on,media=cdrom
  [...]
  => # interrupt autoboot
  => env set -e -bs -nv -rt -guid 605dab50-e046-4300-abb6-3dd810dd8b23 SHIM_VERBOSE 1
  => boot
  [...]
  mok.c:296:mirror_one_esl() SetVariable("MokListXRT43", ... varsz=0x4C) = Out of Resources
  mok.c:452:mirror_mok_db() esd:0x7DB92D20 adj:0x30
  Failed to set MokListXRT: Out of Resources
  mok.c:767:mirror_one_mok_variable() mirror_mok_db("MokListXRT",  datasz=17328) returned Out of Resources
  mok.c:812:mirror_one_mok_variable() returning Out of Resources
  Could not create MokListXRT: Out of Resources
  [...]
  Welcome to GRUB!

This would normally be fine as shim would continue to run grubaa64.efi,
but shim's error handling code for this case has a bug [1] that causes a
synchronous abort on at least chromebook_kevin (but apparently not on
QEMU arm64).

Double the default variable store size so the variables fit. There is a
note about this value matching PcdFlashNvStorageVariableSize when
EFI_MM_COMM_TEE is enabled, so keep the old default in that case.

[1] https://github.com/rhboot/shim/pull/577

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-09 03:53:08 +02:00
Alper Nebi Yasak
d7fe913f23 efi_loader: Avoid underflow when calculating remaining var store size
The efi_var_mem_free() function calculates the available size for a new
EFI variable by subtracting the occupied buffer size and the overhead
for a new variable from the maximum buffer size set in Kconfig. This
is then returned as QueryVariableInfo()'s RemainingVariableStorageSize
output.

This can underflow as the calculation is done in and processed as
unsigned integer types. Check for underflow before doing the subtraction
and return zero if there's no space.

Fixes: f1f990a8c9 ("efi_loader: memory buffer for variables")
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-07-09 03:53:08 +02:00
Tom Rini
e80f4079b3 Prepare v2023.07-rc6
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmSjExsACgkQFHw5/5Y0
 tywJ3gwAsTbr9mCmCzaKs2F/Jh6H47WEUMEz96wE8eXwuS57pfNJhml4v2rEhYpQ
 MlBjz6vTOyHDrtinRlvempJWVZEuoflMb6M2OTqVFqZPuPT3cLLuSdM4pgb5SdKS
 jNDWcxr12LqiDS0Mz+QOHdps3H8mzsCnOXeOTT+VaSeYHPOLQ+M9OV2o/aY2BsNi
 JLAGX+8i7FuZnVYZzSv6PQYYGZZV+Kvl5oLlPPJttsA7bGu4m2k8zRQQdzd+PIbu
 owAh3CHSKCy1g+y7ASn1Nd2VE06huvqGG7Qo2sj+Ypf/wbNy16qbMc2C7HDwDcul
 nrnf6BZ+MTelwxyPHBOR52ERgY6H8rgpvsCNL0arxaCHJOVddXtrUY1591vE71aB
 nGxhnyLnHwOXXdDGsPsR7p4SF16e6RzaINKmDorQ37nidRnTFLlFCxidnR8ztscR
 aUpLraqYUquGJf7lejYX2OZg2f36lvpYKy1lwuJfd9fUSgK8iyUKrE9wOJhWnTK8
 cIOnS/A+
 =DNor
 -----END PGP SIGNATURE-----

Merge tag 'v2023.07-rc6' into next

Prepare v2023.07-rc6
2023-07-05 11:28:55 -04:00
Stefano Babic
50195a2346 mkimage: ecdsa: password for signing from environment
Use a variable (MKIMAGE_SIGN_PASSWORD) like already done for RSA to
allow the signing process to run in batch.

Signed-off-by: Stefano Babic <sbabic@denx.de>
2023-06-20 16:08:13 -04:00
Ilias Apalodimas
5669591dd8 efi_selftests: fix protocol repeated selftesting
Running the protocols  selftest more than one times fails with

=> setenv efi_selftest 'manage protocols' && bootefi selftest
Testing EFI API implementation
Selected test: 'manage protocols'
Setting up 'manage protocols'
Setting up 'manage protocols' succeeded
Executing 'manage protocols'
Executing 'manage protocols' succeeded
Tearing down 'manage protocols'
Tearing down 'manage protocols' succeeded
Summary: 0 failures

=> bootefi selftest
Testing EFI API implementation
Selected test: 'manage protocols'
Setting up 'manage protocols'
lib/efi_selftest/efi_selftest_manageprotocols.c(88):
ERROR: InstallProtocolInterface failed
lib/efi_selftest/efi_selftest.c(89):
ERROR: Setting up 'manage protocols' failed
Tearing down 'manage protocols'
Tearing down 'manage protocols' succeeded
Summary: 1 failures

The reason is that we don't set the handles to NULL after deleting and
freeing them.  As a result the subsequent protocol installation will try
to use an existing handle which we just removed that from our object list.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-16 06:48:46 +02:00
Ilias Apalodimas
3cc2b9f5b9 efi_loader: simplify efi_disk_remove
Instead of discovering the ID of the device and call two different
functions for a block device or a partition, we can rewrite
efi_disk_remove() and handle the minor differences between the two
variants internally.  As a results we can simplify efi_disk_remove()
a lot and get rid of the extra efi_disk_delete_raw/blk calls.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

If a handle is not found, return 0 to let the device be removed.

Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-16 06:45:20 +02:00
Ilias Apalodimas
3ae95fe21c efi_selftests: fix controllers repeated selftesting
Running the controller selftest more than one times fails with

=> setenv efi_selftest 'controllers' && bootefi selftest
Testing EFI API implementation
Selected test: 'controllers'
Setting up 'controllers'
Setting up 'controllers' succeeded
Executing 'controllers'
Executing 'controllers' succeeded
Summary: 0 failures

=> bootefi selftest
Testing EFI API implementation
Selected test: 'controllers'
Setting up 'controllers'
lib/efi_selftest/efi_selftest_controllers.c(280):
ERROR: InstallProtocolInterface failed
lib/efi_selftest/efi_selftest.c(89):
ERROR: Setting up 'controllers' failed
Summary: 1 failures

There are multiple reason for this.  We don't uninstall the binding
interface from the controller handle and we don't reset the handle
pointers either.  So let's uninstall all the protocols properly and
reset the handles to NULL on setup().

While at it add a forgotten check when uninstalling protocols from the
handle_controller and make sure the number of child controllers is 0

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-16 06:45:20 +02:00
Heinrich Schuchardt
a61e6ad769 efi_selftest: ReinstallProtocolInterface test
Test ReinstallProtocolInterface() more rigorously.

Replacing the sole installed protocol interface must not result in deleting
the handle and creating a new one.

Check which interface is actually installed before and after
ReinstallProtocolInterface().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-16 06:45:19 +02:00
Tom Rini
260d4962e0 Merge tag v2023.07-rc4 into next
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-06-12 14:55:33 -04:00
Jassi Brar
a7e45415b2 fwu: provide default fwu_plat_get_bootidx
Just like fwu_plat_get_update_index, provide a default/weak
implementation of fwu_plat_get_bootidx. So that most platforms
wouldn't have to re-implement the likely case.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-06-09 13:52:40 -04:00
Masami Hiramatsu
4898679e19 FWU: Add FWU metadata access driver for MTD storage regions
In the FWU Multi Bank Update feature, the information about the
updatable images is stored as part of the metadata, on a separate
region. Add a driver for reading from and writing to the metadata
when the updatable images and the metadata are stored on a raw
MTD region.
The code is divided into core under drivers/fwu-mdata/ and some helper
functions clubbed together under lib/fwu_updates/

Signed-off-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2023-06-09 13:52:40 -04:00
Jassi Brar
1e917a69e5 fwu: rename fwu_get_verified_mdata to fwu_get_mdata
fwu_get_mdata() sounds more appropriate than fwu_get_verified_mdata()

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-09 13:52:40 -04:00
Jassi Brar
246ec2a12c fwu: meta-data: switch to management by common code
The common code can now read, verify and fix meta-data copies
while exposing one consistent structure to users.
 Only the .read_mdata() and .write_mdata() callbacks of fwu_mdata_ops
are needed. Get rid of .get_mdata() .update_mdata() .get_mdata_part_num()
.read_mdata_partition() and .write_mdata_partition() and also the
corresponding wrapper functions.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-09 13:52:40 -04:00
Jassi Brar
167994f295 fwu: move meta-data management in core
Instead of each i/f having to implement their own meta-data verification
and storage, move the logic in common code. This simplifies the i/f code
much simpler and compact.

Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-06-09 13:49:55 -04:00
Masahisa Kojima
6ab7a6853f efi_loader: check lowest supported version
The FMP Payload Header which EDK II capsule generation scripts
insert has a firmware version.
This commit reads the lowest supported version stored in the
device tree, then check if the firmware version in FMP payload header
of the ongoing capsule is equal or greater than the
lowest supported version. If the firmware version is lower than
lowest supported version, capsule update will not be performed.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2023-06-08 09:20:36 +02:00
Masahisa Kojima
25dc7d5aed efi_loader: get lowest supported version from device tree
This commit gets the lowest supported version from device tree,
then fills the lowest supported version in FMP->GetImageInfo().

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-08 09:20:36 +02:00
Masahisa Kojima
3cba9702d1 efi_loader: versioning support in GetImageInfo
Current FMP->GetImageInfo() always return 0 for the firmware
version, user can not identify which firmware version is currently
running through the EFI interface.

This commit reads the "FmpStateXXXX" EFI variable, then fills the
firmware version in FMP->GetImageInfo().

Now FMP->GetImageInfo() and ESRT have the meaningful version number.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-08 09:20:36 +02:00
Masahisa Kojima
bfaa1fbc62 efi_loader: store firmware version into FmpState variable
Firmware version management is not implemented in the current
FMP protocol.
EDK II reference implementation capsule generation script inserts
the FMP Payload Header right before the payload, FMP Payload Header
contains the firmware version and lowest supported version.

This commit utilizes the FMP Payload Header, reads the header and
stores the firmware version into "FmpStateXXXX" EFI non-volatile variable.
XXXX indicates the image index, since FMP protocol handles multiple
image indexes.
Note that lowest supported version included in the FMP Payload Header
is not used. If the platform uses file-based EFI variable storage,
it can be tampered. The file-based EFI variable storage is not the
right place to store the lowest supported version for anti-rollback
protection.

This change is compatible with the existing FMP implementation.
This change does not mandate the FMP Payload Header.
If no FMP Payload Header is found in the capsule file, fw_version,
lowest supported version, last attempt version and last attempt
status is 0 and this is the same behavior as existing FMP
implementation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2023-06-08 09:20:36 +02:00
Masahisa Kojima
cccea18813 efi_loader: add the number of image entries in efi_capsule_update_info
The number of image array entries global variable is required
to support EFI capsule update. This information is exposed as a
num_image_type_guids variable, but this information
should be included in the efi_capsule_update_info structure.

This commit adds the num_images member in the
efi_capsule_update_info structure. All board files supporting
EFI capsule update are updated.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-08 09:20:36 +02:00
Heinrich Schuchardt
75ebeb4d94 efi_selftest: LocateHandleBuffer return code
Check that LocateHandleBuffer() return EFI_NOT_FOUND when called with
ByRegisterNotify and all handles already have been retrieved.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-06-02 10:59:15 +02:00
Heinrich Schuchardt
1becdfcdc1 efi_loader: check return value of part_get_info()
part_get_info() may return an error code. Check it.
Update function description of dp_part_node().

Addresses-Coverity-ID: 184067 ("Unchecked return value")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-06-02 10:59:15 +02:00
Simon Glass
c52bd0362d efi: Correct .efi rules
These files should have both 'always' and 'targets' so that dependencies
are detected correctly.

When only 'always' is used, the target is built every time, although I am
not quite sure why.

Make sure each has both 'always' and 'targets' to avoid this problem.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-05-31 17:23:01 -04:00
Simon Glass
1e4d965b59 acpi: Put the version numbers in a central place
At present two acpi files are built every time since they use a version
number from version.h

This is not necessary. Make use of the same technique as for the version
string, so that they are build only when they change.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-05-31 17:23:01 -04:00
Heinrich Schuchardt
c7c0ca3767 efi_loader: fix efi_dp_from_file()
* When called from efi_dp_from_name() we miss to append the filename
  for non-block devices.
* expand_media_path() could be simplified by using efi_dp_from_file to
  prepend the device path of the boot device.

This can be avoided by passing a device path to efi_dp_from_file() instead
of a block device descriptor and a partition number.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
e1273ea2ec efi_loader: simplify efi_dp_from_name()
Don't do the same check and assignment in multiple places.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
9f7ed4b469 efi_loader: error code efi_dp_from_name()
Use EFI_OUT_OF_RESOURCES if the device path cannot be constructed.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
5780612891 efi_loader: clean up efi_dp_from_file
* Improve variable name usage: Use pos instead of buf to indicate the
  current position in a buffer.
* Avoid double assignment in a single code line.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
bd646fc3de efi_loader: duplicate code in efi_dp_from_name
efi_dp_from_name() has duplicate code to replace slash by backslash.
path_to_uefi() called by efi_dp_from_file() already does this.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
d76184edc3 efi_loader: avoid #ifdef in efi_dp_from_name()
According to our coding style guide #ifdef should be avoided.
Use IS_ENABLED() instead.

Sort string comparisons alphabetically.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
01c528118d efi_loader: support booting semihosting file
Executing an EFI binary fails for files loaded via semihosting.

Construct a dummy device path for EFI binaries loaded via semihosting.

A future complete solution may include the creation of a handle with a
simple file system protocol.

Reported-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
31eda3f55c efi_loader: print file path w/o boot device
Helloworld.efi should print the file path even if the boot device is
not set.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-05-13 11:09:51 +02:00
Heinrich Schuchardt
227d3b3e0a fwu: fix config FWU_MULTI_BANK_UPDATE
Symbol CONFIG_EFI_SETUP_EARLY does not exist anymore.

CONFIG_FWU_MULTI_BANK_UPDATE without CONFIG_FWU_MDATA results in

    lib/fwu_updates/fwu.c:49: undefined reference to `fwu_get_mdata'

Fixes: 8679405241 ("FWU: Add support for the FWU Multi Bank Update feature")
Fixes: 023d9c9393 ("efi_loader: remove CONFIG_EFI_SETUP_EARLY")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2023-05-13 11:09:51 +02:00
Simon Glass
37bf44073b acpi: Move the table-finding functions into the libary
This is useful for other features. Move the function into library code
so it can be used outside just the 'acpi' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
2023-05-11 10:25:29 +08:00
Simon Glass
0992a90daa acpi: Create a new Kconfig for ACPI
We have several Kconfig options for ACPI, but all relate to specific
functions, such as generating tables and AML code.

Add a new option which controls including basic ACPI library code,
including the lib/acpi directory. This will allow us to add functions
which are available even if table generation is not supported.

Adjust the command to avoid a build error when ACPIGEN is not enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2023-05-11 10:25:29 +08:00
Tom Rini
27dc882644 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
Please pull the second part of the sunxi pull request for this cycle.
Another bunch of patches that replace old-school U-Boot hacks with
proper DM based code, this time for the raw NAND flash driver, and the
USB PHY VBUS detection code. Plus two smaller patches that were sitting
in my inbox for a while.

Gitlab CI passed. In lack of some supported board with NAND flash I
couldn't really test this part, but apparently this was tested by the
reviewer. I briefly ran the branch on some boards with USB-OTG, and
this still worked.
2023-04-30 21:29:50 -04:00
Simon Glass
f43fc16812 fdt: Indicate that people should use the ofnode API
Add a note to the comment at the top of this file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-28 11:52:38 -06:00
Samuel Holland
1eb09081f6 mtd: nand: sunxi: Convert from fdtdec to ofnode
As a first step toward converting this driver to the driver model, use
the ofnode abstraction to replace direct references to the FDT blob.

Using ofnode_read_u32_index removes an extra pair of loops and makes the
allwinner,rb property optional, matching the devicetree binding.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Acked-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2023-04-28 01:06:57 +01:00
Heinrich Schuchardt
4bccbd32fb efi_loader: remove unused efi_capsule_authenticate
Remove an unused implementation of efi_capsule_authenticate().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-21 08:50:35 +02:00
Bin Meng
6fc4fc38ac efi: loader: Make efi_runtime_mmio static
efi_runtime_mmio is only referenced in efi_boottime.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08 07:46:44 +02:00
Bin Meng
207b686421 efi: loader: Make efi_mem static
efi_mem is only referenced in efi_memory.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08 07:46:44 +02:00
Bin Meng
ee23830b6e efi: loader: Make efi_event_queue and efi_register_notify_events static
efi_event_queue and efi_register_notify_events are only referenced
in efi_boottime.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08 07:46:44 +02:00
Bin Meng
8063c55e58 efi: selftest: Make load_file() and load_file2() static
load_file() and load_file2() are only referenced in
efi_selftest_load_file.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08 07:46:44 +02:00
Bin Meng
013f9f89f8 efi: selftest: Make record static
record is only referenced in efi_selftest_exitbootservices.c

Signed-off-by: Bin Meng <bmeng@tinylab.org>
2023-04-08 07:46:44 +02:00
Heinrich Schuchardt
199675b9d5 efi_loader: avoid using HandleProtocol in initrddump.efi
HandleProtocol() is deprecated and leaves an OpenedProtocolInformation
behind. Use OpenProtocol(GET_PROTOCOL) instead.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-04-08 07:45:34 +02:00
Heinrich Schuchardt
ff6ce8da97 efi_loader: avoid using HandleProtocol in helloworld.efi
HandleProtocol() is deprecated and leaves an OpenedProtocolInformation
behind. Use OpenProtocol(GET_PROTOCOL) instead.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-04-08 07:45:34 +02:00
Heinrich Schuchardt
9ee32a7876 lib: missing fallthrough comment in vsnprintf_internal()
When a case statement intentionally falls through we should add a comment.
Cf. -Wimplicit-fallthrough

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-06 19:10:08 -04:00
Patrick Delaunay
c9eb37a1e7 lmb: add max number of region in lmb_dump_region() output
Add the max number of region in lmb dump; this patch allows to
check the limit for usage of the LMB regions, memory or reserved.

Result on STM32MP157C-DK2:

STM32MP> bdinfo
.....
lmb_dump_all:
 memory.cnt = 0x1 / max = 0x2
 memory[0]	[0xc0000000-0xdfffffff], 0x20000000 bytes flags: 0
 reserved.cnt = 0x6 / max = 0x10
 reserved[0]	[0x10000000-0x10045fff], 0x00046000 bytes flags: 4
 reserved[1]	[0x30000000-0x3003ffff], 0x00040000 bytes flags: 4
 reserved[2]	[0x38000000-0x3800ffff], 0x00010000 bytes flags: 4
 reserved[3]	[0xd4000000-0xd7ffffff], 0x04000000 bytes flags: 4
 reserved[4]	[0xdcae5000-0xdfffffff], 0x0351b000 bytes flags: 0
 reserved[5]	[0xddafb5b8-0xdfffffff], 0x02504a48 bytes flags: 0
....

Reported-by: Mark Millard <marklmi@yahoo.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2023-04-06 15:08:46 -04:00
Patrick Delaunay
94c8da2121 lmb: Fix LMB_MEMORY_REGIONS flag usage
Remove test on CONFIG_LMB_MEMORY_REGIONS introduced by commit
7c1860fce4 ("lmb: Fix lmb property's defination under struct lmb").

This code in lmb_init() is strange, because if CONFIG_LMB_USE_MAX_REGIONS
and CONFIG_LMB_MEMORY_REGIONS are not defined, the implicit #else is empty
and the required initialization is not done:
lmb->memory.max = ?
lmb->reserved.max = ?

But this setting is not possible:
- CONFIG_LMB_USE_MAX_REGIONS not defined
- CONFIG_LMB_MEMORY_REGIONS not defined
because CONFIG_LMB_MEMORY_REGIONS and CONFIG_LMB_RESERVED_REGIONS are
defined as soon as the CONFIG_LMB_USE_MAX_REGIONS is not defined.

This patch removes this impossible case #elif and I add some
explanation in lmb.h to explain why in the struct lmb {} the lmb
property is defined if CONFIG_LMB_MEMORY_REGIONS is NOT defined.

This patch also removes CONFIG_LMB_XXX dependency on CONFIG_LMB as these
defines are used in API file lmb.h and not only in library file.

Fixes: 5e2548c1d6 ("lmb: Fix LMB_MEMORY_REGIONS flag usage")
Reported-by: Mark Millard <marklmi@yahoo.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Acked-by: Michal Simek <michal.simek@amd.com>
2023-04-06 15:08:46 -04:00
Tobias Waldekranz
272ec6b453 efi_loader: device_path: support blkmap devices
Create a distinct EFI device path for each blkmap device.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-04-05 10:54:47 -04:00
Tom Rini
288fe30a23 Merge branch 'next'
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-04-03 16:45:41 -04:00
Heinrich Schuchardt
dfd4288173 efi_loader: remove duplicate assignment
Assigning the value of a variable to itself should be avoided.

Addresses-Coverity-ID: 451089 ("Evaluation order violation")
Fixes: 180b7118be ("efi_loader: fix device-path for USB devices")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-01 10:11:50 +02:00
Heinrich Schuchardt
a9203b0fef efi_loader: correct shortening of device-paths
We use short device-paths in boot options so that a file on a block device
can be found independent of the port into which the device is plugged.

Usb() device-path nodes only contain port and interface information and
therefore cannot identify a block device.
UsbWwi() device-path nodes contain the serial number of USB devices.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-04-01 10:11:50 +02:00
Marek Vasut
c61df34009 lib: Fix SYS_TIMER_COUNTS_DOWN description in Kconfig
The SYS_TIMER_COUNTS_DOWN description contains a typo,
s@rathe@&r@ , fix it.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-03-30 15:09:59 -04:00
Tom Rini
605bc145f9 Merge branch 'master' into next 2023-03-27 15:19:57 -04:00
Simon Glass
4e5e49a3c7 efi: Include GUID names with EFI app and payload
These are currently only available when running with EFI_LOADER.
Expand this to include the app and payload, since it is useful to be
able to decode things there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-25 11:07:22 +01:00
Simon Glass
ac93275d79 efi: Add another tranch of GUIDs
Provide information about the GUIDs supplied by QEMU, so far as it is
known.

These values are used in the 'efi table' command as well as the printf
format string %sU

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-25 11:07:22 +01:00
Heinrich Schuchardt
bace47a59d efi_loader: simplify efi_str_to_u16()
Use efi_alloc() to allocate memory.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-25 11:06:35 +01:00
Heinrich Schuchardt
f606fab8da efi_loader: move dp_alloc() to efi_alloc()
The incumbent function efi_alloc() is unused.

Replace dp_alloc() by a new function efi_alloc() that we can use more
widely.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-03-25 11:06:34 +01:00
Heinrich Schuchardt
e472ef8a3d efi_loader: fix device-path for USB devices
EFI device paths for block devices must be unique. If a non-unique device
path is discovered, probing of the block device fails.

Currently we use UsbClass() device path nodes. As multiple devices may
have the same vendor and product id these are non-unique. Instead we
should use Usb() device path nodes. They include the USB port on the
parent hub. Hence they are unique.

A USB storage device may contain multiple logical units. These can be
modeled as Ctrl() nodes.

Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-25 11:05:42 +01:00
Heinrich Schuchardt
c5cc6da855 efi_loader: support for Ctrl() device path node
* Add the definitions for Ctrl() device path nodes.
* Implement Ctrl() nodes in the device path to text protocol.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-03-25 11:05:42 +01:00
Heinrich Schuchardt
180b7118be efi_loader: fix device-path for USB devices
EFI device paths for block devices must be unique. If a non-unique device
path is discovered, probing of the block device fails.

Currently we use UsbClass() device path nodes. As multiple devices may
have the same vendor and product id these are non-unique. Instead we
should use Usb() device path nodes. They include the USB port on the
parent hub. Hence they are unique.

A USB storage device may contain multiple logical units. These can be
modeled as Ctrl() nodes.

Reported-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-25 10:43:50 +01:00
Heinrich Schuchardt
3f26bca262 efi_loader: support for Ctrl() device path node
* Add the definitions for Ctrl() device path nodes.
* Implement Ctrl() nodes in the device path to text protocol.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-03-25 10:43:50 +01:00
Tom Rini
99de38a109 zlib: trees.c: Fix a warning with clang-15
With clang-15 we now will get warnings such as:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]

And it is easy enough to address this warning here, even if we would
like to stay in sync more with upstream as it's a single location.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-22 15:22:48 -04:00
Tom Rini
fbfcb614e0 libavb: Fix a warning with clang-15
With clang-15 we now will get warnings such as:

warning: a function declaration without a prototype is deprecated in all
versions of C [-Wstrict-prototypes]

And it is easy enough to address this warning here, as we aren't
concerned with re-syncing with an upstream.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-22 15:22:48 -04:00
Tony Dinh
c5f4cdb8eb console: Use flush() before panic and reset
To make sure the panic and the reset messages will go out, console flush() should be used.
Sleep periods do not work in early u-boot phase when timer driver is not initialized yet.

Reference: https://lists.denx.de/pipermail/u-boot/2023-March/512233.html

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Stefan Roese <sr@denx.de>
2023-03-22 12:51:08 -04:00
Tom Rini
a5faa4a9eb Prepare v2023.04-rc4
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmQPxXsACgkQFHw5/5Y0
 tyzRWgwAlpwF0u0Xtfs+isnwy/2wb1uMKSeZTiMWkP8he48DX/+db1LHyxnb5apX
 5ULLLKnxZGDviFNw6F/Vuq/BlL8aK+K6wJm+HxdN4Df+sQZgP0kZVnZH1DcDGyJ7
 2I5mYxXCQiRfl3lG8uHdfQyGT5BOm1ZYTIBgXPzpdp/PS6Es74aIHfHS4UdsnpZ2
 dw5APUHnXsSeycbvgiZZEAQphRGplTgSmEDLZTCHD6+oIFoyJVMRr4QWc+KjYPR8
 MgfykqaITO7xKg1V2GwEWJA7LpU4L3HrK+8upSjdx0kfKw4jZoBTU5LE3dnk+6fz
 rgisMfyDGZ+w467uk9BSAO9smRRRI7GFMSkvi+kMQtVCFWCSaddkfYPlpFu1PND7
 nHfxkzoIjxeEOG8yIFF8P199w2lEorKTxlXuNBStfozvAz1wfhgq3o3WQGpvDmqF
 E+FoC7t73qVu6DVMiCXCOyUYNyI7d1tFlUhlbZPVCelVL8RX3JjMF/0uhLsOSDMc
 s4z/6fVq
 =xK+J
 -----END PGP SIGNATURE-----

Merge tag 'v2023.04-rc4' into next

Prepare v2023.04-rc4

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-03-14 12:06:35 -04:00
Heinrich Schuchardt
d3970e04e7 efi_loader: describe term_get_char()
Add a function description.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-03-13 13:56:14 +01:00
Masahisa Kojima
26a35023c4 efi_loader: update SetVariable attribute check
UEFI specification v2.10 says that
EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS is deprecated and
EFI_UNSUPPORTED should be returned in SetVariable variable service.
Current implementation returns EFI_INVALID_PARAMETER,
let's fix the return value.

Together with above change, this commit also updates the SetVariable
attribute check to be aligned with the EDK2 reference implementation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-03-13 13:56:14 +01:00
Simon Glass
3b510807f5 lib: Add an SPL config for LIB_UUID
This is selected by PARTITION_UUIDS which has a separate option for SPL.
Add an SPL option for LIB_UUID also, so that we can keep them consistent.

Also add one for PARTITION_TYPE_GUID to avoid a build error in part_efi.c
which wants to call a uuid function in SPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-02 17:45:58 -05:00
Simon Glass
05a8e1a447 lib: Fix build condition for tiny-printf
This should be checking for any SPL build. Drop the use of SPL_TPL_ since
it is not necessary and will not work with split config.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-02 17:45:58 -05:00
Simon Glass
5a6bc166ef lib: Add VPL options for SHA1 and SHA256
Add these options so these algorithms can be used in VPL.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-02 17:45:58 -05:00
Simon Glass
ae625d9287 lib: Add a Kconfig for SPL_BZIP2
This is implicitly used in the source and seems useful, so add it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-02 17:45:58 -05:00
Simon Glass
a11be4c303 tpm: Implement tpm_auto_start() for TPMv1.2
Add an implementation of this, moving the common call to tpm_init() up
into the common API implementation.

Add a test.

Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-02-28 09:44:33 +02:00
Ilias Apalodimas
78fd2f54d5 efi_loader: use tpm_auto_start for the tpm device
A previous commit is adding a new tpm startup functions which
initializes the TPMv2 and performs all the needed selftests.
Since the TPM selftests might be needed depending on the requested
algorithm or functional module use that instead.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-02-28 09:44:22 +02:00
Ilias Apalodimas
a595be3a4a tpm: add a function that performs selftest + startup
As described in [0] if a command requires use of an untested algorithm
or functional module, the TPM performs the test and then completes the
command actions.

Since we don't check for TPM_RC_NEEDS_TEST (which is the return code of
the TPM in that case) and even if we would, it would complicate our TPM
code for no apparent reason,  add a wrapper function that performs both
the selftest and the startup sequence of the TPM.

It's worth noting that this is implemented on TPMv2.0.  The code for
1.2 would look similar,  but I don't have a device available to test.

[0]
https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.07-2014-03-13.pdf
§12.3 Self-test modes

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-02-28 09:44:19 +02:00
Etienne Carriere
4429393b5a efi_loader: set CapsuleMax from CONFIG_EFI_CAPSULE_MAX
Adds CONFIG_EFI_CAPSULE_MAX to configure the max index value used in
EFI capsule reports. Prior to this change is the hard coded value was
65535 which would exceed available storage for variables. Now the
default value is 15 which should work fine with most systems.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
2023-02-19 21:15:15 +01:00
Etienne Carriere
aa2d3945ce efi_loader: Measure the loaded DTB
Measures the DTB passed to the EFI application upon new boolean config
switch CONFIG_EFI_TCG2_PROTOCOL_MEASURE_DTB. For platforms where the
content of the DTB passed to the OS can change across reboots, there is
not point measuring it hence the config switch to allow platform to not
embed this feature.

Co-developed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-02-19 21:15:15 +01:00
Masahisa Kojima
a135320b42 efi_loader: fix wrong attribute check for QueryVariableInfo
QueryVariableInfo with EFI_VARIABLE_HARDWARE_ERROR_RECORD is
accepted, remove wrong attribute check.

Fixes: 454a9442fb ("efi_loader: update attribute check for QueryVariableInfo()")
Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-19 21:15:15 +01:00
Heinrich Schuchardt
67af329a74 efi_loader: avoid buffer overrun in efi_var_mem_compare
We should not scan beyond the end of string name.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-19 21:15:15 +01:00
Sjoerd Simons
0d91c88230 lmb: Treat a region which is a subset as equal
In various cases logical memory blocks are coalesced; As a result doing
a strict check whether memory blocks are the same doesn't necessarily
work as a previous addition of a given block might have been merged into
a bigger block.

Fix this by considering a block is already registered if it's a pure
subset of one of the existing blocks.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2023-02-12 11:54:18 -05:00
Simon Glass
852d4dbd70 trace: Detect an infinite loop
If something is wrong with a board's timer function such that it calls
functions not marked with notrace, U-Boot will hang.

Detect this, print a message and disable the trace.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
80f91558a1 trace: Correct the relocation handover with buffer overflow
When the early trace buffer overflows it leaves a gap in the trace buffer
between where the actual data finished and where it would have finished if
there were enough buffer space. This results in corrupted output.

Adjust the logic to resolve this and add a message when the buffer
overflows.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
9dd665ad33 trace: Show a few more stats about tracing
Add a few more useful items into the output. Update the buffers to use hex
consistently.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
daca66d55f trace: Track the minimum stack depth
The trace does not necessarily start at the top level, so we can see it
go negative. Track this so that we can show an accurate value for the
stack depth.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
c3d91812a2 trace: Reduce the number of function sites
Given that the compiler adds two function calls into each function, the
current spacing is overkill. Drop it down to 16 bytes per function, which
is still plenty. This saves some space in the trace buffer.

Also move the calculation into a function, so it is common code. Add a
check for gd->mon_len being unset, which breaks tracing.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
d9044e5363 trace: Update the file header
It seems better to put the TEXT_BASE value in the file header rather than
in an entry record. While it is true that there is a separate base for
pre-relocation, this can be handled by using offsets in the file.

It is useful to have a version number in case we need to change the trace
format again.

Update the header to make these changes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:35 -05:00
Simon Glass
90ad4e28e8 abuf: Support use from tools
Update the code slightly so that abuf can be used in U-Boot tools. It will
soon be needed for proftool.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:34 -05:00
Simon Glass
c33425c6f9 trace: Reduce the default for TRACE_EARLY_CALL_DEPTH_LIMIT
This is a silly value at present, since U-Boot's call depth never reaches
200. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:34 -05:00
Simon Glass
64d445a3b7 time: Tidy up some unnecessary #ifdefs
Avoid using the preprocessor with TIMER_EARLY.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-11 12:22:34 -05:00
Tom Rini
c34009d5a9 Pull request for efi-2023-04-rc2
Documentation:
 
 * Provide page with links to talks on U-Boot
 
 UEFI:
 
 * Enable CTRL+S to save the boot order in eficonfig command
 * Run attribute check for QueryVariableInfo() only for the file store
 * Bug fixes
 
 Others:
 
 * Improve output formatting of the coninfo command
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAmPme8EACgkQxIHbvCwF
 GsTJ6RAAiDVG2OFTodxLFVhzxoorrIf/piMZDxtc1ClRxF7CPe5CET18bHp0hvvw
 qKJW+dk3aCUSr+E1Ma9ndAHI+/mKmEXudZj/XuUyxlVhm9P8Fw2EQRGZFeogdp0v
 /tMB8c7DjW5kTg39/U3z3F7qo6ifs1I8rGcxAhvU38iuOmmIai6AZH1cEq2P2zY9
 JdHPzSCVz4TOGzmhJD3wxYMn+DjsLxIT0tggGPRJzXGaAdZdLS7cl/X52rabV/Tq
 aJXhjpWNl7RUiNiQbKMtltbmkJQ2MpHkhLGDj2/3H2W5sbpIx0GwDs7r0GSKJ0Ba
 6ycn5NBjP3C3gcl91oWJXrzux6LN2aWqe45lgOLpL2H2pPaRlDebBEdDA+oNQKoo
 mqX8pMbLfpb3nhg/fOXo/YDZ5Uug42fmpjj3Vu5+imjq9jL+tr5lxZ2oDpsUyT51
 MvQXohYTfsYNHQm7M4BzGIuA66WwCJ5TJ3D/YmwdDWPnCCN+QAUMI2/d8Osbct6W
 OBGaoZQoRpPZV62+mrHloXW9j8sapcQfJGejdby7S1bxagF/KG/BLXGCWH/HdWCc
 TsnW+bOOF4N9gIyyyu3yRfHyE7pIyszWlNwRAuPzjwG0dxEbkboA/JdLIFic3Qsj
 fk/65FSvvAeOuvNYEgsEA5VYXJzhD4oNtcNQZHIHjhSTGKBrJF4=
 =HVHT
 -----END PGP SIGNATURE-----

Merge tag 'efi-2023-04-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-04-rc2

Documentation:

* Provide page with links to talks on U-Boot

UEFI:

* Enable CTRL+S to save the boot order in eficonfig command
* Run attribute check for QueryVariableInfo() only for the file store
* Bug fixes

Others:

* Improve output formatting of the coninfo command

# -----END PGP SIGNATURE-----
# gpg: Signature made Fri 10 Feb 2023 12:15:45 PM EST
# gpg:                using RSA key 6DC4F9C71F29A6FA06B76D33C481DBBC2C051AC4
# gpg: Good signature from "Heinrich Schuchardt <xypron.glpk@gmx.de>" [unknown]
# gpg:                 aka "[jpeg image of size 1389]" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 6DC4 F9C7 1F29 A6FA 06B7  6D33 C481 DBBC 2C05 1AC4
2023-02-10 13:45:15 -05:00
Heinrich Schuchardt
124725732f efi_loader: static efi_query_variable_info_runtime()
This function is not used externally and hence should be static.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
f28c4b2222 efi_loader: make gop_blt() static
This function is not used externally.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
b9276637ce efi_loader: include definition of allow_unaligned()
Add missing include.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
6c2377f9a0 efi_loader: static functions in efi_runtime.c
Functions that are not used externally should be static.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
e7175f9320 efi_loader: static functions in efi_console.c
Define function set_shift_mask() as static as it is not used externally.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
be6784789e efi_loader: static functions in efi_boottime.c
Make functions that are no used externally static.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
575cfe7b47 efi_loader: static functions in helloworld.c
Make functions that are not used externally static.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
8d4c2c770c efi_loader: fix efi_ecpt_register()
num_entries should be unsigned to avoid warnings. As the target field is
u16 we should use this type.

    lib/efi_loader/efi_conformance.c: In function ‘efi_ecpt_register’:
    lib/efi_loader/efi_conformance.c:30:33: warning:
    conversion to ‘long unsigned int’ from ‘int’ may change
    the sign of the result [-Wsign-conversion]
       30 |         ecpt_size = num_entries * sizeof(efi_guid_t)
          |                                 ^
    lib/efi_loader/efi_conformance.c:46:36: warning:
    conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’}
    may change value [-Wconversion]
       46 |         ecpt->number_of_profiles = num_entries;
          |                                    ^~~~~~~~~~~

Fixes: 6b92c17352 ("efi: Create ECPT table")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Heinrich Schuchardt
7d840627ca efi_loader: make get_load_options() static
In program initrddump.efi function get_load_options() can be static.

This avoids a warning when building with 'make W=1':

    lib/efi_loader/initrddump.c:442:6: warning:
    no previous prototype for ‘get_load_options’ [-Wmissing-prototypes]
      442 | u16 *get_load_options(void)
          |      ^~~~~~~~~~~~~~~~

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:40 +01:00
Masahisa Kojima
454a9442fb efi_loader: update attribute check for QueryVariableInfo()
Current U-Boot supports two EFI variable service, U-Boot own
implementation and op-tee based StMM variable service.

With ACS Security Interface Extension(SIE) v22.10_SIE_REL1.1.0,
there are several failure items of QueryVariableInfo().

Current attribute check for QueryVariableInfo() was implemented
based on the Self Certification Test (SCT) II Case Specification,
June 2017, chapter 4.1.4 QueryVariableInfo().
This test case specification is outdated and don't align at all
with the SCT test case code, and UEFI specification v2.10 does
not clearly define the priority of the attribute check.

For U-Boot standard case that EFI variables are stored in a file
in the ESP, this commit modifies the attribute check to get align
to the EDK2 implementation.

For latter case(op-tee based StMM variable service), parameter check
should be delegated to StMM.

Now all ACS SIE QueryVariableInfo() test cases passed both EFI variable
storage implementations.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Acked-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-02-10 13:05:39 +01:00
Simon Glass
28de1e06c9 Correct SPL use of ENV_WRITEABLE_LIST
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_ENV_WRITEABLE_LIST defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Simon Glass
bed722328b Correct SPL use of EFI_UNICODE_COLLATION_PROTOCOL2
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_EFI_UNICODE_COLLATION_PROTOCOL2 defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Simon Glass
07754cb0ae Correct SPL use of EFI_TCG2_PROTOCOL
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_EFI_TCG2_PROTOCOL defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Simon Glass
da841537ce Correct SPL use of EFI_LOADER_HII
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_EFI_LOADER_HII defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Simon Glass
5cf9952e69 Correct SPL use of EFI_DEVICE_PATH_UTIL
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_EFI_DEVICE_PATH_UTIL defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Simon Glass
deda5d5ecd Correct SPL use of EFI_APP
This converts 1 usage of this option to the non-SPL form, since there is
no SPL_EFI_APP defined in Kconfig

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-09 16:32:26 -05:00
Sjoerd Simons
2dc16a2c1f Bump LMB_MAX_REGIONS default to 16
Since commit 06d514d77c ("lmb: consider EFI memory map") the EFI regions
are also pushed into the lmb if EFI_LOADER is enabled (which is by
default on most system). Which can cause the number of entries to go
over the maximum as it's default is only 8.

Specifically i ran into this case on an TI am62 which has an fdt with
4 reserved regions (in practice 3 lmb entries due to adjecent ranges).

As this is likely to impact more devices bump the default max
regions to 16 so there is a bit more slack.

Fixes: 06d514d77c ("lmb: consider EFI memory map")
Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1207562
Reviewed-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
Signed-off-by: Michal Suchanek <msuchanek@suse.de>
[trini: collect tags from the other equivalent patch]
2023-02-08 14:09:39 -05:00
Tom Rini
948d3999bf Revert "lmb: Default to not-LMB_USE_MAX_REGIONS"
As explained by Philippe Schenker, I was misinterpreting what happened
in the case where we do not set LMB_USE_MAX_REGIONS and so had
re-introduced the problem I was attempting to more widely resolve.

This reverts commit 007ae5d108.

Reported-by: Philippe Schenker <philippe.schenker@toradex.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-02-08 10:18:26 -05:00
Sjoerd Simons
c5279ea1c3 lmb: Set correct lmb flags for EFI memory map entries
When adding reserved memory areas from the EFI memory map set the NOMAP
flag when applicable. When this isn't done adding "no-map" flagged entries
from the fdt after receiving the same from the EFI memory map fails due
to non-matching flags.

Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
2023-02-06 12:07:18 -05:00
Tom Rini
007ae5d108 lmb: Default to not-LMB_USE_MAX_REGIONS
The LMB code allows for picking a hard limit on the number of regions it
can know of, or to dynamically allocate these regions. The reason for
this choice is to allow for the compiler to perform a size optimization
in the common case. This optimization however, is very small, ranging
from 196 bytes to 15 bytes saved, or in some cases, being larger. Now
that we also have more regions covered by LMB (in order to protect
various parts of our self at run time), the default of 8 is also much
easier to hit and leads to non-obvious error messages (which imply that
an area is protected, not that we're out of areas to add to the list).

Switch to the dynamic use as the default.

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-02-06 12:07:18 -05:00
Heinrich Schuchardt
15436faa46 efi_loader: don't use HandleProtocol
HandleProtocol() is deprecrated. According to the UEFI specification it
should be implemented as a call to  OpenProtocolInterface() with a hard
coded agent handle. This implies that we would have to call
CloseProtocolInterfaces() after usage with the same handle.

Getting rid of an EFI_CALL() is also appreciated.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-27 18:32:00 +01:00
Heinrich Schuchardt
cb50dda10f efi_loader: fix comment in ESRT code
There is no variable num_pages in function efi_esrt_allocate_install().

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-27 18:32:00 +01:00
Simon Glass
3722cc973f efi: Improve logging in efi_disk
When this fails it can be time-consuming to debug. Add some debugging
to help with this. Also try to return error codes instead of just using
-1.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23 18:11:39 -05:00
Simon Glass
7f33194132 lib: Support printing an error string
It is often useful to show an error code to give the user a clue as to
what went wrong. When error strings are compiled into U-Boot it is
possible to show a message as well.

But at present it is not very convenient, since code must check if the
error strings are present, then obtain the error string and use it in
a printf() string.

Add a %dE option which shows an error code along with an error string,
if available. This makes it easy to show one or both.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23 18:11:39 -05:00
Simon Glass
3e96ed44e8 lib: Add a function to split a string into substrings
Some environment variables provide a space-separated list of strings. It
is easier to process these when they are broken out into an array of
strings.

Add a utility function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-23 18:11:39 -05:00
Tom Rini
dd31cd58b0 Pull request for efi-2023-04-rc1-2
Documentation
 
 * man-pages for source, blkcache, bdinfo
 * fix references to distro documentation
 
 UEFI:
 
 * allow clear screen by scrolling
 * ensure that file ubootefi.var is created
 * fix CapsuleMax variable reporting
 
 Others:
 
 * reduce verbosity of fat_read_file()
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAmPK4d8ACgkQxIHbvCwF
 GsTF7g/9GV5pCoXX3Z3y5s7aLdbCrTxl0R1cMkVEupwQ2t9kIhenVxI1xC/lYIq4
 8DQN5LEB98iH9Ivl28nnsbQnznHlAh0MOzIEVgw0UcAvxLT59hCHyaNcFPAXQsE6
 oVb0H6EX1QhP6j645nHtTq8dbgXP+a8VCN6KFE+j4mS46h+4wQwmV8hHZh/sUF4X
 bFs4aAkRULndQ3hrgj+GnNwQwEnek9VUkoa+28qOwZdAmRrfQfz3uY8mcvE+k0lh
 fHHu6+7KMOBR0wC288/tdCcejyDmPseFU1aflbxJ7GqOp3Jfth2MK+mmKFJ0FeeQ
 mJtlcLXH7fEdymisoVSBpwYFeN+G394yxLNhqnVP2zt88gDFp42zNz56tT6vOhR7
 t5VjmdpWqQOff9A0U7FCtatM8D7kCVDME+prVztQuQ92ED3GiBuY+NHggHo2GgC6
 tezJRpYLD9OBFIfDVRPYDJ0M4NISCCFzHLYQqUZ/IE9InHS34j4oGfjkPgCuxO5l
 y8caw2tcxazdX+QZ2m2jdf0i1pyexk/pYsPBtZcmwg1vwNzFg4a9E19Uq4+IxJVg
 1LyKQ84QdcSzYE8DKZVaqG4Dg2MQZz8huMV35/H/xXIFhsU983HKLGIyG6Cjtuc/
 aAasn2kGlD4mulEB76aXNO09Mb6F0lQwW6yCzN8g+2RKugsEq3w=
 =gM74
 -----END PGP SIGNATURE-----

Merge tag 'efi-2023-04-rc1-2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2023-04-rc1-2

Documentation

* man-pages for source, blkcache, bdinfo
* fix references to distro documentation

UEFI:

* allow clear screen by scrolling
* ensure that file ubootefi.var is created
* fix CapsuleMax variable reporting

Others:

* reduce verbosity of fat_read_file()
2023-01-20 14:23:20 -05:00
Tom Rini
6e7df1d151 global: Finish CONFIG -> CFG migration
At this point, the remaining places where we have a symbol that is
defined as CONFIG_... are in fairly odd locations. While as much dead
code has been removed as possible, some of these locations are simply
less obvious at first. In other cases, this code is used, but was
defined in such a way as to have been missed by earlier checks.  Perform
a rename of all such remaining symbols to be CFG_... rather than
CONFIG_...

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-20 12:27:24 -05:00
Ilias Apalodimas
e10fffe8b5 efi_loader: fix CapsuleMax variable reporting
Currently the code that adds the CapsuleMax variable is under a
Kconfig named 'EFI_HAVE_CAPSULE_UPDATE.  Git history only shows a
single occurrence of that.  The IS_ENABLED should be checking for
EFI_HAVE_CAPSULE_SUPPORT

Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20 17:10:57 +01:00
Ilias Apalodimas
cd63e2d26c efi_loader: update the error message of TCG protocol installation
"Unable to find TPMv2 device" doesn't explain much with regards to the
error origin. Update it to match what we have in the RNG protocol
installation.

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20 16:38:52 +01:00
Heinrich Schuchardt
90c420509e efi_loader: ensure that file ubootefi.var is created
Currently file ubootefi.var is only created if the user sets a non-volatile
EFI variable. If the file is missing, a warning is written.

With the change PlatformLang is always persisted. So the file will exist on
second boot.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-20 16:38:52 +01:00
Jan Kiszka
e585b79ee4 efi_loader: Avoid overwriting previous outputs on console screen clearing
Before clearing the screen, ensure that no previous output of firmware
or UEFI programs will be overwritten on serial devices or other
streaming consoles. This helps generating complete boot logs.

Tested regarding multi-output against qemu-x86_defconfig. Still, there
were remaining concerns about side effects, so this is provided as an
opt-in feature.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20 16:38:52 +01:00
Jan Kiszka
de94f0f320 efi_loader: Set default console colors on efi_cout_clear_screen if needed
Ensures a consistent background color of the whole screen for succeeding
outputs as both demanded by the spec and implemented in EDK2 as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-20 16:38:52 +01:00
Tom Rini
53c47c59e6 convert rockchip to use binman
patman fix for checkpatch
 binman optional entries, improved support for ELF symbols
 trace improvements
 minor fdt refactoring
 -----BEGIN PGP SIGNATURE-----
 
 iQFFBAABCgAvFiEEslwAIq+Gp8wWVbYnfxc6PpAIreYFAmPIpV4RHHNqZ0BjaHJv
 bWl1bS5vcmcACgkQfxc6PpAIreZuqwgA0UpYQEX6/MegzHSCIx3AMT4rCF1Ytitr
 LS4Cbvj1Q09Rt9jriW7wAV5AobVPwGf2L5SVcnWv2I9+MmypDIXEe8HIrt2fRFu9
 bzn/2GOzXczuXqPFa/CWOUwjvCzTb8Sl9NtRszrP5NvOzuN15x00ZUYaXFO7fgsB
 zZMzOKxemwjdtLaox+x+VIJ95HMDEkYrWTAqTPg74CNVSjRbbLNqNq0zqkHB8SnH
 ubgphtIKYItTeIXcfIa9V4LeQp0ZitkzSfAibX+nIPCMPg9jbG9MrQQ+VvSZDjnM
 y8wa8gFj47Ek+gGNFXMHIpO6tBd83uHRgtf2x+zhcovLELYnZ6fDGw==
 =1K6m
 -----END PGP SIGNATURE-----

Merge tag 'dm-pull-18jan23' of https://source.denx.de/u-boot/custodians/u-boot-dm

convert rockchip to use binman
patman fix for checkpatch
binman optional entries, improved support for ELF symbols
trace improvements
minor fdt refactoring
2023-01-19 09:46:57 -05:00
Brandon Maier
4b9b25d943 lib: zstd: update to latest Linux zstd 1.5.2
Update the zstd implementation to match Linux zstd 1.5.2 from commit
2aa14b1ab2.

This was motivated by running into decompression corruption issues when
trying to uncompress files compressed with newer versions of zstd. zstd
users also claim significantly improved decompression times with newer
zstd versions which is a side benefit.

Original zstd code was copied from Linux commit 2aa14b1ab2 which is a
custom-built implementation based on zstd 1.3.1. Linux switched to an
implementation that is a copy of the upstream zstd code in Linux commit
e0c1b49f5b, this results in a large code diff. However this should make
future updates easier along with other benefits[1].

This commit is a straight mirror of the Linux zstd code, except to:
- update a few #include that do not translate cleanly
  - linux/swab.h -> asm/byteorder.h
  - linux/limits.h -> linux/kernel.h
  - linux/module.h -> linux/compat.h
- remove assert() from debug.h so it doesn't conflict with u-boot's
  assert()
- strip out the compressor code as was done in the previous u-boot zstd
- update existing zstd users to the new Linux zstd API
- change the #define for MEM_STATIC to use INLINE_KEYWORD for codesize
- add a new KConfig option that sets zstd build options to minify code
  based on zstd's ZSTD_LIB_MINIFY[2].

These changes were tested by booting a zstd 1.5.2 compressed kernel inside a
FIT. And the squashfs changes by loading a file from zstd compressed squashfs
with sqfsload. buildman was used to compile test other boards and check for
binary bloat, as follows:

> $ buildman -b zstd2 --boards dh_imx6,m53menlo,mvebu_espressobin-88f3720,sandbox,sandbox64,stm32mp15_dhcom_basic,stm32mp15_dhcor_basic,turris_mox,turris_omnia -sS
> Summary of 6 commits for 9 boards (8 threads, 1 job per thread)
> 01: Merge branch '2023-01-10-platform-updates'
>        arm:  w+   m53menlo dh_imx6
> 02: lib: zstd: update to latest Linux zstd 1.5.2
>    aarch64: (for 2/2 boards) all -3186.0 rodata +920.0 text -4106.0
>        arm: (for 5/5 boards) all +1254.4 rodata +940.0 text +314.4
>    sandbox: (for 2/2 boards) all -4452.0 data -16.0 rodata +640.0 text -5076.0

[1] e0c1b49f5b
[2] f302ad8811/lib/libzstd.mk (L31)

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
[trini: Set ret to -EINVAL for the error of "failed to detect
compressed" to fix warning, drop ZSTD_SRCSIZEHINT_MAX for non-Linux host
tool builds]
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-18 19:04:17 -05:00
Simon Glass
ebc1d50ab5 Revert "fdtdec: drop needlessly convoluted CONFIG_PHANDLE_CHECK_SEQ"
The fdt_path_offset() function is slow since it must scan the tree.
This substantial overhead now applies to all boards.

The original code may not be ideal but it is fit for purpose and is only
needed on a few boards.

Reverting this reduces time to set up driver model by about 30ms.

Before revert:

Accumulated time:
                47,170  dm_r
                53,237  dm_spl
               572,986  dm_f

Accumulated time:
                44,598  dm_r
                50,347  dm_spl
               549,133  dm_f

This reverts commit 26f981f295.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
12619d4ec8 trace: Don't require TIMER_EARLY
Some platforms cannot honour this and don't need trace before relocation.
Use 'imply' instead, so boards can disable this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
bebc1410ca trace: Move trace pointer to data section
This can be written before relocation. Move it to the data section, since
accessing BSS before relocation is not permitted.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
9557592edc fdt: Check for overlapping data and FDT
If the FDT overlaps with the data region of the image, or with the stack,
it can become corrupted before relocation. Add a check for this, behind a
debug flag, as it can be very confusing and time-consuming to debug.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
ec4f327145 fdt: Pass the device tree to fdtdec_prepare_fdt()
This function uses gd->fdt_blob a lot and cannot be used to check any
other device tree. Use a parameter instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
b62d34937a fdt: Drop ifdefs in fdtdec_prepare_fdt()
This function is a bit messy with several #ifdefs. Convert them to use C
for the conditions.

Rewrite the function comment since most of it is stale.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
c662d0b722 fdt: Avoid exporting fdtdec_prepare_fdt()
This function is not used outside this file. Make it static.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
0c16fca927 tpm: Add a proper Kconfig option for crc8 in SPL
The current approach is a bit of a hack and only works for the tpm
subsystem. Add a Kconfig so that crc8 can be enabled in SPL for other
purposes.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
33c60a38bb trace: Use notrace for short
The attribute syntax is quite verbose. Use the macro provided for this
purpose.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:12 -07:00
Tom Rini
448e2b6327 event: Correct dependencies on the EVENT framework
The event framework is just that, a framework. Enabling it by itself
does nothing, so we shouldn't ask the user about it. Reword (and correct
typos) around this the option and help text. This also applies to
DM_EVENT and EVENT_DYNAMIC. Only EVENT_DEBUG and CMD_EVENT should be
visible to the user to select, when EVENT is selected.

With this, it's time to address the larger problems. When functionality
uses events, typically via EVENT_SPY, the appropriate framework then
must be select'd and NOT imply'd. As the functionality will cease to
work (and so, platforms will fail to boot) this is non-optional and
where select is appropriate. Audit the current users of EVENT_SPY to
have a more fine-grained approach to select'ing the framework where
used. Also ensure the current users of event_register and also select
EVENT_DYNAMIC.

Cc: AKASHI Takahiro <takahiro.akashi@linaro.org>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reported-by: Oliver Graute <Oliver.Graute@kococonnector.com>
Reported-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Fixes: 7fe32b3442 ("event: Convert arch_cpu_init_dm() to use events")
Fixes: 42fdcebf85 ("event: Convert misc_init_f() to use events")
Fixes: c5ef202557 ("dm: fix DM_EVENT dependencies")
Signed-off-by: Tom Rini <trini@konsulko.com>
Tested-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Fabio Estevam <festevam@denx.de>
2023-01-18 12:46:13 -05:00
John Keeping
93a6e60e49 rc4: mark key as const
Key data is never written so the parameter can be const, which allows
putting fixed keys in .rodata.

Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-01-16 18:01:10 +08:00
Heinrich Schuchardt
8e4ec3e947 efi_loader: provide agent_handle to efi_disk_add_dev()
In efi_disk_add_dev() we have to open protocols with BY_DRIVER and
BY_CHILD_CONTROLLER. Provide the handle of the EFI block driver. The actual
usage of the value will follow in a later patch.

Change function descriptions to Sphinx style.

Remove a TODO: tag.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-13 09:09:07 +01:00
Vincent Stehlé
4d4ec25810 efi_selftest: add hii set keyboard layout test case
Add a test for the case when the HII database protocol
set_keyboard_layout() function is called with a NULL key_guid argument.

Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2023-01-13 09:09:07 +01:00