OP-TEE on Qualcomm Lemans › Development Branches › dTPM + DRTM (Xen)

dTPM + DRTM with Xen

The discrete TPM of features/lemans/security/dtpm, plus the pieces of an Arm DRTM (DEN0113) dynamic launch: TF-A BL31 as the dynamic configuration environment (DCE), Xen as the dynamically launched measured environment (DLME), and OP-TEE as the S-EL1 SPMC that owns the TPM and reaches Xen's guests over FF-A only.

Branch: features/lemans/security/dtpm-drtm of qcom-buildroot, the development branch, on top of features/lemans/security/dtpm. Its manifests/lemans.xml pins every project to a tested commit (each from the features/lemans/drtm branch of Linux, TF-A, OP-TEE, Xen, U-Boot and the test definitions, and build/ from this branch), and lemans.mk builds the FF-A firmware, BL31 with the DRTM service and the Xen DLME launched by default.

Building it

The Quick Start, dTPM + DRTM tab. XEN=y and DRTM=y are the defaults here. LOCALVERSION=-mybuild-001 on the make lines adds a fingerprint every stage prints at boot; make flash-lava flashes a lab board (lemans/lava/flash-lava-xen.yaml).

XEN=n DRTM=ngives back the plain OP-TEE boot of the dTPM branch: SPD=opteed, OP-TEE on the SMC ABI, Linux from the UKI. This branch's U-Boot boots only through the DRTM launch, so such a build (and XEN=y DRTM=n) stops at the U-Boot prompt; boot it with run do_boot.

Trees

ProjectBranchWhat it carries
arm-trusted-firmwareEmbeddedAndroid · features/lemans/drtmThe SPMC manifest built into BL31 (U-Boot SPL replaces BL2, so nothing else passes it); the QTI DRTM platform port; DMA protection for the SMMU-500 instances (an SMMUv2 abort-all helper next to the SMMUv3 one).
optee_osEmbeddedAndroid · features/lemans/drtmThe dTPM stack of OP-TEE/optee_os#8155 (TIS SPI driver and the dTPM mediator PTA), with locality 4 and the SPI hardening on top, the SPMC fixes from the Nord/Eliza Xen work, and CFG_DT forced for an embedded DT with an SPMC.
xenEmbeddedAndroid · features/lemans/drtmThe Qualcomm Xen tree (GENI UART, SMMU, FF-A mediator) with the Lemans SoC match.
linuxEmbeddedAndroid · features/lemans/drtmThe dTPM kernel of buildroot/lemans/dtpm (the OP-TEE TPM transport core and discrete TPM driver, v2 on linux-integrity) plus the OP-TEE firmware node, the TIS locality support, and two dom0 fixes: gcc-sa8775p no longer parks the QUP serial engine clocks at registration (that garbled the Xen console), and msm DPU no longer tears down the KMS twice when hardware init fails.
test-definitionsEmbeddedAndroid · features/lemans/drtmThe tpm2 tests and the Xen tests (dom0, xl guests, OP-TEE over FF-A from dom0 and from a guest).
u-bootEmbeddedAndroid · features/lemans/drtmqcom-next plus the drtm command (doc/usage/cmd/drtm.rst), and a lemans default environment whose boot command is the DRTM launch (see below).

The boot

XBL U-Boot SPL tz.mbn TF-A BL31 (EL3) SPMD DRTM service (DCE) SMMU-500 DMA protection OP-TEE S-EL1 SPMC + dTPM U-Boot proper drtm launch Xen (EL2) DLME, FF-A mediator dom0 Linux hvc0, /dev/tpm0, xl
The uefi partition FIT carries BL31, OP-TEE and U-Boot proper; efi.bin carries dlme.img (Xen, its device tree, the dom0 Image and initramfs), which U-Boot's default boot command launches through BL31. xen.efi, its bootaa64.cfg and the UKI stay on the ESP for a static boot by hand.

The DRTM launch is the default boot

