Commit Graph

399 Commits

Author SHA1 Message Date
Frantisek Sumsal 86b52a3958 tree-wide: fix spelling errors
Based on a report from Fossies.org using Codespell.

Followup to #15436
2020-04-21 23:21:08 +02:00
Zbigniew Jędrzejewski-Szmek 162392b75a tree-wide: spellcheck using codespell
Fixes #15436.
2020-04-16 18:00:40 +02:00
Jan Janssen 904ebcb200 sd-boot: Add → as alternative to boot selected entry
This is sometimes slightly more convenient to use
and is also what GRUB supports.
2020-04-15 21:29:41 +01:00
Zbigniew Jędrzejewski-Szmek 38cd55b007 Remove unneded {}s
$ perl -i -0pe 's|\s+{\n([^\n]*;)\n\s+}\n|\n\1\n|gms' **/*.c

Inspired by ea7cbf5bdd.
2020-04-13 09:31:49 +02:00
Lennart Poettering c46db6c0a2 bootctl: fix assert issue
Follow-up for b46c3e4913
2020-04-09 11:22:40 -07:00
Vito Caputo b46c3e4913 *: use _cleanup_close_ with fdopen() where trivial
Also convert these to use take_fdopen().
2020-03-31 06:48:03 -07:00
James T. Lee 1ad6056239 boot: Ensure ARM UEFI binary does not contain FP/SIMD instructions
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
2020-03-08 15:21:00 +09:00
Zbigniew Jędrzejewski-Szmek ce4121c6ff meson: update efi path detection to gnu-efi-3.0.11
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
2020-02-04 23:43:21 +09:00
Yu Watanabe efda8aebcb sd-boot: fix -Wpointer-sign warning 2020-01-31 19:59:34 +09:00
Yu Watanabe a614aa1985 sd-boot: fix warning about comparison is always true 2020-01-31 19:20:34 +09:00
Lennart Poettering 8615bec7a0
Merge pull request #14667 from yuwata/boot-random-seed-mode
boot: parse random-seed-mode
2020-01-28 15:42:10 +01:00
Susant Sahani 8bdda551da efi: fix build.
```
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

```
2020-01-27 16:13:28 +09:00
Yu Watanabe a14c18ba7b sd-boot: fix typo
Fixes #14657.
2020-01-26 13:20:21 +09:00
Lennart Poettering 4353974d75 boot: fix osrel parser
let's check VERSION instead of VERSION_ID where appropriate.

Fixes: #14493
2020-01-07 19:32:14 +00:00
Lennart Poettering 3b5cd25f4d
Merge pull request #14196 from keszybz/gpt-auto-generator-debugging
gpt-auto-generator debugging
2019-12-16 09:24:02 +01:00
Zbigniew Jędrzejewski-Szmek 41ab3b7a85
Merge pull request #13953 from SpencerMichaels/systemd-boot-efistub-id-fix
boot: Fix default/oneshot selection for EFISTUB entries
2019-12-04 13:30:52 +01:00
Leonid Bloch 26601a2a17 sd-boot: Add a 0.1 second delay before key-probing for showing menu
If there is no boot menu timeout, pressing a key during boot should get
the boot menu displayed. However, on some systems the keyboard is not
initialized right away, which causes the menu to be inaccessible if no
timeout is specified.

To resolve this, if the error is "not ready" after the initial attempt of
detection, wait for 0.1 second and retry. This solves the problem
described above on all the tested systems.

The reason for just a single retry, and not retrying while "not ready",
is that some firmwares continue to return the "not ready" error on
every probe attempt if no key is pressed.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
2019-12-04 10:52:28 +01:00
Zbigniew Jędrzejewski-Szmek 607ebf2bd2 bootlctl: show LoaderDevicePartUUID information in status 2019-11-30 17:42:13 +01:00
Lennart Poettering 351de38e4b bootctl: make 'random-seed' handle inability to write system token EFI variable gracefully
Apparently some firmwares don't allow us to write this token, and refuse
it with EINVAL. We should normally consider that a fatal error, but not
really in the case of "bootctl random-seed" when called from the
systemd-boot-system-token.service since it's called as "best effort"
service after boot on various systems, and hence we shouldn't fail
loudly.

Similar, when we cannot find the ESP don't fail either, since there are
systems (arch install ISOs) that carry a boot loader capable of the
random seed logic but don't mount it after boot.

Fixes: #13603
2019-11-21 19:55:17 +01:00
Spencer Michaels 10d0024a07 boot: Improve EFISTUB name and version detection.
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.
2019-11-18 22:59:51 -08:00
Spencer Michaels 6cd12ebcfe boot: Retain ".conf" suffix for loader config IDs.
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).
2019-11-18 22:59:51 -08:00
Spencer Michaels 65901c0fd1 boot: Ignore EFISTUB binaries starting with "auto-".
To further increase similarity with loader configs and provide global
uniqueness, ignore filenames starting with auto- (see boot.c:1512).
2019-11-18 22:59:51 -08:00
Spencer Michaels 7fa23ab646 boot: Make EFISTUB IDs use binaries' filenames.
Change config_entry_add_linux() so that Linux EFISTUB entries' ids are
simply the binaries' filenames, as is already the case with loader
configs. This guarantees that EFISTUB binaries' IDs are mutually unique.
2019-11-18 22:59:44 -08:00
Zbigniew Jędrzejewski-Szmek 2536752dda Rename "system-options" to "systemd-efi-options"
This makes the naming more consistent: we now have
bootctl systemd-efi-options,
$SYSTEMD_EFI_OPTIONS
and the SystemdOptions EFI variable.

(SystemdEFIOptions would be redundant, because it is only used in the context
of efivars, and users don't interact with that name directly.)

bootctl is adjusted to use 2sp indentation, similarly to systemctl and other
programs.

Remove the prefix with the old name from 'bootctl systemd-efi-options' output,
since it's redundant and we don't want the old name anyway.
2019-11-18 20:20:58 +01:00
Zbigniew Jędrzejewski-Szmek b289de2b06 bootctl: update --help text 2019-11-18 20:20:58 +01:00
Lennart Poettering 353b2baa20 tree-wide: clean up --help texts a bit
This cleans up and unifies the outut of --help texts a bit:

1. Highlight the human friendly description string, not the command
   line via ANSI sequences. Previously both this description string and
   the brief command line summary was marked with the same ANSI
   highlight sequence, but given we auto-page to less and less does not
   honour multi-line highlights only the command line summary was
   affectively highlighted. Rationale: for highlighting the description
   instead of the command line: the command line summary is relatively
   boring, and mostly the same for out tools, the description on the
   other hand is pregnant, important and captions the whole thing and
   hence deserves highlighting.

2. Always suffix "Options" with ":" in the help text

3. Rename "Flags" →  "Options" in one case

4. Move commands to the top in a few cases

5. add coloring to many more help pages

6. Unify on COMMAND instead of {COMMAND} in the command line summary.
   Some tools did it one way, others the other way. I am not sure what
   precisely {} is supposed to mean, that uppercasing doesn't, hence
   let's simplify and stick to the {}-less syntax

And minor other tweaks.
2019-11-18 15:14:43 +01:00
Dimitri John Ledkov 07d5ed536e boot: Add ARM64 support to the EFI stub 2019-11-14 10:03:08 +01:00
Dimitri John Ledkov 53a2045521 boot: Load LoadOptions cmdline, if none is available.
Fixes #13694
2019-11-14 10:01:20 +01:00
Lennart Poettering a4a55e9ace bootctl: create leading dirs when "bootctl random-seed" is called if needed
Prompted by: #13603
2019-11-04 14:26:53 +01:00
Zbigniew Jędrzejewski-Szmek a859abf062
Merge pull request #13906 from yuwata/drop-missing-take2
tree-wide: drop xxx.h when xxx-util.h is included
2019-11-04 13:41:37 +01:00
Jan Janssen f9f1d01cbd sd-boot: Skip adding boot entries when the loader does not exist 2019-11-04 13:39:20 +01:00
Yu Watanabe 1405cb653a tree-wide: drop stdio.h when stdio-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe e30e8b5073 tree-wide: drop stat.h or statfs.h when stat-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe adb29d588e tree-wide: drop blkid.h when blkid-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 996f7e1cd0 tree-wide: drop dirent.h when dirent-util.h is included 2019-11-04 00:30:32 +09:00
Yu Watanabe 455fa9610c tree-wide: drop string.h when string-util.h or friends are included 2019-11-04 00:30:32 +09:00
Jan Janssen d9690d8fe9 sd-boot: Silence compiler warning when building with -O2 2019-10-30 17:47:55 +01:00
Jan Janssen 391719682b sd-boot: Don't loudly complain if RNG protocol isn't available
Fixes #13503
2019-10-30 17:47:50 +01:00
Jan Janssen 9ea4d81c12 sd-boot: Only disable optimization on debug builds 2019-10-30 17:34:12 +01:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Zbigniew Jędrzejewski-Szmek 4e5aa79185 bootctl: add "system-options" verb 2019-09-16 18:08:54 +02:00
Zbigniew Jędrzejewski-Szmek 0bb2f0f10e util-lib: split shared/efivars into basic/efivars and shared/efi-loader
I want to use efivars.[ch] in proc-cmdline.c, but most of the efivars stuff is
not needed in basic/. Move the file from shared/ to basic/, but then move back
most of the higher-level functions to the new shared/efi-loader.c file.
2019-09-16 18:08:53 +02:00
Dan Streetman 4d6c1fce0e src/boot/efi/meson.build: if meson --werror is true, set gcc -Werror
This part of the build does not use the normal meson parameters, so
we need to explicitly check for the meson --werror parameter, and if
it's true, set the gcc -Werror parameter for this subdir's build.
2019-08-15 17:46:58 -04:00
Dan Streetman 4287d0832c src/boot/efi/linux: elide __attribute__((regparm(0))) on non-i386
This attribute is x86_32-only, so when building on non-intel archs it
generates a compiler warning.  When building with -Werror this turns
into an error, so only include the attribute on i386 arch builds.
2019-08-15 16:36:10 -04:00
Dan Streetman 82a0fb328e src/boot/efi/shim: elide __attribute__((sysv_abi)) on non-intel archs
This attribute is x86-only, so when building on non-intel archs it
generates a compiler warning.  When building with -Werror this turns
into an error, so only include the attribute on intel archs.
2019-08-15 16:36:10 -04:00
Yu Watanabe f8a2b09a18 bootctl: arg_dolloar_boot_path() may return NULL 2019-08-12 16:14:07 +09:00
Yu Watanabe a2ae0d4969 bootctl: clear arg_xbootldr_path when acquire_xbootldr() succeeds 2019-08-12 00:04:44 +09:00
Yu Watanabe 4c858c6fd5 boot: fix build with gnu-efi older than 3.0.5 2019-07-30 18:58:15 +02:00
Zbigniew Jędrzejewski-Szmek a4d208018c bootctl: log message tweaks
Follow-up for e44c3229f2.
2019-07-26 15:05:18 +02:00
Zbigniew Jędrzejewski-Szmek 47685d9d4b
Merge pull request #13137 from poettering/efi-random
beef up random seed logic, add boot loader entropy privisioning, improve docs about it
2019-07-26 12:43:32 +02:00