From patchwork Tue Jul 2 01:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809014 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830638wrr; Mon, 1 Jul 2024 18:11:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOl+8H5YmubWtv+NXOuOBt2x9Z1m4jKvZGa8hGdf/N+fODxpOynnqnDo4EBlmQU5FX7OlZyo7CuOsVsmTJDFpY X-Google-Smtp-Source: AGHT+IHAdlxnlADY567sOmybEaPlIesosiy/0WR//XAgStOacGdNaPIHCPhFyjLZ5KzmkP+ZuA/+ X-Received: by 2002:a05:622a:49:b0:441:382b:75c with SMTP id d75a77b69052e-44662df1a75mr80353871cf.20.1719882678089; Mon, 01 Jul 2024 18:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882678; cv=none; d=google.com; s=arc-20160816; b=DnWJ4Ai0yo8qoMeGPD/MGHzu1FgV594POyk4ERg+cXFnxCS+s/ZqFjwdj1CDJZhzhV pJRBwAfvzzj5zIMq+iRHVJLKJeHRxocMHtDdbRmloH1S89XmX785d/D0bi+bjClnRfsI s2+UyYkkvb5QbdRqS5hpDEjd14R/Je9ELBcaxFJS9u7+77FHJYb5kZxhr1weyvahTnr+ ruNSGXt9Ju/kfUbqeMbWVR3Gz3JFrF4+fdqQwtQEgcck/XMIK9D5jzGxp8fyqyik94b3 VlHgxDcJzfbxxN5BUpb+E8lL/9dXaz3L4OPPfy41Rsq1g/xSdVZKVsE7+0nN6JT70rU/ S6XA== 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:message-id:date:subject:cc:to:from:dkim-signature; bh=knxfm46spRW6D4Stc09Cap/r3lb612NK/daP3Um8g20=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=ixqCU5DZkSFM5Jep4uUVS6QFjgwz2vZyJM9+z7SkBKkCCh+dsZCsFJmZPXLEaEuoIQ /OulbFwW1tXlsNi63f8ohJxO9IfD1g/H1FpifKRWTSiYtpSAynWypIUg917CluNVB/0p dbRJoDx+359UiK7h8iVNHk3UEjiplRK2POJN3JxQ+CWSxPKLhVKXx1u4k3cjfCxQvlRY dVkYnqgocz1S+CNBSc4NqpPKPQPKewYfPFzReQpG1WStovH7hGC9SFwGavjWhULB+UkH ujS9nttT4K7VGpX7xOWU2VlWN6KKvXdUPUWBYOXURBMNrkQoXIdo0G07xxi8oe63mrX8 kStQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oc+erbzv; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-446513c16f9si94510571cf.108.2024.07.01.18.11.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:11:18 -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=oc+erbzv; 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 1sOS2Q-0005PW-Ds; Mon, 01 Jul 2024 21:10:31 -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 1sOS2J-0005Ou-Il for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:23 -0400 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2H-00029r-Q9 for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:23 -0400 Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-7066a3229f4so2225826b3a.2 for ; Mon, 01 Jul 2024 18:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882619; x=1720487419; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=knxfm46spRW6D4Stc09Cap/r3lb612NK/daP3Um8g20=; b=oc+erbzvTeJEdEAsxXZOjIgFEdxJk2VpawUPNtuK3fZJn91wQJ2fu7PkQt9+rxT2w5 G0I6Gi7T+H1cPfrLnHO+oUOZMOYyZjZb9VZuHLS8yJj5lKhFJNeBnqMoYi8c5bqRtP2F B0HL3/Z6NjfVZcTBUAwZz6dipTSREv2UlKhhogZu+6hUmCtIIowiSPZGOLadf7FFTDIE EGB/QMay2CaASbLuP5b7YkDl9TSDSZ2EBOuouUKiMiFo3UexH5rFjO19YCNhdP9w4nGC 7s5cIv5tH4abM8dR6SYmKbqzXqWkYzv8q4Fszy7Z9pStYS2iT5LQvRIBC0ktel1k5hkt Uycg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882619; x=1720487419; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=knxfm46spRW6D4Stc09Cap/r3lb612NK/daP3Um8g20=; b=amm5FwA931uSR4KDkttQ/VKZoRPTEyKClJXH6XYmmtXkhgsMTMk7feAesiM+km3SVn pqXSYI5XJWEN0kZuuxe7IrnGB0xrjJkdRFGKxvA5Q71PfN8rF2MaL+3QLuwHCTDr87B6 eckDNh2QjMC6J4g2PjTfXBCnUzmCwNawIWRjUBPvwPCuJa8GKLDtbA76x6l6KFdvbtAx fvnNCSXSt3b+mRQ6Bv6ZmemMdt0r0ZiAe5lX/DalWJGyVGMkeEgznXY3Ub0bAhNcQRJI eBFkypDrb+zQu03bPtzHBCqCjdYciJwY+Fz37XfKC3ZZSMNWBi+mvfMowjvwJqDJ+Rog TCwQ== X-Gm-Message-State: AOJu0YxXanezZzViRgpr9wREGFPCewvgj32hYoEsI6G+euZ6epii0rGP w5i/7Lbi+bOrBVWhEzUbyREgZGz5g4D+mFgb4JJb6plsLzhp7fMhVlPPNTkmWcw//l42y8cK1YG 4 X-Received: by 2002:a05:6a20:cd92:b0:1c0:80f5:425b with SMTP id adf61e73a8af0-1c080f545d7mr1938915637.61.1719882619435; Mon, 01 Jul 2024 18:10:19 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91ce1f198sm7480317a91.2.2024.07.01.18.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:18 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Eduardo Habkost , =?utf-8?q?Alex_Benn=C3=A9e?= , Pierrick Bouvier , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexandre Iooss , Richard Henderson , Mahmoud Mandour Subject: [PATCH v3 0/7] plugins: access values during a memory read/write Date: Mon, 1 Jul 2024 18:10:08 -0700 Message-Id: <20240702011015.325609-1-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::434; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x434.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 series allows plugins to know which value is read/written during a memory access. For every memory access, we know copy this value before calling mem callbacks, and those can query it using new API function: - qemu_plugin_mem_get_value Mem plugin was extended to print accesses, and a new test was added to check functionality work as expected. A bug was found where callbacks were not called as expected. This will open new use cases for plugins, such as following specific values in memory. v3 - simplify API: return an algebraic data type for value accessed this can be easily extended when QEMU will support wider accesses - fix Makefile test (use quiet-command instead of manually run the command) - rename upper/lower to high/low - reorder functions parameters and code to low/high instead of high/low, to follow current convention in QEMU codebase v2 - fix compilation on aarch64 (missing undef in accel/tcg/atomic_template.h) v3 - add info when printing memory accesses (insn_vaddr,mem_vaddr,mem_hwaddr) Pierrick Bouvier (7): plugins: fix mem callback array size plugins: save value during memory accesses plugins: extend API to get latest memory value accessed tests/tcg: add mechanism to run specific tests with plugins tests/tcg: allow to check output of plugins tests/plugin/mem: add option to print memory accesses tests/tcg/x86_64: add test for plugin memory access accel/tcg/atomic_template.h | 66 +++++++++++++-- include/qemu/plugin.h | 8 ++ include/qemu/qemu-plugin.h | 32 ++++++++ accel/tcg/plugin-gen.c | 3 +- plugins/api.c | 34 ++++++++ plugins/core.c | 7 ++ tcg/tcg-op-ldst.c | 72 +++++++++++++++-- tests/plugin/mem.c | 69 +++++++++++++++- tests/tcg/x86_64/test-plugin-mem-access.c | 89 +++++++++++++++++++++ accel/tcg/atomic_common.c.inc | 13 ++- accel/tcg/ldst_common.c.inc | 38 +++++---- plugins/qemu-plugins.symbols | 1 + tests/tcg/Makefile.target | 10 ++- tests/tcg/x86_64/Makefile.target | 7 ++ tests/tcg/x86_64/check-plugin-mem-access.sh | 48 +++++++++++ 15 files changed, 462 insertions(+), 35 deletions(-) create mode 100644 tests/tcg/x86_64/test-plugin-mem-access.c create mode 100755 tests/tcg/x86_64/check-plugin-mem-access.sh