From patchwork Thu Oct 25 17:20:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 989276 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=braap.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=braap.org header.i=@braap.org header.b="K52kk8VD"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="EBJltfVs"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42gvwc2T2Xz9sDC for ; Fri, 26 Oct 2018 04:57:35 +1100 (AEDT) Received: from localhost ([::1]:56203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjsz-0007oJ-3p for incoming@patchwork.ozlabs.org; Thu, 25 Oct 2018 13:57:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFjKm-0006j1-KA for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:22:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFjJl-0008Pr-JQ for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:12 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:49907) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gFjJl-0008PG-Eb for qemu-devel@nongnu.org; Thu, 25 Oct 2018 13:21:09 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 2AF0B21F30; Thu, 25 Oct 2018 13:21:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 25 Oct 2018 13:21:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=braap.org; h= from:to:cc:subject:date:message-id:in-reply-to:references; s= mesmtp; bh=VZpcu0cRqtxF3QM9uVZkd8VKZVm6+pUJegReZs6l8LU=; b=K52kk 8VDHk4ONoTH/nBqsTDuauHbtzjfCnEFqJf7irb1FMJz6WVp6vz0R54ZD8N32Jirh GgCyUdJ6fmFsu/0CbXmKWcuk1PGy1BM49mwSuxb8iCFcRhTwsLxe+6ncIrYVuQyo g478eOTPM8TwDBuKC1PbtfqGv1qizaLaB4NcCQ= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=VZpcu0cRqtxF3QM9uVZkd8VKZVm6+ pUJegReZs6l8LU=; b=EBJltfVsXYvk3pKfiQyEzj4SiC1tpqMxz0HaH0Rj504jh 2zGktllFlhe837NQEmg4VrXxlSQ2nAemzBQ4dasXd/F9aJD9rNTdAS1wHfaxg70Z ytUIojKyGAqD4zRwsEVHrCNrnhi8Bhcz24m7zb9c4NA5hc+/knRYk9gg4kYxMHl9 lu8OCPb1Dh3w/jli8YJQ2tshWYmWsqd6TLds7M3AAXn/UZ9cqsLQY7dCsrN2Ktts 0P8GgAllGcATpGZCsfs/hspEdq9pV6XXoQPttCX8n5xipLSsnWh4+7kVSff48pBL lP1B0Y7DGjjHcLJTsruy6bf2TTxIZiH33JkKCFIHA== X-ME-Sender: X-ME-Proxy: Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id BC5A5E4074; Thu, 25 Oct 2018 13:21:08 -0400 (EDT) From: "Emilio G. Cota" To: qemu-devel@nongnu.org Date: Thu, 25 Oct 2018 13:20:18 -0400 Message-Id: <20181025172057.20414-10-cota@braap.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025172057.20414-1-cota@braap.org> References: <20181025172057.20414-1-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 09/48] tcg: reset runtime helpers when flushing the code cache 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 , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Llu=C3=ADs_Vilanova?= , Pavel Dovgalyuk , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" In preparation for adding plugin support. One of the clean-up actions when uninstalling plugins will be to flush the code cache. We'll also have to clear the runtime helpers, since some of those runtime helpers may belong to the plugin being uninstalled. Signed-off-by: Emilio G. Cota Reviewed-by: Alex Bennée --- tcg/tcg.h | 1 + accel/tcg/translate-all.c | 1 + tcg/tcg.c | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/tcg/tcg.h b/tcg/tcg.h index 3fa434d891..2c378415d2 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -1079,6 +1079,7 @@ bool tcg_op_supported(TCGOpcode op); void tcg_gen_callN(void *func, TCGTemp *ret, int nargs, TCGTemp **args); void tcg_gen_runtime_helper(const TCGHelperInfo *orig, TCGTemp *ret, int nargs, TCGTemp **args); +void tcg_reset_runtime_helpers(void); TCGOp *tcg_emit_op(TCGOpcode opc); void tcg_op_remove(TCGContext *s, TCGOp *op); diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 038d82fdb5..c8b3e0a491 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -1255,6 +1255,7 @@ static void do_tb_flush(CPUState *cpu, run_on_cpu_data tb_flush_count) qht_reset_size(&tb_ctx.htable, CODE_GEN_HTABLE_SIZE); page_flush_tb(); + tcg_reset_runtime_helpers(); tcg_region_reset_all(); /* XXX: flush processor icache at this point if cache flush is diff --git a/tcg/tcg.c b/tcg/tcg.c index 87e02da740..a6824145b0 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -874,6 +874,7 @@ static const TCGHelperInfo all_helpers[] = { #include "exec/helper-tcg.h" }; static struct qht helper_table; +static struct qht runtime_helper_table; static bool helper_table_inited; static int indirect_reg_alloc_order[ARRAY_SIZE(tcg_target_reg_alloc_order)]; @@ -913,6 +914,22 @@ static void tcg_helper_insert(const TCGHelperInfo *info) g_assert(inserted); } +static void +rm_from_helper_table_and_free(void *p, uint32_t h, void *userp) +{ + bool success; + + success = qht_remove(&helper_table, p, h); + g_assert(success); + g_free(p); +} + +void tcg_reset_runtime_helpers(void) +{ + qht_iter(&runtime_helper_table, rm_from_helper_table_and_free, NULL); + qht_reset(&runtime_helper_table); +} + void tcg_context_init(TCGContext *s) { int op, total_args, n, i; @@ -948,6 +965,7 @@ void tcg_context_init(TCGContext *s) /* Register helpers. */ qht_init(&helper_table, tcg_helper_cmp, ARRAY_SIZE(all_helpers), QHT_MODE_AUTO_RESIZE); + qht_init(&runtime_helper_table, tcg_helper_cmp, 1, QHT_MODE_AUTO_RESIZE); for (i = 0; i < ARRAY_SIZE(all_helpers); ++i) { tcg_helper_insert(&all_helpers[i]); @@ -1847,6 +1865,9 @@ void tcg_gen_runtime_helper(const TCGHelperInfo *orig, TCGTemp *ret, int nargs, if (unlikely(existing)) { g_free(info); info = existing; + } else { + qht_insert(&runtime_helper_table, info, hash, &existing); + g_assert(existing == NULL); } } do_tcg_gen_callN(info, ret, nargs, args);