Return INV_CRB_CTRL_DATA for empty CRB control data on Start#79
Merged
dymk merged 1 commit intoJun 12, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns the TPM Service CRB-over-FF-A Start status codes with ARM DEN0138 semantics by returning INV_CRB_CTRL_DATA (instead of DENIED) when the host issues Start with empty/invalid CRB control data.
Changes:
- In
handle_command(), returnInvCrbCtrlDatawhen bothcrb_control_requestandcrb_control_startare zero (no operation requested). - In
handle_locality_request(), returnInvCrbCtrlDatawhen neitherRELINQUISHnorREQUEST_ACCESSis set inlocality_control.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
kurtjd
previously approved these changes
Jun 12, 2026
Raymond-MS
reviewed
Jun 12, 2026
Raymond-MS
reviewed
Jun 12, 2026
Raymond-MS
previously approved these changes
Jun 12, 2026
Raymond-MS
left a comment
Collaborator
There was a problem hiding this comment.
Good catch! Just some minor comments.
Per ARM DEN0138 'TPM Service CRB Interface Over FF-A':
CRB_FFA_DENIED: the TPM has previously DISABLED locality
requests and command processing at the
given locality
CRB_FFA_INV_CRB_CTRL_DATA: CRB control data or locality control
data at the given TPM locality is not valid
The SP currently returns DENIED for two scenarios that don't match
the DENIED semantics:
1. handle_command() falls through to a default 'Denied' status
whenever no state-transition bit is set in the CRB control_request
/ control_start registers (e.g., the host issues Start(COMMAND)
before writing cmdReady).
2. handle_locality_request() returns 'Denied' when neither the
RELINQUISH nor REQUEST_ACCESS bit is set in locality_control.
Both are 'host gave us a Start with empty CRB control data', which
per DEN0138 is INV_CRB_CTRL_DATA, not DENIED. The TianoCore EDK2
client maps INV_CRB_CTRL_DATA to EFI_COMPROMISED_DATA and DENIED to
EFI_ACCESS_DENIED — confirming the spec's semantic distinction
between 'malformed CRB' and 'access disabled'.
Fix is two minimal edits to ec-service-lib/src/services/tpm.rs:
- handle_command(): early-return InvCrbCtrlData when both
crb_control_request and crb_control_start are zero.
- handle_locality_request(): change the 'no bits set' branch
return from Denied to InvCrbCtrlData.
Other paths (locality mismatch, closed locality, invalid arguments)
are left as-is — their existing return codes are spec-conformant.
Surfaced from systematic debugging of qemu-sbsa Phase 2 e2e tests
(tpm_start_command_locality_mismatch, tpm_start_command_idle_no_bits,
tpm_start_locality_no_crb_bits). The qemu-sbsa test expectations
are updated in a companion commit.
References:
- Linux kernel driver: drivers/char/tpm/tpm_crb_ffa.c (CRB_FFA_START documented function status codes)
- TianoCore EDK2: SecurityPkg/Library/Tpm2DeviceLibFfa/Tpm2ServiceFfaRaw.c::TranslateTpmReturnStatus
Assisted-by: GitHub Copilot:claude-opus-4.7-1m-internal
5fd3231 to
6d164c9
Compare
Raymond-MS
approved these changes
Jun 12, 2026
kurtjd
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per ARM DEN0138 TPM Service CRB Interface Over FF-A, the
Startfunction's response codes have these semantics:The SP currently returns
DENIEDfor two scenarios that don't fit the spec's DENIED semantics:handle_command()falls through to a defaultDeniedwhenever no state-transition bit is set in the CRBcontrol_request/control_startregisters (e.g., the host issuesStart(COMMAND)before writingcmdReady).handle_locality_request()returnsDeniedwhen neither theRELINQUISHnorREQUEST_ACCESSbit is set inlocality_control.Both cases are "host issued Start with empty CRB control data" — which per DEN0138 is
INV_CRB_CTRL_DATA, notDENIED. The semantic distinction is corroborated by two independent authoritative consumers of DEN0138:drivers/char/tpm/tpm_crb_ffa.c): theCRB_FFA_STARTdocstring lists the same four status codes with the same semantics.SecurityPkg/Library/Tpm2DeviceLibFfa/Tpm2ServiceFfaRaw.c::TranslateTpmReturnStatus): mapsINV_CRB_CTRL_DATA→EFI_COMPROMISED_DATAandDENIED→EFI_ACCESS_DENIED, confirming the distinction between "malformed CRB" and "access disabled."Diff
Two minimal edits to
ec-service-lib/src/services/tpm.rs:Other paths (locality mismatch, closed locality, invalid arguments, source-id check) are left as-is — their existing return codes are spec-conformant. SP unit tests are unaffected (none exercise the "no bits set" paths).
Surfaced from / verified by
Systematic debugging of
odp-platform-qemu-sbsa's Phase 2 e2e tests (tpm_start_command_locality_mismatch,tpm_start_command_idle_no_bits,tpm_start_locality_no_crb_bits). Companion test-side change for the qemu-sbsa harness is being prepared as a super-PR that bundles 4 related fixes (TPM device wiring, CI gate, uart-logger retarget, TPM test alignment) — it bumps the submodule to this commit.Verified locally inside the qemu-sbsa devcontainer: with this SP fix + the qemu-sbsa side fixes stacked,
make e2e-test QEMU_TIMEOUT=900reportsRESULT: ALL TESTS PASSED(27/27).