Commit Graph
731 Commits
Author SHA1 Message Date
Lennart Poettering f63b5ad935 boot: suppress XBOOTLDR if same device as ESP when enumerating entries
On my local system I linked up the ESP and XBOOTLDR partitions, and
ended up with duplicate entries being listed. Try hard to detect that
and only enumerate entries in the ESP if it turns out that both dirs
have the same dev_t.

This should detect both bind mounted and symlinked cases and should make
our list output less confusing.
2022-02-14 16:24:04 +01:00
Lennart Poettering bb68205768 bootctl: show more information about boot entry state in list
Let's improve display of boot entries and show what type they have (i.e.
boot loader spec type 1, or type 2, or auto-discovered or reported by
boot loader), and in particular mark entries the boot loader discovered
but we can't find (i.e. that likely vanished, or possibly couldn't be
found due to a misconfiguration) and that the boot loader didn't find
but we see (which are new, or possibly also the result of
misconfiguraiton).

This is supposed to be a replacement for #22161, but instead of hiding
vanished entries, highlights them, which I think is more appropriate for
a low-level tool such bootctl.

Replaces: #22161 #22398
2022-02-14 15:44:07 +01:00
Lennart Poettering a78e472dfd bootspec: also collect/mark the "selected" boot entry (i.e. the one currently booted)
it's helpful and easy, so let's do it
2022-02-14 15:44:07 +01:00
Lennart Poettering fdc5c04299 bootspec: parse/show devicetree-overlay field too
It has been defined in the boot loader spec, and is the only field we
currently don't parse, hence fix that.
2022-02-14 15:44:07 +01:00
Lennart Poettering 9951736b7f Revert "bootctl: Ignore boot entries (continue #22041)" 2022-02-14 15:44:07 +01:00
Jan Janssen ac3979abd7 boot: Correctly check the return value of CheckEvent
Fixes: #22428
2022-02-11 17:07:05 +00:00
Lennart Poettering 3bcc999fa5 sd-boot: don't use TSC in virtualized environments
Replaces: f699bd81e8

Fixes: #22060
2022-02-08 13:46:26 +01:00
Lennart Poettering 16cec133c6 sd-boot: return 0 (not 1) from ticks_read() in fallback implementation
The single consumer of ticks_read() (i.e. time_usec()) checks for == 0
to detect the "not supported/invalid" case, hence actually return the
right value for that.
2022-02-08 13:46:23 +01:00
Lennart Poettering fb63526f72 sd-boot: encapsulate freq cache in ticks_freq()
It's usually nicer to abstract a cache away in the provider of a value,
hence do so.
2022-02-08 13:46:20 +01:00
Lennart Poettering efbb86797d sd-boot: don't export ticks_read() and ticks_freq()
They only have a single user in time_usec(), hence don't expose them.
2022-02-08 13:46:17 +01:00
Lennart Poettering 476c0e969a sd-boot: add overflow check to TSC reads
On some archs the counter is 32bit, and in case of virtualization it
might actually overflow, who knows.
2022-02-08 13:46:14 +01:00
Lennart Poettering 1e66a23373 sd-boot: split out TSC/time API
These are a whole family of functions, let's give them their own .c/.h
file.

No code changes, just splitting things out.
2022-02-08 13:46:02 +01:00
Jan Janssen ce5e7872f8 boot: Fix some error messages 2022-02-03 23:05:36 +01:00
Lennart Poettering 0bf78c12b1 boot: fix pretty nasty typo
Note to self: should I ever become a black hat hacker, this is how I'd
hide a vulnerability. ;-)

(No, this one is not a vulnerability)

Follow-up for: 163d1ea5dd
2022-02-03 14:57:35 +01:00
Lennart Poettering 362c62296a sd-boot: rename LOADER_STUB → LOADER_UNIFIED_LINUX
No actual code changes, just renaming.

