Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1514040ybt; Thu, 25 Jun 2020 07:51:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxixH3sw0lYMIfmr3OYS8KtPaJ5g07fNE7FCC8weKlLoRG+W8cZpKmd6j5GyQRB7GMxqheM X-Received: by 2002:a17:906:a385:: with SMTP id k5mr31227932ejz.44.1593096669837; Thu, 25 Jun 2020 07:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593096669; cv=none; d=google.com; s=arc-20160816; b=f1asnORK+DoAY0ks1tqL/Qmtz1JJehyVOCYjEYN+nQqWT8yI/nM4TIfJrh9njJk4BC uFQFGDiQQ5yB4dkcSWwEyqcOn0y2MBlnXf5F2vtlKVTkvOhb1sJydq40xfZrcJmY1LOZ VRdG3mrFKGJpz+A1+vykuBJuaZw6gYvRUVc7GWOe7JrNWvqVhyPDMey8P7/fsg0FVHJX qg3OnMcoL7XVWkkl2GDkQa072EP0XCj/+QLJLP6TRoPVtcQjLXxTHdG5s/cXh192DQaZ JbFNNrsFDBkBZMvEGqPBI8jNSkfgp2hU2FvRlI95Ff+DZOiuZKYi2w/IRwcjxr7PqB53 p1kg== 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=LD8u2K/hqU5nKfpFJeSbqu7jSbt94I+33JhAfj8SxOY=; b=emdJaN4eiLmEVBqsSpgW6tRs7cli0+fu7JG9m5lZANgSSHLM9A/MLlgZwEluJ6DagT 9Hj4Maf+OTba/P2qFnJ0Rt9dv9ViEsJ7e/BZ1ZSObWbA74bgUpKkxAVP5ckKMqPf3iE1 L/fCCBx0ZvMEhWyZV5ZAj4xb5/Eb6AEI+dz9QsQB1aMCfv73iY0NizZBnuNCtUnEu1P6 3XtKH2RJBMM0e0cowhqEUBkKZVFm7LSlcZn45DvX5FdDdb8CUn0mAW/5duHYR354oTJ0 jgC0O86P90nf70bFcEjcHuUH1/3cs/ULChwvST9cJy6Qc6uypEw0SQdS255+fmhRKc30 JSPA== 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 c9si716885ejb.631.2020.06.25.07.50.46; Thu, 25 Jun 2020 07:51:09 -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 S2405590AbgFYOtF (ORCPT + 99 others); Thu, 25 Jun 2020 10:49:05 -0400 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:51464 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2405425AbgFYOtF (ORCPT ); Thu, 25 Jun 2020 10:49:05 -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 05PElns9015288; Thu, 25 Jun 2020 17:47:49 +0300 Received: by taln60.nuvoton.co.il (Postfix, from userid 10140) id 9D642639BE; Thu, 25 Jun 2020 17:47:49 +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 v12 5/9] tpm: tpm_tis: Rewrite "tpm_tis_req_canceled()" Date: Thu, 25 Jun 2020 17:46:45 +0300 Message-Id: <20200625144650.269719-6-amirmizi6@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200625144650.269719-1-amirmizi6@gmail.com> References: <20200625144650.269719-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 347c020..a38465f 100644 --- a/drivers/char/tpm/tpm_tis_core.c +++ b/drivers/char/tpm/tpm_tis_core.c @@ -701,13 +701,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