qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset
@ 2018-03-19 16:21 Stefan Berger
  2018-03-19 16:21 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in initialization Stefan Berger
  2018-03-20 14:52 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Marc-André Lureau
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Berger @ 2018-03-19 16:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, Stefan Berger

Fix the initialization of the tpmRegValidSts flag and set it to '1'
during device reset without expecting a write to another register.
This seems to also be the default behavior of real hardware.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_crb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index d8917cb..114b66e 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -145,8 +145,6 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
                              beenSeized, 0);
             ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
                              locAssigned, 1);
-            ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
-                             tpmRegValidSts, 1);
             break;
         }
         break;
@@ -210,6 +208,8 @@ static void tpm_crb_reset(void *dev)
 
     tpm_backend_reset(s->tpmbe);
 
+    ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
+                     tpmRegValidSts, 1);
     ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
                      InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
     ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in initialization
  2018-03-19 16:21 [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Stefan Berger
@ 2018-03-19 16:21 ` Stefan Berger
  2018-03-20 14:52 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Marc-André Lureau
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Berger @ 2018-03-19 16:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, Stefan Berger

Fix the initialization of the tpmRegValidSts flag and set it to '1'
during device reset without expecting a write to another register.
This seems to also be the default behavior of real hardware.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
---
 hw/tpm/tpm_crb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
index d8917cb..114b66e 100644
--- a/hw/tpm/tpm_crb.c
+++ b/hw/tpm/tpm_crb.c
@@ -145,8 +145,6 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
                              beenSeized, 0);
             ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
                              locAssigned, 1);
-            ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
-                             tpmRegValidSts, 1);
             break;
         }
         break;
@@ -210,6 +208,8 @@ static void tpm_crb_reset(void *dev)
 
     tpm_backend_reset(s->tpmbe);
 
+    ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
+                     tpmRegValidSts, 1);
     ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
                      InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
     ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
-- 
2.5.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset
  2018-03-19 16:21 [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Stefan Berger
  2018-03-19 16:21 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in initialization Stefan Berger
@ 2018-03-20 14:52 ` Marc-André Lureau
  2018-03-20 16:20   ` Stefan Berger
  1 sibling, 1 reply; 4+ messages in thread
From: Marc-André Lureau @ 2018-03-20 14:52 UTC (permalink / raw)
  To: Stefan Berger; +Cc: QEMU

Hi

On Mon, Mar 19, 2018 at 5:21 PM, Stefan Berger
<stefanb@linux.vnet.ibm.com> wrote:
> Fix the initialization of the tpmRegValidSts flag and set it to '1'
> during device reset without expecting a write to another register.
> This seems to also be the default behavior of real hardware.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  hw/tpm/tpm_crb.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
> index d8917cb..114b66e 100644
> --- a/hw/tpm/tpm_crb.c
> +++ b/hw/tpm/tpm_crb.c
> @@ -145,8 +145,6 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
>                               beenSeized, 0);
>              ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
>                               locAssigned, 1);
> -            ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
> -                             tpmRegValidSts, 1);
>              break;
>          }
>          break;
> @@ -210,6 +208,8 @@ static void tpm_crb_reset(void *dev)
>
>      tpm_backend_reset(s->tpmbe);
>
> +    ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
> +                     tpmRegValidSts, 1);
>      ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
>                       InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
>      ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,

Hmm, the specification says they default to 0. Except tpmEstablished
to 1, which we should probably manipulate somehow ("The TPM clears
this bit to 0 upon receipt of _TPM_Hash_End The TPM sets this bit to a
1 when the TPM_LOC_CTRL_x.resetEstablishment field is set to 1.").
Help welcome!

Shouldn't it also set locAssigned to 1 in this case ?

I am not very familiar with the locality support, since I didn't
implement it for CRB. You may have more clues what is expected here.

-- 
Marc-André Lureau

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset
  2018-03-20 14:52 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Marc-André Lureau
@ 2018-03-20 16:20   ` Stefan Berger
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Berger @ 2018-03-20 16:20 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Stephen Douthit

On 03/20/2018 10:52 AM, Marc-André Lureau wrote:
> Hi
>
> On Mon, Mar 19, 2018 at 5:21 PM, Stefan Berger
> <stefanb@linux.vnet.ibm.com> wrote:
>> Fix the initialization of the tpmRegValidSts flag and set it to '1'
>> during device reset without expecting a write to another register.
>> This seems to also be the default behavior of real hardware.
>>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>> ---
>>   hw/tpm/tpm_crb.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/tpm/tpm_crb.c b/hw/tpm/tpm_crb.c
>> index d8917cb..114b66e 100644
>> --- a/hw/tpm/tpm_crb.c
>> +++ b/hw/tpm/tpm_crb.c
>> @@ -145,8 +145,6 @@ static void tpm_crb_mmio_write(void *opaque, hwaddr addr,
>>                                beenSeized, 0);
>>               ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
>>                                locAssigned, 1);
>> -            ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
>> -                             tpmRegValidSts, 1);
>>               break;
>>           }
>>           break;
>> @@ -210,6 +208,8 @@ static void tpm_crb_reset(void *dev)
>>
>>       tpm_backend_reset(s->tpmbe);
>>
>> +    ARRAY_FIELD_DP32(s->regs, CRB_LOC_STATE,
>> +                     tpmRegValidSts, 1);
>>       ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
>>                        InterfaceType, CRB_INTF_TYPE_CRB_ACTIVE);
>>       ARRAY_FIELD_DP32(s->regs, CRB_INTF_ID,
> Hmm, the specification says they default to 0. Except tpmEstablished
> to 1, which we should probably manipulate somehow ("The TPM clears
> this bit to 0 upon receipt of _TPM_Hash_End The TPM sets this bit to a
> 1 when the TPM_LOC_CTRL_x.resetEstablishment field is set to 1.").
> Help welcome!

Right. We would have to set this flag to '1' -- maybe in a separate 
patch. We don't support DRTM, which is initiated by CPU instructions, 
that would then cause the _TPM_Hash_End. So there's no need to 
manipulate it.
>
> Shouldn't it also set locAssigned to 1 in this case ?

Stephen Douthit did some experiments with a hardware TPM and posted a 
patch to SeaBIOS mailing list:

https://mail.coreboot.org/pipermail/seabios/2018-March/012221.html

A hardware TPM would see the tpmRegValidSts bit set but not the 
locAssigned bit. I think our method of setting the locAssigned bit 
following the requestAccess bit being set is correct.

Also, in the following spec on pdf page 67 it indicates that after 500 
usec the tpmRegValidSts bit is set to a valid value. This means that no 
other register needs to be written to so that this happens. The text 
later on near Table 24 is a little more vague about that I find.

https://trustedcomputinggroup.org/wp-content/uploads/TCG_PC_Client_Platform_TPM_Profile_PTP_Specification_Family_2.0_Revision_1.3v22.pdf




>
> I am not very familiar with the locality support, since I didn't
> implement it for CRB. You may have more clues what is expected here.
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-20 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-19 16:21 [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Stefan Berger
2018-03-19 16:21 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in initialization Stefan Berger
2018-03-20 14:52 ` [Qemu-devel] [PATCH] tpm: Set tpmRegValidSts flag to '1' in device reset Marc-André Lureau
2018-03-20 16:20   ` Stefan Berger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).