tpm: Handle failure mode of backend device better
cover tpm: Handle failure mode of backend device better
The following two patches fix the case that the backend device, e.g., tpm_emulator, could not be initialized and the TIS frontend needs to go into failure mode.
Stefan
Stefan Berger (2):
tpm_tis: Return TPM_VERSION_UNSPEC in case of BE failure
tpm_tis: Return 0 for every register in case of failure mode
hw/tpm/tpm_tis.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.5.5
PATCH 2/2 tpm_tis: Return 0 for every register in case of failure mode
Rather than returning ~0, return 0 for every register in case of failure mode. The '0' is better to indicate that there's no device there.
--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/tpm/tpm_tis.c +1 -1
@@ -519,7 +519,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,uint8_t v;if (tpm_backend_had_startup_error (s->be_driver)) { -return val; +return 0 ; }switch (offset) {
Signature · 1 line
2.5.5
PATCH 1/2 tpm_tis: Return TPM_VERSION_UNSPEC in case of BE failure
In reply to Stefan BergerIn case the backend has a failure, such as the tpm_emulator's CMD_INIT failing, the TIS goes into failure mode and does not respond to reads or writes to MMIO registers. In this case we need to prevent the ACPI table from being added and the straight-forward way is to indicate that there's no known TPM version being used.
--- hw/tpm/tpm_tis.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/tpm/tpm_tis.c +4 -0
@@ -970,6 +970,10 @@ static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti) {TPMState *s =TPM (ti); +if (tpm_backend_had_startup_error (s->be_driver)) { +return TPM_VERSION_UNSPEC ; + } +return tpm_backend_get_tpm_version (s->be_driver); }
Signature · 1 line
2.5.5
Re: [Qemu-devel] [PATCH 1/2] tpm_tis: Return TPM_VERSION_UNSPEC in case of BE failure
Quoted 7 lines · Stefan Berger
In case the backend has a failure, such as the tpm_emulator's
CMD_INITfailing, the TIS goes into failure mode and does not respond to reads or writes to MMIO registers. In this case we need to prevent the ACPI table from being added and the straight-forward way is to indicate that there's no known TPM version being used.Signed-off-by Stefan Berger <[email protected]>
Quoted 23 lines
--- hw/tpm/tpm_tis.c | 4 ++++ 1 file changed, 4 insertions(+)hw/tpm/tpm_tis.c +4
-1@@ -970,6 +970,10 @@ static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti) {TPMState *s =TPM (ti); +if (tpm_backend_had_startup_error (s->be_driver)) { +return TPM_VERSION_UNSPEC ; + } +return tpm_backend_get_tpm_version (s->be_driver); } --2.5.5
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH 2/2] tpm_tis: Return 0 for every register in case of failure mode
In reply to Stefan BergerHi Stefan
Quoted 14 lines · Stefan Berger
Rather than returning ~0, return 0 for every register in case of failure mode. The '0' is better to indicate that there's no device there.
Signed-off-by Stefan Berger <[email protected]>--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/tpm/tpm_tis.c +0
-0
hw/tpm/tpm_tis.c static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr, · line 523
Quoted 6 lines
hw/tpm/tpm_tis.c +1
-1@@ -519,7 +519,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,uint8_t v;if (tpm_backend_had_startup_error (s->be_driver)) { -return val; +return 0 ; }
it's not obvious to me why it's better. Could you detail a bit more the reason?
why not change the initialization of val instead?
Quoted 6 lines
hw/tpm/tpm_tis.c +0
-1switch (offset) { --2.5.5
Signature · 1 line
Marc-André Lureau
Re: [Qemu-devel] [PATCH 1/2] tpm_tis: Return TPM_VERSION_UNSPEC in case of BE failure
In reply to Marc-André LureauQuoted 10 lines · Marc-André Lureau
Quoted 7 lines · Stefan Berger
In case the backend has a failure, such as the tpm_emulator's
CMD_INITfailing, the TIS goes into failure mode and does not respond to reads or writes to MMIO registers. In this case we need to prevent the ACPI table from being added and the straight-forward way is to indicate that there's no known TPM version being used.Signed-off-by Stefan Berger <[email protected]>Reviewed-by Marc-André Lureau <[email protected]>
Resending an old response?
https://patchwork.kernel.org/patch/10058405/
Quoted 27 lines
Quoted 25 lines
--- hw/tpm/tpm_tis.c | 4 ++++ 1 file changed, 4 insertions(+)hw/tpm/tpm_tis.c +4
-1@@ -970,6 +970,10 @@ static enum TPMVersion tpm_tis_get_tpm_version(TPMIf *ti) {TPMState *s =TPM (ti); +if (tpm_backend_had_startup_error (s->be_driver)) { +return TPM_VERSION_UNSPEC ; + } +return tpm_backend_get_tpm_version (s->be_driver); } --2.5.5
Re: [Qemu-devel] [PATCH 2/2] tpm_tis: Return 0 for every register in case of failure mode
In reply to Marc-André LureauQuoted 20 lines · Marc-André Lureau
Hi Stefan
Quoted 16 lines · Stefan Berger
Rather than returning ~0, return 0 for every register in case of failure mode. The '0' is better to indicate that there's no device there.
Signed-off-by Stefan Berger <[email protected]>--- hw/tpm/tpm_tis.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/tpm/tpm_tis.c +0
-0@@ -519,7 +519,7 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,uint8_t v;
Quoted 7 lines
hw/tpm/tpm_tis.c static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr, · line 523
Quoted 4 lines
hw/tpm/tpm_tis.c +1
-1if (tpm_backend_had_startup_error (s->be_driver)) { -return val; +return 0 ; }it's not obvious to me why it's better. Could you detail a bit more the reason?
why not change the initialization of val instead?