From patchwork Thu Oct 19 18:02:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Berger X-Patchwork-Id: 10018091 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 734AE60215 for ; Thu, 19 Oct 2017 18:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DF1728DF2 for ; Thu, 19 Oct 2017 18:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6135128DF8; Thu, 19 Oct 2017 18:10:30 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 C5E7628DF2 for ; Thu, 19 Oct 2017 18:10:29 +0000 (UTC) Received: from localhost ([::1]:50702 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5FH3-00048o-0h for patchwork-qemu-devel@patchwork.kernel.org; Thu, 19 Oct 2017 14:10:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5FAP-0007QH-4B for qemu-devel@nongnu.org; Thu, 19 Oct 2017 14:03:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5FAK-0007PL-VU for qemu-devel@nongnu.org; Thu, 19 Oct 2017 14:03:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:41000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e5FAK-0007Nz-JA for qemu-devel@nongnu.org; Thu, 19 Oct 2017 14:03:32 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9JHxQGe128243 for ; Thu, 19 Oct 2017 14:03:29 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dpws24549-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 19 Oct 2017 14:03:29 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 19 Oct 2017 14:03:28 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 19 Oct 2017 14:03:25 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9JI3Pv241484502; Thu, 19 Oct 2017 18:03:25 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 372C428041; Thu, 19 Oct 2017 14:03:18 -0400 (EDT) Received: from sbct-3.watson.ibm.com (unknown [9.47.158.153]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 1F8E32804A; Thu, 19 Oct 2017 14:03:18 -0400 (EDT) From: Stefan Berger To: qemu-devel@nongnu.org Date: Thu, 19 Oct 2017 14:02:45 -0400 X-Mailer: git-send-email 2.5.5 In-Reply-To: <1508436175-1596-1-git-send-email-stefanb@linux.vnet.ibm.com> References: <1508436175-1596-1-git-send-email-stefanb@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17101918-0048-0000-0000-000001F83B76 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007919; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000238; SDB=6.00933481; UDB=6.00470184; IPR=6.00713768; BA=6.00005651; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017610; XFM=3.00000015; UTC=2017-10-19 18:03:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17101918-0049-0000-0000-000042EC28C3 Message-Id: <1508436175-1596-12-git-send-email-stefanb@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-19_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710190247 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v9JHxQGe128243 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PULL v1 11/21] tpm: remove unused TPMBackendCmd 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: Peter Maydell , Stefan Berger , marcandre.lureau@gmail.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau There is only handling of request so far in both backends. Signed-off-by: Marc-André Lureau Reviewed-by: Stefan Berger Signed-off-by: Stefan Berger --- backends/tpm.c | 7 ++----- hw/tpm/tpm_emulator.c | 42 ++++++++++++++++-------------------------- hw/tpm/tpm_passthrough.c | 29 ++++++++++------------------- include/sysemu/tpm_backend.h | 9 +-------- 4 files changed, 29 insertions(+), 58 deletions(-) diff --git a/backends/tpm.c b/backends/tpm.c index dc750d4..34e8208 100644 --- a/backends/tpm.c +++ b/backends/tpm.c @@ -25,13 +25,12 @@ static void tpm_backend_worker_thread(gpointer data, gpointer user_data) TPMBackendClass *k = TPM_BACKEND_GET_CLASS(s); assert(k->handle_request != NULL); - k->handle_request(s, (TPMBackendCmd)data); + k->handle_request(s); } static void tpm_backend_thread_end(TPMBackend *s) { if (s->thread_pool) { - g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_END, NULL); g_thread_pool_free(s->thread_pool, FALSE, TRUE); s->thread_pool = NULL; } @@ -64,7 +63,6 @@ int tpm_backend_startup_tpm(TPMBackend *s) s->thread_pool = g_thread_pool_new(tpm_backend_worker_thread, s, 1, TRUE, NULL); - g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_INIT, NULL); res = k->startup_tpm ? k->startup_tpm(s) : 0; @@ -80,8 +78,7 @@ bool tpm_backend_had_startup_error(TPMBackend *s) void tpm_backend_deliver_request(TPMBackend *s) { - g_thread_pool_push(s->thread_pool, (gpointer)TPM_BACKEND_CMD_PROCESS_CMD, - NULL); + g_thread_pool_push(s->thread_pool, NULL, NULL); } void tpm_backend_reset(TPMBackend *s) diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c index 03ea584..a6763e8 100644 --- a/hw/tpm/tpm_emulator.c +++ b/hw/tpm/tpm_emulator.c @@ -172,39 +172,29 @@ static int tpm_emulator_set_locality(TPMEmulator *tpm_emu, uint8_t locty_number) return 0; } -static void tpm_emulator_handle_request(TPMBackend *tb, TPMBackendCmd cmd) +static void tpm_emulator_handle_request(TPMBackend *tb) { TPMEmulator *tpm_emu = TPM_EMULATOR(tb); TPMLocality *locty = NULL; bool selftest_done = false; Error *err = NULL; - DPRINTF("processing command type %d", cmd); - - switch (cmd) { - case TPM_BACKEND_CMD_PROCESS_CMD: - locty = tb->tpm_state->locty_data; - if (tpm_emulator_set_locality(tpm_emu, - tb->tpm_state->locty_number) < 0 || - tpm_emulator_unix_tx_bufs(tpm_emu, locty->w_buffer.buffer, - locty->w_offset, locty->r_buffer.buffer, - locty->r_buffer.size, &selftest_done, - &err) < 0) { - tpm_util_write_fatal_error_response(locty->r_buffer.buffer, - locty->r_buffer.size); - error_report_err(err); - } - - tb->recv_data_callback(tb->tpm_state, tb->tpm_state->locty_number, - selftest_done); - - break; - case TPM_BACKEND_CMD_INIT: - case TPM_BACKEND_CMD_END: - case TPM_BACKEND_CMD_TPM_RESET: - /* nothing to do */ - break; + DPRINTF("processing TPM command"); + + locty = tb->tpm_state->locty_data; + if (tpm_emulator_set_locality(tpm_emu, + tb->tpm_state->locty_number) < 0 || + tpm_emulator_unix_tx_bufs(tpm_emu, locty->w_buffer.buffer, + locty->w_offset, locty->r_buffer.buffer, + locty->r_buffer.size, &selftest_done, + &err) < 0) { + tpm_util_write_fatal_error_response(locty->r_buffer.buffer, + locty->r_buffer.size); + error_report_err(err); } + + tb->recv_data_callback(tb->tpm_state, tb->tpm_state->locty_number, + selftest_done); } static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu) diff --git a/hw/tpm/tpm_passthrough.c b/hw/tpm/tpm_passthrough.c index d9da99b..5cd988e 100644 --- a/hw/tpm/tpm_passthrough.c +++ b/hw/tpm/tpm_passthrough.c @@ -149,29 +149,20 @@ static int tpm_passthrough_unix_transfer(TPMPassthruState *tpm_pt, selftest_done); } -static void tpm_passthrough_handle_request(TPMBackend *tb, TPMBackendCmd cmd) +static void tpm_passthrough_handle_request(TPMBackend *tb) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); bool selftest_done = false; - DPRINTF("tpm_passthrough: processing command type %d\n", cmd); - - switch (cmd) { - case TPM_BACKEND_CMD_PROCESS_CMD: - tpm_passthrough_unix_transfer(tpm_pt, - tb->tpm_state->locty_data, - &selftest_done); - - tb->recv_data_callback(tb->tpm_state, - tb->tpm_state->locty_number, - selftest_done); - break; - case TPM_BACKEND_CMD_INIT: - case TPM_BACKEND_CMD_END: - case TPM_BACKEND_CMD_TPM_RESET: - /* nothing to do */ - break; - } + DPRINTF("tpm_passthrough: processing command\n"); + + tpm_passthrough_unix_transfer(tpm_pt, + tb->tpm_state->locty_data, + &selftest_done); + + tb->recv_data_callback(tb->tpm_state, + tb->tpm_state->locty_number, + selftest_done); } static void tpm_passthrough_reset(TPMBackend *tb) diff --git a/include/sysemu/tpm_backend.h b/include/sysemu/tpm_backend.h index b08f985..7d7ebfc 100644 --- a/include/sysemu/tpm_backend.h +++ b/include/sysemu/tpm_backend.h @@ -32,13 +32,6 @@ typedef struct TPMBackend TPMBackend; typedef void (TPMRecvDataCB)(TPMState *, uint8_t locty, bool selftest_done); -typedef enum TPMBackendCmd { - TPM_BACKEND_CMD_INIT = 1, - TPM_BACKEND_CMD_PROCESS_CMD, - TPM_BACKEND_CMD_END, - TPM_BACKEND_CMD_TPM_RESET, -} TPMBackendCmd; - struct TPMBackend { Object parent; @@ -83,7 +76,7 @@ struct TPMBackendClass { void (*opened)(TPMBackend *s, Error **errp); - void (*handle_request)(TPMBackend *s, TPMBackendCmd cmd); + void (*handle_request)(TPMBackend *s); }; /**