Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp346282imm; Fri, 31 Aug 2018 01:58:51 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaxbfSIFP4v1EjL+VymxWcuqDSMNKnsvD3s3WcVzST+OSU/CY63gTQg+CsnfTG93/09uL8V X-Received: by 2002:a63:2365:: with SMTP id u37-v6mr11280827pgm.122.1535705931079; Fri, 31 Aug 2018 01:58:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535705931; cv=none; d=google.com; s=arc-20160816; b=T22vb9TmQFvqwtcgm5AAofrEKWSqzzFT5zEB9GTm3wUw+qVSUPECPJxzDq4b/zAavI bMlbtlhpr6azO066xSmzEJMMA0aLavv/JsN9CKKCE9Qb4KPwI1uBdX+kPOTBQVXMoZdW 5ln3SPTu6djLjsF6uVtZCEJIwbXRGaZ6kGVu87ZO35Q/QbWEa/p2sR+w0joawbIRi1oq 4t6dcDyhKRG3qVrXh/3YMhdJhsHG7WTwFG0ZUd9tQ9gOKvOJ79vZSLliER7t+YISILbc OgakoHSd4bcHCFT0QRqZsSlOdJfiWjf05U3ywdHfDOpGFySj5zc1A9g2VWTFxAoYGp8b Sxig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=/DAH5po+QX+7G2hC3J9Lz+tf0R94g2INopQjfVPAJ50=; b=o5TBHYDkjI11L+5HmM+4oauGjATZiClANyfYxbNWB6rtnYyEt08Mx0LOgeSLLsjaYT wBIy8b29cdmTkW7jnQCypa7C/VtPzz5tUUoX4KFY5aP5uTG7RUqVpiXMcNGzmMo73YIC bFdOQs2dzzXtMH1sRQ/7Oc0o1kqd5jfCAHZL/2yLrGN5m3E4oqRax6x/GAvuiIS7XHvD YGaGl7ixRAJ2SS0dbO2mbF4pjW371xQIsGCFIW1nUpBYZtDuOfjcD57jR5JJ0XRBS+T9 Xb3wt1g0z7EBswhKUdJOy7kAXVI+31EqD3iIVNxVlRe6S3s2JEwMTVRiV/Ygcw1XLx/Q CmxQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9-v6si9067605pgi.691.2018.08.31.01.58.36; Fri, 31 Aug 2018 01:58:51 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbeHaND4 (ORCPT + 99 others); Fri, 31 Aug 2018 09:03:56 -0400 Received: from mga07.intel.com ([134.134.136.100]:65053 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727207AbeHaNDz (ORCPT ); Fri, 31 Aug 2018 09:03:55 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Aug 2018 01:57:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,309,1531810800"; d="scan'208";a="70549473" Received: from ssirohi-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.48.112]) by orsmga006.jf.intel.com with ESMTP; 31 Aug 2018 01:57:12 -0700 Date: Fri, 31 Aug 2018 11:57:11 +0300 From: Jarkko Sakkinen To: Tadeusz Struk Cc: flihp@twobit.us, jgg@ziepe.ca, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 0/2] tpm: add support for nonblocking operation Message-ID: <20180831085711.GC12908@linux.intel.com> References: <153419236870.8189.15489652816512817246.stgit@tstruk-mobl1.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <153419236870.8189.15489652816512817246.stgit@tstruk-mobl1.jf.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Are you planning to send v6 soon fixing the minor things in 1/2 (typo + change for the commit message)? /Jarkko On Mon, Aug 13, 2018 at 01:32:48PM -0700, Tadeusz Struk wrote: > The TCG SAPI specification [1] defines a set of functions, which allow > applications to use the TPM device in either blocking or non-blocking fashion. > Each command defined by the specification has a corresponding > Tss2_Sys__Prepare() and Tss2_Sys__Complete() call, which > together with Tss2_Sys_ExecuteAsync() is designed to allow asynchronous > mode of operation. Currently the TPM driver supports only blocking calls, > which doesn't allow asynchronous IO operations. > This patch changes it and adds support for nonblocking write and a new poll > function to enable applications, which want to take advantage of this feature. > The new functionality can be tested using standard TPM tools implemented > in [2], together with modified TCTI from [3], and an example application > by Philip Tricca [4]. Here is a short description from Philip: > > "The example application `glib-tss2-event` uses a glib main event loop > to create an RSA 2048 primary key in the TPM2 NULL hierarchy while > using a glib timer event to time the operation. A GSource object is > used to generate an event when the FD underlying the tss2 function > call has data ready. While the application waits for an event indicating > that the CreatePrimary operation is complete, it counts timer events > that occur every 100ms. Once the CreatePrimary operation completes the > number of timer events that occurred is used to make a rough calculation > of the elapsed time. This value is then printed to the console. > This takes ~300 lines of C code and requires no management or > synchronization of threads. The glib GMainContext is "just a poll() > loop" according to the glib documentation here: > > https://developer.gnome.org/programming-guidelines/stable/main-contexts.html.en > > and so supporting 'poll' is the easiest way to integrate with glib / > gtk+. This is true of any other event system that relies on 'poll' > instead of worker threads." > > [1] https://trustedcomputinggroup.org/wp-content/uploads/TSS_SAPI_Version-1.1_Revision-22_review_030918.pdf > [2] https://github.com/tpm2-software/tpm2-tools > [3] https://github.com/tstruk/tpm2-tss/tree/async > [4] https://github.com/flihp/glib-tss2-async-example > > --- > Changes in v5: > - Changed the workqueue allocation time back from the first user interface > open to module init. > > Changes in v4: > - Changed the way buffer_mutex is handled in nonblocking mode so that > it is not held when write() returns to user space. > > Changes in v3: > - Fixed problem reported by 0-dey kbuild test robot around __exitcall. > It complained because there is a module_exit() in another file already. > - Added info on example application from Philip > > Changes in v2: > - Split the change into two separate patches. First patch adds a pointer > to the space to the struct file_priv to have access to it from the async job. > This is to avoid memory allocations on every write call. Now everything > what's needed is in the file_priv struct. > - Renamed the 'work' member of the timer to avoid confusion. > Now there are 'timeout_work' and 'async_work'. > - Removed the global wait queue and moved it to file_priv. > - Only creating the work queue when the first file is opened. > > Tadeusz Struk (2): > tpm: add ptr to the tpm_space struct to file_priv > tpm: add support for nonblocking operation > > drivers/char/tpm/tpm-dev-common.c | 150 +++++++++++++++++++++++++++---------- > drivers/char/tpm/tpm-dev.c | 22 +++-- > drivers/char/tpm/tpm-dev.h | 19 +++-- > drivers/char/tpm/tpm-interface.c | 1 > drivers/char/tpm/tpm.h | 1 > drivers/char/tpm/tpmrm-dev.c | 31 ++++---- > 6 files changed, 152 insertions(+), 72 deletions(-) > > -- > TS