Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1641623 > unrolled thread

Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out tpm_transfer function

Started byJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
First post2017-05-15 14:50 +0200
Last post2017-05-15 18:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out  tpm_transfer function Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-05-15 14:50 +0200
    Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out  tpm_transfer function Stefan Berger <stefanb@linux.vnet.ibm.com> - 2017-05-15 18:10 +0200
    Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out  tpm_transfer function Stefan Berger <stefanb@linux.vnet.ibm.com> - 2017-05-15 18:10 +0200

#1641623 — Re: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out tpm_transfer function

FromJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Date2017-05-15 14:50 +0200
SubjectRe: [PATCH v4 1/2] tpm: Refactor tpm_transmit pulling out tpm_transfer function
Message-ID<tHnBL-8iJ-1@gated-at.bofh.it>
On Wed, May 10, 2017 at 07:54:21PM -0400, Stefan Berger wrote:
> Refactor tpm_transmit and pull out code sending the command
> and receiving the response and put this into tpm_transfer.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> ---
>  drivers/char/tpm/tpm-interface.c | 121 +++++++++++++++++++++++----------------
>  1 file changed, 73 insertions(+), 48 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
> index 158c1db..263b6d1 100644
> --- a/drivers/char/tpm/tpm-interface.c
> +++ b/drivers/char/tpm/tpm-interface.c
> @@ -370,67 +370,29 @@ static bool tpm_validate_command(struct tpm_chip *chip,
>  }
>  
>  /**
> - * tmp_transmit - Internal kernel interface to transmit TPM commands.
> + * tmp_transfer - Send a TPM command to the TPM and receive response
>   *
>   * @chip: TPM chip to use
>   * @buf: TPM command buffer
> + * @count: size of the TPM command
>   * @bufsiz: length of the TPM command buffer
> - * @flags: tpm transmit flags - bitmap
>   *
>   * Return:
> - *     0 when the operation is successful.
> + *     >0 when the operation is successful; returns response length
>   *     A negative number for system errors (errno).
>   */
> -ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
> -		     u8 *buf, size_t bufsiz, unsigned int flags)
> +ssize_t tpm_transfer(struct tpm_chip *chip, u8 *buf, u32 count, size_t bufsiz)

Add instead a flag TPM_TRANSMIT_RAW (this name is just a suggestion)
that skips "prepare" and "commit" parts. That would save us from a
new export.

Better way to make it less messy would be to add static functions
tpm_prepare_command and tpm_commit_command that would be always
called and would return immediately if flags contain TPM_TRANSMIT_RAW.

/Jarkko

[toc] | [next] | [standalone]


#1641859

