From patchwork Sun Nov 18 12:47:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 10687843 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 9EE7C13BB for ; Sun, 18 Nov 2018 12:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E77A29DB6 for ; Sun, 18 Nov 2018 12:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8300E29DB8; Sun, 18 Nov 2018 12:49:31 +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 E44FD29DB0 for ; Sun, 18 Nov 2018 12:49:30 +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=SOOggoajDqSrgABFQ2hqcWYD/1zdMW8ziZdplL7NtwA=; b=fVQ7vfav/dkCdx ye3BYQqBTUMDHBLN80j1kY52Y+uypWYzo1AFPE1RNysvWiBAJOQdVNqJnm20u3JzKN7aH/1cMAbJU JU9vtWwDCX9jdQIYToKgdPZHAeOKy/wTLKkqGPojC1RLLkgRluCGUn63IXxmreKRhN28XQd/2nvOj p47tI7DJzvOtC2SxcozX+d1bzXKfgf+zrGMVlWMPs5OjXoGeOVg+ZlW3Fp8VL8VFxclH66YxApqNU zDyzxaHubOqSjXZtv+P/Qm7mI8/FsJ2er8PiqiixCw5YNg7+5XR6W2/X+YFv5febmz9L41lGyecBI 7efssjIz+fEE90N6GNRw==; 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 1gOMVz-0001nZ-Po; Sun, 18 Nov 2018 12:49:27 +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 1gOMVv-0001fr-Ch for linux-arm-kernel@bombadil.infradead.org; Sun, 18 Nov 2018 12:49:23 +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=TRvUGvGrL75TScV6x64m+TKOU/es0R10t/xxHAb5/jE=; b=h1AVQGYORgt9zKiPvN55tQ2XLS KvzJ9COgLZcq21ramegpft4i8RyFFUD1gEyG8aH/W4WBD2QH/v1IqupwUC1hE1A2GOkKg4obteN7n FfqpTrpxjGA/78T/RmCiIEwyByTeg4JPg0Tkw/7shpAsR53J/zitod79bAN8f9UTJVyZV+sgMb/b5 ukcDjZ0zY1MasYSQouIVXUvueuTzlrJ/JBxRAixS0K1xJXu/61UHKQfyJNqznpcZndmbrXkfx0DZx VlhuaJ9PK3GbpoItc0g592LclXBpvXqth9cec4jckOZhI00JaO8+GqfmpW+kZuQsvvxA88jcPU+Ku wnCtU/Ow==; Received: from mga05.intel.com ([192.55.52.43]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gOMVr-0007vi-Hu for linux-arm-kernel@lists.infradead.org; Sun, 18 Nov 2018 12:49:20 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Nov 2018 04:48:03 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,248,1539673200"; d="scan'208";a="280962954" Received: from tmuluk-mobl4.ger.corp.intel.com (HELO localhost) ([10.249.254.142]) by fmsmga005.fm.intel.com with ESMTP; 18 Nov 2018 04:47:58 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Subject: [PATCH v9 00/17] Removed nested TPM operations Date: Sun, 18 Nov 2018 14:47:33 +0200 Message-Id: <20181118124753.18613-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-20181118_074919_739521_59C1949E X-CRM114-Status: GOOD ( 12.24 ) 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. v9: * Fixed again tpm_try_get_ops(). * Added missing reviewed-by's. v8: * Re-add the check for ret < 0 after calling tpm_try_transmit() that was dropped by mistake while moving code. * Fix error fallback for tpm_try_get_ops() when tpm_chip_start() fails. v7: * Reorganize series so that more trivial and self-contained changes are in the head. 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: print tpm2_commit_space() error inside tpm2_commit_space() tpm: declare struct tpm_header tpm: access command header through struct in tpm_try_transmit() tpm: encapsulate tpm_dev_transmit() tpm: call tpm2_flush_space() on error in tpm_try_transmit() tpm: clean up tpm_try_transmit() error handling flow tpm: move tpm_validate_commmand() to tpm2-space.c 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 | 109 ++++++++++++ drivers/char/tpm/tpm-dev-common.c | 45 ++++- drivers/char/tpm/tpm-interface.c | 264 ++++++------------------------ 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, 410 insertions(+), 422 deletions(-) Tested-by: Stefan Berger