qtests: Enable starting swtpm with a given profile
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/5 qtests: Enable starting swtpm with a given profile
Enable swtpm to start with a given profile by passing it to swtpm on the command line using
--profile name=<profile name>
Remove any existing TPM 2 state file since applying a new profile to existing state would be refused by swtpm.
--- tests/qtest/tpm-tests.c | 6 +++--- tests/qtest/tpm-util.c | 9 ++++++++- tests/qtest/tpm-util.h | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-)
tests/qtest/tpm-tests.c +3 -3
@@ -43,7 +43,7 @@ void tpm_test_swtpm_test(const char *src_tpm_path, tx_func *tx,return ; } - succ =tpm_util_swtpm_start (src_tpm_path, &swtpm_pid, &addr, &error); + succ =tpm_util_swtpm_start (src_tpm_path, &swtpm_pid, &addr,NULL , &error);g_assert_true (succ); args = g_strdup_printf(
@@ -96,11 +96,11 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path, } succ =tpm_util_swtpm_start (src_tpm_path, &src_tpm_pid, - &src_tpm_addr, &error); + &src_tpm_addr,NULL , &error);g_assert_true (succ); succ =tpm_util_swtpm_start (dst_tpm_path, &dst_tpm_pid, - &dst_tpm_addr, &error); + &dst_tpm_addr,NULL , &error);g_assert_true (succ); tpm_util_migration_start_qemu(&src_qemu, &dst_qemu,
tests/qtest/tpm-util.c +8 -1
@@ -225,7 +225,8 @@ bool tpm_util_swtpm_has_tpm2(void) }gboolean tpm_util_swtpm_start (const char *path,GPid *pid, -SocketAddress **addr,GError **error) +SocketAddress **addr,const char *profilename, +GError **error) {char *swtpm_argv_tpmstate =g_strdup_printf ("dir=%s" , path); char *swtpm_argv_ctrl = g_strdup_printf("type=unixio,path=%s/sock",
@@ -235,11 +236,17 @@ gboolean tpm_util_swtpm_start(const char *path, GPid *pid,g_strdup ("--tpmstate" ), swtpm_argv_tpmstate,g_strdup ("--ctrl" ), swtpm_argv_ctrl,g_strdup ("--tpm2" ), + profilename ?g_strdup ("--profile" ) :NULL , + profilename ?g_strdup_printf ("name=%s" , profilename) :NULL ,NULL }; + g_autofree char *swtpm_state_file;gboolean succ;unsigned i; + swtpm_state_file =g_strdup_printf ("%s/tpm2-00.permall" , path); +g_unlink (swtpm_state_file); + *addr =g_new0 (SocketAddress,1 ); (*addr)->type =SOCKET_ADDRESS_TYPE_UNIX ; (*addr)->u.q_unix.path =g_build_filename (path,"sock" ,NULL );
tests/qtest/tpm-util.h +2 -1
@@ -41,7 +41,8 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx,bool tpm_util_swtpm_has_tpm2 (void );gboolean tpm_util_swtpm_start (const char *path,GPid *pid, -SocketAddress **addr,GError **error); +SocketAddress **addr,const char *profilename, +GError **error);void tpm_util_swtpm_kill (GPid pid);void tpm_util_migrate (QTestState *who,const char *uri);
Signature · 1 line
2.53.0
PATCH 2/5 tests: Use ML-DSA-87 operations to cause large TPM transfers with CRB
In reply to a message not in the archiveTo test large data transfers (receiving and sending) that make use of a CRB chunked transfer, create an ML-DSA-87 key and sign some data with it and receive the 4627 bytes signature. After this send the signature back to the TPM to have the TPM verify the signature.
--- tests/qtest/tpm-crb-swtpm-test.c | 5 +- tests/qtest/tpm-tests.c | 113 +++++++++++++++++++++++++++++++ tests/qtest/tpm-tests.h | 4 ++ tests/qtest/tpm-util.c | 37 ++++++++++ tests/qtest/tpm-util.h | 2 + 5 files changed, 159 insertions(+), 2 deletions(-)
tests/qtest/tpm-crb-swtpm-test.c +3 -2
@@ -37,8 +37,9 @@ 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 ); +tpm_test_swtpm_large_tx_test (ts->src_tpm_path, + tpm_util_crb_chunk_transfer, +"tpm-crb" ,NULL ); }static void tpm_crb_swtpm_migration_test (const void *data)
tests/qtest/tpm-tests.c +113 -0
127 lines not on this page · raw message
tests/qtest/tpm-tests.h +4 -0
@@ -24,4 +24,8 @@ void tpm_test_swtpm_migration_test(const char *src_tpm_path,const char *ifmodel, const char *machine_options); +void tpm_test_swtpm_large_tx_test (const char *src_tpm_path,tx_func *tx, +const char *ifmodel, +const char *machine_options); +#endif /* TESTS_TPM_TESTS_H */
tests/qtest/tpm-util.c +37 -0
@@ -224,6 +224,43 @@ bool tpm_util_swtpm_has_tpm2(void)return has_tpm2; } +bool tpm_util_swtpm_has_profile (const char *profilename, +const char *content) +{ +bool has_profile = false; +char *out =NULL ; +static const char *argv[] = { +"swtpm" ,"socket" ,"--tpm2" ,"--print-profiles" ,NULL + }; + +if (!tpm_util_swtpm_has_tpm2 ()) { +return false; + } + +if (!g_spawn_sync (NULL /* working_dir */ , + (char **)argv, +NULL /* envp */ , +G_SPAWN_SEARCH_PATH , +NULL /* child_setup */ , +NULL /* user_data */ , + &out, +NULL /* err */ , +NULL /* exit_status */ , +NULL )) { +return false; + } + +if (strstr (out, profilename)) { + has_profile = true; + } +if (has_profile && content &&strstr (out, content) ==NULL ) { + has_profile = false; + } + +g_free (out); +return has_profile; +} +gboolean tpm_util_swtpm_start (const char *path,GPid *pid,SocketAddress **addr,const char *profilename,GError **error)
tests/qtest/tpm-util.h +2 -0
@@ -39,6 +39,8 @@ void tpm_util_pcrread(QTestState *s, tx_func *tx, const unsigned char *exp_resp, size_t exp_resp_size);bool tpm_util_swtpm_has_tpm2 (void ); +bool tpm_util_swtpm_has_profile (const char *profilename, +const char *content); gboolean tpm_util_swtpm_start(const char *path, GPid *pid, SocketAddress **addr, const char *profilename,
Signature · 1 line
2.53.0
PATCH 3/5 tpm: Extend TPM TIS buffer size to 8kb for machines >= v11.1
In reply to a message not in the archiveExtend the TIS buffer size to 8kb for machines >= v11.1 and store the first 4096 bytes using VMSTATE_PARTIAL_BUFFER and the rest using VMSTATE_BUFFER_START_MIDDLE when necessary. It is necessary to store the buffer beyond the original 4096 bytes when:
- the user has written more than 4096 bytes to the buffer
- the TPM 2 response is larger than 4096 bytes
Use the .needed function of the VMStateDescription interface to check whether the bytes in the buffer beyond 4096 bytes needed to be saved. The .pre_save function is called before the .needed function so that we can be sure to have received any response packet from the TPM.
Limit the buffer size for machines older than 11.1 to 4096 so that they have the old buffer size as before.
--- hw/core/machine.c | 3 +++ hw/tpm/tpm_tis.h | 12 +++++++++++- hw/tpm/tpm_tis_common.c | 33 ++++++++++++++++++++++++++++++++- hw/tpm/tpm_tis_i2c.c | 28 +++++++++++++++++++++++++++- hw/tpm/tpm_tis_isa.c | 28 +++++++++++++++++++++++++++- hw/tpm/tpm_tis_sysbus.c | 28 +++++++++++++++++++++++++++- 6 files changed, 127 insertions(+), 5 deletions(-)
hw/core/machine.c +3 -0
@@ -42,6 +42,9 @@GlobalProperty hw_compat_11_0[] = { {"tpm-crb" ,"cap-chunk" ,"off" }, {"tpm-crb" ,"x-allow-chunk-migration" ,"off" }, + {"tpm-tis" ,"x-allow-ext-buffer" ,"off" }, + {"tpm-tis-i2c" ,"x-allow-ext-buffer" ,"off" }, + {"tpm-tis-device" ,"x-allow-ext-buffer" ,"off" }, };const size_t hw_compat_11_0_len =G_N_ELEMENTS (hw_compat_11_0);
hw/tpm/tpm_tis.h +11 -1
@@ -33,7 +33,7 @@#define TPM_TIS_IS_VALID_LOCTY (x) ((x) < TPM_TIS_NUM_LOCALITIES) -#define TPM_TIS_BUFFER_MAX 4096 +#define TPM_TIS_BUFFER_MAX 8192 typedef enum { TPM_TIS_STATE_IDLE = 0,
@@ -54,10 +54,13 @@ typedef struct TPMLocality { } TPMLocality; typedef struct TPMState { + const char *devname; + MemoryRegion mmio; unsigned char buffer[TPM_TIS_BUFFER_MAX]; uint16_t rw_offset; + bool allow_ext_buffer; uint8_t active_locty; uint8_t aborting_locty;
@@ -89,4 +92,11 @@ uint32_t tpm_tis_read_data(TPMState *s, hwaddr addr, unsigned size);void tpm_tis_write_data (TPMState *s,hwaddr addr,uint64_t val,uint32_t size);uint16_t tpm_tis_get_checksum (TPMState *s); +bool tpm_tis_ext_buffer_migration_needed (struct TPMState *s); +void tpm_tis_unset_migration_blocker (struct TPMState *s); + +#define MIGRATION_BLOCKER_MESSAGE \ + "The %s device does not support extended buffer migration with " \ + "machine version less than 11.1" +#endif /* TPM_TPM_TIS_H */
hw/tpm/tpm_tis_common.c +32 -1
@@ -33,6 +33,7 @@#include "hw/acpi/tpm.h" #include "hw/pci/pci_ids.h" #include "hw/core/qdev-properties.h" +#include "migration/blocker.h" #include "migration/vmstate.h" #include "system/tpm_backend.h" #include "system/tpm_util.h"
@@ -676,6 +677,7 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,case TPM_TIS_STATE_COMPLETION : s->rw_offset =0 ; +/* shortcut to ready state with C/R set */ s->loc[locty].state =TPM_TIS_STATE_READY ;if (!(s->loc[locty].sts &TPM_TIS_STS_COMMAND_READY )) {
@@ -815,11 +817,16 @@ enum TPMVersion tpm_tis_get_tpm_version(TPMState *s)*/ void tpm_tis_reset (TPMState *s,bool ppi_enabled) { +size_t limit =TPM_TIS_BUFFER_MAX ;int c; s->be_tpm_version =tpm_backend_get_tpm_version (s->be_driver); + +if (!s->allow_ext_buffer) { + limit =4096 ; + } s->be_buffer_size =MIN (tpm_backend_get_buffer_size (s->be_driver), -TPM_TIS_BUFFER_MAX ); + limit);if (ppi_enabled) {tpm_ppi_reset (&s->ppi);
@@ -890,3 +897,27 @@ const VMStateDescription vmstate_locty = { } }; +bool tpm_tis_ext_buffer_migration_needed (struct TPMState *s) +{ +if (!TPM_TIS_IS_VALID_LOCTY (s->active_locty)) { +return false; + } + +switch (s->loc[s->active_locty].state) { +case TPM_TIS_STATE_IDLE : +case TPM_TIS_STATE_READY : +return false; +case TPM_TIS_STATE_RECEPTION : +return s->rw_offset >=4096 ; +case TPM_TIS_STATE_EXECUTION : +/* +* TPM is executing: we cannot know the size of TPM response. +* .pre_save must have been called before (should never get here). +*/ +return false; +case TPM_TIS_STATE_COMPLETION : +return (tpm_cmd_get_size (&s->buffer) >=4096 ); + } +return false; +} +
hw/tpm/tpm_tis_i2c.c +27 -1
@@ -110,13 +110,31 @@ static int tpm_tis_i2c_post_load(void *opaque, int version_id)return 0 ; } +static bool tpm_tis_ext_buffer_migration_needed_i2c (void *opaque) +{ +TPMStateI2C *i2cst = opaque; + +return tpm_tis_ext_buffer_migration_needed (&i2cst->state); +} + +static const VMStateDescription vmstate_tpm_tis_ext_buffer_i2c = { + .name ="tpm-tis/ext_buffer" , + .version_id =0 , + .needed = tpm_tis_ext_buffer_migration_needed_i2c, + .pre_save = tpm_tis_i2c_pre_save, + .fields = (const VMStateField []) { +VMSTATE_BUFFER_START_MIDDLE (state.buffer, TPMStateI2C,4096 ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_tpm_tis_i2c = { .name ="tpm-tis-i2c" , .version_id =0 , .pre_save = tpm_tis_i2c_pre_save, .post_load = tpm_tis_i2c_post_load, .fields = (const VMStateField []) { -VMSTATE_BUFFER (state.buffer, TPMStateI2C), +VMSTATE_PARTIAL_BUFFER (state.buffer, TPMStateI2C,4096 ),VMSTATE_UINT16 (state.rw_offset, TPMStateI2C),VMSTATE_UINT8 (state.active_locty, TPMStateI2C),VMSTATE_UINT8 (state.aborting_locty, TPMStateI2C),
@@ -133,6 +151,10 @@ static const VMStateDescription vmstate_tpm_tis_i2c = { VMSTATE_UINT8(csum_enable, TPMStateI2C),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription *const []) { + &vmstate_tpm_tis_ext_buffer_i2c, +NULL , } };
@@ -489,6 +511,8 @@ static int tpm_tis_i2c_send(I2CSlave *i2c, uint8_t data)static const Property tpm_tis_i2c_properties[] = {DEFINE_PROP_TPMBE ("tpmdev" , TPMStateI2C, state.be_driver), +DEFINE_PROP_BOOL ("x-allow-ext-buffer" , TPMStateI2C, + state.allow_ext_buffer, true), };static void tpm_tis_i2c_realizefn (DeviceState *dev,Error **errp)
@@ -511,6 +535,8 @@ static void tpm_tis_i2c_realizefn(DeviceState *dev, Error **errp)error_setg (errp,"'tpmdev' property is required" );return ; } + + s->devname ="tpm-tis-i2c" ; }static void tpm_tis_i2c_reset (DeviceState *dev)
hw/tpm/tpm_tis_isa.c +27 -1
@@ -49,12 +49,30 @@ static int tpm_tis_pre_save_isa(void *opaque)return tpm_tis_pre_save (&isadev->state); } +static bool tpm_tis_ext_buffer_migration_needed_isa (void *opaque) +{ +TPMStateISA *isadev = opaque; + +return tpm_tis_ext_buffer_migration_needed (&isadev->state); +} + +static const VMStateDescription vmstate_tpm_tis_ext_buffer_isa = { + .name ="tpm-tis/ext_buffer" , + .version_id =0 , + .needed = tpm_tis_ext_buffer_migration_needed_isa, + .pre_save = tpm_tis_pre_save_isa, + .fields = (const VMStateField []) { +VMSTATE_BUFFER_START_MIDDLE (state.buffer, TPMStateISA,4096 ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_tpm_tis_isa = { .name ="tpm-tis" , .version_id =0 , .pre_save = tpm_tis_pre_save_isa, .fields = (const VMStateField []) { -VMSTATE_BUFFER (state.buffer, TPMStateISA), +VMSTATE_PARTIAL_BUFFER (state.buffer, TPMStateISA,4096 ),VMSTATE_UINT16 (state.rw_offset, TPMStateISA),VMSTATE_UINT8 (state.active_locty, TPMStateISA),VMSTATE_UINT8 (state.aborting_locty, TPMStateISA),
@@ -64,6 +82,10 @@ static const VMStateDescription vmstate_tpm_tis_isa = { vmstate_locty, TPMLocality),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription *const[]) { + &vmstate_tpm_tis_ext_buffer_isa, +NULL , } };
@@ -94,6 +116,8 @@ static void tpm_tis_isa_reset(DeviceState *dev)static const Property tpm_tis_isa_properties[] = {DEFINE_PROP_UINT32 ("irq" , TPMStateISA, state.irq_num,TPM_TIS_IRQ ),DEFINE_PROP_TPMBE ("tpmdev" , TPMStateISA, state.be_driver), +DEFINE_PROP_BOOL ("x-allow-ext-buffer" , TPMStateISA, + state.allow_ext_buffer, true), };static void tpm_tis_isa_initfn (Object *obj)
@@ -133,6 +157,8 @@ static void tpm_tis_isa_realizefn(DeviceState *dev, Error **errp)tpm_ppi_init (&s->ppi,isa_address_space (ISA_DEVICE (dev)),TPM_PPI_ADDR_BASE ,OBJECT (dev)); + + s->devname ="tpm-tis" ; }static void build_tpm_tis_isa_aml (AcpiDevAmlIf *adev,Aml *scope)
hw/tpm/tpm_tis_sysbus.c +27 -1
@@ -49,12 +49,30 @@ static int tpm_tis_pre_save_sysbus(void *opaque)return tpm_tis_pre_save (&sbdev->state); } +static bool tpm_tis_ext_buffer_migration_needed_sysbus (void *opaque) +{ +TPMStateSysBus *sbdev = opaque; + +return tpm_tis_ext_buffer_migration_needed (&sbdev->state); +} + +static const VMStateDescription vmstate_tpm_tis_ext_buffer_sysbus = { + .name ="tpm-tis/ext_buffer" , + .version_id =0 , + .needed = tpm_tis_ext_buffer_migration_needed_sysbus, + .pre_save = tpm_tis_pre_save_sysbus, + .fields = (const VMStateField []) { +VMSTATE_BUFFER_START_MIDDLE (state.buffer, TPMStateSysBus,4096 ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_tpm_tis_sysbus = { .name ="tpm-tis" , .version_id =0 , .pre_save = tpm_tis_pre_save_sysbus, .fields = (const VMStateField []) { -VMSTATE_BUFFER (state.buffer, TPMStateSysBus), +VMSTATE_PARTIAL_BUFFER (state.buffer, TPMStateSysBus,4096 ),VMSTATE_UINT16 (state.rw_offset, TPMStateSysBus),VMSTATE_UINT8 (state.active_locty, TPMStateSysBus),VMSTATE_UINT8 (state.aborting_locty, TPMStateSysBus),
@@ -64,6 +82,10 @@ static const VMStateDescription vmstate_tpm_tis_sysbus = { 0, vmstate_locty, TPMLocality),VMSTATE_END_OF_LIST () + }, + .subsections = (const VMStateDescription *const[]) { + &vmstate_tpm_tis_ext_buffer_sysbus, +NULL , } };
@@ -94,6 +116,8 @@ static void tpm_tis_sysbus_reset(DeviceState *dev)static const Property tpm_tis_sysbus_properties[] = {DEFINE_PROP_UINT32 ("irq" , TPMStateSysBus, state.irq_num,TPM_TIS_IRQ ),DEFINE_PROP_TPMBE ("tpmdev" , TPMStateSysBus, state.be_driver), +DEFINE_PROP_BOOL ("x-allow-ext-buffer" , TPMStateSysBus, + state.allow_ext_buffer, true), };static void tpm_tis_sysbus_initfn (Object *obj)
@@ -132,6 +156,8 @@ static void tpm_tis_sysbus_realizefn(DeviceState *dev, Error **errp) }vmstate_register_ram (&s->ppi.ram, dev); + + s->devname ="tpm-tis-device" ; }static void tpm_tis_sysbus_class_init (ObjectClass *klass,const void *data)
Signature · 1 line
2.53.0
PATCH 4/5 tests: Use ML-DSA-87 operations to cause large TPM transfers with TIS
In reply to a message not in the archiveTest large data transfers with the TPM TIS over MMIO and I2C interfaces. To do this, first create an ML-DSA-87 key and sign some data with it. Then receive the 4627 bytes signature and subsequently send the signature back to the TPM to have the TPM verify the signature.
--- tests/qtest/tpm-tis-i2c-swtpm-test.c | 10 ++++++++++ tests/qtest/tpm-tis-swtpm-test.c | 10 ++++++++++ 2 files changed, 20 insertions(+)
tests/qtest/tpm-tis-i2c-swtpm-test.c +10 -0
@@ -36,6 +36,14 @@ static void tpm_tis_i2c_swtpm_test(const void *data) ts->ifmodel, ts->machine_options); } +static void tpm_tis_i2c_large_tx_swtpm_test (const void *data) +{ +const TestState *ts = data; + +tpm_test_swtpm_large_tx_test (ts->src_tpm_path, tpm_tis_i2c_transfer, + ts->ifmodel, ts->machine_options); +} +static void tpm_tis_swtpm_migration_test (const void *data) {const TestState *ts = data;
@@ -67,6 +75,8 @@ int main(int argc, char **argv) aspeed_bus_addr =ast2600_i2c_calc_bus_addr (I2C_DEV_BUS_NUM );qtest_add_data_func ("/tpm/tis-i2c-swtpm/test" , &ts, tpm_tis_i2c_swtpm_test); +qtest_add_data_func ("/tpm/tis-i2c-large-tx-swtpm/test" , &ts, + tpm_tis_i2c_large_tx_swtpm_test);qtest_add_data_func ("/tpm/tis-i2c-swtpm-migration/test" , &ts, tpm_tis_swtpm_migration_test); ret =g_test_run ();
tests/qtest/tpm-tis-swtpm-test.c +10 -0
@@ -36,6 +36,14 @@ static void tpm_tis_swtpm_test(const void *data) "tpm-tis", NULL); } +static void tpm_tis_large_tx_swtpm_test (const void *data) +{ +const TestState *ts = data; + +tpm_test_swtpm_large_tx_test (ts->src_tpm_path, tpm_tis_transfer, +"tpm-tis" ,NULL ); +} +static void tpm_tis_swtpm_migration_test (const void *data) {const TestState *ts = data;
@@ -57,6 +65,8 @@ int main(int argc, char **argv)g_test_init (&argc, &argv,NULL );qtest_add_data_func ("/tpm/tis-swtpm/test" , &ts, tpm_tis_swtpm_test); +qtest_add_data_func ("/tpm/tis-large-tx-swtpm/test" , &ts, + tpm_tis_large_tx_swtpm_test);qtest_add_data_func ("/tpm/tis-swtpm-migration/test" , &ts, tpm_tis_swtpm_migration_test); ret =g_test_run ();
Signature · 1 line
2.53.0
PATCH 5/5 tpm-spapr: Extend buffer size to 8kb for machines >= v11.1
In reply to a message not in the archiveExtend the buffer size to 8kb. Also introduce the allow-ext-buffer property that is set to true for the 11.1 machine and to false for git older machine. If it is set to true, allow the 8kb buffer size and restrict the buffer to the previous 4kb otherwise.
--- hw/core/machine.c | 1 + hw/tpm/tpm_spapr.c | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-)
hw/core/machine.c +1 -0
@@ -45,6 +45,7 @@ GlobalProperty hw_compat_11_0[] = { { "tpm-tis", "x-allow-ext-buffer", "off" }, { "tpm-tis-i2c", "x-allow-ext-buffer", "off" }, { "tpm-tis-device", "x-allow-ext-buffer", "off" }, + { "tpm-spapr", "x-allow-ext-buffer", "off" }, };const size_t hw_compat_11_0_len =G_N_ELEMENTS (hw_compat_11_0);
hw/tpm/tpm_spapr.c +9 -2
@@ -64,7 +64,7 @@ typedef struct TpmCrq {#define SPAPR_VTPM_ERR_COPY_IN_FAILED 0x3#define SPAPR_VTPM_ERR_COPY_OUT_FAILED 0x4 -#define TPM_SPAPR_BUFFER_MAX 4096 +#define TPM_SPAPR_BUFFER_MAX 8192struct SpaprTpmState {SpaprVioDevice vdev;
@@ -86,6 +86,7 @@ struct SpaprTpmState {TPMVersion be_tpm_version;size_t be_buffer_size; +bool allow_ext_buffer; };/*
@@ -293,14 +294,18 @@ static const char *tpm_spapr_get_dt_compatible(SpaprVioDevice *dev)static void tpm_spapr_reset (SpaprVioDevice *dev) {SpaprTpmState *s =VIO_SPAPR_VTPM (dev); +size_t limit =TPM_SPAPR_BUFFER_MAX ; s->state =SPAPR_VTPM_STATE_NONE ; s->numbytes =0 ; s->be_tpm_version =tpm_backend_get_tpm_version (s->be_driver); +if (!s->allow_ext_buffer) { + limit =4096 ; + } s->be_buffer_size =MIN (tpm_backend_get_buffer_size (s->be_driver), -TPM_SPAPR_BUFFER_MAX ); + limit);tpm_backend_reset (s->be_driver);
@@ -367,6 +372,8 @@ static const VMStateDescription vmstate_spapr_vtpm = {static const Property tpm_spapr_properties[] = {DEFINE_SPAPR_PROPERTIES (SpaprTpmState, vdev),DEFINE_PROP_TPMBE ("tpmdev" , SpaprTpmState, be_driver), +DEFINE_PROP_BOOL ("x-allow-ext-buffer" , SpaprTpmState, + allow_ext_buffer, true), };static void tpm_spapr_realizefn (SpaprVioDevice *dev,Error **errp)
Signature · 1 line
2.53.0