Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp107638ybt; Tue, 16 Jun 2020 18:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz/yql5HTppPtxLmvfsMVYs6fsQbedtU+bvzNCmCXhLgoeupncgfrJGdRIOofJK7iEAbBBd X-Received: by 2002:a17:906:ce2f:: with SMTP id sd15mr5090202ejb.445.1592355919510; Tue, 16 Jun 2020 18:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592355919; cv=none; d=google.com; s=arc-20160816; b=bzV8aA0cVShCYRfUYl1Kbq+FX4D/jJ7q1PWXTELEgh/MBVlnPIUp2WSXoMVi9Iu81m 320W3M2pqVibMYhZ49DWUaVsusUcb6ERy0CwLSFzk3V8wR+1yNwqc4zbzGCUHf3xQcnb O90+6Uudl7+br9aJO7O6n3ymgsJWUXI0KUi63/bD3ZfLhPYuy/crM30UaLl4iXI/GqvF mS2VWGPOnxg6hH2wRImHGU5evg0XfQeP2CB+l57ZVO1IywwaA/X4NYncdAcBj8VxupP3 vu1Q4gD8zghBUZzuAQ6FBI9ZAeOdzeVvW4YD9Cz5YkqwLiWmGpRP4A4uvaVsFr8CXJY6 Uc3Q== 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=VxwQTbrXZ2r2Tp2hdMU1bDlwxxJZUsrXokMDOUGTnTk=; b=GKysmgd6LQxVE7IqnkCzkTK0LZri3OtefvvTn1g4lta6uih/KPIj+WoxIKgpkuon3U QK1FeVfJxVZ0at/mS0u/4Rzb0NKvNs1luJOaaq+fDxYFy2IU0dIlhECywIxsLFLYFXzw KLCchvdsWp3t/fUH3MdpLfyUjicvYlmcEMgckqLK0YiQ9qLxo4e+MEEiumkCtxPZsEbT HvpIZ4KlXrSPpRFH4TR2wTPU6UrWTpOmHX6k0yy2ky9ux8fN3ZZmLcJ6dcrdqOQ1lp4P yJTHTsPbszlu/0BX1YBljFCe2kFP5fI80cHqfIu5KGVFZo398j9BEdp2F+w74u7lBeDw ukvw== 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 j28si11257103edy.293.2020.06.16.18.04.56; Tue, 16 Jun 2020 18:05:19 -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 S1726632AbgFQBBP (ORCPT + 99 others); Tue, 16 Jun 2020 21:01:15 -0400 Received: from mga17.intel.com ([192.55.52.151]:27658 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726600AbgFQBBO (ORCPT ); Tue, 16 Jun 2020 21:01:14 -0400 IronPort-SDR: 7zCaFnrtO1zmJR5K9faS7qk/pUE0gHExivuPc+SsW5fnE6L6BcHjzvIOSxPDZ/n8/iVt3tdwD2 ueJUAHK+7JLA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2020 18:01:12 -0700 IronPort-SDR: tYvItSxVa5vDgDLWIUJSj5xJUFsh7xyAL+jXQk9M76uVpbPTgE7boUdpPWPRIEj6Ks1Oo/JLiG HoAumagWExOA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,520,1583222400"; d="scan'208";a="291253132" Received: from carusoal-mobl.ger.corp.intel.com (HELO localhost) ([10.252.48.130]) by orsmga002.jf.intel.com with ESMTP; 16 Jun 2020 18:01:04 -0700 Date: Wed, 17 Jun 2020 04:01:03 +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: <20200617010050.GA5100@linux.intel.com> References: <20200604134713.157951-1-amirmizi6@gmail.com> <20200604134713.157951-3-amirmizi6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200604134713.157951-3-amirmizi6@gmail.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 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'? /Jarkko