Hi there,
I tried to use the TPM2 AES256 / AES256CTR to encrypt a file. When I ran the following command, I got an error message in an infinite loop and had to reboot my machine.

$ tpm2_encryptdecrypt -c 0x81010000 --iv=iv.input:iv.output -p ${pswd} -o enc_test.data test.data

The error message was
   tpm tpm0 invalid count value ffffffff 1000
   tpm tpm0 invalid count value ffffffff 1000 
   ...
   tpm tpm0 invalid count value ffffffff 1000

Digging the location where the error message comes from, I found it was in the tpm driver file: file tpm-interface.c

static ssize_t tpm_try_transmit(struct tpm_chip *chip, void *buf, size_t bufsiz)
{
struct tpm_header *header = buf;
...

count = be32_to_cpu(header->length); // ---> count = ffffffff  
...

if (count > bufsiz) {   // ---> bufsiz = 1000
    dev_err(&chip->dev,
                  "invalid count value %x %zx\n", count, bufsiz);
     
return -E2BIG;
 }
....
}

My question is did someone meet the same problem? And how can I debug this problem?
I double checked the tpm2-abrmd service. It was running okay.

The builds for my test are:
1. rpi-kernel: 5.4.y
2. tpm2-tss: 3.0.x
3. tpm2-abrmd: 2.3.2
4. tpm2-tools: 4.2.X
5. tpm2-tss-engine: v1.1.x

My test environments:
RPI 3B & 4B
AES in the TPM was enabled.

Attached is my test script.

Thanks a lot,
Ben