From patchwork Wed Jun 26 23:37:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807526 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546058wrn; Wed, 26 Jun 2024 16:39:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKXuhEJ6ofSrzeu21f1CmfPz6vFaENrAaP5Gd2/+CXDO35qprO3LPTdQo30MMev/fhfrCDS9HCEdFZa2JsfJYK X-Google-Smtp-Source: AGHT+IF0B9XZmi0LcWzzxGFVctuG903K1cJrSRireEAR19qeKUDnkDTgik9PaeeRfa+2j6uGP5Se X-Received: by 2002:a25:5381:0:b0:e03:2ba0:309 with SMTP id 3f1490d57ef6-e034558ff7bmr462312276.41.1719445188607; Wed, 26 Jun 2024 16:39:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445188; cv=none; d=google.com; s=arc-20160816; b=z1VaQz6NwR6BmNNEaqMivyLUDO3HH/m0X3D13Km/VCsc+LD3W4OjbPPqpe9RAAscBy 6lbsSlOjOZgihWfhdK7pj9Lqj8FKfJ00iMIX3dgfd/r4vhMiSLt+hIcieNpDHCcExN2P vz/Uh9EvdO2Y3sNC/1iplHilg8CTngmVkBx6tQ4dAyeWioIY9ynWbKaExf1+hRDkTOKz 06qDB5C3sF/Ak9tinXE0xfVrP5lzXj2yY/xNhdt84e9SVPulX816WPJJ2/97BmIW7hVt zTdkxHYLTyzGML32IjMN+Jp3WrsEWCLzEiLTuj5rCaSXGUxROzo6T37jCQEGZ/tKysvR 9o8Q== 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=Vur5FgBBvNrr+CWbFl6sJPPgkraawbsHcuDeXMpGM7c=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=eBrzs7BEYTYrHEFWrFPHeOBQKnnAJsCd8eU48Kj+pjuwenyxBYmx+grg7jEPqdCma/ OzTy8glFipYDGIux9xTBMC+JQL5LyO8qKDJeY/JOjlvREN0F9M9d05b173uggacHWliX q+UPxg44iuCVxX9eloALo98/ldfvDLYN93eMwh/C4cQddWmcw8pc9X9BE9WnnJxLcTOO zlWAa/9Bhmw7u7L5qKdcBgEkU+zOPEIqQIRAy/xesMsxsTfA29juhMMqd2U9RvGwgobg vq7QKB4mdL+bAU52a+aIR1/vJ2tEA9ARZANiKRVDCaqRLG1ZZXrmKwgFQ8H0/smeJc1J fegg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XGZ2FQZv; 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-44641efa046si1279021cf.60.2024.06.26.16.39.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:48 -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=XGZ2FQZv; 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 1sMcDV-0007T0-9f; Wed, 26 Jun 2024 19:38: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 1sMcDH-0007RT-DQ for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:07 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDE-0007FM-Rr for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:06 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1fa3bdd91c1so31276515ad.2 for ; Wed, 26 Jun 2024 16:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445082; x=1720049882; 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=Vur5FgBBvNrr+CWbFl6sJPPgkraawbsHcuDeXMpGM7c=; b=XGZ2FQZvfM++JdarB0EPWFMhLawczOBQU1B/mMoTkYXwzbwKBYDD+PN8t06srPj81V 2U2a2uhZbA9OYfj/s+gYcR0UEu7iCmhwVDtfghGDlSN6rq8WmujJYYVfRGu6tgHFmPCh /qpJrtzXrwYISqWud5Kl77qbTwoXeQzdzjqkP5QHDuTM5T1XnAlg22ZsMUkbGEv6Vtd/ lU4OW73gV+UwsEId8oBCkI1GQmM2EzzmWNJx2T3T6W+/87BYHRtNxwnAJXf/JeWVyRD/ N4tn1sqWPx78yAAp+XYffzH/jjr2xEsXkBoDEfPud3UF1TJ2tv7Checqp3CmNbP29KJL gk4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445082; x=1720049882; 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=Vur5FgBBvNrr+CWbFl6sJPPgkraawbsHcuDeXMpGM7c=; b=p2L42PqF/iz//KVw1uEgjjvwV4AujVr2wnvEkC07GVP/FD44QLZRP6bSinWfJTcHeb 7OMQ6U3RCAC+cZk2vDtl75U6YMNp2GntGJ97mkdwbUJEYHJtr2zD2uar+eG20X3EuuNc 2bJhbSGHdqs9zPpnSDC7naezfXqLcp2h2mcrDVUYSqjJHsa80VuETewGL5yp5QjvPfGW Pba9M+0bHbEaf2915s54duyWvXECY5jq4gTsL5CD/KqgtiuoKP/E/WglfdQSUD6fdbhh 0IVeK1idVvWDfovNNnWobtESeVViag7YFlz89CkoH6F+k249P+aL0JkUen84le9nYEMe HGag== X-Gm-Message-State: AOJu0YzaIKidWDfcBOCgG8/IjVb9NDw+mkO/Phr8rhKcBGH2k7ofOFZW hl8nCeIHK2jODmgJEAYMi5swKL4nQAupGCAXlx2fMBtwLJXs+l/WEZERPQZW8ku4fYwaUte9EuP EpqE= X-Received: by 2002:a17:902:db10:b0:1fa:104b:36a7 with SMTP id d9443c01a7336-1fa23ec3e4fmr145395795ad.17.1719445081503; Wed, 26 Jun 2024 16:38:01 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac8df624sm563055ad.29.2024.06.26.16.38.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:01 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= Subject: [PATCH v2 0/7] plugins: access values during a memory read/write Date: Wed, 26 Jun 2024 16:37:50 -0700 Message-Id: <20240626233757.375083-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::629; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x629.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 functions: - qemu_plugin_mem_get_value_upper_bits - qemu_plugin_mem_get_value_lower_bits 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. v2 --- fix compilation on aarch64 (missing undef in accel/tcg/atomic_template.h) 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 | 20 +++++ accel/tcg/plugin-gen.c | 3 +- plugins/api.c | 21 +++++ plugins/core.c | 7 ++ tcg/tcg-op-ldst.c | 72 +++++++++++++++-- tests/plugin/mem.c | 28 ++++++- 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 | 2 + tests/tcg/Makefile.target | 8 +- tests/tcg/x86_64/Makefile.target | 7 ++ tests/tcg/x86_64/check-plugin-mem-access.sh | 48 +++++++++++ 15 files changed, 395 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