From patchwork Thu Nov 10 15:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13038927 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 EEBA3C4332F for ; Thu, 10 Nov 2022 15:26:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229829AbiKJP0k (ORCPT ); Thu, 10 Nov 2022 10:26:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231569AbiKJP01 (ORCPT ); Thu, 10 Nov 2022 10:26:27 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFB513C6FF; Thu, 10 Nov 2022 07:26:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668093945; bh=NZ0b2tOq2Jj1mWbGc2AGV1zg/VmCzKBMKS0JDk1OzUg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=JraCJdsKpqTaJ1tCduuIEmE+jAYDJpzWpdV2jYswMKYAuEZ/y5xjAMMDFv9Jpt43E JEtjkNPZYzBB7ZdZsimenVC5Ar4VddpJGl5M45xvFFDhgrS5tJQVGojoJJZc3NxM50 QSbQalNEqu0fhhstUAqwqPQbmR+L6PJPJq8XhGHU0Btozc/wtR7vHFJoiYF/YfbweI T6Z3AMYN9R6k0tD3wvEy/Vz8qcX/9FS6BZ99vRoBPwws4NeYwr2ZzOcuDe3/bZFgR8 KoLuErV2A1UuK+RzW4TyTw1zouoR8DLVHKyYXBy0gyd5AV3ufL4BZeBNhy44RskGd2 QRffVo0oqmM/A== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MwQTF-1p9Zj20CdZ-00sNBA; Thu, 10 Nov 2022 16:25:45 +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 v9 07/12] tpm, tpm_tis: do not check for the active locality in interrupt handler Date: Thu, 10 Nov 2022 16:25:28 +0100 Message-Id: <20221110152533.24243-8-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221110152533.24243-1-LinoSanfilippo@gmx.de> References: <20221110152533.24243-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:GxP0aibOPHfomqlU2L62HC78GYwnrsSmJt5Ub7ZOMwbOcAXKjiZ TmH7+V1qV/nkWal0Chqm7Ie45EULFTBztt0nz6MsGxyDfTmEJYv5fktsf6RET4B7IT3benQ /vnTRy7nbIafZMQrbmt27nnhrsr1ZPIeME8jRZtj52XunV4xRG2EDK5Yq75ez6jNrcgOUoN lbI0d8/n0/8QfFEAvE6dg== UI-OutboundReport: notjunk:1;M01:P0:pE9h/nbfKPo=;amtKpgOOFt18QFUb+vzjAWN2835 uIquYovDCbBjPUvi+DhHtFa4miXr+EkvA+4+GmktxmLK8CYEkbqgK4PTlzqTDWvcaLH0PrW2Y R7k/Ic16SBH1ldZA8W5K52+FfKc9TwXzeTU3htqPcekjX3SGMswS/0vsEXzb/1hedV5y68VcL CRCh3dS51SrmROZBG6UQ10GMx5FFDfxVLzIaCAnJqoYg0XZoyo5okMQrtQF7SGcwRXMEN2qFr 39WaWxhjHrI5Y/e41Rz0OofushHhXXIVY2VK0J42R+Lmbxj17mL8A9ZNqH0l1gFLBrBDvuWo+ y6K+AWEEYFh/FHvZG9qq3WDRAz+27whaqJ2xXzLCjZBZzTJJhu1d/A6MVddZaix7J+LBewaTZ HCnSOp88z4gl8LO846ws3993XKNXuJrq/9rkI0Q/W/IH8l/1vGVt5uX+Wz3Gl5VcVD+AdaeoX D31efIBIBiUFNqdEkKVDENVM+awbqPfbkwKN9UAey91bo+/3NcbKzyulGOErleHaOE/cWFaZf pzQQOrizAmB+h/EBHY9ox4r9CF+pZ5ZhgqmayPb1zi+nqJTwzXsP3KU+/Vpqpj/BW795aVv/a 3kqJvNiLWR1LxxArrfjOFe21PusJxyUxX6VaBMB0IpHby6i1Twvn2WzdHW/0LYC+44xyK9m3K a3h0okqcUV89d3zetbXB/JpI7+Xgeeg662/MbSuJLAzFe9IzgHPr7vorVqGg1e0Zny3wFnIZe fLecKn3to3Okx0v0N4qpp/SJfvLRMGV8wc+l8/aJnXwgM3KHZcvC6+H9e4Y/tew7P5c4bQmzM /vJrw01ZLN3Gr+N8tcSZ/HDVT1C5LyZmIvF1jvvMUN3xSlJ409K6ygKU9vGYVIZpq67yYT3is LR3cFWhFf+t2QR+q9tjnQAjwZzsrZKbjPCi3qxuDdpwNeh2cUv3XmwK9ZQHeQ6wPSN+tg8fLd itOuV3FeF/lcPF52bGJ6c5OV/H0= 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 181c291b0bb8..4336f7ea8c2b 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))