Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4149131imm; Thu, 17 May 2018 23:34:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqjecKhIDr9U5qYgwa5IA2bhAJ2yATNSjyEitxCoOrMJfL0rvx+T50yNRJbG/5NrBHc43IW X-Received: by 2002:a65:65d5:: with SMTP id y21-v6mr6264310pgv.277.1526625276263; Thu, 17 May 2018 23:34:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526625276; cv=none; d=google.com; s=arc-20160816; b=MQaG9wSmJZE5gX/nK1CyDHOXKJusBgz3r6tN6zbqbnDoiBE2tONi5/3n9rWLHKe2H9 gJWU8x9h9Pr3U5KN9FlsLz67ycig0Yz0SVzUCAajEuZw5uSxF/HhFTuNwJBs1+YtMKKJ hlV2kTnMi6dR4As3+otFtabPYxhOGK8VljrdDT8CdzSiHWbK6aF5mA/qhBHGS7GoZnps yc/BuwgyErGVUEeHCVmnv9OR1fpIpemfto1V/XhrpZEeAKv7dWA7by2BYH/jN/EfY4YQ hsjDI5Eyq6nUMzHpUkOIJ0S8IH2C5ohh71y/KchmAdieRmsRXxNUmTqYY64LQiANr81h /rEA== 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=YGUDlSx4tGGWUgM01FrXNS0ixQ7lRf+nH3Csy/OFiqo=; b=va3PkmpnR4Cl9l2h9pzIPO+wYyKElHDGUZai6DZ9M+B3z2HaS4OXVwuVIhPISb5y9N Nhu8zIoZbpkhU8zhFTBhZyaly6ifvU1Yp21WgYLPKeuSkVoJ7Ds4FQTlbM8eJXRllge5 JXiRcMp72A4CRaVOGD5taK00Qe5s/SNMccGNigIMkLLMnpQR04N71NwNYW5a7qUw+2yH jTKnKtldnHrTZEdU2D5KMhxyJTl4j6qaVxlAtjstYm32hwI4MDlZdeB5nrrZ7h36r8ID aCEAZhXIvoTBLHe1tP/Fvs0eJdR7Mj2U0DV7eDH8PRyioC2jobAXWiBXVdLu8uLUPT/7 qo/Q== 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 j11-v6si5539562pgt.497.2018.05.17.23.34.22; Thu, 17 May 2018 23:34:36 -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 S1752075AbeERGdq (ORCPT + 99 others); Fri, 18 May 2018 02:33:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:59936 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751450AbeERGdo (ORCPT ); Fri, 18 May 2018 02:33:44 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4I6TaLZ002929 for ; Fri, 18 May 2018 02:33:44 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j1q505exw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 May 2018 02:33:43 -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:42 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 18 May 2018 00:33:39 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4I6Xcmt10682740; Thu, 17 May 2018 23:33:38 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D11676E038; Fri, 18 May 2018 00:33:38 -0600 (MDT) Received: from [9.79.218.60] (unknown [9.79.218.60]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 1E8E56E035; Fri, 18 May 2018 00:33:34 -0600 (MDT) Subject: Re: [PATCH v4 3/4] tpm: migrate tpm2_get_tpm_pt() 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-4-jarkko.sakkinen@linux.intel.com> From: Nayna Jain Date: Fri, 18 May 2018 12:01:46 +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-4-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-0000186F067C 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:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051806-0025-0000-0000-000050098C24 Message-Id: <95828353-43e1-0a02-ea54-544b709584b9@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_get_tpm_pt() to use it. > > Signed-off-by: Jarkko Sakkinen Reviewed-by: Nayna Jain Tested-by: Nayna Jain Thanks & Regards,    - Nayna > --- > drivers/char/tpm/tpm2-cmd.c | 63 +++++++++++++++++---------------------------- > 1 file changed, 23 insertions(+), 40 deletions(-) > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > index 7bffd0fd1dca..b3b52f9eb65f 100644 > --- a/drivers/char/tpm/tpm2-cmd.c > +++ b/drivers/char/tpm/tpm2-cmd.c > @@ -27,20 +27,6 @@ enum tpm2_session_attributes { > TPM2_SA_CONTINUE_SESSION = BIT(0), > }; > > -struct tpm2_get_tpm_pt_in { > - __be32 cap_id; > - __be32 property_id; > - __be32 property_cnt; > -} __packed; > - > -struct tpm2_get_tpm_pt_out { > - u8 more_data; > - __be32 subcap_id; > - __be32 property_cnt; > - __be32 property_id; > - __be32 value; > -} __packed; > - > struct tpm2_get_random_in { > __be16 size; > } __packed; > @@ -51,8 +37,6 @@ struct tpm2_get_random_out { > } __packed; > > union tpm2_cmd_params { > - struct tpm2_get_tpm_pt_in get_tpm_pt_in; > - struct tpm2_get_tpm_pt_out get_tpm_pt_out; > struct tpm2_get_random_in getrandom_in; > struct tpm2_get_random_out getrandom_out; > }; > @@ -379,19 +363,6 @@ int tpm2_get_random(struct tpm_chip *chip, u8 *out, size_t max) > return total ? total : -EIO; > } > > -#define TPM2_GET_TPM_PT_IN_SIZE \ > - (sizeof(struct tpm_input_header) + \ > - sizeof(struct tpm2_get_tpm_pt_in)) > - > -#define TPM2_GET_TPM_PT_OUT_BODY_SIZE \ > - sizeof(struct tpm2_get_tpm_pt_out) > - > -static const struct tpm_input_header tpm2_get_tpm_pt_header = { > - .tag = cpu_to_be16(TPM2_ST_NO_SESSIONS), > - .length = cpu_to_be32(TPM2_GET_TPM_PT_IN_SIZE), > - .ordinal = cpu_to_be32(TPM2_CC_GET_CAPABILITY) > -}; > - > /** > * tpm2_flush_context_cmd() - execute a TPM2_FlushContext command > * @chip: TPM chip to use > @@ -725,6 +696,14 @@ int tpm2_unseal_trusted(struct tpm_chip *chip, > return rc; > } > > +struct tpm2_get_cap_out { > + u8 more_data; > + __be32 subcap_id; > + __be32 property_cnt; > + __be32 property_id; > + __be32 value; > +} __packed; > + > /** > * tpm2_get_tpm_pt() - get value of a TPM_CAP_TPM_PROPERTIES type property > * @chip: TPM chip to use. > @@ -737,19 +716,23 @@ int tpm2_unseal_trusted(struct tpm_chip *chip, > ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, > const char *desc) > { > - struct tpm2_cmd cmd; > + struct tpm2_get_cap_out *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(property_id); > - cmd.params.get_tpm_pt_in.property_cnt = cpu_to_be32(1); > - > - rc = tpm_transmit_cmd(chip, NULL, &cmd, sizeof(cmd), > - TPM2_GET_TPM_PT_OUT_BODY_SIZE, 0, desc); > - if (!rc) > - *value = be32_to_cpu(cmd.params.get_tpm_pt_out.value); > - > + rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); > + if (rc) > + return rc; > + tpm_buf_append_u32(&buf, TPM2_CAP_TPM_PROPERTIES); > + tpm_buf_append_u32(&buf, property_id); > + tpm_buf_append_u32(&buf, 1); > + rc = tpm_transmit_cmd(chip, NULL, buf.data, PAGE_SIZE, 0, 0, NULL); > + if (!rc) { > + out = (struct tpm2_get_cap_out *) > + &buf.data[TPM_HEADER_SIZE]; > + *value = be32_to_cpu(out->value); > + } > + tpm_buf_destroy(&buf); > return rc; > } > EXPORT_SYMBOL_GPL(tpm2_get_tpm_pt);