summaryrefslogtreecommitdiff
path: root/src/boot
Commit message (Collapse)AuthorAgeFilesLines
* dissect-image: port mount_image_privately_interactively() to use ↵Lennart Poettering2023-05-161-3/+3
| | | | | | | | | | /run/systemd/mount-rootfs/ too Let's use the same common directory as the unit logic uses. This means we have less to clean up, and opens the door to eventually allow unprivileged operation of the mount_image_privately_interactively() logic.
* test/60-ukify: override stub location in testsZbigniew Jędrzejewski-Szmek2023-05-051-1/+5
| | | | Without this, build would fail if the stub is not available in /usr/lib/.
* boot: Use correct memory type for allocationsJan Janssen2023-05-021-1/+1
| | | | | | | | | | | | | | | | We were using the wrong memory type when allocating pool memory. This does not seem to cause a problem on x86, but the kernel will fail to boot at least on ARM in QEMU. This is caused by mixing different allocation types which ended up breaking the kernel or EDK2 during boot services exit. Commit 2f3c3b0bee5534f2338439f04b0aa517479f8b76 appears to fix this boot failure because it was replacing the gnu-efi xpool_print with xasprintf thereby unifying the allocation type. But this same issue can also happen without this fix somehow when the random-seed logic is in use. Fixes: #27371
* stub: Relocate kernels below 4G for EFI handoverJan Janssen2023-05-011-8/+20
| | | | | | | Old kernels can fail to boot when they are located above the 4G boundary even if they claim to support it. Fixes: #27472
* boot: Fix EFI_SIZE_TO_PAGES macroJan Janssen2023-05-011-1/+1
|
* Merge pull request #27113 from keszybz/variable-expansion-reworkZbigniew Jędrzejewski-Szmek2023-04-241-4/+5
|\ | | | | Rework serialization of command lines in pid1 and make run not expand variables
| * basic/logarithm: add popcount() wrapperZbigniew Jędrzejewski-Szmek2023-04-241-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | __builtin_popcount() is a bit of a mouthful, so let's provide a helper. Using _Generic has the advantage that if a type other then the ones on the list is given, compilation will fail. This is nice, because if by any change we pass a wider type, it is rejected immediately instead of being truncated. log.h is also needed. It is included transitively, but let's include it directly. macro.h is *not* needed.
* | stub: add comment on measurement of io.systemd.stub.kernel-cmdline-extraLuca Boccassi2023-04-241-0/+1
| |
* | Merge pull request #27256 from medhefgo/boot-rdtscLennart Poettering2023-04-181-28/+57
|\ \ | | | | | | boot: Improve timer frequency detection
| * | boot: Use CPUID to detect TSC frequencyJan Janssen2023-04-131-1/+30
| | | | | | | | | | | | | | | Aside from being more accurate on CPUs that report the information this is also orders of magnitude faster than sleeping for 1ms.
| * | boot: Rework timer frquency readingJan Janssen2023-04-131-18/+31
| | | | | | | | | | | | This is in preparation for the next commit.
| * | boot: Use compiler intrinsic for TSCJan Janssen2023-04-131-15/+2
| | |
* | | tree-wide: replace __alignof__() with alignof()Yu Watanabe2023-04-141-1/+1
|/ / | | | | | | Addresses https://github.com/systemd/systemd/pull/27254#discussion_r1165267046.
* | image-policy: introduce parse_image_policy_argument() helperYu Watanabe2023-04-131-14/+8
| | | | | | | | | | | | | | | | | | Addresses https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1060130312, https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067927293, and https://github.com/systemd/systemd/pull/25608/commits/84be0c710d9d562f6d2cf986cc2a8ff4c98a138b#r1067926416. Follow-up for 84be0c710d9d562f6d2cf986cc2a8ff4c98a138b.
* | Merge pull request #27217 from yuwata/boot-entry-atYu Watanabe2023-04-121-0/+1
|\ \ | | | | | | boot-entry: introduce _at() variant
| * | boot-entry: prioritize machine ID only when it is not randomly generatedYu Watanabe2023-04-121-0/+1
| | | | | | | | | | | | | | | Preparation for later commits. The parameter will be used in kernel-install later.
* | | Merge pull request #25608 from poettering/dissect-moarLennart Poettering2023-04-122-0/+21
|\ \ \ | |/ / |/| | dissect: add dissection policies
| * | tree-wide: hook up image dissection policy logic everywhereLennart Poettering2023-04-052-0/+21
| | |
* | | boot: Fix alignment of long long inside structs on x86Jan Janssen2023-04-112-4/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On x86 EFI follows the windows ABI, which expects 8-byte aligned long long. The x86 sysv ELF ABI expects them to be 8-byte aligned when used alone, but 4-byte aligned when they appear inside of structs: struct S { int i; long long ll; }; // _Static_assert(sizeof(struct S) == 12, "x86 sysv ABI"); _Static_assert(sizeof(struct S) == 16, "EFI/MS ABI"); To get the behavior we need when building with sysv ELF ABI we need to pass '-malign-double' to the compiler as done by EDK2. This in turn will make ubsan unhappy as the stack may not be properly aligned on entry, so we have to tell the compiler explicitly to re-align the stack on entry to efi_main. This fixes loading EFI drivers on x86 that were previously always rejected as the EFI_LOADED_IMAGE_PROTOCOL had a wrong memory layout. See also: https://github.com/rhboot/shim/pull/516
* | | kernel-image: make inspect_kernel() optionally take directory fdYu Watanabe2023-04-091-2/+4
| | |
* | | bootctl: Gracefully handle missing bootloader directoryDaan De Meyer2023-04-071-0/+4
|/ / | | | | | | | | When --graceful is specified, let's gracefully deal with a missing bootloader directory.
* | various: simplify calls to parse_boolean_argument()Zbigniew Jędrzejewski-Szmek2023-04-051-4/+4
|/ | | | | parse_boolean_argument() returns the same information via both the output argument and normal return.
* bootctl: clean up handling of files with no version informationZbigniew Jędrzejewski-Szmek2023-03-303-31/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | get_file_version() would return: - various negative errors if the file could not be accessed or if it was not a regular file - 0/NULL if the file was too small - -ESRCH or -EINVAL if the file did not contain the marker - -ENOMEM or permissions errors - 1 if the marker was found bootctl status iterates over /EFI/{systemd,BOOT}/*.efi and checks if the files contain a systemd-boot version tag. Resource or permission errors should be fatal, but lack of version information should be silently ignored. OTOH, when updating or installing bootloader files, the version is expected to be present. get_file_version() is changed to return -ESRCH if the version is unavailable, and other errnos for permission or resource errors. The logging is reworked to always display an error if encountered, but also to log the status at debug level what the result of the version inquiry is. This makes it figure out what is going on: /efi/EFI/systemd/systemd-bootx64.efi: EFI binary LoaderInfo marker: "systemd-boot 253-6.fc38" /efi/EFI/BOOT/BOOTfbx64.efi: EFI binary has no LoaderInfo marker. /efi/EFI/BOOT/BOOTIA32.EFI: EFI binary has no LoaderInfo marker. /efi/EFI/BOOT/BOOTX64.EFI: EFI binary LoaderInfo marker: "systemd-boot 253-6.fc38" Replaces #27034. Fixes https://github.com/NixOS/nixpkgs/issues/223579.
* bootctl: split-out entry token related definitions into boot-entry.[ch]Yu Watanabe2023-03-274-125/+17
| | | | | | | | | | No functional change, just preparation for later commits. These can be used in kernel-install later. Note, unlike the our usual coding style, the arguments for boot_entry_token_ensure() and parse_boot_entry_token_type() are referenced, updated, and may freed, hence, always pass initialized values. That's why they are not named as 'ret_xyz'.
* bootctl: enable colored loggingYu Watanabe2023-03-251-2/+1
|
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-243-18/+18
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* bootctl: 'graceful' should ignore EFI variable failuresKevin P. Fleming2023-03-221-9/+22
| | | | | | | Suppress errors when creating/writing EFI variables during 'bootctl update' if '--graceful' mode is active (as the documentation indicates). Closes #26773.
* util: rename uki-util.[ch] -> kernel-image.[ch]Yu Watanabe2023-03-211-1/+1
| | | | As the file contains functions not only for UKI.
* uki-util: rename KernelType -> KernelImageTypeYu Watanabe2023-03-211-4/+4
| | | | | The name KernelType is slightly ambiguous. The type is about kernel image. Let's rename the enum to clarify that.
* bootctl: fix wrong type comparisonYu Watanabe2023-03-201-1/+1
|
* Merge pull request #26759 from medhefgo/boot-stack-protectorYu Watanabe2023-03-187-19/+140
|\ | | | | boot: Add support for stack protector/trapping math/ubsan
| * boot: Add undefined sanitizer supportJan Janssen2023-03-174-5/+62
| | | | | | | | Sadly, no stack traces, but this is better than nothing.
| * meson: Share more C flagsJan Janssen2023-03-174-6/+14
| |
| * boot: Add support for -ftrapvJan Janssen2023-03-172-1/+6
| |
| * boot: Add support for -fstack-protectorJan Janssen2023-03-174-2/+40
| |
| * boot: Detect nested assertionsJan Janssen2023-03-171-5/+18
| |
* | uki-util: move functions for inspecting kernel to uki-util.[ch]Yu Watanabe2023-03-171-300/+2
| |
* | bootctl: introduce inspect_kernel()Yu Watanabe2023-03-171-39/+87
| | | | | | | | | | Then, now verb_kernel_identify() and verb_kernel_inspect() can share most of the code.
* | bootctl: introduce uki_read_pretty_name()Yu Watanabe2023-03-171-11/+36
| | | | | | | | No functional change, just prepration for later commits.
* | bootctl: find matching section in read_pe_section()Yu Watanabe2023-03-171-11/+33
| | | | | | | | No functional change, just refactoring.
* | bootctl: return 0 instead of EXIT_SUCCESSYu Watanabe2023-03-173-4/+4
| |
* | bootctl: move verb_kernel_identity()Yu Watanabe2023-03-171-24/+24
|/ | | | No functional change, just for making beautify later diffs.
* Merge pull request #26784 from DaanDeMeyer/chase-fixDaan De Meyer2023-03-152-2/+2
|\ | | | | Allow creating files and directories with chase_symlinks_open() and further improvements
| * chase-symlinks: Remove unused ret_fd argumentsDaan De Meyer2023-03-142-2/+2
| |
* | fs-util: Drop unlink_noerrno()Daan De Meyer2023-03-151-4/+5
| |
* | stub: Remove overlapping PE section warningJan Janssen2023-03-151-8/+0
|/ | | | | | | | | Now that we always create PE images with a non-zero image base we cannot run into this issue anymore. Any tool that still uses the old hard-coded section offsets will end up creating bad images with sections below the image base. objcopy will warn about this and any PE loader will simply refuse to load such an image. Meanwhile updated tools do not use hard-coded offsets anymore.
* sd-boot: fix incompatible typeYu Watanabe2023-03-121-1/+1
| | | | | | | | | | Fixes the following build error: ``` ../src/boot/efi/vmm.c: In function ‘get_smbios_table’: ../src/boot/efi/vmm.c:217:24: error: incompatible types when returning type ‘_Bool’ but ‘const SmbiosHeader *’ was expected 217 | return false; | ^~~~~ ```
* Merge pull request #26641 from medhefgo/boot-elf2efiYu Watanabe2023-03-117-414/+244
|\ | | | | boot: Drop gnu-efi / Add elf2efi.py
| * meson: Use static library for EFI testsJan Janssen2023-03-101-40/+49
| | | | | | | | This also moves them so that fuzz builds do not need pyelftools around.
| * boot: Fix unused function warningJan Janssen2023-03-101-0/+2
| |