[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKf6xpvY1peO-mWM+bjaHnXhrqpOrGbyrOOaT18-myWYSJ88Sw@mail.gmail.com>
Date: Mon, 11 Jul 2022 15:39:15 -0400
From: Jason Andryuk <jandryuk@...il.com>
To: Lino Sanfilippo <LinoSanfilippo@....de>
Cc: Peter Huewe <peterhuewe@....de>,
Jarkko Sakkinen <jarkko@...nel.org>,
Jason Gunthorpe <jgg@...pe.ca>,
Stefan Berger <stefanb@...ux.vnet.ibm.com>,
linux@...ewoehner.de, linux-integrity@...r.kernel.org,
open list <linux-kernel@...r.kernel.org>,
l.sanfilippo@...bus.com, lukas@...ner.de, p.rosenberger@...bus.com
Subject: Re: [PATCH v7 07/10] tmp, tmp_tis: Implement usage counter for locality
Hi,
This patch subject has a typo "tmp, tmp_tis" -> "tpm, tpm_tis"
On Wed, Jun 29, 2022 at 7:28 PM Lino Sanfilippo <LinoSanfilippo@....de> wrote:
>
> From: Lino Sanfilippo <l.sanfilippo@...bus.com>
>
> Implement a usage counter for the (default) locality used by the TPM TIS
> driver:
> Request the locality from the TPM if it has not been claimed yet, otherwise
> only increment the counter. Also release the locality if the counter is 0
> otherwise only decrement the counter. Ensure thread-safety by protecting
> the counter with a mutex.
>
> This allows to request and release the locality from a thread and the
> interrupt handler at the same time without the danger to interfere with
> each other.
>
> By doing this refactor the names of the amended functions to use the proper
> prefix.
>
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
> Tested-by: Michael Niewöhner <linux@...ewoehner.de>
> ---
> drivers/char/tpm/tpm_tis_core.c | 75 ++++++++++++++++++++++-----------
> drivers/char/tpm/tpm_tis_core.h | 2 +
> 2 files changed, 53 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index bd4eeb0b2192..e50a2c78de9f 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -215,6 +226,20 @@ static int request_locality(struct tpm_chip *chip, int l)
> return -1;
> }
>
> +static int tpm_tis_request_locality(struct tpm_chip *chip, int l)
> +{
> + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev);
> + int ret = 0;
> +
> + mutex_lock(&priv->locality_count_mutex);
> + if (priv->locality_count == 0)
> + ret = tpm_tis_request_locality_locked(chip, l);
> + if (!ret)
> + priv->locality_count++;
> + mutex_unlock(&priv->locality_count_mutex);
> + return ret;
> +}
> +
This function should check that the requested locality matches the
current locality otherwise this sequence would seemingly succeed
though locality 0 is the one acquired.
tpm_tis_request_locality(chip, 0);
tpm_tis_request_locality(chip, 1);
Regards,
Jason
Powered by blists - more mailing lists