Skip to content

Commit b4df573

Browse files
committed
redhat: Directly use 'ukify' for building the UKI
Upstream Status: RHEL only JIRA: https://issues.redhat.com/browse/RHEL-109610 dracut-107 switched to calling 'ukify' directly and this causes several issues: 1) '--uname' is not passed to 'ukify' by dracut, this triggers version autodetection which breaks on -debug kernels with e.g. Kernel version not specified, starting autodetection 😖. Cannot parse version-host-release uname string: b'6.17.0-0.rc2.24.fc44.x86_64+debug (mockbuild@fb2dab7653d446e38a376a74fe4e22a2) #1 SMP PREEMPT_DYNAMIC Mon Aug 18 16:54:37 UTC 20' + readelf --notes /builddir/build/BUILD/kernel-6.17.0-build/kernel-6.17-rc2/linux-6.17.0-0.rc2.24.fc44.x86_64/arch/x86/boot/bzImage readelf: Error: Not an ELF file - it has the wrong magic bytes at the start Cannot find b'Linux version (?P<version>\\d\\.\\S+) \\(' in /builddir/build/BUILD/kernel-6.17.0-build/kernel-6.17-rc2/linux-6.17.0-0.rc2.24.fc44.x86_64/arch/x86/boot/bzImage 2) 'ukify' expects SBAT data to begin with the standard 'sbat,1,SBAT Version,sbat,1,...' line but for kernel-uki-virt we only pass the addon ('kernel-uki-virt.<suffix>,1,...') as the header comes through systemd-stub. This leads to /var/tmp/dracut.dzt9WSC/uefi/uki.sbat does not contain a valid SBAT section, skipping. While it is possible to solve 2) by altering our SBAT data, 1) requires a dracut fix (dracut-ng/dracut-ng#1594). As there's no real benefit in using the dracut wrapper, switch to calling 'ukify' explicitly. Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
1 parent 638f86f commit b4df573

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

redhat/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ sources-rh: $(TARBALL) $(KABI_TARBALL) $(KABIDW_TARBALL) generate-testpatch-tmp
761761
README.rst \
762762
kernel-local \
763763
dracut-virt.conf \
764+
uki.sbat.template \
765+
uki-addons.sbat.template \
764766
$(SOURCES)/
765767
@changelog_glob="$(SPECPACKAGE_NAME).changelog-*"; \
766768
[[ -n "$(AUTOMOTIVE_BUILD)" ]] && changelog_glob="kernel.changelog-*"; \

redhat/kernel.spec.template

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,17 @@ Summary: The Linux kernel
108108
%global signkernel 0
109109
%endif
110110

111+
# RHEL/CentOS/Fedora specific .SBAT entries
112+
%if 0%{?centos}
113+
%global sbat_suffix centos
114+
%else
115+
%if 0%{?fedora}
116+
%global sbat_suffix fedora
117+
%else
118+
%global sbat_suffix rhel
119+
%endif
120+
%endif
121+
111122
# Sign modules on all arches
112123
%global signmodules 1
113124

@@ -989,6 +1000,9 @@ Source77: partial-clang_lto-aarch64-debug-snip.config
9891000
Source80: generate_all_configs.sh
9901001
Source81: process_configs.sh
9911002

1003+
Source83: uki.sbat.template
1004+
Source84: uki-addons.sbat.template
1005+
9921006
Source86: dracut-virt.conf
9931007

9941008
Source87: flavors
@@ -1977,6 +1991,10 @@ rm -f localversion-next localversion-rt
19771991
Documentation \
19781992
scripts/clang-tools 2> /dev/null
19791993

1994+
# SBAT data
1995+
sed -e s,@KVER,%{KVERREL}, -e s,@SBAT_SUFFIX,%{sbat_suffix}, %{SOURCE83} > uki.sbat
1996+
sed -e s,@KVER,%{KVERREL}, -e s,@SBAT_SUFFIX,%{sbat_suffix}, %{SOURCE84} > uki-addons.sbat
1997+
19801998
# only deal with configs if we are going to build for the arch
19811999
%ifnarch %nobuildarches
19822000

@@ -2736,19 +2754,9 @@ BuildKernel() {
27362754
SBATsuffix="rhel"
27372755
%endif
27382756
%endif
2739-
SBAT=$(cat <<- EOF
2740-
kernel-uki-virt.$SBATsuffix,1,Red Hat,kernel-uki-virt,$KernelVer,mailto:secalert@redhat.com
2741-
EOF
2742-
)
2743-
2744-
ADDONS_SBAT=$(cat <<- EOF
2745-
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2746-
kernel-uki-virt-addons.$SBATsuffix,1,Red Hat,kernel-uki-virt-addons,$KernelVer,mailto:secalert@redhat.com
2747-
EOF
2748-
)
2749-
27502757
KernelUnifiedImageDir="$RPM_BUILD_ROOT/lib/modules/$KernelVer"
27512758
KernelUnifiedImage="$KernelUnifiedImageDir/$InstallName-virt.efi"
2759+
KernelUnifiedInitrd="$KernelUnifiedImageDir/$InstallName-virt.img"
27522760

27532761
mkdir -p $KernelUnifiedImageDir
27542762

@@ -2758,15 +2766,17 @@ BuildKernel() {
27582766
--kver "$KernelVer" \
27592767
--kmoddir "$RPM_BUILD_ROOT/lib/modules/$KernelVer/" \
27602768
--logfile=$(mktemp) \
2761-
--uefi \
2762-
--sbat "$SBAT" \
2763-
--kernel-image $(realpath $KernelImage) \
2764-
--kernel-cmdline 'console=tty0 console=ttyS0' \
2765-
$KernelUnifiedImage
2769+
$KernelUnifiedInitrd
2770+
2771+
ukify build --linux $(realpath $KernelImage) --initrd $KernelUnifiedInitrd \
2772+
--sbat @uki.sbat --os-release @/etc/os-release --uname $KernelVer \
2773+
--cmdline 'console=tty0 console=ttyS0' --output $KernelUnifiedImage
2774+
2775+
rm -f $KernelUnifiedInitrd
27662776

27672777
KernelAddonsDirOut="$KernelUnifiedImage.extra.d"
27682778
mkdir -p $KernelAddonsDirOut
2769-
python3 %{SOURCE151} %{SOURCE152} $KernelAddonsDirOut virt %{primary_target} %{_target_cpu} "$ADDONS_SBAT"
2779+
python3 %{SOURCE151} %{SOURCE152} $KernelAddonsDirOut virt %{primary_target} %{_target_cpu} @uki-addons.sbat
27702780

27712781
%if %{signkernel}
27722782
%{log_msg "Sign the EFI UKI kernel"}

redhat/uki-addons.sbat.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2+
kernel-uki-virt-addons.@SBAT_SUFFIX,1,Red Hat,kernel-uki-virt-addons,@KVER,mailto:secalert@redhat.com

redhat/uki.sbat.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md
2+
kernel-uki-virt.@SBAT_SUFFIX,1,Red Hat,kernel-uki-virt,@KVER,mailto:secalert@redhat.com

0 commit comments

Comments
 (0)