Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2751716ybt; Tue, 16 Jun 2020 14:16:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0c2NzvxT6b+GZMJjEotjz4Fck2Nl6SU51hlBocnlRXw78Lw9uvK1TsgnqBIVnmnhBOsX2 X-Received: by 2002:a17:906:138b:: with SMTP id f11mr4479369ejc.288.1592342200123; Tue, 16 Jun 2020 14:16:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592342200; cv=none; d=google.com; s=arc-20160816; b=oq5/q0mWVN3hKWmUPZ92/2cwd4xb8O+mcrMFiGyX8LxBarQgkSLA1lyWzxAEocjAyP lzNWcFEw023v3h/vIm+wZBZhm7uoxDZWCDVjXRBJJrETmsgjLwJQTXzyGMwctRyKAj2w GXl7jjHRXjUJFDXrQfVQLPQDS60BTgAz5DnN1pn0Z86NTQz6cWp9Y+pGO1rspWaFUDoj sbVty+mQhVvBB6957X+K8xTcbxD2mbHMt/KJAqeSWuqZVdB0q5FKd90OCDBYB3qkDUck kjgaSelKd4Heb+yfDou8K/o2iMKByQDJo4wuLdDEO3OGkrBxpkIC+Nr7dEzrtb7ttz6E NWQw== 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=hb7TUJ8+OFMtF+GomMgTMSCaUPpYbVkqk3ZYYJC3xnc=; b=Yp62x+hx3rfbD+NGWTJwfJ8iYvuJ2eFJAyM1kJiBZCmVsKJz1tsIjgTNsNCDZRXvRE 7MLhjH2mjRbQ73uQ7BdDugXzZNGzwrFIJzPPIl49cANo6lP6RC3fmETbsBMS3VYk2iKc 7D00dEnlbbJojT61e9ZOt9l/Or9ek6HsOky+LE6jG36qp/pFoBK0j2yYEdtxLNq/xZQw dcAXBQCuQOMhZDlvim+ozL3rv0Vj/8nGjnLmCLRBxsw+ttji670fecaQSvqjZUQl5/M4 Ipl7EGi2HQnuW2XiBnKVnoEisO+1Y+8rL0Vb+3KjuhwERlfXNY8GXGv7qxt+TNhIA+dM 4YJQ== 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 v25si10532072edq.70.2020.06.16.14.16.17; Tue, 16 Jun 2020 14:16:40 -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 S1728175AbgFPVIQ (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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