Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752539AbdFTV0I (ORCPT ); Tue, 20 Jun 2017 17:26:08 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42625 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752188AbdFTV0F (ORCPT ); Tue, 20 Jun 2017 17:26:05 -0400 Subject: Re: [PATCH] tpm: consolidate the TPM startup code To: Jarkko Sakkinen , Jason Gunthorpe References: <20170620181334.28363-1-jarkko.sakkinen@linux.intel.com> <20170620193152.GA3368@obsidianresearch.com> <20170620205529.ku3nueglj3mqkd3s@linux.intel.com> Cc: tpmdd-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org, Peter Huewe , Marcel Selhorst , open list From: Stefan Berger Date: Tue, 20 Jun 2017 17:25:57 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170620205529.ku3nueglj3mqkd3s@linux.intel.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 17062021-0048-0000-0000-000001ACFBAC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007263; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000214; SDB=6.00877612; UDB=6.00437203; IPR=6.00657751; BA=6.00005432; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015903; XFM=3.00000015; UTC=2017-06-20 21:26:03 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17062021-0049-0000-0000-00004197A585 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-06-20_10:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706200369 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1873 Lines: 53 On 06/20/2017 04:55 PM, Jarkko Sakkinen wrote: > On Tue, Jun 20, 2017 at 01:31:52PM -0600, Jason Gunthorpe wrote: >> On Tue, Jun 20, 2017 at 08:13:34PM +0200, Jarkko Sakkinen wrote: >>> Consolidated all the "manual" TPM startup code to a single function >>> in order to make code flows a bit cleaner and migrate to tpm_buf. >>> >>> Signed-off-by: Jarkko Sakkinen >>> drivers/char/tpm/tpm-interface.c | 67 +++++++++++++++++++++++++--------------- >>> drivers/char/tpm/tpm.h | 6 +--- >>> drivers/char/tpm/tpm2-cmd.c | 32 +------------------ >>> 3 files changed, 44 insertions(+), 61 deletions(-) >> Makes sense to me >> >>> diff --git a/drivers/char/tpm/tpm-interface.c b/drivers/char/tpm/tpm-interface.c >>> index d2b4df6d9894..fbef47d8bd06 100644 >>> +++ b/drivers/char/tpm/tpm-interface.c >>> @@ -540,6 +540,47 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, struct tpm_space *space, >>> } >>> EXPORT_SYMBOL_GPL(tpm_transmit_cmd); >>> >>> +#define TPM_ORD_STARTUP 153 >>> +#define TPM_ST_CLEAR 1 >> We should really have a tpm1.h and tpm2.h that has all these various >> constants and things instead of open coding them randomly all over.. >> >> Jason > I agree. > > Is this patch acceptable to be applied? > > Stefan, can you peer test this with a TPM emulator? For convenient testing > I created 'readpubek' branch that includes also my readpubek bug fixes. > Seeing that the module loads and you can output pubek sysfs attribute is > sufficient for seeing that all the three patches work. Doesn't work. The startup_type is be16, but you are appending a u32 now for both TPM1.2 and TPM2. + tpm_buf_append_u32(&buf, TPM_ST_CLEAR); -struct tpm_startup_in { - __be16 startup_type; -} __packed; - struct tpm2_startup_in can probably be removed as well? Stefan > > /Jarkko >