|
From: | Stefan Berger |
Subject: | Re: [PATCH 3/3] qtest: Add a test case for TPM TIS I2C connected to Aspeed I2C controller |
Date: | Tue, 28 Mar 2023 07:31:35 -0400 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 |
On 3/28/23 05:17, Cédric Le Goater wrote:
+static void tpm_tis_i2c_test_basic(const void *data) +{ + uint8_t access; + uint32_t v; + + /* + * All register accesses below must work without locality 0 being the + * active locality. Therefore, ensure access is released. + */ + tpm_tis_i2c_writeb(0, TPM_I2C_REG_ACCESS, + TPM_TIS_ACCESS_ACTIVE_LOCALITY); + access = tpm_tis_i2c_readb(0, TPM_I2C_REG_ACCESS); + g_assert_cmpint(access, ==, TPM_TIS_ACCESS_TPM_REG_VALID_STS | + TPM_TIS_ACCESS_TPM_ESTABLISHMENT); + + /* read interrupt capability -- none are supported */ + v = tpm_tis_i2c_readl(0, TPM_I2C_REG_INT_CAPABILITY); + g_assert_cmpint(v, ==, 0); + + /* try to enable all interrupts */ + tpm_tis_i2c_writel(0, TPM_I2C_REG_INT_ENABLE, 0xffffffff); + v = tpm_tis_i2c_readl(0, TPM_I2C_REG_INT_ENABLE); + /* none could be enabled */ + g_assert_cmpint(v, ==, 0); + + /* enable csum */ + tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_CSUM_ENABLE, TPM_DATA_CSUM_ENABLED); + /* check csum enable register has bit 0 set */ + v = tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + g_assert_cmpint(v, ==, TPM_DATA_CSUM_ENABLED); + /* reading it as 32bit register returns same result */ + v = tpm_tis_i2c_readl(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + g_assert_cmpint(v, ==, TPM_DATA_CSUM_ENABLED); + + /* disable csum */ + tpm_tis_i2c_writeb(0, TPM_I2C_REG_DATA_CSUM_ENABLE, 0); + /* check csum enable register has bit 0 clear */ + v = tpm_tis_i2c_readb(0, TPM_I2C_REG_DATA_CSUM_ENABLE); + g_assert_cmpint(v, ==, 0); + + /* write to unsupported register '1' */ + tpm_tis_i2c_writel(0, 1, 0x12345678); + v = tpm_tis_i2c_readl(0, 1); + g_assert_cmpint(v, ==, 0xffffffff); +}I am seeing some errors :
There's a small fix to apply to 3/3 of Ninad's patches. See my comment here: https://lists.nongnu.org/archive/html/qemu-devel/2023-03/msg06464.html Stefan
$ QTEST_QEMU_BINARY=arm-softmmu/qemu-system-arm tests/qtest/tpm-tis-i2c-test # random seed: R02S68cdeb5a9a7b97eed594a7792b6aa7ff # starting QEMU: exec arm-softmmu/qemu-system-arm -qtest unix:/tmp/qtest-1981218.sock -qtest-log /dev/null -chardev socket,path=/tmp/qtest-1981218.qmp,id=char0 -mon chardev=char0,mode=control -display none -machine rainier-bmc -accel tcg -chardev socket,id=chr,path=/tmp/qemu-tpm-tis-i2c-test.DFGN21/sock -tpmdev emulator,id=tpm0,chardev=chr -device tpm-tis-i2c,tpmdev=tpm0,bus=aspeed.i2c.bus.10,address=0x2e -accel qtest # GLib-DEBUG: setenv()/putenv() are not thread-safe and should not be used after threads are created qemu-system-arm: warning: Aspeed iBT has no chardev backend 1..6 # Start of arm tests # Start of tpm-tis-i2c tests ** ERROR:../tests/qtest/tpm-tis-i2c-test.c:130:tpm_tis_i2c_test_basic: assertion failed (v == 0): (1 == 0) Bail out! ERROR:../tests/qtest/tpm-tis-i2c-test.c:130:tpm_tis_i2c_test_basic: assertion failed (v == 0): (1 == 0) Unexpected error in qio_channel_socket_writev() at ../io/channel-socket.c:621: qemu-system-arm: tests/qtest/tpm-tis-i2c-test:tpm-emulator: Could not cleanly shutdown the TPM: Interrupted system call Unable to write to socket: Bad file descriptor Aborted (core dumped)
[Prev in Thread] | Current Thread | [Next in Thread] |