Rationale: the focus here should be on the fact that these are "unified"
images, whether our stub is used or not, or something else doesn't
really matter. Moreover, these are still Linux entries. Hence, emphasize
that these are *unified* images, and *Linux* images, and deemphesize
that our sd-stub is likely used.
2022-02-03 13:44:28 +09:00
Lennart Poettering 1462d2451a efi: use assert_se() instead of assert() to guard for OOM issues in EFI code 2022-02-01 15:31:20 +01:00
Lennart Poettering 3b23a6c40a fundamental: support assert_se() in EFI mode too 2022-02-01 15:29:21 +01:00
Daan De Meyer 17e2e8073f boot: Don't require a machine ID to be available
Regression introduced in https://github.com/systemd/systemd/pull/21807.

Fixes #22224
2022-01-31 13:58:06 +00:00
Yu Watanabe e6d31fc97a tree-wide: fix typo 2022-01-28 04:47:39 +09:00
Jan Janssen 1926a11439 boot: Add screen resolution to print status 2022-01-26 18:07:00 +01:00
Jan Janssen c323c2f63c boot: Also NUL-terminate for CHAR16 in file_reaad 2022-01-26 18:07:00 +01:00
Jan Janssen 20a734726e boot: Use ASSERT_PTR 2022-01-26 18:07:00 +01:00
Jan Janssen 83d905b7b4 boot: Optimize unique title generation 2022-01-26 18:06:52 +01:00
Jan Janssen 7afd0196b6 meson: Use --no-wchar-size-warning
This only disables the one warning that we care to ignore, making
sure that any future issues do not get masked.
2022-01-26 14:40:55 +01:00
Jan Janssen b6167d9611 meson: Use same name format for efi binary intermediates 2022-01-26 14:40:55 +01:00
Jan Janssen b2ba8511e6 meson: Remove test-efi-create-disk.sh
The script was probably not used for a very long time. It is currently
passed systemd_boot.so as boot loader, which cannot work. The test
entries it creates are all pointing at non-existant efi/linux binaries,
which means they would not even show up in the menu if the created image
were actually booted. There is also nothing that actually tries to run
the image in the first place.

If we end up creating a proper systemd-boot test suite, it would be
better to start from scratch. In the meantime, mkosi already covers
the bare minimum with a simple bootup test.
2022-01-26 14:40:51 +01:00
Jan Janssen 76fb85316e boot: Only build with debug symbols in developer mode
The debug symbols are of very limited use in proper deployments
unlike with regular userspace. Unless someone goes through the pain
of setting up an EFI debugger (assuming their firmware even supports
this in the first place) any provided debug symbols will just be
useless.
Debugging under QEMU is possible, but even then it is non-trivial
to set up, so anyone willing to go that far can just build in
developer mode.

Meanwhile, at least x86 firmware tends to refuse binaries that contain
debug symbols. We do strip the files when converted to PE anyway, but
the elf file needs to stay around on other arches as objcopy does not
support PE as input there.

Also, the generated debug symbols seem to be not reproducible when
building with LTO. Whether this is an issue in tooling or our side
is unclear. This works around this issue.

Fixes: #22157
2022-01-21 23:11:36 +00:00
Jan Janssen 1e11b6a76d meson: Add missing boot headers and use @INPUT@ for linking 2022-01-21 08:48:17 +09:00
Jan Janssen 1bc8417cfe boot: Use -ffile-prefix-map when present
This should make sure the stub elf binary is reproducible.

