Provide measured boot via fTPM for arm64, early deploy EFI certificates
v2 cover Provide measured boot via fTPM for arm64, early deploy EFI certificates
Due to some deficits in U-Boot, the fTPM was not recognized and, thus, its PCRs for measurements were not fed. This led to the disk encryption key we are storing in the TPM not being sealed properly. Existing deployments were most likely not affected by this when they locked down U-Boot to only boot in secure mode (like we did and continue to do).
After fixing this, we are confronted with a practical problem: The QEMU target for arm64 is set up without pre-deployed UEFI certificates. When we now, with working measurements, switch to secure boot after the initial disk encryption, unsealing the key will no longer work.
For this but possibly also for other scenarios, the series adds an initramfs hook which tries to deploy the secure boot certs if the target is in non-secure mode and no other certs are deployed yet.
With all that in place, we change the policy of the disk encryption hook to only perform its task when the device is securely booted. If this should break valid downstream scenarios, we may make it opt-out later on, but so far none are imaginable.
Changes in v2:
- general renaming "EFI keys" -> "EFI certs"
Jan
Jan Kiszka (7):
secure-boot-efi-keys: Add recipe to create EFI certificates
cip-initramfs-functions: Add secure_boot_enabled helper
cip-core-initramfs: Automatically deploy EFI secure boot certificates
on first boot
u-boot: Add patches to enable measured boot with fTPM
u-boot: Refactor ftpm-stmm.cfg to enable measured boot for all
u-boot: Drop obsolete config workaround
initramfs-crypt-hook: Prevent encryption without secure boot
...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 95 +++++++++++ ...pport-for-enumerating-services-that-.patch | 155 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 33 ++++ ...to-optee-after-a-successful-mmc_init.patch | 41 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 50 ++++++ recipes-bsp/u-boot/files/ftpm-stmm.cfg | 7 +- recipes-bsp/u-boot/files/qemu-extra.cfg | 2 + recipes-bsp/u-boot/files/secure-boot.cfg | 2 - recipes-bsp/u-boot/files/ti-extra.cfg | 8 +- recipes-bsp/u-boot/u-boot-common-2026.01.inc | 6 + .../single-key-to-efi-certs_0.1.bb | 41 +++++ .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../files/cip-initramfs-functions | 16 ++ .../files/local-top-complete | 4 + .../initramfs-sbcerts-hook/files/hook | 16 ++ .../initramfs-sbcerts-hook/files/local-top | 34 ++++ .../initramfs-sbcerts-hook/files/mount-stub | 13 ++ .../initramfs-sbcerts-hook_0.1.bb | 32 ++++ 19 files changed, 589 insertions(+), 10 deletions(-) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch create mode 100644 recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbcerts-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/initramfs-sbcerts-hook_0.1.bb
Signature · 1 line
2.47.3
PATCH v2 1/7 secure-boot-efi-keys: Add recipe to create EFI certificates
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-certs" which could also be offered by an alternative recipe/package that picks up differently generated certificates and/or a proper hierarchy.
--- .../single-key-to-efi-certs_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +41 -0
@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI certificates from single secure boot key" + +PROVIDES += "secure-boot-efi-certs" +DEBIAN_PROVIDES = "secure-boot-efi-certs" + +DEPENDS = "secure-boot-secrets" +DEBIAN_BUILD_DEPENDS .= ", secure-boot-secrets, efitools" + +do_prepare_build() { + deb_debianize + + cat <<EOF > ${S}/debian/${BPN}.install +db.auth usr/share/secure-boot-efi-certs +KEK.auth usr/share/secure-boot-efi-certs +PK.auth usr/share/secure-boot-efi-certs +EOF + + cat <<EOF >> ${S}/debian/rules + +override_dh_auto_build: + cert-to-efi-sig-list /usr/share/secure-boot-secrets/secure-boot.pem PK.esl + sign-efi-sig-list -k /usr/share/secure-boot-secrets/secure-boot.key \ + -c /usr/share/secure-boot-secrets/secure-boot.pem PK PK.esl PK.auth + cp PK.auth KEK.auth + cp PK.auth db.auth +EOF +}
Signature · 1 line
2.47.3
Re: [cip-dev] [isar-cip-core][PATCH v2 1/7] secure-boot-efi-keys: Add recipe to create EFI certificates
Quoted 22 lines · Jan Kiszka via lists.cip-project.org
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-certs" which could also be offered by an alternative recipe/package that picks up differently generated certificates and/or a proper hierarchy.
Signed-off-by Jan Kiszka <[email protected]>--- .../single-key-to-efi-certs_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bbrecipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +2
-0@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb line 12
Quoted 10 lines
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +10
-0+# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit dpkg
Hi, please either use dpkg-raw, or set DPKG_ARCH = "all", as this package does not depend on the architecture of the target.
Felix
Quoted 31 lines
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +29
-0+ +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Generate EFI certificates from single secure boot key" + +PROVIDES += "secure-boot-efi-certs" +DEBIAN_PROVIDES = "secure-boot-efi-certs" + +DEPENDS = "secure-boot-secrets" +DEBIAN_BUILD_DEPENDS .= ", secure-boot-secrets, efitools" + +do_prepare_build() { + deb_debianize + + cat <<EOF > ${S}/debian/${BPN}.install +db.auth usr/share/secure-boot-efi-certs +KEK.auth usr/share/secure-boot-efi-certs +PK.auth usr/share/secure-boot-efi-certs +EOF + + cat <<EOF >> ${S}/debian/rules + +override_dh_auto_build: + cert-to-efi-sig-list /usr/share/secure-boot-secrets/secure-boot.pem PK.esl + sign-efi-sig-list -k /usr/share/secure-boot-secrets/secure-boot.key \ + -c /usr/share/secure-boot-secrets/secure-boot.pem PK PK.esl PK.auth + cp PK.auth KEK.auth + cp PK.auth db.auth +EOF +}Signature · 1 line
2.47.3
Re: [cip-dev] [isar-cip-core][PATCH v2 1/7] secure-boot-efi-keys: Add recipe to create EFI certificates
Quoted 29 lines · Felix (FT RPD CED OES-DE)
Quoted 27 lines · Jan Kiszka via lists.cip-project.org
From: Jan Kiszka <[email protected]>
This recipe allows to derive the PK, KEK and db values from a single signing key as we are using for demonstration/testing purposes and simple scenarios. The recipe provides abstract "secure-boot-efi-certs" which could also be offered by an alternative recipe/package that picks up differently generated certificates and/or a proper hierarchy.
Signed-off-by Jan Kiszka <[email protected]>--- .../single-key-to-efi-certs_0.1.bb | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bbrecipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +7
-0@@ -0,0 +1,41 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]>
Quoted 9 lines
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb line 12
Quoted 5 lines
recipes-devtools/secure-boot-efi-certs/single-key-to-efi-certs_0.1.bb new file +5
-0+# +# SPDX-License-Identifier: MIT +# + +inherit dpkgHi, please either use dpkg-raw, or set
DPKG_ARCH= "all", as this package does not depend on the architecture of the target.
Added
DPKG_ARCH = "all"
in next.
Thanks,
Jan
Signature · 2 lines
Siemens AG, Foundational Technologies Linux Expert Center
PATCH v2 2/7 cip-initramfs-functions: Add secure_boot_enabled helper
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Will allow initramfs hooks to determine whether UEFI secure boot is enabled. The user is responsible for deploying cmp and mountpoint binaries into the initramfs.
--- .../files/cip-initramfs-functions | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
recipes-initramfs/initramfs-cip-functions/files/cip-initramfs-functions +16 -0
@@ -68,3 +68,19 @@ scan_for_partitions() { fi return 1 } + +# check if system was securely booted via UEFI +secure_boot_enabled() { + efivars=/sys/firmware/efi/efivars + if ! mountpoint -q $efivars; then + mount -t efivarfs none $efivars + fi + + secure_boot="$efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c" + setup_mode="$efivars/SetupMode-8be4df61-93ca-11d2-aa0d-00e098032b8c" + if printf '\001' | cmp -s -i 4:0 $secure_boot && + printf '\000' | cmp -s -i 4:0 $setup_mode; then + return 0 + fi + return 1 +}
Signature · 1 line
2.47.3
PATCH v2 3/7 cip-core-initramfs: Automatically deploy EFI secure boot certificates on first boot
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
This both simplifies the initial deployment of secure boot to a device as well as makes sure that we will always seal the disk encryption key against the right state.
We only deploy if secure boot is off and the db is found empty. So this hook is not intended to be used for key exchange or db extensions. The former will be once handled via SWUpdate packages, the latter might be considered given a concrete use case.
Note that due to the primitive implementation of efivarfs detection in efitools, we need to deploy a horrible hack to make it work against the mount implementation of busybox in the initramfs. A patch to improve that issue is pending upstream.
--- .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../initramfs-sbcerts-hook/files/hook | 16 +++++++++ .../initramfs-sbcerts-hook/files/local-top | 34 +++++++++++++++++++ .../initramfs-sbcerts-hook/files/mount-stub | 13 +++++++ .../initramfs-sbcerts-hook_0.1.bb | 32 +++++++++++++++++ 5 files changed, 96 insertions(+) create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbcerts-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/initramfs-sbcerts-hook_0.1.bb
recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb +1 -0
@@ -22,6 +22,7 @@ INITRAMFS_INSTALL:append:factory-reset = " initramfs-factory-reset-hook" INITRAMFS_INSTALL:append:ftpm-stmm = " initramfs-tee-ftpm-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-abrootfs-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-${RO_ROOTFS_TYPE}-hook" +INITRAMFS_INSTALL:append:secureboot = " initramfs-sbcerts-hook" INITRAMFS_INSTALL:append:secureboot = " initramfs-verity-hook" # abrootfs cannot be installed together with verity INITRAMFS_INSTALL:remove:secureboot = "initramfs-abrootfs-hook"
recipes-initramfs/initramfs-sbcerts-hook/files/hook new file +16 -0
@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +copy_file binary /usr/share/secure-boot-efi-certs/db.auth +copy_file binary /usr/share/secure-boot-efi-certs/KEK.auth +copy_file binary /usr/share/secure-boot-efi-certs/PK.auth + +copy_file binary /usr/share/initramfs-sbcerts-hook/mount
recipes-initramfs/initramfs-sbcerts-hook/files/local-top new file +34 -0
@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +. /scripts/cip-initramfs-functions + +if secure_boot_enabled; then + exit 0 +fi + +ORIG_PATH="$PATH" +export PATH="/usr/share/initramfs-sbcerts-hook:$PATH" + +if ! efi-readvar -v db | grep -q "has no entries"; then + export PATH="$ORIG_PATH" + log_warning_msg "Not securely booting, but certificates already deployed" + exit 0 +fi + +log_begin_msg "Deploying EFI secure boot certificates" +efi-updatevar -f /usr/share/secure-boot-efi-certs/db.auth db +efi-updatevar -f /usr/share/secure-boot-efi-certs/KEK.auth KEK +efi-updatevar -f /usr/share/secure-boot-efi-certs/PK.auth PK +log_end_msg + +log_success_msg "Rebooting after certificate deployment..." +reboot
recipes-initramfs/initramfs-sbcerts-hook/files/mount-stub new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +echo "none on /sys/firmware/efi/efivars type efivarfs"
recipes-initramfs/initramfs-sbcerts-hook/initramfs-sbcerts-hook_0.1.bb new file +32 -0
@@ -0,0 +1,32 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit initramfs-hook + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Initramfs hook to deploy UEFI secure boot certificates during early boot" + +DEPENDS = "secure-boot-efi-certs initramfs-cip-functions" +DEBIAN_DEPENDS .= ", secure-boot-efi-certs, efitools, initramfs-cip-functions" + +HOOK_COPY_EXECS = "cmp mountpoint efi-readvar efi-updatevar grep" + +HOOK_ADD_MODULES = "efivarfs" + +SRC_URI += " \ + file://hook \ + file://local-top \ + file://mount-stub" + +do_install[cleandirs] += "${D}/usr/share/${BPN}" +do_install:append() { + install "${WORKDIR}/mount-stub" "${D}/usr/share/${BPN}/mount" +}
Signature · 1 line
2.47.3
Re: [isar-cip-core][PATCH v2 3/7] cip-core-initramfs: Automatically deploy EFI secure boot certificates on first boot
Am 26.08.2026 um 17:20 schrieb Jan Kiszka:
Quoted 11 lines
From: Jan Kiszka <[email protected]>
This both simplifies the initial deployment of secure boot to a device as well as makes sure that we will always seal the disk encryption key against the right state.
We only deploy if secure boot is off and the db is found empty. So this hook is not intended to be used for key exchange or db extensions. The former will be once handled via SWUpdate packages, the latter might be considered given a concrete use case.
Quoted 6 lines
Note that due to the primitive implementation of efivarfs detection in efitools, we need to deploy a horrible hack to make it work against the mount implementation of busybox in the initramfs. A patch to improve that issue is pending upstream.
Signed-off-by Jan Kiszka <[email protected]>
Although already applied to master, but for sake of completeness:
Quoted 143 lines
--- .../cip-core-initramfs/cip-core-initramfs.bb | 1 + .../initramfs-sbcerts-hook/files/hook | 16 +++++++++ .../initramfs-sbcerts-hook/files/local-top | 34 +++++++++++++++++++ .../initramfs-sbcerts-hook/files/mount-stub | 13 +++++++ .../initramfs-sbcerts-hook_0.1.bb | 32 +++++++++++++++++ 5 files changed, 96 insertions(+)create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/hook create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/files/local-top create mode 100755 recipes-initramfs/initramfs-sbcerts-hook/files/mount-stub create mode 100644 recipes-initramfs/initramfs-sbcerts-hook/initramfs-sbcerts-hook_0.1.bb
recipes-initramfs/cip-core-initramfs/cip-core-initramfs.bb +1
-0@@ -22,6 +22,7 @@ INITRAMFS_INSTALL:append:factory-reset = " initramfs-factory-reset-hook" INITRAMFS_INSTALL:append:ftpm-stmm = " initramfs-tee-ftpm-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-abrootfs-hook" INITRAMFS_INSTALL:append:swupdate = " initramfs-${RO_ROOTFS_TYPE}-hook" +INITRAMFS_INSTALL:append:secureboot = " initramfs-sbcerts-hook" INITRAMFS_INSTALL:append:secureboot = " initramfs-verity-hook" # abrootfs cannot be installed together with verity INITRAMFS_INSTALL:remove:secureboot = "initramfs-abrootfs-hook"recipes-initramfs/initramfs-sbcerts-hook/files/hook new file +16
-0@@ -0,0 +1,16 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +copy_file binary /usr/share/secure-boot-efi-certs/db.auth +copy_file binary /usr/share/secure-boot-efi-certs/KEK.auth +copy_file binary /usr/share/secure-boot-efi-certs/PK.auth + +copy_file binary /usr/share/initramfs-sbcerts-hook/mountrecipes-initramfs/initramfs-sbcerts-hook/files/local-top new file +34
-0@@ -0,0 +1,34 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +. /scripts/cip-initramfs-functions + +if secure_boot_enabled; then + exit 0 +fi + +ORIG_PATH="$PATH" +export PATH="/usr/share/initramfs-sbcerts-hook:$PATH" + +if ! efi-readvar -v db | grep -q "has no entries"; then + export PATH="$ORIG_PATH" + log_warning_msg "Not securely booting, but certificates already deployed" + exit 0 +fi + +log_begin_msg "Deploying EFI secure boot certificates" +efi-updatevar -f /usr/share/secure-boot-efi-certs/db.auth db +efi-updatevar -f /usr/share/secure-boot-efi-certs/KEK.auth KEK +efi-updatevar -f /usr/share/secure-boot-efi-certs/PK.auth PK +log_end_msg + +log_success_msg "Rebooting after certificate deployment..." +rebootrecipes-initramfs/initramfs-sbcerts-hook/files/mount-stub new file +13
-0@@ -0,0 +1,13 @@ +#!/bin/sh +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +echo "none on /sys/firmware/efi/efivars type efivarfs"recipes-initramfs/initramfs-sbcerts-hook/initramfs-sbcerts-hook_0.1.bb new file +32
-0@@ -0,0 +1,32 @@ +# +# CIP Core, generic profile +# +# Copyright (c) Siemens AG, 2026 +# +# Authors: +# Jan Kiszka <[email protected]> +# +# SPDX-License-Identifier: MIT +# + +inherit initramfs-hook + +MAINTAINER = "cip-dev <[email protected]>" +DESCRIPTION = "Initramfs hook to deploy UEFI secure boot certificates during early boot" + +DEPENDS = "secure-boot-efi-certs initramfs-cip-functions" +DEBIAN_DEPENDS .= ", secure-boot-efi-certs, efitools, initramfs-cip-functions" + +HOOK_COPY_EXECS = "cmp mountpoint efi-readvar efi-updatevar grep" + +HOOK_ADD_MODULES = "efivarfs" + +SRC_URI += " \ + file://hook \ + file://local-top \ + file://mount-stub" + +do_install[cleandirs] += "${D}/usr/share/${BPN}" +do_install:append() { + install "${WORKDIR}/mount-stub" "${D}/usr/share/${BPN}/mount" +}
PATCH v2 4/7 u-boot: Add patches to enable measured boot with fTPM
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
U-Boot was so far not enumerating the fTPM device, and that caused the PCRs to stay zero. systemd-cryptenroll was complaining already, just not loud enough.
With these extra patches (currently under review upstream), we are getting a TPM right before the EFI loader starts, and we get valid PCR content as well.
--- ...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 95 +++++++++++ ...pport-for-enumerating-services-that-.patch | 155 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 33 ++++ ...to-optee-after-a-successful-mmc_init.patch | 41 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 50 ++++++ recipes-bsp/u-boot/u-boot-common-2026.01.inc | 6 + 7 files changed, 423 insertions(+) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch
recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch new file +43 -0
@@ -0,0 +1,43 @@ +From 1d9a066892b73d65129cb899c6ed611eb3d1c3bc Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Thu, 20 Aug 2026 17:30:54 +0200 +Subject: [PATCH 1/6] test: boot: measurement: Fix compilation for non-sandbox + builds +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +asm/io.h provides map_to_sysmem() only for the sandbox. Other targets +fail the build with + +../test/boot/measurement.c: In function ‘measure’: +../test/boot/measurement.c:30:33: error: implicit declaration of function ‘map_to_sysmem’; did you mean ‘map_physmem’? [-Wimplicit-function-declaration] + 30 | images.os.image_start = map_to_sysmem(kernel); + | ^~~~~~~~~~~~~ + | map_physmem + +Use the proper header that will pull asm/io.h only where needed. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + test/boot/measurement.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/boot/measurement.c b/test/boot/measurement.c +index 71f503f1567..85a01f1fec8 100644 +--- a/test/boot/measurement.c ++++ b/test/boot/measurement.c +@@ -9,9 +9,9 @@ + #include <bootm.h> + #include <env.h> + #include <malloc.h> ++#include <mapmem.h> + #include <test/test.h> + #include <test/ut.h> +-#include <asm/io.h> + + #define MEASUREMENT_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, measurement) +-- +2.47.3 +
recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch new file +95 -0
95 lines not on this page · raw message
recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch new file +155 -0
155 lines not on this page · raw message
recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch new file +33 -0
@@ -0,0 +1,33 @@ +From 13fc430cf440cdbc490bce630031ca49e81e1e13 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Fri, 21 Aug 2026 09:02:23 +0200 +Subject: [PATCH 4/6] tee: optee: Do not warn about + TEE_ERROR_STORAGE_NOT_AVAILABLE + +This is a transitional error that is resolved once an RPMB becomes +available. Keep it as debug output only. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + drivers/tee/optee/core.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c +index ed8f2b6ec74..d3b5811afb8 100644 +--- a/drivers/tee/optee/core.c ++++ b/drivers/tee/optee/core.c +@@ -106,7 +106,10 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm + + ret = tee_invoke_func(dev, &arg, 1, ¶m); + if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { +- dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ if (arg.ret != TEE_ERROR_STORAGE_NOT_AVAILABLE) ++ dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ else ++ dev_dbg(dev, "Enumeration command 0x%x failed due to unavailable storage\n", pta_cmd); + return -EINVAL; + } + +-- +2.47.3 +
recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch new file +41 -0
41 lines not on this page · raw message
recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch new file +50 -0
50 lines not on this page · raw message
recipes-bsp/u-boot/u-boot-common-2026.01.inc +6 -0
@@ -26,6 +26,12 @@ SRC_URI += " \ file://0001-riscv-create-a-custom-CPU-implementation-for-PolarFi.patch \ file://0002-riscv-mpfs-move-SoC-level-options-to-the-CPU-Kconfig.patch \ file://0003-riscv-Add-support-for-BeagleV-Fire.patch \ + file://0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch \ + file://0002-tee-optee-Factor-out-service-enumeration-and-binding.patch \ + file://0003-tee-optee-Add-support-for-enumerating-services-that-.patch \ + file://0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch \ + file://0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch \ + file://0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch \ file://rules.tmpl;subdir=debian" SRC_URI[sha256sum] = "b60d5865cefdbc75da8da4156c56c458e00de75a49b80c1a2e58a96e30ad0d54"
Signature · 1 line
2.47.3
PATCH v3 4/7 u-boot: Add patches to enable measured boot with fTPM
From: Jan Kiszka <[email protected]>
U-Boot was so far not enumerating the fTPM device, and that caused the PCRs to stay zero. systemd-cryptenroll was complaining already, just not loud enough.
With these extra patches (currently under review upstream), we are getting a TPM right before the EFI loader starts, and we get valid PCR content as well.
---
Partial update of this series to include patches sent as v3 to u-boot:
https://lore.kernel.org/u-boot/[email protected]/
...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 95 +++++++++++ ...pport-for-enumerating-services-that-.patch | 156 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 33 ++++ ...to-optee-after-a-successful-mmc_init.patch | 41 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 50 ++++++ recipes-bsp/u-boot/u-boot-common-2026.01.inc | 6 + 7 files changed, 424 insertions(+) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch
recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch new file +43 -0
@@ -0,0 +1,43 @@ +From bb19b017d4d389b4ba9a08e35e4e19d39f552c5d Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Thu, 20 Aug 2026 17:57:08 +0200 +Subject: [PATCH 1/6] test: boot: measurement: Fix compilation for non-sandbox + builds +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +asm/io.h provides map_to_sysmem() only for the sandbox. Other targets +fail the build with + +../test/boot/measurement.c: In function ‘measure’: +../test/boot/measurement.c:30:33: error: implicit declaration of function ‘map_to_sysmem’; did you mean ‘map_physmem’? [-Wimplicit-function-declaration] + 30 | images.os.image_start = map_to_sysmem(kernel); + | ^~~~~~~~~~~~~ + | map_physmem + +Use the proper header that will pull asm/io.h only where needed. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + test/boot/measurement.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/boot/measurement.c b/test/boot/measurement.c +index 71f503f1567..85a01f1fec8 100644 +--- a/test/boot/measurement.c ++++ b/test/boot/measurement.c +@@ -9,9 +9,9 @@ + #include <bootm.h> + #include <env.h> + #include <malloc.h> ++#include <mapmem.h> + #include <test/test.h> + #include <test/ut.h> +-#include <asm/io.h> + + #define MEASUREMENT_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, measurement) +-- +2.47.3 +
recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch new file +95 -0
95 lines not on this page · raw message
recipes-bsp/u-boot/files/0003-tee-optee-Add-support-for-enumerating-services-that-.patch new file +156 -0
156 lines not on this page · raw message
recipes-bsp/u-boot/files/0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch new file +33 -0
@@ -0,0 +1,33 @@ +From ae4196ebbfc089828aea826422c16b58ff417aac Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Fri, 21 Aug 2026 09:02:23 +0200 +Subject: [PATCH 4/6] tee: optee: Do not warn about + TEE_ERROR_STORAGE_NOT_AVAILABLE + +This is a transitional error that is resolved once an RPMB becomes +available. Keep it as debug output only. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + drivers/tee/optee/core.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c +index 6127ca431f2..720f59a680f 100644 +--- a/drivers/tee/optee/core.c ++++ b/drivers/tee/optee/core.c +@@ -106,7 +106,10 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm + + ret = tee_invoke_func(dev, &arg, 1, ¶m); + if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { +- dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ if (arg.ret != TEE_ERROR_STORAGE_NOT_AVAILABLE) ++ dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ else ++ dev_dbg(dev, "Enumeration command 0x%x failed due to unavailable storage\n", pta_cmd); + return -EINVAL; + } + +-- +2.47.3 +
recipes-bsp/u-boot/files/0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch new file +41 -0
41 lines not on this page · raw message
recipes-bsp/u-boot/files/0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch new file +50 -0
50 lines not on this page · raw message
recipes-bsp/u-boot/u-boot-common-2026.01.inc +6 -0
@@ -26,6 +26,12 @@ SRC_URI += " \ file://0001-riscv-create-a-custom-CPU-implementation-for-PolarFi.patch \ file://0002-riscv-mpfs-move-SoC-level-options-to-the-CPU-Kconfig.patch \ file://0003-riscv-Add-support-for-BeagleV-Fire.patch \ + file://0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch \ + file://0002-tee-optee-Factor-out-service-enumeration-and-binding.patch \ + file://0003-tee-optee-Add-support-for-enumerating-services-that-.patch \ + file://0004-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch \ + file://0005-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch \ + file://0006-mmc-Make-MMC-Device-not-found-a-debug-output.patch \ file://rules.tmpl;subdir=debian" SRC_URI[sha256sum] = "b60d5865cefdbc75da8da4156c56c458e00de75a49b80c1a2e58a96e30ad0d54"
Signature · 1 line
2.47.3
PATCH v4 4/7 u-boot: Add patches to enable measured boot with fTPM
From: Jan Kiszka <[email protected]>
U-Boot was so far not enumerating the fTPM device, and that caused the PCRs to stay zero. systemd-cryptenroll was complaining already, just not loud enough.
With these extra patches (currently under review upstream), we are getting a TPM right before the EFI loader starts, and we get valid PCR content as well.
---
Another partial update, avoiding a duplicate registration issue with the fTPM. Hopefully the last one.
...ement-Fix-compilation-for-non-sandbo.patch | 43 +++++ ...-out-service-enumeration-and-binding.patch | 96 +++++++++++ ...-optee-Avoid-binding-a-service-twice.patch | 42 +++++ ...pport-for-enumerating-services-that-.patch | 156 ++++++++++++++++++ ...-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch | 34 ++++ ...to-optee-after-a-successful-mmc_init.patch | 43 +++++ ...-MMC-Device-not-found-a-debug-output.patch | 52 ++++++ recipes-bsp/u-boot/u-boot-common-2026.01.inc | 7 + 8 files changed, 473 insertions(+) create mode 100644 recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch create mode 100644 recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch create mode 100644 recipes-bsp/u-boot/files/0003-tee-optee-Avoid-binding-a-service-twice.patch create mode 100644 recipes-bsp/u-boot/files/0004-tee-optee-Add-support-for-enumerating-services-that-.patch create mode 100644 recipes-bsp/u-boot/files/0005-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch create mode 100644 recipes-bsp/u-boot/files/0006-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch create mode 100644 recipes-bsp/u-boot/files/0007-mmc-Make-MMC-Device-not-found-a-debug-output.patch
recipes-bsp/u-boot/files/0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch new file +43 -0
@@ -0,0 +1,43 @@ +From bb19b017d4d389b4ba9a08e35e4e19d39f552c5d Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Thu, 20 Aug 2026 17:57:08 +0200 +Subject: [PATCH 1/7] test: boot: measurement: Fix compilation for non-sandbox + builds +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +asm/io.h provides map_to_sysmem() only for the sandbox. Other targets +fail the build with + +../test/boot/measurement.c: In function ‘measure’: +../test/boot/measurement.c:30:33: error: implicit declaration of function ‘map_to_sysmem’; did you mean ‘map_physmem’? [-Wimplicit-function-declaration] + 30 | images.os.image_start = map_to_sysmem(kernel); + | ^~~~~~~~~~~~~ + | map_physmem + +Use the proper header that will pull asm/io.h only where needed. + +Signed-off-by: Jan Kiszka <[email protected]> +--- + test/boot/measurement.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/test/boot/measurement.c b/test/boot/measurement.c +index 71f503f1567..85a01f1fec8 100644 +--- a/test/boot/measurement.c ++++ b/test/boot/measurement.c +@@ -9,9 +9,9 @@ + #include <bootm.h> + #include <env.h> + #include <malloc.h> ++#include <mapmem.h> + #include <test/test.h> + #include <test/ut.h> +-#include <asm/io.h> + + #define MEASUREMENT_TEST(_name, _flags) \ + UNIT_TEST(_name, _flags, measurement) +-- +2.47.3 +
recipes-bsp/u-boot/files/0002-tee-optee-Factor-out-service-enumeration-and-binding.patch new file +96 -0
96 lines not on this page · raw message
recipes-bsp/u-boot/files/0003-tee-optee-Avoid-binding-a-service-twice.patch new file +42 -0
42 lines not on this page · raw message
recipes-bsp/u-boot/files/0004-tee-optee-Add-support-for-enumerating-services-that-.patch new file +156 -0
156 lines not on this page · raw message
recipes-bsp/u-boot/files/0005-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch new file +34 -0
@@ -0,0 +1,34 @@ +From 9c5619a48894f01010b3af306f722727072b5873 Mon Sep 17 00:00:00 2001 +From: Jan Kiszka <[email protected]> +Date: Fri, 21 Aug 2026 09:02:23 +0200 +Subject: [PATCH 5/7] tee: optee: Do not warn about + TEE_ERROR_STORAGE_NOT_AVAILABLE + +This is a transitional error that is resolved once an RPMB becomes +available. Keep it as debug output only. + +Signed-off-by: Jan Kiszka <[email protected]> +Reviewed-by: Ilias Apalodimas <[email protected]> +--- + drivers/tee/optee/core.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c +index e5dbbf00410..9bedc4e427d 100644 +--- a/drivers/tee/optee/core.c ++++ b/drivers/tee/optee/core.c +@@ -112,7 +112,10 @@ static int __enum_services(struct udevice *dev, struct tee_shm *shm, size_t *shm + + ret = tee_invoke_func(dev, &arg, 1, ¶m); + if (ret || (arg.ret && arg.ret != TEE_ERROR_SHORT_BUFFER)) { +- dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ if (arg.ret != TEE_ERROR_STORAGE_NOT_AVAILABLE) ++ dev_err(dev, "Enumeration command 0x%x failed: 0x%x\n", pta_cmd, arg.ret); ++ else ++ dev_dbg(dev, "Enumeration command 0x%x failed due to unavailable storage\n", pta_cmd); + return -EINVAL; + } + +-- +2.47.3 +
recipes-bsp/u-boot/files/0006-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch new file +43 -0
43 lines not on this page · raw message
recipes-bsp/u-boot/files/0007-mmc-Make-MMC-Device-not-found-a-debug-output.patch new file +52 -0
52 lines not on this page · raw message
recipes-bsp/u-boot/u-boot-common-2026.01.inc +7 -0
@@ -26,6 +26,13 @@ SRC_URI += " \ file://0001-riscv-create-a-custom-CPU-implementation-for-PolarFi.patch \ file://0002-riscv-mpfs-move-SoC-level-options-to-the-CPU-Kconfig.patch \ file://0003-riscv-Add-support-for-BeagleV-Fire.patch \ + file://0001-test-boot-measurement-Fix-compilation-for-non-sandbo.patch \ + file://0002-tee-optee-Factor-out-service-enumeration-and-binding.patch \ + file://0003-tee-optee-Avoid-binding-a-service-twice.patch \ + file://0004-tee-optee-Add-support-for-enumerating-services-that-.patch \ + file://0005-tee-optee-Do-not-warn-about-TEE_ERROR_STORAGE_NOT_AV.patch \ + file://0006-mmc-Call-back-to-optee-after-a-successful-mmc_init.patch \ + file://0007-mmc-Make-MMC-Device-not-found-a-debug-output.patch \ file://rules.tmpl;subdir=debian" SRC_URI[sha256sum] = "b60d5865cefdbc75da8da4156c56c458e00de75a49b80c1a2e58a96e30ad0d54"
Signature · 1 line
2.47.3
PATCH v2 5/7 u-boot: Refactor ftpm-stmm.cfg to enable measured boot for all
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Move the common bits out the ti-extra.cfg into the shared ftpm-stmm.cfg which is consumed by the am62px unconditionally. Any commands, though, should be selected at board level because they are not needed for the fTPM and StMM functionalities.
While at it, fix the header of the ti-extra.cfg so that its bits get removed before being re-applied.
--- recipes-bsp/u-boot/files/ftpm-stmm.cfg | 7 ++++++- recipes-bsp/u-boot/files/qemu-extra.cfg | 2 ++ recipes-bsp/u-boot/files/ti-extra.cfg | 8 +------- 3 files changed, 9 insertions(+), 8 deletions(-)
recipes-bsp/u-boot/files/ftpm-stmm.cfg +6 -1
@@ -4,5 +4,10 @@ ### Enable OPTEE, fTPM and StMM CONFIG_TEE=y CONFIG_OPTEE=y -CONFIG_CMD_OPTEE_RPMB=y +CONFIG_OPTEE_SERVICE_DISCOVERY=y CONFIG_EFI_MM_COMM_TEE=y +CONFIG_TPM=y +CONFIG_TPM_V2=y +CONFIG_TPM2_FTPM_TEE=y +CONFIG_MEASURED_BOOT=y +CONFIG_EFI_TCG2_PROTOCOL=y
recipes-bsp/u-boot/files/qemu-extra.cfg +2 -0
@@ -10,3 +10,5 @@ CONFIG_MMC_SDHCI=y CONFIG_CMD_MMC=y CONFIG_CMD_MMC_REG=y CONFIG_EFI_SCROLL_ON_CLEAR_SCREEN=y +CONFIG_CMD_OPTEE_RPMB=y +CONFIG_CMD_TPM=y
recipes-bsp/u-boot/files/ti-extra.cfg +1 -7
@@ -1,17 +1,11 @@ # # SPDX-License-Identifier: MIT # -### FTPM + RPMB + StandaloneMM setup -CONFIG_OPTEE_SERVICE_DISCOVERY=y -CONFIG_TPM=y -CONFIG_TPM_V2=y +### TI extra config CONFIG_CMD_TPM=y -CONFIG_TPM2_FTPM_TEE=y CONFIG_SUPPORT_EMMC_RPMB=y -CONFIG_MEASURED_BOOT=y CONFIG_CMD_NVEDIT_EFI=y CONFIG_CMD_MMC_RPMB=y -CONFIG_EFI_TCG2_PROTOCOL=n # workaround for v2025.07 CONFIG_USB_STORAGE=y
Signature · 1 line
2.47.3
PATCH v2 6/7 u-boot: Drop obsolete config workaround
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We moved to a newer U-Boot version meanwhile which resolved that issue.
--- recipes-bsp/u-boot/files/secure-boot.cfg | 2 -- 1 file changed, 2 deletions(-)
recipes-bsp/u-boot/files/secure-boot.cfg +0 -2
@@ -17,5 +17,3 @@ CONFIG_FS_FAT=y CONFIG_EFI_SECURE_BOOT=y # overruled by CONFIG_EFI_MM_COMM_TEE where available CONFIG_EFI_VARIABLES_PRESEED=y -# workaround for v2025.07 -CONFIG_CMD_DHCP=y
Signature · 1 line
2.47.3
PATCH v2 7/7 initramfs-crypt-hook: Prevent encryption without secure boot
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We so far allowed to run first-boot encryption in any secure boot state. This remained unnoticed because the QEMU x86 machine was started with certificates provisioned, and the QEMU arm64 machine did not support measured boot. The latter is fixed now, and we also deploy certs during first boot now if they aren't pre-deployed. Time to raise the bar and reject generally insecure states.
--- .../initramfs-crypt-hook/files/local-top-complete | 4 ++++ 1 file changed, 4 insertions(+)
recipes-initramfs/initramfs-crypt-hook/files/local-top-complete +4 -0
@@ -297,6 +297,10 @@ for partition_set in $partition_sets; do continue fi + if ! secure_boot_enabled; then + panic "Secure boot disabled! Must be enabled to ensure correct key sealing." + fi + # check if we are trying to mount root, set ROOT to decrypted partition: if [ "$partition_mountpoint" = "/" ]; then echo "ROOT=$decrypted_part" >/conf/param.conf
Signature · 1 line
2.47.3
[isar-cip-core][PATCH v2 8/7] doc: Update README.secureboot regarding recent deployment enhancements
In reply to Jan Kiszka[reposted against the correct series version, sorry]
From: Jan Kiszka <[email protected]>
Explain the automatic certificates deployment and its dependencies. There is no longer the need to explain manual key creation, we can simply reference the new single-key-to-efi-certs package. Keep the manual deployment method for special causes.
--- doc/README.secureboot.md | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-)
doc/README.secureboot.md +29 -10
@@ -273,32 +273,51 @@ lrwxrwxrwx 1 root root 0 Jun 30 13:20 sda5 -> ../../../../pci0000:00/0000:00:1f. Secureboot for a generic UEFI x86 target works similar to the QEMU target, except the enrollment of the secure boot keys. -### Generate keys from Debian snakeoil keys +### Generate keys from a single signing key -For testing purposes, the snakeoil keys from OVMF package can be used to -convert the certificate into a efi authority file use the following commands: +The recipe `single-key-to-efi-certs` can be used to generate a Debian package +that contains the required EFI certificates for enabling secure boot. It uses +a single key/cert pair as basis. Unless otherwise configured, this pair will +be taken from the corresponding Debian snakeoil set which is fine only for +testing purposes. The package will contain the `.auth` files required for +manual deployment: -```bash -cert-to-efi-sig-list recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.pem PK.esl -sign-efi-sig-list -k recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.key -c recipes-devtools/secure-boot-secrets/files/bookworm/PkKek-1-snakeoil.pem PK PK.esl PK.auth +``` +$ dpkg -c build/tmp/deploy/isar-apt/cip-core-trixie/apt/cip-core-trixie/pool/main/s/single-key-to-efi-certs/single-key-to-efi-certs_0.1_arm64.deb +[...] +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/KEK.auth +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/PK.auth +-rw-r--r-- root/root 2549 1970-01-01 02:00 ./usr/share/secure-boot-efi-certs/db.auth ``` -The package `efitools` needs to be installed for this. +### Automatic secure boot certificate enrollment -In this case, the PK.esl can be used as DB and KEK keys. The PK.auth file is for PK key. +By default, isar-cip-core images contain an early boot service +(initramfs-sbcerts-hook) which will deploy the required EFI certificates during +first boot and restart the machine into secure boot afterwards. This will only +happen when the machine is in Setup Mode and no other certificates have been +deployed to the Allowed Signature Database yet. This also ensures that disk +encryption on first boot will only take place when the machine was securely +booted so that the encryption key is sealed against this state in the TPM. -### Secure boot key enrollment +The certificates needed for this auto-enrollment are taken from a package that +provides `secure-boot-efi-certs`. The `single-key-to-efi-certs` package is the +default provider of this in isar-cip-core. + +### Manual secure boot certificate enrollment > :exclamation:**IMPORTANT** This document is not for generating a Machine Owner Key(MOK). > :exclamation:**IMPORTANT** Enrollment of secure boot keys must occur > in a secure environment. -The following keys need to be enrolled onto the device: +The certificates for the following keys need to be enrolled onto the device: - The Platform Key (PK) - The Key Exchange Key (KEK) - Allowed Signatures Database +You can obtain them from the single-key-to-efi-certs package described before. + The enrollment can typically be achieved with the help of [efi-updatevar](https://manpages.debian.org/bookworm/efitools/efi-updatevar.1.en.html) on the device.
Signature · 1 line
2.47.3