From patchwork Sun Nov 20 13:31: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: 13050034 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 2929FC4332F for ; Sun, 20 Nov 2022 13:32:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229773AbiKTNcl (ORCPT ); Sun, 20 Nov 2022 08:32:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbiKTNc3 (ORCPT ); Sun, 20 Nov 2022 08:32:29 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CDA824C; Sun, 20 Nov 2022 05:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1668951128; bh=4OA7IK6FYkk305Zhb0W1evKbz0zZ40AwmsMipD4BkLE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=NSBTHCpbkjFFSJ2iELowShWXLJ/DsbOAcN5yzEAo+5jUsmHpdecwn/PEWEp1OZu7x +iZ9Dzon0CDxHEUAPQ5/wq95yje7yK1+Cy3BBC9vQuXdaVn3YrEJqQyJXgP9/S6wL6 es5TT7Kk3kEZVBCG//62/vJk6p+9guMF+uozKh29uAyHjYy0V+VZTT0AEHOCzoxPgZ D8tBINVQEzOIHDGqVDgjx/YSXg1UitREpki5ezClrMiita84qYb5NTRwDJH8ourAgn XnHOArEWN433lxP1FtaT/ia5SgJnq3Za8Ej7t8AvrspcsVpjG/vkhdC4fp5kedAF/J Kmbj1Tp1/rnow== 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 1MCKBc-1onMmA3ACg-009RAT; Sun, 20 Nov 2022 14:32:08 +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 12/14] tpm, tpm_tis: Claim locality when interrupts are reenabled on resume Date: Sun, 20 Nov 2022 14:31:32 +0100 Message-Id: <20221120133134.28926-13-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:Y2Bn6bdeDl3t3/ithIn9bOFj1yJNMiWUB6ywXGw5LG20I8Pov/9 QvJYibFa1pdIC3bTtDU+GUHDY24TPVfdTvJ506nTc9DYSqmXZ7vevwNzbaHLe4jtpG194c8 mDP0STxKk2YNQE6Yb1aUsHsM6tN8ouuh8WkQD/JMwxUCIoJ3qGr2Epui3fgaG5ZilWW0boB ZCZ7Hn3YNez4hQeaejUyw== UI-OutboundReport: notjunk:1;M01:P0:Nok8fe+gyn0=;mDY6JN+z9tqG7De91VyS9iEMns/ gRYGlqR+3QOdsfOPZlj51R4mCZZ3gnl7iSQEVPvdA5JHovRI63axlIg/Dd8Zn+Yx+daiPwAUK HeHDGD6ymUE7r7YujIyVkNM9HUjoCQ6ketUoT4ytRki3qvgisQ6jHEaMfc9MXFHd7bVj2sMJ9 sO5E2suzurAVEnhQD1Kz5qMcYTQmA0VCEuDxoyqYvDEjzQxcvG/wSV6MFc64UVOA0MTePtZEQ c2hTBnGXmvPHutIHBKuxg2Z1cfHmaF8DF/gFMHVLfO1YBvaMc3Uc313kt5KTDCFU2cejsxdxd B290wl5KsAXVVIGLDX8TFjnNYtwjmk3NW64Gzni8UVX49iLwx2zN6RbMSuAtqDwY6zTyJuJWE JjESKjwNswHIIeFSLTNPVW1BP2QEiqeYzubFxjT5jObf4j99adDrLY0cDWrvI082D7RXTA3s+ LZ4khSBzcT3MK8pVu1wXxG7AI0gLv1y7Tav+O9IYhtlt3abCHluaLeUNNRIPori+v3/4z/cx7 yA0H0gVqUdp2ZR/wNL01kExlP/AyxZHQlOQOcRmLe8JzSN+hbmpSxGj/a9gUvk5oxcXRTN2Sv iaX+BcYq6fHLE+OYrlz0miHQMpQgjO+9wMjIvT73GBblzARx4yXhVkiUa18+bNLRTNp9a9XYw Hit9BrdAquEehZKoQqKXqmZzhiIaVFe+Usca+m7AvuHvB0h3kIJwdmOEj+BMKelzGctTFeq1c hGe38Kuo4V7pzXuXk2mqv8gQesdCNGEQ/9Oe+2GvxCTDvIXKnqbjBQXNMxGnIEZnfxsWnSQwz B+KvkWWEaN73/eQfrrNG3C15YNkkOZqAGvUNamGXNjfkZmoDogVZgRxHpeC0AN53WbaklZuJ7 DUpVv3zhD167/NxRthzyuGqxgU3yh5XbSI70YPjlKydB+w9BbZK172rNC5mVfkIi7RqAqWMIk bIVd8Q== 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. Fixes: 45baa1d1fa39 ("tpm_tis: Re-enable interrupts upon (S3) resume") Signed-off-by: Lino Sanfilippo Reviewed-by: Jarkko Sakkinen --- 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 4312c5cc13da..2514e60f6778 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1220,28 +1220,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