From patchwork Wed Jun 28 15:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 697240 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp4422180wrm; Wed, 28 Jun 2023 08:55:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hR5ignpdAYT6PdmCh7vaG6PD94vm2LoBVVBl8DU4vlxzYLAjZ0C2Y+PV/U+zq57GYmvFw X-Received: by 2002:a05:6214:1303:b0:628:65c8:9c3b with SMTP id pn3-20020a056214130300b0062865c89c3bmr49124381qvb.21.1687967701925; Wed, 28 Jun 2023 08:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687967701; cv=none; d=google.com; s=arc-20160816; b=D5/T7vdrONxSgwoDtBAddH2AGc8zK3tzjEQ38iU1XppORfU7Oel0SavsSEgtT+HnN1 DwVJAT1g4bEdVy0rLrREO+2HNkTylwQYy6luHkJTOpkk4fqrdq7n3yVfe1fcrDkTWswy auoH/KTAJYyT+A9kZ5oOeVwUr4gi3qvQoIo0JgUWbFF5/3tDTU0DF0WsxmzaYxqmFgLn 9sXwewBYawd5gtFoiJWJOpIn07LTcvqX0oA7lx9PqdoiCJmc2Bd7zcE1p4pL9JZwL0M0 y69b03uyM86wFde0zPvjC5NIXeKLLgLtGMCnVMMNVAbWQ7ygjkb0jspXDt/WAYHMTtSF EFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1p01mwNI4PbnXBYS34TfQsFRd8XkOd+v72EGXhsO46o=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=F1aaicnM/ui+0M119+CXyGidR2APFFjiEnlCgF4nC/nkz6xQxhkU9k1WLyC0JwxHok IL23+zYlHvHFpbFgSnh1CFqbiOQ6tEFQpITbFILk5PWVXcUDoy2dbIby9mGhGVcnuJga 7l5YYZ8ELN06cfB3UtTs69tuwrwrOokZ9BUsdcKod67U2aES7oDJhoLJd1BqDxXkuoDG WJDNLJOgqw0Ms986hq7wQnPUaA1eojAA0UBIhG6bigrarXFSG+QIzz2efXt1tJRvgi4s U+SWEtQXCk+5O/e+GOCl2KRp88Bsd7/jRVqu9XK5/O4QNbLMA+WA2co4JMzSimE1maj8 46Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="icj/Uvz/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id qt13-20020a05620a8a0d00b00767155a5f95si2094928qkn.258.2023.06.28.08.55.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Jun 2023 08:55:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="icj/Uvz/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qEXUc-0006Ef-C4; Wed, 28 Jun 2023 11:54:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qEXUZ-0006DP-24 for qemu-devel@nongnu.org; Wed, 28 Jun 2023 11:54:03 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEXUV-00085Q-0m for qemu-devel@nongnu.org; Wed, 28 Jun 2023 11:54:01 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-312824aa384so5370287f8f.1 for ; Wed, 28 Jun 2023 08:53:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687967635; x=1690559635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1p01mwNI4PbnXBYS34TfQsFRd8XkOd+v72EGXhsO46o=; b=icj/Uvz/U4FB1FMi9RSNPvamzpE83Tt76AV1YPWuw1O9Wo5KCeOOQ6Z4prMKjh/eQr hb7CIT64tHKAqZ26Pw9Eg2r2YDNwfFd97xwV2nrnH+BueS6w3F5RwGonRdyzoHLhn2Tl R9YUwLch4AtmAkL7jd9oejhor8igrapwzpZ3di2Kkt7zXltmc61Zn7456DnUFsnjf9rM ztBlcEF2HwaQ2dot6aEKR84QrzoYxboH6cZsVyoBQZZkP3G08XaOYm6gHSpZP2O1mjJ7 1TmApcNX6JuxPi5XEmt94JFk2Q7mtVc6N57e0GL+ffvBrexBjWYOtuEYcIlcMbrSwm4+ DoBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687967635; x=1690559635; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1p01mwNI4PbnXBYS34TfQsFRd8XkOd+v72EGXhsO46o=; b=QAwQc3ZmvdXXph7s7dWYOUjfKsRTOTCDOvf5kIt26z1CE1qXb6j2lm5hRqAMe8DpId A7ahE91iKfMkxRcUVIiW3OMhcOWsByKhC9ZgHtLIXiPRmdO0PkVE9klNqzHsKEh4Z781 CDCMy79gA8hwmkJNGkuKQbuzytat39dfFTu2mCZ32hUZk+3+G9/B8GWnP+al+sadD7CS JJqhbSuBid2fzOLLlnBKyoz2QBufYmnmHQH9lirtpKsTFk2RDg13tUfLVXIQ+Hyg9Hn+ s19gPVtCrVhCVkxUU4u5DXzgn6/dqFz6JLWMll8y0YfoRLxVAqsT3cQZHanbTflKYYFm 1yOg== X-Gm-Message-State: AC+VfDyIeyhd6JOtiRADslbZaAQvj1SZWs3nKLBBGc5bNHRovjTW/cee 9Zz79NKyrjIObpFJ2+kN9X+RzIB8trUKn6/z964= X-Received: by 2002:adf:f243:0:b0:313:f1ec:f429 with SMTP id b3-20020adff243000000b00313f1ecf429mr6754227wrp.46.1687967635648; Wed, 28 Jun 2023 08:53:55 -0700 (PDT) Received: from m1x-phil.lan ([176.187.207.229]) by smtp.gmail.com with ESMTPSA id g9-20020a5d5549000000b00307acec258esm13782917wrw.3.2023.06.28.08.53.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 28 Jun 2023 08:53:55 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson Subject: [PULL 07/30] accel: Destroy HAX vCPU threads once done Date: Wed, 28 Jun 2023 17:52:50 +0200 Message-Id: <20230628155313.71594-8-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230628155313.71594-1-philmd@linaro.org> References: <20230628155313.71594-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When the vCPU thread finished its processing, destroy it and signal its destruction to generic vCPU management layer. Add a sanity check for the vCPU accelerator context. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20230624174121.11508-6-philmd@linaro.org> --- target/i386/hax/hax-accel-ops.c | 3 +++ target/i386/hax/hax-all.c | 1 + 2 files changed, 4 insertions(+) diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c index 18114fe34d..0157a628a3 100644 --- a/target/i386/hax/hax-accel-ops.c +++ b/target/i386/hax/hax-accel-ops.c @@ -53,6 +53,8 @@ static void *hax_cpu_thread_fn(void *arg) qemu_wait_io_event(cpu); } while (!cpu->unplug || cpu_can_run(cpu)); + hax_vcpu_destroy(cpu); + cpu_thread_signal_destroyed(cpu); rcu_unregister_thread(); return NULL; } @@ -69,6 +71,7 @@ static void hax_start_vcpu_thread(CPUState *cpu) cpu->cpu_index); qemu_thread_create(cpu->thread, thread_name, hax_cpu_thread_fn, cpu, QEMU_THREAD_JOINABLE); + assert(cpu->hax_vcpu); #ifdef _WIN32 cpu->hThread = qemu_thread_get_handle(cpu->thread); #endif diff --git a/target/i386/hax/hax-all.c b/target/i386/hax/hax-all.c index a2321a1eff..38a4323a3c 100644 --- a/target/i386/hax/hax-all.c +++ b/target/i386/hax/hax-all.c @@ -209,6 +209,7 @@ int hax_vcpu_destroy(CPUState *cpu) CloseHandle(cpu->hThread); #endif g_free(vcpu); + cpu->hax_vcpu = NULL; return 0; }