[SeaBIOS] [PATCH 4/4] WIP: add TPM CRB device support

Stefan Berger stefanb at linux.vnet.ibm.com
Mon Oct 23 23:36:00 CEST 2017


On 10/06/2017 10:50 AM, Stefan Berger wrote:
> On 10/06/2017 10:33 AM, marcandre.lureau at redhat.com wrote:
>> From: Marc-André Lureau <marcandre.lureau at redhat.com>
>>
>> The CRB device was introduced with TPM 2.0 to be physical-bus agnostic
>> and defined in TCG PC Client Platform TPM Profile (PTP) Specification
>> Family “2.0” Level 00 Revision 01.03 v22
>>
>> It seems to be required with Windows 10. It is also a simpler device
>> than FIFO/TIS.
>>
>> This WIP patch doesn't support locality other than 0. The BIOS doesn't
>> seem to require other localities, so that code seems a bit pointless.
>>
>> In theory, the cmd/resp buffers could be located above 4G, but I
>> don't know how seabios could reach it in 32bit mode (my qemu WIP
>> allocates next to 0xfed40000).
>

The following fixes a bug:

diff --git a/src/hw/tpm_drivers.c b/src/hw/tpm_drivers.c
index 3b8f6e1..2551b11 100644
--- a/src/hw/tpm_drivers.c
+++ b/src/hw/tpm_drivers.c
@@ -491,10 +491,13 @@ static u32 crb_readresp(u8 *buffer, u32 *len)

      memcpy(buffer, crb_resp, 6);
      u32 expected = be32_to_cpu(*(u32 *) &buffer[2]);
-    if (expected > *len || expected < 6)
+    if (expected < 6)
          return 1;

-    memcpy(buffer + 6, crb_resp + 6, expected - 6);
+#define MIN(x,y) ((x) < (y) ? (x) : (y))
+    *len = MIN(expected, *len);
+
+    memcpy(buffer + 6, crb_resp + 6, *len - 6);

      return 0;
  }





More information about the SeaBIOS mailing list