Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp305277imm; Tue, 16 Oct 2018 23:52:03 -0700 (PDT) X-Google-Smtp-Source: ACcGV63TFXMTxYPYrvnoug2S8rxjP8KXmXrT7gDgONfCOAeyMhkfyTc2rrQFdMCoSb3hcq6LFSNI X-Received: by 2002:a62:b209:: with SMTP id x9-v6mr25917231pfe.148.1539759123804; Tue, 16 Oct 2018 23:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539759123; cv=none; d=google.com; s=arc-20160816; b=AV/bFmWxPkAnmKJbCO5Zia/zAqyL7OgWbZlfOOtw169X0sfXDPCdEQcV0S7KkQd7Gu 4qW0t5d2/wM4wYdLaVY2eP3M0zIFU6cHSIheOElvNVOpDk0hB/SDiUIqeoeKeBY24c7a 1aKS0wNoEoRuLqNeHY/Lxmlp+1CTWBkbJbv0Cx7i1nHgHGOoEd3E3hnaku3s8eoOBtTH JJRoUodhrx5wgh6Fy3WbzaLqQAZEq8b5THOLRjZr44+TW4fsqMd4XXI1oHHSYOx7v2ft 3MKfVlIfOSUcOZ5LnBJFbN0IlQLxNl/k6XikIsgF1dvcwsQhiJOJDLYMQPirg9lPg1pg WtXw== 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=nha6Ib1txYF/L27Msme9WfkA4/LDtVfeKWl14vEs7Mc=; b=ig9IuUo+8ullyNeSJpkt62YeK1jNW9QX8zxMCMkkSx/wlkvpy0U988wXAKgqCduOdy 2GspSzjiTmnFeQC2ii3BcnVWdkn4Naxb0V8q4jvQ2s56Nomoa2BYlvCScadARaA6Bj1i OXkHsiudcayAegf+FkwYEdHem5xk6DPWWgEybGZsiTwlW4hunf+b/Rol2CKSJ5IidHoc T9i02m/VnJiqGULBvA6ORtMG9amFQ71X95PHbUhcHbfM2Yqdtrfm04xDXYWuC8PS+2qa tZR8kHm3Lwq7q26D1rszLIzbK5bGk6EljYdGPBZTp33+E4zePA4masVU1U0jktQBcCKa 1ClA== 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 t71-v6si16506682pgd.431.2018.10.16.23.51.48; Tue, 16 Oct 2018 23:52:03 -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 S1727871AbeJQOpT (ORCPT + 99 others); Wed, 17 Oct 2018 10:45:19 -0400 Received: from mga11.intel.com ([192.55.52.93]:48122 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727570AbeJQOpS (ORCPT ); Wed, 17 Oct 2018 10:45:18 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2018 23:51:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,391,1534834800"; d="scan'208";a="79371356" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by fmsmga008.fm.intel.com with ESMTP; 16 Oct 2018 23:51:05 -0700 From: Tomas Winkler To: Jarkko Sakkinen , Jason Gunthorpe Cc: Nayna Jain , Alexander Usyskin , Tadeusz Struk , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Tomas Winkler Subject: [PATCH v6 19/20] tpm1: reimplement tpm1_continue_selftest() using tpm_buf Date: Wed, 17 Oct 2018 09:46:12 +0300 Message-Id: <20181017064613.19746-20-tomas.winkler@intel.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20181017064613.19746-1-tomas.winkler@intel.com> References: <20181017064613.19746-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. Cc: Nayna Jain Signed-off-by: Tomas Winkler Reviewed-by: Jarkko Sakkinen Tested-by: Jarkko Sakkinen --- V3: New in the series. V4: Resend. V5: Fix &buf.data -> buf.data in tpm1_continue_selftest() V6: Rebase. 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 bf2ef1eeda50..e0778d19da98 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 d418a27a75e0..6b04648f8184 100644 --- a/drivers/char/tpm/tpm1-cmd.c +++ b/drivers/char/tpm/tpm1-cmd.c @@ -602,15 +602,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 @@ -618,12 +611,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