Menu

#1 timeouts too long

open
None
6
2008-07-02
2008-02-26
debora
No

According to TCG TPM Specification Version 1.2 Revision 103
timeouts and durations are returned in microseconds (10 ^ -6 s)

mainP2Structrev103.pdf,
page 166 :
"
TPM_CAP_PROP_TIS_TIMEOUT
An 4 element array of UINT32 values each denoting the timeout value in
microseconds for the
following in the order:
TIMEOUT_A, TIMEOUT_B, TIMEOUT_C, TIMEOUT_D
[...]
"

page 167 :
"
TPM_CAP_PROP_DURATION
An 4 element array of UINT32 values each denoting the duration value
in microseconds [...]
"

tpm.c code converts above timeouts to jiffies using msecs_to_jiffies(),
but input value for msesc_to_jiffies() have to be defined in
miliseconds (10 ^ -3 s).
In result - timeouts are 1000 times longer!
To convert microseconds to jiffies - usecs_to_jiffies() should be used.

Am I wrong?

Regards
Marcin

Discussion

  • debora

    debora - 2008-06-11

    Logged In: YES
    user_id=1367797
    Originator: YES

    From: Marcin Obara <marcin_obara@users.sourceforge.net>
    To: tpmdd-devel@lists.sourceforge.net, Marcel Selhorst <tpm@selhorst.net>
    Cc: linux-kernel@vger.kernel.org
    Subject: [tpmdd-devel] [PATCH] tpm:correct tpm timeouts to jiffies conversion
    Date: Thu, 5 Jun 2008 22:19:53 +0200 (CEST) (13:19 PDT)

    This patch fixes timeouts conversion to jiffies,
    by replacing msecs_to_jiffies() calls with usecs_to_jiffies().
    According to TCG TPM Specification Version 1.2 Revision 103 (pages 166, 167)
    TPM timeouts and durations are returned in microseconds (usec)
    not in miliseconds (msec).

    Signed-off-by: Marcin Obara <marcin_obara@users.sourceforge.net>

    --- linux/drivers/char/tpm/tpm.c 2008-06-05 20:57:06.000000000 +0200
    +++ linux_tpm/drivers/char/tpm/tpm.c 2008-06-05 20:54:52.000000000 +0200
    @@ -524,19 +524,19 @@ void tpm_get_timeouts(struct tpm_chip *c
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)));
    if (timeout)
    - chip->vendor.timeout_a = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_a = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX)));
    if (timeout)
    - chip->vendor.timeout_b = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_b = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX)));
    if (timeout)
    - chip->vendor.timeout_c = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_c = usecs_to_jiffies(timeout);
    timeout =
    be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX)));
    if (timeout)
    - chip->vendor.timeout_d = msecs_to_jiffies(timeout);
    + chip->vendor.timeout_d = usecs_to_jiffies(timeout);

    duration:
    memcpy(data, tpm_cap, sizeof(tpm_cap));
    @@ -553,15 +553,15 @@ duration:
    return;

    chip->vendor.duration[TPM_SHORT] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_1_IDX))));
    chip->vendor.duration[TPM_MEDIUM] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_2_IDX))));
    chip->vendor.duration[TPM_LONG] =
    - msecs_to_jiffies(be32_to_cpu
    + usecs_to_jiffies(be32_to_cpu
    (*((__be32 *) (data +
    TPM_GET_CAP_RET_UINT32_3_IDX))));
    }

    -------------------------------------------------------------------------

     
  • debora

    debora - 2008-07-01
    • priority: 5 --> 6
     
  • debora

    debora - 2008-07-02
    • assigned_to: nobody --> phreakz
     
  • Rajiv Andrade

    Rajiv Andrade - 2008-07-25

    Logged In: YES
    user_id=2032327
    Originator: NO

    Patch already submitted to LKML