In case swtpm was to return a control channel message with an error code it would only return 4 bytes. However, some of the commands expect a response with more bytes and QEMU would get stuck in qemu_chr_fe_read_all() waiting for bytes following the error code. Therefore, read the response in 2 passes stopping if an error code is received in the first 4 bytes to avoid getting stuck. Implement an exception for CMD_GET_STATEBLOB that has always been sending the header in case of error.
Stefan v2: - Stefan Berger (2): tpm: Use new ptm_cap_n structure for PTM_GET_CAPABILITY tpm_emulator: Read control channel response in 2 passes backends/tpm/tpm_emulator.c | 45 ++++++++++++++++++++++++++++++------- backends/tpm/tpm_ioctl.h | 13 ++++++++++- backends/tpm/trace-events | 2 +- 3 files changed, 50 insertions(+), 10 deletions(-) -- 2.47.0