From patchwork Thu Nov 24 13:55:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13055005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0DC6C43217 for ; Thu, 24 Nov 2022 13:56:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230094AbiKXN4f (ORCPT ); Thu, 24 Nov 2022 08:56:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbiKXN4c (ORCPT ); Thu, 24 Nov 2022 08:56:32 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D2D4FCDE5; Thu, 24 Nov 2022 05:56:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1669298172; bh=KYgm8KRRqsXZGdn21yoPTnrJv96Ne6lqyUqKM2FAIYk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=l3aJvhaSv1q0D+rXI60cI/Ma/anYl/lkYrN80NC1/0UTnepJGz5pH5nnaoGzmzMsI kzDRZ9wfyYQ6g33KPjVvOj+sApYyCFRQxoJxcalz1yVrVoz1wS0cqMd1w4+vTp8vHJ 8t+g0DxSyqcgDd9YjNiHTTNTUKYne8cYShzHrZPo29G1FIZjWJpfmbgzFl8PpccO4k mFw9w7C1hmEHp0oVMCVz3c/E4bqeauKGwwAF2JuQTTb+Rwqm3fmieAVwauPC+VlawG oaJfVGS6Onu+ahQGtJwkIlgtxkyu3ac1N/HfMsDUSqWBjucrTN7eSa0RN4l/QeSXyR 2LWZtRLX9R9Dw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MybGh-1p7slF2snt-00z1Ur; Thu, 24 Nov 2022 14:56:12 +0100 From: Lino Sanfilippo To: peterhuewe@gmx.de, jarkko@kernel.org, jgg@ziepe.ca Cc: stefanb@linux.vnet.ibm.com, linux@mniewoehner.de, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, jandryuk@gmail.com, pmenzel@molgen.mpg.de, l.sanfilippo@kunbus.com, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com Subject: [PATCH v11 08/14] tpm, tpm_tis: do not check for the active locality in interrupt handler Date: Thu, 24 Nov 2022 14:55:32 +0100 Message-Id: <20221124135538.31020-9-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221124135538.31020-1-LinoSanfilippo@gmx.de> References: <20221124135538.31020-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:YZiUudcwOuChyLmzP4dwIkl3/awLNQ8KvBhXt/WodxMvdwl6lqo LlvMEiHfeu8ijXYdt5z3l1dJ8nClGm3ZE/fOr0XUIvycnjXXKIE/a9nSTHWz2Lx7j+PLOFz UoIsae9eEmaE265WB9dK/wPWCsVS9zLGWYpPzJeKKcPyOki2TCwCFwMxS9j9TLKqdr2dVZb 5S/AFQr/uIehx5tMNoMZg== UI-OutboundReport: notjunk:1;M01:P0:6fJmel/inqo=;Xf58vLAIKBd8FABsoQ2j5E1vpHB Pm6ssHhRUxLjlzXsLBNl2lVwOC0N/daWFx+PkqgPMJk5A1EQDCpiyPpEluUKiZEv1P5KXQrIM aceYNzDS2M2CAa5f88BD8MtIosfhLQUC5GGCvgUvKg66ch57MUHZqfORiRgdjhYjS1Zb/SDIo 2DjUWlkneDzOkdEHYrybkVSgDKLyCwWE99qx4LvL4yZSIYlLjj4MgJT7wJmbIZ3NMflV1zSqU lq1fxrkmQAxYQEzt2gVdQslzl7qMuCRjpT40xBA9qKXaLgEycj2CqviIWmTKoOx99Ajf5qqKZ yD9ZHYL3ab706mtUUesc2ZjVIw+MbwkbCRgxrirQd4Sa9QRiyOXGB55CxJr1AwrHA7xNnvxCR tIF74Ul9W/NoVCTtxPjLv3jTd6bK4lSeIXqCvUUR0q+FRSX6weFKB6i8gzqeUFJhvpszziTPc 7rS+nrqTMU3XdFkBnW20reV1f7bvtJf4tekEXyq1rHQATYKphAIzxe/OycuXWoYibJs2I+rWy ZaPkA0gkmtVCrFYwPxY673u4j7exBZyOCx8kgfTfbz5gbs8dH85dmcs7KKyMtZYliJD44PYl5 eZFgvh1rhgq9vHBfuh1WAs6VlzOjEn50IvW/Gj1qhflSdG90eLUARCPe0L56Z8EupCaDBYZ1/ dtYf8tYpz01YAUefzdtkXkDuTatW5iS9J9rbRb8l6a19Y4jl+xKVa1QzUp2MbN59lv3d9u6X7 gX7LY/neHAwh39NVD6z6p0fR6yCtjA6Ytz2LOIrC+2jLT7vWB6sZzjQUd+vhi8SVq2ULyGwYf nhNXQVy/dMTex496Sfs/vvLMW0nrNgNPdSaFf4skJy0ICO42cMITdLUyXw8hWdyiybnFOvm2v DlrKXyEbRxQAxi3HWByT84Py+MENN+J+TowiEKUJD4CdFV6rAjX61xgNrPHFK/FQkCUkFsvdC J9jXqg== Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo After driver initialization tpm_tis_data->locality may only be modified in case of a LOCALITY CHANGE interrupt. In this case the interrupt handler iterates over all localities only to assign the active one to tpm_tis_data->locality. However this information is never used any more, so the assignment is not needed. Furthermore without the assignment tpm_tis_data->locality cannot change any more at driver runtime, and thus no protection against concurrent modification is required when the variable is read at other places. So remove this iteration entirely. Signed-off-by: Lino Sanfilippo Acked-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 65d1ec7eb4c3..d705dfb64cf9 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -728,7 +728,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) struct tpm_chip *chip = dev_id; struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); u32 interrupt; - int i, rc; + int rc; rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt); if (rc < 0) @@ -740,10 +740,7 @@ static irqreturn_t tis_int_handler(int dummy, void *dev_id) set_bit(TPM_TIS_IRQ_TESTED, &priv->flags); if (interrupt & TPM_INTF_DATA_AVAIL_INT) wake_up_interruptible(&priv->read_queue); - if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT) - for (i = 0; i < 5; i++) - if (check_locality(chip, i)) - break; + if (interrupt & (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT | TPM_INTF_CMD_READY_INT))