From patchwork Sat Feb 20 12:55:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 12096869 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7239C433DB for ; Sat, 20 Feb 2021 12:56:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B33A64E4B for ; Sat, 20 Feb 2021 12:56:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229614AbhBTM4d (ORCPT ); Sat, 20 Feb 2021 07:56:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:41022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229490AbhBTM4d (ORCPT ); Sat, 20 Feb 2021 07:56:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1F19864EDE; Sat, 20 Feb 2021 12:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613825752; bh=K9h9PwzVuFck/DHhyJJBDnkh9g7ovnOcpR87cc2Yuxw=; h=From:To:Cc:Subject:Date:From; b=JB7w7aKtndSoF2YCbnKauXDpt6qxCv0c08t34lIgILK/xG4FJ5OXVIETWuIduO7o2 jxHKvDypSeu4Xvp+SCXvI2WVUtahehY+1yIABz5UJYHADTt65dNFPr7E1sy7IHvl8Z 1ZMRtCnRiKYIdBalQru4TDqLa5Zs9hU3neJ3Cpnard7vNVL+2HD1BMVlxdc+C/kxxh cYeRT6rg3F5GYgLTJF/MHpEULIl7Zwt0cPmyKXstR+wT327PXnYvrcuyCbg/nuFvYi z+alJh9wV4dh36eB4wjPuUNLihjguisv4hdfl7LyvolE0rSjAXxf9f77m/qE4/rQsA lRmRdP4v8jYvg== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: Lukasz Majczak , Laurent Bigonville , James Bottomley , Guenter Roeck , stable@vger.kernel.org, Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe , Stefan Berger , Jerry Snitselaar Subject: [PATCH 2/2] tpm, tpm_tis: Decorate tpm_tis_gen_interrupt() with request_locality() Date: Sat, 20 Feb 2021 14:55:33 +0200 Message-Id: <20210220125534.20707-1-jarkko@kernel.org> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org From: Lukasz Majczak This is shown with Samsung Chromebook Pro (Caroline) with TPM 1.2 (SLB 9670): [ 4.324298] TPM returned invalid status [ 4.324806] WARNING: CPU: 2 PID: 1 at drivers/char/tpm/tpm_tis_core.c:275 tpm_tis_status+0x86/0x8f Background ========== TCG PC Client Platform TPM Profile (PTP) Specification, paragraph 6.1 FIFO Interface Locality Usage per Register, Table 39 Register Behavior Based on Locality Setting for FIFO - a read attempt to TPM_STS_x Registers returns 0xFF in case of lack of locality. The fix ======= Decorate tpm_tis_gen_interrupt() with request_locality() and release_locality(). Cc: Laurent Bigonville Cc: James Bottomley Cc: Guenter Roeck Cc: stable@vger.kernel.org Fixes: a3fbfae82b4c ("tpm: take TPM chip power gating out of tpm_transmit()") Signed-off-by: Lukasz Majczak Signed-off-by: Jarkko Sakkinen --- drivers/char/tpm/tpm_tis_core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 30843954aa36..a2e0395cbe61 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -707,12 +707,22 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip) const char *desc = "attempting to generate an interrupt"; u32 cap2; cap_t cap; + int ret; + /* TPM 2.0 */ if (chip->flags & TPM_CHIP_FLAG_TPM2) return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); - else - return tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, - 0); + + /* TPM 1.2 */ + ret = request_locality(chip, 0); + if (ret < 0) + return ret; + + ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); + + release_locality(chip, 0); + + return ret; } /* Register the IRQ and issue a command that will cause an interrupt. If an