Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4148557imm; Thu, 17 May 2018 23:33:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpiM2l/dZGCdrKC6lGg4h1kl5usDgacyS0mMeUgIo7mOWGIw8bjAefGisERg+9nPC/znhzz X-Received: by 2002:a62:3cd1:: with SMTP id b78-v6mr8047628pfk.44.1526625228019; Thu, 17 May 2018 23:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526625227; cv=none; d=google.com; s=arc-20160816; b=FNPwX+HCNsVT5Cl+1xEOK/pMBpzq63r2lFnMbVWskXYPHe/9oFBponKZ7ZCGju4+qh HfJD9tEb/drkXS0Cf8n0GnjUJKTZuTp/X8/3KwCzXoypPPnq6qKVcM8KlGsQmC1hlePk NR0UC8Vl7hbB6DV/tpLDNMRAQ76cOultvdBs/L6FCxWwycyk6iHiaC0oAQbgoY9hFntt TlMGIkDpi4tBY0LMEnZD3OKaE/q+kUBVBOIXUxSD0YUi8tUEN44yf3+21DUd7OfOEVce au8Up133he30oDTbAoCFI8sP+TnQre1xukKBkPYhFpJoGAI2penNTD31J+vDbXXrDGA/ Ln7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:cc:to:subject:arc-authentication-results; bh=0ujDC0A1Kn7B76Csz3P/VGizk3aE13ZHHdT7HmraHlY=; b=nqZjAW1aXyHpn1NSJYR+K143Sss6OPPcwUOuhN8VZxYkTP65FnVzjLTUqXYhxe7I4C TPrAZzmXE3s7F2HcJ67QS8k4krIgQVSuAB4qqAEcM91RJR56KtTuf2XNYa6rFMFGad7d kfna8mtvg+jt4DYmJB7QW8/w/CwRJClCZLT2rxAIeWKvkWaU1uMPCSrVDOIuESDTlZ8u AEcgRq7bJDIombzahL0MxencbwGFIBYQn11VF6L0uQup0jmzNjWxG10gaEf31MA+gD+j 0Tv+QrYtanxyGZNdSgq+TtwKBQ7Xh1pSdmVfgPKP8sfTO5nqVwLwUr/4ZU75NTIBFIr6 TWuQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r63-v6si7002949pfj.331.2018.05.17.23.33.33; Thu, 17 May 2018 23:33:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751672AbeERGdH (ORCPT + 99 others); Fri, 18 May 2018 02:33:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60512 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbeERGdF (ORCPT ); Fri, 18 May 2018 02:33:05 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4I6TghJ067518 for ; Fri, 18 May 2018 02:33:05 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j1qhvcvvq-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 May 2018 02:33:04 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 May 2018 00:33:03 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 18 May 2018 00:33:01 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4I6X0jd11141532 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 May 2018 23:33:00 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 22FF16E03D; Fri, 18 May 2018 00:33:00 -0600 (MDT) Received: from [9.79.218.60] (unknown [9.79.218.60]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 7D3C66E035; Fri, 18 May 2018 00:32:56 -0600 (MDT) Subject: Re: [PATCH v4 2/4] tpm: migrate tpm2_probe() to use struct tpm_buf To: Jarkko Sakkinen , linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list References: <20180326121406.14548-1-jarkko.sakkinen@linux.intel.com> <20180326121406.14548-3-jarkko.sakkinen@linux.intel.com> From: Nayna Jain Date: Fri, 18 May 2018 12:01:07 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20180326121406.14548-3-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18051806-0024-0000-0000-0000186F066F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009044; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01033963; UDB=6.00528730; IPR=6.00813092; MB=3.00021176; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-18 06:33:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051806-0025-0000-0000-000050098BE4 Message-Id: <8c7f20fd-4b4f-0f25-35a4-eb1a615f1615@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-18_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=9 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805180072 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/26/2018 05:44 PM, Jarkko Sakkinen wrote: > In order to make struct tpm_buf the first class object for constructing TPM > commands, migrate tpm2_probe() to use it. > > Signed-off-by: Jarkko Sakkinen > Acked-by: Jay Freyensee Reviewed-by: Nayna Jain Tested-by: Nayna Jain Thanks & Regards,     - Nayna > --- > drivers/char/tpm/tpm2-cmd.c | 37 +++++++++++++++++++++---------------- > 1 file changed, 21 insertions(+), 16 deletions(-) > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > index 7665661d9230..7bffd0fd1dca 100644 > --- a/drivers/char/tpm/tpm2-cmd.c > +++ b/drivers/char/tpm/tpm2-cmd.c > @@ -844,30 +844,35 @@ static int tpm2_do_selftest(struct tpm_chip *chip) > > /** > * tpm2_probe() - probe TPM 2.0 > - * @chip: TPM chip to use > + * @chip: a TPM chip to probe > * > - * Return: < 0 error and 0 on success. > + * Return: 0 on success, > + * -errno otherwise > * > - * Send idempotent TPM 2.0 command and see whether TPM 2.0 chip replied based on > - * the reply tag. > + * Send an idempotent TPM 2.0 command and see whether there is TPM2 chip in the > + * other end based on the response tag. The flag TPM_CHIP_FLAG_TPM2 is set if > + * this is the case. > */ > int tpm2_probe(struct tpm_chip *chip) > { > - struct tpm2_cmd cmd; > + struct tpm_output_header *out; > + struct tpm_buf buf; > int rc; > > - cmd.header.in = tpm2_get_tpm_pt_header; > - cmd.params.get_tpm_pt_in.cap_id = cpu_to_be32(TPM2_CAP_TPM_PROPERTIES); > - cmd.params.get_tpm_pt_in.property_id = cpu_to_be32(0x100); > - cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); > - > - rc = tpm_transmit_cmd(chip, NULL, &cmd, sizeof(cmd), 0, 0, NULL); > - if (rc < 0) > + rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); > + if (rc) > return rc; > - > - if (be16_to_cpu(cmd.header.out.tag) == TPM2_ST_NO_SESSIONS) > - chip->flags |= TPM_CHIP_FLAG_TPM2; > - > + tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES); > + tpm_buf_append_u32(&buf, TPM_PT_TOTAL_COMMANDS); > + tpm_buf_append_u32(&buf, 1); > + rc = tpm_transmit_cmd(chip, NULL, buf.data, PAGE_SIZE, 0, 0, NULL); > + /* We ignore TPM return codes on purpose. */ > + if (rc >= 0) { > + out = (struct tpm_output_header *)buf.data; > + if (be16_to_cpu(out->tag) == TPM2_ST_NO_SESSIONS) > + chip->flags |= TPM_CHIP_FLAG_TPM2; > + } > + tpm_buf_destroy(&buf); > return 0; > } > EXPORT_SYMBOL_GPL(tpm2_probe);