Cleanup and locality range check
v3 cover Cleanup and locality range check
This series of patches removes an unnecessary parameter from tpm_tis_abort() and adds a locality range check to tpm_tis_prep_abort() and tpm_tis_request_completed().
Stefan
Stefan Berger (3):
tpm: Remove unused locty parameter from tpm_tis_abort()
tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid
tpm: Make sure the locality received from backend is valid
hw/tpm/tpm_tis.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.17.1
PATCH v3 1/3 tpm: Remove unused locty parameter from tpm_tis_abort()
Remove the unused locty parameter from tpm_tis_abort() function.
--- hw/tpm/tpm_tis.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
hw/tpm/tpm_tis.c +3 -3
@@ -233,7 +233,7 @@ static void tpm_tis_new_active_locality(TPMState *s, uint8_t new_active_locty) }/* abort -- this function switches the locality */ -static void tpm_tis_abort (TPMState *s,uint8_t locty) +static void tpm_tis_abort (TPMState *s) { s->rw_offset =0 ;
@@ -281,7 +281,7 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty) } } -tpm_tis_abort (s, locty); +tpm_tis_abort (s); }/*
@@ -311,7 +311,7 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret) }if (TPM_TIS_IS_VALID_LOCTY (s->next_locty)) { -tpm_tis_abort (s, locty); +tpm_tis_abort (s); } tpm_tis_raise_irq(s, locty,
Signature · 1 line
2.17.1
PATCH v3 2/3 tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid
In reply to Stefan BergerMake sure that the new locality passed to tpm_tis_prep_abort() is valid.
Add a comment to aborting_locty that it may be any locality, including TPM_TIS_NO_LOCALITY.
--- hw/tpm/tpm_tis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/tpm/tpm_tis.c +3 -1
@@ -263,7 +263,9 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty) {uint8_t busy_locty; - s->aborting_locty = locty; +assert (TPM_TIS_IS_VALID_LOCTY (newlocty)); + + s->aborting_locty = locty;/* may also be TPM_TIS_NO_LOCALITY */ s->next_locty = newlocty;/* locality after successful abort */ /*
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 2/3] tpm: Make sure new locality passed to tpm_tis_prep_abort() is valid
Quoted 8 lines · Stefan Berger
Make sure that the new locality passed to
tpm_tis_prep_abort()is valid.Add a comment to
aborting_loctythat it may be any locality, includingTPM_TIS_NO_LOCALITY.Signed-off-by Stefan Berger <[email protected]>
Quoted 22 lines
--- hw/tpm/tpm_tis.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/tpm/tpm_tis.c +3
-2@@ -263,7 +263,9 @@ static void tpm_tis_prep_abort(TPMState *s, uint8_t locty, uint8_t newlocty) {uint8_t busy_locty; - s->aborting_locty = locty; +assert (TPM_TIS_IS_VALID_LOCTY (newlocty)); + + s->aborting_locty = locty;/* may also be TPM_TIS_NO_LOCALITY */ s->next_locty = newlocty;/* locality after successful abort */ /* -- 2.17.1
Signature · 1 line
Marc-André Lureau
PATCH v3 3/3 tpm: Make sure the locality received from backend is valid
In reply to Stefan BergerMake sure that the locality passed from the backend to tpm_tis_request_completed() is valid.
--- hw/tpm/tpm_tis.c | 2 ++ 1 file changed, 2 insertions(+)
hw/tpm/tpm_tis.c +2 -0
@@ -295,6 +295,8 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)uint8_t locty = s->cmd.locty;uint8_t l; +assert (TPM_TIS_IS_VALID_LOCTY (locty)); +if (s->cmd.selftest_done) {for (l =0 ; l <TPM_TIS_NUM_LOCALITIES ; l++) { s->loc[l].sts |=TPM_TIS_STS_SELFTEST_DONE ;
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH v3 3/3] tpm: Make sure the locality received from backend is valid
Quoted 5 lines · Stefan Berger
Make sure that the locality passed from the backend to
tpm_tis_request_completed()is valid.Signed-off-by Stefan Berger <[email protected]>
Quoted 20 lines
--- hw/tpm/tpm_tis.c | 2 ++ 1 file changed, 2 insertions(+)hw/tpm/tpm_tis.c +2
-1@@ -295,6 +295,8 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)uint8_t locty = s->cmd.locty;uint8_t l; +assert (TPM_TIS_IS_VALID_LOCTY (locty)); +if (s->cmd.selftest_done) {for (l =0 ; l <TPM_TIS_NUM_LOCALITIES ; l++) { s->loc[l].sts |=TPM_TIS_STS_SELFTEST_DONE ; --2.17.1
Signature · 1 line
Marc-André Lureau