Fixes: #22157
2022-01-19 21:06:24 +00:00
Yu Watanabe edaca18739 Merge pull request #22161 from kreijack/ignore-boot-entries
bootctl: Ignore boot entries (continue #22041)
2022-01-19 14:43:10 +09:00
Goffredo Baroncelli 2fbf50d675 bootctl: removed unused parameter only_auto
Remove the parameter 'only_auto' from the function
boot_entries_augment_from_loader() because each caller set it always to
true.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
2022-01-18 19:32:35 +01:00
Goffredo Baroncelli 9914d89b51 bootctl: ignore the bootloader boot entries
When bootctl lists the boot entries, considers also the ones
returned by systemd-boot (via the efi LoaderEntries variable),
created at boot time.

Unfortunately this list may became incorrect if (e.g.) the user remove a
kernel package.

This patch changes this behaviour, so bootctl ignores some the
boot entries returned by systemd-boot.

In any case, bootctl still considers the 'auto-xxx' boot entries
listed below:

  Boot entrie name                 Title
  -----------------------------    ------------------------------
  auto-osx                         macOS boot loader
  auto-windows                     Windows Boot Manager
  auto-efi-shell                   EFI Shell
  auto-efi-default                 EFI Default Loader
  auto-reboot-to-firmware-setup    Reboot Into Firmware Interface

The other entries that systemd-boot synthetizes (e.g. the ones loaded from
/efi/loader/entries/<uuid>) can be synthetized by bootctl too, so no
information is lost.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
2022-01-18 19:32:35 +01:00
Jan Janssen 9e814b7715 boot: Pass around HARDDRIVE_DEVICE_PATH 2022-01-18 16:20:09 +01:00
Jan Janssen d81edd5ad7 boot: Simplify looking for the xboot hard drive
The device path should not contain multiple hard drive nodes in it,
so looking at them all should not be needed.
If some crazy firmware/driver were to make nested GPT drives
available like that, we should be only looking at the last partition
and its containing GPT drive anyway.
2022-01-18 16:20:09 +01:00
Jan Janssen 45a24eb7e9 boot: Search for the partition node directly
Some firmware creates partition device paths without a messaging
device path node, making the search for the xboot loader partition
fail.

Fixes: #17756
2022-01-18 16:20:09 +01:00
Jan Janssen cc25bedb29 boot: Beep n times for n-th entry 2022-01-17 00:05:35 +00:00
Jan Janssen 85d2f13b6f boot: Add PC speaker support
Fixes: #17508
2022-01-16 10:34:01 +00:00
Jan Janssen 2d1ac308c5 boot: Use FreePool from boot services directly
This should hopefully allow the compiler to optimize this a bit even
when gnu-efi is not compiled with LTO.
2022-01-13 14:30:51 +01:00
Jan Janssen 27c106bab8 boot: Add missing assert to file_read() 2022-01-13 14:30:51 +01:00
Jan Janssen e1e086d1f7 boot: Use _cleanup_ in shim
Also, better be safe than sorry and check the return value.
2022-01-13 14:30:51 +01:00
Jan Janssen acd28f3912 boot: Don't try to free loaded_image
EFI_LOADED_IMAGE is a protocol pointer and thus, we shouldn't try
to free it.
2022-01-13 14:29:46 +01:00
Jan Janssen 85eb489e23 boot: Use EFI_FILE* instead of EFI_FILE_HANDLE
They are both the same, but the former is shorter and also closer
to how file handles are represented in the UEFI spec.
2022-01-13 14:26:43 +01:00
Jan Janssen 41b74a18b2 boot: Fix invalid free
LocateDevicePath() advances the device path pointer, making it invalid
when freed.
2022-01-13 14:19:32 +01:00
Yu Watanabe 2ebb69bc09 boot: add missing error check
Follow-up for 661615a0af.

Fixes CID#1468973.
2022-01-13 14:17:15 +01:00
Luca Boccassi e80b51dad2 Merge pull request #22043 from medhefgo/boot-bitlocker
boot: Add BitLocker TPM key sealing workaround
2022-01-12 13:05:30 +00:00
Yu Watanabe d5ff7bdbb7 Merge pull request #22088 from medhefgo/meson
meson: Small improvements
2022-01-12 22:01:27 +09:00
Jan Janssen 68a06b3cdf meson: Add check argument to remaining run_command() calls 2022-01-11 14:56:30 +01:00
Jan Janssen bbec46c817 meson: Use files() for fuzzers
Not having to provide the full path in the source tree is much
nicer and the produced lists can also be used anywhere in the source
tree.
2022-01-11 14:15:54 +01:00
Jan Janssen e1eeebbb11 meson: Use files() for tests
Not having to provide the full path in the source tree is much
nicer and the produced lists can also be used anywhere in the source
tree.
2022-01-11 14:15:54 +01:00
Zbigniew Jędrzejewski-Szmek 49927ad813 bootctl: do not update sd-boot if it wasn't installed in the first place
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2038289.
2022-01-11 10:57:36 +01:00