From patchwork Mon Mar 25 12:41:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 782324 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1149592wrt; Mon, 25 Mar 2024 05:43:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUE1sMIvq86IkXKU5EaIKYzyXP9goG3pUyd8RgqXK1bA+tKbTSwKeVPY4Y9w5+wXBzdMbk7GCtS9Ho0iMFhNr7D X-Google-Smtp-Source: AGHT+IEi7xxQprsJAgXhYwJDyW/ZvWeUPeRfgPElgaTQMMFlWwikiWYwTqGjuaPPL6mYEeB8oN5m X-Received: by 2002:a05:620a:24c9:b0:78a:599c:e449 with SMTP id m9-20020a05620a24c900b0078a599ce449mr2214628qkn.58.1711370593059; Mon, 25 Mar 2024 05:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370593; cv=none; d=google.com; s=arc-20160816; b=cuwc97lhmSl1wk6XqFFaFkB9LAnnxKaeQvwh0GC1tn+5smyLNBAMPIZImfATncK38R K08TUVf9Y/swwVU4gJX5yEc1rH9VLMTzUqEnhRjo8Hn/aLCbXNbEsiO8Fl0EVcrHsx3A CIbZDHHsP3VLpJ6LFKaJeQFmrr/EQHEgj6pvGB88c02Jc/MLT55YZO3C6I4ycIesT//M nrxaijr3+6nzRxMcjaXifvLHToc2F6AwuEIcD4UuMB/1yhdB/wEgyri6CtVusG89kA70 Aol/i0xmyOX4ya+o10pV7viaWN+QZlydV+wksGgQt1njiH7PJvZ/T8A9SBzoMpXKnBkl 4JhQ== 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=xa0cGVykUGxKfnAtL7QB1M6ycqNL5KJpeAnibJ6bZdY=; fh=lDUBIxRmlFMVCYepQTPJQoo4dC2bnsDTL2QxjcosbcE=; b=s7zUJC3s344l8eEc4fm4trmKzXVBJyTPpfil8iVJUM1S/e7aZ/nYzLs/TNvuR33zSL 05nssCpfLg7PEsGcHORGhMRzFW2DfR2o7I4JSTMYD0CgYYfBJ+tYGIzZctZ2L89lAzsc VCsKL9qYBzKVr4sgCsFWxlM8FVPR6AAO5o6C/Vg39dKJeeBWfz2WFyqy53DXifgaqhiU yNsDmLkzKK7YDa0xJEwO+Dz/ri5vvbcxyJ3GTXDHJvX0Wvetk1nVN9mM4gmqTBqRZzRS hu4oK9jQjPj9VMHhWON9QlGKqdvYcmQ3WGk5dvDPcGDiDUEdpYUHpzpcm+V84G/ZmX2V sMnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NnkUHyGs; 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 v2-20020a05620a0f0200b0078a48a8e4aasi4857545qkl.450.2024.03.25.05.43.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:43:13 -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=NnkUHyGs; 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 1rojfF-0000Vx-BK; Mon, 25 Mar 2024 08:42: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 1rojec-0008SX-9R for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:42:24 -0400 Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojea-0006e3-GC for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:42:17 -0400 Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-512ed314881so3074958e87.2 for ; Mon, 25 Mar 2024 05:42:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370534; x=1711975334; 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=xa0cGVykUGxKfnAtL7QB1M6ycqNL5KJpeAnibJ6bZdY=; b=NnkUHyGs/HYkPiSBIwE7e5Ohrbd9JtgDr2RfrchwbTtYGCiEJQy1+SRU2x2KXDUx2M ceFDNvboNwWY5NAbfkoIlZC0OYxeKgx+icBsfTQIFrlJzBrrSVgumQS4hLgHNo+Kfv0V HkEYV+tuH9q8RXfgG+cudOWsXpTyHqet41AmQJrxznpw61YzaPXNllWik8KB/fJkxmFH AS43yclALMVi0mAo3eWMv++DkQ9gr8RuO4uN4EW/GUT2UTByAluVcjpHxVnXM5xQDpHg 4JE5MnIfLu3/SWES3bEcYdHYWuIeQj4yF3o/AnvE48R2J87wND5TdCd/PZ7w7PrKxpyN 60rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370534; x=1711975334; 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=xa0cGVykUGxKfnAtL7QB1M6ycqNL5KJpeAnibJ6bZdY=; b=NpT2S3gN9Vdma3FLypfnVNrHlR59R0Tr58gPlBcwWIKy8CBkaYm4dZCpipkV//lPTX 5B9cziTWqNZ5q+kh/Eq+KqI47JY5RUbV2snkChBwYpitiaQdNhavQk5Zfeqq1XyqLYDX OdH/CJhy2Y6jXC9KaMBkCiJl+TOK0KSzt9+G4qL4EIlx3SstqIPkz4dbveJce8R9pUnu J/9bdfitokBqGocF7Vx6FWyFL7H5YClwppS8bi2+8YSSf16CX9Y7Tz8qEpQLFQWKMoML 9qJh8Up/r5lJzR58ZJ2eb8on6wTY8pWU1x19Latpfl80KrsYymeWaXWUij38cRe0jnLd RAxQ== X-Gm-Message-State: AOJu0YxV0CsyMu7NY1xbRop4tB0KZAdZFnPr1jpTeO+3xRmmOcs2zGTC Uxx699AKYekfQ1QdhQJP0mk0IzhekyE0VXv7n+G6Z6xTvyxSXvKN79F0hrKL9G4P7sASlpoYWEp w X-Received: by 2002:a05:6512:70d:b0:513:13eb:c99b with SMTP id b13-20020a056512070d00b0051313ebc99bmr4933812lfs.62.1711370534389; Mon, 25 Mar 2024 05:42:14 -0700 (PDT) Received: from linaro.. ([102.35.208.160]) by smtp.gmail.com with ESMTPSA id t20-20020ac243b4000000b00515b1b3a2bdsm35231lfl.194.2024.03.25.05.42.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:42:14 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Alexandre Iooss , Pierrick Bouvier , Richard Henderson , Paolo Bonzini , Mahmoud Mandour Subject: [PATCH v3 3/8] plugins: add new inline op STORE_U64 Date: Mon, 25 Mar 2024 16:41:46 +0400 Message-Id: <20240325124151.336003-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240325124151.336003-1-pierrick.bouvier@linaro.org> References: <20240325124151.336003-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=pierrick.bouvier@linaro.org; helo=mail-lf1-x132.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 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- include/qemu/plugin.h | 1 + include/qemu/qemu-plugin.h | 4 ++-- accel/tcg/plugin-gen.c | 15 +++++++++++++++ plugins/core.c | 6 ++++++ 4 files changed, 24 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, }; /* 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 d3667203546..45856a75cda 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -152,6 +152,18 @@ 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_temp_ebb_new_i64(); + + tcg_gen_movi_i64(val, cb->inline_insn.imm); + tcg_gen_st_i64(val, ptr, 0); + + tcg_temp_free_i64(val); + 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 +189,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: