From patchwork Tue Apr 30 12:27:57 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: 793314 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp231326wrf; Tue, 30 Apr 2024 05:30:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVg+STskuxekSl7EMy/nvmNsgYJWimdE1jFIMsJF3I2Z8qqP/jLpYEwSbNI8VjMtmfBN+43oqk0V+kZWFlBWVcI X-Google-Smtp-Source: AGHT+IFMXBqA02TBMYHgdoBqKTrvW3InW/3RS7Bue/PYXPQm49hBxCk3/4OviN24fGNJtBSwZv5K X-Received: by 2002:a05:6870:7b52:b0:233:1901:7523 with SMTP id ji18-20020a0568707b5200b0023319017523mr14603458oab.55.1714480230574; Tue, 30 Apr 2024 05:30:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714480230; cv=none; d=google.com; s=arc-20160816; b=rKcu5C7eBOo47mNTDSwFRaC8oJSuUdnt0rtG/bq1FjcIVnsAdyvtlZkHV9RHfRM9Fm POWjy4TyPnv/BQsZn+WYJYYHJ+PpUildm+EmHSOoY7JzlqKllPGHUYE7B1f8K0XxmrlB uSGX6yuNvceiYoXE6CjqTLB5jZzQoJ4dkF1bDzp/D2a9SiIpwVRMAmlJ8I5sn0vu957C jM3rYPpoafayv32G//RHYMxJUbbJpMQAS99W0Uza5YXvr8maYhPuhfE7wh/4g3aPodM4 m3Panuq/nwA28bZWSYmAeFXF1okfpFl8oSxmswbZWDZoUbLAY09kwzZ5e+lS8OjNDjCX ygoA== 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=Hkxy+q36ycHAd+y0qweEznlxDOkt7GiSqjsKlga6SbM=; fh=FpicyC1Jz/v4a6LtO5q/pqWquDN+5u5L8HIupeq3rHw=; b=jke0RPSDVoCq/pPgjaJKgYoANzXsrzlbvpCOcstPYwUDCE767vMGon9w+nI2ZgOCQW o8MBBX68q6LzmlUN70d+t0r+wKQAADA3V0yeKbQmMpm6zH+8sLWjOnASgcHR9Y3+xQY+ oUiAk2RL1re/8YPjr7vEnAQrGIy/YpZHqPjI3mAqiZ+BUECuL1+OFD6mxBdWjhxKYgPX mUQ1mj8M6h2FmPMI0w0xwv+AsuTgMz07RPmbxk+EXIYU6nKicva+x1bopkqpBoYaTz+Q 05+3F5jF5LVO5QsBitts3HVN/XJ7shWWmaNPgdPlNovej60T9llRT66tybnqpqZypaO2 Rxcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cmkkvxko; 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 m4-20020a05620a214400b00790f59d6844si4446453qkm.660.2024.04.30.05.30.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 05:30:30 -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=cmkkvxko; 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 1s1mb4-0006EX-EX; Tue, 30 Apr 2024 08:28:34 -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 1s1mb2-0006EG-IM for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:28:32 -0400 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1mb0-0001ls-SZ for qemu-devel@nongnu.org; Tue, 30 Apr 2024 08:28:32 -0400 Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-56e56ee8d5cso7145780a12.2 for ; Tue, 30 Apr 2024 05:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714480108; x=1715084908; 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=Hkxy+q36ycHAd+y0qweEznlxDOkt7GiSqjsKlga6SbM=; b=cmkkvxkor0QS3ssLiEzPKl2uhhizZ/NIxWUKRiHMN2YzdpCbPa2ilEpCD4dA+MfOqX aXAdZbPhynmzGEkwK+HfJ0nnTpfYXx0cfkr+F9C05dgtB/TYKn5ZMgffPpu0hJnl2eb9 B7wYfI1A4qobU+H+x428EK+G9aUAkTnjVV264zfjWTz/ElHlSxQ5qtr7PHwyhOWnJNuD Qc/56lO6BcQmpRxmOi+b/7KQJLC50hCSGo6HGuM0q9u8he/bbj3bpTL7TuHuo9jAOhfQ AcbQH1yikv510wJvUtqjE+rtPcJripB1yooVjH8qrplEAN7dIOzYtKVT/b4d31Sla/ve +F3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714480108; x=1715084908; 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=Hkxy+q36ycHAd+y0qweEznlxDOkt7GiSqjsKlga6SbM=; b=qYKij0WQOLhWwEUYhg4I23rYdvJaROxSCx7kYSIJN/rdqUp5qaNhOiNgcUVdjCMjvR k1n27bV2wxjSYZpdUQEMOIApKIonbKR2IIAgWSyY3mdgjEGX+LolBzhXAIckz+hJJIH6 2ALkV/zyCymGSp7vgczyRyAdBKn4pBnjwEN51+VEpxwAwvvMuPueu10C5OMaqIgFNW6i ZrKlUbQC0hMF2Zq7mpDuIpYdJLNeu/9p0TMBZCnKgHUgfRrYZ7PY4HfhMyQhtGTJ42Mk qhC6iWop0kpykVE9nsu3f9B2V6IsXRli49j+EDSFYNK8riWDaU8MK+U39yWrsLvwPFWW TYlQ== X-Gm-Message-State: AOJu0YxxHpcyXPv7v+62carwitgz1BnmpZykG19pnn2sC7Z5kaGIG5sp XaTY5q21vrkzQzFYSRTdrSTzxjYY90iffxbDcwfhZcS9yP5H86DF52nWa6rHaYyZBPIwQbdFVVt g X-Received: by 2002:a17:906:414:b0:a55:bd8e:b6ef with SMTP id d20-20020a170906041400b00a55bd8eb6efmr8786834eja.37.1714480107781; Tue, 30 Apr 2024 05:28:27 -0700 (PDT) Received: from m1x-phil.lan (mab78-h01-176-184-55-179.dsl.sta.abo.bbox.fr. [176.184.55.179]) by smtp.gmail.com with ESMTPSA id h26-20020a17090619da00b00a588729de82sm8190841ejd.142.2024.04.30.05.28.26 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 30 Apr 2024 05:28:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Anton Johansson , Ilya Leoshkevich , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= Subject: [PATCH v3 03/13] accel/tcg: Move @plugin_mem_cbs from CPUState to CPUNegativeOffsetState Date: Tue, 30 Apr 2024 14:27:57 +0200 Message-ID: <20240430122808.72025-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240430122808.72025-1-philmd@linaro.org> References: <20240430122808.72025-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::535; envelope-from=philmd@linaro.org; helo=mail-ed1-x535.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 | 5 +++-- plugins/core.c | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h index 5061687900..867426500f 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 55555be618..571ef3e514 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 @@ -509,11 +515,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 41db748eda..99a32446e9 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -229,7 +229,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 cd78ef94a1..fd268c79b5 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -178,7 +178,7 @@ static void gen_empty_mem_helper(void) TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); tcg_gen_movi_ptr(ptr, 0); - tcg_gen_st_ptr(ptr, tcg_env, offsetof(CPUState, plugin_mem_cbs) - + tcg_gen_st_ptr(ptr, tcg_env, offsetof(CPUState, neg.plugin_mem_cbs) - offsetof(ArchCPU, env)); tcg_temp_free_ptr(ptr); } @@ -634,7 +634,8 @@ void plugin_gen_disable_mem_helpers(void) return; } tcg_gen_st_ptr(tcg_constant_ptr(NULL), tcg_env, - offsetof(CPUState, plugin_mem_cbs) - offsetof(ArchCPU, env)); + offsetof(CPUState, neg.plugin_mem_cbs) - + offsetof(ArchCPU, env)); } static void plugin_gen_tb_udata(const struct qemu_plugin_tb *ptb, diff --git a/plugins/core.c b/plugins/core.c index 09c98382f5..a097d02788 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -496,7 +496,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) {