Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp4146888imm; Thu, 17 May 2018 23:31:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsL1L7ZaMljHK82SlmQIgIqBGhoOV1SIzThg15pQbzRtapEcLQeT3l42led3IAWzE+uJZf X-Received: by 2002:a62:2f44:: with SMTP id v65-v6mr8077717pfv.83.1526625091843; Thu, 17 May 2018 23:31:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526625091; cv=none; d=google.com; s=arc-20160816; b=L/W29o+N62AzHc92MNTbmNgoD5B6hp17+vNAwnF3KzQbavePVrT10u2QDszUfghIYM 24exfCEVjeAwlojtUXXYYzg4x860BTGlTsDncdYUurHMhM5mddm7fsBM7Fuu/3gKtopm h/Mtqweg/UIXBWS+bx0reFvBdS1WGtFL85WszdNV1yUldUwou5xsAnTvo/K/QcIcxirf zg5RjfOzw5z0FpbXEbKX87XLQRpKpoFj0iRJvM016+qGFIZVjrT/0SReipuIT1MDy7ku WxisNuJlrSX6Xj9bcKlecE8RjY4wboYtuUdOSJaIJ5stW8M3fmsMyzG4E5xml+/PTq9J dwmA== 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=4Zxtni2/aC0w2aV1DzUpV4XYz+3vAB4+5bE79cmDD48=; b=X7MwvVW78QZNq099RExyaaIVvxhSZ3EdLlS19M04iiF47o/RZetWzxsrvKwFok4HKZ YwU1BrHUD8Yuf/wxb0fI3Rh/ttByyKXHfDMidDos9M/k8+gMgVKywEmp84C5QsbcrY79 ZTtikAjv5PXRBhQOJo1ATXqNQw0F5kahrkgS7kHq5ZNa5h5e3e/ZWn5CGoRm6EEKexEa U/iFBOq9lf/HDyEhLHBZZKG77NeS3AodaFW6R5LO3TdJcI8x7E2Pod+emwYg2CrbItXa 3I2m2dygTQy/rAC82oH3FMnJ3AojMAAV36r5fPCuGTVCuJQZ/WtnUl8oVUNv4fFwvdOa VZrg== 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 x10-v6si5358228pgr.45.2018.05.17.23.31.17; Thu, 17 May 2018 23:31:31 -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 S1752042AbeERGbE (ORCPT + 99 others); Fri, 18 May 2018 02:31:04 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50706 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751815AbeERGbC (ORCPT ); Fri, 18 May 2018 02:31:02 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4I6TYwL027530 for ; Fri, 18 May 2018 02:31:01 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j1pwb5809-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 18 May 2018 02:31:00 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 18 May 2018 00:31:00 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 18 May 2018 00:30:56 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4I6UteD9634202; Thu, 17 May 2018 23:30:55 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBBA26E038; Fri, 18 May 2018 00:30:55 -0600 (MDT) Received: from [9.79.218.60] (unknown [9.79.218.60]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 322B56E035; Fri, 18 May 2018 00:30:51 -0600 (MDT) Subject: Re: [PATCH v4 1/4] tpm: migrate tpm2_shutdown() 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-2-jarkko.sakkinen@linux.intel.com> From: Nayna Jain Date: Fri, 18 May 2018 11:59:03 +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-2-jarkko.sakkinen@linux.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18051806-8235-0000-0000-00000D85CB05 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.01033962; UDB=6.00528730; IPR=6.00813091; MB=3.00021176; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-18 06:30:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051806-8236-0000-0000-0000410472CA Message-Id: 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_shutdown() to use it. In addition, removed the klog > entry when tpm_transmit_cmd() fails because tpm_tansmit_cmd() already > prints an error message. > > Signed-off-by: Jarkko Sakkinen Reviewed-by: Nayna Jain Tested-by: Nayna Jain > --- > drivers/char/tpm/tpm2-cmd.c | 44 ++++++++++++-------------------------------- > 1 file changed, 12 insertions(+), 32 deletions(-) > > diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c > index 96c77c8e7f40..7665661d9230 100644 > --- a/drivers/char/tpm/tpm2-cmd.c > +++ b/drivers/char/tpm/tpm2-cmd.c > @@ -27,10 +27,6 @@ enum tpm2_session_attributes { > TPM2_SA_CONTINUE_SESSION = BIT(0), > }; > > -struct tpm2_startup_in { > - __be16 startup_type; > -} __packed; > - > struct tpm2_get_tpm_pt_in { > __be32 cap_id; > __be32 property_id; > @@ -55,7 +51,6 @@ struct tpm2_get_random_out { > } __packed; > > union tpm2_cmd_params { > - struct tpm2_startup_in startup_in; > 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; > @@ -412,11 +407,8 @@ void tpm2_flush_context_cmd(struct tpm_chip *chip, u32 handle, > int rc; > > rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_FLUSH_CONTEXT); > - if (rc) { > - dev_warn(&chip->dev, "0x%08x was not flushed, out of memory\n", > - handle); > + if (rc) > return; > - } > > tpm_buf_append_u32(&buf, handle); > > @@ -762,40 +754,28 @@ ssize_t tpm2_get_tpm_pt(struct tpm_chip *chip, u32 property_id, u32 *value, > } > EXPORT_SYMBOL_GPL(tpm2_get_tpm_pt); > > -#define TPM2_SHUTDOWN_IN_SIZE \ > - (sizeof(struct tpm_input_header) + \ > - sizeof(struct tpm2_startup_in)) > - > -static const struct tpm_input_header tpm2_shutdown_header = { > - .tag = cpu_to_be16(TPM2_ST_NO_SESSIONS), > - .length = cpu_to_be32(TPM2_SHUTDOWN_IN_SIZE), > - .ordinal = cpu_to_be32(TPM2_CC_SHUTDOWN) > -}; > - > /** > * tpm2_shutdown() - send shutdown command to the TPM chip > * > + * In places where shutdown command is sent there's no much we can do except > + * print the error code on a system failure. > + * > * @chip: TPM chip to use. > * @shutdown_type: shutdown type. The value is either > * TPM_SU_CLEAR or TPM_SU_STATE. > */ > void tpm2_shutdown(struct tpm_chip *chip, u16 shutdown_type) > { > - struct tpm2_cmd cmd; > + struct tpm_buf buf; > int rc; > > - cmd.header.in = tpm2_shutdown_header; > - cmd.params.startup_in.startup_type = cpu_to_be16(shutdown_type); > - > - rc = tpm_transmit_cmd(chip, NULL, &cmd, sizeof(cmd), 0, 0, > - "stopping the TPM"); > - > - /* In places where shutdown command is sent there's no much we can do > - * except print the error code on a system failure. > - */ > - if (rc < 0 && rc != -EPIPE) > - dev_warn(&chip->dev, "transmit returned %d while stopping the TPM", > - rc); > + rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_SHUTDOWN); > + if (rc) > + return; > + tpm_buf_append_u16(&buf, shutdown_type); > + tpm_transmit_cmd(chip, NULL, buf.data, PAGE_SIZE, 0, 0, > + "stopping the TPM"); > + tpm_buf_destroy(&buf); > } > > /*