From patchwork Thu Nov 8 14:15:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 10674307 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 31CC114D6 for ; Thu, 8 Nov 2018 14:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F4942C0FA for ; Thu, 8 Nov 2018 14:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 129632D697; Thu, 8 Nov 2018 14:17:17 +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 B8A1D2CEC2 for ; Thu, 8 Nov 2018 14:17:16 +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=mWSmE5rC73ybCcIXuDhW8fQfMwlqsJURrA5AkQui83Q=; b=UvD9AU9KPSbjim 9xPkc+cqrGN4kI04eiMXtzL2slB3R8LWvvt/3wUFJbSiGxOXlCr5gBHPWPEP3Eoi4bA9y5GGmBQIF PL1XOEI3rvhP1RGFSXAonaQEIK+umCoFOaY2iivo4WZVaCAVtHrmqgJW63GebXjAJMTKQM8d/v93E 76Nj7P+S5l2UM8ZJI62UBa/7YlP3+0Drm9JziuML6XI4vefE+cpahQt4pm+WFf3Il1+VVTcaANo5y khX9VVT1jWHQouiOX6u+bgI9h/5oBcK89mkHRJExyww4m398D2ZejhdX9K3G/1A0LhpJ2KZqFFDpe rf/qnSLmzaw797OV6uyQ==; 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 1gKl7N-0006bq-4Q; Thu, 08 Nov 2018 14:17:09 +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 1gKl7L-0006bJ-Ce for linux-arm-kernel@bombadil.infradead.org; Thu, 08 Nov 2018 14:17:07 +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=II22I5p3hmRbt3+r0SBbYaCc2VWYewSLJUKx8zpmeP8=; b=k25kwnu69+v0ZVwV5GZBgd0jP3 oKXV7HClsLToSng+V96NfxLO27tNwzzvAdwnXQ164JwoB0F7yxCOaEgMJQeQDqH5dzwYv7yO+IrG0 pcF78ra6k6moRlSLg1dPaVmHPS/pMKmJjL8+eb4mJejewy9KgmB+w1WDs83+G2aiNdqhysCO8p1iT i7jlKJxFM7Ft4f2VlpSBElzkP78zPteTpc3z51Ylo1wZPF3SwOz7kpM51B2/P5wdeWtHgfJ2IiIIT h5MXFOzXJcGaNfy0ENDxK5TBwvu80pfSw7aOzSjLEUgOFK6m1SKI7O/0Mc17rvNqA+JcCJZMSWcf3 qB+xIJ6g==; Received: from mga05.intel.com ([192.55.52.43]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gKl7I-0001zQ-FW for linux-arm-kernel@lists.infradead.org; Thu, 08 Nov 2018 14:17:05 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Nov 2018 06:15:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,478,1534834800"; d="scan'208";a="94663665" Received: from ibanaga-mobl1.ger.corp.intel.com (HELO localhost) ([10.249.254.75]) by FMSMGA003.fm.intel.com with ESMTP; 08 Nov 2018 06:15:44 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Subject: [PATCH v5 00/17] Remove nested TPM operations Date: Thu, 8 Nov 2018 16:15:21 +0200 Message-Id: <20181108141541.12832-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-20181108_091704_688196_59C503C4 X-CRM114-Status: GOOD ( 13.11 ) 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. The commits are available in a branch called 'nested' in git://git.infradead.org/users/jjs/linux-tpmdd.git 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(-)