From patchwork Thu May 2 18:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 794132 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp388704wrr; Thu, 2 May 2024 11:11:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWuYE89R3U0WJLAoYAY3DSB7EqGP1E/PgkCTiQK/wWIDUzSm8dy3qGXAw0nD96Vi+YfQUPv78vzgCHFnU4QLVpV X-Google-Smtp-Source: AGHT+IFE+GHicWPT4dOVLzsizFYZxz7cBaVlb2pPZrDYL0XBRfogpdkBAYe7ODUSCqYVxZ5LHBVU X-Received: by 2002:a05:622a:1207:b0:43a:a89d:ee8 with SMTP id y7-20020a05622a120700b0043aa89d0ee8mr272734qtx.58.1714673516259; Thu, 02 May 2024 11:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714673516; cv=none; d=google.com; s=arc-20160816; b=WX4VtB6k5kEMPPdhEg2o5+orl6jkej6zmXMEfhnlhjHk4+vQ+VOVApfa4eRiEM8BeF uyAsojDSQr/6tfDKQM9XrL2ieqdfZfP4zi2onxN3PkTLJMI6WrxuXHmlMPYj00cTcb8I NGOwQyMSKIcXmQAxfZahdBdD4JjChpubZPu3+vFEbWBmr/rFwO7IUh+sSw6OM0f063Rz P0Th7vQuwD1HrfnoC3KNFwCCjpxMu882nxVFqG5hLmfkACEAJS0O1Y/nC6GpdYuNCkyA 6h/BrrjEHuwya/mD5gXkBNOgt6IqaBe80qb6e6oM4eK3WqrtPPJ8D0POvJ+qcXdTAt8r eQ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NSeK0Xfs9eq2wodWsR8+v2lG4Bqi0BcZDktPkPqvPZ4=; fh=cGQQHKa+VmgbxLLxTvBCsw0Hx1TzppraI5gmJtpkFxg=; b=bD8Psw1IoLfFUOSPNzavBhnsc4utjMyjxBV1lmhC/CDOBWoo3tmNJ3Tj3Mh3g0N26y laSga3LozCGRmpAnemig4b3m1aig2Cw5JWYehikpfw1rb3PuzwMuUoJG7BoPaYf/DHzL j20nxO/wjBc7JKwh3+0FL2xbcVphM60C+/wgWMRf+8Dy3zVGaOofC7u31n6mpLIsQTkm 9BerTyUZq9skbnECJnbdtZYfdDAQxqIDLhKNKKUZy+INFVrv+ogEfxip7HW707rztEJR z50gBGDYt0aV0FF9pescbgyl4ch8I4cumEXr+x5oOqDFy9Rvr/YhyZCcaVDz4SvuUE+9 yqAg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITM8h7I1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w2-20020a05622a134200b0043ae5af838asi1609739qtk.375.2024.05.02.11.11.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 11:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ITM8h7I1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2arx-0003GK-BI; Thu, 02 May 2024 14:09:21 -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 1s2ari-0003Ac-2L for qemu-devel@nongnu.org; Thu, 02 May 2024 14:09:06 -0400 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2arg-0003QQ-AL for qemu-devel@nongnu.org; Thu, 02 May 2024 14:09:05 -0400 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1ec486198b6so27785315ad.1 for ; Thu, 02 May 2024 11:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714673342; x=1715278142; 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=NSeK0Xfs9eq2wodWsR8+v2lG4Bqi0BcZDktPkPqvPZ4=; b=ITM8h7I19+wZVExADKEgl8wzT7M0YGxxU2lL4LydCd/FDwR5CBQFE1dN7/1t4rD3Qe xLaJChoQXqUYmUcRRDLWPzk90Omt7w55+/QImzntxru9zdkM83CO23GGvkgkU+v/YcBA M/MEBf04lvgD4QaTUMgG6Uq6VnyDDmTyUWaeYuEt2eSa5RQAsvVs6bbPSSLKNheG+ioe txmKqsvA+F1C220O0VYO65meU9ChNNFjfqA6IUjyx67WFLL/zJIcBCxCRhf2yU/eewbX pxLJ0yL2YQKkV2boEYWczXFR018u0jJflDMfJHkG0yO+P2RmggYHAI8A25lZRaUkpWzt FMVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714673342; x=1715278142; 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=NSeK0Xfs9eq2wodWsR8+v2lG4Bqi0BcZDktPkPqvPZ4=; b=jbhM1GJL9q9gdrvmTY272f+XZcYQScA5/oZggRso5545aIc1FnUrWU7hfQFWhaJiEW Xnubbcy3dLEGuouwFbUMlHT+mCXwzZMcreOulpxMDnfK5YFTxyyaEiFHjqvhfQFP1DTc I+XT6Wr78Uwaq6pc1VM3uAaB9ovLOVQveQcBgeiLHQq/RRQtYVn5KSF5qZpeGegksI8D 37ET0GLr4cvHi9CnbC5JGNMakLx3kL8koiX68H3Xr9DT9wskGwVYTbS+LOcrsFYh+KUI dW/01kUGVNafAMWJFtZyHWLtmJoVmWPm8K7Uyw846TIvj33tUrzudXMENV75s2mpi6Yg EHNQ== X-Gm-Message-State: AOJu0Yx6D4e68VkzrJw3WYYaCEn/9rROyhJtLaVMSISXrwSHpH+PWU8+ giSW2Zbv7v5Ei/8ww0XbIZKP+uFqolVNswOakG4pVUAmvmPZxtMFrmawmShmKuKm77S4obER3wG dF4I= X-Received: by 2002:a17:903:2487:b0:1e4:c07b:a8e0 with SMTP id p7-20020a170903248700b001e4c07ba8e0mr401748plw.66.1714673342454; Thu, 02 May 2024 11:09:02 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::ecd0]) by smtp.gmail.com with ESMTPSA id c17-20020a170902d49100b001ebd73f61fcsm1615605plg.121.2024.05.02.11.09.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 11:09:02 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Mahmoud Mandour , Richard Henderson , Alexandre Iooss , Paolo Bonzini Subject: [PATCH v5 3/9] plugins: add new inline op STORE_U64 Date: Thu, 2 May 2024 11:08:41 -0700 Message-Id: <20240502180847.287673-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240502180847.287673-1-pierrick.bouvier@linaro.org> References: <20240502180847.287673-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Reviewed-by: Richard Henderson Signed-off-by: Pierrick Bouvier --- 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 bee1647cfc4..0c5df7fa90a 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -70,6 +70,7 @@ enum plugin_dyn_cb_type { PLUGIN_CB_REGULAR, PLUGIN_CB_MEM_REGULAR, PLUGIN_CB_INLINE_ADD_U64, + PLUGIN_CB_INLINE_STORE_U64, }; /* 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 */ enum qemu_plugin_op { QEMU_PLUGIN_INLINE_ADD_U64, + QEMU_PLUGIN_INLINE_STORE_U64, }; /** diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index 8e2c3ef94f6..a5313cbbb2f 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -145,6 +145,16 @@ static void gen_inline_add_u64_cb(struct qemu_plugin_dyn_cb *cb) tcg_temp_free_ptr(ptr); } +static void gen_inline_store_u64_cb(struct qemu_plugin_dyn_cb *cb) +{ + TCGv_ptr ptr = gen_plugin_u64_ptr(cb->inline_insn.entry); + TCGv_i64 val = 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) { @@ -170,6 +180,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 += cb->inline_insn.imm; break; + case QEMU_PLUGIN_INLINE_STORE_U64: + *val = cb->inline_insn.imm; + break; default: g_assert_not_reached(); } @@ -562,6 +567,7 @@ void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, 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: