Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1319147ybg; Thu, 4 Jun 2020 06:52:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvVEC3V6bT+7JyPVvPShVenaWpKxrpnbtpZPYrIUgTTyydhKLyNn8Cz5ZfgGCKtOh3JX5H X-Received: by 2002:a50:8467:: with SMTP id 94mr4307438edp.249.1591278720046; Thu, 04 Jun 2020 06:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591278720; cv=none; d=google.com; s=arc-20160816; b=iDWQqIT503t7YCZJ8nrkUGmq5RxhzBJcB39FHQoTiYCAkaOGpajtWRXB53Nz4FAu4y 0oSCy16TlYJsCMwTC47+zNCQYIZsLXxsOKYkU8F8xODCF1ThXCN63cdRLaTQ7eb4ktLh Hb9bQqF48vrGQKILxn3Ph2oZ+SGr+vZbs4PYZ/sQspUcN7n6rGu33QnLE9fatPRwmaua lGj6qTqKAoXubpQw/ahddsIAu1mRs64xJNSAjsR1Ak+6IcAkhEN6z0d7pXkYBh7cztEz h5At3SAVqsBibD2tgBYzen3E1dWrAairgXNuQ/vTQq7moE3waUlJaWlJ2Ke3cW7ETU9W DXRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gIWrXUt/gcXzYmwzZkoNFoqPz/7Xrhafpf6XF5sEd/A=; b=Vx45zaRr0c1KdvX4NRlPZXIkeBiKk8xvLRbBw0akW14Seqe+uhFYY0aCcH0jqEdTqE E+iX42sF8aiYQ2hXi6aTSKsMSMcrcaiyCfC9+mBxfTtYA4PmV0Voks5owHlAywZf3Mgz ffvwheHYauOMbVzk7p5zBEAhSUGzkiwL4BDFwu8QytWlgN6R9PiUzdnJcUolYICCDyjX 6w41SWEB1hUxFHOVHCRYlr72y9NWfWr0d3+sMZMQtAKw9f53W1XKPE4gxAn33Km0G04a rVGBsfO0PM4sg9eLIR/0c6haQ3k+hcnCKXY6iYw16tbtRL6cnsRNg0FHWZOU8FRMHky2 jTSg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w11si1591565ejv.686.2020.06.04.06.51.36; Thu, 04 Jun 2020 06:52:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728707AbgFDNsY (ORCPT + 99 others); Thu, 4 Jun 2020 09:48:24 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:50220 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728682AbgFDNsW (ORCPT ); Thu, 4 Jun 2020 09:48:22 -0400 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 054Dlv8K011529; Thu, 4 Jun 2020 16:47:57 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 1E681639BF; Thu, 4 Jun 2020 16:47:57 +0300 (IDT) From: amirmizi6@gmail.com To: Eyal.Cohen@nuvoton.com, jarkko.sakkinen@linux.intel.com, oshrialkoby85@gmail.com, alexander.steffen@infineon.com, robh+dt@kernel.org, "benoit.houyere@st.com--to=mark.rutland"@arm.com, peterhuewe@gmx.de, christophe-h.richard@st.com, jgg@ziepe.ca, arnd@arndb.de, gregkh@linuxfoundation.org Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, oshri.alkoby@nuvoton.com, tmaimon77@gmail.com, gcwilson@us.ibm.com, kgoldman@us.ibm.com, Dan.Morav@nuvoton.com, oren.tanami@nuvoton.com, shmulik.hager@nuvoton.com, amir.mizinski@nuvoton.com, Amir Mizinski Subject: [PATCH v10 4/8] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()" Date: Thu, 4 Jun 2020 16:47:09 +0300 Message-Id: <20200604134713.157951-5-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200604134713.157951-1-amirmizi6@gmail.com> References: <20200604134713.157951-1-amirmizi6@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Amir Mizinski Using this function while reading/writing data resulted in an aborted operation. After investigating the issue according to the TCG TPM Profile (PTP) Specifications, I found that "request to cancel" should occur only if TPM_STS.commandReady bit is lit. Note that i couldn't find a case where the present condition (in the linux kernel) is valid, so I'm removing the case for "TPM_VID_WINBOND" since we have no need for it. Also, the default comparison is wrong. Only cmdReady bit needs to be compared instead of the full lower status register byte. Fixes: 1f866057291f (tpm: Fix cancellation of TPM commands (polling mode)) Signed-off-by: Amir Mizinski --- drivers/char/tpm/tpm_tis_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c index 202714d..9d90b9a 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -687,13 +687,11 @@ static bool tpm_tis_req_canceled(struct tpm_chip *chip, u8 status) struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); switch (priv->manufacturer_id) { - case TPM_VID_WINBOND: - return ((status == TPM_STS_VALID) || - (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY))); case TPM_VID_STM: return (status == (TPM_STS_VALID | TPM_STS_COMMAND_READY)); default: - return (status == TPM_STS_COMMAND_READY); + return ((status & TPM_STS_COMMAND_READY) == + TPM_STS_COMMAND_READY); } } -- 2.7.4