Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932949AbcKVLDw (ORCPT ); Tue, 22 Nov 2016 06:03:52 -0500 Received: from mga06.intel.com ([134.134.136.31]:54375 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbcKVLDv (ORCPT ); Tue, 22 Nov 2016 06:03:51 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,680,1473145200"; d="scan'208";a="34267686" Date: Tue, 22 Nov 2016 13:03:48 +0200 From: Jarkko Sakkinen To: Nayna Cc: Peter Huewe , "moderated list:TPM DEVICE DRIVER" , open list Subject: Re: [tpmdd-devel] [PATCH RFC 2/2] tpm: refactor tpm2_get_tpm_pt to tpm2_getcap_cmd Message-ID: <20161122110348.2yicgx7nygiql55p@intel.com> References: <1476008057-2395-1-git-send-email-jarkko.sakkinen@linux.intel.com> <1476008057-2395-3-git-send-email-jarkko.sakkinen@linux.intel.com> <58254759.80406@linux.vnet.ibm.com> <20161112000242.63hgv5ujmkr7hy6a@intel.com> <582D998C.40605@linux.vnet.ibm.com> <20161117174241.wvyd7g5lj4ibfnry@intel.com> <582EF011.1050007@linux.vnet.ibm.com> <20161118161224.7sq4dbcnyzumbvds@intel.com> <58340B05.4060702@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <58340B05.4060702@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.6.2-neo (2016-08-21) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3772 Lines: 85 On Tue, Nov 22, 2016 at 02:38:21PM +0530, Nayna wrote: > > > On 11/18/2016 09:43 PM, Jarkko Sakkinen wrote: > > On Fri, Nov 18, 2016 at 05:42:01PM +0530, Nayna wrote: > > > > > > > > > On 11/17/2016 11:12 PM, Jarkko Sakkinen wrote: > > > > On Thu, Nov 17, 2016 at 05:20:36PM +0530, Nayna wrote: > > > > > > > > > I tested this for capability TPM2_CAP_PCRS. It seems TPM2_CAP_PCRS > > > > > capability always returns full PCR allocation, and more_data as 0, So, I > > > > > think the idea of looping over based on more_data may not work for this > > > > > capability. > > > > > > > > You can always request one value at a time until there's no more. > > > > > > > > If you request N values, depending on the hardware, the hardware returns > > > > to you anything from 1 to N values. If you implement a function that > > > > requests N values in the command, you *must* handle the case where > > > > moreData is 1 even if the hardware you are testing that never happens. > > > > > > > > That's the reason why I would start with a function that you request one > > > > property of one capability and optimize it in future if it doesn't scale > > > > for some workload. > > > > > > > > Do you have a workload where it doesn't scale? > > > > > > Thanks Jarkko for explaining in detail. > > > > > > If I understood correctly, the idea is to request for one property at a > > > time, and if we need multiple properties, then to request for each of them > > > in a loop. In case of TPM2_CAP_PCRS, property is always zero. This is how I > > > am calling getcap_cmd for TPM2_CAP_PCRS. > > > > > > tpm2_getcap_cmd(chip, TPM2_CAP_PCRS, 0, &cap_data, "get active pcr banks"); > > > > > > Output : > > > > > > [ 17.081665] tpm: cap id to receive value is 2 > > > [ 17.081666] tpm: TPM2_CAP_COMMANDS: more data 1 > > > [ 17.081667] tpm: 2 > > > [ 17.081668] tpm: tpm2_get_active_banks -------> cap is TPM2_CAP_PCRS > > > [ 17.171665] tpm: cap id to receive value is 5 > > > [ 17.171666] tpm: TPM2_CAP_PCRS: more data 0 ---> more data is zero. > > > [ 17.171666] tpm: TPM2_CAP_PCRS: more data 0 > > > [ 17.171667] tpm: count pcr banks is 2 ------> count of active pcr banks > > > information returned > > > > > > more_data is always zero here, so am not sure how to handle more_data in > > > this case ? > > > Since property_id is always zero, I am not able to request for one property > > > at a time. > > > and response_buffer returns the details for both active banks. > > > > > > This is the expected behavior defined in TCG 2.0 Part 3 Commands > > > Specification (Section 30.2.1): > > > > > > "TPM_CAP_PCRS – Returns the current allocation of PCR in a > > > TPML_PCR_SELECTION. The property parameter shall be zero. The TPM will > > > always respond to this command with the full PCR allocation and moreData > > > will be NO." > > > > > > Please let me know, if I am missing something. > > > > Thanks for pointing that. I think you got it right and I had some wrong > > assumptions about 'moreData'. > > > > Here's what I propose. Do a non-generic function just for getting CAP_PCRS. > > You could call it tpm2_get_pcr_allocation() as you don't want or rather > > need to handle all the bells and whistles in that TPM command. > > > > It makes a lot more sense now than having one-size-for-all function. > > Thanks Jarkko, Yeah, Sure, I will write it as different non-generic call. > Otherwise, the function works good. > Also, I am thinking now I can write "multi-bank support for extend" on top > of master branch itself. Any issues with that ? I'm not sure what exactly I should or should not have an issue with. I can check the patch but won't apply or test it before it is used for something if that is what you are asking. /Jarkko