From patchwork Mon Apr 29 21:30:41 2024 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: 793027 Delivered-To: patch@linaro.org Received: by 2002:adf:ec83:0:b0:34d:5089:5a9e with SMTP id z3csp317642wrn; Mon, 29 Apr 2024 14:32:01 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVRVuN4x/hkSS8el3VhJ5dy7iWP+48TRoKscClYUDz5k71AiKmdf2JLkiy8FpO2D0SqAxnrWHFzVVHjaFWsBtez X-Google-Smtp-Source: AGHT+IGiURc719XjP7zu5/jYL+yA4AeYYc1xwqDsyhPmhrejR/kV+GvxEaa1b21tv9sXncNWiqUT X-Received: by 2002:a05:622a:4cc8:b0:437:9c7e:ab1f with SMTP id fa8-20020a05622a4cc800b004379c7eab1fmr1165688qtb.33.1714426321140; Mon, 29 Apr 2024 14:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714426321; cv=none; d=google.com; s=arc-20160816; b=c3ynwikOTCfvSg+IaW152XCJe38TQpWrPYvbp/Y90vWaPt2EF2vhOxWyNg0c8VXoBE IIRDzSJkzH17Plq/Ns7N2MnTfJMRysL53T5+8ZwWVIxDEbDQHATAy5AWr8inSsL8cG61 CzgnVGkUyz/7uD4ZfVSGorP7EYZ93vQ6YU/5Ttd3fFqmEwBCqAH6pHD9QuFflmcU69ql Pkpb8SSQqhmujA6TBDQZmLl3y5MSavFU1AKF57Hv5NRcp4DFBzHVNdEQUkZcRzf49jvC +Wzzl/KXbjoDLLhmiXGAM2uzdDr45D2xVc4s6GQNSfdrZ2DeylaAHRhK0lLrYPpi3V41 fpmg== 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=Q0XtObvwSIJmn1wCbR4xzdf8RtxMxRInH39sdIpqdxw=; fh=hPEYkGzCDPyP/3ZkGHLTHhyYbPfmxEKmvnAkP1JYmAU=; b=DL4gWTfyFRxi0ep00gflQ2kIfvee2t0jrlrQhD+8Su2f7S5BFC4BPXIIbRZKMdXVLx pXRWv9WXL5H96jiFm/geRtDAxWAvB7nQB99PQXh38AWkG2SBzyIZR8VuQt/xhhrh/EyZ spYyl3jlZaIaiXy0h0HF6aVlWn+sJnKV/6qeRbIErTiZDCR7Lczb0oDdhG2qO+MsE4gX AdSYN3uOZUmHiGv3LRbiIAiq4D9TkWsdX1wvKszKbWfMeH/3SFHR+gdX50R5Epbea0pI TzLCnRQ5TxsuUJNWoI4DiF5qkX0Saeq2sr/QumA+h2pXhuVZP23Sznt5nW7HUyqjL0MA hs5w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HAwK5zr1; 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 z14-20020ac87f8e000000b0043ab530ba30si5591177qtj.257.2024.04.29.14.32.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2024 14:32: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=HAwK5zr1; 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 1s1Yb3-0007Fz-FK; Mon, 29 Apr 2024 17:31:41 -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 1s1Yak-000788-5J for qemu-devel@nongnu.org; Mon, 29 Apr 2024 17:31:19 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1Yai-0003KB-78 for qemu-devel@nongnu.org; Mon, 29 Apr 2024 17:31:17 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-41b79451128so28405375e9.0 for ; Mon, 29 Apr 2024 14:31:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714426274; x=1715031074; darn=nongnu.org; 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=Q0XtObvwSIJmn1wCbR4xzdf8RtxMxRInH39sdIpqdxw=; b=HAwK5zr1COqgBJfb8WrST3DK0JvJJRg5sRY1c2d2dK9//Te2cuusA52Lw5v/5ToaNc XzxSFNzcetzuElcKs1rXraZJL96IYzJYTLu0VTxIX6P6WGm0peQ4dl1spc6j+qbQa1WB lPNKKfqtFr6BuknBLseja4/RSTbT9oEelcaTXIlT8G5KXVXvtQ1oOOW5vqrYfp/YbyEk cuuzfgXzrhwJTTwyi6yCzWQH3r7MLSOFUfMFfeFWngAIq6bS18fqGiQPDGU0YUSYQUQH YuIi2zg0FwL+HUmyplvaMzaB2Cwwhxt71W82w/TkDQcZO+cXsQR+JSeFLBD8iB5/x1Ky 7CKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714426274; x=1715031074; 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=Q0XtObvwSIJmn1wCbR4xzdf8RtxMxRInH39sdIpqdxw=; b=HPChCnXcm0IsMdls+AUjsILezi/4ybRkw0IVHsyJCw6aEiOQIS5Qf7+3zXBeDVdpdq HUySvTP2OTVK8qs0wEHDNKaokMX1usaQGcvDmJqHiqF63zAUvLD+s3bZbkfR6jgbMMqa /hx3JTlj6hHDRoyCaJuqX9xtVo4Kf2Xzre1RaEhRJITzNFZm6gj02lzyEdGvmrZbmcd5 FDXaVPTbt6wBm+Tpc8ndFRYDKylJthuKULupAZLlYRtyuwULUbT1DUwogA6PzZb9qNCW j/5EWXgG47ka3s7cR4SDBB4eW3QxpvvJIdafTcr/voN1Sws0p2pc5/HJN8bVifaGbCqY MUUg== X-Gm-Message-State: AOJu0YwjB9Ygdn3JaErwpFljzXjX+6pKooVtQPE85xvwv9dG8KPIp07g YYcqIeLgc5TDgw+MnrfseweDxhjpwCJ8onwwfKesTqZFhxEgh3GpaH5I0k+WMviYgRC75Ne8IJm 5zvY= X-Received: by 2002:a05:600c:3ba1:b0:41c:97e:2100 with SMTP id n33-20020a05600c3ba100b0041c097e2100mr4429507wms.3.1714426274120; Mon, 29 Apr 2024 14:31:14 -0700 (PDT) Received: from m1x-phil.lan (bny92-h02-176-184-44-142.dsl.sta.abo.bbox.fr. [176.184.44.142]) by smtp.gmail.com with ESMTPSA id bg5-20020a05600c3c8500b00419f419236fsm34246626wmb.41.2024.04.29.14.31.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 29 Apr 2024 14:31:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Anton Johansson , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH v2 04/13] accel/tcg: Move @plugin_state from CPUState to TCG AccelCPUState Date: Mon, 29 Apr 2024 23:30:41 +0200 Message-ID: <20240429213050.55177-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240429213050.55177-1-philmd@linaro.org> References: <20240429213050.55177-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=philmd@linaro.org; helo=mail-wm1-x335.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 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 @plugin_state is specific to TCG accelerator, move it to its AccelCPUState. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- TODO: check dubious include of "accel/tcg/vcpu-state.h" in hw/core/cpu-common.c. --- accel/tcg/vcpu-state.h | 5 +++++ include/hw/core/cpu.h | 5 ----- accel/tcg/plugin-gen.c | 4 +++- hw/core/cpu-common.c | 3 ++- plugins/core.c | 7 ++++--- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/accel/tcg/vcpu-state.h b/accel/tcg/vcpu-state.h index e30368edae..35c2695a77 100644 --- a/accel/tcg/vcpu-state.h +++ b/accel/tcg/vcpu-state.h @@ -10,11 +10,16 @@ /** * AccelCPUState: vCPU fields specific to TCG accelerator + * @plugin_state: per-CPU plugin state */ struct AccelCPUState { #ifdef CONFIG_USER_ONLY TaskState *ts; #endif /* !CONFIG_USER_ONLY */ + +#ifdef CONFIG_PLUGIN + CPUPluginState *plugin_state; +#endif /* CONFIG_PLUGIN */ }; #ifdef CONFIG_USER_ONLY diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 571ef3e514..91e793e590 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -423,7 +423,6 @@ struct qemu_work_item; * @kvm_fd: vCPU file descriptor for KVM. * @work_mutex: Lock to prevent multiple access to @work_list. * @work_list: List of pending asynchronous work. - * @plugin_state: per-CPU plugin state * @ignore_memory_transaction_failures: Cached copy of the MachineState * flag of the same name: allows the board to suppress calling of the * CPU do_transaction_failed hook function. @@ -514,10 +513,6 @@ struct CPUState { /* Use by accel-block: CPU is executing an ioctl() */ QemuLockCnt in_ioctl_lock; -#ifdef CONFIG_PLUGIN - CPUPluginState *plugin_state; -#endif - /* TODO Move common fields from CPUArchState here. */ int cpu_index; int cluster_index; diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index fd268c79b5..88d720d549 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -52,6 +52,7 @@ #include "exec/plugin-gen.h" #include "exec/translator.h" #include "exec/helper-proto-common.h" +#include "accel/tcg/vcpu-state.h" #define HELPER_H "accel/tcg/plugin-helpers.h" #include "exec/helper-info.c.inc" @@ -872,7 +873,8 @@ bool plugin_gen_tb_start(CPUState *cpu, const DisasContextBase *db, { bool ret = false; - if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, cpu->plugin_state->event_mask)) { + if (test_bit(QEMU_PLUGIN_EV_VCPU_TB_TRANS, + cpu->accel->plugin_state->event_mask)) { struct qemu_plugin_tb *ptb = tcg_ctx->plugin_tb; int i; diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index f2826d0409..0e5ebbe050 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -31,6 +31,7 @@ #include "hw/qdev-properties.h" #include "trace.h" #ifdef CONFIG_PLUGIN +#include "accel/tcg/vcpu-state.h" // ??? #include "qemu/plugin.h" #endif @@ -215,7 +216,7 @@ static void cpu_common_realizefn(DeviceState *dev, Error **errp) /* Plugin initialization must wait until the cpu start executing code */ #ifdef CONFIG_PLUGIN if (tcg_enabled()) { - cpu->plugin_state = qemu_plugin_create_vcpu_state(); + cpu->accel->plugin_state = qemu_plugin_create_vcpu_state(); async_run_on_cpu(cpu, qemu_plugin_vcpu_init__async, RUN_ON_CPU_NULL); } #endif diff --git a/plugins/core.c b/plugins/core.c index a097d02788..722224e5d8 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -28,6 +28,7 @@ #include "exec/tb-flush.h" #include "tcg/tcg.h" #include "tcg/tcg-op.h" +#include "accel/tcg/vcpu-state.h" #include "plugin.h" struct qemu_plugin_cb { @@ -55,7 +56,7 @@ struct qemu_plugin_ctx *plugin_id_to_ctx_locked(qemu_plugin_id_t id) static void plugin_cpu_update__async(CPUState *cpu, run_on_cpu_data data) { - bitmap_copy(cpu->plugin_state->event_mask, + bitmap_copy(cpu->accel->plugin_state->event_mask, &data.host_ulong, QEMU_PLUGIN_EV_MAX); tcg_flush_jmp_cache(cpu); } @@ -396,7 +397,7 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, uint64_t a2, struct qemu_plugin_cb *cb, *next; enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL; - if (!test_bit(ev, cpu->plugin_state->event_mask)) { + if (!test_bit(ev, cpu->accel->plugin_state->event_mask)) { return; } @@ -418,7 +419,7 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) struct qemu_plugin_cb *cb, *next; enum qemu_plugin_event ev = QEMU_PLUGIN_EV_VCPU_SYSCALL_RET; - if (!test_bit(ev, cpu->plugin_state->event_mask)) { + if (!test_bit(ev, cpu->accel->plugin_state->event_mask)) { return; }