From patchwork Sun Jul 10 11:47:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Condrea X-Patchwork-Id: 9222613 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 C87CB60572 for ; Sun, 10 Jul 2016 12:11:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9B9625404 for ; Sun, 10 Jul 2016 12:11:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE5322705B; Sun, 10 Jul 2016 12:11:06 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10B9925404 for ; Sun, 10 Jul 2016 12:11:06 +0000 (UTC) Received: from localhost ([::1]:54391 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDZh-0005ne-7L for patchwork-qemu-devel@patchwork.kernel.org; Sun, 10 Jul 2016 08:11:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDE8-0006Ol-3e for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bMDE2-0001o0-62 for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:47 -0400 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:35992) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bMDE1-0001ne-Vp for qemu-devel@nongnu.org; Sun, 10 Jul 2016 07:48:42 -0400 Received: by mail-wm0-x244.google.com with SMTP id x83so11999598wma.3 for ; Sun, 10 Jul 2016 04:48:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AOdXXuvx8NGe5EYrUvWo2LcOvu2+DHw11/m+AnzvhAY=; b=Hq5c/n1BqeLHM5MD5IQoHbH0aQItpfFRPOxX1A1pSSoQu0MGAZlXIPo3pdVHivgru1 fNlwIf0XQi+FH23IgyA0unWrNPmkVcACqeDbo65iHDvyTWVt6SgJbVQ+JEh6qvcKrsy8 2yccViBE6V4gpuQ3q20q2hjZS9nBoETaSF1BTJ4wqTt2RojqtQRJAJXjEaSeiSvu/d7f 8dtvBdNV5fMFKDQfc8aZI2HIfdEblJgyVQ+O2tKY1NyoE/KcwAjNDOkegrGvEHN2u2t5 auO7TSZdXPa3J6e2kkEQjHI2nc7lJVNLY2ry2TN68GfbnmkdMf1QdsYdtnrQsyyAw+Z6 YukQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AOdXXuvx8NGe5EYrUvWo2LcOvu2+DHw11/m+AnzvhAY=; b=Q29pL0xOwx0MXX5dy2xe7y7bQXc+/GorS0IL9vII0xai91sPs192TdKRW01+QztAB2 +q78yVuAn7NVRE6ovLBTdIYOItseYQfGojY7lBbl+0BXV4VOBOGEtdXky6yX5lyAXS8/ D8RqauMiGVR+3bfeKbOJKDiY8ZGIavz4cF8JO7h6TONrZ4n0iUE3lmpJj+ZDOUJ6hFX8 kOeKvFhzMYaRtFVN9kKk8EmB847Y88Oh4290EKdudXV4ww2r7L/AsOiJclA4VOeeVifD am9bdoGojyANGgsXFdleHC70GovE8Tvhop1jy6xHsO+FIGeo7MfVTNaeNS9H5XqtXeuX C8yw== X-Gm-Message-State: ALyK8tLqoGpP9y4075xm+cZ9Cc2TWdqNtib8k1AWHaEjgpSyO/zByczRvtaXO/OkTEL0+w== X-Received: by 10.28.209.13 with SMTP id i13mr7348741wmg.93.1468151321355; Sun, 10 Jul 2016 04:48:41 -0700 (PDT) Received: from localhost.localdomain ([79.112.8.37]) by smtp.gmail.com with ESMTPSA id d137sm6888378wmd.12.2016.07.10.04.48.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Jul 2016 04:48:40 -0700 (PDT) From: Emil Condrea To: qemu-devel@nongnu.org Date: Sun, 10 Jul 2016 14:47:48 +0300 Message-Id: <1468151270-12984-18-git-send-email-emilcondrea@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468151270-12984-1-git-send-email-emilcondrea@gmail.com> References: <1468151270-12984-1-git-send-email-emilcondrea@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH 17/19] Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: wei.liu2@citrix.com, stefanb@linux.vnet.ibm.com, stefano.stabellini@eu.citrix.com, xen-devel@lists.xen.org, quan.xu@intel.com, dgdegra@tycho.nsa.gov, emilcondrea@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Also rename it to tpm_util_is_selftest(). Signed-off-by: Quan Xu Signed-off-by: Emil Condrea Reviewed-by: Stefan Berger --- hw/tpm/Makefile.objs | 2 +- hw/tpm/tpm_passthrough.c | 13 +------------ hw/tpm/tpm_util.c | 11 +++++++++++ hw/tpm/tpm_util.h | 1 + 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/hw/tpm/Makefile.objs b/hw/tpm/Makefile.objs index b0a821c..16b1447 100644 --- a/hw/tpm/Makefile.objs +++ b/hw/tpm/Makefile.objs @@ -1,3 +1,3 @@ -common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o +common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o tpm_util.o common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o tpm_util.o common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index e88c0d2..dba408b 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -137,17 +137,6 @@ static void tpm_write_fatal_error_response(uint8_t *out, uint32_t out_len) } } -static bool tpm_passthrough_is_selftest(const uint8_t *in, uint32_t in_len) -{ - struct tpm_req_hdr *hdr = (struct tpm_req_hdr *)in; - - if (in_len >= sizeof(*hdr)) { - return (be32_to_cpu(hdr->ordinal) == TPM_ORD_ContinueSelfTest); - } - - return false; -} - static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, const uint8_t *in, uint32_t in_len, uint8_t *out, uint32_t out_len, @@ -161,7 +150,7 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt, tpm_pt->tpm_executing = true; *selftest_done = false; - is_selftest = tpm_passthrough_is_selftest(in, in_len); + is_selftest = tpm_util_is_selftest(in, in_len); ret = tpm_passthrough_unix_write(tpm_pt->tpm_fd, in, in_len); if (ret != in_len) { diff --git a/hw/tpm/tpm_util.c b/hw/tpm/tpm_util.c index 7b35429..323f4ae 100644 --- a/hw/tpm/tpm_util.c +++ b/hw/tpm/tpm_util.c @@ -125,3 +125,14 @@ int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version) return 1; } + +bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len) +{ + struct tpm_req_hdr *hdr = (struct tpm_req_hdr *)in; + + if (in_len >= sizeof(*hdr)) { + return (be32_to_cpu(hdr->ordinal) == TPM_ORD_ContinueSelfTest); + } + + return false; +} diff --git a/hw/tpm/tpm_util.h b/hw/tpm/tpm_util.h index e7f354a..b629663 100644 --- a/hw/tpm/tpm_util.h +++ b/hw/tpm/tpm_util.h @@ -24,5 +24,6 @@ #include "sysemu/tpm_backend.h" int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version); +bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len); #endif /* TPM_TPM_UTILS_H */