Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp113875ybt; Thu, 25 Jun 2020 16:49:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydtSTC+LqmFI44tnSXwhSCTDBBo9gYrKpHrxft16UQPJjOENE78VDDG0IQIh6DotpbuMJv X-Received: by 2002:a17:906:b6cc:: with SMTP id ec12mr208623ejb.391.1593128946038; Thu, 25 Jun 2020 16:49:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593128946; cv=none; d=google.com; s=arc-20160816; b=RHmTK+49Ep6XINU8gCvm/Zc6IDugxPJnB0DQoNDnOWAqE+//K9bGr5LvXsKnGntZOY gMHTgJ7A8WbLoUAaemu4Coemgc58CBtQhW8JAQ/pfNMgoks9PzsVyhtYqH00QKt8O9MD eMuH277TguXm1i/qZBRbI6RNJfYpVFn92Nv8fq6JECK/wd2wykgDky8FwzIBNLGXT4E9 o464lX9oEaFS3P4RJWm4jrGlUwyqsrG8767eqKht+3Ay9RkBcp0JA4O0EkLIESX3/mT5 R3Povv5lZqdTlJb8IF1Vb5013sC7csI6sGVSLZ3orKmRwra+sBenUYR3Z5jJ3Aif15SZ JWUA== 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=PB90PrGnbNpjxjATX7vTAX0H1cbqi7pX8PlFiFdHIPw=; b=copsZy+IH0CepWYVzvDZ9oQhG2+GRZClUof2yCDoozQjDe/vRNBmPanyaK5TrJuzvw CCyhHVox19AnLP4v7bKWf2lcsOWgm/39Q26j7E/3JNQA4sJ/AiaR/LS8OYj9MESRaDU/ ZdXUMF/B9JfXLYHf5hN/TRRZQgww/q7D+a84hIdoyGKYIn/t6JYeNV8jfDxazYWrYTGp M8rzcYjhnlZuVpa4kzf4dn1FcKTs5AXL0EiGy+OrODJFvYYlOC4wR+OEnwlVI4tU5f3T d5PuK3MSiPU57xAyYcIa1KDpseXyhbrE3MO5MP4BTudcgBhXYseXB1TyvGdpBT0L8z9K 2UfA== 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 g1si9847623ejd.517.2020.06.25.16.48.43; Thu, 25 Jun 2020 16:49:06 -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 S2391321AbgFYWCY (ORCPT + 99 others); Thu, 25 Jun 2020 18:02:24 -0400 Received: from mga17.intel.com ([192.55.52.151]:28028 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390431AbgFYWCY (ORCPT ); Thu, 25 Jun 2020 18:02:24 -0400 IronPort-SDR: DmC4P91v2JiNRWw03I36NYigDecAwVU4dtnYh2nHSkqTmK5NQM2ttxJ3lYPjG/a2X4TBVKMd6y Xb4R4lFsqqiw== X-IronPort-AV: E=McAfee;i="6000,8403,9663"; a="125322478" X-IronPort-AV: E=Sophos;i="5.75,280,1589266800"; d="scan'208";a="125322478" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2020 15:02:23 -0700 IronPort-SDR: gDHQaT1VFcIUjjilKxCrtBQl2lM/KCJFtD9n7mv4x1PGWxE08O4Kz+dw5JyNozokOjcRB+CLDS vCcbmsbPhBYw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,280,1589266800"; d="scan'208";a="299070067" Received: from jproldan-mobl.ger.corp.intel.com (HELO localhost) ([10.252.49.123]) by orsmga007.jf.intel.com with ESMTP; 25 Jun 2020 15:02:13 -0700 Date: Fri, 26 Jun 2020 01:02:11 +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, Christophe Ricard Subject: Re: [PATCH v12 4/9] tpm: tpm_tis: Add verify_data_integrity handle to tpm_tis_phy_ops Message-ID: <20200625220211.GJ20341@linux.intel.com> References: <20200625144650.269719-1-amirmizi6@gmail.com> <20200625144650.269719-5-amirmizi6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200625144650.269719-5-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 25, 2020 at 05:46:44PM +0300, amirmizi6@gmail.com wrote: > From: Amir Mizinski > > When using I2C bus protocol, the TPM has the ability to report data > integrity on incoming or outgoing command parameter bytes. > According to the TCG specs, if this data validation functionality is > enabled via the TPM_DATA_CSUM_ENABLE register, the TPM will update the > TPM_DATA_CSUM register after reception of the last command byte and after > the last response byte has been read. > > Data integrity is checked if a "verify_data_integrity" handle is defined in > "tpm_tis_phy_ops". > > Co-developed-by: Christophe Ricard > Signed-off-by: Christophe Ricard > Signed-off-by: Amir Mizinski > --- > drivers/char/tpm/tpm_tis_core.c | 14 ++++++++++++++ > drivers/char/tpm/tpm_tis_core.h | 2 ++ > 2 files changed, 16 insertions(+) > > diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c > index e136467..347c020 100644 > --- a/drivers/char/tpm/tpm_tis_core.c > +++ b/drivers/char/tpm/tpm_tis_core.c > @@ -347,6 +347,13 @@ static int __tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count) > return size; > } > > + if (priv->phy_ops->verify_data_integrity) > + if (!priv->phy_ops->verify_data_integrity(priv, buf, > + size)) { > + size = -EIO; > + return size; > + } > + > return size; > } > > @@ -419,6 +426,13 @@ static int tpm_tis_send_data(struct tpm_chip *chip, const u8 *buf, size_t len) > return rc; > } > > + if (priv->phy_ops->verify_data_integrity) { > + if (!priv->phy_ops->verify_data_integrity(priv, buf, len)) { > + rc = -EIO; > + return rc; > + } > + } > + > return 0; > } > > diff --git a/drivers/char/tpm/tpm_tis_core.h b/drivers/char/tpm/tpm_tis_core.h > index 6cc6b76..cd97c01 100644 > --- a/drivers/char/tpm/tpm_tis_core.h > +++ b/drivers/char/tpm/tpm_tis_core.h > @@ -107,6 +107,8 @@ struct tpm_tis_phy_ops { > int (*read16)(struct tpm_tis_data *data, u32 addr, u16 *result); > int (*read32)(struct tpm_tis_data *data, u32 addr, u32 *result); > int (*write32)(struct tpm_tis_data *data, u32 addr, u32 src); > + bool (*verify_data_integrity)(struct tpm_tis_data *data, const u8 *buf, > + size_t len); > }; > > static inline int tpm_tis_read_bytes(struct tpm_tis_data *data, u32 addr, > -- > 2.7.4 > As I've said before, I'm not too eager to add a new callback and nothing in the commit message rationalizes adding one. /Jarkko