A build from manifests/lemans.xml boots Xen and dom0 through an Arm DRTM dynamic launch, so the D-RTM PCRs are extended on every boot. make all (XEN=y DRTM=y) packs lemans/output/dlme.img with lemans/dlme/mkdlme.py: a 4 KiB trampoline, Xen's host device tree (the EVK memory banks, Xen's options with drtm-tpm=0x8100, the dom0 kernel and initramfs as /chosen modules with the dom0 command line), Xen (built with CONFIG_ARM_DRTM), the dom0 Image and the Buildroot initramfs. It copies dlme.img to the root of efi.bin and writes lemans/output/dlme-pcr.txt, the PCR values a launch of that image must leave in both banks.

U-Boot's default boot command (qcom_lemans_defconfig, board/qualcomm/lemans-drtm.env):

drtm info
load scsi 0:${drtm_part} 0x180000000 dlme.img    # in effect: the efi partition
drtm launch 0x180000000 0x10200000 ${filesize} 0x10000000

The DLME region is 258 MiB at 0x180000000 with the DLME data at 256 MiB; dlme.img must end below it, which make checks.

PCRExtended byMeasurements, in order (each bank: PCR = H(PCR || H(data)), from the locality 4 reset to zeros)
17BL31 (DCE), locality 4the DCE (0x00: no normal-world DCE), the PCR schema (0x00), the separator ARM_DRTM. The same value on every launch.
18BL31 (DCE), locality 4the PCR schema, the DCE public key (0x00), the DLME image (dlme.img, its file size as U-Boot passes it), the DLME entry point offset (8 zero bytes), the separator.
19Xen, locality 2one event per dom0 object, its data the object's SHA-256: the kernel, the initramfs, the command line (without its NUL). Xen then closes locality 2.

In dom0, read both banks and compare them with dlme-pcr.txt of the build:

for b in sha256 sha384; do for p in 17 18 19; do
    echo "PCR $b $p $(cat /sys/class/tpm/tpm0/pcr-$b/$p)"
done; done
# or: tpm2_pcrread sha256:17,18,19+sha384:17,18,19

lemans/dlme/dlme-pcr.py <dlme.img> <Image> <initrd> <dom0 cmdline> recomputes the values from the images, for example after changing one of them. Changing one byte of dlme.img outside the dom0 kernel, initramfs and command line (in Xen, or in the zero padding at its end) changes PCR 18 only; PCR 17 and 19 stay the same.

A failed launch stops at the U-Boot promptThere is no fallback to the static boot. U-Boot prints why and stops at its prompt when the firmware has no DRTM service, when it still holds an error code from an earlier launch, when dlme.img is missing from the ESP, or when drtm launch refuses the image before quiescing. When BL31 refuses the launch after U-Boot quiesced, U-Boot prints the DEN0113 code, records it as the error code and resets the board; the next boot stops at the prompt (if the firmware cannot record the code, U-Boot says so and the next boot launches again). A launch that fails inside BL31 after the D-RTM PCRs were reset panics BL31, recording an error code where it can. drtm info shows the code (also in $drtm_error); drtm clear clears it, and boot launches again. run do_boot boots Xen statically by hand (no D-RTM measurement). A saved U-Boot environment overrides the default boot command; env default -a; saveenv restores it.

The event log of the launch (which BL31 writes into the DLME data) is not passed on to dom0 yet; until it is, the check is against the values computed from the measured images.

Validated on 2026-11-29 from a clean build of manifests/lemans.xml (fingerprint QCDFP-261129-3217, QTI_SECURE_DTPM=1): LAVA 634751 (rb8-hyd-03) and 634752 (rb8-hyd-02) boot through the launch with PCR 17/18/19 of both banks equal to dlme-pcr.txt; 634749 boots the same build with one padding byte of dlme.img changed and sees PCR 18 change while PCR 17 and 19 do not.

DRTM: where it stands

The target follows the tboot model: the DCE measures the DLME into PCR 17/18 at locality 4 through the secure-world dTPM, and Xen measures dom0 at locality 2 into PCR 19.

PieceStateNotes
dTPM in OP-TEE, locality 4 refused to the normal worlddoneAs on the dTPM branch; the tpm2 tests pass from dom0 under Xen.
Xen + dom0 + xl guests + OP-TEE over FF-AdoneLAVA 557881: dom0, four parallel xl guests, OP-TEE xtest and FF-A from dom0 and from a guest, tpm2 tests.
DEN0113 service in BL31 (version, features, set/get error, launch)doneExercised from U-Boot in LAVA 557870 (test build, see below); unaligned parameters and a DLME in a secure carveout are refused.
DMA protection during launchdoneAll non-secure SMMU-500 streams fault until the DLME takes over; a UFS doorbell from the DLME faults on the apps SMMU (557870).
DRTM error record across resetdoneKept in a PMIC SDAM slot; U-Boot's boot command reads it with drtm info.
BL31 to OP-TEE measurement path (SPMD to SPMC direct message), normal-world firewall on the TPMdoneThe D-RTM PCRs are extended at locality 4 through OP-TEE; with QTI_SECURE_DTPM=1 the dTPM SPI engine and pads are secure only.
U-Boot launch preamble (DRTM_DYNAMIC_LAUNCH from U-Boot)doneThe default boot command (below).
Xen as the DLME (non-EFI entry, dom0 measurement)donedlme.img, built by make all; Xen measures dom0 into PCR 19.
DRTM event log for the DLME and dom0openBL31 writes it into the DLME data; nothing hands it to dom0 yet.

The validated DRTM scenario

The first proof on the board (2026-11-10, before the launch became the default boot) covered the DCE half of the launch: BL31 answers the DEN0113 calls, refuses malformed launches, turns on DMA protection and enters a DLME at NS-EL2 with every non-secure DMA stream blocked. The run below (LAVA job 557870, rb8-hyd-02) uses this branch's TF-A and OP-TEE with a test U-Boot whose preboot issues the DRTM SMCs, and a small test DLME that reports what it sees; neither test piece is built by this branch.

  1. Cold boot

    BL31 sets up the DRTM service next to the SPMD; OP-TEE starts as the S-EL1 SPMC. AOP, SAIL and CPUCP are DMA-capable but trusted (non-host platforms). The GPU SMMU is only engaged when GPU CX is on; at this point it is off.
    NOTICE:  BL31: v2.15.0(release):QCDFP-261110-3044
    INFO:    DRTM service setup
    WARNING: DRTM: the platform includes trusted DMA-capable devices (non-host platforms)
    INFO:    DRTM: GPU CX off (GDSCR 0x22f001), GPU SMMU not engaged
    I/TC: OP-TEE version: QCDFP-261110-3044 ...
  2. Discovery and the error record

    From U-Boot: DRTM_VERSION, DRTM_FEATURES (TPM, minimum memory, DMA protection, boot PE, TCB hashes, DLME image authentication), then DRTM_SET_ERROR and DRTM_GET_ERROR round trip.
  3. Malformed launches are refused

    DRTM_DYNAMIC_LAUNCH with a parameter block that is not 4 KiB aligned, and with a DLME placed inside secure memory, both fail without touching the SMMUs.
    ERROR:   DRTM: parameters structure is not 4-KiB-aligned
    ERROR:   DRTM: DLME region lies within secure memory
  4. DMA protection

    On a valid launch BL31 puts both SMMU-500 instances into abort-all: every stream mapping group of the apps SMMU (224) and of the PCIe SMMU (64) is handed to the non-secure side with client bypass off and unmatched streams faulting (NSCR0 CLIENTPD cleared, USFCFG set). The DLME has to program the SMMUs before any device can reach memory again.
    INFO:    SMMUv2 @0x15000000: 224 of 224 stream mapping groups Non-secure, NSCR0 0x290400
    INFO:    SMMUv2 @0x15200000: 64 of 64 stream mapping groups Non-secure, NSCR0 0x240400
  5. DLME entry

    The DLME starts at NS-EL2 (CurrentEL 0x8) with x0 pointing at the DLME data (header version 1) and finds the SMMUs as BL31 left them, with no fault recorded.
    DLME_START QCDFP-261110-3044 x0=0x00000000e0100000 x1=0x0000000000100000 CurrentEL=0x0000000000000008
  6. A DMA attempt is blocked

    The DLME rings the UFS host controller doorbell with a transfer request. The UFS DMA never reaches memory: the apps SMMU records an unidentified stream fault (GFSR 0x80000002) for stream ID 0x100, the UFS controller.
    DLME_APPS_FAULT_AFTER_UFS GFSR,GFSYNR0,GFSYNR1,GFAR 0x0000000080000002 0x0000000000000000 0x0000000000000100 0x0000000f536cb800
    DLME_DONE QCDFP-261110-3044
The rest of the stack under XenLAVA job 557881 (rb8-hyd-03) boots the same firmware and the kernel of this branch with the test rootfs: the tpm2 tests from dom0 (locality 4 refused to the normal world), OP-TEE xtest (37772 subtests, 0 failed), and the Xen tests (dom0, parallel xl guests, OP-TEE over FF-A from dom0 and from a guest).

Verification

This is the static boot of the 2026-11-11 build: U-Boot's EFI loader starts Xen, as run do_boot still does. The default boot is the DRTM launch (above).

make flash-lava on this branch from a clean repo sync, built with LOCALVERSION=-QCDFP-261111-3050, flashed and booted LAVA job 559581 on rb8-hyd-03. Every stage printed the fingerprint:

U-Boot SPL 2026.07-rc4-QCDFP-261111-3050-g3902cb4183e0-dirty
NOTICE:  BL31: v2.15.0(release):QCDFP-261111-3050
I/TC: OP-TEE version: QCDFP-261111-3050 (gcc version 14.3.1 ...) aarch64
U-Boot 2026.07-rc4-QCDFP-261111-3050-g3902cb4183e0-dirty
(XEN) Xen version 4.23-unstable-QCDFP-261111-3050 ... debug=y
[    0.000000] Linux version 7.1.0-rc6-QCDFP-261111-3050-g4f98c7e9f301 ...
buildroot login: root
# xl info | grep -E '^xen_(version|extra)'
xen_extra              : -unstable-QCDFP-261111-3050
xen_version            : 4.23-unstable-QCDFP-261111-3050
# dmesg | grep optee
optee: probing for conduit method.
optee: api uid mismatch
optee firmware:optee: probe with driver optee failed with error -22
optee: revision 4.11 (979c0eec)
optee: initialized driver

The SMC-conduit probe is refused (there is no OP-TEE SMC ABI under the SPMD); the driver then binds over FF-A, through Xen's mediator.

On the board:

# dom0 runs under Xen
cat /sys/hypervisor/type          # xen
xl info | grep -E '^xen_(version|extra)'
xl list                           # Domain-0

# OP-TEE through the FF-A mediator, and the dTPM behind it
dmesg | grep -i -E 'arm_ffa|optee'
tpm2_getcap properties-fixed
tpm2_pcrread sha256:17,18,19

Glossary

DRTMDynamic Root of Trust for Measurement: a late, measured launch of a small trusted environment, independent of the boot chain before it (Arm DEN0113; the x86 counterparts are Intel TXT and AMD SKINIT).
DCEDynamic Configuration Environment: the code that performs the launch, here the DRTM service in TF-A BL31.
DLMEDynamically Launched Measured Environment: what gets launched and measured, here Xen.
SPMD / SPMCThe TF-A dispatcher and the secure partition manager of FF-A; with SPMD_SPM_AT_SEL2=0 OP-TEE is the SPMC at S-EL1.
FF-AArm Firmware Framework for A-profile: the messaging ABI between the normal world, the hypervisor and the secure world.
LocalityTPM access level. PCR 17 and 18 are reset only from locality 4 and cannot be extended from locality 0 or 1; PCR 19 is extended from locality 2, the DLME's own measurements.