Re: [PATCH RFC v2 1/9] attestation: Add the base family specification and generated files
From: Jason Gunthorpe
Date: Thu Nov 26 2026 - 19:26:05 EST
> [ ... 60 lines skipped ... ]
> +++ b/Documentation/ctlv/abi/ctlv-attestation.yaml
> @@ -0,0 +1,147 @@
> +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> +%YAML 1.2
> +---
> +# Checked-in ABI snapshot of the ctlv-attestation family, from
> +# Documentation/ctlv/specs/ctlv-attestation.yaml, written by
> +# "make -C tools/ctlv regen".
> +#
> +# Updating the file is how a UAPI change gets reviewed; an update that
> +# removes or renumbers anything, narrows a bound, or makes a member required
> +# is an ABI break, whatever the file says afterwards.
> +family: {name: ctlv-attestation, id: 1, inherits: ctlv}
> +enums:
> + evidence-class: {signed: 1, event-log: 2}
> + evidence-format: {ccel: 1}
> + hash-algo: {$header: linux/hash_info.h, $enum: hash_algo,
> + $end: HASH_ALGO__LAST}
I feel like this should parse the C enum into numbers here so the ABI
can be checked too?
> +flags:
> + mr-device-caps: {extend: 0}
> + mr-caps: {extend: 0}
> +records:
> + mr-desc:
> + id: 0x00010000
> + fields:
> + name: {number: 1, type: string, min-length: 1, max-length: 128}
> + supported-hash-algorithms: {number: 2, enum: hash-algo,
> + max-occurrences: hash-algo}
> + caps: {number: 3, flags: mr-caps}
> + register-index: {number: 4, type: uint, max: u32-max, optional: true}
> + mr-value:
> + id: 0x00020000
> + fields:
> + hash-algo: {number: 1, enum: hash-algo}
> + data: {number: 2, type: binary, min-length: 16, max-length: 64}
> + mr-generation:
> + id: 0x00030000
> + fields:
> + mr-generation: {number: 1, type: uint, max: u32-max}
> + mr-values:
> + id: 0x00040000
> + fields:
> + mr-values: {number: 1, record: mr-value, max-occurrences: hash-algo}
> + device-get request:
> + id: 0x80010000
> + device-get reply:
> + id: 0xc0010000
> + fields:
> + caps: {number: 1, record: device-get caps}
> + info: {number: 2, extension: device-info}
> + device-get caps:
> + id: 0xc0011000
> + fields:
> + evidence: {number: 1, record: device-get caps.evidence, optional: true}
> + mr: {number: 2, record: device-get caps.mr, optional: true}
> + device-get caps.evidence:
> + id: 0xc0011100
> + fields:
> + objects: {number: 1, record: device-get caps.evidence.objects,
> + max-occurrences: 16}
> + device-get caps.evidence.objects:
> + id: 0xc0011110
> + fields:
> + id: {number: 1, type: uint, max: 15}
> + class: {number: 2, enum: evidence-class}
> + formats: {number: 3, enum: evidence-format, max-occurrences: 4,
> + optional: true}
> + vendor-formats: {number: 4, enum: evidence-vendor-format,
> + max-occurrences: 4, optional: true}
> + max-length: {number: 5, type: uint}
> + challenge-lengths:
> + {number: 6, record: device-get caps.evidence.objects.challenge-lengths,
> + max-occurrences: 8, optional: true}
> + device-get caps.evidence.objects.challenge-lengths:
> + id: 0xc0011111
> + fields:
> + length: {number: 1, type: uint, min: 1, max: 4K, unit: bytes,
> + optional: true}
> + min-length: {number: 2, type: uint, min: 1, max: 4K, unit: bytes,
> + optional: true}
> + max-length: {number: 3, type: uint, min: 1, max: 4K, unit: bytes,
> + optional: true}
> + device-get caps.mr:
> + id: 0xc0011200
> + fields:
> + flags: {number: 1, flags: mr-device-caps}
> + evidence-get request:
> + id: 0x80020000
> + fields:
> + challenge: {number: 1, type: binary, min-length: 1, max-length: 4K,
> + optional: true}
> + objects: {number: 2, record: evidence-get objects, max-occurrences: 16}
> + evidence-get objects:
> + id: 0x80021000
> + fields:
> + id: {number: 1, type: uint, max: 15}
> + data: {number: 2, blob: output, backings: [va], max-length: u32-max}
> + evidence-get reply:
> + id: 0xc0020000
> + fields:
> + results: {number: 1, record: evidence-get results, max-occurrences: 16}
> + members: ['record mr-generation?']
> + evidence-get results:
> + id: 0xc0021000
> + fields:
> + format: {number: 1, enum: evidence-format, optional: true}
> + vendor-format: {number: 2, enum: evidence-vendor-format, optional: true}
> + length: {number: 3, type: uint}
> + mr-get request:
> + id: 0x80030000
> + fields:
> + id: {number: 1, type: uint, max: u32-max, optional: true}
> + mr-get reply:
> + id: 0xc0030000
> + fields:
> + items: {number: 1, record: mr-get items, max-occurrences: unlimited}
> + mr-get items:
> + id: 0xc0031000
> + fields:
> + id: {number: 1, type: uint, max: u32-max}
> + members: [$include mr-desc]
> + mr-read request:
> + id: 0x80040000
> + fields:
> + id: {number: 1, type: uint, max: u32-max}
> + mr-read reply:
> + id: 0xc0040000
> + members: [record mr-generation, record mr-values]
> + mr-extend request:
> + id: 0x80050000
> + fields:
> + id: {number: 1, type: uint, max: u32-max}
> + members: [record mr-values]
> + mr-extend reply:
> + id: 0xc0050000
> + members: [record mr-generation]
> +extensions: {device-info: 1}
> +enum-extensions: {evidence-vendor-format: 1}
> +ops:
> + device-get: {id: 1, type: action, fd-access: read,
> + request: device-get request, reply: device-get reply}
> + evidence-get: {id: 2, type: action, availability: dynamic, optional: true,
> + request: evidence-get request, reply: evidence-get reply}
> + mr-get: {id: 3, type: query, fd-access: read, optional: true,
> + request: mr-get request, reply: mr-get reply}
> + mr-read: {id: 4, type: query, fd-access: read, optional: true,
> + request: mr-read request, reply: mr-read reply}
> + mr-extend: {id: 5, type: action, optional: true, request: mr-extend request,
> + reply: mr-extend reply}
> diff --git a/Documentation/ctlv/abi/families.registry.yaml b/Documentation/ctlv/abi/families.registry.yaml
> index 5845e745777150..7a5c6af2956578 100644
> --- a/Documentation/ctlv/abi/families.registry.yaml
> +++ b/Documentation/ctlv/abi/families.registry.yaml
> @@ -5,3 +5,4 @@
> # Written by "make -C tools/ctlv regen".
> families:
> - ctlv
> + - ctlv-attestation
> diff --git a/Documentation/ctlv/families.yaml b/Documentation/ctlv/families.yaml
> index 4d219d7af74a79..dbb0243b873d68 100644
> --- a/Documentation/ctlv/families.yaml
> +++ b/Documentation/ctlv/families.yaml
> @@ -15,3 +15,4 @@
>
> families:
> - ctlv
> + - ctlv-attestation
> diff --git a/Documentation/ctlv/generated-files.yaml b/Documentation/ctlv/generated-files.yaml
> index d4766b176ceb98..00a56634805d40 100644
> --- a/Documentation/ctlv/generated-files.yaml
> +++ b/Documentation/ctlv/generated-files.yaml
> @@ -16,3 +16,10 @@ families:
> kernel-header: include/linux/ctlv_gen.h
> kernel-source: lib/ctlv/ctlv_gen.c
> user-source: tools/ctlv/libctlv/ctlv_user_gen.c
> +
> + - name: ctlv-attestation
> + source: Documentation/ctlv/specs/ctlv-attestation.yaml
> + outputs:
> + uapi-header: include/uapi/ctlv/ctlv_attestation_gen.h
> + kernel-header: drivers/attestation/generated/ctlv_attestation_gen.h
> + kernel-source: drivers/attestation/generated/ctlv_attestation_gen.c
> diff --git a/Documentation/ctlv/specs/ctlv-attestation.yaml b/Documentation/ctlv/specs/ctlv-attestation.yaml
> new file mode 100644
> index 00000000000000..78b2dad6318a6f
> --- /dev/null
> +++ b/Documentation/ctlv/specs/ctlv-attestation.yaml
> @@ -0,0 +1,181 @@
> +# SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)
> +%YAML 1.2
> +---
> +# Attestation devices: evidence and measurement registers (MRs). The device's
> +# family inherits this one, fills device-info and gives evidence-vendor-format
> +# the formats its vendor defines.
> +family: ctlv-attestation
> +inherits: ctlv
This is much easier to read, I think it works well like this!
> +
> +enums:
> + # What an evidence object is.
> + evidence-class:
> + # Made by evidence-get over its challenge, and signed by the root of
> + # trust.
> + - signed
> + # The platform's log of what firmware and the boot chain measured into
> + # the MRs. Later extends, through mr-extend or otherwise, are not in it.
> + - event-log
> + # A layout of an evidence object that a standard defines.
> + evidence-format:
> + # The log area of an ACPI CCEL table, a TCG crypto-agile event log.
> + - ccel
Lets be in the habit of including a detailed spec reference for things
that are standards.
> + # A layout of an evidence object that one vendor defines, given by the
> + # device's family.
> + evidence-vendor-format: extension
I find this 'standard' 'vendor' distinction confusing. Is this an
artifact of the compilation process?
This would be more usable if there was one enum but both this yaml and
the driver yaml can contribute values to it. If we made an 'extendable
enum' then the values could be full 64 bit ID numbers with the tree
coding so that the extension works the same way as a op and record?
Though I'm a bit nervous about what happens if something in a driver
turns into a standard. It would be nice to be able to make the
driver's ID promoted to a global ID without changing the ID. That
sounds like something the generator could learn to do later I guess.
The comment should be improved to define what consitutes a 'format'. I
was advocating that the format should define enough to check the
signature and the challenge universally.
Like Peter described the new TDX evidence as "tdx-quote-eat-cwt-1.0".
Poking at the IETF RFCs with AI a bit I think it should be described
as "CWT EAT" in this language. The EAT RFC defines the location of the
challenge and uses the CWT packaging which defines how the signature
is placed.
I think ARM uses this format too, IDK what AMD uses.
The EAT itself should have information inside that describes the
"tdx-quote-1.0" idea, so we don't need it externally.
> + # The kernel's hash algorithms.
> + hash-algo:
> + $header: linux/hash_info.h
> + $enum: hash_algo
> + $end: HASH_ALGO__LAST
> +
> +flags:
> + # What a device offers for its MRs.
> + mr-device-caps:
> + # mr-extend is provided.
> + - extend
I guessed the userspace should learn what operations are supported
using introspection directly on the operation? Do we need to specify
what ops are implemented in device-get?
> [ ... 5 lines skipped ... ]
> +records:
> + # One MR, as mr-get describes it.
> + mr-desc:
> + # The platform's name for the MR, such as rtmr0.
> + name: string(1..128)
> + # Its banks, each once, in the provider's order.
> + supported-hash-algorithms[hash-algo]: hash-algo
I wonder if it would be wise to put a bit more syntax here:
supported-hash-algorithms[num_entries(hash-algo)]: hash-algo
Just to be clear about exactly what is being extracted from
hash_algo.. It is the total number of entries, not the maximum value
or something else.
> + # What it allows.
> + caps: mr-caps
> + # The hardware's number for the MR, where it has one: 0 for rtmr0.
> + register-index?: uint(..u32-max)
> +
> + # One bank of an MR.
> + mr-value:
> + # The bank's algorithm.
> + hash-algo: hash-algo
> + # The digest, as long as hash-algo's.
> + data: binary(16..64)
> +
> + # The device's MR generation, which each extend bumps.
> + mr-generation: uint(..u32-max)
> +
> + # Values for banks of the MR, each bank once.
> + mr-values[hash-algo]: record mr-value
> +
> +ops:
> + # What the device can do, and its family's fields.
> + device-get:
> + type: action
> + fd-access: read
> + reply:
> + # What the device supports, fixed for its life.
> + caps:
> + # Present when the device produces evidence.
> + evidence?:
> + # One per object evidence-get can produce.
> + objects[16]:
> + # The device's handle for the object in requests.
> + id: uint(..15)
> + # What the object is.
> + class: evidence-class
> + # The layouts a standard defines that the object may have. At
> + # least one of formats and vendor-formats is present.
> + formats[4]?: evidence-format
> + # The layouts its vendor defines that the object may have.
> + vendor-formats[4]?: evidence-vendor-format
How do we want to fit AMD's unique GUID scheme into this?
I'm not sure we should be passing a GUID from userspace to select an
opaque blob. If not then the kernel could have the GUID list and
report the correct evidence formats as options here?
But then this is maybe a bit limiting because the format is supposed
to be the basic envelope, but the AMD version uses almost the same
format but they are still different. Though I suppose the difference
in the nonce calculation warrants a second format.
And then how does generic userspace even know which one to pick? List
them all? Should kernel give some 'default signed evidence' ID ?
So many questions :(
> + # The longest the object gets; a blob this long always holds it.
> + max-length: uint
> + # A signed object's challenge lengths: each entry is one length,
> + # or a range from min-length to max-length.
> + challenge-lengths[8]?:
> + # A single length.
> + length?: uint(1..4K, bytes)
> + # The shortest of a range.
> + min-length?: uint(1..4K, bytes)
> + # The longest of a range.
> + max-length?: uint(1..4K, bytes)
The comments should be more prescriptive on how userspace has to
handle this. I guess if length appears then that length must be used,
otherwise within the range described by min/max length
But I wonder if this is worth some additional schema support to define
a tagged union?
> + # Present when the device has MRs.
> + mr?:
> + # The MR operations the device provides.
> + flags: mr-device-caps
> + # The device's family's fields.
> + info: extension device-info
> +
> + # Evidence objects, written into the caller's blobs. A signed object is made
> + # by the call, over the challenge, and never reused; the others are read as
> + # they stand at the call.
> + evidence-get:
> + type: action
> + fd-access: read-write
> + availability: dynamic
> + optional: true
> + request:
> + # Bound into each signed object named: pass a verifier's nonce, or a hash
> + # binding one to your context, never data a peer chose. Present exactly
> + # when a signed object is named, and of a length each of them takes.
> + challenge?: binary(1..4K)
> + # The objects to produce, each named once.
> + objects[16]:
> + # The object, by the ID device-get lists.
> + id: uint(..15)
> + # Where the object is written. One too short for it fails the op with
> + # EMSGSIZE, and error-info's required-length says how long it has to
> + # be.
> + data: blob(out, va)
What will this be like when we add memfd later?
> + reply:
> + # One per object, in request order.
> + results[16]:
> + # The layout it came in, where a standard defines it. Exactly one of
> + # format and vendor-format is present.
> + format?: evidence-format
> + # The layout it came in, where its vendor defines it.
> + vendor-format?: evidence-vendor-format
> + # The bytes written to its blob.
> + length: uint
> + # Present when the evidence depends on the MRs.
> + mr-generation?: record
Later we will need to add 'tsm controlled challenge' meaning the challenge is
an output not an input,
> +
> + # The MRs' IDs and descriptions, which do not change; mr-read returns
> + # values, which change with every extension and are read from the hardware.
> + mr-get:
> + type: query
> + fd-access: read
> + optional: true
> + suggested-reply-length: 4K
> + request:
> + # Only this MR; every MR without it.
> + id?: uint(..u32-max)
> + reply:
> + # One per MR, ordered by ID.
> + items[]:
> + # The device's handle for the MR in requests.
> + id: uint(..u32-max)
> + $include: mr-desc
> +
> + # One MR's values, and the MR generation they belong to.
> + mr-read:
> + type: query
> + fd-access: read
> + optional: true
> + suggested-reply-length: 4K
> + request:
> + # The MR to read, by the ID mr-get lists.
> + id: uint(..u32-max)
> + reply:
> + mr-generation: record
> + mr-values: record
Can we leave the generation for a followup with more understanding
what it will be used for and how it is computed?
> +
> + # Extends banks of the MR by digests, as TPM2_PCR_Extend.
> + mr-extend:
> + type: action
> + fd-access: read-write
> + optional: true
> + request:
> + # The MR to extend, by the ID mr-get lists.
> + id: uint(..u32-max)
> + # For the banks to extend, each once, in any order.
> + mr-values: record
> + reply:
> + mr-generation: record
The comment should say that mr-values must include exactly every bank
inside the MR, not more or less.
If we want to later add something like a log entry as an option this
is easy to extend for that, right?
This API eventually needs certificates. I expect that Intel is
including the certificates embedded within the EAT returned here as
signed evidence. AFAIK ARM does the same
But AMD seems to pass them through 'auxblob' in tsm_report, so there
should be a certificates API here to get them. SPDM also has them
detached from the evidence.
--
Jason