Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp707198imm; Fri, 21 Sep 2018 07:03:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV61u9pb6l6j7QStlvnEXY+pxybx7hvSwv6/gagbxEs5Zd+mDGbn3ZcHUNGkrnPgJqETeMl02 X-Received: by 2002:a17:902:b58f:: with SMTP id a15-v6mr2074518pls.23.1537538612288; Fri, 21 Sep 2018 07:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537538612; cv=none; d=google.com; s=arc-20160816; b=QhBlk4b8aiIr/Qev5wbhIxcEwVqc3RcPIjX7cNfw+inFY9WUa3p6qSv4aAxJFYpcOt xyL+cjskyXJQJjIHbafYJWi5FMlUMzwEgjPYaUQTaOncR6nlXAYrZ00c5bCzQhOVxHir eY9yxGPdx8aTzgCaq8S4ekT4cpKuyUc+j8qtjWK6ihnqN8xBaMq4urtCKQr3r7u4XCvK Z7tWbJO4EXdc65r2zDuzDc1JL02aToHJhB0ODlEq9Gdfpkeh1hpiH24i+AWLq/O3F9aO zJTlxL6Oaw06SFqRqVRVGf1KUwXQGRaC3OAg1MZeD7RNwBHjObxIZPiI2tlVrOBb6pXA 1cxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=IoFcK3E9z4qrPYvvepsqVpyg1KY1QJUR5JjnKZcJFwk=; b=m06gfHbm5h8mXAUHQwCosvRXypYAmMtOjeE26lXdKTbEQJSn5KXBFrYKKeaDU30FgL g/GmaZRgrlFiOcmT3OeiOjCi7fIcyxxvAa/Xxg49F76NgOaEASz0Nyi5BUxc3v1nMZ83 Pu0C6pPuYhlvm/afXJKkRrtP9Jc1V4RSOWqse8CpR4rjx9Od88pNtZdWXQt4HW/zrImq YhQSdLkqR6eDDXr1JGWKy1oZs5W2E3b5ErAIKASuVAgH9mHSHJO4L/GlzZCMjnQuUMyS g46wnHDJogiz3NWX1fHjrPZKpXI1hmFeL+V6+HZACT8/ar9Mk/pi5gLgsqXJF8VBP9cM lLJA== 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 c4-v6si27918798pfa.285.2018.09.21.07.03.13; Fri, 21 Sep 2018 07:03:32 -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 S2390542AbeIUTvk (ORCPT + 99 others); Fri, 21 Sep 2018 15:51:40 -0400 Received: from mga18.intel.com ([134.134.136.126]:4682 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389586AbeIUTvj (ORCPT ); Fri, 21 Sep 2018 15:51:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Sep 2018 07:02:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,285,1534834800"; d="scan'208";a="71839245" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga007.fm.intel.com with ESMTP; 21 Sep 2018 07:02:36 -0700 From: Tomas Winkler To: Jarkko Sakkinen , Jason Gunthorpe Cc: Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH v4 20/21] tpm1: reimplement tpm1_continue_selftest() using tpm_buf Date: Fri, 21 Sep 2018 16:58:19 +0300 Message-Id: <20180921135820.20549-21-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180921135820.20549-1-tomas.winkler@intel.com> References: <20180921135820.20549-1-tomas.winkler@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reimplement tpm1_continue_selftest() using tpm_buf structure. This is the last command using the old tpm_cmd_t structure and now the structure can be removed. Signed-off-by: Tomas Winkler Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen --- V3: New in the series. V4: Resend. drivers/char/tpm/tpm.h | 9 --------- drivers/char/tpm/tpm1-cmd.c | 21 ++++++++++----------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index 2f06740f993d..7ada00f067f1 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h @@ -377,15 +377,6 @@ enum tpm_sub_capabilities { TPM_CAP_PROP_TIS_DURATION = 0x120, }; -typedef union { - struct tpm_input_header in; - struct tpm_output_header out; -} tpm_cmd_header; - -struct tpm_cmd_t { - tpm_cmd_header header; -} __packed; - /* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18 * bytes, but 128 is still a relatively large number of random bytes and diff --git a/drivers/char/tpm/tpm1-cmd.c b/drivers/char/tpm/tpm1-cmd.c index cde9a01ad31f..6d7d70b0d130 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -604,15 +604,8 @@ int tpm1_pcr_read(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) } #define TPM_ORD_CONTINUE_SELFTEST 83 -#define CONTINUE_SELFTEST_RESULT_SIZE 10 -static const struct tpm_input_header continue_selftest_header = { - .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), - .length = cpu_to_be32(10), - .ordinal = cpu_to_be32(TPM_ORD_CONTINUE_SELFTEST), -}; - /** - * tpm_continue_selftest -- run TPM's selftest + * tpm_continue_selftest() - run TPM's selftest * @chip: TPM chip to use * * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing @@ -620,12 +613,18 @@ static const struct tpm_input_header continue_selftest_header = { */ static int tpm1_continue_selftest(struct tpm_chip *chip) { + struct tpm_buf buf; int rc; - struct tpm_cmd_t cmd; - cmd.header.in = continue_selftest_header; - rc = tpm_transmit_cmd(chip, NULL, &cmd, CONTINUE_SELFTEST_RESULT_SIZE, + rc = tpm_buf_init(&buf, TPM_TAG_RQU_COMMAND, TPM_ORD_CONTINUE_SELFTEST); + if (rc) + return rc; + + rc = tpm_transmit_cmd(chip, NULL, &buf.data, PAGE_SIZE, 0, 0, "continue selftest"); + + tpm_buf_destroy(&buf); + return rc; } -- 2.14.4