Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp110320ybt; Tue, 16 Jun 2020 18:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxav3hHBuRVwzxm5OId3qtRwYAtTESAsh9U9GFm7q/p4lUa5av7s3AMkL5KOXD2HygIXAb X-Received: by 2002:a17:906:f1ca:: with SMTP id gx10mr5116215ejb.542.1592356230698; Tue, 16 Jun 2020 18:10:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592356230; cv=none; d=google.com; s=arc-20160816; b=GQEhurMWSGIwe4PSF1niuWCj+7BPfe2/aqKyIly/5l2AkU5D87+zfJvocKGJZYXIWI x0qy5JqR+gYM472wc3xFqCsRTdg9pb1xXRLiO4sQFDdl3QfuEmSqHIRJHaDXWPOtMy1Z yeJbkn9nkoMXFlQ6bjrajm/OtoktuLue4MNXrQVUmNG2fdVjVR6CJ+CczNKivJVTa0jS Z0iwvsN/9d9UJAyb7BQwToSAeKyz39UXWbUXKqX4OPKzFBSy8scFi0j621gEcgg94MHY 0YOD1U9aUPuS60j3BCwC/F9nWUPpEbun7WTcGkVwIEwPB1ZwCbejXh6pgM527k93pNn1 vZOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=631nUC7rCU6pCTPCDo7ob02w3Hs+iqqk1w0/yk1XWEI=; b=JxT6KoHWxYaqjMtbdi2VwD93iikXwh3MqtegNgZQkwzrHMweyXFyxDadzSA9hM7iNz S4iY9raUZfVSB/t5T6dLUDIyuyBkEnsAx9/lPYxVPyYQ/RGdeXbBwRgLKUegF2wRuTJw RlVt1YndYKFxGggo+XGOlCFsSB5qsTmDD9HqOJPQty9jPuENUR2OZdX4lu4Qj5qOcylX mw5nA94WdGdTryUg4kkZdw91A8iQaWXVh2NRVsTkIWZHJcyexF5rB0v/MNSc9S+/bTgO dJSQrkHQPCw7cyyHFx8ILoUYVP7OeehXlJ+zMDf8KOp2lK4OX8GNHPXR7dk1s23InF7Q WikA== 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t25si11244160edq.407.2020.06.16.18.10.08; Tue, 16 Jun 2020 18:10:30 -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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbgFQBF6 (ORCPT + 99 others); Tue, 16 Jun 2020 21:05:58 -0400 Received: from mga12.intel.com ([192.55.52.136]:3622 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726044AbgFQBF6 (ORCPT ); Tue, 16 Jun 2020 21:05:58 -0400 IronPort-SDR: WnXuZpfr0F0rncc7t1hrc7P9wVgIfMvlhQ4Q1HqOj9IrW6ZYivFA79DVk/c5BpLSA61TjY+pTt LxsV4E8ktrjA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2020 18:05:57 -0700 IronPort-SDR: MAkF63yb+K9N07U4j2cEULH3Hiur+Q7TSSFkmxQobO+NCSat8OsJpSg2vz/qYdwT7hIiUSIfVy SOgJXG7rrn3w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,520,1583222400"; d="scan'208";a="262400302" Received: from carusoal-mobl.ger.corp.intel.com (HELO localhost) ([10.252.48.130]) by orsmga007.jf.intel.com with ESMTP; 16 Jun 2020 18:05:48 -0700 Date: Wed, 17 Jun 2020 04:05:46 +0300 From: Jarkko Sakkinen To: amirmizi6@gmail.com Cc: Eyal.Cohen@nuvoton.com, oshrialkoby85@gmail.com, alexander.steffen@infineon.com, robh+dt@kernel.org, peterhuewe@gmx.de, christophe-h.richard@st.com, jgg@ziepe.ca, arnd@arndb.de, gregkh@linuxfoundation.org, 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, Benoit Houyere Subject: Re: [PATCH v10 2/8] tpm: tpm_tis: Fix expected bit handling and send all bytes in one shot without last byte in exception Message-ID: <20200617010546.GB5100@linux.intel.com> References: <20200604134713.157951-1-amirmizi6@gmail.com> <20200604134713.157951-3-amirmizi6@gmail.com> <20200617010050.GA5100@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617010050.GA5100@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 17, 2020 at 04:01:12AM +0300, Jarkko Sakkinen wrote: > On Thu, Jun 04, 2020 at 04:47:07PM +0300, amirmizi6@gmail.com wrote: > > From: Amir Mizinski > > > > Detected the following incorrect implementation of the send command: > > polling on the TPM_STS.stsValid field followed by checking the > > TPM_STS.expect field only once. Since TPM_STS.stsValid represents the > > TPM_STS.expect validity, both fields should be polled at the same time. > > > > This fix modifies the signature of wait_for_tpm_stat(), adding an > > additional "mask_result" parameter to its call. wait_for_tpm_stat() is now > > polling the TPM_STS with a mask and waits for the value in mask_result. > > The fix adds the ability to check if certain TPM_STS bits have been > > cleared. > > > > This change is also aligned to verifying the CRC on I2C TPM. The CRC > > verification should be done after the TPM_STS.expect field is cleared > > (TPM received all expected command bytes and set the calculated CRC value > > in the register). > > > > In addition, the send command was changed to comply with > > TCG_DesignPrinciples_TPM2p0Driver_vp24_pubrev.pdf as follows: > > - send all command bytes in one loop > > - remove special handling of the last byte > > > > Suggested-by: Benoit Houyere > > Signed-off-by: Amir Mizinski > > Just wondering how did you come up with that name since you are not > masking anything with 'mask_result'? Maybe just rename it as 'stat'? That would make the whole thing a lot less confusing looking I think. /Jarkko