From patchwork Tue Nov 13 12:25:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 10680501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E1E4F1709 for ; Tue, 13 Nov 2018 12:27:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE8AE29FE8 for ; Tue, 13 Nov 2018 12:27:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C26652A4A9; Tue, 13 Nov 2018 12:27:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 73F2B29FE8 for ; Tue, 13 Nov 2018 12:27:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=hk3TF140gGaD4ku/4yGA7eVpjrSGoF1617xz5ZlMpKE=; b=KWwnw6b/Dbod0l BAxbuEQ7890pV+9h1SvUDO4NN+J8l1ve4Yot09c2qaUGOH34Y41q+WHIhQ3EPyWLogbPQtr0S9VLo QE3utj3slbhAXQZJCY4oqYpV+jGoITXX6YthrGVMRRyYW03F7/bw8AZ0uaAOf/0eLWkzMBk9M5n+r azJWRKX6+tj8PF2jtqHIWV0B9tbgYYa9jjtbsHCYs4PJGr+B1dx2s0Nr6gRsMuCqKXkVPiic8xwK6 yYONZMTAOsP2yT///3aFWOMLpz+YlZQNtgq8+WTF18+fVNLEx2D4Ku6x6sJN5+C3U3j+4En8ctl/J gkDGa5hOISFi3szVAXQQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXnA-0000RT-RK; Tue, 13 Nov 2018 12:27:40 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXn9-0000RL-5t for linux-arm-kernel@bombadil.infradead.org; Tue, 13 Nov 2018 12:27:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=G3GWSVNn+KvJTTIQL480AM2v3PvFEjux5FJUaLEvFVI=; b=WJcGC/AhG/cD2SlS6WA/j/wStJ q3PDOu/WtQNGFH7b8af9sWyM/Km1hc+57oFcqfxcNYsocD1H5Xs5I9PEW0hyjxa9ZGnFps7JPqBbZ T2yl2qkFhr65Wg+GIgfEMZRtKfj9PP2Rr7t31SgTsla5YTrPIE9p1KFqnfMzbAbmN8SW4cOKT+NeH EYs3A+B65jo+EhdzSt/88kEf0YDC4MW+W23a9sQM1qMQpXjlWbYXmVEB5OymS/AoUvBWL2kWO5pXQ dZr1lopMMclGSCqq3Pk0diAzl3kFz2S75fdgYvYAXH4GIpl0QXae9SiITCh0nnGMPTqzzdi8kq3LN EzowoCDA==; Received: from mga03.intel.com ([134.134.136.65]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXn5-0004QY-Q9 for linux-arm-kernel@lists.infradead.org; Tue, 13 Nov 2018 12:27:36 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Nov 2018 04:26:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,499,1534834800"; d="scan'208";a="108176345" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.77]) by orsmga002.jf.intel.com with ESMTP; 13 Nov 2018 04:26:14 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Subject: [PATCH v6 00/17] Removed nested TPM operations Date: Tue, 13 Nov 2018 14:25:49 +0200 Message-Id: <20181113122609.21643-1-jarkko.sakkinen@linux.intel.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_072735_983184_71A3B6EC X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Berger , Nayna Jain , open list , Tadeusz Struk , James Bottomley , Jason Gunthorpe , linux-security-module@vger.kernel.org, Jarkko Sakkinen , Tomas Winkler , "moderated list:ARM/Microchip AT91 SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP [was Detach TPM space code out of the tpm_transmit() flow but the scope expanded a bit.] Make the changes necessary to detach TPM space code and TPM activation code out of the tpm_transmit() flow because of both of these can cause nested tpm_transmit() calls. The nesteds calls make the whole flow hard to maintain, and thus, it is better to just fix things now before this turns into a bigger mess. v6: * When tpm_validate_commmand() was moved to tpm2-space.c, the struct for the TPM header was incorrectly declared as struct tpm_input_header. * Fix return value in tpm_validate_command(). v5: * Add the missing rev's from Stefan Berger. v4: * Return 0 from pcrs_show() when tpm1_pcr_read() fails. * Fix error handling flow in tpm_try_transmit(). * Replace struct tpm_input_header and struct tpm_output_header with struct tpm_header. v3: * Encapsulate power gating code to tpm_chip_start() and tpm_chip_stop(). * Move TPM power gating code and locking to tpm_try_get_ops() and tpm_put_ops(). * Call power gating code directly in tpm_chip_register() and tpm2_del_space(). v2: * Print tpm2_commit_space() error inside tpm2_commit_space() * Error code was not printed when recv() callback failed. It is fixed in this version. * Added a patch that removes @space from tpm_transmit(). * Fixed a regression in earlier series. Forgot to amend the change from the staging area that renames NESTED to UNLOCKED in tpm2-space.c. Jarkko Sakkinen (17): tpm: use tpm_buf in tpm_transmit_cmd() as the IO parameter tpm: fix invalid return value in pubek_show() tpm: return 0 from pcrs_show() when tpm1_pcr_read() fails tpm: call tpm2_flush_space() on error in tpm_try_transmit() tpm: print tpm2_commit_space() error inside tpm2_commit_space() tpm: clean up tpm_try_transmit() error handling flow tpm: declare struct tpm_header tpm: access command header through struct in tpm_try_transmit() tpm: move tpm_validate_commmand() to tpm2-space.c tpm: encapsulate tpm_dev_transmit() tpm: move TPM space code out of tpm_transmit() tpm: remove @space from tpm_transmit() tpm: use tpm_try_get_ops() in tpm-sysfs.c. tpm: remove TPM_TRANSMIT_UNLOCKED flag tpm: introduce tpm_chip_start() and tpm_chip_stop() tpm: take TPM chip power gating out of tpm_transmit() tpm: remove @flags from tpm_transmit() drivers/char/tpm/tpm-chip.c | 105 +++++++++++- drivers/char/tpm/tpm-dev-common.c | 45 ++++- drivers/char/tpm/tpm-interface.c | 267 ++++++------------------------ drivers/char/tpm/tpm-sysfs.c | 138 +++++++++------ drivers/char/tpm/tpm.h | 64 +++---- drivers/char/tpm/tpm1-cmd.c | 28 +--- drivers/char/tpm/tpm2-cmd.c | 72 +++----- drivers/char/tpm/tpm2-space.c | 93 ++++++++--- drivers/char/tpm/tpm_i2c_atmel.c | 5 +- drivers/char/tpm/tpm_vtpm_proxy.c | 12 +- drivers/char/tpm/xen-tpmfront.c | 2 +- 11 files changed, 406 insertions(+), 425 deletions(-)