Skip to content

hw/tpm: CRB chunking capability to handle PQC

Arun Menon qemu-devel 7 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest6 patches 0 repliesNew
  2. v66 patches 4 repliesSuperseded
  3. v510 patches 13 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v410 patches4 repliesSuperseded
v310 patches11 repliesSuperseded
v2 RFC7 patches13 repliesSuperseded
v1 RFC5 patches8 repliesSuperseded

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6hw/tpm: Add TPM CRB chunking fieldshw/core/machine.c hw/tpm/tpm_crb.c include/hw/acpi/tpm.h+13 -20 replies
2/6hw/tpm: Refactor CRB_CTRL_START register accesshw/tpm/tpm_crb.c+2 -20 replies
3/6hw/tpm: Add internal buffer state for chunkinghw/tpm/tpm_crb.c+29 -40 replies
4/6hw/tpm: Implement TPM CRB chunking logichw/tpm/tpm_crb.c+130 -130 replies
5/6test/qtest: Add test for tpm crb chunkingtests/qtest/tpm-crb-swtpm-test.c tests/qtest/tpm-util.c tests/qtest/tpm-util.h+109 -150 replies
6/6hw/tpm: Add support for VM migration with TPM CRB chunkinghw/core/machine.c hw/tpm/tpm_crb.c+68 -00 replies

Reviews trailers per patch

All 6 patches have a Reviewed-by or Acked-by.

PatchStefan BergerMarc-André Lureau
1/6R-b R-b
2/6R-b R-b
3/6R-b R-b
4/6R-b R-b
5/6R-b R-b
6/6R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 0/6] hw/tpm: CRB chunking capability to handle PQC

The move to Post Quantum Cryptography (PQC) changes how we manage memory buffers. Unlike classic crypto algorithms like RSA or ECC which used small keys and signatures, PQC algorithms require larger buffers.

The new version of TCG TPM v185 (currently under review [1]) supports sending data/commands in chunks for the CRB (Command Response Buffer) interface. This is in line with the initiative to support PQC algorithms.

This series implements the logic to send and receive data from the linux guest to the TPM backend in chunks, thereby allowing the guest to send larger data buffers. We introduce 2 new control registers called nextChunk and crbRspRetry that will control the START. We also add the CRB Interface Identifier called CapCRBChunk that is set to 1 indicating that the device supports chunking. The default maximum chunk/buffer size is 3968 (4096 - 128) bytes.

During a send operation, the guest driver places data in the CRB buffer and signals nextChunk for each segment until the final chunk is reached. Upon receiving the START signal, QEMU appends the final chunk to its internal buffer and dispatches the complete command to the TPM backend.

For responses, the backend's output is buffered. The guest consumes the first chunk once the START bit is cleared. Subsequent chunks are retrieved by the guest toggling the nextChunk bit, which advances the internal buffer offset and populates the CRB data window.

For this to work, the linux guest tpm driver will also have to
a) probe if CRB chunking is supported
b) send data in chunks if the command length exceeds the chunk size.
c) receive data in chunks by sending a nextChunk signal and accumulate. These patches are posted upstream:
https://lore.kernel.org/lkml/[email protected]/

Dependencies:
This series has a hard dependency on the following patches currently on the mailing list. They must be applied first for this series to function correctly:
1. [PATCH 1/2] migration/vmstate: Add VMState support for GByteArray

2. [PATCH for-11.1] hw: add compat machines for 11.1

[1] https://trustedcomputinggroup.org/wp-content/uploads/PC-Client-Specific-Platform-TPM-Profile-for-TPM-2p0-v1p07_rc1_121225.pdf

v7
--
- Removed error_free() after calling migrate_del_blocker
- Typo fix be_bufer_size to be_buffer_size, and removed a redundant check.

v6
--
- Removed Stefan Berger's patches to make this series CRB-only. The complex TIS changes will be posted later.
- Added a comment in the post_load hook.

v5
--
- Expose cap-chunk only if the binary is run with the new machine type (>11.1). Remove migrate-buffers as this property is not needed.
- Add x-allow-chunk-migration internal property that will help in blocking migration from a source with 11.1 binary and pre 11.1 machine type to pre 11.1 binary and pre 11.1 machine type.
In this case, the source supports cap-chunk, but the destination binary is unaware of the new buffers.
- Add post_load_errp hook, to validate the buffers before the VM is started at the destination.
- Check if cap-chunk is true before processing nextChunk and crbRspRetry from the guest. Patches 01, 04 and 06 have undergone changes.

v4
--
- Add migration blocker to prevent data loss and new hw_compat property called cap_chunk. The chunking feature is now only visible to machine type 11.1 and higher.
- Rename invoke to Start, to comply with the TCG TPM specification.
- Use g_clear_pointer for safety.

v3
--
Patches 1-6
- Fix the issue with subsequent nextChunk signal from the guest while the TPM backend is not done processing the previous request.
- Add tpm_crb_unrealize() to clear buffers
- Update hw_compat to 11.1.
- Use newly introduced GByteArray VMStateInfo for migration. Patches 7-10
- Add Stefan Berger's patches for swtpm profile support, TPM TIS migration support with extended buffer and related tests.
NOTE: I have removed the "WIP" prefix and the "TODO" regarding dynamic allocation from Stefan's final patch, as the static 8192-byte limit is sufficient for the current requirements and passes all local testing.

v2
--
- Add the VM migration support.
- Increase the TIS TPM interface max buffer size to 8192.

Based-on: <[email protected]>
Based-on: <[email protected]>

Arun Menon (6):
hw/tpm: Add TPM CRB chunking fields
hw/tpm: Refactor CRB_CTRL_START register access hw/tpm: Add internal buffer state for chunking hw/tpm: Implement TPM CRB chunking logic test/qtest: Add test for tpm crb chunking hw/tpm: Add support for VM migration with TPM CRB chunking

 hw/core/machine.c                |   5 +-
 hw/tpm/tpm_crb.c                 | 253 ++++++++++++++++++++++++++++---
 include/hw/acpi/tpm.h            |   5 +-
 tests/qtest/tpm-crb-swtpm-test.c |  10 ++
 tests/qtest/tpm-util.c           | 109 +++++++++++--
 tests/qtest/tpm-util.h           |   5 +
 6 files changed, 351 insertions(+), 36 deletions(-)
Signature · 1 line
2.54.0