From patchwork Thu May 2 18:08:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 794128 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp388023wrr; Thu, 2 May 2024 11:10:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU7Ki9czp+bzP2Bu0Js7/v9Sp1avPHzYq2sKYfdxsSMDZq0lBdTkQrJuJ6GFXEMSgjAgTwfH+Jlujs9ifVIxQkP X-Google-Smtp-Source: AGHT+IF9XKdU8IkwL85hH8ZXvtCK1xwAbeYJ4dwASbxQdOvE1z9g9cmaYetQqiZ+VLyKUuB3xaN/ X-Received: by 2002:a05:6102:3bca:b0:47e:f475:940a with SMTP id a10-20020a0561023bca00b0047ef475940amr439364vsv.34.1714673433190; Thu, 02 May 2024 11:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714673433; cv=none; d=google.com; s=arc-20160816; b=gSgk2+ibYm5ohGnYi4nIe7LBUvR0qaM2uWGnHV5AC0hrRp3L0GuYNMgXdMZTOga4ue pUikeVfMoVBq2rEudrw6WvRzWMbmeNXHsYsHFZsOkdJBLxRczXtlVpqV45z1C8RtI3OE Xk3bZJ55Q3i+0a/EWRUH6cdHX9H6+uHnGVZ8abP/DdSZQz021o0WhRW7GEsEwzcAZkkG pZ2tMZ6+iPANqcAb5Wvmr+sE0jdn2kjvj3S883WS51fvGn5OUrMqz+BLGWZgWzCs+3n/ an5kZ5dIqPtwrqPJYBqbDn2EabOobnwEbjC1AY4xkphE/WA3u0rui55T9tKvG2EjJaDN AmDw== 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=6rrkhscyYuczfAUwr3Y8eSiiztQ7d4sdBk9KEUj+ldE=; fh=cGQQHKa+VmgbxLLxTvBCsw0Hx1TzppraI5gmJtpkFxg=; b=t7ZMFU+hBhDxg0yQ9k3MmLWjDofTes8+KfgJzIygxXjPDLXnA4AKdVl+ehJf1f8i6q sK9snj+zyzTCFSqqCCI4I6wbBAnfDNX858dCLrZY/s4bvvyuuLP90f9ISqAWLznRvWZ2 hDoK0jpkajqD3FG1SV7gc1j4m+L4wLScrbjcTmCGzNEUuKcHfy5dlxHxPn7SFzeyBJwy yGJBA/YZnsy7WSs/pLp0xNtInDFyBlc1Gsywgb140ZbqzL/Wr5aAqDtBsNCQwz2MRoTN T1sjtxBtJfr2m11zDQHN2700UbueQXmVwYyXCVGe8+SS/Q4JKLPIzx4xLWzcDDuWLzld 0Adg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gV9HJwsw; 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 k14-20020a67f60e000000b0047c380df5afsi349354vso.57.2024.05.02.11.10.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 11:10:33 -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=gV9HJwsw; 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 1s2as7-0003Ia-R1; Thu, 02 May 2024 14:09:31 -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 1s2arp-0003Cq-Qc for qemu-devel@nongnu.org; Thu, 02 May 2024 14:09:14 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2arn-0003RS-3s for qemu-devel@nongnu.org; Thu, 02 May 2024 14:09:13 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1ec41d82b8bso33054315ad.2 for ; Thu, 02 May 2024 11:09:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714673348; x=1715278148; 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=6rrkhscyYuczfAUwr3Y8eSiiztQ7d4sdBk9KEUj+ldE=; b=gV9HJwswEod0g/ro7cNJ7Ycc9BgoYXFVGvuY75ary0g9UBgLyT2gMyysLxnQ6XtowU TGe9NzTZiNQtFKxPixK+Ur5+4uK2dO0mzFPquKjyVM+InZnWHX2y8ekv+lFVnAhIu0bJ f87hnXUmP8mlU6gLuHtK/QpPVlfqdlth3J87+g+IRE9zAz1SIGjYGR7ThMFvMGilKeBm leD4/PArDZMuIyD4iym4Ke42JqDX5R1W8VIVZc7hciOU+W7+1xJ09gZnbt4dH4DDEB1I lN7+YAgtme7IWv1gNXrC5iUewMErnW7edixd4eDkKDVc/BU9O0W4+AaY7chKemsikWlD l3nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714673348; x=1715278148; 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=6rrkhscyYuczfAUwr3Y8eSiiztQ7d4sdBk9KEUj+ldE=; b=NFb23505bt7zg26Q/lQ5jeyNzywVXKxJq0zt/9PpDXFoZL3mME1i983QAZ+qEcBoRP fsDTLIF28QgWvWoZhl5vEBWwLyg5JWZzmR3xZz5h/tX8m7kbHVglTxs6FdYcy9KpZ4lU Z4cPDDutBSKYpC/DA91ogmxS/e2YgQDEnqApeMo/gRPiZ1JVcta0mVF4169DDrpLec0l hVuM9KeRE/rvkJLUy0eVid/g5A4VjhhNbqIVLvZ2rFeI3YxrzTZbXfUw5xeqU7C96aYq qZMPCtV2+IbDVfeY2rSxhmJ8n3fEE2TU+XOK6aH5dG74MxwpWDzHu2iTpU0DAB+l5A3w 7/1Q== X-Gm-Message-State: AOJu0YwwNKYyBQptjaMSkD5iKewYB9XvaQ5HJJ4aN3l7CraOkRVzudt2 NCkZA5kaLfhgGH2C18be9jTI+OPPdvnBh9ELNQhcaR8TTggh/iZ6QjRRPEQlYbkr1IqPp8O2nwl 17Ek= X-Received: by 2002:a17:902:ce87:b0:1e0:983c:d686 with SMTP id f7-20020a170902ce8700b001e0983cd686mr583932plg.20.1714673348270; Thu, 02 May 2024 11:09:08 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::ecd0]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001ebd73f61fcsm1615605plg.121.2024.05.02.11.09.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 11:09:07 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mahmoud Mandour , Richard Henderson , Alexandre Iooss , Paolo Bonzini Subject: [PATCH v5 8/9] plugins: extract cpu_index generate Date: Thu, 2 May 2024 11:08:46 -0700 Message-Id: <20240502180847.287673-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240502180847.287673-1-pierrick.bouvier@linaro.org> References: <20240502180847.287673-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62c.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 Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b829a959398..7b73520e788 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -101,12 +101,17 @@ static void gen_disable_mem_helper(void) offsetof(ArchCPU, env)); } +static TCGv_i32 gen_cpu_index(void) +{ + TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + return cpu_index; +} + static void gen_udata_cb(struct qemu_plugin_regular_cb *cb) { - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + TCGv_i32 cpu_index = gen_cpu_index(); tcg_gen_call2(cb->f.vcpu_udata, cb->info, NULL, tcgv_i32_temp(cpu_index), tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); @@ -121,9 +126,7 @@ static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 entry) char *base_ptr = arr->data + entry.offset; size_t entry_size = g_array_get_element_size(arr); - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + TCGv_i32 cpu_index = gen_cpu_index(); tcg_gen_muli_i32(cpu_index, cpu_index, entry_size); tcg_gen_ext_i32_ptr(ptr, cpu_index); tcg_temp_free_i32(cpu_index); @@ -156,7 +159,6 @@ static TCGCond plugin_cond_to_tcgcond(enum qemu_plugin_cond cond) static void gen_udata_cond_cb(struct qemu_plugin_conditional_cb *cb) { TCGv_ptr ptr = gen_plugin_u64_ptr(cb->entry); - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGLabel *after_cb = gen_new_label(); @@ -165,15 +167,14 @@ static void gen_udata_cond_cb(struct qemu_plugin_conditional_cb *cb) tcg_gen_ld_i64(val, ptr, 0); tcg_gen_brcondi_i64(cond, val, cb->imm, after_cb); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + TCGv_i32 cpu_index = gen_cpu_index(); tcg_gen_call2(cb->f.vcpu_udata, cb->info, NULL, tcgv_i32_temp(cpu_index), tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + tcg_temp_free_i32(cpu_index); gen_set_label(after_cb); tcg_temp_free_i64(val); - tcg_temp_free_i32(cpu_index); tcg_temp_free_ptr(ptr); } @@ -203,10 +204,7 @@ static void gen_inline_store_u64_cb(struct qemu_plugin_inline_cb *cb) static void gen_mem_cb(struct qemu_plugin_regular_cb *cb, qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) { - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)); + TCGv_i32 cpu_index = gen_cpu_index(); tcg_gen_call4(cb->f.vcpu_mem, cb->info, NULL, tcgv_i32_temp(cpu_index), tcgv_i32_temp(tcg_constant_i32(meminfo)),