TPM-TIS bios-tables-test
cover TPM-TIS bios-tables-test
This series adds the test of the TPM2 and DSDT tables when the TPM-TIS device gets instantiated.
The series also allows to validate changes in the TPM2 table generation done in "[PATCH v3 0/4] vTPM/aarch64 ACPI support", sent separately.
This depends on Stefan's "acpi: tpm: Do not build TCPA table for TPM 2".
This is in RFC state because I am not very familiar with the table generation process docommented in bios-tables-test.c.
I don't know how to get rid of the checkpatch errors:
"ERROR: Does not appear to be a unified-diff format patch"
Surprisingly, checkpatch argues when void tables are added in the same time as bios-tables-test-allowed-diff.h changes.
Most importantly, to be able to reuse tpm-emu code, I was forced to remove the TPM2_ST_NO_SESSIONS assert. I would be grateful if I could get some advises on the best way to address the issue.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/v5.0-tpm-acpi-tests-v1
Eric Auger (6):
test/tpm-emu: include sockets and channel headers in tpm-emu header tests/acpi: Add void tables for Q35/TPM-TIS bios-tables-test tests/acpi: Ignore TPM2.tis and DSDT.tis
tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
bios-tables-test: Add Q35/TPM-TIS test
bios-tables-test: Generate reference tables for Q35/TPM-TIS
tests/qtest/tpm-emu.h | 3 ++ tests/qtest/bios-tables-test.c | 60 +++++++++++++++++++++++++++++++++ tests/qtest/tpm-emu.c | 1 - tests/data/acpi/q35/DSDT.tis | Bin 0 -> 8468 bytes tests/data/acpi/q35/TPM2.tis | Bin 0 -> 76 bytes tests/qtest/Makefile.include | 1 + 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/q35/DSDT.tis create mode 100644 tests/data/acpi/q35/TPM2.tis
Signature · 1 line
2.20.1
RFC 1/6 test/tpm-emu: include sockets and channel headers in tpm-emu header
Include sockets and channel headers to that the header is self-contained.
--- tests/qtest/tpm-emu.h | 3 +++ 1 file changed, 3 insertions(+)
tests/qtest/tpm-emu.h +3 -0
@@ -16,6 +16,9 @@#define TPM_RC_FAILURE 0x101#define TPM2_ST_NO_SESSIONS 0x8001 +#include "qemu/sockets.h" +#include "io/channel.h" +struct tpm_hdr {uint16_t tag;uint32_t len;
Signature · 1 line
2.20.1
Re: [RFC 1/6] test/tpm-emu: include sockets and channel headers in tpm-emu header
Quoted 4 lines · Eric Auger
Include sockets and channel headers to that the header is self-contained.
Signed-off-by Eric Auger <[email protected]>
Quoted 18 lines
--- tests/qtest/tpm-emu.h | 3 +++ 1 file changed, 3 insertions(+)tests/qtest/tpm-emu.h +3
-0@@ -16,6 +16,9 @@#define TPM_RC_FAILURE 0x101#define TPM2_ST_NO_SESSIONS 0x8001 +#include "qemu/sockets.h" +#include "io/channel.h" +struct tpm_hdr {uint16_t tag;uint32_t len;
RFC 2/6 tests/acpi: Add void tables for Q35/TPM-TIS bios-tables-test
In reply to Eric AugerAdd placeholders for TPM and DSDT reference tables for Q35 TPM-TIS tests.
--- tests/data/acpi/q35/DSDT.tis | Bin tests/data/acpi/q35/TPM2.tis | Bin 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/data/acpi/q35/DSDT.tis create mode 100644 tests/data/acpi/q35/TPM2.tis
tests/data/acpi/q35/DSDT.tis new file +0 -0
tests/data/acpi/q35/TPM2.tis new file +0 -0
Signature · 1 line
2.20.1
Re: [RFC 2/6] tests/acpi: Add void tables for Q35/TPM-TIS bios-tables-test
Quoted 4 lines · Eric Auger
Add placeholders for TPM and DSDT reference tables for Q35 TPM-TIS tests.
Signed-off-by Eric Auger <[email protected]>
Quoted 13 lines
--- tests/data/acpi/q35/DSDT.tis | Bin tests/data/acpi/q35/TPM2.tis | Bin 2 files changed, 0 insertions(+), 0 deletions(-)create mode 100644 tests/data/acpi/q35/DSDT.tis
create mode 100644 tests/data/acpi/q35/TPM2.tistests/data/acpi/q35/DSDT.tis new file +0
-0tests/data/acpi/q35/TPM2.tis new file +0
-0
Re: [RFC 2/6] tests/acpi: Add void tables for Q35/TPM-TIS bios-tables-test
In reply to Eric AugerQuoted 4 lines · On Mon, 1 Jun 2020 12:21:09 +0200 Eric Auger <[email protected]> wrote:
Add placeholders for TPM and DSDT reference tables for Q35 TPM-TIS tests.
Signed-off-by Eric Auger <[email protected]>
Quoted 13 lines
--- tests/data/acpi/q35/DSDT.tis | Bin tests/data/acpi/q35/TPM2.tis | Bin 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/data/acpi/q35/DSDT.tis create mode 100644 tests/data/acpi/q35/TPM2.tistests/data/acpi/q35/DSDT.tis new file +0
-0tests/data/acpi/q35/TPM2.tis new file +0
-0
RFC 3/6 tests/acpi: Ignore TPM2.tis and DSDT.tis
In reply to Eric AugerSubsequent patches will alter the content of TPM2.tis and DSDT.tis so let's ignore them until the references are generated.
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 1 file changed, 2 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +2 -0
@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/TPM2.tis",
Signature · 1 line
2.20.1
Re: [RFC 3/6] tests/acpi: Ignore TPM2.tis and DSDT.tis
Quoted 5 lines · Eric Auger
Subsequent patches will alter the content of TPM2.tis and DSDT.tis so let's ignore them until the references are generated.
Signed-off-by Eric Auger <[email protected]>
Quoted 12 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 1 file changed, 2 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +2
-0@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/TPM2.tis",
Re: [RFC 3/6] tests/acpi: Ignore TPM2.tis and DSDT.tis
In reply to Eric AugerQuoted 5 lines · On Mon, 1 Jun 2020 12:21:10 +0200 Eric Auger <[email protected]> wrote:
Subsequent patches will alter the content of TPM2.tis and DSDT.tis so let's ignore them until the references are generated.
Signed-off-by Eric Auger <[email protected]>
Quoted 12 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 ++ 1 file changed, 2 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +2
-0@@ -1 +1,3 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/q35/DSDT.tis" , +"tests/data/acpi/q35/TPM2.tis",
RFC 4/6 tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
In reply to Eric AugerWhile writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.
--- tests/qtest/tpm-emu.c | 1 - 1 file changed, 1 deletion(-)
tests/qtest/tpm-emu.c +0 -1
@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag =be16_to_cpu (s->tpm_msg->tag); s->tpm_msg->len =be32_to_cpu (s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS); s->tpm_msg =g_realloc (s->tpm_msg, s->tpm_msg->len); qio_channel_read(ioc, (char *)&s->tpm_msg->code,
Signature · 1 line
2.20.1
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>--- tests/qtest/tpm-emu.c | 1 - 1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0
tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag =be16_to_cpu (s->tpm_msg->tag); s->tpm_msg->len =be32_to_cpu (s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);
You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have TPM2_ST_NO_SESSIONS as the tag. I'd be curious what other value you are seeing there.
Quoted 3 lines
tests/qtest/tpm-emu.c +0
-0s->tpm_msg =g_realloc (s->tpm_msg, s->tpm_msg->len); qio_channel_read(ioc, (char *)&s->tpm_msg->code,
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Quoted 14 lines · Stefan Berger
Quoted 13 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)
Quoted 10 lines
tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 9 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.
In hw/tpm/tpm_util.c tpm_util_test_tpmdev() we have a probing function that tries to determine whether the attached TPM is a TPM 1.2 or TPM 2. It sends a TPM 2 command first and I would say this is the only command we should see in this (fake) TPM emulation here. We respond with a TPM 2 command header [indicating failure], but the probing function should then not proceed to probe with the TPM 1.2 command.
Quoted 4 lines
Quoted 2 lines
tests/qtest/tpm-emu.c +0
-0s->tpm_msg = g_realloc(s->tpm_msg, s->tpm_msg->len); qio_channel_read(ioc, (char *)&s->tpm_msg->code,
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
In reply to Stefan BergerHi Stefan,
Quoted 14 lines · Stefan Berger
Quoted 13 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)
Quoted 15 lines
tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 9 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.
If I revert this patch I am getting TPM2_ST_SESSIONS on my end.
Thanks
Eric
Quoted 5 lines
Quoted 2 lines
tests/qtest/tpm-emu.c +0
-0s->tpm_msg = g_realloc(s->tpm_msg, s->tpm_msg->len); qio_channel_read(ioc, (char *)&s->tpm_msg->code,
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Quoted 32 lines · Auger Eric
Hi Stefan,
Quoted 14 lines · Stefan Berger
Quoted 13 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>--- tests/qtest/tpm-emu.c | 1 - 1 file changed, 1 deletion(-)Quoted 15 lines
tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 9 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.
Is firmware/BIOS active? There's no TPM2_ST_SESSIONS coming out of QEMU.
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Stefan,
Quoted 33 lines · Stefan Berger
Quoted 32 lines · Auger Eric
Hi Stefan,
Quoted 29 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.
Quoted 3 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.
From what I understand
QTEST_QEMU_BINARY=x86_64-softmmu/qemu-system-x86_64 tests/qtest/bios-tables-test
launches
x86_64-softmmu/qemu-system-x86_64 \
-qtest unix:/tmp/qtest-20181.sock \
-qtest-log /dev/null -chardev socket,path=/tmp/qtest-20181.qmp,id=char0 -mon chardev=char0,mode=control \
-display none -machine q35,kernel-irqchip=off \
-accel kvm -accel tcg \
-net none -display none \
-chardev socket,id=chr,path=/tmp/qemu-test_acpi_q35_tcg_tpm2.RJJCL0/sock -tpmdev emulator,id=dev,chardev=chr \
-device tpm-tis,tpmdev=dev \
-drive id=hd0,if=none,file=tests/acpi-test-disk-RAnagW,format=raw -device ide-hd,drive=hd0 -accel qtest
acpi-test-disk-RAnagW consists in an x86 boot sector code, created by boot_sector_init (x86_boot_sector)
Thanks
Eric
Quoted 5 lines
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
In reply to Stefan BergerHi Stefan,
Quoted 33 lines · Stefan Berger
Quoted 32 lines · Auger Eric
Hi Stefan,
Quoted 29 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.
Quoted 3 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.
So it looks SeaBIOS is in use (bios-256k.bin loaded).
I can see MMIO accesses to the TPM and the following commands are observable:tpm_emu_tpm_thread code=0x181 tag=0x8001 len=0xa tpm_emu_tpm_thread code=0x144 tag=0x8001 len=0xc tpm_emu_tpm_thread code=0x121 tag=0x8002 len=0x20
This last one causes the assert (TPM2_CC_HierarchyControl)
I checked in Seabios and effectively tpm20_hierarchycontrol() tags the TPM2_CC_HierarchyControl command with TPM2_ST_SESSIONS
Due to our emulation, maybe tpm_set_failure() gets called, inducing tpm20_hierarchycontrol() call.
That being said, what do you recommend? Remove the assert, improve the emulation, other?
Thank you in advance
Best Regards
Eric
Quoted 5 lines
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Quoted 47 lines · Auger Eric
Hi Stefan,
Quoted 33 lines · Stefan Berger
Quoted 32 lines · Auger Eric
Hi Stefan,
Quoted 29 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>--- tests/qtest/tpm-emu.c | 1 - 1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should have
TPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you are seeing there.Quoted 2 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.So it looks SeaBIOS is in use (bios-256k.bin loaded).
I can see MMIO accesses to the TPM and the following commands are observable:
tpm_emu_tpm_threadcode=0x181 tag=0x8001 len=0xatpm_emu_tpm_threadcode=0x144 tag=0x8001 len=0xctpm_emu_tpm_threadcode=0x121 tag=0x8002 len=0x20
This last one causes the assert (TPM2_CC_HierarchyControl)
Quoted 8 lines
I checked in Seabios and effectively
tpm20_hierarchycontrol()tags theTPM2_CC_HierarchyControlcommand withTPM2_ST_SESSIONSDue to our emulation, maybe
tpm_set_failure()gets called, inducingtpm20_hierarchycontrol()call.That being said, what do you recommend? Remove the assert, improve the emulation, other?
So this is an ACPI test. What role does the firmware play for success of the test? If the test relies on the firmware showing some sort of expected result, then I would recommend only running this test with an attached swtpm, like we run some other tests. If we don't need the firmware to succeed then I would just get rid of the assert. Probably no other test we have implemented so far was running the firmware...
Stefan
Quoted 11 lines
Thank you in advance
Best Regards
Eric
Quoted 4 lines
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Hi Stefan,
Quoted 59 lines · Stefan Berger
Quoted 49 lines · Auger Eric
Hi Stefan,
Quoted 35 lines · Stefan Berger
Quoted 34 lines · Auger Eric
Hi Stefan,
Quoted 31 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does
not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should haveTPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you
are seeing there.Quoted 2 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.So it looks SeaBIOS is in use (bios-256k.bin loaded).
I can see MMIO accesses to the TPM and the following commands are observable:
tpm_emu_tpm_threadcode=0x181 tag=0x8001 len=0xatpm_emu_tpm_threadcode=0x144 tag=0x8001 len=0xctpm_emu_tpm_threadcode=0x121 tag=0x8002 len=0x20
This last one causes the assert (TPM2_CC_HierarchyControl)Quoted 8 lines
I checked in Seabios and effectively
tpm20_hierarchycontrol()tags theTPM2_CC_HierarchyControlcommand withTPM2_ST_SESSIONSDue to our emulation, maybe
tpm_set_failure()gets called, inducingtpm20_hierarchycontrol()call.That being said, what do you recommend? Remove the assert, improve the emulation, other?
Quoted 6 lines
So this is an ACPI test. What role does the firmware play for success of the test? If the test relies on the firmware showing some sort of expected result, then I would recommend only running this test with an attached swtpm, like we run some other tests. If we don't need the firmware to succeed then I would just get rid of the assert. Probably no other test we have implemented so far was running the firmware...
FWIU The goal of this test is to compare the acpi tables generated by qemu against reference ones. I dont think we expect from the FW any specific result but I would prefer Igor or Michael to confirm.
In that case, removing the assert() allows to compare the specific DSDT and TPM2 tables and that's our expectation here I think.
Thanks
Eric
Quoted 18 lines
Stefan
Quoted 11 lines
Thank you in advance
Best Regards
Eric
Quoted 4 lines
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Quoted 68 lines · On Fri, 5 Jun 2020 17:47:08 +0200 Auger Eric <[email protected]> wrote:
Hi Stefan,
Quoted 59 lines · Stefan Berger
Quoted 49 lines · Auger Eric
Hi Stefan,
Quoted 35 lines · Stefan Berger
Quoted 34 lines · Auger Eric
Hi Stefan,
Quoted 31 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does
not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should haveTPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you
are seeing there.Quoted 2 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.So it looks SeaBIOS is in use (bios-256k.bin loaded).
I can see MMIO accesses to the TPM and the following commands are observable:
tpm_emu_tpm_threadcode=0x181 tag=0x8001 len=0xatpm_emu_tpm_threadcode=0x144 tag=0x8001 len=0xctpm_emu_tpm_threadcode=0x121 tag=0x8002 len=0x20
This last one causes the assert (TPM2_CC_HierarchyControl)Quoted 8 lines
I checked in Seabios and effectively
tpm20_hierarchycontrol()tags theTPM2_CC_HierarchyControlcommand withTPM2_ST_SESSIONSDue to our emulation, maybe
tpm_set_failure()gets called, inducingtpm20_hierarchycontrol()call.That being said, what do you recommend? Remove the assert, improve the emulation, other?
Quoted 6 lines
So this is an ACPI test. What role does the firmware play for success of the test? If the test relies on the firmware showing some sort of expected result, then I would recommend only running this test with an attached swtpm, like we run some other tests. If we don't need the firmware to succeed then I would just get rid of the assert. Probably no other test we have implemented so far was running the firmware...
Quoted 3 lines
FWIU The goal of this test is to compare the acpi tables generated by qemu against reference ones. I dont think we expect from the FW any specific result but I would prefer Igor or Michael to confirm.
Firmware is needed to fetch tables from QEMU and place them in guest RAM, it will also patch cross table pointers accordingly.
So bios-tables-test checks both QEMU and firmware at the same time, and reference tables are in form guest OS will see them.
Quoted 25 lines
In that case, removing the
assert()allows to compare the specific DSDT and TPM2 tables and that's our expectation here I think.Thanks
Eric
Quoted 18 lines
Stefan
Quoted 11 lines
Thank you in advance
Best Regards
Eric
Quoted 4 lines
Stefan
Re: [RFC 4/6] tests: tpm-emu: Remove assert on TPM2_ST_NO_SESSIONS
Hi Igor,
Quoted 75 lines · Igor Mammedov
Quoted 68 lines · On Fri, 5 Jun 2020 17:47:08 +0200 Auger Eric <[email protected]> wrote:
Hi Stefan,
Quoted 59 lines · Stefan Berger
Quoted 49 lines · Auger Eric
Hi Stefan,
Quoted 35 lines · Stefan Berger
Quoted 34 lines · Auger Eric
Hi Stefan,
Quoted 31 lines · Stefan Berger
Quoted 18 lines · Eric Auger
While writing tests for checking the content of TPM2 and DSDT along with TPM-TIS instantiation I attempted to reuse the framework used for TPM-TIS tests. However While dumping the ACPI tables I get an assert on
TPM2_ST_NO_SESSIONS. My assumption is maybe the other tests did not execute long enough to encounter this. So I tentatively propose to remove the assert as it does not seem to break other tests and enable the new ones.Signed-off-by Eric Auger <[email protected]>---
tests/qtest/tpm-emu.c| 1 -1 file changed, 1 deletion(-)tests/qtest/tpm-emu.c +0
-0tests/qtest/tpm-emu.c static void *tpm_emu_tpm_thread(void *data) · line 52
Quoted 4 lines
tests/qtest/tpm-emu.c +0
-1@@ -49,7 +49,6 @@ static void *tpm_emu_tpm_thread(void *data) s->tpm_msg->tag = be16_to_cpu(s->tpm_msg->tag); s->tpm_msg->len = be32_to_cpu(s->tpm_msg->len); g_assert_cmpint(s->tpm_msg->len, >=, minhlen); - g_assert_cmpint(s->tpm_msg->tag, ==, TPM2_ST_NO_SESSIONS);You should not have to remove this. The tests are skipped if swtpm does
not support TPM 2 via --tpm2 option. This would be a very old swtpm version, though. So, all tests are run with --tpm2 option and any response received from the TPM would be a TPM 2 response that should haveTPM2_ST_NO_SESSIONSas the tag. I'd be curious what other value you
are seeing there.Quoted 2 lines
Quoted 1 line
If I revert this patch I am getting
TPM2_ST_SESSIONSon my end.Is
firmware/BIOSactive? There's noTPM2_ST_SESSIONScoming out of QEMU.So it looks SeaBIOS is in use (bios-256k.bin loaded).
I can see MMIO accesses to the TPM and the following commands are observable:
tpm_emu_tpm_threadcode=0x181 tag=0x8001 len=0xatpm_emu_tpm_threadcode=0x144 tag=0x8001 len=0xctpm_emu_tpm_threadcode=0x121 tag=0x8002 len=0x20
This last one causes the assert (TPM2_CC_HierarchyControl)Quoted 8 lines
I checked in Seabios and effectively
tpm20_hierarchycontrol()tags theTPM2_CC_HierarchyControlcommand withTPM2_ST_SESSIONSDue to our emulation, maybe
tpm_set_failure()gets called, inducingtpm20_hierarchycontrol()call.That being said, what do you recommend? Remove the assert, improve the emulation, other?
Quoted 6 lines
So this is an ACPI test. What role does the firmware play for success of the test? If the test relies on the firmware showing some sort of expected result, then I would recommend only running this test with an attached swtpm, like we run some other tests. If we don't need the firmware to succeed then I would just get rid of the assert. Probably no other test we have implemented so far was running the firmware...
Quoted 3 lines
FWIU The goal of this test is to compare the acpi tables generated by qemu against reference ones. I dont think we expect from the FW any specific result but I would prefer Igor or Michael to confirm.
Quoted 5 lines
Firmware is needed to fetch tables from QEMU and place them in guest RAM, it will also patch cross table pointers accordingly.
So bios-tables-test checks both QEMU and firmware at the same time, and reference tables are in form guest OS will see them.
Thank you for your input. I guess Stefan's concern was: is that an issue if the FW accesses to the TPM silently fail at some (assumed late) point. I guess the job we expect from the FW, ie. copy the ACPI tables and patch tables, is done prior to that failure, hence the test success. So this functional failure should not be an issue for bios-table-test, right?
Thanks
Eric
Quoted 28 lines
Quoted 26 lines
In that case, removing the
assert()allows to compare the specific DSDT and TPM2 tables and that's our expectation here I think.Thanks
Eric
Quoted 18 lines
Stefan
Quoted 11 lines
Thank you in advance
Best Regards
Eric
Quoted 4 lines
Stefan
RFC 5/6 bios-tables-test: Add Q35/TPM-TIS test
In reply to Eric AugerTest tables specific to the TPM-TIS instantiation. The TPM2 is added in the framework. Also the DSDT is updated with the TPM. The new function should be be usable for CRB as well, later one.
--- tests/qtest/bios-tables-test.c | 60 ++++++++++++++++++++++++++++++++++ tests/qtest/Makefile.include | 1 + 2 files changed, 61 insertions(+)
tests/qtest/bios-tables-test.c +60 -0
@@ -57,6 +57,9 @@#include "qemu/bitmap.h" #include "acpi-utils.h" #include "boot-sector.h" +#include "tpm-emu.h" +#include "hw/acpi/tpm.h" +#define MACHINE_PC "pc"#define MACHINE_Q35 "q35"
@@ -874,6 +877,60 @@ static void test_acpi_piix4_tcg_numamem(void)free_test_data (&data); } +uint64_t tpm_tis_base_addr; + +struct tpm_test_data { +const char *machine; +const char *tpm_if; +}; + +static void test_acpi_tcg_tpm (const void *context) +{ +struct tpm_test_data *c = (struct tpm_test_data *)context; +gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , + c->machine, c->tpm_if); +char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL ); +TestState test; +test_data data; +GThread *thread; +char *args, *variant =g_strdup_printf (".%s" , c->tpm_if); + + tpm_tis_base_addr =TPM_TIS_ADDR_BASE ; + +module_call_init (MODULE_INIT_QOM ); + + test.addr =g_new0 (SocketAddress,1 ); + test.addr->type =SOCKET_ADDRESS_TYPE_UNIX ; + test.addr->u.q_unix.path =g_build_filename (tmp_path,"sock" ,NULL ); +g_mutex_init (&test.data_mutex); +g_cond_init (&test.data_cond); + test.data_cond_signal = false; + + thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test); +tpm_emu_test_wait_cond (&test); + +memset (&data,0 ,sizeof (data)); + data.machine = c->machine; + data.variant = variant; + + args =g_strdup_printf ( +" -chardev socket,id=chr,path=%s" +" -tpmdev emulator,id=dev,chardev=chr" +" -device tpm-%s,tpmdev=dev" , + test.addr->u.q_unix.path, c->tpm_if); + +test_acpi_one (args, &data); + +g_thread_join (thread); +g_unlink (test.addr->u.q_unix.path); +qapi_free_SocketAddress (test.addr); +g_rmdir (tmp_path); +g_free (variant); +g_free (tmp_path); +g_free (tmp_dir_name); +free_test_data (&data); +} +static void test_acpi_tcg_dimm_pxm (const char *machine) {test_data data;
@@ -1028,6 +1085,7 @@ int main(int argc, char *argv[]) {const char *arch =qtest_get_arch ();int ret; +struct tpm_test_data tpm_q35_tis = {MACHINE_Q35 ,"tis" };g_test_init (&argc, &argv,NULL );
@@ -1037,6 +1095,8 @@ int main(int argc, char *argv[])return ret; } +qtest_add_data_func ("acpi/q35/tpm-tis" , + &tpm_q35_tis, test_acpi_tcg_tpm);qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg);qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35" , test_acpi_q35_tcg);
tests/qtest/Makefile.include +1 -0
@@ -262,6 +262,7 @@ tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y) tests/qtest/boot-order-test$(EXESUF): tests/qtest/boot-order-test.o $(libqos-obj-y) tests/qtest/boot-serial-test$(EXESUF): tests/qtest/boot-serial-test.o $(libqos-obj-y) tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \ + tests/qtest/tpm-emu.o $(test-io-obj-y) \ tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y) tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y) tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o
Signature · 1 line
2.20.1
Re: [RFC 5/6] bios-tables-test: Add Q35/TPM-TIS test
Quoted 108 lines · Eric Auger
Test tables specific to the TPM-TIS instantiation. The TPM2 is added in the framework. Also the DSDT is updated with the TPM. The new function should be be usable for CRB as well, later one.
Signed-off-by Eric Auger <[email protected]>--- tests/qtest/bios-tables-test.c | 60 ++++++++++++++++++++++++++++++++++ tests/qtest/Makefile.include | 1 + 2 files changed, 61 insertions(+)tests/qtest/bios-tables-test.c +60
-0@@ -57,6 +57,9 @@#include "qemu/bitmap.h" #include "acpi-utils.h" #include "boot-sector.h" +#include "tpm-emu.h" +#include "hw/acpi/tpm.h" +#define MACHINE_PC "pc"#define MACHINE_Q35 "q35"@@ -874,6 +877,60 @@ static void test_acpi_piix4_tcg_numamem(void)free_test_data (&data); } +uint64_t tpm_tis_base_addr; + +struct tpm_test_data { +const char *machine; +const char *tpm_if; +}; + +static void test_acpi_tcg_tpm (const void *context) +{ +struct tpm_test_data *c = (struct tpm_test_data *)context; +gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , + c->machine, c->tpm_if); +char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL ); +TestState test; +test_data data; +GThread *thread; +char *args, *variant =g_strdup_printf (".%s" , c->tpm_if); + + tpm_tis_base_addr =TPM_TIS_ADDR_BASE ; + +module_call_init (MODULE_INIT_QOM ); + + test.addr =g_new0 (SocketAddress,1 ); + test.addr->type =SOCKET_ADDRESS_TYPE_UNIX ; + test.addr->u.q_unix.path =g_build_filename (tmp_path,"sock" ,NULL ); +g_mutex_init (&test.data_mutex); +g_cond_init (&test.data_cond); + test.data_cond_signal = false; + + thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test); +tpm_emu_test_wait_cond (&test); + +memset (&data,0 ,sizeof (data)); + data.machine = c->machine; + data.variant = variant; + + args =g_strdup_printf ( +" -chardev socket,id=chr,path=%s" +" -tpmdev emulator,id=dev,chardev=chr" +" -device tpm-%s,tpmdev=dev" , + test.addr->u.q_unix.path, c->tpm_if); + +test_acpi_one (args, &data); + +g_thread_join (thread); +g_unlink (test.addr->u.q_unix.path); +qapi_free_SocketAddress (test.addr); +g_rmdir (tmp_path); +g_free (variant); +g_free (tmp_path); +g_free (tmp_dir_name); +free_test_data (&data); +} +static void test_acpi_tcg_dimm_pxm (const char *machine) {test_data data;@@ -1028,6 +1085,7 @@ int main(int argc, char *argv[]) {const char *arch =qtest_get_arch ();int ret; +struct tpm_test_data tpm_q35_tis = {MACHINE_Q35 ,"tis" };g_test_init (&argc, &argv,NULL );@@ -1037,6 +1095,8 @@ int main(int argc, char *argv[])return ret; } +qtest_add_data_func ("acpi/q35/tpm-tis" , + &tpm_q35_tis, test_acpi_tcg_tpm);qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg);qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35" , test_acpi_q35_tcg);tests/qtest/Makefile.include +0
-0
tests/qtest/Makefile.include tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y) · line 268
Quoted 7 lines
tests/qtest/Makefile.include +1
-0@@ -262,6 +262,7 @@ tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y) tests/qtest/boot-order-test$(EXESUF): tests/qtest/boot-order-test.o $(libqos-obj-y) tests/qtest/boot-serial-test$(EXESUF): tests/qtest/boot-serial-test.o $(libqos-obj-y) tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \ + tests/qtest/tpm-emu.o $(test-io-obj-y) \ tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y) tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y) tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o
Re: [RFC 5/6] bios-tables-test: Add Q35/TPM-TIS test
In reply to Eric AugerQuoted 28 lines · On Mon, 1 Jun 2020 12:21:12 +0200 Eric Auger <[email protected]> wrote:
Test tables specific to the TPM-TIS instantiation. The TPM2 is added in the framework. Also the DSDT is updated with the TPM. The new function should be be usable for CRB as well, later one.
Signed-off-by Eric Auger <[email protected]>--- tests/qtest/bios-tables-test.c | 60 ++++++++++++++++++++++++++++++++++ tests/qtest/Makefile.include | 1 + 2 files changed, 61 insertions(+)tests/qtest/bios-tables-test.c +3
-0@@ -57,6 +57,9 @@#include "qemu/bitmap.h" #include "acpi-utils.h" #include "boot-sector.h" +#include "tpm-emu.h" +#include "hw/acpi/tpm.h" +#define MACHINE_PC "pc"#define MACHINE_Q35 "q35"@@ -874,6 +877,60 @@ static void test_acpi_piix4_tcg_numamem(void)free_test_data (&data); }
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 888
Quoted 10 lines
tests/qtest/bios-tables-test.c +9
-0+uint64_t tpm_tis_base_addr; + +struct tpm_test_data { +const char *machine; +const char *tpm_if; +}; + +static void test_acpi_tcg_tpm (const void *context) +{
s/test_acpi_tcg_tpm/test_acpi_q35_tcg_tpm/
I'd try to keep test specific parameter within test function isnstead of pushing it up to main(),
drawback would be some code duplication for intializing test data and calling runner
but it's trivial and worked well so far. See for example test_acpi_piix4_tcg_bridge/test_acpi_q35_tcg_bridge. I might seem a waste but it's consictent with what we were doing with bios tests.
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 896
Quoted 8 lines
tests/qtest/bios-tables-test.c +8
-0+struct tpm_test_data *c = (struct tpm_test_data *)context; +gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , + c->machine, c->tpm_if); +char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL ); +TestState test; +test_data data; +GThread *thread; +char *args, *variant =g_strdup_printf (".%s" , c->tpm_if);
maybe derive tpm_if from '.variant' if it's necessary at all?
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 898
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ + tpm_tis_base_addr =TPM_TIS_ADDR_BASE ;
hardcode it here, so in case QEMU regresses, test could notice?
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 900
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ +module_call_init (MODULE_INIT_QOM );
why it's here?
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 910
Quoted 10 lines
tests/qtest/bios-tables-test.c +10
-0+ + test.addr =g_new0 (SocketAddress,1 ); + test.addr->type =SOCKET_ADDRESS_TYPE_UNIX ; + test.addr->u.q_unix.path =g_build_filename (tmp_path,"sock" ,NULL ); +g_mutex_init (&test.data_mutex); +g_cond_init (&test.data_cond); + test.data_cond_signal = false; + + thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test); +tpm_emu_test_wait_cond (&test);
perhaps make a separate helper function from this chunk so it could be reused from other TMP test functions.
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 912
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ +memset (&data,0 ,sizeof (data));
I'd init fields with initializer, see test_acpi_virt_tcg_numamem()
Quoted 25 lines
tests/qtest/bios-tables-test.c +21
-0+ data.machine = c->machine; + data.variant = variant; + + args =g_strdup_printf ( +" -chardev socket,id=chr,path=%s" +" -tpmdev emulator,id=dev,chardev=chr" +" -device tpm-%s,tpmdev=dev" , + test.addr->u.q_unix.path, c->tpm_if); + +test_acpi_one (args, &data); + +g_thread_join (thread); +g_unlink (test.addr->u.q_unix.path); +qapi_free_SocketAddress (test.addr); +g_rmdir (tmp_path); +g_free (variant); +g_free (tmp_path); +g_free (tmp_dir_name); +free_test_data (&data); +} +static void test_acpi_tcg_dimm_pxm (const char *machine) {test_data data;
tests/qtest/bios-tables-test.c int main(int argc, char *argv[]) · line 1088
Quoted 4 lines
tests/qtest/bios-tables-test.c +1
-0@@ -1028,6 +1085,7 @@ int main(int argc, char *argv[]) {const char *arch =qtest_get_arch ();int ret; +struct tpm_test_data tpm_q35_tis = {MACHINE_Q35 ,"tis" };
I'd hide this within test_acpi_tcg_tpm() as it's done in other test functions
Quoted 24 lines
tests/qtest/bios-tables-test.c +2
-0g_test_init (&argc, &argv,NULL );@@ -1037,6 +1095,8 @@ int main(int argc, char *argv[])return ret; } +qtest_add_data_func ("acpi/q35/tpm-tis" , + &tpm_q35_tis, test_acpi_tcg_tpm);qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg);qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35" , test_acpi_q35_tcg);tests/qtest/Makefile.include +1
-0@@ -262,6 +262,7 @@ tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y) tests/qtest/boot-order-test$(EXESUF): tests/qtest/boot-order-test.o $(libqos-obj-y) tests/qtest/boot-serial-test$(EXESUF): tests/qtest/boot-serial-test.o $(libqos-obj-y) tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \ + tests/qtest/tpm-emu.o $(test-io-obj-y) \ tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y) tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y) tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o
Re: [RFC 5/6] bios-tables-test: Add Q35/TPM-TIS test
Hi Igor,
Quoted 44 lines · Igor Mammedov
Quoted 28 lines · On Mon, 1 Jun 2020 12:21:12 +0200 Eric Auger <[email protected]> wrote:
Test tables specific to the TPM-TIS instantiation. The TPM2 is added in the framework. Also the DSDT is updated with the TPM. The new function should be be usable for CRB as well, later one.
Signed-off-by Eric Auger <[email protected]>--- tests/qtest/bios-tables-test.c | 60 ++++++++++++++++++++++++++++++++++ tests/qtest/Makefile.include | 1 + 2 files changed, 61 insertions(+)tests/qtest/bios-tables-test.c +3
-0@@ -57,6 +57,9 @@#include "qemu/bitmap.h" #include "acpi-utils.h" #include "boot-sector.h" +#include "tpm-emu.h" +#include "hw/acpi/tpm.h" +#define MACHINE_PC "pc"#define MACHINE_Q35 "q35"@@ -874,6 +877,60 @@ static void test_acpi_piix4_tcg_numamem(void)free_test_data (&data); }tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 888
Quoted 10 lines
tests/qtest/bios-tables-test.c +9
-0+uint64_t tpm_tis_base_addr; + +struct tpm_test_data { +const char *machine; +const char *tpm_if; +}; + +static void test_acpi_tcg_tpm (const void *context) +{s/test_acpi_tcg_tpm/test_acpi_q35_tcg_tpm/
Quoted 4 lines
I'd try to keep test specific parameter within test function isnstead of pushing it up to
main(),
drawback would be some code duplication for intializing test data and calling runner
but it's trivial and worked well so far. See for example test_acpi_piix4_tcg_bridge/test_acpi_q35_tcg_bridge. I might seem a waste but it's consictent with what we were doing with bios tests.
OK
Quoted 12 lines
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 896
Quoted 10 lines
tests/qtest/bios-tables-test.c +8
-0+struct tpm_test_data *c = (struct tpm_test_data *)context; +gchar *tmp_dir_name =g_strdup_printf ("qemu-test_acpi_%s_tcg_%s.XXXXXX" , + c->machine, c->tpm_if); +char *tmp_path =g_dir_make_tmp (tmp_dir_name,NULL ); +TestState test; +test_data data; +GThread *thread; +char *args, *variant =g_strdup_printf (".%s" , c->tpm_if);maybe derive
tpm_iffrom '.variant' if it's necessary at all?
Quoted 7 lines
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 898
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ + tpm_tis_base_addr =TPM_TIS_ADDR_BASE ;hardcode it here, so in case QEMU regresses, test could notice?
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 900
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ +module_call_init (MODULE_INIT_QOM );why it's here
Without it, I get
/x86_64/acpi/q35/tpm-tis: ** ERROR:qom/object.c:677:object_new_with_type: assertion failed: (type != NULL)
Thanks
Eric
Quoted 75 lines
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 910
Quoted 11 lines
tests/qtest/bios-tables-test.c +10
-0+ + test.addr =g_new0 (SocketAddress,1 ); + test.addr->type =SOCKET_ADDRESS_TYPE_UNIX ; + test.addr->u.q_unix.path =g_build_filename (tmp_path,"sock" ,NULL ); +g_mutex_init (&test.data_mutex); +g_cond_init (&test.data_cond); + test.data_cond_signal = false; + + thread =g_thread_new (NULL , tpm_emu_ctrl_thread, &test); +tpm_emu_test_wait_cond (&test);perhaps make a separate helper function from this chunk so it could be reused from other TMP test functions.
tests/qtest/bios-tables-test.c static void test_acpi_piix4_tcg_numamem(void) · line 912
Quoted 2 lines
tests/qtest/bios-tables-test.c +2
-0+ +memset (&data,0 ,sizeof (data));I'd init fields with initializer, see
test_acpi_virt_tcg_numamem()Quoted 25 lines
tests/qtest/bios-tables-test.c +21
-0+ data.machine = c->machine; + data.variant = variant; + + args =g_strdup_printf ( +" -chardev socket,id=chr,path=%s" +" -tpmdev emulator,id=dev,chardev=chr" +" -device tpm-%s,tpmdev=dev" , + test.addr->u.q_unix.path, c->tpm_if); + +test_acpi_one (args, &data); + +g_thread_join (thread); +g_unlink (test.addr->u.q_unix.path); +qapi_free_SocketAddress (test.addr); +g_rmdir (tmp_path); +g_free (variant); +g_free (tmp_path); +g_free (tmp_dir_name); +free_test_data (&data); +} +static void test_acpi_tcg_dimm_pxm (const char *machine) {test_data data;tests/qtest/bios-tables-test.c int main(int argc, char *argv[]) · line 1088
Quoted 4 lines
tests/qtest/bios-tables-test.c +1
-0@@ -1028,6 +1085,7 @@ int main(int argc, char *argv[]) {const char *arch =qtest_get_arch ();int ret; +struct tpm_test_data tpm_q35_tis = {MACHINE_Q35 ,"tis" };I'd hide this within
test_acpi_tcg_tpm()as it's done in other test functionsQuoted 24 lines
tests/qtest/bios-tables-test.c +2
-0g_test_init (&argc, &argv,NULL );@@ -1037,6 +1095,8 @@ int main(int argc, char *argv[])return ret; } +qtest_add_data_func ("acpi/q35/tpm-tis" , + &tpm_q35_tis, test_acpi_tcg_tpm);qtest_add_func ("acpi/piix4" , test_acpi_piix4_tcg);qtest_add_func ("acpi/piix4/bridge" , test_acpi_piix4_tcg_bridge);qtest_add_func ("acpi/q35" , test_acpi_q35_tcg);tests/qtest/Makefile.include +1
-0@@ -262,6 +262,7 @@ tests/qtest/hd-geo-test$(EXESUF): tests/qtest/hd-geo-test.o $(libqos-obj-y) tests/qtest/boot-order-test$(EXESUF): tests/qtest/boot-order-test.o $(libqos-obj-y) tests/qtest/boot-serial-test$(EXESUF): tests/qtest/boot-serial-test.o $(libqos-obj-y) tests/qtest/bios-tables-test$(EXESUF): tests/qtest/bios-tables-test.o \ + tests/qtest/tpm-emu.o $(test-io-obj-y) \ tests/qtest/boot-sector.o tests/qtest/acpi-utils.o $(libqos-obj-y) tests/qtest/pxe-test$(EXESUF): tests/qtest/pxe-test.o tests/qtest/boot-sector.o $(libqos-obj-y) tests/qtest/microbit-test$(EXESUF): tests/qtest/microbit-test.o
RFC 6/6 bios-tables-test: Generate reference tables for Q35/TPM-TIS
In reply to Eric AugerTPM2, DSDT tables were generated usingtests/data/acpi/rebuild-expected-aml.sh
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/DSDT.tis | Bin 0 -> 8468 bytes tests/data/acpi/q35/TPM2.tis | Bin 0 -> 76 bytes 3 files changed, 2 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -2
@@ -1,3 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.tis" , -"tests/data/acpi/q35/TPM2.tis",
tests/data/acpi/q35/DSDT.tis binary +0 -0
tests/data/acpi/q35/TPM2.tis binary +0 -0
Signature · 1 line
2.20.1
Re: [RFC 6/6] bios-tables-test: Generate reference tables for Q35/TPM-TIS
Quoted 4 lines · Eric Auger
TPM2, DSDT tables were generated using
tests/data/acpi/rebuild-expected-aml.shSigned-off-by Eric Auger <[email protected]>
Quoted 93 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 2 -- tests/data/acpi/q35/DSDT.tis | Bin 0 -> 8468 bytes tests/data/acpi/q35/TPM2.tis | Bin 0 -> 76 bytes 3 files changed, 2 deletions(-)tests/qtest/bios-tables-test-allowed-diff.h +0
-2@@ -1,3 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/q35/DSDT.tis" , -"tests/data/acpi/q35/TPM2.tis",tests/data/acpi/q35/DSDT.tis binary +0
-0tests/data/acpi/q35/TPM2.tis binary +0
-0
Hi,
Quoted 10 lines · Eric Auger
This series adds the test of the TPM2 and DSDT tables when the TPM-TIS device gets instantiated.
The series also allows to validate changes in the TPM2 table generation done in "[PATCH v3 0/4] vTPM/aarch64 ACPI support", sent separately.
This depends on Stefan's "acpi: tpm: Do not build TCPA table for TPM 2".
Quoted 8 lines
This is in RFC state because I am not very familiar with the table generation process docommented in
bios-tables-test.c.I don't know how to get rid of the checkpatch errors:
"ERROR: Does not appear to be a unified-diff format patch"Surprisingly, checkpatch argues when void tables are added in the same time as
bios-tables-test-allowed-diff.hchanges.
Both issues reported above were resolved by Michael's [PATCH] checkpatch: reversed logic with acpi test checks
Thank you for fixing that
Eric
Quoted 31 lines
Most importantly, to be able to reuse tpm-emu code, I was forced to remove the
TPM2_ST_NO_SESSIONSassert. I would be grateful if I could get some advises on the best way to address the issue.Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/v5.0-tpm-acpi-tests-v1Eric Auger (6):
test/tpm-emu: include sockets and channel headers in tpm-emu header tests/acpi: Add void tables for Q35/TPM-TIS bios-tables-test tests/acpi: Ignore TPM2.tis and DSDT.tis
tests: tpm-emu: Remove assert onTPM2_ST_NO_SESSIONS
bios-tables-test: Add Q35/TPM-TIS test
bios-tables-test: Generate reference tables for Q35/TPM-TIStests/qtest/tpm-emu.h | 3 ++ tests/qtest/bios-tables-test.c | 60 +++++++++++++++++++++++++++++++++ tests/qtest/tpm-emu.c | 1 - tests/data/acpi/q35/DSDT.tis | Bin 0 -> 8468 bytes tests/data/acpi/q35/TPM2.tis | Bin 0 -> 76 bytes tests/qtest/Makefile.include | 1 + 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/q35/DSDT.tis create mode 100644 tests/data/acpi/q35/TPM2.tis