lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yr4vcYpAonXzD2Qu@kernel.org>
Date:   Fri, 1 Jul 2022 02:19:13 +0300
From:   Jarkko Sakkinen <jarkko@...nel.org>
To:     Lino Sanfilippo <LinoSanfilippo@....de>
Cc:     peterhuewe@....de, jgg@...pe.ca, stefanb@...ux.vnet.ibm.com,
        linux@...ewoehner.de, linux-integrity@...r.kernel.org,
        linux-kernel@...r.kernel.org, l.sanfilippo@...bus.com,
        lukas@...ner.de, p.rosenberger@...bus.com
Subject: Re: [PATCH v7 06/10] tpm, tpm_tis: Move interrupt mask checks into
 own function

On Thu, Jun 30, 2022 at 01:26:49AM +0200, Lino Sanfilippo wrote:
> From: Lino Sanfilippo <l.sanfilippo@...bus.com>
> 
> Clean up wait_for_tpm_stat() by moving multiple similar interrupt mask
> checks into an own function.
> 
> Signed-off-by: Lino Sanfilippo <l.sanfilippo@...bus.com>
> Suggested-by: Jarkko Sakkinen <jarkko@...nel.org>
> ---
>  drivers/char/tpm/tpm_tis_core.c | 29 ++++++++++++++++++-----------
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c
> index c13599e94ab6..bd4eeb0b2192 100644
> --- a/drivers/char/tpm/tpm_tis_core.c
> +++ b/drivers/char/tpm/tpm_tis_core.c
> @@ -44,6 +44,20 @@ static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
>  	return false;
>  }
>  
> +static u8 tpm_tis_filter_sts_mask(u8 int_mask, u8 sts_mask)
> +{
> +	if (!(int_mask & TPM_INTF_STS_VALID_INT))
> +		sts_mask &= ~TPM_STS_VALID;
> +
> +	if (!(int_mask & TPM_INTF_DATA_AVAIL_INT))
> +		sts_mask &= ~TPM_STS_DATA_AVAIL;
> +
> +	if (!(int_mask & TPM_INTF_CMD_READY_INT))
> +		sts_mask &= ~TPM_STS_COMMAND_READY;
> +
> +	return sts_mask;
> +}
> +
>  static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
>  		unsigned long timeout, wait_queue_head_t *queue,
>  		bool check_cancel)
> @@ -53,7 +67,7 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
>  	long rc;
>  	u8 status;
>  	bool canceled = false;
> -	u8 sts_mask = 0;
> +	u8 sts_mask;
>  	int ret = 0;
>  
>  	/* check current status */
> @@ -61,17 +75,10 @@ static int wait_for_tpm_stat(struct tpm_chip *chip, u8 mask,
>  	if ((status & mask) == mask)
>  		return 0;
>  
> +	sts_mask = mask & (TPM_STS_VALID | TPM_STS_DATA_AVAIL |
> +			   TPM_STS_COMMAND_READY);
>  	/* check which status changes can be handled by irqs */
> -	if (priv->int_mask & TPM_INTF_STS_VALID_INT)
> -		sts_mask |= TPM_STS_VALID;
> -
> -	if (priv->int_mask & TPM_INTF_DATA_AVAIL_INT)
> -		sts_mask |= TPM_STS_DATA_AVAIL;
> -
> -	if (priv->int_mask & TPM_INTF_CMD_READY_INT)
> -		sts_mask |= TPM_STS_COMMAND_READY;
> -
> -	sts_mask &= mask;
> +	sts_mask = tpm_tis_filter_sts_mask(priv->int_mask, sts_mask);
>  
>  	stop = jiffies + timeout;
>  	/* process status changes with irq support */
> -- 
> 2.25.1
> 

Reviewed-by: Jarkko Sakkinen <jarkko@...nel.org>

BR, Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