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/20260324181244.17741-1-armenon@redhat.com/
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
Link: https://lore.kernel.org/all/20260406115247.4879-2-armenon@redhat.com/
2. [PATCH for-11.1] hw: add compat machines for 11.1
Link: https://lore.kernel.org/all/20260331140347.653404-1-cohuck@redhat.com/
[1] https://trustedcomputinggroup.org/wp-content/uploads/PC-Client-Specific-Platform-TPM-Profile-for-TPM-2p0-v1p07_rc1_121225.pdf
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: <20260331140347.653404-1-cohuck@redhat.com>
Based-on: <20260406115247.4879-2-armenon@redhat.com>
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
Stefan Berger (4):
qtests: Enable starting swtpm with a given profile
tests: Use ML-DSA-87 operations to caused large TPM transfers with CRB
tpm: Extend TPM TIS buffer size to 8192 bytes
tests: Use ML-DSA-87 operations to caused large TPM transfers with TIS
hw/core/machine.c | 4 +-
hw/tpm/tpm_crb.c | 218 +++++++++++++++++++++++++++----
hw/tpm/tpm_tis.h | 2 +
hw/tpm/tpm_tis_common.c | 23 ++++
hw/tpm/tpm_tis_i2c.c | 24 +++-
hw/tpm/tpm_tis_isa.c | 24 +++-
hw/tpm/tpm_tis_sysbus.c | 24 +++-
include/hw/acpi/tpm.h | 5 +-
tests/qtest/tpm-crb-swtpm-test.c | 11 ++
tests/qtest/tpm-tests.c | 102 ++++++++++++++-
tests/qtest/tpm-tests.h | 4 +
tests/qtest/tpm-tis-swtpm-test.c | 11 ++
tests/qtest/tpm-util.c | 154 +++++++++++++++++++---
tests/qtest/tpm-util.h | 10 +-
14 files changed, 569 insertions(+), 47 deletions(-)
--
2.53.0