From patchwork Mon May 6 12:37:12 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: 795004 Delivered-To: patch@linaro.org Received: by 2002:adf:a453:0:b0:34e:ceec:bfcd with SMTP id e19csp901571wra; Mon, 6 May 2024 05:39:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLN04IJ3Zxf36NRJOkOd6xxUsRuh44WgPT+JSSjx50EZqfvEAvJefZGLKV+57jvC/Xd/pW/Rnnc+GW47iUKoDk X-Google-Smtp-Source: AGHT+IGaoeSbQBR6sXWtPlOqqoPwpNEaGe63J+svlQNBW9hKbNtAPoGpPXZ1nl8Nu0A+x8wwAyiX X-Received: by 2002:a05:6808:2212:b0:3c8:63a6:eb4c with SMTP id bd18-20020a056808221200b003c863a6eb4cmr13782691oib.43.1714999188168; Mon, 06 May 2024 05:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714999188; cv=none; d=google.com; s=arc-20160816; b=wDWyfU3zBNYfzD1Tz5hGFYa0V+dV6JUtfxRKn7vwkLhMZWNlQmTIHjHRmcPkOCNOZ3 Av8D669dubEuyhAdVJXnMiabw+r+XqjELTK6Ov3OlVBJFAbdthNELW4SSogh2RYTn3U0 LztbZtnqNH9GhvLaCAW2TNyQfHuHECJRxyMoFjVZN+0yWnGn1ru63KtJXixd8OLZANIk 9UHorBvT1ImksLliC7LGZgGdGqJur7x5Jjh3u2yCXtSBhlosL6fw+baD2Qa1aEMlno4f shDCof9Wed6b5T/VRXwdjmN7zPhMyiENVSLjRLLeA4p+vdKKvjirvd6cutAXnVK14Gu1 wv5Q== 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=2P2Lp6Z6ney+zSdOdvmSI8h/fve28/uqRuYWe+tRCYc=; fh=qtn8prgQtzf5IzCNvLChUZDElvNECP6ej9YfjQeBz3I=; b=q8sBQZRKTU/y5E8V/YcpKl8Hsi1kV3Ks+/A0quCY9g0vmAyu1ALSjxvLfv/Z4OtQl1 St7soQBDDhXBqu9LtZUAjgSi4NxHCjOZbkHabc9xvNuPDPPKXOhcazVvZTbZmeNQ3GF9 QNeRdSiByAf3y8c6R9eFI9Iwv6jNjTw1Rnwp2RNUFLrT34TMn3uCM2QGf9lqkx3Q2uCq ATAosGdvFKt92iSWRcH1Uk5elzNTX56ri6t9PZMn+XIt46Zgd6AumK5VvieAGrAuZonu 98tBDNX5Z4FtExUdtQ3iD/ZomGeM6tGoL1bwtGJl2v21dD/ZTh1zA8/MG8g4g91hIIO/ W3mg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tXlWHPcH; 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 gv12-20020a056214262c00b006a0cb4e4c47si8830457qvb.590.2024.05.06.05.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2024 05:39:48 -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=tXlWHPcH; 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 1s3xcw-0004Fm-3m; Mon, 06 May 2024 08:39:30 -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 1s3xcW-0002QI-5s for qemu-devel@nongnu.org; Mon, 06 May 2024 08:39:04 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3xcT-00025Y-AW for qemu-devel@nongnu.org; Mon, 06 May 2024 08:39:03 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-34d8d11a523so860204f8f.2 for ; Mon, 06 May 2024 05:38:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714999138; x=1715603938; 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=2P2Lp6Z6ney+zSdOdvmSI8h/fve28/uqRuYWe+tRCYc=; b=tXlWHPcHhzVz4qJYEFJhFI0bYhRwNL1uCBON+XwQKj5VUy1EfGM2nDOoJdnqPeHfe6 2YZQH5wLHkI+wW5dIzmsIe0vhaSqp+YMkMBEafcHTw6S3r2OtvB6C1/f3Q79kJixk0BU w5xx+g92psGhJbMprGQkkJ5FL8r4VrKnI5UH7itQyLQrB0xQycXY6n3dWbPD7yallA2g SBjqkbjhf36LD6kYrxyuNHVL4CQLgi/6bgV3zwdF4BaBxhIglAO8/9b0loRc6CDW9wLc Y2pOoj3lVdPf+a6mR/m6bc0d4y9Seh2gVvcsSZTq8TIQ5Pk2sVWDpPBmzarVzBp3yjgm SR/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714999138; x=1715603938; 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=2P2Lp6Z6ney+zSdOdvmSI8h/fve28/uqRuYWe+tRCYc=; b=jzMIkQkjUE9ugUZ2915aVlzX04jy1mQf5VnTYEj61QuSFmXkWhHNwlficx6BOmGl4o +SmEsUnVYKZLizOWuj1TYnTaO67jqJrdXCUvVXHqLdSH93yPapykCT/6k1/N+RVMUAsJ r2IX1DrOflBWupMkLdUIlF/KZ4aJFOhHH9d7kOfsuv72RilAo10/boREbCpGSK6mfniu naqiS70gp0kHZ0DYgAsV8UwQ6vxElJ8n9oBcBhcd4+XLE+wch01NcBfDXbcvb+GBa0Le IapM/G9HO+HaFrTsDLG28ZGcUx3LxZ3XNlmzk4JHj58RP8LDzaQxEdNLPtjA1XRW7Dmh bKzQ== X-Gm-Message-State: AOJu0YzlvjktS3yA4NDzZUeASNPi+YSq9sateuSF2POJBd4+FmDT0Aqj Bq4QP+JiyErAd5N0Rerg2FekKezBVMXZNTxoreAB40x+FlC6fr5gGt+zCGfMqwuTjkOov/Yeb3A 9 X-Received: by 2002:a5d:6a83:0:b0:34c:c4fe:63d with SMTP id s3-20020a5d6a83000000b0034cc4fe063dmr7072541wru.29.1714999138632; Mon, 06 May 2024 05:38:58 -0700 (PDT) Received: from m1x-phil.lan ([176.187.211.4]) by smtp.gmail.com with ESMTPSA id n15-20020adff08f000000b00343eac2acc4sm10630140wro.111.2024.05.06.05.38.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 May 2024 05:38:58 -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 12/28] accel/tcg: Move @plugin_mem_cbs from CPUState to CPUNegativeOffsetState Date: Mon, 6 May 2024 14:37:12 +0200 Message-ID: <20240506123728.65278-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240506123728.65278-1-philmd@linaro.org> References: <20240506123728.65278-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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_mem_cbs is accessed by tcg generated code, move it to CPUNegativeOffsetState. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Message-Id: <20240429213050.55177-4-philmd@linaro.org> --- accel/tcg/internal-common.h | 2 +- include/hw/core/cpu.h | 13 +++++++------ include/qemu/plugin.h | 2 +- accel/tcg/plugin-gen.c | 6 +++--- plugins/core.c | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h index cbeff39e3e..cff43d221b 100644 --- a/accel/tcg/internal-common.h +++ b/accel/tcg/internal-common.h @@ -35,7 +35,7 @@ static inline bool cpu_in_serial_context(CPUState *cs) static inline bool cpu_plugin_mem_cbs_enabled(const CPUState *cpu) { #ifdef CONFIG_PLUGIN - return !!cpu->plugin_mem_cbs; + return !!cpu->neg.plugin_mem_cbs; #else return false; #endif diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a001bafcf8..6efd7353be 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -342,9 +342,16 @@ typedef union IcountDecr { * CPUNegativeOffsetState: Elements of CPUState most efficiently accessed * from CPUArchState, via small negative offsets. * @can_do_io: True if memory-mapped IO is allowed. + * @plugin_mem_cbs: active plugin memory callbacks */ typedef struct CPUNegativeOffsetState { CPUTLB tlb; +#ifdef CONFIG_PLUGIN + /* + * The callback pointer are accessed via TCG (see gen_empty_mem_helper). + */ + GArray *plugin_mem_cbs; +#endif IcountDecr icount_decr; bool can_do_io; } CPUNegativeOffsetState; @@ -416,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_mem_cbs: active plugin memory callbacks * @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 @@ -511,11 +517,6 @@ struct CPUState { QemuLockCnt in_ioctl_lock; #ifdef CONFIG_PLUGIN - /* - * The callback pointer stays in the main CPUState as it is - * accessed via TCG (see gen_empty_mem_helper). - */ - GArray *plugin_mem_cbs; CPUPluginState *plugin_state; #endif diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 18062528c1..b535bfd5de 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -180,7 +180,7 @@ void qemu_plugin_add_dyn_cb_arr(GArray *arr); static inline void qemu_plugin_disable_mem_helpers(CPUState *cpu) { - cpu->plugin_mem_cbs = NULL; + cpu->neg.plugin_mem_cbs = NULL; } /** diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 3db74ae9bf..49f5d1c2e4 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -55,7 +55,7 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, * Tracking memory accesses performed from helpers requires extra work. * If an instruction is emulated with helpers, we do two things: * (1) copy the CB descriptors, and keep track of it so that they can be - * freed later on, and (2) point CPUState.plugin_mem_cbs to the + * freed later on, and (2) point CPUState.neg.plugin_mem_cbs to the * descriptors, so that we can read them at run-time * (i.e. when the helper executes). * This run-time access is performed from qemu_plugin_vcpu_mem_cb. @@ -90,14 +90,14 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - + offsetof(CPUState, neg.plugin_mem_cbs) - offsetof(ArchCPU, env)); } static void gen_disable_mem_helper(void) { tcg_gen_st_ptr(tcg_constant_ptr(0), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - + offsetof(CPUState, neg.plugin_mem_cbs) - offsetof(ArchCPU, env)); } diff --git a/plugins/core.c b/plugins/core.c index 081323dafc..1e58a57bf1 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -533,7 +533,7 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { - GArray *arr = cpu->plugin_mem_cbs; + GArray *arr = cpu->neg.plugin_mem_cbs; size_t i; if (arr == NULL) {