From patchwork Sun Nov 20 13:31:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13050038 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 7ABC6C433FE for ; Sun, 20 Nov 2022 13:32:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiKTNcp (ORCPT ); Sun, 20 Nov 2022 08:32:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229508AbiKTNci (ORCPT ); Sun, 20 Nov 2022 08:32:38 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F1CF326; Sun, 20 Nov 2022 05:32:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668951129; bh=b2p9orljkPQAtfm2cx8Ohv8A3ug+yirHYm4KhuxDbQg=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=cLJ3ZWl4KL9RDxAMDQazxg/pLd+UAJ34UD2jdHsrA8zzTo0oZuodjjbrCIaz6ztdu 9cQ11nbp1mfazF3yTPaPX9QZ4cZ3GkCm3iqjKhSud4umBw4KGR98KnmC5X3fbmvoot 6pgPZ2vcyLUDUbclQLgzDfdyBmt6AahXVjwkgd7XWXvhxbwN/J535tAo3mRPw7qS76 OL75adGNRqhq8oOOysn3HkdJxylcl5o5lIyTJldqnZWL1SbpWmWRtVApJvWWwGK/hz mAaZUx3xI/K+0u1xiKGPtjNb9Ho8oQXYDJ435hDGrPG0sqfEdj1accCwPnm38sOizy xV7mWRLrqQRZQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from Venus.speedport.ip ([84.162.7.17]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M8QS2-1osMht1t56-004VDT; Sun, 20 Nov 2022 14:32:09 +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 v10 14/14] tpm, tpm_tis: Enable interrupt test Date: Sun, 20 Nov 2022 14:31:34 +0100 Message-Id: <20221120133134.28926-15-LinoSanfilippo@gmx.de> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20221120133134.28926-1-LinoSanfilippo@gmx.de> References: <20221120133134.28926-1-LinoSanfilippo@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:BKMRYOEhyfnkSjTu8QNQmyWBrZ0shgweC98K2S5I+em4v1FZ1vw xJm/V0KgsjeT2pkq7QRrr2FLo/CfBqDLcYP60wIBRTvSLhV68R/Ams+kdnFxcYt8jb2L3ou pZX5r3uJjv09RWyvQxM4GR0ioUKekCkRPUT1LtkvJkbc4AY47ouqSRekmuK3Rmai8TxViw/ ynwEGbIg2JzXb0ffAcbEw== UI-OutboundReport: notjunk:1;M01:P0:mrSM3TH/Aok=;Dkll088hNQPY5V9rJi8UGOJXlhK /cloz7pNK06KOjCzCC7ZWEhOByE0aQhQh/yKhebkyyVJzoIOi7ySiRWEn7/k/WVebebusWZW5 igSfzp1b/aMLUvcKxZ0zBROBN7QemmtzaJkYVUUVIYx1OAXtndVQOj7LD47Qy7MFIA8yTcdcu qUnFLg3CTqrNLkNylDVcxLqPmjv0m4PhCCFuUBsZnkPHnNrn2TJx9mgPdiV2hU1Nf/Tnm+HMV gvyIL4YVTruDZ6U6OWhwyl6YTlpJ1XImMPm0F9LRxTegVJmYB18oDaf+3jtySuBYVA7f+6a+g RX33Z+uitevMgTTkiEeXgMk2l6AAlLmz/jVusjuAheRxqy7PgDHSVepwAPTGNXvMLSHnwS/aC 6MJr5oUJdDfeHFyUgYhpQkPf3HHdCds6xObHFPFqFpd2JP8mSSXoo7zfH72QfwjJ2Alyss9wY VQZy9Le8z307WUKTx8nRijLcRWh0a8i5DhlO4LxJ3vYDkUM7g/kkduiowOiFTJnFCDiR2C2Ei vRzVFdQgx8HlUQWES9VC/LfFuIotKfPMYFuHRl/8YSF0lfDyvMgGchuTLTDQ6W8VRSGivjsa8 rBbP2n0JLxVleUFmJJV1qTqWw+ysuXQa992+eD9mJZuuEY0JtOQrgHurJhlBj0kvGLKfxG5Zh Dpa6StViIIfspolhEyzYsSG72zgPgrZFLxlgWDR1D11BpSgGWW7iwYBV5Jkx0QzjUn30aVTsJ OhyCQYN3bncQigf2207ca5wL+fT8yREiW6y7ZroM4ZA40IoaVAzwQgKWT+JmHioetZg6ZmKJT xhXDqh+0DMn6eG1DEG+ch7yUVh8j0zxQKgMTufJBCZNFIIz8T6h81SA3vDnE6JWIQTfwj4hua uypPw1ZsctNbDOWQtnjsxDyRpMr4Ngk6/4UYYqNKEKsEi5/+SeMOetD5l2aEExv+qyVhll3ZZ MPrTOg== Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo The test for interrupts in tpm_tis_send() is skipped if the flag TPM_CHIP_FLAG_IRQ is not set. Since the current code never sets the flag initially the test is never executed. Fix this by setting the flag in tpm_tis_gen_interrupt() right after interrupts have been enabled and before the test is executed. Signed-off-by: Lino Sanfilippo Tested-by: Michael Niewöhner Reviewed-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index b97cb325ccb7..602ca4bb8e2f 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -787,11 +787,17 @@ static void tpm_tis_gen_interrupt(struct tpm_chip *chip) const char *desc = "attempting to generate an interrupt"; u32 cap2; cap_t cap; + int ret; + + chip->flags |= TPM_CHIP_FLAG_IRQ; if (chip->flags & TPM_CHIP_FLAG_TPM2) - tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); + ret = tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); else - tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); + ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); + + if (ret) + chip->flags &= ~TPM_CHIP_FLAG_IRQ; } /* Register the IRQ and issue a command that will cause an interrupt. If an