From patchwork Thu Nov 10 15:25: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: 13038932 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 9D7E8C43219 for ; Thu, 10 Nov 2022 15:26:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230513AbiKJP0o (ORCPT ); Thu, 10 Nov 2022 10:26:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231149AbiKJP02 (ORCPT ); Thu, 10 Nov 2022 10:26:28 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD21140915; Thu, 10 Nov 2022 07:26:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668093946; bh=btC8dh3Dw+tNF4g/eehZF3VWk3cjhFERu/V5ftrirJU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=KS4pwt5e7dF5v08WVnVrcx+livLGTde0Q8qRYi7YuKyWajffO3E0LyizhO/WuJuOJ 2oMCxeFmLe7Q+A58SOsYlEAQRpL/thR4//cU1/tus8oB7ZKE+8pfAHA47qCqljnXZ4 d9HOdXz6/6v/LyCsw1+TJf5H6A7mj8PL4tE4inpbUF1fenztDRtSzuxs/tN/4wRUKw yM9yXczC3A5ZllXUoB6exdBliS8WYFlUbU0ui3cIoia5pR525Y4poSLs8ipJZmUL2n NPrVfsquhc6VC2NGOt2+8frYuR6VfUm6GSGTGkj5t+LznYG7cBvzqjxChPWZzdk84+ E1WNpRyhvievw== 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 1Ml6qC-1pGQQI1UY0-00lWbB; Thu, 10 Nov 2022 16:25:46 +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 11/12] tpm, tpm_tis: Claim locality when interrupts are reenabled on resume Date: Thu, 10 Nov 2022 16:25:32 +0100 Message-Id: <20221110152533.24243-12-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:A5G0ft3dSpBNzjqm1md9SHcjwaK4bKyVV/yoMeXJ+jVjZzq7VdY AuBcZPbCNhA4ddUre49DAerbGgjciksv0owtEqpPumDjCsPpptePlZ1fUTttnyiT5ifaKca 2Li0xgq0PZQ4JGvhumjQexAzOMxv3eWVjmzCz8MqRDeYU8tb7knd4TZccFrt5fkker0DUv5 7Za0l/odSyyJ/09Vgf5sw== UI-OutboundReport: notjunk:1;M01:P0:BBiN0L+fq3M=;NOc00iAhdsZJs8odzXGACJWmRyp uCnsIirG2oEPjoP+q0V9qNUUy7S4JdiQt7HrLzPsL0X2yT2YTW8qG3BfUMAkeiGJLWzj7mASU AuVmRfBohZ/d/fGuOiPewkiawHyhcyMWSbT0KmmJh1N//pjqeciY8D02KEETJcG7kbJJpTGue 8+gAMUQ8R2sMHMQDPN4FnwgzJIIrw/EmJ+KFN4JdM6ql6gJKYPJZwUpqhZ13PvmK8jc1zaSU6 diVlB0KxgEZsey1OYionJAZ3XjcCNzEp7BHY6D/HW0YZ5Dbl9ugWr1jfxioQ0HEELhNGpVqrC MLmFUc7yzC0//NeNlmIUWGi5PAqsHofPevpOP8rGlNzFs5ZOM6N2jeBMeghhL/meQD9gPXx7T vS73n+cLJQ76ccWxbJhOoKjujbofhmSGkW1H2dF62UxB0X9EVqK12S6po5j1jQLPdbBQw4Xnp wFvUJNdWn+zmBjM9kE5BfQ3c2AxhjN2FVgN6d1Pocjs/PHLykwrCYAEOApKyDbH7gYlZ8e19t Mws4BAdFMQCtMObygTNAIzik+huYcBAjRc8KWsDwCdPwDn/ENfALXyqR9u8zlCpU1hEhjT3o4 15v6uMwnEpDFqciHAuY74cuMzop2aif2FTviSK5pXGfkjRLtvukDY+Dy4SBFvMoTTBVuqaSH4 TUeEV5tC9B1J40k0OHF45oh3KKrpxZ56rAWWx8jnT97qRyKas1MPba3ANWqbdwLdh8+y8gnbT KTL6Cs85zNaUw4Z2nnKy1cPhOV9jPHNr6uQop7fX0oN5lajOVSK+XD1qbFF01sNKW3Cnq65T4 6PYF0SioAyxELoyfLOO6w42oojNq9tjJCXPx9cFsWEcAeotAzYOECP33Pe73YbR5OVPAHx0YF O/kHExO3eJwp0osupJ4WriN1/SNXWWE7PgxvQ3kMvmIaZPInYmz/K81ecxAIFws9fOp8fd5aG MrgduvusoZZxWhctZ3afVMlsZV0= Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lino Sanfilippo In tpm_tis_resume() make sure that the locality has been claimed when tpm_tis_reenable_interrupts() is called. Otherwise the writings to the register might not have any effect. Signed-off-by: Lino Sanfilippo --- drivers/char/tpm/tpm_tis_core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index a0a1b1a3ddc6..469a1db95941 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1241,28 +1241,27 @@ int tpm_tis_resume(struct device *dev) struct tpm_chip *chip = dev_get_drvdata(dev); int ret; + ret = tpm_tis_request_locality(chip, 0); + if (ret < 0) + return ret; + if (chip->flags & TPM_CHIP_FLAG_IRQ) tpm_tis_reenable_interrupts(chip); ret = tpm_pm_resume(dev); if (ret) - return ret; + goto out; /* * TPM 1.2 requires self-test on resume. This function actually returns * an error code but for unknown reason it isn't handled. */ - if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) { - ret = tpm_tis_request_locality(chip, 0); - if (ret < 0) - return ret; - + if (!(chip->flags & TPM_CHIP_FLAG_TPM2)) tpm1_do_selftest(chip); +out: + tpm_tis_relinquish_locality(chip, 0); - tpm_tis_relinquish_locality(chip, 0); - } - - return 0; + return ret; } EXPORT_SYMBOL_GPL(tpm_tis_resume); #endif