From patchwork Mon Dec 25 02:22:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 10132223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 054EC6037D for ; Mon, 25 Dec 2017 02:23:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECA28289EA for ; Mon, 25 Dec 2017 02:23:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E1B5028C8E; Mon, 25 Dec 2017 02:23:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E73C289EA for ; Mon, 25 Dec 2017 02:23:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752111AbdLYCXK (ORCPT ); Sun, 24 Dec 2017 21:23:10 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:45331 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751891AbdLYCXA (ORCPT ); Sun, 24 Dec 2017 21:23:00 -0500 Received: by mail-wm0-f65.google.com with SMTP id 9so30525691wme.4 for ; Sun, 24 Dec 2017 18:22:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ukTmvsgQ6D/jfEm/U1ueTfHXgtTeFvyLSr2WQFiIChU=; b=a+WwS9VHsQuNKivs8enkR8b9YD2S5i/qTGD9OigV0YVoh7/hdwCfu83fyymss8Jk/d opGhwk7l5CMYHw5I1oRx/dwTBTnYQDH6I2zWWdDiAjchZiAfeHHB9JAMc5MsQqvLYToX goF5lD/K+rAdaK1suFu0ZQc7zYBL3JJN0Ta7qE4LHmnNYqTy16VFJ+7fUwsIkjgDCGbG FLL01/IMPPBuKtNfvJcg4++y+lLTFtSrhVRL7PURFRWxVph86tfkhsLWnEJHCPgvxZgo lEABz7+Eapv/xK1V21pE6pADbVFKIC414Rib64HtMf/euJxo1iJhDoY4f5a0v68+SgD2 XRKg== X-Gm-Message-State: AKGB3mLhyLUWCpWN2Ac0b2WJYmU+2xKyDYQg2BV/jdtVtxDAu0GtFCv6 JVbWeGGmBh1mEmVxDny3tsF+/Q== X-Google-Smtp-Source: ACJfBousfRzM9C4vx3gGqgxUVy4L/jIPef+x1CmhwubmFBrbsubcKhHXFvPt3Px/p5pmbdHcIl6mOA== X-Received: by 10.28.190.12 with SMTP id o12mr11996040wmf.148.1514168578627; Sun, 24 Dec 2017 18:22:58 -0800 (PST) Received: from minerva.home ([90.77.100.34]) by smtp.gmail.com with ESMTPSA id v10sm7635011wra.15.2017.12.24.18.22.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 24 Dec 2017 18:22:58 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: James Ettle , Hans de Goede , Azhar Shaikh , Javier Martinez Canillas , Jason Gunthorpe , linux-integrity@vger.kernel.org, Peter Huewe , Jarkko Sakkinen Subject: [PATCH v2 3/3] tpm: only attempt to disable the LPC CLKRUN if is already enabled Date: Mon, 25 Dec 2017 03:22:51 +0100 Message-Id: <20171225022251.6464-4-javierm@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171225022251.6464-1-javierm@redhat.com> References: <20171225022251.6464-1-javierm@redhat.com> Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 5e572cab92f0 ("tpm: Enable CLKRUN protocol for Braswell systems") added logic in the TPM TIS driver to disable the Low Pin Count CLKRUN signal during TPM transactions. Unfortunately this breaks other devices that are attached to the LPC bus like for example PS/2 mouse and keyboards. One flaw with the logic is that it assumes that the CLKRUN is always enabled, and so it unconditionally enables it after a TPM transaction. But it could be that the CLKRUN# signal was already disabled in the LPC bus and so after the driver probes, CLKRUN_EN will remain enabled which may break other devices that are attached to the LPC bus but don't have support for the CLKRUN protocol. Fixes: 5e572cab92f0 ("tpm: Enable CLKRUN protocol for Braswell systems") Signed-off-by: Javier Martinez Canillas Tested-by: James Ettle Tested-by: Jeffery Miller Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen --- This patch fixes the bug reported for the Fedora kernel [0] and the kernel bugzilla [1]. The issue and the propossed solution were discussed in this [2] thread. [0]: https://bugzilla.redhat.com/show_bug.cgi?id=1498987 [1]: https://bugzilla.kernel.org/show_bug.cgi?id=197287 [2]: https://patchwork.kernel.org/patch/10119417/ drivers/char/tpm/tpm_tis_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 03daf7017e0f..a72a9f03286d 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -747,7 +747,8 @@ static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value) struct tpm_tis_data *data = dev_get_drvdata(&chip->dev); u32 clkrun_val; - if (!IS_ENABLED(CONFIG_X86) || !is_bsw()) + if (!IS_ENABLED(CONFIG_X86) || !is_bsw() || + !data->ilb_base_addr) return; if (value) { @@ -806,6 +807,7 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, u32 vendor; u32 intfcaps; u32 intmask; + u32 clkrun_val; u8 rid; int rc, probe; struct tpm_chip *chip; @@ -831,6 +833,13 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, ILB_REMAP_SIZE); if (!priv->ilb_base_addr) return -ENOMEM; + + clkrun_val = ioread32(priv->ilb_base_addr + LPC_CNTRL_OFFSET); + /* Check if CLKRUN# is already not enabled in the LPC bus */ + if (!(clkrun_val & LPC_CLKRUN_EN)) { + iounmap(priv->ilb_base_addr); + priv->ilb_base_addr = NULL; + } } if (chip->ops->clk_enable != NULL)