summaryrefslogtreecommitdiff
path: root/src/boot/efi
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: avoid uninitialized warning on _cleanup_ variablesLuca Boccassi2021-05-063-5/+5
| | | | | | | | | With some versions of the compiler, the _cleanup_ attr makes it think the variable might be freed/closed when uninitialized, even though it cannot happen. The added cost is small enough to be worth the benefit, and optimized builds will help reduce it even further. (cherry picked from commit c2b2df604b845b4e1697d0911935e6644323c5a6)
* meson: fix warning about comparison between different typesYu Watanabe2021-03-221-7/+5
| | | | Follow-up for e39288193fcdf3a36dbc49b78e6c9bf86a764e31.
* systemd-boot: LLVM/lld does not support PE/COFF relocations. Bail out with ↵tpgxyz2021-03-191-1/+8
| | | | an error message
* boot: Move console declarations to missing_efi.hDaan De Meyer2021-03-133-61/+69
| | | | | | These were added to eficonex.h in gnu-efi 3.0.13. Let's move them to missing_efi.h behind an appropriate guard to fix the build with recent versions of gnu-efi.
* efi: introduce UINT32_MAX and UINT64_MAXYu Watanabe2021-03-052-24/+30
|
* efi stub: accept it if our loaded image has no FilePath field setLennart Poettering2021-02-231-2/+8
| | | | | | | | | | | The firmware spec doesn't really say whether FilePath of the LoadedImage protocol may be NULL or not. So far we assumed it to be non-NULL, but apparently the FreeBSD UEFI chainloader sets it to NULL. Handle this gracefully. (Noticed and tracked down by Alexander Schreiber) Fixes: #18733
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-1/+2
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* tree-wide: replace strverscmp() and str_verscmp() with strverscmp_improved()Yu Watanabe2021-02-091-58/+1
|
* fundamental: move several macros and functions into src/fundamental/Yu Watanabe2021-02-095-96/+11
| | | | | | | | | | sd-boot has a copy of a subset of codes from libbasic. This makes sd-boot share the code with libbasic, and dedup the code. Note, startswith_no_case() is dropped from sd-boot, as - it is not used, - the previous implementation is not correct, - gnu-efi does not have StrniCmp() or so.
* boot: Replace efivar_set() persistent argument with flags argumentDaan De Meyer2021-02-045-45/+47
| | | | | | To add secure-boot enrolling support, we need to be able to specify the EFI_VARIABLE_APPEND_WRITE flag so let's make the efivar_set() methods more generic so we can set that flag.
* boot: Add startswith() and endswith() functions with no_case variantsDaan De Meyer2021-02-023-12/+66
| | | | Adapted from string-util
* boot: Drop unnecessary bracesDaan De Meyer2021-02-021-2/+1
|
* boot: Fix void pointer arithmetic warningDaan De Meyer2021-02-021-1/+1
|
* boot: Replace raw efivar gets with typed variantsDaan De Meyer2021-02-021-21/+15
|
* boot: Add efivar_get/set_uint64_le() functionsDaan De Meyer2021-02-022-0/+65
| | | | | | These are implemented as bit-shifting functions that allow reading and writing UEFI variables stored as little endian 64-bit unsigned values.
* boot: Rename efivar_get/set_int() to efivar_get/set_uint_string()Daan De Meyer2021-02-023-9/+9
| | | | | Let's clearly indicate that these are used to set/get uints that are stored as strings.
* boot: Tighten scope of variables used in loopsDaan De Meyer2021-02-029-101/+70
|
* boot: Add efivar_get_boolean_u8()Daan De Meyer2021-02-023-5/+17
|
* boot: Make all efivar util functions take the guid as an argumentDaan De Meyer2021-01-314-44/+50
| | | | | | | Let's make these functions a little more generic so we can have them work on more than one GUID. More specifically, this allows using them with the global guid which will be used a bit more to extend the secure boot support.
* boot: Turn all guid constants into C99 compound initializersDaan De Meyer2021-01-3110-60/+56
| | | | | Avoids having to use the address operator all the time and avoids having to cast or do other unintuitive stuff.
* boot: Enable C99Daan De Meyer2021-01-311-2/+2
| | | | | | | | | Instead of using -nostdinc, we use -nostdlib. This is necessary to allow moving to C99 as efibind.h includes stdint.h when C99 is enabled. It isn't necessarily problematic to use some standard library headers as long as they don't contain functions defined in libc or another system library (or in other words, header only headers are fine to use in sd-boot).
* boot: Move Secure Boot logic to new fileDaan De Meyer2021-01-318-27/+30
|
* sd-boot: Add missing includesDaan De Meyer2021-01-318-0/+15
| | | | | Let's make all headers self-sufficient by including the necessary EFI headers in the headers themselves.
* sd-boot: Make internal functions staticDaan De Meyer2021-01-313-4/+4
|
* tree-wide: add spdx header on all scripts and helpersZbigniew Jędrzejewski-Szmek2021-01-281-0/+1
| | | | | | Even though many of those scripts are very simple, it is easier to include the header than to try to say whether each of those files is trivial enough not to require one.
* boot: at least one of os_name_pretty or os_name exists in this blockYu Watanabe2021-01-121-2/+2
| | | | Closes CID#1438933.
* efi: Only use arm flags if supportedAndrew Balmos2020-12-151-1/+7
| | | | Support gcc 8 on arm
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-0927-27/+27
|
* headers: use custom LicenseRef- spdx tag for various "public domain" filesZbigniew Jędrzejewski-Szmek2020-10-292-1/+2
| | | | | | | | There is no spdx tag defined for those versions of "public domain", but we can add a custom tag, see https://spdx.github.io/spdx-spec/6-other-licensing-information-detected/. crc32.h is updated to match crc32.c.
* headers: add spdx tags to imported files with a known licenseZbigniew Jędrzejewski-Szmek2020-10-291-0/+2
| | | | | | | | | | | | | | | I added the header in the cases where the license text is present and it is easy to find the appropriate SPDX header. For "public domain" stuff: SDPX treats each "public domain" license as unique [1], but luckily the one in siphash24.c is one of the identified variants. There are some other cases which specify "public domain" but there doesn't seem to be a SPDX identifier. [1] https://wiki.spdx.org/view/Legal_Team/Decisions/Dealing_with_Public_Domain_within_SPDX_Files gunicode.[ch] are imported from glib, which is licensed as LGPL2.1+, see https://gitlab.gnome.org/GNOME/glib/-/blob/master/glib/gunicode.h.
* tree-wide: use the usual SPDX header for our own filesZbigniew Jędrzejewski-Szmek2020-10-291-0/+2
|
* boot/efi: Explicitly specify void in parameter listMarco Wang2020-10-061-1/+1
| | | | | | | Functions that accept no arguments should be explicitly declared a void parameter in their parameter list. Signed-off-by: Marco Wang <m.aesophor@gmail.com>
* sd-boot: Add small comments after device-specific key macrosPaul Cercueil2020-06-181-4/+4
| | | | | | | | | The key macros added in commit 6fe95d3020 look strange at first sight. Add a comment with just the tablet name after each line, so that it's obvious that these lines address device-specific issues of the EFI firmware, and not broken/old code. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
* sd-boot: Work around malformed CR key codePaul Cercueil2020-06-151-0/+4
| | | | | | | | | | | | | | | | | | | | | When a key is pressed, the EFI firmware gives us a 64-bit word that contains the modifier key code in the upper 32 bits, the scan code in the middle 16 bits, and a unicode character in the low 16 bits. Some bogus EFI firmwares will put the unicode character in the scan code area, for instance on the EZpad mini 4s tablet. Others will even put the unicode character in both the scan code and unicode areas. This is the case for instance on the Teclast X98+ II tablet. Add workarounds for these corner cases, only for the carriage return key right now. Some more workarounds may be needed, e.g. for volume keys, but I cannot test it. Partially fixes #8466. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
* sd-boot: fix menu ordering with boot countingDaniel Fullmer2020-05-261-8/+8
| | | | | | systemd-boot selects the last valid entry by default, not the first. Fixes: #15256
* tree-wide: fix spelling errorsFrantisek Sumsal2020-04-211-1/+1
| | | | | | Based on a report from Fossies.org using Codespell. Followup to #15436
* sd-boot: Add → as alternative to boot selected entryJan Janssen2020-04-151-0/+1
| | | | | This is sometimes slightly more convenient to use and is also what GRUB supports.
* Remove unneded {}sZbigniew Jędrzejewski-Szmek2020-04-131-2/+1
| | | | | | $ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c Inspired by ea7cbf5bdd68d7861ebf1570c439e8bbabd83f6c.
* boot: Ensure ARM UEFI binary does not contain FP/SIMD instructionsJames T. Lee2020-03-081-0/+2
| | | | | | | | | | | | | | | | | | ARM toolchains will sometimes optimize otherwise floating-point-free code with floating point and SIMD instructions. This was happening with systemd-bootarm.efi and it was causing U-Boot to crash and reset the CPU. U-Boot does not support the ARM VFP floating point coprocessor, which is an optional piece of hardware anyway [1]. Ensure the compiler does not generate FP/SIMD instructions by supplying the `-mgeneral-regs-only` option when building for ARM [2]. The other option you often see to solve these problems is `-msoft-float`, but that changes the ABI and prevents linking with libgnuefi. [1] https://lists.denx.de/pipermail/u-boot/2011-February/087736.html [2] https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html#index-mgeneral-regs-only-1
* meson: update efi path detection to gnu-efi-3.0.11Zbigniew Jędrzejewski-Szmek2020-02-041-22/+41
| | | | | | | | | | | | | | | | | | | | | | | | Fixes systemd build in Fedora rawhide. The old ldsdir option is not useful, because both the directory and the file name changed. Let's remove the option and try to autodetect the file name. If this turns out to be not enough, a new option to simply specify the full path to the file can be added. F31: efi arch: x86_64 EFI machine type: x64 EFI CC ccache cc EFI lds: /usr/lib64/gnuefi/elf_x64_efi.lds EFI crt0: /usr/lib64/gnuefi/crt0-efi-x64.o EFI include directory: /usr/include/efi F32: efi arch: x86_64 EFI machine type: x64 EFI CC ccache cc EFI lds: /usr/lib/gnuefi/x64/efi.lds EFI crt0: /usr/lib/gnuefi/x64/crt0.o EFI include directory: /usr/include/efi
* sd-boot: fix -Wpointer-sign warningYu Watanabe2020-01-312-6/+6
|
* sd-boot: fix warning about comparison is always trueYu Watanabe2020-01-311-1/+1
|
* Merge pull request #14667 from yuwata/boot-random-seed-modeLennart Poettering2020-01-281-2/+2
|\ | | | | boot: parse random-seed-mode
| * sd-boot: fix typoYu Watanabe2020-01-261-2/+2
| | | | | | | | Fixes #14657.
* | efi: fix build.Susant Sahani2020-01-271-1/+1
|/ | | | | | | | | | | | | | | | | | | | | ``` ninja -C build ninja: Entering directory `build' [29/101] Generating systemd_boot.so with a custom command. FAILED: src/boot/efi/systemd_boot.so /usr/bin/ld -o src/boot/efi/systemd_boot.so -T /usr/lib64/gnuefi/elf_x64_efi.lds -shared -Bsymbolic -nostdlib -znocombreloc -L /usr/lib64 /usr/lib64/gnuefi/crt0-efi-x64.o src/boot/efi/disk.c.o src/boot/efi/graphics.c.o src/boot/efi/measure.c.o src/boot/efi/pe.c.o src/boot/efi/util.c.o src/boot/efi/boot.c.o src/boot/efi/console.c.o src/boot/efi/crc32.c.o src/boot/efi/random-seed.c.o src/boot/efi/sha256.c.o src/boot/efi/shim.c.o -lefi -lgnuefi /usr/lib/gcc/x86_64-redhat-linux/10/libgcc.a /usr/bin/ld: src/boot/efi/graphics.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/pe.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/util.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/boot.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/console.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/random-seed.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here /usr/bin/ld: src/boot/efi/shim.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: multiple definition of `loader_guid'; src/boot/efi/disk.c.o:/home/sus/tt/systemd/build/../src/boot/efi/util.h:58: first defined here [31/101] Generating stub.c.o with a custom command. ninja: build stopped: subcommand failed. make: *** [Makefile:2: all] Error 1 ```
* boot: fix osrel parserLennart Poettering2020-01-071-1/+1
| | | | | | let's check VERSION instead of VERSION_ID where appropriate. Fixes: #14493
* Merge pull request #13953 from SpencerMichaels/systemd-boot-efistub-id-fixZbigniew Jędrzejewski-Szmek2019-12-041-16/+32
|\ | | | | boot: Fix default/oneshot selection for EFISTUB entries
| * boot: Improve EFISTUB name and version detection.Spencer Michaels2019-11-181-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | Make two minor cosmetic changes to how config_entry_add_linux() extracts OS information from the embedded /etc/os-release in EFISTUB binaries. This increases the detail of information available to the user for EFISTUB entries. * entry->version, which was previously always null, is now set to the value of VERSION, or VERSION_ID, or BUILD_ID (preferred in that order). * entry->title, which was previously set to the value of PRETTY_NAME, can now fall back to NAME or ID if PRETTY_NAME is not present. In that case, NAME is preferred over ID.
| * boot: Retain ".conf" suffix for loader config IDs.Spencer Michaels2019-11-181-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Change config_entry_add_from_file() so that it does not remove the `.conf` ending from the filename that it uses for entry->id. This is necessary because otherwise an EFISTUB binary and a loader config entry might end up with the same ID, as the loader config IDs previously didn't include the config filename's .conf extension (see boot.c:1435). Consider, for instance, an EFISTUB /EFI/Linux/linux.efi and a loader config /loader/entries/linux.efi.conf; both would have the ID linux.efi. In addition, update a comment that previously stated that IDs are non-unique (which is no longer the case, as of this commit).
| * boot: Ignore EFISTUB binaries starting with "auto-".Spencer Michaels2019-11-181-0/+2
| | | | | | | | | | To further increase similarity with loader configs and provide global uniqueness, ignore filenames starting with auto- (see boot.c:1512).