FromStefan Berger <stefanb@linux.vnet.ibm.com>
Date2017-05-15 18:10 +0200
Message-ID<tHqJj-1Wb-3@gated-at.bofh.it>
In reply to#1641623
On 05/15/2017 12:04 PM, Stefan Berger wrote:
> On 05/15/2017 08:40 AM, Jarkko Sakkinen wrote:
>> On Wed, May 10, 2017 at 07:54:21PM -0400, Stefan Berger wrote:
>>> Refactor tpm_transmit and pull out code sending the command
>>> and receiving the response and put this into tpm_transfer.
>>>
>>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>>> ---
>>>   drivers/char/tpm/tpm-interface.c | 121 
>>> +++++++++++++++++++++++----------------
>>>   1 file changed, 73 insertions(+), 48 deletions(-)
>>>
>>> diff --git a/drivers/char/tpm/tpm-interface.c 
>>> b/drivers/char/tpm/tpm-interface.c
>>> index 158c1db..263b6d1 100644
>>> --- a/drivers/char/tpm/tpm-interface.c
>>> +++ b/drivers/char/tpm/tpm-interface.c
>>> @@ -370,67 +370,29 @@ static bool tpm_validate_command(struct 
>>> tpm_chip *chip,
>>>   }
>>>     /**
>>> - * tmp_transmit - Internal kernel interface to transmit TPM commands.
>>> + * tmp_transfer - Send a TPM command to the TPM and receive response
>>>    *
>>>    * @chip: TPM chip to use
>>>    * @buf: TPM command buffer
>>> + * @count: size of the TPM command
>>>    * @bufsiz: length of the TPM command buffer
>>> - * @flags: tpm transmit flags - bitmap
>>>    *
>>>    * Return:
>>> - *     0 when the operation is successful.
>>> + *     >0 when the operation is successful; returns response length
>>>    *     A negative number for system errors (errno).
>>>    */
>>> -ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>>> -             u8 *buf, size_t bufsiz, unsigned int flags)
>>> +ssize_t tpm_transfer(struct tpm_chip *chip, u8 *buf, u32 count, 
>>> size_t bufsiz)
>> Add instead a flag TPM_TRANSMIT_RAW (this name is just a suggestion)
>> that skips "prepare" and "commit" parts. That would save us from a
>> new export.
>>
>> Better way to make it less messy would be to add static functions
>> tpm_prepare_command and tpm_commit_command that would be always
>> called and would return immediately if flags contain TPM_TRANSMIT_RAW.
>
> I'll do that then, modifying the code to skip tpm_validate_command as 
> well.
>

But we don't want to recurse (in the 2nd patch) into 
chip->ops->request_locality(). Any suggestions ?

    Stefan

[toc] | [prev] | [next] | [standalone]


#1641861

FromStefan Berger <stefanb@linux.vnet.ibm.com>
Date2017-05-15 18:10 +0200
Message-ID<tHqJj-1Wb-5@gated-at.bofh.it>
In reply to#1641623
On 05/15/2017 08:40 AM, Jarkko Sakkinen wrote:
> On Wed, May 10, 2017 at 07:54:21PM -0400, Stefan Berger wrote:
>> Refactor tpm_transmit and pull out code sending the command
>> and receiving the response and put this into tpm_transfer.
>>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>> ---
>>   drivers/char/tpm/tpm-interface.c | 121 +++++++++++++++++++++++----------------
>>   1 file changed, 73 insertions(+), 48 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c
>> index 158c1db..263b6d1 100644
>> --- a/drivers/char/tpm/tpm-interface.c
>> +++ b/drivers/char/tpm/tpm-interface.c
>> @@ -370,67 +370,29 @@ static bool tpm_validate_command(struct tpm_chip *chip,
>>   }
>>   
>>   /**
>> - * tmp_transmit - Internal kernel interface to transmit TPM commands.
>> + * tmp_transfer - Send a TPM command to the TPM and receive response
>>    *
>>    * @chip: TPM chip to use
>>    * @buf: TPM command buffer
>> + * @count: size of the TPM command
>>    * @bufsiz: length of the TPM command buffer
>> - * @flags: tpm transmit flags - bitmap
>>    *
>>    * Return:
>> - *     0 when the operation is successful.
>> + *     >0 when the operation is successful; returns response length
>>    *     A negative number for system errors (errno).
>>    */
>> -ssize_t tpm_transmit(struct tpm_chip *chip, struct tpm_space *space,
>> -		     u8 *buf, size_t bufsiz, unsigned int flags)
>> +ssize_t tpm_transfer(struct tpm_chip *chip, u8 *buf, u32 count, size_t bufsiz)
> Add instead a flag TPM_TRANSMIT_RAW (this name is just a suggestion)
> that skips "prepare" and "commit" parts. That would save us from a
> new export.
>
> Better way to make it less messy would be to add static functions
> tpm_prepare_command and tpm_commit_command that would be always
> called and would return immediately if flags contain TPM_TRANSMIT_RAW.

I'll do that then, modifying the code to skip tpm_validate_command as well.

    Stefan

>
> /Jarkko
> --
> To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web