hw/tpm: CRB chunking capability to handle PQC
PATCH v7 2/6 hw/tpm: Refactor CRB_CTRL_START register access
In reply to Arun MenonFrom: Arun Menon <[email protected]>
Replace manual bitwise operations with ARRAY_FIELD_DP32 macros No functional changes.
--- hw/tpm/tpm_crb.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/tpm/tpm_crb.c +2 -2
@@ -146,7 +146,7 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr, tpm_crb_get_active_locty(s) == locty) {void *mem =memory_region_get_ram_ptr (&s->cmdmem); - s->regs[R_CRB_CTRL_START ] |=CRB_START_INVOKE ; +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , Start,1 ); s->cmd = (TPMBackendCmd ) { .in = mem, .in_len =MIN (tpm_cmd_get_size (mem), s->be_buffer_size),
@@ -195,7 +195,7 @@ static void tpm_crb_request_completed(TPMIf *ti, int ret) {CRBState *s =CRB (ti); - s->regs[R_CRB_CTRL_START ] &= ~CRB_START_INVOKE ; +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , Start,0 );if (ret !=0 ) {ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_STS , tpmSts,1 );/* fatal error */
Signature · 1 line
2.54.0
PATCH v7 3/6 hw/tpm: Add internal buffer state for chunking
In reply to Arun MenonFrom: Arun Menon <[email protected]>
- Introduce GByteArray buffers to hold the command request and response data during chunked TPM CRB transactions.
- Add helper function to clean them.
--- hw/tpm/tpm_crb.c | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-)
hw/tpm/tpm_crb.c +29 -4
@@ -38,10 +38,13 @@ struct CRBState {TPMBackend *tpmbe;TPMBackendCmd cmd;uint32_t regs[TPM_CRB_R_MAX ]; +size_t be_buffer_size;MemoryRegion mmio;MemoryRegion cmdmem; -size_t be_buffer_size; +GByteArray *command_buffer; +GByteArray *response_buffer; +uint32_t response_offset;TPMPPI ppi;
@@ -86,6 +89,13 @@ enum crb_cancel {#define TPM_CRB_NO_LOCALITY 0xff +static void tpm_crb_clear_internal_buffers (CRBState *s) +{ +g_byte_array_set_size (s->response_buffer,0 ); +g_byte_array_set_size (s->command_buffer,0 ); + s->response_offset =0 ; +} +static uint64_t tpm_crb_mmio_read (void *opaque,hwaddr addr,unsigned size) {
@@ -135,9 +145,11 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr, }break ;case A_CRB_CTRL_CANCEL : -if (val ==CRB_CANCEL_INVOKE && - s->regs[R_CRB_CTRL_START ] &CRB_START_INVOKE ) { -tpm_backend_cancel_cmd (s->tpmbe); +if (val ==CRB_CANCEL_INVOKE ) { +if (s->regs[R_CRB_CTRL_START ] &CRB_START_INVOKE ) { +tpm_backend_cancel_cmd (s->tpmbe); + } +tpm_crb_clear_internal_buffers (s); }break ;case A_CRB_CTRL_START :
@@ -239,6 +251,7 @@ static void tpm_crb_reset(void *dev)tpm_ppi_reset (&s->ppi);tpm_backend_reset (s->tpmbe); +tpm_crb_clear_internal_buffers (s);memset (s->regs,0 ,sizeof (s->regs));
@@ -305,6 +318,9 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp)memory_region_add_subregion (get_system_memory (),TPM_CRB_ADDR_BASE +sizeof (s->regs), &s->cmdmem); + s->command_buffer =g_byte_array_new (); + s->response_buffer =g_byte_array_new (); +tpm_ppi_init (&s->ppi,get_system_memory (),TPM_PPI_ADDR_BASE ,OBJECT (s));
@@ -315,12 +331,21 @@ static void tpm_crb_realize(DeviceState *dev, Error **errp) } } +static void tpm_crb_unrealize (DeviceState *dev) +{ +CRBState *s =CRB (dev); + +g_clear_pointer (&s->command_buffer, g_byte_array_unref); +g_clear_pointer (&s->response_buffer, g_byte_array_unref); +} +static void tpm_crb_class_init (ObjectClass *klass,const void *data) {DeviceClass *dc =DEVICE_CLASS (klass);TPMIfClass *tc =TPM_IF_CLASS (klass); dc->realize = tpm_crb_realize; + dc->unrealize = tpm_crb_unrealize;device_class_set_props (dc, tpm_crb_properties); dc->vmsd = &vmstate_tpm_crb; dc->user_creatable = true;
Signature · 1 line
2.54.0
PATCH v7 4/6 hw/tpm: Implement TPM CRB chunking logic
In reply to Arun MenonFrom: Arun Menon <[email protected]>
- Add logic to populate internal TPM command request and response buffers and to toggle the control registers after each operation.
- The chunk size is limited to CRB_CTRL_CMD_SIZE which is (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER). This comes out as 3968 bytes (4096 - 128 or 0x1000 - 0x80), because 128 bytes are reserved for control and status registers. In other words, only 3968 bytes are available for the TPM data.
- With this feature, guests can send commands larger than 3968 bytes.
- Refer section 6.5.3.9 of [1] for implementation details.
--- hw/tpm/tpm_crb.c | 143 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 130 insertions(+), 13 deletions(-)
hw/tpm/tpm_crb.c +130 -13
@@ -17,6 +17,7 @@#include "qemu/osdep.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "system/address-spaces.h" #include "hw/core/qdev-properties.h"
@@ -66,6 +67,7 @@ DECLARE_INSTANCE_CHECKER(CRBState, CRB,#define CRB_INTF_CAP_CRB_CHUNK 0b1#define CRB_CTRL_CMD_SIZE (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER) +#define TPM_HEADER_SIZE 10enum crb_loc_ctrl {CRB_LOC_CTRL_REQUEST_ACCESS =BIT (0 ),
@@ -81,6 +83,8 @@ enum crb_ctrl_req {enum crb_start {CRB_START_INVOKE =BIT (0 ), +CRB_START_RSP_RETRY =BIT (1 ), +CRB_START_NEXT_CHUNK =BIT (2 ), };enum crb_cancel {
@@ -123,6 +127,69 @@ static uint8_t tpm_crb_get_active_locty(CRBState *s)return ARRAY_FIELD_EX32 (s->regs,CRB_LOC_STATE , activeLocality); } +static bool tpm_crb_append_command_request (CRBState *s) +{ +/* +* The linux guest writes the TPM command to the MMIO region in chunks. +* This function appends a chunk from the MMIO region to internal +* command_buffer. +*/ +void *mem =memory_region_get_ram_ptr (&s->cmdmem); +uint32_t to_copy =0 ; +uint32_t total_request_size =0 ; + +/* +* The initial call extracts the total TPM command size +* from its header. For the subsequent calls, the data already +* appended in the command_buffer is used to calculate the total +* size, as its header stays the same. +*/ +if (s->command_buffer->len ==0 ) { + total_request_size =tpm_cmd_get_size (mem); +if (total_request_size <TPM_HEADER_SIZE ) { +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_STS , tpmSts,1 ); +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , Start,0 ); +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , nextChunk,0 ); +tpm_crb_clear_internal_buffers (s); +error_report ("Command size %" PRIu32" less than " +"TPM header size %" PRIu32, + total_request_size, (uint32_t )TPM_HEADER_SIZE ); +return false; + } + }else { + total_request_size =tpm_cmd_get_size (s->command_buffer->data); + } + total_request_size =MIN (total_request_size, s->be_buffer_size); + +if (total_request_size > s->command_buffer->len) { +uint32_t remaining = total_request_size - s->command_buffer->len; + to_copy =MIN (remaining,CRB_CTRL_CMD_SIZE ); +g_byte_array_append (s->command_buffer, (guint8 *)mem, to_copy); + } +return true; +} + +static void tpm_crb_fill_command_response (CRBState *s) +{ +/* +* Response from the tpm backend will be stored in the internal +* response_buffer. This function will serve that accumulated response +* to the linux guest in chunks by writing it back to MMIO region. +*/ +void *mem =memory_region_get_ram_ptr (&s->cmdmem); +uint32_t remaining = s->response_buffer->len - s->response_offset; +uint32_t to_copy =MIN (CRB_CTRL_CMD_SIZE , remaining); + +memcpy (mem, s->response_buffer->data + s->response_offset, to_copy); + +if (to_copy <CRB_CTRL_CMD_SIZE ) { +memset ((guint8 *)mem + to_copy,0 ,CRB_CTRL_CMD_SIZE - to_copy); + } + + s->response_offset += to_copy; +memory_region_set_dirty (&s->cmdmem,0 ,CRB_CTRL_CMD_SIZE ); +} +static void tpm_crb_mmio_write (void *opaque,hwaddr addr,uint64_t val,unsigned size) {
@@ -153,20 +220,58 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr, }break ;case A_CRB_CTRL_START : -if (val ==CRB_START_INVOKE && - !(s->regs[R_CRB_CTRL_START ] &CRB_START_INVOKE ) && -tpm_crb_get_active_locty (s) == locty) { -void *mem =memory_region_get_ram_ptr (&s->cmdmem); - +if (tpm_crb_get_active_locty (s) != locty) { +break ; + } +if (s->regs[R_CRB_CTRL_START ] &CRB_START_INVOKE ) { +/* +* Backend TPM is busy processing a request. +*/ +break ; + } +if (val &CRB_START_INVOKE ) { +if (!tpm_crb_append_command_request (s)) { +break ; + }ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , Start,1 ); +g_byte_array_set_size (s->response_buffer, s->be_buffer_size); s->cmd = (TPMBackendCmd ) { - .in = mem, - .in_len =MIN (tpm_cmd_get_size (mem), s->be_buffer_size), - .out = mem, - .out_len = s->be_buffer_size, + .in = s->command_buffer->data, + .in_len = s->command_buffer->len, + .out = s->response_buffer->data, + .out_len = s->response_buffer->len, }; -tpm_backend_deliver_request (s->tpmbe, &s->cmd); + }else if (val &CRB_START_NEXT_CHUNK ) { +if (!s->cap_chunk) { +break ; + } +/* +* nextChunk is used both while sending and receiving data. +* To distinguish between the two, response_buffer is checked. +* If it does not have data, then that means we have not yet +* sent the command to the tpm backend, and therefore call +* tpm_crb_append_command_request(). +*/ +if (s->response_buffer->len >0 && + s->response_offset < s->response_buffer->len) { +tpm_crb_fill_command_response (s); + }else { +if (!tpm_crb_append_command_request (s)) { +break ; + } + } +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , nextChunk,0 ); + }else if (val &CRB_START_RSP_RETRY ) { +if (!s->cap_chunk) { +break ; + } +if (s->response_buffer->len >0 ) { + s->response_offset =0 ; +tpm_crb_fill_command_response (s); + } +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , crbRspRetry,0 ); +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , nextChunk,0 ); }break ;case A_CRB_LOC_CTRL :
@@ -211,8 +316,21 @@ static void tpm_crb_request_completed(TPMIf *ti, int ret)if (ret !=0 ) {ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_STS , tpmSts,1 );/* fatal error */ +tpm_crb_clear_internal_buffers (s); + }else { +uint32_t actual_resp_size =tpm_cmd_get_size (s->response_buffer->data); +uint32_t total_resp_size =MIN (actual_resp_size, s->be_buffer_size); +g_byte_array_set_size (s->response_buffer, total_resp_size); + s->response_offset =0 ; } -memory_region_set_dirty (&s->cmdmem,0 ,CRB_CTRL_CMD_SIZE ); +/* +* Send the first chunk. Subsequent chunks will be sent +* on receiving nextChunk from the guest +*/ +tpm_crb_fill_command_response (s); +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , nextChunk,0 ); +ARRAY_FIELD_DP32 (s->regs,CRB_CTRL_START , crbRspRetry,0 ); +g_byte_array_set_size (s->command_buffer,0 ); }static enum TPMVersion tpm_crb_get_version (TPMIf *ti)
@@ -287,8 +405,7 @@ static void tpm_crb_reset(void *dev) s->regs[R_CRB_CTRL_RSP_SIZE ] =CRB_CTRL_CMD_SIZE ; s->regs[R_CRB_CTRL_RSP_ADDR ] =TPM_CRB_ADDR_BASE +A_CRB_DATA_BUFFER ; - s->be_buffer_size =MIN (tpm_backend_get_buffer_size (s->tpmbe), -CRB_CTRL_CMD_SIZE ); + s->be_buffer_size =tpm_backend_get_buffer_size (s->tpmbe);if (tpm_backend_startup_tpm (s->tpmbe, s->be_buffer_size) <0 ) {exit (1 );
Signature · 1 line
2.54.0
v7 cover 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
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
PATCH v7 1/6 hw/tpm: Add TPM CRB chunking fields
From: Arun Menon <[email protected]>
- Add new fields to the CRB Interface Identifier and the CRB Control Start registers.
- CRB_CTRL_START now has 2 new settings, that can be toggled using the nextChunk and crbRspRetry bits.
- CapCRBChunk bit (10) was Reserved1 previously. The field is reused in this revision of the specification. Refer to section 6.4.2.2 of [1]
- Add hw_compat global property called cap-chunk because the chunking feature is only supported for machine type 11.1 and higher.
--- hw/core/machine.c | 4 +++- hw/tpm/tpm_crb.c | 6 ++++++ include/hw/acpi/tpm.h | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-)
hw/core/machine.c +3 -1
@@ -39,7 +39,9 @@#include "hw/acpi/generic_event_device.h" #include "qemu/audio.h" -GlobalProperty hw_compat_11_0[] = {}; +GlobalProperty hw_compat_11_0[] = { + {"tpm-crb" ,"cap-chunk" ,"off" }, +};const size_t hw_compat_11_0_len =G_N_ELEMENTS (hw_compat_11_0);GlobalProperty hw_compat_10_2[] = {
hw/tpm/tpm_crb.c +6 -0
@@ -44,6 +44,8 @@ struct CRBState {size_t be_buffer_size;TPMPPI ppi; + +bool cap_chunk; };typedef struct CRBState CRBState ;
@@ -58,6 +60,7 @@ DECLARE_INSTANCE_CHECKER(CRBState, CRB,#define CRB_INTF_CAP_FIFO_NOT_SUPPORTED 0b0#define CRB_INTF_CAP_CRB_SUPPORTED 0b1#define CRB_INTF_IF_SELECTOR_CRB 0b1 +#define CRB_INTF_CAP_CRB_CHUNK 0b1#define CRB_CTRL_CMD_SIZE (TPM_CRB_ADDR_SIZE - A_CRB_DATA_BUFFER)
@@ -227,6 +230,7 @@ static const VMStateDescription vmstate_tpm_crb = {static const Property tpm_crb_properties[] = {DEFINE_PROP_TPMBE ("tpmdev" , CRBState, tpmbe), +DEFINE_PROP_BOOL ("cap-chunk" , CRBState, cap_chunk, true), };static void tpm_crb_reset (void *dev)
@@ -258,6 +262,8 @@ static void tpm_crb_reset(void *dev) CapCRB, CRB_INTF_CAP_CRB_SUPPORTED);ARRAY_FIELD_DP32 (s->regs,CRB_INTF_ID , InterfaceSelector,CRB_INTF_IF_SELECTOR_CRB ); +ARRAY_FIELD_DP32 (s->regs,CRB_INTF_ID , + CapCRBChunk, s->cap_chunk ?CRB_INTF_CAP_CRB_CHUNK :0 );ARRAY_FIELD_DP32 (s->regs,CRB_INTF_ID ,RID ,0b0000 ); ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID2,
include/hw/acpi/tpm.h +4 -1
@@ -150,7 +150,7 @@ REG32(CRB_INTF_ID, 0x30) FIELD(CRB_INTF_ID, InterfaceVersion, 4, 4) FIELD(CRB_INTF_ID, CapLocality, 8, 1) FIELD(CRB_INTF_ID, CapCRBIdleBypass, 9, 1) - FIELD(CRB_INTF_ID, Reserved1, 10, 1) + FIELD(CRB_INTF_ID, CapCRBChunk, 10, 1) FIELD(CRB_INTF_ID, CapDataXferSizeSupport, 11, 2) FIELD(CRB_INTF_ID, CapFIFO, 13, 1)FIELD (CRB_INTF_ID , CapCRB,14 ,1 )
@@ -169,6 +169,9 @@ REG32(CRB_CTRL_STS, 0x44) FIELD(CRB_CTRL_STS, tpmIdle, 1, 1) REG32(CRB_CTRL_CANCEL, 0x48) REG32(CRB_CTRL_START, 0x4C) + FIELD(CRB_CTRL_START, Start, 0, 1) + FIELD(CRB_CTRL_START, crbRspRetry, 1, 1) + FIELD(CRB_CTRL_START, nextChunk, 2, 1) REG32(CRB_INT_ENABLED, 0x50) REG32(CRB_INT_STS, 0x54)REG32 (CRB_CTRL_CMD_SIZE ,0x58 )
Signature · 1 line
2.54.0
PATCH v7 6/6 hw/tpm: Add support for VM migration with TPM CRB chunking
In reply to Arun MenonFrom: Arun Menon <[email protected]>
- Add subsection in VMState for TPM CRB with the newly introduced command and response buffer GByteArrays, along with a needed callback, so that newer QEMU only sends the buffers if it is necessary.
- Implement a migration blocker to prevent migration of the VM if the user manually enables chunking capability, cap-chunk, but the machine type does not support it, using a new hw_compat property called allow_chunk_migration.
- Add a post_load_errp hook so that during a migration, the buffers are validated before destination VM is started.
--- hw/core/machine.c | 1 + hw/tpm/tpm_crb.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+)
hw/core/machine.c +1 -0
@@ -41,6 +41,7 @@GlobalProperty hw_compat_11_0[] = { {"tpm-crb" ,"cap-chunk" ,"off" }, + {"tpm-crb" ,"x-allow-chunk-migration" ,"off" }, };const size_t hw_compat_11_0_len =G_N_ELEMENTS (hw_compat_11_0);
hw/tpm/tpm_crb.c +67 -0
115 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v7 5/6 test/qtest: Add test for tpm crb chunking
In reply to Arun MenonFrom: Arun Menon <[email protected]>
- New test case added to the swtpm test. Data is written and read from the buffer in chunks.
- The chunk size is dynamically calculated by reading the CRB_CTRL_CMD_SIZE address. This can be changed manually to test.
- Add a helper function tpm_wait_till_bit_clear()
- Note that this commit does not yet exercise the chunked read/write logic, as current transfer sizes remain small. Testing for large transfers is introduced in a subsequent patch: 'tests: Use ML-DSA-87 operations to cause large TPM transfers with CRB'
--- tests/qtest/tpm-crb-swtpm-test.c | 10 +++ tests/qtest/tpm-util.c | 109 ++++++++++++++++++++++++++----- tests/qtest/tpm-util.h | 5 ++ 3 files changed, 109 insertions(+), 15 deletions(-)
tests/qtest/tpm-crb-swtpm-test.c +10 -0
@@ -33,6 +33,14 @@ static void tpm_crb_swtpm_test(const void *data) "tpm-crb", NULL); } +static void tpm_crb_chunk_swtpm_test (const void *data) +{ +const TestState *ts = data; + +tpm_test_swtpm_test (ts->src_tpm_path, tpm_util_crb_chunk_transfer, +"tpm-crb" ,NULL ); +} +static void tpm_crb_swtpm_migration_test (const void *data) {const TestState *ts = data;
@@ -54,6 +62,8 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );qtest_add_data_func ("/tpm/crb-swtpm/test" , &ts, tpm_crb_swtpm_test); +qtest_add_data_func ("/tpm/crb-chunk-swtpm/test" , &ts, + tpm_crb_chunk_swtpm_test);qtest_add_data_func ("/tpm/crb-swtpm-migration/test" , &ts, tpm_crb_swtpm_migration_test); ret =g_test_run ();
tests/qtest/tpm-util.c +94 -15
134 lines not on this page · raw message
tests/qtest/tpm-util.h +5 -0
@@ -24,10 +24,15 @@ typedef void (tx_func)(QTestState *s, const unsigned char *req, size_t req_size, unsigned char *rsp, size_t rsp_size); +void tpm_wait_till_bit_clear (QTestState *s,uint64_t addr,uint32_t mask);void tpm_util_crb_transfer (QTestState *s,const unsigned char *req,size_t req_size,unsigned char *rsp,size_t rsp_size); +void tpm_util_crb_chunk_transfer (QTestState *s, +const unsigned char *req,size_t req_size, +unsigned char *rsp,size_t rsp_size); +void tpm_util_startup (QTestState *s,tx_func *tx);void tpm_util_pcrextend (QTestState *s,tx_func *tx); void tpm_util_pcrread(QTestState *s, tx_func *tx,
Signature · 1 line
2.54.0