From patchwork Thu Nov 24 13:55:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lino Sanfilippo X-Patchwork-Id: 13055007 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 93EC2C433FE for ; Thu, 24 Nov 2022 13:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbiKXN4h (ORCPT ); Thu, 24 Nov 2022 08:56:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229980AbiKXN4c (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 E270CFFA83; 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=1669298174; bh=ZQrQ2undxx4v+6nZgOuKeQ4fsU8UgfXoZI9MOOth8tE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ddo6u5hs4cj434HcTpvwD7vW5+PiLY02huNtyJ4ohWXaqqaSRC8kFnEX1Oj1/186W f5JQW+ArJNDd88wHAGIFB2/Ewor1o5IZfXdV2Z0j8BuswykfniZffgtTnV8/ObB118 wSquDx1nblWyPykGdYHSUCxaDbA3ILAfhhHyRoHqnlI3D/Yi8mph6U/QXLBLH6wPE7 LQPlao0reGbUfmLBZZuMBYXJp+ZPnO8MytdAyXZOiTFvNjA5pxttEx7N9UwwvV1Kno Gc+YCMSIrZyYcP6CuhEegwtY05QLm88r0wfeGr/D1OQPcxkV1dLWDvCj0Cd4t+6+GH WcpSx9yqGegkg== 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 1N33Ed-1p3SuR0Ny9-013PDZ; Thu, 24 Nov 2022 14:56:14 +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 12/14] tpm, tpm_tis: Claim locality when interrupts are reenabled on resume Date: Thu, 24 Nov 2022 14:55:36 +0100 Message-Id: <20221124135538.31020-13-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:yRmIK1f7+KxuNnECWFfKad/tTssuC85ALDbC/SoyTS81qtmvqpc AwTK5Hk2uvTdkpPGPYrmxnkYAyuykDIPFH1hQ8ViCKeKAg7N0jx9eMxVXT+BHCbIQfwq1fm ++obvjcECsK1RpCjoFxvWhSV3yVS3dMTB6GuYJlWd27RYjG5hP4SlLg60HP7rwVWtJUhxjs PtxAMW45nsfvyImDBW3gg== UI-OutboundReport: notjunk:1;M01:P0:Z2d0MsdV5WE=;XM9FBqeSHw8Rx9MapvOY3cFSXaZ TC5cmrDnDLdiVszxx1katTwJrXLSo3xzmP6t7u08luQvC/KkeXD0ldetn3rkG1HPwy9iWqwGq HTEjSyYryS4qLssywWSmBK/MFilZoDrJXB8wrmNlaIrQ2YMzmfioHf9cisgqeSJ8cTbvTQe7T OqKjs88MgELFapfpNiIdFG2ECoa1XRc8Ljf7Dy9bLdqTXBk/L9+Rx9SU+PKZQfvt73wxIEmed IT6+WXiK/N3U/c/dkmBmxufp8QdyNzml3LnEvt3s7sLaxRqo8vHOWbw/mPslxwduN8ZTDHbt6 MsKUIPoK2SnJbI/Qb8Kg+aP/c/SbJusfsRlDbUuuEzLImH/eCHxI62Wvl8otGYrjMBWoKcIpe vrrWbx/pNkjvul8uEem7bDNd5MUhuU0PQnqRQPyKvhW141WcPrJu4+ubsvN/jfuFCfE5aSxqG yUufGqqCnIlCDEJgI2WaV0PV43V/AKwCJUOn2UayRRbTmbOhC/YcK6zeTt7G3oO2iaj4URrH4 nxtNfyQQz1RCHu931HXJ3bhZUl9JmhZ0RPLtNpFwN5PY0HTQwjLgSng+UJ6PJnTJT48ElV3cs Qnqd/Dou35TyR0FnUz/yFPp19Wx7VyQ8NGjGuCKbL+feZiGECgKNXDbl4ONCKW+f2pE82YHfy TzK6AsYIx7LAYCxub+iQNn+HP2wYSG76GmQTd/a2W/67l2KmKf3h2WMf7OXt2zt+vGSXUIkBc O2NSzOU4YvLQlzs+Ax4Zml/Lmx5UllM7uPJpcjVkWpYO9zwtz9Ie3n3gvwEesjZhD+/ac76Mv q7/nKY0UHSpg5Ytl/ZRswiXHZ8zjKg6f2d/W2hfIfG2XHaRFZXOJR/uoPWdHjhpTjWlgyGy1W MCNjOFAwR8+vBlX789a8++OwFeg+s8yAlF/1NagbadH7I60qS43p9pKBJrcmhgp6KrqzgNcTp HunYdQ== 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 eda3b122e540..ddaf362e62c1 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -1221,28 +1221,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