Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp5043587imm; Fri, 18 May 2018 15:35:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrPb6TFKpPDozSLkKhfukGuhma0QAWyhhQOW3AeJ4CTEkS4KgL6zGzUuQGIxqSL44f0sJvi X-Received: by 2002:a62:f24a:: with SMTP id y10-v6mr11144225pfl.75.1526682941880; Fri, 18 May 2018 15:35:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526682941; cv=none; d=google.com; s=arc-20160816; b=Yd10LF3xctGPNRMdiIbpvJxtk5RW7i/ArVyPLfW94CRRscSt2OwC6kGln3YRncF2dT ZSHlE+hCXiOQFUJ4s35k/UTHhnf/p13pkBBMVivt4UOU3Gw+dynMrCnrH7qx/yjfSLEW kM0pl2BpWFKZd9Ac4Cg3Py7i18AR6XAzTYplM1uWqRWkDJQI61Ntcog+ek47rfbQ0PH/ KZ6+kdVoAd6Qd3yVh1SYkHx7UopmwbBxOFUIjQEXJ78Bfh/NbWXhi35cwV6gJdxc8RXV wV4E2DwzP/479nIAuHfBfI/eUYRxwq2z/vdIUZzDyswHHK/d459ynIGvWlFrYwROxpNh Ggmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=6jazSS4rNP+hzrk/7LWYiPYcCjNi8u1TLEI5rF1MPwc=; b=S6kpojS5pLIMFxoxpJUAdm3/aD12HrfwNg+z86QtPu5/Tvw/vsWXVXsx6h7CahFLUm BRh4DUc2o764o/bcAqH3GlCh3tRPnAYdEvOSO1BKsVmmtYeLErXpQeqfnY3ZsJRN5rmJ Ka+a/zElyveuXaWYRvywUwT1PS0ntz4aknwZfKe+drNpGUPAhvXHf3NEp8G7YW5q4Fpm lT+A9ImNB7G9Ieax3e1es1MKe0RL2RsdK8MZtNaJZZsjUmR8Ry7k8cY6uaIyJmbSWIAX FLSgbiCAe3/RypNj+qxQ4mvnxdto2nw6QXjYp1zuVZ8vyMgBOsw/+n43pkuVee7cQ8/K 8h2Q== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si8196935plt.357.2018.05.18.15.35.27; Fri, 18 May 2018 15:35:41 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752274AbeERWfQ (ORCPT + 99 others); Fri, 18 May 2018 18:35:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49560 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751747AbeERWfN (ORCPT ); Fri, 18 May 2018 18:35:13 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9A17AD44C5; Fri, 18 May 2018 22:35:13 +0000 (UTC) Received: from localhost (ovpn-116-99.phx2.redhat.com [10.3.116.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62DC11001642; Fri, 18 May 2018 22:35:13 +0000 (UTC) Date: Fri, 18 May 2018 15:35:13 -0700 From: Jerry Snitselaar To: Jarkko Sakkinen Cc: linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Peter Huewe , Jason Gunthorpe , Arnd Bergmann , Greg Kroah-Hartman , open list Subject: Re: [PATCH v4 2/4] tpm: migrate tpm2_probe() to use struct tpm_buf Message-ID: <20180518223513.qh6wcckjp4sl7xwx@cantor> Reply-To: Jerry Snitselaar Mail-Followup-To: Jarkko Sakkinen , linux-integrity@vger.kernel.org, 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20180326121406.14548-3-jarkko.sakkinen@linux.intel.com> User-Agent: NeoMutt/20180512 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 18 May 2018 22:35:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon Mar 26 18, 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: Jerry Snitselaar >--- > 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); >-- >2.15.1 >