From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456534; cv=none; d=zohomail.com; s=zohoarc; b=X3DSUDoAyL8/rxYZ/nfQ7dk728NGLhBdooDZaxehihtQyqBLYZUJdQU2QwUhTQ+KTH+6bSLHJ544gbiHZhexi/EZ9ZpRQvGqa7U+K2pYIoju/9UMZVJgNGK6sFuLc5VWjUFN322H+rmptXhCFU1nEQnL+jo6+Bje8cVhkwn3prI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456534; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jrYhcbQiD/iBdvr35vsxxSuWauM+6gxOSzxNrMmsmbY=; b=QRM84/UiLzIFff7/jK738meR/VzLCuy6UDtmFD389727RWXEzC3eIwg95PjL1FRUG0LPpeiMTyupKUMFgWmQil9oo1CNRXWv95XaAcykzFgM6JG4sThPkIkTFo4WU+r58zdIeb23DhoZrCxdVRQMq6YEQtnpCPoijEr1kIoLCEY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456534258421.93389926508837; Tue, 26 Mar 2024 05:35:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp60w-00057R-Qy; Tue, 26 Mar 2024 08:34: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 1rp60v-00056t-HO for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:49 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp60t-0000dO-WE for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:49 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4148c6af2d3so8335315e9.1 for ; Tue, 26 Mar 2024 05:34:47 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456485; x=1712061285; 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=jrYhcbQiD/iBdvr35vsxxSuWauM+6gxOSzxNrMmsmbY=; b=oe8RA2DVOAn5RiG1nUh+bmU2nGBfsx58517XEvbczx0JHmN0BWatEOL/+Rp/i3IOjt 74K+ZEZWTenfxBGUE2EmYDzC50f5BBpBL7RxlW5hFaqu8IWavRv+75qAvsNU0BeeMuZw M8rwT4KoU/gRjKi+Xzs0d0SvJk/Cn6t+CZ9pFaOiFJQa/TqfpF9JbjrX3XeI8cnBH37w xWCWUE7OmnW4aNxOGvsFuYi7OnVIHMmdj1P9CNFFRVKlI+MQ+DQ7FnO1G1V2pqoyEYgq yDcAiQpnkVwkb4yIk228eEmY5YhNRMGjs7vQgVNHO8odgZ8UoC8DD3NI1w3OKCFr21+5 aFSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456485; x=1712061285; 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=jrYhcbQiD/iBdvr35vsxxSuWauM+6gxOSzxNrMmsmbY=; b=Ao6mALPOWdY4oxCA6aOHRDQKPWTCLnIF3S8tbPn9KdwcwizQhLFHnE/9vJgkwAGY1m 0GW0TiHBSAFSGf2CETvnDitE5QxkL0IxmNZX1GABWDBlze6LJb2sc93I6U2QUEmA4DQ8 lcdwQ0L0wGFXhGOBM2izXrgakQG7qk4EgowdQ5UlOyHkQsfrKY5t2atiQxYhh/EoLu86 qn8Op8RDvhKVnD4VUFcKVsv3bECQXl5hvZxvVUFjqllJRYmqH3VLPJ4xRvIUlkZOKAtE Q4T+jUO6Vf7UBl/v7DPJllul9rI5JFMZU/gR1aFTawPgq3G7wqXwAMl62CEsbomdBL4u imYg== X-Gm-Message-State: AOJu0Yw642NER4cI5dpiK4pGtoDc0/Src9exmS89LNwkSvnNEyQCIRsC DTQzH2YqPv7yHCN7nzrrsXYXm6u/TbrlZk8nl5eH3ITXGtU42AnKEIzWRpeQqkxqqp9k0rpOlC+ /C9w= X-Google-Smtp-Source: AGHT+IFDLHw+bx5jmaOGf7ZDIw7+qBbiykKkHJ4MD+Xltk7GQZqyRLTfXiyMiWsef8C52gJqerd3jg== X-Received: by 2002:a05:600c:2e51:b0:414:250:ccaa with SMTP id q17-20020a05600c2e5100b004140250ccaamr7189953wmf.12.1711456485419; Tue, 26 Mar 2024 05:34:45 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 1/9] plugins: prepare introduction of new inline ops Date: Tue, 26 Mar 2024 16:34:18 +0400 Message-Id: <20240326123426.761473-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x329.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456535810100006 Content-Type: text/plain; charset="utf-8" Until now, only add_u64 was available, and all functions assumed this or were named uniquely. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- include/qemu/plugin.h | 2 +- accel/tcg/plugin-gen.c | 6 +++--- plugins/core.c | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 201889cbeec..23271fbe36a 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -68,7 +68,7 @@ union qemu_plugin_cb_sig { enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, PLUGIN_CB_MEM_REGULAR, - PLUGIN_CB_INLINE, + PLUGIN_CB_INLINE_ADD_U64, }; =20 /* diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index c3548257798..41d4d83f547 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -120,7 +120,7 @@ static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_i32(cpu_index); } =20 -static void gen_inline_cb(struct qemu_plugin_dyn_cb *cb) +static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) { GArray *arr =3D cb->inline_insn.entry.score->data; size_t offset =3D cb->inline_insn.entry.offset; @@ -165,8 +165,8 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb) case PLUGIN_CB_REGULAR: gen_udata_cb(cb); break; - case PLUGIN_CB_INLINE: - gen_inline_cb(cb); + case PLUGIN_CB_INLINE_ADD_U64: + gen_inline_add_u64_cb(cb); break; default: g_assert_not_reached(); diff --git a/plugins/core.c b/plugins/core.c index 0213513ec65..a8557b54ff7 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -316,6 +316,16 @@ static struct qemu_plugin_dyn_cb *plugin_get_dyn_cb(GA= rray **arr) return &g_array_index(cbs, struct qemu_plugin_dyn_cb, cbs->len - 1); } =20 +static enum plugin_dyn_cb_type op_to_cb_type(enum qemu_plugin_op op) +{ + switch (op) { + case QEMU_PLUGIN_INLINE_ADD_U64: + return PLUGIN_CB_INLINE_ADD_U64; + default: + g_assert_not_reached(); + } +} + void plugin_register_inline_op_on_entry(GArray **arr, enum qemu_plugin_mem_rw rw, enum qemu_plugin_op op, @@ -326,7 +336,7 @@ void plugin_register_inline_op_on_entry(GArray **arr, =20 dyn_cb =3D plugin_get_dyn_cb(arr); dyn_cb->userp =3D NULL; - dyn_cb->type =3D PLUGIN_CB_INLINE; + dyn_cb->type =3D op_to_cb_type(op); dyn_cb->rw =3D rw; dyn_cb->inline_insn.entry =3D entry; dyn_cb->inline_insn.op =3D op; @@ -551,7 +561,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi,= rw), vaddr, cb->userp); break; - case PLUGIN_CB_INLINE: + case PLUGIN_CB_INLINE_ADD_U64: exec_inline_op(cb, cpu->cpu_index); break; default: --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456534; cv=none; d=zohomail.com; s=zohoarc; b=gfq+DgxT7VSiV35L/e4N/Oaw/HE9ajfI5eWxlvPtbmAoC/ylMDOlBRuNoWjVfsNPo3a3P2Hb4ZQBMLWd7EtWIOLdcOZUBlnR0uv/Lj8K+olMbsqK1N8sNX7pEpq97OLZr3XFbNqZe2ZFuzbmlktMMIb8l9zuGKtI1WRNqwX7iNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456534; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l7VfVydk8X6xAOfkDzXyCX6+wA+A3zYuyrN3TJWFm9Y=; b=ep4tXmvvRaA9Un23ivH8YQxiaAvPH/fhDQrniRjQok+ypnaCq3Xv30knMB9x5NoD1aie5szV5mXmYIMlJWdPgmCXHUD06z9x7btdlmxV/kyAhHDZMHSWktWLzFb0XVo1iREp390crpb10sVfWHkjOUOLWMkpe5nD6O0y2UmxBZc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171145653445284.44145666872771; Tue, 26 Mar 2024 05:35:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp60z-000583-KW; Tue, 26 Mar 2024 08:34:53 -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 1rp60y-00057h-EE for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:52 -0400 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp60w-0000df-TJ for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:52 -0400 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-513cf9bacf1so7376858e87.0 for ; Tue, 26 Mar 2024 05:34:50 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456489; x=1712061289; 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=l7VfVydk8X6xAOfkDzXyCX6+wA+A3zYuyrN3TJWFm9Y=; b=aD7QolHA2fYhHih+ZVPzNwiZTS7Tw/UZk9BRqX1Gh30alZwBTQaEQfeQRU08LrsfUS at69T6KyXNTZYqUGnogdQg+zleKzHfgJufj+V7AWu2w1vWo8Iih6a1r66wKGMMokNKyn NSq0+3aY5/rd0uAGNZh5rHobpVxFC/colRXzkgcHpkTXHJCf+RJgp+D8PZ2FUbryDlV9 IgUIghPtbzqNR5pMNY9KtUS7rM8mqw/83KApIKHN2izbVdrSB/Lxv2e1o6/Qq/Z5vR+J MUiad68VjsOZfuWeMSDeuy4S/vk22KwMKElQJFZS5eu9saDp4nJGCa9HkbdWa/yivdel fI5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456489; x=1712061289; 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=l7VfVydk8X6xAOfkDzXyCX6+wA+A3zYuyrN3TJWFm9Y=; b=OUayLe+3n53Rnu94y3beXBRUxBsVmS4by5DoyJVlNhsjYcJ5FUv8Gwmxeksyhtr0jj LnBmYXzy+aMixice5//Sl+uZ0cynJeD45spE/xNa3R2trRSVVZ6Spx6EEHx0W3rxl3ZJ J7bKrRFoGO0xxGG5fuNDVaEP1Jk5uDia2030TBX6BEYfOlAQTVX5HMl2AqL5o2bGkJ33 YYHNnpqaIonijR/Fs+dL2OaabM2pXM0H+2cvBT77LXoTWj1+J5/UWfjTcd2AsNn1q8PV diz6+IZXJxiGmgeWr9LRrdZJyL6hUcQ8BWVCoDL4A3nzz4SbWT801rGUsmjkybj4Yro3 45Gg== X-Gm-Message-State: AOJu0YwDxpbvJwKKDGvLFWBAivCgNluKK5gbUxYF/I7EKJb4PNZcZESA faH3EzdCvQcOy0gWP1nW4XtSjkSdLb7NMi5uq8+776/nWEugeq+JHx3GTq3lp9wIk0PaPAPjMrY Sqr8= X-Google-Smtp-Source: AGHT+IHWDELf7Ew47iLifPnlmiFC5ibXSsMMmbkiLZLtVNeDz6sd73naskKontGTgFebu3NTrS/Xng== X-Received: by 2002:a19:5f5a:0:b0:513:af26:8cd0 with SMTP id a26-20020a195f5a000000b00513af268cd0mr5969007lfj.68.1711456488605; Tue, 26 Mar 2024 05:34:48 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 2/9] plugins: extract generate ptr for qemu_plugin_u64 Date: Tue, 26 Mar 2024 16:34:19 +0400 Message-Id: <20240326123426.761473-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x12f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456535808100005 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- 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 41d4d83f547..d3667203546 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -120,24 +120,33 @@ static void gen_udata_cb(struct qemu_plugin_dyn_cb *c= b) tcg_temp_free_i32(cpu_index); } =20 -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 =3D cb->inline_insn.entry.score->data; - size_t offset =3D cb->inline_insn.entry.offset; - TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); - TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGv_ptr ptr =3D tcg_temp_ebb_new_ptr(); =20 + GArray *arr =3D entry.score->data; + char *base_ptr =3D arr->data + entry.offset; + size_t entry_size =3D g_array_get_element_size(arr); + + TCGv_i32 cpu_index =3D 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); =20 - tcg_gen_addi_ptr(ptr, ptr, (intptr_t)arr->data); - tcg_gen_ld_i64(val, ptr, offset); + return ptr; +} + +static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val =3D tcg_temp_ebb_new_i64(); + + 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); =20 tcg_temp_free_i64(val); tcg_temp_free_ptr(ptr); --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456584; cv=none; d=zohomail.com; s=zohoarc; b=SC8dD4PG9fqBWjQ+Ecw+1iAgeZEhD6ayt922ELu6YY/bLOfYotxsNdIOGGpd5Gs/baB35zF9s7EcGidtpYSziKgMBFNdguXk6ifPKE9Avs2T1E9xcdpcIMt73Rp61bd6piLPD82HccChPzc5AASAuG99wjL8e+IF+iGlf/YqpIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456584; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IJYNwNm35V5xzu7ic8glr0yVgOLlUO7V69uiN6b/dLQ=; b=lLrdv+62IA5dZ4IIo6rQVMz/SlGwA1HiuZRVsbPBiYu9+5/D08U8VDCS6jWX73tvs3tSl4yQSe/bshFBrWKqRrE+kxRAaF9wMuVvi6OazYsk4plxaJP4pGZGWh63q02imhactbPXC1LEruKuZFwYiVUjDnHAMbjqp5skLFeOYXA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456584069920.1332190874443; Tue, 26 Mar 2024 05:36:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp613-0005BP-OC; Tue, 26 Mar 2024 08:34:57 -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 1rp612-0005A5-BS for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:56 -0400 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp610-0000e1-Bo for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:55 -0400 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2d4a8bddc21so73417131fa.0 for ; Tue, 26 Mar 2024 05:34:53 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456492; x=1712061292; 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=IJYNwNm35V5xzu7ic8glr0yVgOLlUO7V69uiN6b/dLQ=; b=ImwtXejocYwY03ztl7PcvG+qWx+9sEyjnBtmkQf8mNh782mcjxhbgXY2ToKGqTqyD9 cGDO1Rv9/jtZe++yvJpMy3tCF56yc7XNL5UMsSNsIhte2cGk8HgRJiq29hQRLdVwa6xm iWbz+0Y96kxDPiuwHBFIHxT8AwE/6nD6rsbjJabU+ucfQhr5C+V5OCz7ImbhzfDv5wW7 9/9q0OPBvYTgykZESz4Ul/cXNV5b0xqmtpbiePC2zoey2W8Y8fm3w79D2ePhgIHmMeeH 7BK+x9lagdCHTaYogRt9CcQVuLVN7HGW5H4ZKALi5ml52vIV76t8Wzul+Wzz0HGdZ85s QLRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456492; x=1712061292; 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=IJYNwNm35V5xzu7ic8glr0yVgOLlUO7V69uiN6b/dLQ=; b=kr2YIqhmGvd/xu35X1ALH6m2LPaWw4TZet55Aw85hPczBR5iOEr5v1XlF45rry/4QJ KtyIfczqgc+BLf45FuSwMnFR38U/MOCS/E4PpBE/zuCmz1VgSeRBoHQf9F2OCgjGnyCB bbyhv+n4cyKa4dGk/smJ+MJa20L1oSuCNTUn+eb0LFrqIeyo6JT6kEaeldOBbdTqOR4/ N+Djn74udXwmDmTnfXklAllU8+n1W2asaplx8a6AijX6TjgiINg82b33GWZT3KLR4s1o yBz+IzGymkC6rRcoxGPLIiM2DMpIxGo5pgr8PnTy+j5Ys3D6XFt1HAJE+kbUJAvIXWJp kGmA== X-Gm-Message-State: AOJu0Yy/nbiLhxRKyzbncQuFN2q/Ej49WrwWng10ggNSqnr23mSYWEGr PMUss9dCvh8zzy9GaUkNTf4daJsQ9JGfddRHXX8PF5YbngfCfoabeKy1UdQl0Eo+G8TcXpOqz12 XcEc= X-Google-Smtp-Source: AGHT+IFF+q4pH2dp2GsZ2JARo/2j7Re9ePv1UenxaKmnmjeL/SoIw3pZ+/ICTHBVBikr0xeTX4YDSA== X-Received: by 2002:a2e:9c95:0:b0:2d2:b506:d2cb with SMTP id x21-20020a2e9c95000000b002d2b506d2cbmr7372056lji.9.1711456491775; Tue, 26 Mar 2024 05:34:51 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 3/9] plugins: add new inline op STORE_U64 Date: Tue, 26 Mar 2024 16:34:20 +0400 Message-Id: <20240326123426.761473-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::22a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lj1-x22a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456585943100005 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- include/qemu/plugin.h | 1 + include/qemu/qemu-plugin.h | 4 ++-- accel/tcg/plugin-gen.c | 13 +++++++++++++ plugins/core.c | 6 ++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index 23271fbe36a..d1d9b4490df 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -69,6 +69,7 @@ enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, PLUGIN_CB_MEM_REGULAR, PLUGIN_CB_INLINE_ADD_U64, + PLUGIN_CB_INLINE_STORE_U64, }; =20 /* diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index 4fc6c3739b2..c5cac897a0b 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -305,12 +305,12 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu= _plugin_tb *tb, * enum qemu_plugin_op - describes an inline op * * @QEMU_PLUGIN_INLINE_ADD_U64: add an immediate value uint64_t - * - * Note: currently only a single inline op is supported. + * @QEMU_PLUGIN_INLINE_STORE_U64: store an immediate value uint64_t */ =20 enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, + QEMU_PLUGIN_INLINE_STORE_U64, }; =20 /** diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index d3667203546..1cfd7908df1 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -152,6 +152,16 @@ static void gen_inline_add_u64_cb(struct qemu_plugin_d= yn_cb *cb) tcg_temp_free_ptr(ptr); } =20 +static void gen_inline_store_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val =3D tcg_constant_i64(cb->inline_insn.imm); + + tcg_gen_st_i64(val, ptr, 0); + + tcg_temp_free_ptr(ptr); +} + static void gen_mem_cb(struct qemu_plugin_dyn_cb *cb, qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) { @@ -177,6 +187,9 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb) case PLUGIN_CB_INLINE_ADD_U64: gen_inline_add_u64_cb(cb); break; + case PLUGIN_CB_INLINE_STORE_U64: + gen_inline_store_u64_cb(cb); + break; default: g_assert_not_reached(); } diff --git a/plugins/core.c b/plugins/core.c index a8557b54ff7..e1bf0dc3717 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -321,6 +321,8 @@ static enum plugin_dyn_cb_type op_to_cb_type(enum qemu_= plugin_op op) switch (op) { case QEMU_PLUGIN_INLINE_ADD_U64: return PLUGIN_CB_INLINE_ADD_U64; + case QEMU_PLUGIN_INLINE_STORE_U64: + return PLUGIN_CB_INLINE_STORE_U64; default: g_assert_not_reached(); } @@ -535,6 +537,9 @@ void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int = cpu_index) case QEMU_PLUGIN_INLINE_ADD_U64: *val +=3D cb->inline_insn.imm; break; + case QEMU_PLUGIN_INLINE_STORE_U64: + *val =3D cb->inline_insn.imm; + break; default: g_assert_not_reached(); } @@ -562,6 +567,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, vaddr, cb->userp); break; case PLUGIN_CB_INLINE_ADD_U64: + case PLUGIN_CB_INLINE_STORE_U64: exec_inline_op(cb, cpu->cpu_index); break; default: --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456605; cv=none; d=zohomail.com; s=zohoarc; b=UyZ55W0ltt0zSzroKCEC/lkVHP97R3UxJMy+jCai7a5M+LzT54aDQVuW8U2i9G1hwbmxlcQxQ6DcWQCdJSWt3LqFg17OGXEz4P0rtAuRemymgBtZacWSLJxOnqjef52Kxex9tLp1AeZQYzfxbvoBzVX3ACctUq2jG5UYEhJwgm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456605; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; b=MymSJ4fnFxGCtGSaXhKd4thmCXiRU9fKrMzXXLY4SMInyyokyE4uNs6E4kc/AvGR1V4oZD+MDIWMD74GkuzPhQ/4QUPay58jvn+VTTl2QE8+TRtDIxg0aHn+WE2nl1FFGYoO2hqHHY2kSlAB6fiOB42k9ntmxndaHR71eGzDdrY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456605708577.6961575386241; Tue, 26 Mar 2024 05:36:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp617-0005DR-6Q; Tue, 26 Mar 2024 08:35:01 -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 1rp615-0005Ch-Im for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:59 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp613-0000eZ-Ti for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:34:59 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4148c95db1fso7197955e9.0 for ; Tue, 26 Mar 2024 05:34:57 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456495; x=1712061295; 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=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; b=c00uXdl/FGNcBVV+ZiPjpYGXzB/A0gnvulbIYDhwZZlcFz0UqCgH8BbIgJ9zLCLNja idDQ0Qp8ukOGsxDLenEma2e/5GqaPrvS42MbN0xoJLMYD268+Mnz55KrLerdUp0s8YXK gJMhLB05VicuyupTR/vMGoCScR/DjmP0xAq4wjfzyAnzU0FKIAFJn/zcFJGRsBIHsZv5 QzAjPyUX8dO34NM1ldQwA2RduFCRUSdiry0U4H+klKGmPvNtbPyjrT6/dODiHv2Cy259 3VVwlxpWjcZqHI2KMT20GpJOs3SLPie+lu53WkexaqunUUi9s8OyvSq9IVvg0HuN+mjK Hntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456495; x=1712061295; 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=AwiuoqvuZesoeTfyTbR5jyoxVWb/NhK8asPTRiYJ8l0=; b=fw4XYlbcqnzJW4dICKNd4M5Lt4a6OrZDsEcp+gbs22NXN9mCnfxomdun8IVJ3oxMDA VGhP2Nj5D4OUqQQHE0K/R6glnSunTgNmT+oLSGU/dqbVX56xVIeBU9ZQ8YFHkRB9hitX SWRxFdrmwqG/tXDWj0uadqfVrJDBrkpto+bv4q9OABa5Dh1AIwx0+it3QIv+/+s30i3q SXdabtxFUb4Y8fElYliI6ze3j9EmYxtPDREXNeSMNhzFu1Jb263gwHHY0JMmVQEJX/+v yzWNWiIA1n41GNgz97KpHU5zCPj8Aiz6N4CBZEyK8IpxlZD+gfFbBrJKecCifKDjbWmh xn9Q== X-Gm-Message-State: AOJu0YzVFfv4zpIq3HSmtGxd1z4/iDAknz98UAN0+Dl8NcFNsIIlvccz mwt/AYh1QE1Rr/wqk2WW23zjnwxQ9bagQcPVcg0nZcEg9V3yc89817CAVQ+LeBRCHCyhBlsviWF 5Jnc= X-Google-Smtp-Source: AGHT+IHkx0+DUsOaR8kMVa2W/sbstD/b+r8Rk083vyus9EsWo8MnekvA4PnXY8BofnyNGhWKR3TpQQ== X-Received: by 2002:a05:600c:3c94:b0:414:868d:1cbe with SMTP id bg20-20020a05600c3c9400b00414868d1cbemr6324150wmb.9.1711456495035; Tue, 26 Mar 2024 05:34:55 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 4/9] tests/plugin/inline: add test for STORE_U64 inline op Date: Tue, 26 Mar 2024 16:34:21 +0400 Message-Id: <20240326123426.761473-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x331.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456606002100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- tests/plugin/inline.c | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 0163e9b51c5..103c3a22f6e 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -22,6 +22,12 @@ typedef struct { uint64_t count_mem_inline; } CPUCount; =20 +typedef struct { + uint64_t data_insn; + uint64_t data_tb; + uint64_t data_mem; +} CPUData; + static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 count_tb; static qemu_plugin_u64 count_tb_inline; @@ -29,6 +35,10 @@ static qemu_plugin_u64 count_insn; static qemu_plugin_u64 count_insn_inline; static qemu_plugin_u64 count_mem; static qemu_plugin_u64 count_mem_inline; +static struct qemu_plugin_scoreboard *data; +static qemu_plugin_u64 data_insn; +static qemu_plugin_u64 data_tb; +static qemu_plugin_u64 data_mem; =20 static uint64_t global_count_tb; static uint64_t global_count_insn; @@ -109,11 +119,13 @@ static void plugin_exit(qemu_plugin_id_t id, void *ud= ata) stats_mem(); =20 qemu_plugin_scoreboard_free(counts); + qemu_plugin_scoreboard_free(data); } =20 static void vcpu_tb_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_tb, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_tb, cpu_index) =3D=3D (uintptr_t) ud= ata); g_mutex_lock(&tb_lock); max_cpu_index =3D MAX(max_cpu_index, cpu_index); global_count_tb++; @@ -123,6 +135,7 @@ static void vcpu_tb_exec(unsigned int cpu_index, void *= udata) static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_insn, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_insn, cpu_index) =3D=3D (uintptr_t) = udata); g_mutex_lock(&insn_lock); global_count_insn++; g_mutex_unlock(&insn_lock); @@ -131,9 +144,10 @@ static void vcpu_insn_exec(unsigned int cpu_index, voi= d *udata) static void vcpu_mem_access(unsigned int cpu_index, qemu_plugin_meminfo_t info, uint64_t vaddr, - void *userdata) + void *udata) { qemu_plugin_u64_add(count_mem, cpu_index, 1); + g_assert(qemu_plugin_u64_get(data_mem, cpu_index) =3D=3D (uintptr_t) u= data); g_mutex_lock(&mem_lock); global_count_mem++; g_mutex_unlock(&mem_lock); @@ -141,20 +155,34 @@ static void vcpu_mem_access(unsigned int cpu_index, =20 static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { + void *tb_store =3D tb; + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_STORE_U64, data_tb, (uintptr_t) tb_store); qemu_plugin_register_vcpu_tb_exec_cb( - tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + tb, vcpu_tb_exec, QEMU_PLUGIN_CB_NO_REGS, tb_store); qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); =20 for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, idx); + void *insn_store =3D insn; + void *mem_store =3D (char *)insn_store + 0xff; + + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_STORE_U64, data_insn, + (uintptr_t) insn_store); qemu_plugin_register_vcpu_insn_exec_cb( - insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, 0); + insn, vcpu_insn_exec, QEMU_PLUGIN_CB_NO_REGS, insn_store); qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); + + qemu_plugin_register_vcpu_mem_inline_per_vcpu( + insn, QEMU_PLUGIN_MEM_RW, + QEMU_PLUGIN_INLINE_STORE_U64, + data_mem, (uintptr_t) mem_store); qemu_plugin_register_vcpu_mem_cb(insn, &vcpu_mem_access, QEMU_PLUGIN_CB_NO_REGS, - QEMU_PLUGIN_MEM_RW, 0); + QEMU_PLUGIN_MEM_RW, mem_store); qemu_plugin_register_vcpu_mem_inline_per_vcpu( insn, QEMU_PLUGIN_MEM_RW, QEMU_PLUGIN_INLINE_ADD_U64, @@ -179,6 +207,11 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qem= u_info_t *info, counts, CPUCount, count_insn_inline); count_mem_inline =3D qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, count_mem_inline); + data =3D qemu_plugin_scoreboard_new(sizeof(CPUData)); + data_insn =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data= _insn); + data_tb =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_t= b); + data_mem =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_= mem); + qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans); qemu_plugin_register_atexit_cb(id, plugin_exit, NULL); =20 --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456533; cv=none; d=zohomail.com; s=zohoarc; b=nfmsiwa3SNmp5To+U4z8gJ03DCH5W26ASGUSNMCPpkWKFOEO6rXlMc6TqxUEmGoW/S2B0z5U35f86rparGVpCMdy41DhNpYwxNI5C3AYf4z/3yW6gdqLl4J0GHG5o1j9NZrRxD4gGZJqMMrde2jG1w1i4eLOe1qXaOeRK1ulqww= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456533; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=s1T6XJTpY4BRy8dxlhwxm1WWjcttE9EbPLYKwg8XkHA=; b=BFRD8thBU/qzKHMZfxEvEAeWX0nq5rcdPJrXFxTbaD/e6kYLA3I3yt037DV6lCtU+B3GH637UJ+OVux+c11vgAvZbNgvPQ0FO8EmFSdBFvSMAtBr1W0kwAgrYpg+nc593EBQirFjm3O93q1/K1F6Bo682FCRzdoyU2tCW94kOjo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456533039499.201139623435; Tue, 26 Mar 2024 05:35:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp61B-0005FV-Fn; Tue, 26 Mar 2024 08:35:05 -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 1rp618-0005Dp-Uq for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:02 -0400 Received: from mail-lj1-x231.google.com ([2a00:1450:4864:20::231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp616-0000ez-GJ for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:02 -0400 Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2d47a92cfefso64846731fa.1 for ; Tue, 26 Mar 2024 05:35:00 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456498; x=1712061298; 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=s1T6XJTpY4BRy8dxlhwxm1WWjcttE9EbPLYKwg8XkHA=; b=Kaqolfc+qat4grIa/730ruXLLX4Ntp6TV0NbWz3r7B0t2Athoi83c5kSNbeSM/dsMM jlzNHN4JIo0DB2VsMkchSFhAxCXDmaBbO12kE6U/rSQXVRwRuZwsy5CeXJLH6p6c9AGC G2SbTWSJ5+L2iSVSMPZ6jD+JQ3Hp6F34sEpmsbujpRhdgA4WPIbcdFYLWXEEMtjUAxOW 9K/w8LRciLvobV2tlsxM5UPrdGI1Pgh3HmSBlmLbLvQzsRhPqwB2So8guI4KHLVCU25D /t1GES3inEYJfl5K5Lk2Jh8GSjezy6bhNeDCc4G5zZop9EzN++iZLY5GrFz5ASGIuWBx EZZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456498; x=1712061298; 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=s1T6XJTpY4BRy8dxlhwxm1WWjcttE9EbPLYKwg8XkHA=; b=tsX1DpwyLEOF7BNdPYIOIyzGxJV7/WMYwG787hOc57XGEGDx1Nosf1yTuhX+Y7APAC 3fRunHne7lRFGynvaX8yuhjQOttYJWTYIWSPg96jLdaC5ndikTcVtITwRrJnBz1SR1RI Hqcve1/dDfj3OGAuGUTKaezvM6/giOy4vtMrGI9OIcK+G6d44aO20gfWp9rZsxTCjTFL 0bB4SYrzizQdPdHsFbA97wZNTPT3EiME3TEXb6wWyUM09EMsAovPdkCKd+p/vbxYQS66 NWbYZWExi5hkRKatGAwBF7ulvvDnWOsz6aeLrh9ADMuL+/GCB3IQgAwYQY411N2dmAuD K2kA== X-Gm-Message-State: AOJu0YxOny/tSwu/tcE9KE6Bw6M+yataT0myH0atgd/oc868bIUj1bzs be5/q/HLQ63SmnwGnB9CYGzKYvQrmxpqTJnoe5Xry+oymmplzttRFINyeYNcrXqpNqlTczGhCgs zQls= X-Google-Smtp-Source: AGHT+IErmgE4cE4nLKE9X49o0cY0E4J5IC38aPELzKmpLBlH1mFXxOzNz8mjc8EvcbQKIkEHXMMC+Q== X-Received: by 2002:a2e:98c2:0:b0:2d6:9481:b38 with SMTP id s2-20020a2e98c2000000b002d694810b38mr6909542ljj.20.1711456498068; Tue, 26 Mar 2024 05:34:58 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 5/9] plugins: conditional callbacks Date: Tue, 26 Mar 2024 16:34:22 +0400 Message-Id: <20240326123426.761473-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::231; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lj1-x231.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456533808100001 Content-Type: text/plain; charset="utf-8" Extend plugins API to support callback called with a given criteria (evaluated inline). Added functions: - qemu_plugin_register_vcpu_tb_exec_cond_cb - qemu_plugin_register_vcpu_insn_exec_cond_cb They expect as parameter a condition, a qemu_plugin_u64_t (op1) and an immediate (op2). Callback is called if op1 |cond| op2 is true. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- include/qemu/plugin.h | 8 ++++ include/qemu/qemu-plugin.h | 76 ++++++++++++++++++++++++++++++++++++ plugins/plugin.h | 8 ++++ accel/tcg/plugin-gen.c | 48 +++++++++++++++++++++++ plugins/api.c | 39 ++++++++++++++++++ plugins/core.c | 32 +++++++++++++++ plugins/qemu-plugins.symbols | 2 + 7 files changed, 213 insertions(+) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index d1d9b4490df..bb224b8e4c7 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -67,6 +67,7 @@ union qemu_plugin_cb_sig { =20 enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, + PLUGIN_CB_COND, PLUGIN_CB_MEM_REGULAR, PLUGIN_CB_INLINE_ADD_U64, PLUGIN_CB_INLINE_STORE_U64, @@ -88,6 +89,13 @@ struct qemu_plugin_dyn_cb { union qemu_plugin_cb_sig f; TCGHelperInfo *info; } regular; + struct { + union qemu_plugin_cb_sig f; + TCGHelperInfo *info; + qemu_plugin_u64 entry; + enum qemu_plugin_cond cond; + uint64_t imm; + } cond; struct { qemu_plugin_u64 entry; enum qemu_plugin_op op; diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c5cac897a0b..337de25ece7 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -262,6 +262,29 @@ enum qemu_plugin_mem_rw { QEMU_PLUGIN_MEM_RW, }; =20 +/** + * enum qemu_plugin_cond - condition to enable callback + * + * @QEMU_PLUGIN_COND_NEVER: false + * @QEMU_PLUGIN_COND_ALWAYS: true + * @QEMU_PLUGIN_COND_EQ: is equal? + * @QEMU_PLUGIN_COND_NE: is not equal? + * @QEMU_PLUGIN_COND_LT: is less than? + * @QEMU_PLUGIN_COND_LE: is less than or equal? + * @QEMU_PLUGIN_COND_GT: is greater than? + * @QEMU_PLUGIN_COND_GE: is greater than or equal? + */ +enum qemu_plugin_cond { + QEMU_PLUGIN_COND_NEVER, + QEMU_PLUGIN_COND_ALWAYS, + QEMU_PLUGIN_COND_EQ, + QEMU_PLUGIN_COND_NE, + QEMU_PLUGIN_COND_LT, + QEMU_PLUGIN_COND_LE, + QEMU_PLUGIN_COND_GT, + QEMU_PLUGIN_COND_GE, +}; + /** * typedef qemu_plugin_vcpu_tb_trans_cb_t - translation callback * @id: unique plugin id @@ -301,6 +324,32 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_= plugin_tb *tb, enum qemu_plugin_cb_flags flags, void *userdata); =20 +/** + * qemu_plugin_register_vcpu_tb_exec_cond_cb() - register conditional call= back + * @tb: the opaque qemu_plugin_tb handle for the translation + * @cb: callback function + * @cond: condition to enable callback + * @entry: first operand for condition + * @imm: second operand for condition + * @flags: does the plugin read or write the CPU's registers? + * @userdata: any plugin data to pass to the @cb? + * + * The @cb function is called when a translated unit executes if + * entry @cond imm is true. + * If condition is QEMU_PLUGIN_COND_ALWAYS, condition is never interpreted= and + * this function is equivalent to qemu_plugin_register_vcpu_tb_exec_cb. + * If condition QEMU_PLUGIN_COND_NEVER, condition is never interpreted and + * callback is never installed. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_tb_exec_cond_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t= cb, + enum qemu_plugin_cb_flags f= lags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *userdata); + /** * enum qemu_plugin_op - describes an inline op * @@ -344,6 +393,33 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, enum qemu_plugin_cb_flags flag= s, void *userdata); =20 +/** + * qemu_plugin_register_vcpu_insn_exec_cond_cb() - conditional insn execut= ion cb + * @insn: the opaque qemu_plugin_insn handle for an instruction + * @cb: callback function + * @flags: does the plugin read or write the CPU's registers? + * @cond: condition to enable callback + * @entry: first operand for condition + * @imm: second operand for condition + * @userdata: any plugin data to pass to the @cb? + * + * The @cb function is called when an instruction executes if + * entry @cond imm is true. + * If condition is QEMU_PLUGIN_COND_ALWAYS, condition is never interpreted= and + * this function is equivalent to qemu_plugin_register_vcpu_insn_exec_cb. + * If condition QEMU_PLUGIN_COND_NEVER, condition is never interpreted and + * callback is never installed. + */ +QEMU_PLUGIN_API +void qemu_plugin_register_vcpu_insn_exec_cond_cb( + struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *userdata); + /** * qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu() - insn exec inlin= e op * @insn: the opaque qemu_plugin_insn handle for an instruction diff --git a/plugins/plugin.h b/plugins/plugin.h index 7c34f23cfcb..7d4b4e21f7c 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -93,6 +93,14 @@ plugin_register_dyn_cb__udata(GArray **arr, qemu_plugin_vcpu_udata_cb_t cb, enum qemu_plugin_cb_flags flags, void *udata= ); =20 +void +plugin_register_dyn_cond_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *udata); =20 void plugin_register_vcpu_mem_cb(GArray **arr, void *cb, diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 1cfd7908df1..1b1dd264e2b 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -139,6 +139,51 @@ static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 ent= ry) return ptr; } =20 +static TCGCond plugin_cond_to_tcgcond(enum qemu_plugin_cond cond) +{ + switch (cond) { + case QEMU_PLUGIN_COND_EQ: + return TCG_COND_EQ; + case QEMU_PLUGIN_COND_NE: + return TCG_COND_NE; + case QEMU_PLUGIN_COND_LT: + return TCG_COND_LTU; + case QEMU_PLUGIN_COND_LE: + return TCG_COND_LEU; + case QEMU_PLUGIN_COND_GT: + return TCG_COND_GTU; + case QEMU_PLUGIN_COND_GE: + return TCG_COND_GEU; + default: + /* ALWAYS and NEVER conditions should never reach */ + g_assert_not_reached(); + } +} + +static void gen_udata_cond_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->cond.entry); + TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); + TCGv_i64 val =3D tcg_temp_ebb_new_i64(); + TCGLabel *after_cb =3D gen_new_label(); + + /* Condition should be negated, as calling the cb is the "else" path */ + TCGCond cond =3D tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond.cond)= ); + + tcg_gen_ld_i64(val, ptr, 0); + tcg_gen_brcondi_i64(cond, val, cb->cond.imm, after_cb); + tcg_gen_ld_i32(cpu_index, tcg_env, + -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + tcg_gen_call2(cb->cond.f.vcpu_udata, cb->cond.info, NULL, + tcgv_i32_temp(cpu_index), + tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); + gen_set_label(after_cb); + + tcg_temp_free_i64(val); + tcg_temp_free_i32(cpu_index); + tcg_temp_free_ptr(ptr); +} + static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) { TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->inline_insn.entry); @@ -184,6 +229,9 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb) case PLUGIN_CB_REGULAR: gen_udata_cb(cb); break; + case PLUGIN_CB_COND: + gen_udata_cond_cb(cb); + break; case PLUGIN_CB_INLINE_ADD_U64: gen_inline_add_u64_cb(cb); break; diff --git a/plugins/api.c b/plugins/api.c index 3912c9cc8f6..2242d40bbbc 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -96,6 +96,25 @@ void qemu_plugin_register_vcpu_tb_exec_cb(struct qemu_pl= ugin_tb *tb, } } =20 +void qemu_plugin_register_vcpu_tb_exec_cond_cb(struct qemu_plugin_tb *tb, + qemu_plugin_vcpu_udata_cb_t= cb, + enum qemu_plugin_cb_flags f= lags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *udata) +{ + if (cond =3D=3D QEMU_PLUGIN_COND_NEVER || tb->mem_only) { + return; + } + if (cond =3D=3D QEMU_PLUGIN_COND_ALWAYS) { + qemu_plugin_register_vcpu_tb_exec_cb(tb, cb, flags, udata); + return; + } + plugin_register_dyn_cond_cb__udata(&tb->cbs, cb, flags, + cond, entry, imm, udata); +} + void qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( struct qemu_plugin_tb *tb, enum qemu_plugin_op op, @@ -117,6 +136,26 @@ void qemu_plugin_register_vcpu_insn_exec_cb(struct qem= u_plugin_insn *insn, } } =20 +void qemu_plugin_register_vcpu_insn_exec_cond_cb( + struct qemu_plugin_insn *insn, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *udata) +{ + if (cond =3D=3D QEMU_PLUGIN_COND_NEVER || insn->mem_only) { + return; + } + if (cond =3D=3D QEMU_PLUGIN_COND_ALWAYS) { + qemu_plugin_register_vcpu_insn_exec_cb(insn, cb, flags, udata); + return; + } + plugin_register_dyn_cond_cb__udata(&insn->insn_cbs, cb, flags, + cond, entry, imm, udata); +} + void qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( struct qemu_plugin_insn *insn, enum qemu_plugin_op op, diff --git a/plugins/core.c b/plugins/core.c index e1bf0dc3717..b3d0208e022 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -371,6 +371,38 @@ void plugin_register_dyn_cb__udata(GArray **arr, dyn_cb->regular.info =3D &info[flags]; } =20 +void plugin_register_dyn_cond_cb__udata(GArray **arr, + qemu_plugin_vcpu_udata_cb_t cb, + enum qemu_plugin_cb_flags flags, + enum qemu_plugin_cond cond, + qemu_plugin_u64 entry, + uint64_t imm, + void *udata) +{ + static TCGHelperInfo info[3] =3D { + [QEMU_PLUGIN_CB_NO_REGS].flags =3D TCG_CALL_NO_RWG, + [QEMU_PLUGIN_CB_R_REGS].flags =3D TCG_CALL_NO_WG, + /* + * Match qemu_plugin_vcpu_udata_cb_t: + * void (*)(uint32_t, void *) + */ + [0 ... 2].typemask =3D (dh_typemask(void, 0) | + dh_typemask(i32, 1) | + dh_typemask(ptr, 2)) + }; + + struct qemu_plugin_dyn_cb *dyn_cb =3D plugin_get_dyn_cb(arr); + dyn_cb->userp =3D udata; + dyn_cb->type =3D PLUGIN_CB_COND; + dyn_cb->cond.f.vcpu_udata =3D cb; + dyn_cb->cond.cond =3D cond; + dyn_cb->cond.entry =3D entry; + dyn_cb->cond.imm =3D imm; + + assert((unsigned)flags < ARRAY_SIZE(info)); + dyn_cb->cond.info =3D &info[flags]; +} + void plugin_register_vcpu_mem_cb(GArray **arr, void *cb, enum qemu_plugin_cb_flags flags, diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index a9fac056c7f..aa0a77a319f 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -27,6 +27,7 @@ qemu_plugin_register_vcpu_idle_cb; qemu_plugin_register_vcpu_init_cb; qemu_plugin_register_vcpu_insn_exec_cb; + qemu_plugin_register_vcpu_insn_exec_cond_cb; qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu; qemu_plugin_register_vcpu_mem_cb; qemu_plugin_register_vcpu_mem_inline_per_vcpu; @@ -34,6 +35,7 @@ qemu_plugin_register_vcpu_syscall_cb; qemu_plugin_register_vcpu_syscall_ret_cb; qemu_plugin_register_vcpu_tb_exec_cb; + qemu_plugin_register_vcpu_tb_exec_cond_cb; qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu; qemu_plugin_register_vcpu_tb_trans_cb; qemu_plugin_reset; --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456520; cv=none; d=zohomail.com; s=zohoarc; b=hViOmWVUoB4q/rsdGSkuG5ecX1xBwEpu/QodiYTxjUQYybhZDiTikJrfON8HxNLkLRkwA4EHjnBc/UpbGNXggPGMb9wS4xzaraQ4S0loXcD8JzOU5G+VsJrnzfcnOsvkW76gDjQhXj08VcT8pRw19/4FsBCSxi31U/QluKkNp0M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456520; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=OmhIE37fkqsu8g+bGomSlM2HBiD6ETLgpCZvKdmkoMg=; b=hfu72MH0CZab3akptH8lWN/7chySI2UXCNaVkLVcqJ5TEC7nGIQNNHrCKJTR6EUdlAh5LHskQZH+tpDN1owtiCFjEOysB9a1wdrKOcxFF605J7PpD/sO9m9XlYowdGkVVfIBsZhT1gs9I4nn5e49wgqZXtJR4JGv7Bf+zv6/OBU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456520520143.72121424964325; Tue, 26 Mar 2024 05:35:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp61D-0005Kc-Op; Tue, 26 Mar 2024 08:35:07 -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 1rp61B-0005GF-Ej for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:05 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp619-0000ff-2i for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:05 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4148c6af2d3so8337495e9.1 for ; Tue, 26 Mar 2024 05:35:02 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:35:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456501; x=1712061301; 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=OmhIE37fkqsu8g+bGomSlM2HBiD6ETLgpCZvKdmkoMg=; b=sRhujzsu4r9TBUlyZqFTlq0m33RlPPHSaoIIHh5A1VY/rgrBj0Ssz3L4FPTt27kmFH RaeOklSUON88nJE9wdpS3bMSSdL8H1qKxd/4+YQFsIHcPw36JIprgSDsTsSWIOueYWC1 xZ6O47dGvo0Vb5ldibQfO48rmVHAW+bODMBwvfptbbTvMVtuhpEAVzh1TChRetcp5ydU kPGLFly5iBivrmafHjtk3Cb+SZm0l12fYwOwctdiSq346fPQfAEzBVYXXNJqzSmqCvWJ o1EszspvafsdwQHygkL3oLL6Wu4rfKv80T6h7lFhIBa2Pmo97k0padoeFptvPJvt90zn HU5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456501; x=1712061301; 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=OmhIE37fkqsu8g+bGomSlM2HBiD6ETLgpCZvKdmkoMg=; b=Jw6zI9eO5DmOugjq2X/0dps5BLZHnC1BiiB0LdjCRn4Xo8n8APlUlK3ZlkIVOLHovQ /cSVU5WwCk20MUl+A5PnL1iKATSYXLHR6GkOeWrdEPFMxhj+qYl4og349wU33HdMoGCA NFIH9n3R4ZQdcDVAiSe+YhhjwHkhHy2M0mxPHx+4nA7KtzWIJjG9Jz58Mj+lv4TuJyzJ Shir6gl7J1VYlBZq8OZu4N0s0Qwas/oeqKIq2qCwRrRCPKLPuA3wVV7ln17mleeC9dNl FllNUMse4nfe1ovv13eHnc8WUf2GtrDs21r6mc2AlnVRg8I5Ib4HnqXEyQPXlRK0T178 vpkA== X-Gm-Message-State: AOJu0Yxn23yGWCFWtSBk8aXyjZeSWLINZoArHAGsr6gA6CJT+Ir40Zqv 4qHn4fhKWmmAP7TJAUHUYi4xwUZsTAbLz1AAujutrImhzcQyHcEHEVxmLDEQ8UV90x/oMjBQPNZ cju8= X-Google-Smtp-Source: AGHT+IHfrXx3JcGuIHoP8LVBYMX1KIY1zIfNjIk/Zg1ZfyKdY5ZhYkzkDPCznmua8vsTIkW+gsBgfw== X-Received: by 2002:a05:600c:24c:b0:413:eba4:f221 with SMTP id 12-20020a05600c024c00b00413eba4f221mr6907354wmj.37.1711456501299; Tue, 26 Mar 2024 05:35:01 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 6/9] tests/plugin/inline: add test for conditional callback Date: Tue, 26 Mar 2024 16:34:23 +0400 Message-Id: <20240326123426.761473-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x332.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456521791100001 Content-Type: text/plain; charset="utf-8" Count number of tb and insn executed using a conditional callback. We ensure the callback has been called expected number of time (per vcpu). Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- tests/plugin/inline.c | 89 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 3 deletions(-) diff --git a/tests/plugin/inline.c b/tests/plugin/inline.c index 103c3a22f6e..cd63827b7d8 100644 --- a/tests/plugin/inline.c +++ b/tests/plugin/inline.c @@ -20,8 +20,14 @@ typedef struct { uint64_t count_insn_inline; uint64_t count_mem; uint64_t count_mem_inline; + uint64_t tb_cond_num_trigger; + uint64_t tb_cond_track_count; + uint64_t insn_cond_num_trigger; + uint64_t insn_cond_track_count; } CPUCount; =20 +static const uint64_t cond_trigger_limit =3D 100; + typedef struct { uint64_t data_insn; uint64_t data_tb; @@ -35,6 +41,10 @@ static qemu_plugin_u64 count_insn; static qemu_plugin_u64 count_insn_inline; static qemu_plugin_u64 count_mem; static qemu_plugin_u64 count_mem_inline; +static qemu_plugin_u64 tb_cond_num_trigger; +static qemu_plugin_u64 tb_cond_track_count; +static qemu_plugin_u64 insn_cond_num_trigger; +static qemu_plugin_u64 insn_cond_track_count; static struct qemu_plugin_scoreboard *data; static qemu_plugin_u64 data_insn; static qemu_plugin_u64 data_tb; @@ -56,12 +66,19 @@ static void stats_insn(void) const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_insn); const uint64_t inl_per_vcpu =3D qemu_plugin_u64_sum(count_insn_inline); + const uint64_t cond_num_trigger =3D + qemu_plugin_u64_sum(insn_cond_num_trigger); + const uint64_t cond_track_left =3D qemu_plugin_u64_sum(insn_cond_track= _count); + const uint64_t conditional =3D + cond_num_trigger * cond_trigger_limit + cond_track_left; printf("insn: %" PRIu64 "\n", expected); printf("insn: %" PRIu64 " (per vcpu)\n", per_vcpu); printf("insn: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + printf("insn: %" PRIu64 " (cond cb)\n", conditional); g_assert(expected > 0); g_assert(per_vcpu =3D=3D expected); g_assert(inl_per_vcpu =3D=3D expected); + g_assert(conditional =3D=3D expected); } =20 static void stats_tb(void) @@ -70,12 +87,18 @@ static void stats_tb(void) const uint64_t per_vcpu =3D qemu_plugin_u64_sum(count_tb); const uint64_t inl_per_vcpu =3D qemu_plugin_u64_sum(count_tb_inline); + const uint64_t cond_num_trigger =3D qemu_plugin_u64_sum(tb_cond_num_tr= igger); + const uint64_t cond_track_left =3D qemu_plugin_u64_sum(tb_cond_track_c= ount); + const uint64_t conditional =3D + cond_num_trigger * cond_trigger_limit + cond_track_left; printf("tb: %" PRIu64 "\n", expected); printf("tb: %" PRIu64 " (per vcpu)\n", per_vcpu); printf("tb: %" PRIu64 " (per vcpu inline)\n", inl_per_vcpu); + printf("tb: %" PRIu64 " (conditional cb)\n", conditional); g_assert(expected > 0); g_assert(per_vcpu =3D=3D expected); g_assert(inl_per_vcpu =3D=3D expected); + g_assert(conditional =3D=3D expected); } =20 static void stats_mem(void) @@ -104,14 +127,35 @@ static void plugin_exit(qemu_plugin_id_t id, void *ud= ata) const uint64_t insn_inline =3D qemu_plugin_u64_get(count_insn_inli= ne, i); const uint64_t mem =3D qemu_plugin_u64_get(count_mem, i); const uint64_t mem_inline =3D qemu_plugin_u64_get(count_mem_inline= , i); - printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 ") | " - "insn (%" PRIu64 ", %" PRIu64 ") | " + const uint64_t tb_cond_trigger =3D + qemu_plugin_u64_get(tb_cond_num_trigger, i); + const uint64_t tb_cond_left =3D + qemu_plugin_u64_get(tb_cond_track_count, i); + const uint64_t insn_cond_trigger =3D + qemu_plugin_u64_get(insn_cond_num_trigger, i); + const uint64_t insn_cond_left =3D + qemu_plugin_u64_get(insn_cond_track_count, i); + printf("cpu %d: tb (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " + "insn (%" PRIu64 ", %" PRIu64 + ", %" PRIu64 " * %" PRIu64 " + %" PRIu64 + ") | " "mem (%" PRIu64 ", %" PRIu64 ")" "\n", - i, tb, tb_inline, insn, insn_inline, mem, mem_inline); + i, + tb, tb_inline, + tb_cond_trigger, cond_trigger_limit, tb_cond_left, + insn, insn_inline, + insn_cond_trigger, cond_trigger_limit, insn_cond_left, + mem, mem_inline); g_assert(tb =3D=3D tb_inline); g_assert(insn =3D=3D insn_inline); g_assert(mem =3D=3D mem_inline); + g_assert(tb_cond_trigger =3D=3D tb / cond_trigger_limit); + g_assert(tb_cond_left =3D=3D tb % cond_trigger_limit); + g_assert(insn_cond_trigger =3D=3D insn / cond_trigger_limit); + g_assert(insn_cond_left =3D=3D insn % cond_trigger_limit); } =20 stats_tb(); @@ -132,6 +176,24 @@ static void vcpu_tb_exec(unsigned int cpu_index, void = *udata) g_mutex_unlock(&tb_lock); } =20 +static void vcpu_tb_cond_exec(unsigned int cpu_index, void *udata) +{ + g_assert(qemu_plugin_u64_get(tb_cond_track_count, cpu_index) =3D=3D + cond_trigger_limit); + g_assert(qemu_plugin_u64_get(data_tb, cpu_index) =3D=3D (uintptr_t) ud= ata); + qemu_plugin_u64_set(tb_cond_track_count, cpu_index, 0); + qemu_plugin_u64_add(tb_cond_num_trigger, cpu_index, 1); +} + +static void vcpu_insn_cond_exec(unsigned int cpu_index, void *udata) +{ + g_assert(qemu_plugin_u64_get(insn_cond_track_count, cpu_index) =3D=3D + cond_trigger_limit); + g_assert(qemu_plugin_u64_get(data_insn, cpu_index) =3D=3D (uintptr_t) = udata); + qemu_plugin_u64_set(insn_cond_track_count, cpu_index, 0); + qemu_plugin_u64_add(insn_cond_num_trigger, cpu_index, 1); +} + static void vcpu_insn_exec(unsigned int cpu_index, void *udata) { qemu_plugin_u64_add(count_insn, cpu_index, 1); @@ -163,6 +225,12 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( tb, QEMU_PLUGIN_INLINE_ADD_U64, count_tb_inline, 1); =20 + qemu_plugin_register_vcpu_tb_exec_inline_per_vcpu( + tb, QEMU_PLUGIN_INLINE_ADD_U64, tb_cond_track_count, 1); + qemu_plugin_register_vcpu_tb_exec_cond_cb( + tb, vcpu_tb_cond_exec, QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_COND_EQ, tb_cond_track_count, cond_trigger_limit, tb_s= tore); + for (int idx =3D 0; idx < qemu_plugin_tb_n_insns(tb); ++idx) { struct qemu_plugin_insn *insn =3D qemu_plugin_tb_get_insn(tb, idx); void *insn_store =3D insn; @@ -176,6 +244,13 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct = qemu_plugin_tb *tb) qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( insn, QEMU_PLUGIN_INLINE_ADD_U64, count_insn_inline, 1); =20 + qemu_plugin_register_vcpu_insn_exec_inline_per_vcpu( + insn, QEMU_PLUGIN_INLINE_ADD_U64, insn_cond_track_count, 1); + qemu_plugin_register_vcpu_insn_exec_cond_cb( + insn, vcpu_insn_cond_exec, QEMU_PLUGIN_CB_NO_REGS, + QEMU_PLUGIN_COND_EQ, insn_cond_track_count, cond_trigger_limit, + insn_store); + qemu_plugin_register_vcpu_mem_inline_per_vcpu( insn, QEMU_PLUGIN_MEM_RW, QEMU_PLUGIN_INLINE_STORE_U64, @@ -207,6 +282,14 @@ int qemu_plugin_install(qemu_plugin_id_t id, const qem= u_info_t *info, counts, CPUCount, count_insn_inline); count_mem_inline =3D qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, count_mem_inline); + tb_cond_num_trigger =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, tb_cond_num_trigger); + tb_cond_track_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, tb_cond_track_count); + insn_cond_num_trigger =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, insn_cond_num_trigger); + insn_cond_track_count =3D qemu_plugin_scoreboard_u64_in_struct( + counts, CPUCount, insn_cond_track_count); data =3D qemu_plugin_scoreboard_new(sizeof(CPUData)); data_insn =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data= _insn); data_tb =3D qemu_plugin_scoreboard_u64_in_struct(data, CPUData, data_t= b); --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456585; cv=none; d=zohomail.com; s=zohoarc; b=WHwGJJsk5SKxo2bprJdXf9urPTYwHBv4rPOxj5rYpQLYPSkL1G9P8c9QxDL//5VbBZKk7N2mdcz3rX6H8nv3Sp37bXKzCn4Yl0drDoad2zVR64lYW9qa+DBRZRA8oYLrRq1BThfgdDinVfGd4yNdHmL6T053Cfx85JLJwxDrg8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456585; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=V1PJSyLekmQiJMmv7/zxpIRkCdRPSC16cTFoxh7+v0c=; b=HfMGddbkDM+u8oFt9WGIEaG53ae4cdxUOJmJ9xrcYkz4vpUPE23IN4lVTgMjw+mKExS2q4IdO/GQ/f2vwd2K62ReUMg323BA2I6jhSVfh9rjuqSdP/JCrfDA12dDziiwxJTvrerTTaFQ3UUIfe3xndlP4WgbAhAxCSr4gfZDDVE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456585830932.9389433571788; Tue, 26 Mar 2024 05:36:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp61H-0005NC-LX; Tue, 26 Mar 2024 08:35:11 -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 1rp61F-0005Mg-UK for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:09 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp61C-0000gS-Qp for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:09 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4148c6af2d3so8338095e9.1 for ; Tue, 26 Mar 2024 05:35:06 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:35:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456504; x=1712061304; 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=V1PJSyLekmQiJMmv7/zxpIRkCdRPSC16cTFoxh7+v0c=; b=OyUSa1LAcJeG3ntTk43VVI6PDnWwG1Mf/BMjtwzB2z+CrOIhfRKp5id/63xnVQ6s7P sRl+XeZGuqpanDeF3KTx6Yzz/KcxyesmB+lNghm+YEZ3BZ/brjDey6vlvIxCmYxwKkEj BkhoI+H8mmCVezVibAgXJt1xkm/Dwr+AqwMiDBXqk+1qsTZSIIhyo3miK8rLUBc9YJn6 +QzGHdRFhX+X+4l7OCLsEKBH57MgvxcGVIHqdMAiDT3/UeRyv8KxjYc3zmhkJsKKh6Ue j8mTgZj8cno07RWt4+ueTd4RK31TfwAJpH8tglD4/tfXjWmLhzBJJN93BqaJSzbnQfgl rivA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456504; x=1712061304; 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=V1PJSyLekmQiJMmv7/zxpIRkCdRPSC16cTFoxh7+v0c=; b=kZAxUw1POnO9DM7VIXroRUIThDejOEXBil3ToIG8jBntd8uE29VadRS+QYkRhXwifK Ql70xVDo2W9POa6o7E4MqQ+oHbBIF0b7OgVitkq4tJNswwdmY1I8Lr3xqybZrgOdjhwK 6FnbIZs0+djVihJJogPZEWxEjd+lRIX+s1QSWf4HieBDrCXALIcQkPPKWzMV3DuRzmJU 0Eropz/yCtcBXS2FvnnrT3kOMj57FVLl7ruxpLIL3ZzVezMLdsSeUATU+dnGH4DXHEjX el1I4wCo7ho++y8hTqqeEz1xnlvEGTOd+YTLR4y8bIUzNSpA/GFZUc3dWlZl4ebHI40E C+eQ== X-Gm-Message-State: AOJu0Yza0bpX2ePXCYGPEV37K0cD5qtSPVls+7tbZtszTdgEkLYP/YyI 3nXDnFVJGocU72yidZz4vfF9ayKiECwgtOuILuwupL3MenIoVEXpm28Ifp01rGLP4Iq4cl6h/ye xXrU= X-Google-Smtp-Source: AGHT+IFVl5SsnJTLvqEIU0yusx4gfTw+mzpB1tRpxymY3AJdU0Bq6kWCwulbEiQ6nbTEUNeF6AkYwg== X-Received: by 2002:a05:600c:3ba3:b0:413:2966:4bfb with SMTP id n35-20020a05600c3ba300b0041329664bfbmr6620401wms.1.1711456504244; Tue, 26 Mar 2024 05:35:04 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 7/9] plugins: distinct types for callbacks Date: Tue, 26 Mar 2024 16:34:24 +0400 Message-Id: <20240326123426.761473-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456588062100013 Content-Type: text/plain; charset="utf-8" To prevent errors when writing new types of callbacks or inline operations, we split callbacks data to distinct types. Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- include/qemu/plugin.h | 46 ++++++++++++++----------- plugins/plugin.h | 2 +- accel/tcg/plugin-gen.c | 58 +++++++++++++++++--------------- plugins/core.c | 76 ++++++++++++++++++++++-------------------- 4 files changed, 98 insertions(+), 84 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bb224b8e4c7..a078229942f 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -73,34 +73,40 @@ enum plugin_dyn_cb_type { PLUGIN_CB_INLINE_STORE_U64, }; =20 +struct qemu_plugin_regular_cb { + union qemu_plugin_cb_sig f; + TCGHelperInfo *info; + void *userp; + enum qemu_plugin_mem_rw rw; +}; + +struct qemu_plugin_inline_cb { + qemu_plugin_u64 entry; + enum qemu_plugin_op op; + uint64_t imm; + enum qemu_plugin_mem_rw rw; +}; + +struct qemu_plugin_conditional_cb { + union qemu_plugin_cb_sig f; + TCGHelperInfo *info; + void *userp; + qemu_plugin_u64 entry; + enum qemu_plugin_cond cond; + uint64_t imm; +}; + /* * A dynamic callback has an insertion point that is determined at run-tim= e. * Usually the insertion point is somewhere in the code cache; think for * instance of a callback to be called upon the execution of a particular = TB. */ struct qemu_plugin_dyn_cb { - void *userp; enum plugin_dyn_cb_type type; - /* @rw applies to mem callbacks only (both regular and inline) */ - enum qemu_plugin_mem_rw rw; - /* fields specific to each dyn_cb type go here */ union { - struct { - union qemu_plugin_cb_sig f; - TCGHelperInfo *info; - } regular; - struct { - union qemu_plugin_cb_sig f; - TCGHelperInfo *info; - qemu_plugin_u64 entry; - enum qemu_plugin_cond cond; - uint64_t imm; - } cond; - struct { - qemu_plugin_u64 entry; - enum qemu_plugin_op op; - uint64_t imm; - } inline_insn; + struct qemu_plugin_regular_cb regular; + struct qemu_plugin_conditional_cb cond; + struct qemu_plugin_inline_cb inline_insn; }; }; =20 diff --git a/plugins/plugin.h b/plugins/plugin.h index 7d4b4e21f7c..80d5daa9171 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -108,7 +108,7 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index); +void exec_inline_op(struct qemu_plugin_inline_cb *cb, int cpu_index); =20 int plugin_num_vcpus(void); =20 diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 1b1dd264e2b..d00a2b3fd67 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -108,13 +108,13 @@ static void gen_disable_mem_helper(void) offsetof(ArchCPU, env)); } =20 -static void gen_udata_cb(struct qemu_plugin_dyn_cb *cb) +static void gen_udata_cb(struct qemu_plugin_regular_cb *cb) { TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); =20 tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); - tcg_gen_call2(cb->regular.f.vcpu_udata, cb->regular.info, NULL, + 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); @@ -160,21 +160,21 @@ static TCGCond plugin_cond_to_tcgcond(enum qemu_plugi= n_cond cond) } } =20 -static void gen_udata_cond_cb(struct qemu_plugin_dyn_cb *cb) +static void gen_udata_cond_cb(struct qemu_plugin_conditional_cb *cb) { - TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->cond.entry); + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->entry); TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGLabel *after_cb =3D gen_new_label(); =20 /* Condition should be negated, as calling the cb is the "else" path */ - TCGCond cond =3D tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond.cond)= ); + TCGCond cond =3D tcg_invert_cond(plugin_cond_to_tcgcond(cb->cond)); =20 tcg_gen_ld_i64(val, ptr, 0); - tcg_gen_brcondi_i64(cond, val, cb->cond.imm, after_cb); + 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)= ); - tcg_gen_call2(cb->cond.f.vcpu_udata, cb->cond.info, NULL, + tcg_gen_call2(cb->f.vcpu_udata, cb->info, NULL, tcgv_i32_temp(cpu_index), tcgv_ptr_temp(tcg_constant_ptr(cb->userp))); gen_set_label(after_cb); @@ -184,37 +184,37 @@ static void gen_udata_cond_cb(struct qemu_plugin_dyn_= cb *cb) tcg_temp_free_ptr(ptr); } =20 -static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) +static void gen_inline_add_u64_cb(struct qemu_plugin_inline_cb *cb) { - TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->entry); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); =20 tcg_gen_ld_i64(val, ptr, 0); - tcg_gen_addi_i64(val, val, cb->inline_insn.imm); + tcg_gen_addi_i64(val, val, cb->imm); tcg_gen_st_i64(val, ptr, 0); =20 tcg_temp_free_i64(val); tcg_temp_free_ptr(ptr); } =20 -static void gen_inline_store_u64_cb(struct qemu_plugin_dyn_cb *cb) +static void gen_inline_store_u64_cb(struct qemu_plugin_inline_cb *cb) { - TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->inline_insn.entry); - TCGv_i64 val =3D tcg_constant_i64(cb->inline_insn.imm); + TCGv_ptr ptr =3D gen_plugin_u64_ptr(cb->entry); + TCGv_i64 val =3D tcg_constant_i64(cb->imm); =20 tcg_gen_st_i64(val, ptr, 0); =20 tcg_temp_free_ptr(ptr); } =20 -static void gen_mem_cb(struct qemu_plugin_dyn_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 =3D tcg_temp_ebb_new_i32(); =20 tcg_gen_ld_i32(cpu_index, tcg_env, -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); - tcg_gen_call4(cb->regular.f.vcpu_mem, cb->regular.info, NULL, + tcg_gen_call4(cb->f.vcpu_mem, cb->info, NULL, tcgv_i32_temp(cpu_index), tcgv_i32_temp(tcg_constant_i32(meminfo)), tcgv_i64_temp(addr), @@ -227,16 +227,16 @@ static void inject_cb(struct qemu_plugin_dyn_cb *cb) { switch (cb->type) { case PLUGIN_CB_REGULAR: - gen_udata_cb(cb); + gen_udata_cb(&cb->regular); break; case PLUGIN_CB_COND: - gen_udata_cond_cb(cb); + gen_udata_cond_cb(&cb->cond); break; case PLUGIN_CB_INLINE_ADD_U64: - gen_inline_add_u64_cb(cb); + gen_inline_add_u64_cb(&cb->inline_insn); break; case PLUGIN_CB_INLINE_STORE_U64: - gen_inline_store_u64_cb(cb); + gen_inline_store_u64_cb(&cb->inline_insn); break; default: g_assert_not_reached(); @@ -247,15 +247,21 @@ static void inject_mem_cb(struct qemu_plugin_dyn_cb *= cb, enum qemu_plugin_mem_rw rw, qemu_plugin_meminfo_t meminfo, TCGv_i64 addr) { - if (cb->rw & rw) { - switch (cb->type) { - case PLUGIN_CB_MEM_REGULAR: - gen_mem_cb(cb, meminfo, addr); - break; - default: + switch (cb->type) { + case PLUGIN_CB_MEM_REGULAR: + if (rw && cb->regular.rw) { + gen_mem_cb(&cb->regular, meminfo, addr); + } + break; + case PLUGIN_CB_INLINE_ADD_U64: + case PLUGIN_CB_INLINE_STORE_U64: + if (rw && cb->inline_insn.rw) { inject_cb(cb); - break; } + break; + default: + g_assert_not_reached(); + break; } } =20 diff --git a/plugins/core.c b/plugins/core.c index b3d0208e022..7ea2ee208db 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -336,13 +336,13 @@ void plugin_register_inline_op_on_entry(GArray **arr, { struct qemu_plugin_dyn_cb *dyn_cb; =20 + struct qemu_plugin_inline_cb inline_cb =3D { .rw =3D rw, + .entry =3D entry, + .op =3D op, + .imm =3D imm }; dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D NULL; dyn_cb->type =3D op_to_cb_type(op); - dyn_cb->rw =3D rw; - dyn_cb->inline_insn.entry =3D entry; - dyn_cb->inline_insn.op =3D op; - dyn_cb->inline_insn.imm =3D imm; + dyn_cb->inline_insn =3D inline_cb; } =20 void plugin_register_dyn_cb__udata(GArray **arr, @@ -361,14 +361,14 @@ void plugin_register_dyn_cb__udata(GArray **arr, dh_typemask(i32, 1) | dh_typemask(ptr, 2)) }; + assert((unsigned)flags < ARRAY_SIZE(info)); =20 struct qemu_plugin_dyn_cb *dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D udata; + struct qemu_plugin_regular_cb regular_cb =3D { .f.vcpu_udata =3D cb, + .userp =3D udata, + .info =3D &info[flags] }; dyn_cb->type =3D PLUGIN_CB_REGULAR; - dyn_cb->regular.f.vcpu_udata =3D cb; - - assert((unsigned)flags < ARRAY_SIZE(info)); - dyn_cb->regular.info =3D &info[flags]; + dyn_cb->regular =3D regular_cb; } =20 void plugin_register_dyn_cond_cb__udata(GArray **arr, @@ -390,17 +390,17 @@ void plugin_register_dyn_cond_cb__udata(GArray **arr, dh_typemask(i32, 1) | dh_typemask(ptr, 2)) }; + assert((unsigned)flags < ARRAY_SIZE(info)); =20 struct qemu_plugin_dyn_cb *dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D udata; + struct qemu_plugin_conditional_cb cond_cb =3D { .userp =3D udata, + .f.vcpu_udata =3D cb, + .cond =3D cond, + .entry =3D entry, + .imm =3D imm, + .info =3D &info[flags] }; dyn_cb->type =3D PLUGIN_CB_COND; - dyn_cb->cond.f.vcpu_udata =3D cb; - dyn_cb->cond.cond =3D cond; - dyn_cb->cond.entry =3D entry; - dyn_cb->cond.imm =3D imm; - - assert((unsigned)flags < ARRAY_SIZE(info)); - dyn_cb->cond.info =3D &info[flags]; + dyn_cb->cond =3D cond_cb; } =20 void plugin_register_vcpu_mem_cb(GArray **arr, @@ -432,15 +432,15 @@ void plugin_register_vcpu_mem_cb(GArray **arr, dh_typemask(i64, 3) | dh_typemask(ptr, 4)) }; + assert((unsigned)flags < ARRAY_SIZE(info)); =20 struct qemu_plugin_dyn_cb *dyn_cb =3D plugin_get_dyn_cb(arr); - dyn_cb->userp =3D udata; + struct qemu_plugin_regular_cb regular_cb =3D { .userp =3D udata, + .rw =3D rw, + .f.vcpu_mem =3D cb, + .info =3D &info[flags] }; dyn_cb->type =3D PLUGIN_CB_MEM_REGULAR; - dyn_cb->rw =3D rw; - dyn_cb->regular.f.vcpu_mem =3D cb; - - assert((unsigned)flags < ARRAY_SIZE(info)); - dyn_cb->regular.info =3D &info[flags]; + dyn_cb->regular =3D regular_cb; } =20 /* @@ -557,20 +557,20 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } =20 -void exec_inline_op(struct qemu_plugin_dyn_cb *cb, int cpu_index) +void exec_inline_op(struct qemu_plugin_inline_cb *cb, int cpu_index) { - char *ptr =3D cb->inline_insn.entry.score->data->data; + char *ptr =3D cb->entry.score->data->data; size_t elem_size =3D g_array_get_element_size( - cb->inline_insn.entry.score->data); - size_t offset =3D cb->inline_insn.entry.offset; + cb->entry.score->data); + size_t offset =3D cb->entry.offset; uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 - switch (cb->inline_insn.op) { + switch (cb->op) { case QEMU_PLUGIN_INLINE_ADD_U64: - *val +=3D cb->inline_insn.imm; + *val +=3D cb->imm; break; case QEMU_PLUGIN_INLINE_STORE_U64: - *val =3D cb->inline_insn.imm; + *val =3D cb->imm; break; default: g_assert_not_reached(); @@ -590,17 +590,19 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t = vaddr, struct qemu_plugin_dyn_cb *cb =3D &g_array_index(arr, struct qemu_plugin_dyn_cb, i); =20 - if (!(rw & cb->rw)) { - break; - } switch (cb->type) { case PLUGIN_CB_MEM_REGULAR: - cb->regular.f.vcpu_mem(cpu->cpu_index, make_plugin_meminfo(oi,= rw), - vaddr, cb->userp); + if (rw && cb->regular.rw) { + cb->regular.f.vcpu_mem(cpu->cpu_index, + make_plugin_meminfo(oi, rw), + vaddr, cb->regular.userp); + } break; case PLUGIN_CB_INLINE_ADD_U64: case PLUGIN_CB_INLINE_STORE_U64: - exec_inline_op(cb, cpu->cpu_index); + if (rw && cb->inline_insn.rw) { + exec_inline_op(&cb->inline_insn, cpu->cpu_index); + } break; default: g_assert_not_reached(); --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456586; cv=none; d=zohomail.com; s=zohoarc; b=DO2V3uw4oZiRPywTtGXu1H5t2H8wWgQzlLO49QM83wSLTpmMoyZIkLavx/Ufkv/5S0kpFXMwmQT3hDfnAJ87VCDRh8DstRNjK+VKlpJTzAIqB5LWfTpjSnVmJOfGKgKc3+RJ8xE+WhjelqyxXsVqLZie/+hztzicv51Mbnhngmw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456586; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/QfuoecfnqrMZjXVMkUyk45mCnFveAvGVHI65TWYIPA=; b=FnqDkvhC12MQVYZeFCDjC+VIWExCctSY5HuhivMW6IrBNeLQZ02ZFlo4aamnaByIO+ee1iIs5G0Flb8vGm4Zlirj0BqT9B5/zEe7RfyENblJFsolI5iP/mdQJqOXUO+Fv036RtznW3mN4tBW4iPys2iX4t80KS1U1XAp2460BAQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456586805916.558302021758; Tue, 26 Mar 2024 05:36:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp61L-0005RN-0p; Tue, 26 Mar 2024 08:35:15 -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 1rp61I-0005PS-Nm for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:12 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp61G-0000hK-Rk for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:12 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4148c6132b4so6864115e9.1 for ; Tue, 26 Mar 2024 05:35:09 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:35:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456507; x=1712061307; 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=/QfuoecfnqrMZjXVMkUyk45mCnFveAvGVHI65TWYIPA=; b=atwE7df5+t5ysT6qlNYPbt7uiCrvg1BcZ16XRW6rNXqxFgzQUpo3mXGixy/S8/e8P6 4QpGVJquUjJ/jf3ERhxTdVwhZTo5QUG7ouML8fGjrdR2hXCQHTsRJ4JpUfNBtKHYsdud LohMxubbRc/TrNV3WBd6zDPmL2EvgNHkjWkRV0ZauaiYBMSFlMSQk+Chz1nDuJtnYqJw DmvKDB1C4/zEsb3TBg640Sbm/EdytEYsbm4Ht6iaFPD+/6iqzBJJ7prjWs/65NKrIBon VHM07VNtYxcbcTitiSgCtfeWHtMFcSNV1kcJZDV5+j/qobWjcOdZGe7mj58DZr+cVwCL 70zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456507; x=1712061307; 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=/QfuoecfnqrMZjXVMkUyk45mCnFveAvGVHI65TWYIPA=; b=kuiZM7PWplMNb8WdzP0cASazwwd6KQbozPtFWCqxm02VYOxnM7OR7S0WDlVZ/eBtr2 4biK+Sre3je+FqOcaMjrJMpkzV9BRQ3SnQ9FKuklhn3oUAC5CIqqNnkdvbEzkGFP0616 +UvfJuwKPrpUHTLRYCBjcNcmFGQ7FE6pBDhipdbaVVyspdfHW87FnZShyffNwJHKuk25 Swr61sjtTmfNaHBIF9Nof8y8mOppbtW7JneULXJcAm82a/dplQedDKNBmIY/Y16DBJtf tohAjLvwuLpjRlB7qkJxgMXQhG1QdKrqysbcaUPPJZGyLhBq8bP9o/c61s/CV5LJoAki p0GQ== X-Gm-Message-State: AOJu0YxHhLZr2pwvR1KVG1j741VP2Dsl9yfGVrKAAZAB6EBfFgSNQTkq miYqKES4kS9RNF7PqR/7dXB3wLk4Q2V4HErklILpyQNHEGvDAQwX7HUq107gQNiBpo5ejXCJyDG b42Q= X-Google-Smtp-Source: AGHT+IFK18wsRKqW/l9tBFEUG6+AjzKD9uBgDb6iNqYZhRGoscdCf9HBhiISCw6/W1LWAfj7oJiUfg== X-Received: by 2002:a05:600c:3217:b0:414:6467:d8e9 with SMTP id r23-20020a05600c321700b004146467d8e9mr1250601wmp.17.1711456507429; Tue, 26 Mar 2024 05:35:07 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 8/9] plugins: extract cpu_index generate Date: Tue, 26 Mar 2024 16:34:25 +0400 Message-Id: <20240326123426.761473-9-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x333.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456587983100011 Content-Type: text/plain; charset="utf-8" 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 d00a2b3fd67..eaa0160cab1 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -108,12 +108,17 @@ static void gen_disable_mem_helper(void) offsetof(ArchCPU, env)); } =20 +static TCGv_i32 gen_cpu_index(void) +{ + TCGv_i32 cpu_index =3D 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 =3D tcg_temp_ebb_new_i32(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + TCGv_i32 cpu_index =3D 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))); @@ -128,9 +133,7 @@ static TCGv_ptr gen_plugin_u64_ptr(qemu_plugin_u64 entr= y) char *base_ptr =3D arr->data + entry.offset; size_t entry_size =3D g_array_get_element_size(arr); =20 - TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + TCGv_i32 cpu_index =3D 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); @@ -163,7 +166,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 =3D gen_plugin_u64_ptr(cb->entry); - TCGv_i32 cpu_index =3D tcg_temp_ebb_new_i32(); TCGv_i64 val =3D tcg_temp_ebb_new_i64(); TCGLabel *after_cb =3D gen_new_label(); =20 @@ -172,15 +174,14 @@ static void gen_udata_cond_cb(struct qemu_plugin_cond= itional_cb *cb) =20 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 =3D 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); =20 tcg_temp_free_i64(val); - tcg_temp_free_i32(cpu_index); tcg_temp_free_ptr(ptr); } =20 @@ -210,10 +211,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 =3D tcg_temp_ebb_new_i32(); - - tcg_gen_ld_i32(cpu_index, tcg_env, - -offsetof(ArchCPU, env) + offsetof(CPUState, cpu_index)= ); + TCGv_i32 cpu_index =3D 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)), --=20 2.39.2 From nobody Sun May 12 10:01:16 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1711456598; cv=none; d=zohomail.com; s=zohoarc; b=HJZZU/WYC3Ml4z2D2kzhVaZbjoSHO+jjzbZ240DRwThGE2o+F9Ac6cVgZd0OuH7NWUTHEJzfMDSbmfOgxqevUVAtkKr1b2nTee7j5Rf0IwR2yq095e2AwVoAeEmquU4FedveTgZwvdPJMpZhAwP81UdD86qyRJ7WHhcc8UqdQ58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711456598; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+vj9khMMybYoBi53WQZnVBkx0fV+CetJXYOmHrrh01o=; b=hGYMlnWW9vRw0Lnz76ZRmhjjG/s4rEmYNq4NTgQ1OsVda1ZGqKfmup0J2KoSKk5ZLUAGCfcIyYU5DobJ97KcvJWp7HfMeI1IaSILE5j9T8PDiJb+ywUpJ+idhwnTFC+pHkFKVUSB7RN5PzUK6GubQQTw+m/eC9zobdZMPcShcNE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1711456598727904.9493252341365; Tue, 26 Mar 2024 05:36:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rp61L-0005Rn-Lh; Tue, 26 Mar 2024 08:35:15 -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 1rp61K-0005RA-Rl for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:14 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rp61J-0000hx-8y for qemu-devel@nongnu.org; Tue, 26 Mar 2024 08:35:14 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-41490d05b2cso1139365e9.3 for ; Tue, 26 Mar 2024 05:35:12 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id y19-20020a1c4b13000000b004148090cf85sm716317wma.0.2024.03.26.05.35.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 05:35:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711456511; x=1712061311; 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=+vj9khMMybYoBi53WQZnVBkx0fV+CetJXYOmHrrh01o=; b=J+G0K6JbS8wS7l+jGAQm1RQje7YrzpmzneMlMkZ8vd99jbAoX4rafrLYjEZYGSQbkm DI96VtjpMNMc9SMlTm6FOt96iULwilqKqhhOE5QBJnbTlIva2xNVqAoyKKodeEsejyLI 3B7GL/N/0M80C+Bi017TaXdNdT8jX609/q6fYfu7zbiDSHMnGiRNscg40jivbJhaSFT6 ui16KnedThoQCdTrWWBLQx4KQk8qh9htdQk/WjicsxfKsiRSBpkXEf0cCZVn5DHy/ReG ssO1f4VJMFfrfMtlY0TIwnSxFEZZf2lLtDob/9r69wcpp0swbIfJD7XD4qqFbCHp3XpY G0kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711456511; x=1712061311; 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=+vj9khMMybYoBi53WQZnVBkx0fV+CetJXYOmHrrh01o=; b=AYOqE+rawIRzeI5cx3E7DrvwCPtCkK6DnkAdXPg8imxj29J8TG3R7Ph8y4fe6s7tHt G+S7RSywbP5wPdTHyNqEBEhmDvCIPUmjG/TsnXxy32ebSn4/X+84WGFG9zuVKR7Kf7DS b2FHd5NHtUqT1JqniAGSkuCm75EnjYNgMKkfRPh5vlYDwDVCBvJhy6BmkCXtqPcfGfRr g0rdl5ifCQyqpWd9fYRCWQkAVqu0RGNO1Fot3nz+hdQQ6xlVK7F0/1CuCiXW84nEUjMm Nr5KtqMWrkxhGCDZixpNNcAz0x+F6kS21awmN42J9/7xjY8zh1qzN+GsNHW1P3rkarDk MGsg== X-Gm-Message-State: AOJu0YxuGDfI1jmjc2lj29ODOQ8nrCW6X4Lf5gDq9BJ7bu2gzBon9P/v K+B1mMe+7IQqEtMkGxuk86//cqzTUaYH23mxSacY+ruWXNDLAvxthAioXozHTXf+MdK390e09ej qvig= X-Google-Smtp-Source: AGHT+IEW2z6C8OOwCwfZ6zUa7Lq4sTm3MXTQlkJJeVaJMOVscAwW0oyaoNKi0/QUS5moS56Hb5deGg== X-Received: by 2002:a05:600c:4ed0:b0:414:e24:12b4 with SMTP id g16-20020a05600c4ed000b004140e2412b4mr2006116wmq.34.1711456510933; Tue, 26 Mar 2024 05:35:10 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson , Mahmoud Mandour , Paolo Bonzini , Alexandre Iooss , Pierrick Bouvier Subject: [PATCH v4 9/9] plugins: remove op from qemu_plugin_inline_cb Date: Tue, 26 Mar 2024 16:34:26 +0400 Message-Id: <20240326123426.761473-10-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240326123426.761473-1-pierrick.bouvier@linaro.org> References: <20240326123426.761473-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=pierrick.bouvier@linaro.org; helo=mail-wm1-x32c.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1711456599996100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/plugin.h | 1 - plugins/plugin.h | 4 +++- plugins/core.c | 13 +++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index a078229942f..7f7b915e495 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -82,7 +82,6 @@ struct qemu_plugin_regular_cb { =20 struct qemu_plugin_inline_cb { qemu_plugin_u64 entry; - enum qemu_plugin_op op; uint64_t imm; enum qemu_plugin_mem_rw rw; }; diff --git a/plugins/plugin.h b/plugins/plugin.h index 80d5daa9171..30e2299a54d 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -108,7 +108,9 @@ void plugin_register_vcpu_mem_cb(GArray **arr, enum qemu_plugin_mem_rw rw, void *udata); =20 -void exec_inline_op(struct qemu_plugin_inline_cb *cb, int cpu_index); +void exec_inline_op(enum plugin_dyn_cb_type type, + struct qemu_plugin_inline_cb *cb, + int cpu_index); =20 int plugin_num_vcpus(void); =20 diff --git a/plugins/core.c b/plugins/core.c index 7ea2ee208db..a9f19e197aa 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -338,7 +338,6 @@ void plugin_register_inline_op_on_entry(GArray **arr, =20 struct qemu_plugin_inline_cb inline_cb =3D { .rw =3D rw, .entry =3D entry, - .op =3D op, .imm =3D imm }; dyn_cb =3D plugin_get_dyn_cb(arr); dyn_cb->type =3D op_to_cb_type(op); @@ -557,7 +556,9 @@ void qemu_plugin_flush_cb(void) plugin_cb__simple(QEMU_PLUGIN_EV_FLUSH); } =20 -void exec_inline_op(struct qemu_plugin_inline_cb *cb, int cpu_index) +void exec_inline_op(enum plugin_dyn_cb_type type, + struct qemu_plugin_inline_cb *cb, + int cpu_index) { char *ptr =3D cb->entry.score->data->data; size_t elem_size =3D g_array_get_element_size( @@ -565,11 +566,11 @@ void exec_inline_op(struct qemu_plugin_inline_cb *cb,= int cpu_index) size_t offset =3D cb->entry.offset; uint64_t *val =3D (uint64_t *)(ptr + offset + cpu_index * elem_size); =20 - switch (cb->op) { - case QEMU_PLUGIN_INLINE_ADD_U64: + switch (type) { + case PLUGIN_CB_INLINE_ADD_U64: *val +=3D cb->imm; break; - case QEMU_PLUGIN_INLINE_STORE_U64: + case PLUGIN_CB_INLINE_STORE_U64: *val =3D cb->imm; break; default: @@ -601,7 +602,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t va= ddr, case PLUGIN_CB_INLINE_ADD_U64: case PLUGIN_CB_INLINE_STORE_U64: if (rw && cb->inline_insn.rw) { - exec_inline_op(&cb->inline_insn, cpu->cpu_index); + exec_inline_op(cb->type, &cb->inline_insn, cpu->cpu_index); } break; default: --=20 2.39.2