Repository navigation
Open
Labels
area/driversDevice drivers and virtio.Device drivers and virtio.area/securityLSMs, seccomp, Landlock, capabilities and mitigations.LSMs, seccomp, Landlock, capabilities and mitigations.kind/featureNew behavior or a new part.New behavior or a new part.
Milestone
Description
Part of #14.
rukernel has no TPM support. On x86_64 the kernel reads only the MADT of the ACPI tables (frame/rk-frame/src/arch/x86_64/acpi.rs). On arm64 it reads the device tree (frame/rk-frame/src/fdt.rs). There is no securityfs, no AF_ALG and no device mapper, and cargo xtask qemu does not start swtpm.
Scope
- Start swtpm with
cargo xtask qemuandboot-testwhenRK_TPM=1is set:-tpmdev emulatorwith-device tpm-crbon x86_64 and-device tpm-tis-deviceon the arm64virtmachine. Test: all boot tests withRK_TPM=1. Exit: the results do not change. xtask: start swtpm for the QEMU machine with RK_TPM=1 #679: done, and the focused boot tests (x86_64 boot, mm, timer, syscall, init, bzImage and UEFI; arm64 boot) give the same results with RK_TPM=1. The run of all boot tests with RK_TPM=1 is not done yet. - Find the TPM and send commands. On x86_64, read the ACPI
TPM2table for the CRB address. On arm64, find the device tree node withcompatible = "tcg,tpm-tis-mmio". Add the CRB driver (start, cancel and the command and response buffers) and the TIS FIFO driver (locality, status, burst count and data FIFO), with the time limits of the TCG specification. Test: a newtpmboot test that sendsTPM2_Startup,TPM2_GetRandomandTPM2_PCR_Readfrom the kernel. Exit: the test passes on both architectures. drivers: a TPM 2.0 driver with the CRB and FIFO interfaces, and the tpm boot test #683: thetpmtest passes on x86_64 (CRB) and arm64 (TIS). -
/dev/tpm0with one command at a time, and/sys/class/tpm/tpm0withdev,uevent,tpm_version_majorandpcr-sha256. Test: thetpmboot test runstpm2_getrandom 8andtpm2_pcrread sha256:0,7of tpm2-tools on/dev/tpm0. Exit: both pass, and the PCR values are the same as inpcr-sha256. drivers: /dev/tpm0 and /sys/class/tpm/tpm0, and tpm2-tools in the tpm boot test #689: both pass on x86_64 and arm64, and PCRs 0 and 7 are the same as inpcr-sha256. -
/dev/tpmrm0, the resource manager: a space for each open file, with the context save and load of transient objects and sessions and the change of handles, as drivers/char/tpm/tpm2-space.c. Test: addtpm2to tools/kselftest/build.sh and run test_smoke.sh, test_space.sh and test_async.sh. Exit: the three pass on both architectures. drivers: /dev/tpmrm0, the resource manager of TPM 2.0, and the tpm2 kselftests in the tpm boot test #694: test_smoke.sh (9 tests), test_space.sh (4 tests) and test_async.sh (2 tests) pass on x86_64 and arm64. - The event log at
/sys/kernel/security/tpm0/binary_bios_measurements, from the log area of the ACPITPM2table or thelinux,sml-baseproperty of the device tree. It needs securityfs from R5 AppArmor and SELinux: the LSM framework, permissive and then enforcing #540. Test:systemd-analyze pcrsin thesystemdboot test withRK_TPM=1. Exit: the PCR values are the same as the values oftpm2_pcrread. drivers: the event log of the firmware at /sys/kernel/security/tpm0/binary_bios_measurements #696: the log of SeaBIOS is in securityfs on x86_64, and the replay withtpm2_eventloggives the SHA-256 PCRs oftpm2_pcrread. Thesystemdtest with RK_TPM=1 (systemd-analyze pcrs) did not run yet. -
AF_ALGwithskcipherforxts(aes)andcbc(aes)andhashforsha256, so that libcryptsetup can open a LUKS2 key slot without dm-crypt. Test: LTP runtest/crypto (af_alg01 to af_alg07). Exit: the af_alg tests reach the pass set of the reference. - systemd-cryptenroll: a new
cryptenrollboot test makes a LUKS2 image in a file, runssystemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=7, and opens the key slot with the TPM token bycryptsetup open --test-passphrase --token-only. Run the systemd TEST-70-TPM2 integration test and write the result. Exit: the boot test passes on both architectures, and TEST-70-TPM2 reaches the pass set of the reference, apart from the parts that need dm-crypt.
Done when
systemd-cryptenroll binds a key to the virtual TPM. This is the exit of the sixth item of #14.
Test each task on x86_64 and on arm64. Give the result of both in the PR body.
Linux reference: drivers/char/tpm/tpm_crb.c, drivers/char/tpm/tpm_tis_core.c, drivers/char/tpm/tpm-dev-common.c, drivers/char/tpm/tpm2-space.c, drivers/char/tpm/eventlog/acpi.c, crypto/algif_skcipher.c.
Metadata
Metadata
Assignees
Labels
area/driversDevice drivers and virtio.Device drivers and virtio.area/securityLSMs, seccomp, Landlock, capabilities and mitigations.LSMs, seccomp, Landlock, capabilities and mitigations.kind/featureNew behavior or a new part.New behavior or a new part.
Activity
tamnd commentedon Nov 9, 2026
#679 merged: item 1. With
RK_TPM=1,cargo xtask qemuandboot-teststart swtpm for each machine, with-device tpm-crbon x86_64 and-device tpm-tis-deviceon arm64.With a TPM, QEMU 8.2 puts the
-initrdinitramfs over a part of the ACPI tables of SeaBIOS (128 KiB of tables and a 64 KiB TPM log at the top of the memory, butx86_load_linuxkeeps only 160 KiB free). The kernel then found a bad RSDT and did not start. Now the x86_64 SeaBIOS machine with a TPM gets the initramfs from-device loaderat 64 MiB, and the kernel finds it frominitrdmem=ADDRESS,SIZE, as Linux does. The UEFI machine keeps-initrd.Test results:
boot,mm,timer,syscallandinitpass.RK_TPM=1 cargo xtask boot-test boot:boot,boot with the bzImageandboot with UEFIpass.RK_TPM=1 RK_AARCH64_TESTS=boot cargo xtask boot-test aarch64:bootandboot with GICv2pass.boot::5 pass (with the newinitrdmem=test), xtask 4 pass.Not done: a run of all boot tests with
RK_TPM=1. I ran only the focused tests, so the item is not ticked.tamnd commentedon Nov 10, 2026
#683 merged: item 2. rk-frame finds the TPM (the CRB address from the ACPI
TPM2table on x86_64, thetcg,tpm-tis-mmionode of the device tree on arm64). The new crate rk-drv-tpm has the CRB driver and the TIS FIFO driver, with the TCG time limits and the command durations of Linux, and starts the TPM astpm2_auto_startup. The newtpmboot test sendsTPM2_Startup,TPM2_GetRandomandTPM2_PCR_Readfrom the kernel.Test results:
tpmtest passes. The kernel findstpm_crb: TPM 2.0 at 0xfed40000,TPM2_GetRandom(8)gives two different sets of 8 bytes, andTPM2_PCR_Readgives the SHA-256 PCRs 0 and 7.bootandinitwith a TPM also pass.RK_AARCH64_TESTS=tpm cargo xtask boot-test aarch64passes.fdt::6 pass, xtask 4 pass.tamnd commentedon Nov 11, 2026
Item 3 of #541 is done in #689:
/dev/tpm0(one command at a time) and/sys/class/tpm/tpm0withdev,uevent,tpm_version_majorandpcr-sha256. With the tpm2-tools tree oftools/tpm/build.sh, thetpmboot test runstpm2_getrandom 8andtpm2_pcrread sha256:0,7on /dev/tpm0 and compares the PCRs withpcr-sha256.pcr-sha256.The full gate did not run.
tamnd commentedon Nov 11, 2026
Item 4 of #541 is done in #694:
/dev/tpmrm0(253:65536), the resource manager, as tpm2-space.c of Linux. Each open file has its own transient objects and sessions with virtual handles, and the driver saves and loads their contexts around each command. Thetpmboot test runs the tpm2 kselftests of Linux v6.17.tpmtest passes with the three kselftests.The full gate did not run.
tamnd commentedon Nov 11, 2026
Item 5 of #541 is partly done in #696: the event log of the firmware at
/sys/kernel/security/tpm0/binary_bios_measurements, from the log area of the ACPITPM2table on x86-64 orlinux,sml-baseof the device tree on arm64, as drivers/char/tpm/eventlog of Linux.tpm2_eventlogreplays PCRs 0 to 7, and they are the same as the SHA-256 PCRs oftpm2_pcrread.tpmtest passes. QEMUvirtwith-kernelhas no firmware, so there is no log.Not done:
systemd-analyze pcrsin thesystemdboot test withRK_TPM=1did not run.The full gate did not run.
tamnd commentedon Nov 12, 2026
#699 adds the crate
rk-crypto, with SHA-1, SHA-224, SHA-256, SHA-384, SHA-512,hmac, AES and the modesecb,cbc,ctrandxts, as crypto/ of Linux. The 13 unit tests use the vectors of crypto/testmgr.h, and they pass. TheAF_ALGitem is not done yet. TheAF_ALGsockets withhashand withskciphercome in the next two PRs, with LTP af_alg01 to af_alg07.tamnd commentedon Nov 12, 2026
#703 adds the
AF_ALGsockets with the typehash, as crypto/af_alg.c and crypto/algif_hash.c, with the allow lists ofcrypto.af_alg_restrict. LTP af_alg01 passes on x86_64 and arm64. af_alg02 to af_alg06 and af_alg08 give TCONF, as on Linux with the allow list. af_alg07 fails, becausefchownaton a socket after its release does not giveENOENTyet. TheAF_ALGitem is not done yet. Theskciphersockets and the fix for af_alg07 come next.