From patchwork Tue Nov 6 17:36:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Sakkinen X-Patchwork-Id: 10671159 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 296AA14BD for ; Tue, 6 Nov 2018 17:49:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B2542AA73 for ; Tue, 6 Nov 2018 17:49:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D4AF2ADDA; Tue, 6 Nov 2018 17:49:08 +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 7AB8F2ADC7 for ; Tue, 6 Nov 2018 17:49:07 +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=6yeqm3rfVmjXgTgz1jl9qJGxb3TP3k+8CMZLdaaSBJo=; b=u0aHuUL63dPdGY ysM4hTGKI7Xp+Pv35XquxIBBu2DHtgbQ4VGlFMT1d5UkPwUoRfKmByIRbbTul9EnPv8+P2MSwxYnD dtx/zjxAXoRrGeRnCgy8wCpiDb5CLkFforlkPGdqU9QULN64EV0pWU8KPqx4vw1BFlyoRz+jaWdCZ ODBBVxSUOsFdugUNt7hTeDElyx5LROVTCy3wqjjKTmsXymRWdyk/8c2TBlroYOKCsT8/2REk8CBxN FxSBPg4n459v6WV554M6wnL3eNgH5bAx3sAWTQDxT2leKvlbNYHzRC+zM7cy/3wJyjzagUf6layNt aRi7lrxKUhGrBECqjRmQ==; 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 1gK5TH-00010I-HW; Tue, 06 Nov 2018 17:48:59 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gK5TG-0000vs-Gl for linux-arm-kernel@bombadil.infradead.org; Tue, 06 Nov 2018 17:48:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=hEZh6I0B8PhG+ZHGblPIsCnjyYWn5+9G/uIIRb3p01g=; b=IMKG7TmMoUSe+8w4f9hb+1WEh9 yA1oYyYp4W5IVuKn0NS9kyJsiZw4ZvOMdM/Gs+lOFnMF/YW6VMDWKnKSj8mOAFS1t4xFkoNn2MDAP dog3rz+8bfoisHMYsxlm1tHX2gUVy3Jped3DEKqX9Fdn+NWBeZn40gRnivuKCIQ33XCHQJHlftxpq zu4uNxlbvmUDds7wC/uk3XLui6Pe8PFKkEoWrC7PhHpia0OhA7Ywv2K6kh6bT/fj22TLGDwPdAY/X ilprH6mCBL3rBQ0pYO6Z+jtV4FGM5KOUXTVikmUKmapekjPuEgWI5f5sLExfkXKFpKIxcmJH0v4FK 9AHG1T7A==; Received: from mga09.intel.com ([134.134.136.24]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gK5Ir-0005vi-RQ for linux-arm-kernel@lists.infradead.org; Tue, 06 Nov 2018 17:38:15 +0000 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 09:37:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,472,1534834800"; d="scan'208";a="247464728" Received: from wenjiewa-mobl2.ccr.corp.intel.com (HELO localhost) ([10.249.254.60]) by orsmga004.jf.intel.com with ESMTP; 06 Nov 2018 09:36:56 -0800 From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Subject: [PATCH v4 00/17] Remove nested TPM operations Date: Tue, 6 Nov 2018 19:36:32 +0200 Message-Id: <20181106173652.31020-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-20181106_173814_172944_A5C88AE3 X-CRM114-Status: GOOD ( 14.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. The commits are available in a branch called 'nested' in git://git.infradead.org/users/jjs/linux-tpmdd.git 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(-)