From patchwork Tue May 14 17:42:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 796744 Delivered-To: patch@linaro.org Received: by 2002:a5d:452e:0:b0:34e:ceec:bfcd with SMTP id j14csp2611040wra; Tue, 14 May 2024 10:44:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW4KshbmZZwMr/5wABc0g1oDH8yOTR0eycJZpD4k4kffDESsreRl1GnmNqn55qCk715HIDuJWO2xjT+Dzz4KXP/ X-Google-Smtp-Source: AGHT+IENPFt87WtA+XZphzvXqxOyitezekjkEmT49yxeQIHqdbSG7k6yE/hkddbvCakbJrmEOu+3 X-Received: by 2002:a05:622a:105:b0:43d:e8cb:e283 with SMTP id d75a77b69052e-43dfd9e0345mr161304471cf.0.1715708642241; Tue, 14 May 2024 10:44:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1715708642; cv=none; d=google.com; s=arc-20160816; b=VWXbGVxEA4coMs9uG7UcOaFUMeG3FLnBOtprQBr8uuCNoIZVI5b8ZnPkpao+ShCtp5 3bqfdTz+lW2Cl/4yaarBAOR6dw7Wx8k1HQLVMVGGiXwySEdc8syimMO1XD494VZX7u5+ Na7NZp6H1mBU/l6ZyU1srpUIjj752pi9iI77ZLQzoPIgfIkHatbMtdVWN08D34Ki1xpD qgsxFR0lW/tAw9Y1cnhIXB+uG5MwhD4QTNKaiIsBQR5rFO/C6jNSaz/ul0DqJaiNChrM dNrdrpV5RuDefnI9/9/TgJZXU4+45hmBgx4hY2WPK6aqKqvrLAsJ856JsvrWIRGAqCrm nBLQ== 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=twX/8e3VB4vFn+Ywb8v/U/pjCAfPckcQOZEEgaIZtXs=; fh=AUhhMvfuqYV1WD/1Jx7Q0Z0LnvlruScCfdPWYDT2uE8=; b=GHgcKpjn36beBO2POmFS1h6jnSpjZJBk94H9fC7lPUMIDf6evCN3EmKZSSMl8iNhgC pcYIofUl8pqcZq1XQJeL0blBbDq2LIsteZSwM/33zM/iI+4C97Ld5Sf0l6hGW3Z90wPP JeCbchL7xfs8lESN9iVBUMHBtEqY7sHkWxizatS4pAACKS7fpSCdpzldT4aK4RAJYi2B edeg+Cs2qF5xjrzuBE5g/RuZ3nczRebDdg3msJVIAEGtpnuGkI3iD2r0sZmGUbaGvjI6 0T5AU//ZVrfZCRZPPRlU0u2q0KM7LvorzNG3p9qYzvq6vmExnUyfALDW+CREvoVXuOqH R0Ow==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lnin70D6; 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 d75a77b69052e-43df549c742si122429591cf.119.2024.05.14.10.44.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 May 2024 10:44:02 -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=Lnin70D6; 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 1s6wBq-00050d-LF; Tue, 14 May 2024 13:43:50 -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 1s6wBY-0004s3-8v for qemu-devel@nongnu.org; Tue, 14 May 2024 13:43:39 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s6wBH-0004td-8X for qemu-devel@nongnu.org; Tue, 14 May 2024 13:43:24 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-56e69888a36so545771a12.3 for ; Tue, 14 May 2024 10:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715708578; x=1716313378; 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=twX/8e3VB4vFn+Ywb8v/U/pjCAfPckcQOZEEgaIZtXs=; b=Lnin70D690uYXX73jV5V8DKsFcZiZEOwc2XmpzfPPmtgTDW+YY1O0vsDJUbabfsn8E TC/a//OFE8wwiOdRSM2WFzT4lVCww+9OgfqFB1Sq7xw/LdtN2aaCdNkI0uVPEYErH0iQ 3+pGFI+yZx1UmRikp6HNZaVp0qEdUWW4T99KG28vqtlbej4SfXaeDcoVe5uq2FflaPpQ AHIcLl4Qcd3Korw1Y4e2ZhI6Hx/CT0qFaGI3kVJXOs0DhPLZLR2tgcJNQpyuoQG1UR06 D6gzLrtV9lQkWvcB59uHcyXE4M4WkRUMHdW4VCLn7uIbuTvMjy1zjxs8vBX3iMWBLv/L pNNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715708578; x=1716313378; 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=twX/8e3VB4vFn+Ywb8v/U/pjCAfPckcQOZEEgaIZtXs=; b=wYbLcP229itou4MPXH33YWHOvzkBJQbEbJ5nvMztDsMDHXCVq07Pb7+HDEDbpQlFFp svCwTMApuKe9DYnavnhJ+Uv+tVCKc80ulbQBlb9dvKsLPvVGpybi5yQwAXuf4WhknxM6 N2MGqhKv+PneXyCUFTzDonA8H0lQzCICdzZqNDBjq0ZC8kDQ/tL3KAwzdb8nzVGNLnaw p5dV3x1i5vGhTcanTkqx7UwZits4/Yjlo+LbMDlHSv6Ea81VH+0NXf0X6tLyMp3ry78f OC5Z48+TFxBZV2NatT7qDFh0F/zx1mgH/xQ389PpROPoTS2YrsdBaVmrRvAFcqoqbrke NiPQ== X-Gm-Message-State: AOJu0YwWX75ynRq8RN5qi8/CEBiD/pfN4XZMXctfF9LQscoqfLzeEr6I sALDC+4TgJ8eHfuIvCMvXF/h5AWL66rt0GzfR+QYu1ffqym1Ql/lWWn9/vMj/h4= X-Received: by 2002:a50:aa94:0:b0:572:a731:dd14 with SMTP id 4fb4d7f45d1cf-5734d6edacemr9923609a12.28.1715708578095; Tue, 14 May 2024 10:42:58 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-574d8f5501esm1666982a12.75.2024.05.14.10.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 10:42:56 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 4D8C45FA1B; Tue, 14 May 2024 18:42:54 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , qemu-arm@nongnu.org, Richard Henderson , Alexandre Iooss , Pierrick Bouvier , Cornelia Huck , Peter Maydell , "Michael S. Tsirkin" , Mahmoud Mandour Subject: [PATCH 04/11] plugins: extract generate ptr for qemu_plugin_u64 Date: Tue, 14 May 2024 18:42:46 +0100 Message-Id: <20240514174253.694591-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240514174253.694591-1-alex.bennee@linaro.org> References: <20240514174253.694591-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x529.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 From: Pierrick Bouvier Plugin operations can access a scoreboard. This function factorizes code generation for accessing entry associated to a given vcpu. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier Message-Id: <20240502211522.346467-3-pierrick.bouvier@linaro.org> Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- accel/tcg/plugin-gen.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 4069d51daf..97868781fe 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -113,24 +113,33 @@ static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_i32(cpu_index); } -static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 entry) { - GArray *arr = cb->inline_insn.entry.score->data; - size_t offset = cb->inline_insn.entry.offset; - TCGv_i32 cpu_index = tcg_temp_ebb_new_i32(); - TCGv_i64 val = tcg_temp_ebb_new_i64(); TCGv_ptr ptr = tcg_temp_ebb_new_ptr(); + GArray *arr = entry.score->data; + 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)); - tcg_gen_muli_i32(cpu_index, cpu_index, g_array_get_element_size(arr)); + tcg_gen_muli_i32(cpu_index, cpu_index, entry_size); tcg_gen_ext_i32_ptr(ptr, cpu_index); tcg_temp_free_i32(cpu_index); + tcg_gen_addi_ptr(ptr, ptr, (intptr_t) base_ptr); + + return ptr; +} + +static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val = tcg_temp_ebb_new_i64(); - tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); - tcg_gen_ld_i64(val, ptr, offset); + tcg_gen_ld_i64(val, ptr, 0); tcg_gen_addi_i64(val, val, cb->inline_insn.imm); - tcg_gen_st_i64(val, ptr, offset); + tcg_gen_st_i64(val, ptr, 0); tcg_temp_free_i64(val); tcg_temp_free_ptr(ptr);