From patchwork Sat Jun 24 17:41:13 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: 695720 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp2502744wrm; Sat, 24 Jun 2023 10:43:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5u6ezyFq8CLZRSTe4t5hLqwqVewyK/mUK0xZVQM9a61qD9xYM9w1oIgePT6CNBWl1DEMO0 X-Received: by 2002:a05:620a:2602:b0:75d:5103:439a with SMTP id z2-20020a05620a260200b0075d5103439amr24712235qko.75.1687628604187; Sat, 24 Jun 2023 10:43:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687628604; cv=none; d=google.com; s=arc-20160816; b=qkH+/13XHVAG+7hoSG+5qm7wUNme1CKs4pXnVLZ60SS4Q2z9BexVuFF6Xnk1UmnlaP nom9t4vjXJRPUJaTluV3ugA8ciVlrHKTSDgiW/XVqUSygwctTFoUNBDhQzk7CRq3FK5o 42emtLoQ8qOZBOgesAqPTZpwQB7wvoZdqJ95mshExQo7Px555l1XpUFlsy8E44N+vdtq rU1p9iWX+sJW2UPIgj/bRStqfNykBk6XGWGw5vd2jONz8PNqXWzj1DgqI0PHVJI0xPq0 flMI2VwIjLGw24v2GtNGSotnoG7SiiNpghpf9gRpJz5r8RRsEKEItjo+39zNKFza+1ot vTZw== 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=NN9VasAt75iFOv6bKm088IUAp3WHizK1u2macVzvnVk=; fh=dxlO8U8n9FJbkfu3NZ9xTJMkF/Fn5IQj359CkmYw0tg=; b=gKqL5i+mUNaAyAyHor7ur05n314PWc941Af24mwL5H1kxiR1X9Y1qCc1FxnQqSZOF5 IU+ZXaXiXwXxGqooI4m2HY/lJMUHNfxg2KFT9IdFEWi0b91US0CDUw0wVv+oy5dwXX8V 9PcxWtpiB6weBpKCAgXOuEGlbVCgKDZba2QxzAzJwYj8trgRW4X5ELAOC7FAI3t8i0IU XKtHrQyUpLKbLyGpuF0XvWPAqsirQ4pyw//rbhlhaKaYOV7MNbAMLuqeqDzL5Ki+Bv2Q 0jURxkzy2MmqUNtW3pKw7Rf+A5rnMgAPOY/N+omEyK7RJje7FY60Chvyf929/I3M/x8H 41nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TpoTyF2J; 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 rk3-20020a05620a900300b007608295a685si682365qkn.689.2023.06.24.10.43.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sat, 24 Jun 2023 10:43:24 -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=TpoTyF2J; 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 1qD7HJ-0006tg-1e; Sat, 24 Jun 2023 13:42:29 -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 1qD7HH-0006ol-Gl for qemu-devel@nongnu.org; Sat, 24 Jun 2023 13:42:27 -0400 Received: from mail-ej1-x631.google.com ([2a00:1450:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qD7HF-0006oR-N8 for qemu-devel@nongnu.org; Sat, 24 Jun 2023 13:42:27 -0400 Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-98dfb3f9af6so84286266b.2 for ; Sat, 24 Jun 2023 10:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687628544; x=1690220544; 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=NN9VasAt75iFOv6bKm088IUAp3WHizK1u2macVzvnVk=; b=TpoTyF2JMLfTdhJFfQDIJVDl7wyit9krNMh5pkE5UD2Z85JsI+MhIJfZq4TxXmpXb/ Jq5HiN89HJ4wr6rXLea/eWyd7618cAZZiB+S4t907FNYoN5Za7XtU53Yo99TffKFQ0cf 44Xmr7D3BCBiDEaJRA6+UHWtBWBj4mZwYkdJuNkFUXvTWvqPJQ+tLi4m5dnTjJoqSct8 IsWj6zhrwB+4NlanWGr0JPLUH/XYLaVY04sIYBZkfBiSkR23DgIuGBjyK/H2gFkyPBbE jt5/4gwPqUFkxozHegLbIIK30roYFKpcZHG+a2L3V4oBZU7sNJ0K7b+DJi29MWniwKkO nrBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687628544; x=1690220544; 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=NN9VasAt75iFOv6bKm088IUAp3WHizK1u2macVzvnVk=; b=Wb13caU+iqKPvkKsXo1O2jr0ON3Bg49pwnBoGWx2HBeNerbcHmE2N053Nt8SJbe8pn buyFAv3h65w6xlVwU65W1MLSHoSYtUPsTcSFFgCUdAwle9MxcKGKj3DpCfob/Z+B66BX BD8aJfFeztmVGdqe7AX9zp/hLQmDrZfBN0pxj1SRm/VmFZo5JWFUeyJHhq8FZys2GMCJ QpOPslT0alu0gKnAkmpMGx5T5dKZ7a9AwMOyxuzzBrrqxRti/O8H+v6mwiOtQ1TwkE1C tGhtyg3QOKaMxGqUELyM5eE7o8614PDTFwOEZWq8HUTA6/qu7UmEcl0VpoVe7Au+crP+ KaNw== X-Gm-Message-State: AC+VfDyNizGFNIvcwTawbLv3r3+87+u23rvZ4ty7/fkOmrIx5ORcd2l2 vm8OxsRJfM+4ZIChGqxj3zT1tNJa+X1EDskmpg0= X-Received: by 2002:a17:907:5c8:b0:974:7713:293f with SMTP id wg8-20020a17090705c800b009747713293fmr22846007ejb.41.1687628544073; Sat, 24 Jun 2023 10:42:24 -0700 (PDT) Received: from m1x-phil.lan ([176.187.217.150]) by smtp.gmail.com with ESMTPSA id i10-20020a170906250a00b0096a6be0b66dsm1102885ejb.208.2023.06.24.10.42.20 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 24 Jun 2023 10:42:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, Marcel Apfelbaum , Peter Maydell , Roman Bolshakov , qemu-arm@nongnu.org, Richard Henderson , Alexander Graf , xen-devel@lists.xenproject.org, Sunil Muthuswamy , Anthony Perard , Stefano Stabellini , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paul Durrant , Reinoud Zandijk , Eduardo Habkost , Cameron Esfahani , Paolo Bonzini Subject: [PATCH v3 08/16] accel: Move HAX hThread to accelerator context Date: Sat, 24 Jun 2023 19:41:13 +0200 Message-Id: <20230624174121.11508-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230624174121.11508-1-philmd@linaro.org> References: <20230624174121.11508-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::631; envelope-from=philmd@linaro.org; helo=mail-ej1-x631.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 hThread variable is only used by the HAX accelerator, so move it to the accelerator specific context. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/core/cpu.h | 1 - target/i386/hax/hax-i386.h | 3 +++ target/i386/hax/hax-accel-ops.c | 2 +- target/i386/hax/hax-all.c | 2 +- target/i386/hax/hax-windows.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a7fae8571e..8b40946afc 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -337,7 +337,6 @@ struct CPUState { struct QemuThread *thread; #ifdef _WIN32 - HANDLE hThread; QemuSemaphore sem; #endif int thread_id; diff --git a/target/i386/hax/hax-i386.h b/target/i386/hax/hax-i386.h index 4372ee596d..87153f40ab 100644 --- a/target/i386/hax/hax-i386.h +++ b/target/i386/hax/hax-i386.h @@ -27,6 +27,9 @@ typedef HANDLE hax_fd; extern struct hax_state hax_global; struct AccelCPUState { +#ifdef _WIN32 + HANDLE hThread; +#endif hax_fd fd; int vcpu_id; struct hax_tunnel *tunnel; diff --git a/target/i386/hax/hax-accel-ops.c b/target/i386/hax/hax-accel-ops.c index a8512efcd5..5031096760 100644 --- a/target/i386/hax/hax-accel-ops.c +++ b/target/i386/hax/hax-accel-ops.c @@ -73,7 +73,7 @@ static void hax_start_vcpu_thread(CPUState *cpu) cpu, QEMU_THREAD_JOINABLE); assert(cpu->accel); #ifdef _WIN32 - cpu->hThread = qemu_thread_get_handle(cpu->thread); + cpu->accel->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 9d9011cc38..18d78e5b6b 100644 --- a/target/i386/hax/hax-all.c +++ b/target/i386/hax/hax-all.c @@ -206,7 +206,7 @@ int hax_vcpu_destroy(CPUState *cpu) hax_close_fd(vcpu->fd); hax_global.vm->vcpus[vcpu->vcpu_id] = NULL; #ifdef _WIN32 - CloseHandle(cpu->hThread); + CloseHandle(vcpu->hThread); #endif g_free(vcpu); cpu->accel = NULL; diff --git a/target/i386/hax/hax-windows.c b/target/i386/hax/hax-windows.c index bf4b0ad941..4bf6cc08d2 100644 --- a/target/i386/hax/hax-windows.c +++ b/target/i386/hax/hax-windows.c @@ -476,7 +476,7 @@ void hax_kick_vcpu_thread(CPUState *cpu) */ cpu->exit_request = 1; if (!qemu_cpu_is_self(cpu)) { - if (!QueueUserAPC(dummy_apc_func, cpu->hThread, 0)) { + if (!QueueUserAPC(dummy_apc_func, cpu->accel->hThread, 0)) { fprintf(stderr, "%s: QueueUserAPC failed with error %lu\n", __func__, GetLastError()); exit(1);