From patchwork Fri Dec 22 13:56:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Steffen X-Patchwork-Id: 10130535 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DBA546038F for ; Fri, 22 Dec 2017 13:56:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC1C829FAE for ; Fri, 22 Dec 2017 13:56:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF3A529FB5; Fri, 22 Dec 2017 13:56:39 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBE6B29FAE for ; Fri, 22 Dec 2017 13:56:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751893AbdLVN4i (ORCPT ); Fri, 22 Dec 2017 08:56:38 -0500 Received: from smtp11.infineon.com ([217.10.52.105]:47182 "EHLO smtp11.infineon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751770AbdLVN4i (ORCPT ); Fri, 22 Dec 2017 08:56:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=infineon.com; i=@infineon.com; q=dns/txt; s=IFXMAIL; t=1513950999; x=1545486999; h=from:to:cc:subject:date:message-id:mime-version; bh=enboFdzHIsKSnlhqKYl+YGl1R9ldMlWeDXkHClQXWTo=; b=ohZP+cwkPM6QNtib/A5/71DHReG5eAeu8as3LrVlxes1tmLfEc56ztau z0Dgi+Y8hyZkB05VN3KEW57U9fsxPSfTA2acwwkk2cUIM3FPm7lW1Ga4o 0foRF3nKJWKSDGTh9oG1SescNO5n7O8q/Yayhy+nadUCY7Y37FiuyB3nH M=; X-SBRS: None Received: from unknown (HELO mucxv002.muc.infineon.com) ([172.23.11.17]) by smtp11.infineon.com with ESMTP/TLS/AES256-GCM-SHA384; 22 Dec 2017 14:56:38 +0100 Received: from MUCSE708.infineon.com (mucse708.infineon.com [172.23.7.82]) by mucxv002.muc.infineon.com (Postfix) with ESMTPS; Fri, 22 Dec 2017 14:56:36 +0100 (CET) Received: from ABGN5CG4522MQD.eu.infineon.com (172.23.8.247) by MUCSE708.infineon.com (172.23.7.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.669.32; Fri, 22 Dec 2017 14:56:36 +0100 From: Alexander Steffen To: , , , CC: Alexander Steffen Subject: [PATCH] tpm2-cmd: try full selftest once if continue selftest failed Date: Fri, 22 Dec 2017 14:56:10 +0100 Message-ID: <20171222135610.7056-1-Alexander.Steffen@infineon.com> X-Mailer: git-send-email 2.11.1.windows.1 MIME-Version: 1.0 X-Originating-IP: [172.23.8.247] X-ClientProxiedBy: MUCSE707.infineon.com (172.23.7.81) To MUCSE708.infineon.com (172.23.7.82) Sender: linux-integrity-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the usual approach of triggering only the missing selftests failed, give the TPM another chance by requesting all selftests once. With the current implementation, this will only help for TPMs that then choose to run the selftests synchronously and return the selftest result. There is no retry loop that again polls a TPM returning TPM_RC_TESTING in this case. Signed-off-by: Alexander Steffen --- Patch depends on https://patchwork.kernel.org/patch/10105483/ drivers/char/tpm/tpm2-cmd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index c17e753..b5c34d8 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -871,6 +871,14 @@ static int tpm2_do_selftest(struct tpm_chip *chip) tpm_msleep(delay_msec); } + if (rc != TPM2_RC_SUCCESS) { + cmd.header.in = tpm2_selftest_header; + cmd.params.selftest_in.full_test = 1; + + rc = tpm_transmit_cmd(chip, NULL, &cmd, TPM2_SELF_TEST_IN_SIZE, + 0, 0, "full selftest"); + } + return rc; }