Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2225774ybg; Fri, 5 Jun 2020 08:36:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJjPZohmvQdV2ZBKBgXcwDQ9KU0W3a/kqQMzpUoqDT8Ff755zd8BImy+E5HaE/FaGRaDXA X-Received: by 2002:a50:c359:: with SMTP id q25mr10210915edb.123.1591371369441; Fri, 05 Jun 2020 08:36:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591371369; cv=none; d=google.com; s=arc-20160816; b=PrEq5wQACwtn8pYcIpM//rCZDMqQZ/FEb3e7VuQFyjgJclkOiEc9BijCrmmeicZnRy 3duuzC0QoVLgZ80U1CaQyjsFRJpfSJbhjSspu9GOm6FWjCLqQ5t1utko0n3coprm15n3 S+eUxWm3cwJCB0XFqZhOh7qOp5baLCEQ0+Y9kMb+MxjtZLC9mCI3OeM9xGaOxuS/iA9A N1NjX8bCLWs3Z7ygjjNVaw5mFF5Nl9Y/x/1CBRZtpnKwshLg9XiziihRAVOwpn7JJ+8b 7Lp1Adwo9fxO6Mi4TAqKnODYhem8nXNoToLdfJjfZ93IfAqnvH8RcZ6YzEIDKZQojrud 22ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=mC+o9oT4NdaKe2rETTLQwoBmM33UuadNANB0uXOv92o=; b=oA69HLlSYxp0OdhRyTwvqUgtS3rT/zV1r1CX8Qvp7iRzIVDOzcWtoN7z6XBjIv0OtI CFpVaDhV0rsXROnk9glV2fg1ADqk80CWkCI2UOJqbFp4eA373nbV+CXl3TewbKPlrIFC aRafmJ6K3Sz1PYQDRPno7LKLRtmXZCyLxMNimhzN4ctWwnmEbtHufd22VpT6/TnGCC/I eQWlEAdY1FVfp7ySx2Kk84sf/3egPBfH4Gn3klqhxx96EtCnURjLndncsv53qCG+gvKo ii4Bwn63oJ86unfudi3uEyw8bmWNsEIjLKor5aMi77G5GemLQvz/0d3l0z94jVdobtLx M4kg== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si3623842ejg.358.2020.06.05.08.35.45; Fri, 05 Jun 2020 08:36:09 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727797AbgFEPdq (ORCPT + 99 others); Fri, 5 Jun 2020 11:33:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:12148 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726539AbgFEPdq (ORCPT ); Fri, 5 Jun 2020 11:33:46 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 055FWedb096598; Fri, 5 Jun 2020 11:33:19 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 31fhr9xbry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2020 11:33:18 -0400 Received: from m0098419.ppops.net (m0098419.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 055FXDlc100023; Fri, 5 Jun 2020 11:33:16 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 31fhr9xbqr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2020 11:33:15 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 055FKqLA018391; Fri, 5 Jun 2020 15:33:14 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma03dal.us.ibm.com with ESMTP id 31bf4axv19-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 05 Jun 2020 15:33:14 +0000 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 055FXDOt55050728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 5 Jun 2020 15:33:13 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EE9AEB206C; Fri, 5 Jun 2020 15:33:12 +0000 (GMT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D6A27B206A; Fri, 5 Jun 2020 15:33:12 +0000 (GMT) Received: from sbct-3.pok.ibm.com (unknown [9.47.158.153]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Fri, 5 Jun 2020 15:33:12 +0000 (GMT) Subject: Re: [PATCH] tpm: ibmvtpm: Wait for ready buffer before probing for TPM2 attributes To: David Gibson , Michael Ellerman , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Nayna Jain Cc: Paul Mackerras , linuxppc-dev@lists.ozlabs.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200605063719.456277-1-david@gibson.dropbear.id.au> From: Stefan Berger Message-ID: Date: Fri, 5 Jun 2020 11:33:12 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200605063719.456277-1-david@gibson.dropbear.id.au> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-05_04:2020-06-04,2020-06-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 priorityscore=1501 mlxlogscore=999 mlxscore=0 suspectscore=0 lowpriorityscore=0 cotscore=-2147483648 impostorscore=0 spamscore=0 clxscore=1011 phishscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006050113 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/5/20 2:37 AM, 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. Uuuh. Thanks! > Fixes: 18b3670d79ae9 "tpm: ibmvtpm: Add support for TPM2" > Signed-off-by: David Gibson Reviewed-by: Stefan Berger > --- > 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 {