From patchwork Thu May 2 21:15:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 794142 Delivered-To: patch@linaro.org Received: by 2002:adf:a153:0:b0:34d:5089:5a9e with SMTP id r19csp456716wrr; Thu, 2 May 2024 14:17:50 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVaxD5labxnPIedhybS4yw8YRTKf+9Z7XkFmnv3MoyO1NKsl7GNsbWj7HgA/ZFmNfW8Ax4Kla+fFd+pFJQaNXnq X-Google-Smtp-Source: AGHT+IE8aYR5/l1LSwzES//FIn2nVpIlvtkaKbKK+1wGfuL9IlH+Y5H1GlvMTdKedcEzpYpFCGGh X-Received: by 2002:a05:620a:2687:b0:78e:d154:2ae9 with SMTP id c7-20020a05620a268700b0078ed1542ae9mr1071280qkp.63.1714684670446; Thu, 02 May 2024 14:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714684670; cv=none; d=google.com; s=arc-20160816; b=IL4T4ZSCsKYmuDGnTYykgjLfDHrejA5RrNRv3/HVdnkBd7HhEaTnqck+NZ+E63i7/k tFfPqHD9TlqzSv/Blbww+FKrM3F5q4TX2FRpwmsroySz2nIPozDdUvIC1z9bdis4M3j6 z6AT2ASJSSwEqGfThPaQrfH5W7C7garudxGvPLFrJP87fLmOgyG9GQZtyDnNierLFy0E 1bzfTNI97/+zU5tCl4D9lIIaN9B5oz0ethY5+nDoFU2bYv+asVr8wA9D0XUP1uWkhxEE IGq3MSNL46uHx0lwKjK+CALS/MvWEuksZuUcOer0zUKEc/pcOuoUTniIlmDx9Z4A/ny/ gYEw== 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=V/rxl0DFSSivsJa4rLu0a/ciqRjYxWdYfAVWic0qz6E=; fh=9xGhv+1UliIX34j+rhFuVtnm9fBdMYzeJdXCJAB33Zg=; b=yjDpkNYqTZCd9TL7OrivOrSDArOEKWqRVoWCDcHdSOvRVI1Rpfn2p+xiLoc1qF7Ux2 MjWK0S/0gyGNiGcx50OP/jEomjekwGeUvguaU8/tDIyuW75vBMyJYGW5hqojFabaqXfA 5/9AWAdWeT5dSPhk/tvgD5GBdI9srZNXIdwrlRqDSbfUkWrYYK4UWOTGiae/ey7iZNdk OyiPpJk2RV7uIkxPMY/YzTNh+WdMm3/1X7gHxUyj5E2jrrazugxpRVHLCK+3ADU8ADB2 1ARk9aEestrwWHA2+qo81ZQhVwce5fXWQueZS60Q7+0ZpxjRta1EZ2LLcTK8zBqqSWuL bpsw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Lct03jKk; 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 r27-20020a05620a03db00b0079086bf1d7dsi1798755qkm.178.2024.05.02.14.17.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 02 May 2024 14:17:50 -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=Lct03jKk; 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 1s2dmK-0008LT-7P; Thu, 02 May 2024 17:15:44 -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 1s2dmJ-0008Ku-EU for qemu-devel@nongnu.org; Thu, 02 May 2024 17:15:43 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2dmH-0002oU-Mo for qemu-devel@nongnu.org; Thu, 02 May 2024 17:15:43 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-6f447976de7so528434b3a.1 for ; Thu, 02 May 2024 14:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714684540; x=1715289340; 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=V/rxl0DFSSivsJa4rLu0a/ciqRjYxWdYfAVWic0qz6E=; b=Lct03jKkdvHEj906xnP3L7p591Z/mqVeH+RxkXLaJNOt2Gptk44PNTEx+SRzSzhfj1 GasQek0viuSTLd20PvrOL4vmJCwm6mseiVVYt4VZ1eupP65w/ROFEsxO45pLrBn/1+th RyT/VOTV07714ym21CTczpNlH4b0IXkVFqPRcZFo3kqqOI1uR38/lt7yIR3+FQIz0qL/ RSsy9Yd0hx9nX/asass4GzJQ9pZGw5lYYDye480pjJ+pTx6ATdycH3hduryGcagiE56x 2IymjADdj64aUZwddx26z57iPbGwwOE74lfG8Rckb6KT4xzrFYxqqk0WVZwvQNvDxVPj Pk0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714684540; x=1715289340; 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=V/rxl0DFSSivsJa4rLu0a/ciqRjYxWdYfAVWic0qz6E=; b=Kbxm1OsC5BUJvQTywqT9v07SkinJVuKZ46jrrUJABB9c2CleRbWf/gugBs60CHcDn+ 6O8rzE4jhG2DvRAVbmPdhME0FTNFoTqecLySTN5Wxk5ebKhoYULz/QODI0zAWdAkP3Qt PuCF6BRHmV/cbA4rCn0hideoCQ9QwMHabfD3dwST2Ahs7AGbhqOXNTkWlO+0K36mU/Ps pzftHgUBUv776z34oaLZ4uythdiBrcxJKpQYHjXQWPuTJIHw6h/FTPgPVXYim4ahU1UC pMq5liOo1wnDMrQllXafZhS3Zw/vauU55z+XA3lo9Rjytn+hvNJPrury3nWHUiOSNRtB 8J7A== X-Gm-Message-State: AOJu0YzaKJAuttd3aDM60WAB/pYRkKLL4rm+l4iDXIQygABgS2OQQjC5 NvKnFgbLrxe0A7aNCTYoRXiqAupS376TU/fqut/mFB1NzrmVwCwlljB4vOLnNGI84yMusSuwNrs HP2s= X-Received: by 2002:a05:6a20:979b:b0:1ad:9358:25a7 with SMTP id hx27-20020a056a20979b00b001ad935825a7mr847090pzc.15.1714684539836; Thu, 02 May 2024 14:15:39 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::ecd0]) by smtp.gmail.com with ESMTPSA id d14-20020a63f24e000000b0060063c4be3bsm1700915pgk.14.2024.05.02.14.15.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:15:38 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Mahmoud Mandour , Alexandre Iooss , Richard Henderson , Paolo Bonzini , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v6 3/9] plugins: add new inline op STORE_U64 Date: Thu, 2 May 2024 14:15:16 -0700 Message-Id: <20240502211522.346467-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240502211522.346467-1-pierrick.bouvier@linaro.org> References: <20240502211522.346467-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x42b.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 This new operation can store an immediate u64 value to a given scoreboard. 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: