Skip to content

attester: add RA_PERF performance measurement logging#4

Open
mmxsrup wants to merge 3 commits into
pr/prot-os-versionfrom
pr/perf-logging
Open

attester: add RA_PERF performance measurement logging#4
mmxsrup wants to merge 3 commits into
pr/prot-os-versionfrom
pr/perf-logging

Conversation

@mmxsrup

@mmxsrup mmxsrup commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds RA_PERF timing logs across the attestation stack for the performance evaluation: total attestation time, per-event durations (hashing, CBOR/COSE, ECDSA/CAAM signing, black-key processing), and the CAAM black-key on/off comparison.

Stacked on #3 (base = pr/prot-os-version).

One machine-parsable line per measurement:

RA_PERF|<layer>|<event>|<duration_us>|key=<embedded|plain|black|->
  • pta (ARM generic timer, µs): hashes, CBOR encode, sign breakdown, OCOTP reads, key generation. Events are buffered and printed in one batch after all timestamps are taken (the synchronous console would otherwise skew them); the flush cost is reported as perf_flush.
  • ta (TEE_GetSystemTime, ~1 ms): pta_invoke, cmd_total.
  • host (CLOCK_MONOTONIC): TEE round trip, HTTP round trips, total. New options: --perf (enable logs), --loop N, --no-server (local nonce; no verifier needed).
  • Black-key on/off is a runtime choice (--key-hex); compare via pta|sign_ecdsa — both paths sign on CAAM, the black-key path adds blob decapsulation + CCM key import. The embedded-path self-verify is reported separately so it cannot bias the comparison.

Enable with CFG_REMOTE_ATTESTATION_PERF=y; default builds are unaffected. The i.MX bbappend also raises CFG_TEE_CORE_LOG_LEVEL to 2 (meta-freescale forces 0, which compiles out all core trace).

Full log-point list and measurement protocol: docs/performance-measurement.md (Japanese).

Testing (QEMU E2E)

  • Flag off: no perf code compiled, zero RA_PERF lines, attestation flow unchanged.
  • Flag on: with verifier / --no-server --loop 3 / without --perf / --generate-blackkey; ear.status: affirming.
  • Numbers internally consistent (sign_*cose_sign1; event sum ≈ cmd_total).

mmxsrup added 2 commits June 11, 2026 15:04
Add timing instrumentation across the attestation stack so that the
total attestation time and the duration of each major event (memory
hashing, CBOR/COSE encoding, ECDSA/CAAM signing, black-key processing)
can be collected for performance evaluation. Every measurement is one
machine-parsable line:

  RA_PERF|<layer>|<event>|<duration_us>|key=<embedded|plain|black|->

PTA (microsecond resolution, ARM generic timer): ocotp_srk,
ocotp_lifecycle, instance_id, hash_ta, hash_tee, cbor_encode,
sign_key_setup, sign_tbs_hash, sign_ecdsa, sign_verify, cose_sign1,
cmd_total, plus keypair_generate / blackkey_encap / convert_total for
the black-key provisioning commands. Events are buffered and flushed in
one batch after all timestamps are taken, because the secure console is
synchronous and printing between measured operations would skew them;
the flush reports its own cost as perf_flush. sign_ecdsa is the bracket
for the CAAM black-key on/off comparison (sign_verify only runs on the
embedded-key path and is reported separately so it cannot bias it).

TA (millisecond resolution, TEE_GetSystemTime): pta_invoke, cmd_total.

Host (clock_gettime CLOCK_MONOTONIC): teec_init, teec_open_session,
veraison_new_session, evidence_get, print_evidence,
veraison_post_evidence, total, blackkey_generate, blackkey_convert.
New client options: --perf (or RA_PERF=1) enables the host log lines,
--loop N repeats the attestation for statistics, --no-server attests a
local random nonce without a relying party (useful on devices without
network access to a verifier).

The firmware side is compiled in only with
CFG_REMOTE_ATTESTATION_PERF=y (QEMU: pass it to make check; Yocto: set
the variable for optee-os and veraison-attestation in local.conf) and
default builds are unaffected. The i.MX bbappend raises
CFG_TEE_CORE_LOG_LEVEL to 2 together with the flag because
meta-freescale's optee-os-common-fslc-imx.inc forces it to 0, which
would compile out all core trace including the RA_PERF lines.
Document the RA_PERF timing logs: log format and clock sources per
layer, the full log-point list, how to enable the instrumentation on
QEMU and on the i.MX Yocto build, a recommended measurement protocol
(repetitions, aggregation script), and how to compare CAAM signing with
and without the black key (compare pta|sign_ecdsa only; on i.MX both
paths sign on CAAM hardware, the black-key path additionally pays blob
decapsulation + CCM key import). Includes the security note that
running without the black key leaves the signing key unprotected by the
CAAM, so those numbers are for performance comparison only.
Turn the measurement-protocol's "governor/CPU clock" mention into a
concrete pin-and-record step (scaling_governor=performance + record
scaling_cur_freq), since sub-ms events swing with DVFS and nothing else
fixed it. Note that the aggregation one-liner counts all iterations
(including the cold first one the protocol says to discard), how to trim
it offline, and that teec_init/teec_open_session are measured once
before the loop and so are already outside the per-iteration aggregates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant