From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D4D8C433DF for ; Tue, 16 Jun 2020 21:08:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E40B0208B8 for ; Tue, 16 Jun 2020 21:08:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726296AbgFPVIQ (ORCPT ); Tue, 16 Jun 2020 17:08:16 -0400 Received: from mga06.intel.com ([134.134.136.31]:34637 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgFPVIQ (ORCPT ); Tue, 16 Jun 2020 17:08:16 -0400 IronPort-SDR: 38s3mKvjfJBBHQKGEYM82c9NFZTBPdCz5KW8QfHcv1oMpTZ3DO6vFCce2aRZxSMxpaF+0dabvd Ts95Vjfr91aw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2020 14:08:14 -0700 IronPort-SDR: uYSGeta2jHg/O7VYnU4drv0O2NvAE+qnGReSnhh1BY/tenQtJycf5uXNGK4K2kpbvHHxpEHuKC ++DbHNucE5yw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,519,1583222400"; d="scan'208";a="261535509" Received: from gosinald-mobl2.ger.corp.intel.com (HELO localhost) ([10.249.36.106]) by fmsmga007.fm.intel.com with ESMTP; 16 Jun 2020 14:08:09 -0700 Date: Wed, 17 Jun 2020 00:08:08 +0300 From: Jarkko Sakkinen To: David Gibson Cc: Michael Ellerman , Peter Huewe , Jason Gunthorpe , Stefan Berger , Nayna Jain , Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tpm: ibmvtpm: Wait for ready buffer before probing for TPM2 attributes Message-ID: <20200616210808.GJ20943@linux.intel.com> References: <20200605063719.456277-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200605063719.456277-1-david@gibson.dropbear.id.au> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Fri, Jun 05, 2020 at 04:37:19PM +1000, David Gibson wrote: > The tpm2_get_cc_attrs_tbl() call will result in TPM commands being issued, > which will need the use of the internal command/response buffer. But, > we're issuing this *before* we've waited to make sure that buffer is > allocated. > > This can result in intermittent failures to probe if the hypervisor / TPM > implementation doesn't respond quickly enough. I find it fails almost > every time with an 8 vcpu guest under KVM with software emulated TPM. > > Fixes: 18b3670d79ae9 "tpm: ibmvtpm: Add support for TPM2" Should be Fixes: 18b3670d79ae ("tpm: ibmvtpm: Add support for TPM2") Also briefly state what the commit does, not just the problem description. The code change looks legit. Please send v2 with these changes. > Signed-off-by: David Gibson > --- > drivers/char/tpm/tpm_ibmvtpm.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c > index 09fe45246b8c..994385bf37c0 100644 > --- a/drivers/char/tpm/tpm_ibmvtpm.c > +++ b/drivers/char/tpm/tpm_ibmvtpm.c > @@ -683,13 +683,6 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, > if (rc) > goto init_irq_cleanup; > > - if (!strcmp(id->compat, "IBM,vtpm20")) { > - chip->flags |= TPM_CHIP_FLAG_TPM2; > - rc = tpm2_get_cc_attrs_tbl(chip); > - if (rc) > - goto init_irq_cleanup; > - } > - > if (!wait_event_timeout(ibmvtpm->crq_queue.wq, > ibmvtpm->rtce_buf != NULL, > HZ)) { > @@ -697,6 +690,13 @@ static int tpm_ibmvtpm_probe(struct vio_dev *vio_dev, > goto init_irq_cleanup; > } > > + if (!strcmp(id->compat, "IBM,vtpm20")) { > + chip->flags |= TPM_CHIP_FLAG_TPM2; > + rc = tpm2_get_cc_attrs_tbl(chip); > + if (rc) > + goto init_irq_cleanup; > + } > + > return tpm_chip_register(chip); > init_irq_cleanup: > do { > -- > 2.26.2 > /Jarkko