From patchwork Wed Jun 26 23:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807521 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp545835wrn; Wed, 26 Jun 2024 16:38:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKTipoqs+kW9NOBLP1MmXL/RyW91dAIj6MJ1RN6fl8/WLVKDbuM5hXaw2gEqvYDhZ6k39Ac9i9x0nx8s3zn+uN X-Google-Smtp-Source: AGHT+IEubgBYiGTYaHQ7PNQP/bOeomL+tPlXUuE48aLvlrb2bIn20VTZeC5vv3/HCmuSCBWe3uak X-Received: by 2002:a25:e905:0:b0:e03:435d:befe with SMTP id 3f1490d57ef6-e03454e4e29mr407765276.35.1719445130912; Wed, 26 Jun 2024 16:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445130; cv=none; d=google.com; s=arc-20160816; b=sQLncNecWS06T+P9yFniXsFe9/XTObe5uTWlHmBItdZBz0U9cxbOoGaURZhNOPLiyx h7xd1EHjwqvTHf+ZzchSR+2wUoUOqcQXcDTg0F/r8KNgcTYa5Z3LK7Dr8ErhkZQQIAhl IkNQDqtG18mPRnP8d5c03bXD31UgBNNOMnJeCEKlScdP6pAuvtKI9u8k4Pkql66+C/8J ndXQMyYttTygbQ2HS810XCMbrwfpc5ii6nPgxaVqfzN6geO1kRsZ6ShABNOWwBUZuQyu iQnpBlHTaVFjTeotGpNpatT6aW5wE04UtTHteeZyqduIEe5euTPDHgZCJiMJt0byDa3r YzDg== 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=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=JtAyijN0mUr8athzEDIyRZISJGulhVgfTV8H6tE5VjR9tClGAHAmg8Ln2WWqeo+PjE 4NRt4xVE0cFvLknpP724ThpEFHZA27/l4zG/M53VeLs9OCD6bvEyXfiawBR14C4sepBt lsDc4dcvlqjWRNkTW6HOOWx0siIfXz5iC/Cq0dTzEVTUsOd9oSyEL92W6PRV3EetLWyr D5xLyoYnI4hPotXNe2ylB2MrCFJ/2XpWmEpHuFtgJ5vdfbxEkfaICKPiZ50xXanvuYaa zUNthOdv9fFGt9sR9XWyOgaR8WAT/Wt2RISL0+bt81cpZjqEyWvfMGBlnDD8KdTnBvOV 6cKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoGaXvQl; 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-44641efdde9si1161491cf.161.2024.06.26.16.38.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:38: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=BoGaXvQl; 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 1sMcDO-0007Rp-JX; Wed, 26 Jun 2024 19:38:14 -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-0007RU-Di for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:07 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDF-0007Fa-PY for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:07 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7180308e90bso3826861a12.1 for ; Wed, 26 Jun 2024 16:38:05 -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:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=BoGaXvQl02XNNJfhRTX/38eZY8vzQH+Vnlj+PUmWLheho1Xeou5fCsE92k8ulGY3IN QCYHJ9gxjZR/T7Vd4Fxek+oRwuM8EcUqqExIhtG4pROlpWc2/KOOlze4EDQuswyfavKh nVjPyoOicUPUkifIj5IvaN5XdKCj6pJ57zcnkI1omG9cd1LCCF8DLsixN6xYwa/gzjjY +rjxlByMow/+fqCdgkZo0qwSwssrua8es6brHtlsAdsCpLOvLfavfhgUU3+wKiWkzh2k vaQ8A/CgFFkvdF0k1ZcgnroGr8B1Kmk78x6jlpscMMZk+zDF9k+uQkuFZjUXNsq6wSC8 fzVw== 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: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=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=jjD6I+PfxSgoOhOjohxMxSlKHzj2r3Pe53xjBalStw3O3i+VFKD7+S3Y+Vl0MUZ7qo 1r1c5Sr6dR/QFwmHl6ASeD4eqDPs74rFRLNvJq8HbkIgmr7sIAMlvIyuZG0tKckBxKmv 0oez8+ai05zBSok57xgVSE71YEnALJjTK/bFyRGae00bKhRy8n8BqeReYBgfAZacXK4a H1cen3UvfHsgtOt+jW1WIjbP1M8XZrKlHuaUKpqJSBEfuENMZgpor9l+2skl+14ISLty QJ5UynSlddgip/DYnJlCYAtH3Y+y9h18HM7bepAvcuMOuiYz3mIm5KUOmW4zR7pQrYja YLog== X-Gm-Message-State: AOJu0Yx8VOFM2ab04WjEWYeXx7/WCesf+P5lwDZe8BMFJ0WaZnCLlZ1B adjrQvU5aRj5wQSdczcJZezRHMKhRRM9rqQQpbDmr9aVeREXQ3zvhif3d6oKbM5duwntVSV6jnJ 0OwI= X-Received: by 2002:a05:6a20:7487:b0:1b7:4adb:1dc2 with SMTP id adf61e73a8af0-1bcf7eaf9acmr12595873637.21.1719445082474; Wed, 26 Jun 2024 16:38:02 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:02 -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 1/7] plugins: fix mem callback array size Date: Wed, 26 Jun 2024 16:37:51 -0700 Message-Id: <20240626233757.375083-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pg1-x530.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 data was correctly copied, but size of array was not set (g_array_sized_new only reserves memory, but does not set size). As a result, callbacks were not called for code path relying on plugin_register_vcpu_mem_cb(). Found when trying to trigger mem access callbacks for atomic instructions. Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b6bae32b997..ec89a085b43 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -85,8 +85,7 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, len = insn->mem_cbs->len; arr = g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), len); - memcpy(arr->data, insn->mem_cbs->data, - len * sizeof(struct qemu_plugin_dyn_cb)); + g_array_append_vals(arr, insn->mem_cbs->data, len); qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env, From patchwork Wed Jun 26 23:37:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807523 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546035wrn; Wed, 26 Jun 2024 16:39:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUn7KTXFjj133pnUSUdwKZaHppB5MAsMN9Edx6iC2HVAjLyzMI2MB1w4ox4eTBMka6ZuZBfVGLPyJVevNd2Iqwv X-Google-Smtp-Source: AGHT+IE2Ea1JebhzMtLLTVAwcRlrZr2e/aRMQYUyWyDMCYi0XiCgfum+j1YKAHG+6ODajLAyyL+w X-Received: by 2002:a05:622a:11d1:b0:444:af27:384e with SMTP id d75a77b69052e-44642873e3emr791741cf.24.1719445183977; Wed, 26 Jun 2024 16:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445183; cv=none; d=google.com; s=arc-20160816; b=nCPUyyPdYltnvFP3vX8h1hILxsXZPDJyZ1yP8Jm8IFiOxAg5plFwJuYHX5/dIvDVYR 1sVFRO2O9Mio4xfOHSf9LnPFjFGGaWetlbFGMwg5fufweGCPSXl6egEi0kbt/ssxY83d CR6ZCh3vCyGhY015d3j2r12MPk7+7v1w3bV6Fc0sC41pNmkp7cwSNYv+nIuffux5yj+K 4GlyvhF0QSQZL74wR65jgsycVAaW4FbjEheiixzYyusRP9He+j3mnICbTvMLJPWajC19 4qmEAsIRR+cZAvrqPrELxEfk4ZXNUz4wKQ5rFMEYZKaaG3l83I+iI+MoPILiXi2mmyxD +ZDg== 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=4RW2MrXAzT5bHXqExaNEsMQmc5qMJd7priGqiOo0BfA=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=cqkCxA0lGpOfDuftpHPoW/4dLunng8/KKYnzxFB8psEV5OvfN0VUGYNwaNZnwJ/BQJ YjJ3Y/0uNFYUOdjtd5N3IFEs1VBsmnHEgoCXc9lqh4Rxzhe0qABuvEXVNz/7RT6xn5VG FlhfV5558KfIwTdSuqj4ckMeY7ZUnaAO081FGqu72Bbx/BceqiYUKTzXiyRmHV7J3rHS ev0EUZQcsnuBtYmjfX5AoqIyWMr0X0zbAQXHUgwkPwn+8w//JqU55dpbP1QY1OTWk5ze QFIu4xLjZtcLVsbGMmf1l1Yx+g7jvp9aH6lyaD4THhUsvDH7U5/MpwGeULOdOUJtJrI6 n9Mw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PQZOcrdF; 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-4464205f4e1si1059251cf.435.2024.06.26.16.39.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:43 -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=PQZOcrdF; 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 1sMcDd-0007U6-1k; Wed, 26 Jun 2024 19:38:29 -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 1sMcDL-0007Rt-2Y for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:13 -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 1sMcDI-0007Ff-D2 for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:10 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1f4a5344ec7so8853755ad.1 for ; Wed, 26 Jun 2024 16:38:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445085; x=1720049885; 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=4RW2MrXAzT5bHXqExaNEsMQmc5qMJd7priGqiOo0BfA=; b=PQZOcrdFYqp2VcM2dvYdsBHuxHtpdu0IhgaZaRyZdI4RMh1EaItwy4Nfe6wCKrqa7T VwWbX3opILAFL9/HcfdJ04frwAzhDg5t4SSoZ2mRt7gjcq88SsW+0CIGg90LQCxmHjm+ RAWcFmFhZSNdLQUR3vu9LkH85hIr0GIGmkwSa6rI2JagSR8H6r5ITvtvfXB/2L6evv43 h6z43SDaXnEZI2q2YotBpdTXf6xX99XSlRgXKmeJSx0ojBNKP23pE+I5/Q3R+mA3P+3d 0mqZ/B2uCeyuX5Srjw0nM8q69eqWvupYJWo+GAXlj3ks7CQLzLfHeUKdi7BW5lTPl1C3 p4zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445085; x=1720049885; 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=4RW2MrXAzT5bHXqExaNEsMQmc5qMJd7priGqiOo0BfA=; b=PXZJmNkz8elSvyPkhOzsmpWLdKCnSQcwZeVK8meASV5WyUs/SHLpiUqbMDAQfYe867 EfM3lboye1u9s4QkonAZPER+Zox/QeNy73LINHJzaVsjfBrujpGI3r5CKPSZhh/XbEO9 OXfCgycf9XR4asS8JzgHtL203s0feLgUNA8mMwBJnvdVdo9YvdRkva5UK8adX4xd80T0 RLBmb7U312Qk0akHBcX7odmjjMBk6Qwjx0BRNRwIcrjJVZ3TASMC9yKYIb7Yo9i/CVsX Z1TZCM98lp79VKdqM8v077Zc53JOM7961i+688cnRF+7DdPvwwju2+gYbQm3CtrsxEMz +h7A== X-Gm-Message-State: AOJu0YyS7COoP4Xa7en5lEemkVP1yzJpOMKmKcdO0tW7yybyW3ECGhCb jFsKUubvEHB9/UYGN/gnZwPbud+LHoBZ1UiVZx8ytAl5cP75yg5SbUwibQgu8YrqvCwvzFQ/T6m 0A1Y= X-Received: by 2002:a17:903:1104:b0:1fa:97ec:3a4 with SMTP id d9443c01a7336-1fa97ec057emr30007855ad.8.1719445084711; Wed, 26 Jun 2024 16:38:04 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:03 -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 2/7] plugins: save value during memory accesses Date: Wed, 26 Jun 2024 16:37:52 -0700 Message-Id: <20240626233757.375083-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> 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 Different code paths handle memory accesses: - tcg generated code - load/store helpers - atomic helpers This value is saved in cpu->plugin_state. Atomic operations are doing read/write at the same time, so we generate two memory callbacks instead of one, to allow plugins to access distinct values. Signed-off-by: Pierrick Bouvier --- accel/tcg/atomic_template.h | 66 ++++++++++++++++++++++++++++---- include/qemu/plugin.h | 8 ++++ plugins/core.c | 7 ++++ tcg/tcg-op-ldst.c | 72 +++++++++++++++++++++++++++++++---- accel/tcg/atomic_common.c.inc | 13 ++++++- accel/tcg/ldst_common.c.inc | 38 +++++++++++------- 6 files changed, 173 insertions(+), 31 deletions(-) diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h index 1dc2151dafd..830e4f16069 100644 --- a/accel/tcg/atomic_template.h +++ b/accel/tcg/atomic_template.h @@ -53,6 +53,14 @@ # error unsupported data size #endif +#if DATA_SIZE == 16 +# define UPPER_MEMORY_VALUE(val) int128_gethi(val) +# define LOWER_MEMORY_VALUE(val) int128_getlo(val) +#else +# define UPPER_MEMORY_VALUE(val) 0 +# define LOWER_MEMORY_VALUE(val) val +#endif + #if DATA_SIZE >= 4 # define ABI_TYPE DATA_TYPE #else @@ -83,7 +91,12 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr, ret = qatomic_cmpxchg__nocheck(haddr, cmpv, newv); #endif ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(newv), + LOWER_MEMORY_VALUE(newv), + oi); return ret; } @@ -97,7 +110,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val, ret = qatomic_xchg__nocheck(haddr, val); ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(val), + LOWER_MEMORY_VALUE(val), + oi); return ret; } @@ -109,7 +127,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \ ret = qatomic_##X(haddr, val); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + UPPER_MEMORY_VALUE(ret), \ + LOWER_MEMORY_VALUE(ret), \ + UPPER_MEMORY_VALUE(val), \ + LOWER_MEMORY_VALUE(val), \ + oi); \ return ret; \ } @@ -145,7 +168,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ cmp = qatomic_cmpxchg__nocheck(haddr, old, new); \ } while (cmp != old); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + UPPER_MEMORY_VALUE(old), \ + LOWER_MEMORY_VALUE(old), \ + UPPER_MEMORY_VALUE(xval), \ + LOWER_MEMORY_VALUE(xval), \ + oi); \ return RET; \ } @@ -188,7 +216,12 @@ ABI_TYPE ATOMIC_NAME(cmpxchg)(CPUArchState *env, abi_ptr addr, ret = qatomic_cmpxchg__nocheck(haddr, BSWAP(cmpv), BSWAP(newv)); #endif ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(newv), + LOWER_MEMORY_VALUE(newv), + oi); return BSWAP(ret); } @@ -202,7 +235,12 @@ ABI_TYPE ATOMIC_NAME(xchg)(CPUArchState *env, abi_ptr addr, ABI_TYPE val, ret = qatomic_xchg__nocheck(haddr, BSWAP(val)); ATOMIC_MMU_CLEANUP; - atomic_trace_rmw_post(env, addr, oi); + atomic_trace_rmw_post(env, addr, + UPPER_MEMORY_VALUE(ret), + LOWER_MEMORY_VALUE(ret), + UPPER_MEMORY_VALUE(val), + LOWER_MEMORY_VALUE(val), + oi); return BSWAP(ret); } @@ -214,7 +252,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ haddr = atomic_mmu_lookup(env_cpu(env), addr, oi, DATA_SIZE, retaddr); \ ret = qatomic_##X(haddr, BSWAP(val)); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + UPPER_MEMORY_VALUE(ret), \ + LOWER_MEMORY_VALUE(ret), \ + UPPER_MEMORY_VALUE(val), \ + LOWER_MEMORY_VALUE(val), \ + oi); \ return BSWAP(ret); \ } @@ -247,7 +290,12 @@ ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, abi_ptr addr, \ ldn = qatomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ } while (ldo != ldn); \ ATOMIC_MMU_CLEANUP; \ - atomic_trace_rmw_post(env, addr, oi); \ + atomic_trace_rmw_post(env, addr, \ + UPPER_MEMORY_VALUE(old), \ + LOWER_MEMORY_VALUE(old), \ + UPPER_MEMORY_VALUE(xval), \ + LOWER_MEMORY_VALUE(xval), \ + oi); \ return RET; \ } @@ -281,3 +329,5 @@ GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new) #undef SUFFIX #undef DATA_SIZE #undef SHIFT +#undef UPPER_MEMORY_VALUE +#undef LOWER_MEMORY_VALUE diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bc5aef979e7..112dcdad717 100644 --- a/include/qemu/plugin.h +++ b/include/qemu/plugin.h @@ -142,9 +142,13 @@ struct qemu_plugin_tb { /** * struct CPUPluginState - per-CPU state for plugins * @event_mask: plugin event bitmap. Modified only via async work. + * @mem_value_upper_bits: 64 upper bits of latest accessed mem value. + * @mem_value_lower_bits: 64 lower bits of latest accessed mem value. */ struct CPUPluginState { DECLARE_BITMAP(event_mask, QEMU_PLUGIN_EV_MAX); + uint64_t mem_value_upper_bits; + uint64_t mem_value_lower_bits; }; /** @@ -164,6 +168,8 @@ qemu_plugin_vcpu_syscall(CPUState *cpu, int64_t num, uint64_t a1, void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret); void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw); void qemu_plugin_flush_cb(void); @@ -248,6 +254,8 @@ void qemu_plugin_vcpu_syscall_ret(CPUState *cpu, int64_t num, int64_t ret) { } static inline void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { } diff --git a/plugins/core.c b/plugins/core.c index 9d737d82787..957a3efb06d 100644 --- a/plugins/core.c +++ b/plugins/core.c @@ -575,14 +575,21 @@ void exec_inline_op(enum plugin_dyn_cb_type type, } void qemu_plugin_vcpu_mem_cb(CPUState *cpu, uint64_t vaddr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { GArray *arr = cpu->neg.plugin_mem_cbs; + CPUPluginState *plugin_state = cpu->plugin_state; size_t i; if (arr == NULL) { return; } + + plugin_state->mem_value_upper_bits = value_upper_bits; + plugin_state->mem_value_lower_bits = value_lower_bits; + for (i = 0; i < arr->len; i++) { struct qemu_plugin_dyn_cb *cb = &g_array_index(arr, struct qemu_plugin_dyn_cb, i); diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c index 85101602581..93b338704dc 100644 --- a/tcg/tcg-op-ldst.c +++ b/tcg/tcg-op-ldst.c @@ -148,14 +148,24 @@ static TCGv_i64 plugin_maybe_preserve_addr(TCGTemp *addr) return NULL; } +#ifdef CONFIG_PLUGIN static void -plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, +plugin_gen_mem_callbacks(TCGv_i64 value_upper_bits, TCGv_i64 value_lower_bits, + TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { -#ifdef CONFIG_PLUGIN if (tcg_ctx->plugin_insn != NULL) { qemu_plugin_meminfo_t info = make_plugin_meminfo(oi, rw); + TCGv_ptr plugin_state = tcg_temp_ebb_new_ptr(); + tcg_gen_ld_ptr(plugin_state, tcg_env, + offsetof(CPUState, plugin_state) - sizeof(CPUState)); + tcg_gen_st_i64(value_upper_bits, plugin_state, + offsetof(CPUPluginState, mem_value_upper_bits)); + tcg_gen_st_i64(value_lower_bits, plugin_state, + offsetof(CPUPluginState, mem_value_lower_bits)); + tcg_temp_free_ptr(plugin_state); + if (tcg_ctx->addr_type == TCG_TYPE_I32) { if (!copy_addr) { copy_addr = tcg_temp_ebb_new_i64(); @@ -172,6 +182,48 @@ plugin_gen_mem_callbacks(TCGv_i64 copy_addr, TCGTemp *orig_addr, MemOpIdx oi, } } } +} +#endif + +static void +plugin_gen_mem_callbacks_i32(TCGv_i32 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + TCGv_i64 ext_val = tcg_temp_ebb_new_i64(); + tcg_gen_extu_i32_i64(ext_val, val); + plugin_gen_mem_callbacks(tcg_constant_i64(0), ext_val, + copy_addr, orig_addr, oi, rw); + tcg_temp_free_i64(ext_val); + } +#endif +} + +static void +plugin_gen_mem_callbacks_i64(TCGv_i64 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + plugin_gen_mem_callbacks(tcg_constant_i64(0), val, + copy_addr, orig_addr, oi, rw); + } +#endif +} + +static void +plugin_gen_mem_callbacks_i128(TCGv_i128 val, + TCGv_i64 copy_addr, TCGTemp *orig_addr, + MemOpIdx oi, enum qemu_plugin_mem_rw rw) +{ +#ifdef CONFIG_PLUGIN + if (tcg_ctx->plugin_insn != NULL) { + plugin_gen_mem_callbacks(TCGV128_HIGH(val), TCGV128_LOW(val), + copy_addr, orig_addr, oi, rw); + } #endif } @@ -203,7 +255,8 @@ static void tcg_gen_qemu_ld_i32_int(TCGv_i32 val, TCGTemp *addr, opc = INDEX_op_qemu_ld_a64_i32; } gen_ldst(opc, tcgv_i32_temp(val), NULL, addr, oi); - plugin_gen_mem_callbacks(copy_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i32(val, copy_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); if ((orig_memop ^ memop) & MO_BSWAP) { switch (orig_memop & MO_SIZE) { @@ -271,7 +324,7 @@ static void tcg_gen_qemu_st_i32_int(TCGv_i32 val, TCGTemp *addr, } } gen_ldst(opc, tcgv_i32_temp(val), NULL, addr, oi); - plugin_gen_mem_callbacks(NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i32(val, NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); if (swap) { tcg_temp_free_i32(swap); @@ -324,7 +377,8 @@ static void tcg_gen_qemu_ld_i64_int(TCGv_i64 val, TCGTemp *addr, opc = INDEX_op_qemu_ld_a64_i64; } gen_ldst_i64(opc, val, addr, oi); - plugin_gen_mem_callbacks(copy_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i64(val, copy_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); if ((orig_memop ^ memop) & MO_BSWAP) { int flags = (orig_memop & MO_SIGN @@ -396,7 +450,7 @@ static void tcg_gen_qemu_st_i64_int(TCGv_i64 val, TCGTemp *addr, opc = INDEX_op_qemu_st_a64_i64; } gen_ldst_i64(opc, val, addr, oi); - plugin_gen_mem_callbacks(NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i64(val, NULL, addr, orig_oi, QEMU_PLUGIN_MEM_W); if (swap) { tcg_temp_free_i64(swap); @@ -606,7 +660,8 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp *addr, tcg_constant_i32(orig_oi)); } - plugin_gen_mem_callbacks(ext_addr, addr, orig_oi, QEMU_PLUGIN_MEM_R); + plugin_gen_mem_callbacks_i128(val, ext_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_R); } void tcg_gen_qemu_ld_i128_chk(TCGv_i128 val, TCGTemp *addr, TCGArg idx, @@ -722,7 +777,8 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp *addr, tcg_constant_i32(orig_oi)); } - plugin_gen_mem_callbacks(ext_addr, addr, orig_oi, QEMU_PLUGIN_MEM_W); + plugin_gen_mem_callbacks_i128(val, ext_addr, addr, orig_oi, + QEMU_PLUGIN_MEM_W); } void tcg_gen_qemu_st_i128_chk(TCGv_i128 val, TCGTemp *addr, TCGArg idx, diff --git a/accel/tcg/atomic_common.c.inc b/accel/tcg/atomic_common.c.inc index 95a5c5ff12d..bed56d25d47 100644 --- a/accel/tcg/atomic_common.c.inc +++ b/accel/tcg/atomic_common.c.inc @@ -14,9 +14,20 @@ */ static void atomic_trace_rmw_post(CPUArchState *env, uint64_t addr, + uint64_t read_value_upper_bits, + uint64_t read_value_lower_bits, + uint64_t write_value_upper_bits, + uint64_t write_value_lower_bits, MemOpIdx oi) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_RW); + if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + read_value_upper_bits, read_value_lower_bits, + oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + write_value_upper_bits, write_value_lower_bits, + oi, QEMU_PLUGIN_MEM_W); + } } /* diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index 87ceb954873..f6d5613a358 100644 --- a/accel/tcg/ldst_common.c.inc +++ b/accel/tcg/ldst_common.c.inc @@ -123,10 +123,15 @@ void helper_st_i128(CPUArchState *env, uint64_t addr, Int128 val, MemOpIdx oi) * Load helpers for cpu_ldst.h */ -static void plugin_load_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) +static void plugin_load_cb(CPUArchState *env, abi_ptr addr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, + MemOpIdx oi) { if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + value_upper_bits, value_lower_bits, + oi, QEMU_PLUGIN_MEM_R); } } @@ -136,7 +141,7 @@ uint8_t cpu_ldb_mmu(CPUArchState *env, abi_ptr addr, MemOpIdx oi, uintptr_t ra) tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_UB); ret = do_ld1_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, 0, ret, oi); return ret; } @@ -147,7 +152,7 @@ uint16_t cpu_ldw_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); ret = do_ld2_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, 0, ret, oi); return ret; } @@ -158,7 +163,7 @@ uint32_t cpu_ldl_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); ret = do_ld4_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, 0, ret, oi); return ret; } @@ -169,7 +174,7 @@ uint64_t cpu_ldq_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); ret = do_ld8_mmu(env_cpu(env), addr, oi, ra, MMU_DATA_LOAD); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, 0, ret, oi); return ret; } @@ -180,7 +185,7 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); ret = do_ld16_mmu(env_cpu(env), addr, oi, ra); - plugin_load_cb(env, addr, oi); + plugin_load_cb(env, addr, int128_gethi(ret), int128_getlo(ret), oi); return ret; } @@ -188,10 +193,15 @@ Int128 cpu_ld16_mmu(CPUArchState *env, abi_ptr addr, * Store helpers for cpu_ldst.h */ -static void plugin_store_cb(CPUArchState *env, abi_ptr addr, MemOpIdx oi) +static void plugin_store_cb(CPUArchState *env, abi_ptr addr, + uint64_t value_upper_bits, + uint64_t value_lower_bits, + MemOpIdx oi) { if (cpu_plugin_mem_cbs_enabled(env_cpu(env))) { - qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, oi, QEMU_PLUGIN_MEM_W); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + value_upper_bits, value_lower_bits, + oi, QEMU_PLUGIN_MEM_W); } } @@ -199,7 +209,7 @@ void cpu_stb_mmu(CPUArchState *env, abi_ptr addr, uint8_t val, MemOpIdx oi, uintptr_t retaddr) { helper_stb_mmu(env, addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, 0, val, oi); } void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, @@ -207,7 +217,7 @@ void cpu_stw_mmu(CPUArchState *env, abi_ptr addr, uint16_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_16); do_st2_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, 0, val, oi); } void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, @@ -215,7 +225,7 @@ void cpu_stl_mmu(CPUArchState *env, abi_ptr addr, uint32_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_32); do_st4_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, 0, val, oi); } void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, @@ -223,7 +233,7 @@ void cpu_stq_mmu(CPUArchState *env, abi_ptr addr, uint64_t val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_64); do_st8_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, 0, val, oi); } void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, @@ -231,7 +241,7 @@ void cpu_st16_mmu(CPUArchState *env, abi_ptr addr, Int128 val, { tcg_debug_assert((get_memop(oi) & MO_SIZE) == MO_128); do_st16_mmu(env_cpu(env), addr, val, oi, retaddr); - plugin_store_cb(env, addr, oi); + plugin_store_cb(env, addr, int128_gethi(val), int128_getlo(val), oi); } /* From patchwork Wed Jun 26 23:37:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807527 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546078wrn; Wed, 26 Jun 2024 16:39:53 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX6xpP/pd6pVwMcgZMYojIdrux03KqvKpH9iV2gmmWvoCIxKDpxYheHJRPOr8kL9gDH9rLZHT9QIRH6T5ZMiEbv X-Google-Smtp-Source: AGHT+IFrUo+5JYhPfQQnt8jn5ZSft5o/qpCmkROLxdjvVQzigj8yCeheWC5HW2DUwsDFiU4A6p7c X-Received: by 2002:a05:6214:21af:b0:6b5:2bfa:edd5 with SMTP id 6a1803df08f44-6b56341eb3fmr152252596d6.17.1719445193581; Wed, 26 Jun 2024 16:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445193; cv=none; d=google.com; s=arc-20160816; b=PjVz0ciPe+G/+yEO4btq6+VjZrrxbBMEEPOpVgtdIip8GpRqv3UdLuaXFoAahu2JMY 5w55haARu7dw5QenpqI/Y7ZcAhc0RdEI+CWoM3XPFOTUtw4Uo/X+2r13InTHJjNDUmqI 2BYjxGfFIaEFXD3L4HW/OfYIbiDzsdg+dJmVZOvsDg3FJWofO4Rqa4ACIK1cKs/u0kB5 Jz/6BzYfMStU29hQSO9/Mdqj3LhVZeyArcZ0fNPhf//M+Pm72P4Oo2+1423D6vnMZrvM 1LjZA0Uc6r6eAdQZp3dDBYx/t1NMzuSfIWKlhfdrLUm6ZpK3wqbvbgUBytyg7ZdHlHct DLZw== 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=f3YG3piskD3FnrYHWUhj9K/baIAzLlF794+NnT4pc1snWs0qUINfb+aLqAIoH4JViU vKgC0sPnjW0y5CBfszyTIBXsQLH5L/uZIla3VVryGGGW9xDyu0BirxIw+BGUmjdfj+vk +FVDFMZobc8cZn5f3uBMb0/+tuPoJVEhDs9fh+cVLvcU1TNEm+9wdqNwq+f6FnDGYpKx o0eDWMau73Pusj1M9KXvlzYdmYELi9IYGjkb6AIbYr8AXtKBImGFIvbmmITXgdCHCRzD Wh/OoDtixve+gXpzGrnoYdQqvaZPLbNfAxDiteDd5OUkw2fVnL790eS1JOmHrtZhjIoB 8flw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rg0Ph9Vn; 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 6a1803df08f44-6b592901ec8si1051626d6.533.2024.06.26.16.39.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:53 -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=rg0Ph9Vn; 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 1sMcDr-0007W6-TC; Wed, 26 Jun 2024 19:38:45 -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 1sMcDK-0007Rr-6Q for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:12 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDI-0007Ft-Fq for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:09 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1faad2f1967so120105ad.0 for ; Wed, 26 Jun 2024 16:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445086; x=1720049886; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=rg0Ph9VnKXP78yvmrSJR3pcdE5y+2Hrr8Y/nCjNrLYsF0Td/grm3VPFNUGOQI1mtHo Y6AbcxYn0AhrVMwrJcFXHmot2M8klm5xuDcXU7QW9jkXoy3gVTUcTOm3LgMdaAyT54Ib M/GGi9vqYJcVKqxNgKgGi+FPMtWkbPjVbhB/uvLx3N/FvqJRMYCVzhyCCWvjvI18GHnl gdZ0dLufOI4P8HblsLsXVWCK9lx2ud5oi6yHmk+/yTtbmS0+GESOVffbNM6zl8cfogfk lVb8sNKgJ/OvOYF5wd1IZBuJ0xqFOT2ni5WxV7tC2ZSbka6OwuhyG3Za9jwwWN0ipw65 Xtpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445086; x=1720049886; 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=pEE58Wfx3Oif89AADmhPQguadlcOn12TkYSZVg6ccjY=; b=Kv0l00BS58E2h10snFROjMAdDZ7JOqtwTj+lo/ojsTvycDaTg0otqiq5HLaSEn3I+n k5i2ggJQNyHg+av/X7bRufmx3hJXAAkF/VVTaisfR+3MpPT0Rx7YuEyrJBnXMI7SvHs2 tSqvWoFSomGxoZIMIXIY+WBTm2LzcAuhIY65F325JWSoy+LyhtCTaJV1ruGsh0ohfrLG ZA7FHEZkRuNlJKEsY2g7dvGeznvJmPEry6dcxPGNy03fvg3b3aNd9qOWJldo+tL54zzE 3eUJf4W06drlpHvyDXp5XF4+2NLWTEZIX1VXXan8Un5Op1TocaBGvnA1R/yw+8hVkL0R mCsg== X-Gm-Message-State: AOJu0YyWug3g8yLSmtnlmzTJJkdkGxk/4FzKiESOEroGLNVd0hxZX4IR vusmG6CS5IpXlqnGvpuQgjycNUCCSQ8NpZ0/SmGJi0ZjMgIwGCu6F1mW/zwi52WmlRISnCGZSA4 QLPM= X-Received: by 2002:a17:903:2444:b0:1f9:b698:3221 with SMTP id d9443c01a7336-1faac2ba21amr3421045ad.21.1719445086682; Wed, 26 Jun 2024 16:38:06 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:05 -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 3/7] plugins: extend API to get latest memory value accessed Date: Wed, 26 Jun 2024 16:37:53 -0700 Message-Id: <20240626233757.375083-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x632.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 Two functions are added to plugins API: - qemu_plugin_mem_get_value_upper_bits - qemu_plugin_mem_get_value_lower_bits This value can be accessed only during a memory callback. Signed-off-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 20 ++++++++++++++++++++ plugins/api.c | 21 +++++++++++++++++++++ plugins/qemu-plugins.symbols | 2 ++ 3 files changed, 43 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c71c705b699..5945f256949 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -551,6 +551,26 @@ bool qemu_plugin_mem_is_big_endian(qemu_plugin_meminfo_t info); QEMU_PLUGIN_API bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info); +/** + * qemu_plugin_mem_get_value_lower_bits() - return 64 lower bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: lower bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info); + +/** + * qemu_plugin_mem_get_value_upper_bits() - return 64 upper bits of latest + * accessed memory value + * @info: opaque memory transaction handle + * + * Returns: upper bits for value accessed + */ +QEMU_PLUGIN_API +uint64_t qemu_plugin_mem_get_value_upper_bits(qemu_plugin_meminfo_t info); + /** * qemu_plugin_get_hwaddr() - return handle for memory operation * @info: opaque memory info structure diff --git a/plugins/api.c b/plugins/api.c index 2ff13d09de6..89e9f6ba5b4 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -351,6 +351,27 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } +uint64_t qemu_plugin_mem_get_value_upper_bits(qemu_plugin_meminfo_t info) +{ + return current_cpu->plugin_state->mem_value_upper_bits; +} + +uint64_t qemu_plugin_mem_get_value_lower_bits(qemu_plugin_meminfo_t info) +{ + uint64_t value = current_cpu->plugin_state->mem_value_lower_bits; + /* tcg values are sign extended, so we must clip them */ + switch (qemu_plugin_mem_size_shift(info)) { + case 0: + return value & 0xff; + case 1: + return value & 0xffff; + case 2: + return value & 0xffffffff; + default: + return value; + } +} + /* * Virtual Memory queries */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index ca773d8d9fe..9f2646fc812 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -13,6 +13,8 @@ qemu_plugin_insn_size; qemu_plugin_insn_symbol; qemu_plugin_insn_vaddr; + qemu_plugin_mem_get_value_upper_bits; + qemu_plugin_mem_get_value_lower_bits; qemu_plugin_mem_is_big_endian; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; From patchwork Wed Jun 26 23:37:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807522 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546034wrn; Wed, 26 Jun 2024 16:39:44 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFtA1IUySmX2upG3x7FP8mU244jjhfGyll1X/4YBUcfvFeEe3BN6i94vnZ3uyDz6e53dlWHQGqDDEJRUVBswCI X-Google-Smtp-Source: AGHT+IFi2sfvV6k9mprR3/o0b2eGW6uCFqqK+tHrPwg0TYutdFpvH3dj7YfU+h+HDqdTyhLWixJc X-Received: by 2002:ac8:7d0f:0:b0:441:56b2:57c8 with SMTP id d75a77b69052e-444d9219036mr123096201cf.24.1719445183929; Wed, 26 Jun 2024 16:39:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445183; cv=none; d=google.com; s=arc-20160816; b=e2ebPBXyAZUDulZuVHXYL/YBjY2QedxhM9QA+qLs8FK+JhyjS9pCsXWesyJTSQdaP7 q0FQqiMl0wLyX7Cz4PYJRYj/Kpr+UBBj0Lt/ssr+zXNhx6mGst1TUqXeZxIOOTq8rDDu 452nu0QOEbGxyeVFzM9SmrrySTSmKLDryeRT3Otk6L6TQvKShMeIxHgZEwQ2eBKYaIyW ozV+g+DLeoJ72sXQ44o0YCy8Zvk1Wy4z1ajmyXo9kWa/uBluF4YlKjJmaYDlsEmZ15MJ j59WQz+xcPM0bp1c0AMgR8ynzXkPEp6jA/4OiHDDz+pL6z55YESqOHX8KAQatBzmftPI MdYg== 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=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=nOn7xDMgYGam5d1hA4zehwvD9g4V/cXM247Bqq6U3tjnsnYcnrwZq3l+YSc8OCYNSS ZAjN00seqk3knTAr6UYdVsOhZXe520EvGWtf8K2Nc0VJk9M/dssVKdRTLDIZVBS0gti5 PFvABkiazygHYQFY/270SqOFz1wNJm2KMk5GXda7o5q5DP92FDaxxnvUKqtMZ2AtXBup hLOblJfCtsu8WdP5aQ+teNIYcj1zTVPDkxeFtJeupI65oSlWmHJ9JJ3Q4FdbC48rDEgZ r/AEJXoY0jiK0YNHobV5qc/NQqmLqKPkZrV1UROJYclXnNirloGg5yJIIPBlrSwtxyrV 2E0Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R/C0O/xx"; 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-44641ef65c8si1325371cf.159.2024.06.26.16.39.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:43 -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="R/C0O/xx"; 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 1sMcE4-0007jv-74; Wed, 26 Jun 2024 19:38: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 1sMcDL-0007Rv-OP for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:13 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDJ-0007G8-OD for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:11 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1fa0f143b85so38111585ad.3 for ; Wed, 26 Jun 2024 16:38:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445088; x=1720049888; 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=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; b=R/C0O/xxplwLGfnC/mgUJVv+waOwEighnZfl4S5pPz5qB/mjGYP6RCblt8s1eTej/o gX0UN9gnSc/tpu6r3vV7vtwIpkQ/OQEZxQS7U9G0ZqvuoT87f9lMANnNAareNQ4Kcyij Po/7hCOwCy7cARTMumG8Q3M8y3TTES+6h+CdQwcmPaWaGVeKgWuHvLCoSlXdsaSJbbtc St1EFA5+66kt8Se5gV4IInYyjnZIUgFYhiKSDBNTK100HAdHDI/B4UD4cfFUUdibei+o WiUiIyTGeX6hkF0WlDpWXOVkw27KEfVJvCHT5AR4fNDgWKxL8MCs8nO6BE+hty+yHdwl j+sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445088; x=1720049888; 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=KfJtbR1DHFH39g5O1RoXMV40m1cvFRDojz81uxTKSUM=; b=VP7X0NO/WWn6GU1dtQiPeuPc5DpPT+HdDDum0j8+R2837oytc0voh762icBp8sT0Ha 3u1FjxLixNlAGyR3tY8g6tcccs7KgZkpF1S3AVYl7Bc+0YJBULLfz6iucZKZTv3qB6aB xc4sAFVIZSsMrZ3Ld8wsVaSPK+/I61emmSsZ1D2lBxRp/yFtrRGKgFWI4dqQI/+JQkcZ b8k7OtPzMFsj3XiecinvqdVIZGwX7YTuXM5De98HZwhN3gZ6Eqo7V38udgliOlKxfeLh BjkLzT2W0zr/vIIyE6fN8PAwI5pz2smAYDKMuNls0wXC+nG2jAec/5CPBeLIsjwwoC0U iAgw== X-Gm-Message-State: AOJu0YwIR151dFPQTxooTVW2QdrcBZkcGNtu+MNgINdq3Htb5Q/EpOaD yy0b/Z7TsWK47fjPNIP6B1PGJqcCi3dUp5mp/mANo/5NXkMY9pGhi0gxTwW8j7HYYv4mNssWta0 UxkQ= X-Received: by 2002:a17:903:2446:b0:1fa:2760:c3f3 with SMTP id d9443c01a7336-1fa2760d403mr124158315ad.13.1719445087703; Wed, 26 Jun 2024 16:38:07 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:07 -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 4/7] tests/tcg: add mechanism to run specific tests with plugins Date: Wed, 26 Jun 2024 16:37:54 -0700 Message-Id: <20240626233757.375083-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::635; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x635.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 Only multiarch tests are run with plugins, and we want to be able to run per-arch test with plugins too. Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- tests/tcg/Makefile.target | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index f21be50d3b2..dc5c8b7a3b4 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -152,10 +152,11 @@ PLUGINS=$(patsubst %.c, lib%.so, $(notdir $(wildcard $(PLUGIN_SRC)/*.c))) # only expand MULTIARCH_TESTS which are common on most of our targets # to avoid an exponential explosion as new tests are added. We also # add some special helpers the run-plugin- rules can use below. +# In more, extra tests can be added using PLUGINS_TESTS variable. ifneq ($(MULTIARCH_TESTS),) $(foreach p,$(PLUGINS), \ - $(foreach t,$(MULTIARCH_TESTS),\ + $(foreach t,$(MULTIARCH_TESTS) $(PLUGINS_TESTS),\ $(eval run-plugin-$(t)-with-$(p): $t $p) \ $(eval RUN_TESTS+=run-plugin-$(t)-with-$(p)))) endif # MULTIARCH_TESTS From patchwork Wed Jun 26 23:37:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807524 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546050wrn; Wed, 26 Jun 2024 16:39:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUTF46M/w8xji+g5r7SbAcoTKanHQIJhCRnyPXmsNYNPx3mS79rFSUCsoSZVTYL+nYmmg4Ko7kx9n4NsjwRHA13 X-Google-Smtp-Source: AGHT+IHJUnmojaQKI7wLOXlX2PpLhdBgiFCqyihHyy4gC47LTXm1+AXk2syD1TRQPn0JiTafzPM/ X-Received: by 2002:a05:620a:2495:b0:79d:5524:dc70 with SMTP id af79cd13be357-79d5524e1bamr330966285a.37.1719445187293; Wed, 26 Jun 2024 16:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445187; cv=none; d=google.com; s=arc-20160816; b=vbvPUKRrvU4F2lLhd4raks1gmWcGNgjUiuhszz4eM6oiHf5VCSjsCibQfUu+171XvN qgdwcID//Ke4q/eCiFa57ETC0FtpC+HxyaMJUcES3fAp3iX8UhUlbIRp8A2h+4Hs1aoV T1iRrLtvZBzUn6PAELef78hLu7/9x8wvEASbiNHqLfuWJVZCCnm+v/+quo8031frsaVf gzaMRKnVvz3STVq15g5VnyeACtQjR4wGo0V/izL922wkMGZoicGnRUI64Hc7WYXppoNK h/0uWu61qd1NL6b09cDpzVSZxb9AOHC5NRMzcKGe/w0IZ6CcLODz6+pyUwWHzhF3w0NV P+0g== 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=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=kX3Pk0uSCfSZEn9mr77KLxN3nG1yfMFLThUC0TX3T/iPEqtdMFQrIze4Xw0IAwcZtF 4CojZZ1pE0AJdJSpIc0FarRDZfAnmhFoc8KwBQUfPtnXRUpgQwMCQNBnpRV6eIKHaQlF nHXmVJ4rlUefa7O2h1pYZAOfQcg0UIDZrcsuZzx2hrBl4ykMqFTX7IVBgix57fCADVAZ N0eMlRnKFOVgDVe8jTD+rCYKNtIZZwfNg1Qpsq1kvMff0sXwRiJVQ1129O5MNFQvvkjZ bdNsseIiyI316DhxxxODADumbTbslyc6TMXJo8XdOCzDZcdvmMKalJzmcFLxReaaO0pq bGVw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MY8de2nY; 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 af79cd13be357-79d5c8c2b89si16158785a.533.2024.06.26.16.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:47 -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=MY8de2nY; 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 1sMcDa-0007TZ-Ql; Wed, 26 Jun 2024 19:38:28 -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 1sMcDM-0007S3-Op for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:13 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDK-0007Jv-Jh for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:11 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1f64ecb1766so55334935ad.1 for ; Wed, 26 Jun 2024 16:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445089; x=1720049889; 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=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; b=MY8de2nYos1QIr569wG+xLf04ni9RADvGBPqlY3ADy7ENP2Gqf2Oks1+GMNrTUqC/6 NsoRBOkRWZJD6EuhLDAuFQ9XMLF+sEtm4pNifD20K4Of93/q0F3kAVQDj/d+4+2Pgz7j LO5hHfg+QyukHEwB7JQLrFasCmuf3LQnGJoT6QIpCpmbywm9EG2n4Ic8F2QWatm70386 4T0NA2UqPnaJtbzqXnENLAd4z709hdozG5vz5KXICSfjaHQsHBhIZBduMb9laoM0utSS 7iyFqBkFQcbind1cvwAOBWkvH4V9Vx3JMAE39y8/KOzR4K/mpKO1F4xkMyyAvdwjFa5n xnbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445089; x=1720049889; 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=doL4IgQgCF3HWgmN7iQLNBk72z9WitWnst2YOIXTsDc=; b=Qb6GTOCFPvQ050CA8E7S29YO7j8MtKj0//uR8aZXowMKyOUTaWt1JXUmZAUz4+v5yr 7U+83X+WIHuXaxF5OD05LGAYGSolXbqnZ/7dwUsbl1AprOhRXTK7xYF4AcbuZ8to+j2n 1V7eI5qsdL+VPjSW6g2yxHMpLgFRPBgFHebRLmUBxZ54hxVKevLiRoxRuCJtBNRDvvHw 2/SnjclyznIFJkxnlg/RzSHH/wzk1xzZln/l5SS4r1tlxwPJ+8w42Kwjj0gwvPdRL4Ul adO5xyvP6RdymUEuR0aXzm4YXsz7Xrc2Bupgie3yDz0U3frN6v/4GU6IULIQ5cGB6lGq b00Q== X-Gm-Message-State: AOJu0YzlV7r52/dzEVzdBa+EF/xt9a+zaxO2VSLVqzE8NqRQKjyfrarP /w8Za6TyU4XuC8T4ZjTvkE3Uadxse9V5nF3K6EHTpNUE42HisUCk21V/A28ZaYCRGAxR+fA/nP3 UBK4= X-Received: by 2002:a17:903:2446:b0:1fa:4a8:79e0 with SMTP id d9443c01a7336-1fa1d62b79amr137776115ad.39.1719445088715; Wed, 26 Jun 2024 16:38:08 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:08 -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 5/7] tests/tcg: allow to check output of plugins Date: Wed, 26 Jun 2024 16:37:55 -0700 Message-Id: <20240626233757.375083-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62a.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 A specific plugin test can now read and check a plugin output, to ensure it contains expected values. Signed-off-by: Pierrick Bouvier --- tests/tcg/Makefile.target | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index dc5c8b7a3b4..55993611cae 100644 --- a/tests/tcg/Makefile.target +++ b/tests/tcg/Makefile.target @@ -90,6 +90,7 @@ CFLAGS= LDFLAGS= QEMU_OPTS= +CHECK_PLUGIN_OUTPUT_COMMAND=true # If TCG debugging, or TCI is enabled things are a lot slower @@ -180,6 +181,8 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(call strip-plugin,$<)) + @$(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout || echo \ + $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout failed else run-%: % $(call run-test, $<, \ @@ -194,6 +197,8 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(QEMU_OPTS) $(call strip-plugin,$<)) + @$(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout || echo \ + $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout failed endif gdb-%: % From patchwork Wed Jun 26 23:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807525 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546054wrn; Wed, 26 Jun 2024 16:39:48 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWksdMftbrcSPtPqN2LXetQGAJQXjslh7lIAZQ+4UrpYvNczBUS9nll9Zxswy4qTvUHfQJwNnK9nVvgAHMb+q2I X-Google-Smtp-Source: AGHT+IG6Ldme3k7jVVQ8sTyuP2Wq9p02Q8BmOAitujxgLOehZ1lQEKJSR2e0cXezPrs04yTndcK+ X-Received: by 2002:a05:6808:1b09:b0:3d2:1b3a:d073 with SMTP id 5614622812f47-3d545a88fc3mr13673806b6e.57.1719445187898; Wed, 26 Jun 2024 16:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445187; cv=none; d=google.com; s=arc-20160816; b=oypgGDTdiRZNbt3TKTo9Zt5fqyg2ljofeOk0GfbuyUim8fEwP7/euyUDexGshf/jYF qN17OI5uj7P5IlEJeYo1Ii74GMGFq9L5/9t+vwRF3hnGOPiYJLTViBAUKAtPfYhAAIdJ YSOlaCisRXeexJal/d9p1fbhEfxq8den7CqwrEsx6DFrUpMAFGqODg+Qy+m591drrXG9 yV8QTKWdlYwUfm9B5uxDlrLnGnX/aJbbbD7LRcuLJK2Li4tRxeaO/ZVNwAEMFawSPzaN k2RnilNHsi2Z3uEH+K7CBztGzNjhhgLlLLcXPZCKcjhzGggdUGnhi9h/5mQ7961JuJ8P G2fw== 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=YpwlMRxy1b5bkhjwlDrFN0XOHAISnmR/z9S8ig6MNCeNBpyl0vOVARitJSXco6dU7v iGLFVrFafJTunqNKRDhDMqAN4SFP8uyNftsN/6ZjYVGIXoUFwi+d9iYzsQO9r6QQGlI7 SqNe9x3W2yPvPs3VYNuA843AOaR+1pY9oKRo2XDRouT9Lpm6Y+8pyGc2AMaqJDKBjFQA R3fqaJHEHcoDjXGAyV1DSirbiuFc1ByW3TKp/RU/tYLeYQaZxg3VDqY30BYpW0tFYFMp uTBsQr+YPFxDR0PjqnJOHfjHqlsQakYoj1tFzr3EDm1k5ucrRT66K38NteQwKJJnwPmF peXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C9ZVyQh1; 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 af79cd13be357-79d5c8c4961si15240785a.662.2024.06.26.16.39.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:39:47 -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=C9ZVyQh1; 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 1sMcDj-0007U7-MQ; Wed, 26 Jun 2024 19:38:39 -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 1sMcDO-0007Se-Ql for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:15 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDM-0007Ka-Hy for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:14 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1f9de13d6baso52783615ad.2 for ; Wed, 26 Jun 2024 16:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445090; x=1720049890; 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=C9ZVyQh1fFnjDN09RuYGfJwJpcBtqT9MOX9Hi2xAQ1xV7NmOGGjLiFMJVo4ERxebro Bx+uILkFJYDeV1Qdf/SL8vWx4tB2y+mJ5ct/feyEizwg9SdYbS7Vdti0WFN/euhyOvCf zyJXwk9R8izGfLhMAMJWEDGTtwCMS7chK9NZ8MBSq5jz6J6qirY1jyyIGEFy1aawkFUE OnIrIBe5nuwj0Zfk5y1ITMEdGYEjLLIj41b9wlaV6ATEpOQYaTXNT45xpYajpSgvhHZx 4lo7XynKW4Wx9lIAd0lgUMEowd8s3ujz/3BPLL1UHHFmPrmbpQoyoZJg5YjKmHk7y3He vxUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445090; x=1720049890; 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=jtCGpIl6luQ3ISJAfvlxdEXOg6zayrBpIY7vxCz1GF8=; b=cZceDWudVjeTjtrNH+qpccZxSerP7t01i2XfkcV5mpDCCqptfD8G5KqNJUZ+fVlSpY GJju2HQ8AXyLfR3GmgBOwFiKQXeT+lba2Fh7NriYWkRG7Anl/kl5UAml2an/Ffmm4D/Y l9lTEed0vgwMIzKrqtEU5NMXIOY3544617TLeV3TmakHkbKjVgrtql7zVqHw0BpDIzji 5hOvTDd5G5CSLtIgmvp/whjl52MPiUQjvDFKPBmu9TdxSsP81Ex7niOgNzRhTcgUzxZp YJNba/r0091KKuj4d3GyHZDQSNjzlHROVEP6fG4Z4YcugeC94N8HN6mSZUZUEodY4TgF 2FXw== X-Gm-Message-State: AOJu0YzDS1de0EWJPZxAK8MpmVOBz/X1jzsag2nXagnzgCQrrHMA5dAI NrY01EIvFK2CHNWgov8Ln+QF9JmXy1GRMowAUU3+TkKQcVFgjEv61L+EKXISksctTkid6U5/OFl MwIw= X-Received: by 2002:a17:902:c40e:b0:1f9:f3c6:ed37 with SMTP id d9443c01a7336-1fa23f22771mr139607805ad.14.1719445089760; Wed, 26 Jun 2024 16:38:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:09 -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 6/7] tests/plugin/mem: add option to print memory accesses Date: Wed, 26 Jun 2024 16:37:56 -0700 Message-Id: <20240626233757.375083-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::631; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x631.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 By using "print-accesses=true" option, mem plugin will now print every value accessed, with associated size, type (store vs load) and symbol where this happens. Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index b650dddcce1..d897034a044 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -24,7 +24,7 @@ typedef struct { static struct qemu_plugin_scoreboard *counts; static qemu_plugin_u64 mem_count; static qemu_plugin_u64 io_count; -static bool do_inline, do_callback; +static bool do_inline, do_callback, do_print_accesses; static bool do_haddr; static enum qemu_plugin_mem_rw rw = QEMU_PLUGIN_MEM_RW; @@ -60,6 +60,20 @@ static void vcpu_mem(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, } } +static void print_access(unsigned int cpu_index, qemu_plugin_meminfo_t meminfo, + uint64_t vaddr, void *udata) +{ + unsigned size = 8 << qemu_plugin_mem_size_shift(meminfo); + const char *type = qemu_plugin_mem_is_store(meminfo) ? "store" : "load"; + uint64_t upper = qemu_plugin_mem_get_value_upper_bits(meminfo); + uint64_t lower = qemu_plugin_mem_get_value_lower_bits(meminfo); + const char *sym = udata ? udata : ""; + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, "access: 0x%.0"PRIx64"%"PRIx64",%d,%s,%s\n", + upper, lower, size, type, sym); + qemu_plugin_outs(out->str); +} + static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) { size_t n = qemu_plugin_tb_n_insns(tb); @@ -79,6 +93,12 @@ static void vcpu_tb_trans(qemu_plugin_id_t id, struct qemu_plugin_tb *tb) QEMU_PLUGIN_CB_NO_REGS, rw, NULL); } + if (do_print_accesses) { + const char *sym = qemu_plugin_insn_symbol(insn); + qemu_plugin_register_vcpu_mem_cb(insn, print_access, + QEMU_PLUGIN_CB_NO_REGS, + rw, (void *) sym); + } } } @@ -117,6 +137,12 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, fprintf(stderr, "boolean argument parsing failed: %s\n", opt); return -1; } + } else if (g_strcmp0(tokens[0], "print-accesses") == 0) { + if (!qemu_plugin_bool_parse(tokens[0], tokens[1], + &do_print_accesses)) { + fprintf(stderr, "boolean argument parsing failed: %s\n", opt); + return -1; + } } else { fprintf(stderr, "option parsing failed: %s\n", opt); return -1; From patchwork Wed Jun 26 23:37:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807528 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp546221wrn; Wed, 26 Jun 2024 16:40:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXEt62AlXKsEdjcfTU2VUY4yQBjCh22nfaJcaLlp9qgMksFz9cyNfjPRi05FvRtbXL+e3NC6i+ZpZuq+ljCjgAr X-Google-Smtp-Source: AGHT+IFlFTR6D7cGs6Jus9Z4KRyRA11LPqbDa33sO6CWJcuSfMEiw0oHpZx444KUETfUby5/eT7R X-Received: by 2002:a25:838f:0:b0:e02:b545:1bfd with SMTP id 3f1490d57ef6-e0303f52546mr12350376276.18.1719445221695; Wed, 26 Jun 2024 16:40:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445221; cv=none; d=google.com; s=arc-20160816; b=geOHXXUyRHx1opBRbdr9v3MZQAwJ0Ozny4VbZu61WcG4tNVVBs6CUC/SlAqX+zDeOw 13osYRtK4MSbnoG0jbyzxVy++iLeIKDjVdWV6b3giy5XZrBT9h9HBnH0KgosApfmDxBE e2kTsY2pDHOo8iWPo5u0j3gFWbJIjlSWlq/tFRVuSnFZ7ims7/JNC41tPC8mSelF/oj/ m0tyJV2bipSn0G1IEMIPoWtXO9CbiZ86grdizpjIogJBb3aw5SBlcnsNekWLf9iybbnX 0KCdWNoyTS9PQQVcK6iShMm4Fcwd9ZZMcdnpXzbO4N2G9zg6/e5gOYuUNucAu1IK00Na E/dg== 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=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=nmv4Uyom6MIjIAbmSBqejgAb6FIsqlrvY2uYYggWSYWVCv8WG3pSqtZl7BkbdvEDV2 yoBr3mWZRflKb/MZp5aMt51r/rHRjwC74Bz0RbOb1hqUBH/unJWwpIJSuvcaRAse9ObZ TOytrPgGlgSX3bCsh95eJkhr0aKl5bF5FN0j3z0puA7vo8RRQf6RdHB1lvLzx8o1gtON QxkW8NRm7CeADFdKVdbYNjwkQWLN6jISgRVuP1qq+5rEwoJxywSiYzau8MwmuKXQ45E3 gP6OQvEmf+xnP+UFod0iwUYOvwQg3fECelgzLtUo4lEGjLHXih1NVevPTNFZOAYnrfeY qYmw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dUJABsfF; 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-4464202b581si1031001cf.355.2024.06.26.16.40.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:40:21 -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=dUJABsfF; 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 1sMcE1-0007a3-Bt; Wed, 26 Jun 2024 19:38:53 -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 1sMcDQ-0007Si-G5 for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:17 -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 1sMcDO-0007Mb-Ix for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:16 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7066463c841so3687453b3a.1 for ; Wed, 26 Jun 2024 16:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445091; x=1720049891; 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=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; b=dUJABsfFOe4Lzd0MvfhrM1foZAI/KK1sa+yL6BOY0pFDrpV4072il+fva3MIfgizKb iqBIrx+lbMXV0nCr2flbfv95uoHY9JO31A5glo1vNzcC+PW5PzGipjjz8xT3f1SbXuLA t8Jrap5ihwKDOSLCFvHbVxl52o5Wtf8qhsMJWOcMQB4F2XxZQa2P3f1RDQNJY1hisNd3 S77Gko0vXJeH8EFa7t27xnDzffBY+yyet+gIUjEUqqhWw3Y/iWaAr3DnlKJhO6OWvweu S9E0hUjbFQS5nRMOfg1x+lvNrqWm6wcZsdroowMa8J4OHd+IdeLce2vTzk8XwKXebI9I oytA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445091; x=1720049891; 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=uC1drunn1nWD7FST8lIEBPaAEySNItr5VUia6HG7tQ0=; b=tNtr6V/CcWf1GGT3NYztcZ/6V3RHD8zDLJJnrSQXXgwxL/nZBujEbZiqIuX9n2lvJb G20cvlAO6Jd6lcCAskY3Oh5UPTHeBk0XVB5ViUqeljgYfk/BqbqJsWOV/JXg86MguuIL /CAgVLtW7OUpig3eAgpTGoaaaOHWsDeexCGwT99gY4Y11oEAFebLm9yhflvwDZcNnmLZ CZFUwvAD5BlKwZ84CTzrkKMQLG70bhV9JJnOMAJlzhbPIYCC5k3WMTYs3z2RPB0uWfQb AXYzEzqiRYD3KD1JbGp16bMoXfgtVNKln3JWIdZyY9L5sXaz2CaJq1rZWrOUQqNY1st6 b5qw== X-Gm-Message-State: AOJu0Yy8ON+0s/fP/S6B2cGoF5uOJmTHnr5sld0BOOLLDkSL+J6Sv7Xk hhpE2Hs/F/5JrHhacZxMn8lINkRH9kI1jo4HZlXMKG6pcC/ngTm1Xtl7vNb77Zi9QGuDuUS1Aot n3B8= X-Received: by 2002:a05:6a20:a921:b0:1bd:27c6:ee5d with SMTP id adf61e73a8af0-1bd27c6ee8fmr4575553637.31.1719445091555; Wed, 26 Jun 2024 16:38:11 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:10 -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 7/7] tests/tcg/x86_64: add test for plugin memory access Date: Wed, 26 Jun 2024 16:37:57 -0700 Message-Id: <20240626233757.375083-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-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 Add an explicit test to check expected memory values are read/written. For sizes 8, 16, 32, 64 and 128, we generate a load/store operation. For size 8 -> 64, we generate an atomic __sync_val_compare_and_swap too. For 128bits memory access, we rely on SSE2 instructions. By default, atomic accesses are non atomic if a single cpu is running, so we force creation of a second one by creating a new thread first. load/store helpers code path can't be triggered easily in user mode (no softmmu), so we can't test it here. Can be run with: make -C build/tests/tcg/x86_64-linux-user run-plugin-test-plugin-mem-access-with-libmem.so Signed-off-by: Pierrick Bouvier --- tests/tcg/x86_64/test-plugin-mem-access.c | 89 +++++++++++++++++++++ tests/tcg/x86_64/Makefile.target | 7 ++ tests/tcg/x86_64/check-plugin-mem-access.sh | 48 +++++++++++ 3 files changed, 144 insertions(+) create mode 100644 tests/tcg/x86_64/test-plugin-mem-access.c create mode 100755 tests/tcg/x86_64/check-plugin-mem-access.sh diff --git a/tests/tcg/x86_64/test-plugin-mem-access.c b/tests/tcg/x86_64/test-plugin-mem-access.c new file mode 100644 index 00000000000..7fdd6a55829 --- /dev/null +++ b/tests/tcg/x86_64/test-plugin-mem-access.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +static void *data; + +#define DEFINE_STORE(name, type, value) \ +static void store_##name(void) \ +{ \ + *((type *)data) = value; \ +} + +#define DEFINE_ATOMIC_OP(name, type, value) \ +static void atomic_op_##name(void) \ +{ \ + *((type *)data) = 0x42; \ + __sync_val_compare_and_swap((type *)data, 0x42, value); \ +} + +#define DEFINE_LOAD(name, type) \ +static void load_##name(void) \ +{ \ + register type var asm("eax") = *((type *) data); \ + (void)var; \ +} + +DEFINE_STORE(u8, uint8_t, 0xf1) +DEFINE_ATOMIC_OP(u8, uint8_t, 0xf1) +DEFINE_LOAD(u8, uint8_t) +DEFINE_STORE(u16, uint16_t, 0xf123) +DEFINE_ATOMIC_OP(u16, uint16_t, 0xf123) +DEFINE_LOAD(u16, uint16_t) +DEFINE_STORE(u32, uint32_t, 0xff112233) +DEFINE_ATOMIC_OP(u32, uint32_t, 0xff112233) +DEFINE_LOAD(u32, uint32_t) +DEFINE_STORE(u64, uint64_t, 0xf123456789abcdef) +DEFINE_ATOMIC_OP(u64, uint64_t, 0xf123456789abcdef) +DEFINE_LOAD(u64, uint64_t) + +static void store_u128(void) +{ + _mm_store_si128(data, _mm_set_epi32(0xf1223344, 0x55667788, + 0xf1234567, 0x89abcdef)); +} + +static void load_u128(void) +{ + __m128i var = _mm_load_si128(data); + (void)var; +} + +static void *f(void *p) +{ + return NULL; +} + +int main(void) +{ + /* + * We force creation of a second thread to enable cpu flag CF_PARALLEL. + * This will generate atomic operations when needed. + */ + pthread_t thread; + pthread_create(&thread, NULL, &f, NULL); + pthread_join(thread, NULL); + + data = malloc(sizeof(__m128i)); + atomic_op_u8(); + store_u8(); + load_u8(); + + atomic_op_u16(); + store_u16(); + load_u16(); + + atomic_op_u32(); + store_u32(); + load_u32(); + + atomic_op_u64(); + store_u64(); + load_u64(); + + store_u128(); + load_u128(); + + free(data); +} diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target index 5fedf221174..5f7015fd8b4 100644 --- a/tests/tcg/x86_64/Makefile.target +++ b/tests/tcg/x86_64/Makefile.target @@ -14,6 +14,7 @@ X86_64_TESTS += noexec X86_64_TESTS += cmpxchg X86_64_TESTS += adox X86_64_TESTS += test-1648 +PLUGINS_TESTS += test-plugin-mem-access TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64 else TESTS=$(MULTIARCH_TESTS) @@ -24,6 +25,12 @@ adox: CFLAGS=-O2 run-test-i386-ssse3: QEMU_OPTS += -cpu max run-plugin-test-i386-ssse3-%: QEMU_OPTS += -cpu max +run-plugin-test-plugin-mem-access-with-libmem.so: \ + PLUGIN_ARGS=$(COMMA)print-accesses=true +run-plugin-test-plugin-mem-access-with-libmem.so: \ + CHECK_PLUGIN_OUTPUT_COMMAND= \ + $(SRC_PATH)/tests/tcg/x86_64/check-plugin-mem-access.sh + test-x86_64: LDFLAGS+=-lm -lc test-x86_64: test-i386.c test-i386.h test-i386-shift.h test-i386-muldiv.h $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) diff --git a/tests/tcg/x86_64/check-plugin-mem-access.sh b/tests/tcg/x86_64/check-plugin-mem-access.sh new file mode 100755 index 00000000000..3884976af2d --- /dev/null +++ b/tests/tcg/x86_64/check-plugin-mem-access.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +set -euo pipefail + +die() +{ + echo "$@" 1>&2 + exit 1 +} + +check() +{ + file=$1 + pattern=$2 + grep "$pattern" "$file" > /dev/null || die "\"$pattern\" not found in $file" +} + +[ $# -eq 1 ] || die "usage: plugin_out_file" + +plugin_out=$1 + +expected() +{ + cat << EOF +access: 0xf1,8,store,store_u8 +access: 0x42,8,load,atomic_op_u8 +access: 0xf1,8,store,atomic_op_u8 +access: 0xf1,8,load,load_u8 +access: 0xf123,16,store,store_u16 +access: 0x42,16,load,atomic_op_u16 +access: 0xf123,16,store,atomic_op_u16 +access: 0xf123,16,load,load_u16 +access: 0xff112233,32,store,store_u32 +access: 0x42,32,load,atomic_op_u32 +access: 0xff112233,32,store,atomic_op_u32 +access: 0xff112233,32,load,load_u32 +access: 0xf123456789abcdef,64,store,store_u64 +access: 0x42,64,load,atomic_op_u64 +access: 0xf123456789abcdef,64,store,atomic_op_u64 +access: 0xf123456789abcdef,64,load,load_u64 +access: 0xf122334455667788f123456789abcdef,128,store,store_u128 +access: 0xf122334455667788f123456789abcdef,128,load,load_u128 +EOF +} + +expected | while read line; do + check "$plugin_out" "$line" +done