From patchwork Thu Jun 22 16:08:15 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: 694904 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp1484960wrm; Thu, 22 Jun 2023 09:10:23 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7jIT2WKjYvBcxY1+tFIZ597jY+V29aylnmPvXHeO6h/PxupMlcM8ugNHz0caqDTjq3XMG/ X-Received: by 2002:a05:6214:27c6:b0:632:2101:c449 with SMTP id ge6-20020a05621427c600b006322101c449mr2427753qvb.25.1687450223564; Thu, 22 Jun 2023 09:10:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687450223; cv=none; d=google.com; s=arc-20160816; b=IphCPMt5xNjra+fEF1RI39aiZIkHKRg0/8q7805KKdCuopGAX0v5V9L5V/yr9Px+0w Nkplib+h0hbDyUpjYdgHHaM92AkIuE721UnrMQEuS4W1gNVVL7KuLNndJcZkoSYcEFtl n5sQaEt6pIJkqaZgp09wzWfGTDWAJBIxyfTzc5iDKAWLtliQAOFJlTqDaKV7baQzCeGl yM0I0wGsSSGzA9w2uB6UGZVQrGpPjRUIvcTMqHG4tkEvzqzkwClNlhSSoGOMFwllXM1z MB2l8EhTln44xlnJqoszu6JAv965dP0VLbfnN1hZE/glrsWifCwXbh5aENMvZHlPvlZz 7QhA== 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=JvPaiGifFa4V3EDPR8281c6klb7rmX/1fxpDcHgqe0M=; b=HTkn9qB3qaaLi/rvqExDP2bDWGl0uaY60l2WG26H2M4Cmu13nqPR40O0W0tBJMOWtN CGv1PwNT384jHbZog51yGthvA2kY/BaNFxvGYdpQyKWISGECfiDagH09fxWxxuJTD8zv 5Aj/9a01R9Gfn5GPL0wOexFOVaWIp1Sibnm7C7MKpTHZU3/om+JE2xMQowst2NInL+dz lEZ1d5oIXHZcDGhgw6BAM/rH1dSpzgFla98Ae5kZcs/bl5AZ/HMpBwwUzfSd6DdgtpbR AQ9QwzmQLASIaxhiBhkHx63HebCSMOX/g3ljKnJ8FRNW+VXT13n5mLGdmjT24gg3DlHX 49rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eMI0lYof; 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 e7-20020a0562141d0700b0062025424f4fsi2883363qvd.611.2023.06.22.09.10.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Jun 2023 09:10:23 -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=eMI0lYof; 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 1qCMse-0005Vw-GD; Thu, 22 Jun 2023 12:09:56 -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 1qCMsc-0005TC-75 for qemu-devel@nongnu.org; Thu, 22 Jun 2023 12:09:54 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCMsa-0000YQ-IP for qemu-devel@nongnu.org; Thu, 22 Jun 2023 12:09:53 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-3f9ede60140so13048905e9.0 for ; Thu, 22 Jun 2023 09:09:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687450191; x=1690042191; 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=JvPaiGifFa4V3EDPR8281c6klb7rmX/1fxpDcHgqe0M=; b=eMI0lYofss2LnSC9zIInA8Ipk7eMxXhs+QiJpeQw9NS9zkZEFQ1lVPz/mbrEgeEiXA Ri7nz3jKh0S6qK5bsBvFyX/ct26k8E5D8eKE417CKn6y2iGv2+rM8N9uwLCMdAKyEI7X MMdOjASfQZS5YzkHqhkSQtobW3/VLtYbGQcltoxMV3nPGbcAESIgwLdZybGqteLBVnBg a5dpQ46mz72Ed6dT4hb+hrjZXYiJyZjkSA9COUibnKtQZC0+hriXiYatbrVRlJqxvbzY lFDuP+sY/SBTHtbuawPlcyqRonlrtNxF9U2xibk40wo1M3U6dJPNYJfm0W1mWDJUNQxk k1+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687450191; x=1690042191; 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=JvPaiGifFa4V3EDPR8281c6klb7rmX/1fxpDcHgqe0M=; b=SwZHubb8ldcKQdPVPgQ5lYmSAwnY2EDQqRaVlzUH1xl6G4luVneM9DpPAifF6MF+5A +zZrMK3iWEmtWhBRvnq8VAU6hmyjEDapJttPnkO+GbNA58v8SYL9bi1jKvSB5k6h2M1x ENF78BTS3T79Imwcw0e003NjizcilsNMuf/FSroiPYdEVFum1x73du+W5KIjBr8OmDCU gUFJ+bW63pABj3DvxnSHH5V0L/hPhlfZZRySZoyYspeGQc0aYcGHQDUp5d/C7IUlJxk1 R56VYSFPSnse7ppl+B3KkpPPPTPVdqg46XYEYGcAfhsZAklRyhFqHdYdcpsPj4ej/6/6 AsZA== X-Gm-Message-State: AC+VfDx2XMKkteo98lSX55CA+Q6sjMGwLAMnncBfpm1PDZcqeWSQtYQE XnWinycsZzesXx4QX2Q5k/nti9l0/oi2MM0eEo/XJQ== X-Received: by 2002:a7b:cb05:0:b0:3f8:f015:69c9 with SMTP id u5-20020a7bcb05000000b003f8f01569c9mr12695304wmj.11.1687450190857; Thu, 22 Jun 2023 09:09:50 -0700 (PDT) Received: from localhost.localdomain (230.red-88-28-3.dynamicip.rima-tde.net. [88.28.3.230]) by smtp.gmail.com with ESMTPSA id 18-20020a05600c231200b003f9063fc3cbsm15728266wmo.44.2023.06.22.09.09.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 22 Jun 2023 09:09:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Reinoud Zandijk , qemu-arm@nongnu.org, kvm@vger.kernel.org, Marcel Apfelbaum , Stefano Stabellini , Anthony Perard , Yanan Wang , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Peter Maydell , Roman Bolshakov , Paolo Bonzini , Paul Durrant , Sunil Muthuswamy , Alexander Graf , Richard Henderson , xen-devel@lists.xenproject.org, Eduardo Habkost , Cameron Esfahani Subject: [PATCH v2 08/16] accel: Move HAX hThread to accelerator context Date: Thu, 22 Jun 2023 18:08:15 +0200 Message-Id: <20230622160823.71851-9-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230622160823.71851-1-philmd@linaro.org> References: <20230622160823.71851-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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=unavailable 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 7a0eb5ef32..01388d5918 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 341688a254..7055f5b53e 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; typedef 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 a55b18f353..c9ccc411e9 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 08ec93a256..b907953321 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);