From patchwork Tue Jul 2 01:10:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809018 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830792wrr; Mon, 1 Jul 2024 18:11:56 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUn4K0WK1LstGIgLpQxNZRmUfjcw9BaNb8W1eS77KRCVeL+5XvxM7KVh/6sNR7MhGhu2du2vbkm28pW4fvAmEfv X-Google-Smtp-Source: AGHT+IGxdG2VitaUTzYwW07r353SG0LSGc2RE17FZd99m1QqFwTcXTZW2ByqFMab4SKd7XSgXCtm X-Received: by 2002:a05:6122:2894:b0:4ef:5c54:ba1e with SMTP id 71dfb90a1353d-4f2a56f28f1mr4275317e0c.15.1719882715921; Mon, 01 Jul 2024 18:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882715; cv=none; d=google.com; s=arc-20160816; b=RXsIUs8C2dxMON8Gh7mWDw+qHz1ZNBbYnlQYJwjKn+QUakH4lKl9D70vOtKCd/AQB/ 5xdd8TOUbGuZ/r2FqgtFv8ZZQpBp49MyZ2vGKZ3oMv/hZfmvYkt7PD/EMzNTvMEjWt1I rvtJjxBD1voV1UTPnYjXFU4hKIro5h/WVScr1nqKUOe+PICcdCqfvpezd3TF7Xabh1yd PSGCbsRxDyxkxELjCXpmToa5DETs2ARNXGm3Kmvhghxp+suK0v+H7437yQMD8iTR4R3B 6zE2LOKS2Hj89/vx+9BLQ2UZj5MtiOYXG99gKk6oEjULkJonflivC9QLUmdtLNfWA0w9 kQ3A== 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=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=oAq5wLx5NJCjMtg/IWzKu1izYq3xEdczATnIMVD34GiRCp3p/YZAvqswsoiRlU3tGx edxbbR28sXfPUNlEx4iteQTiZ+tJijjxH97yUnlDy8Cwz8T3mfsoPfpluX+kOKjEmj8q Wyupb4Z+Hw3Ux6COYpPtYHgrsln7kMhZfQU1ZZFG3sEmbAHgIQ69Y4H7ZVPW5hG78KEt WG2Uch7dQecqvZ225/O0E2E3zIm6uOflz8CYCh8gSBPK5NKSE+E/NOD7fe/R3FEkNabC +SeVPvkQQ1G+aHptU7Q3VPQcCSPb/62FmVa0ONbuoH2LZZ60XUNKmRWEXlGF1IoraSdl BTxA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SRgOykne; 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-79d692f0102si888625385a.311.2024.07.01.18.11.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:11:55 -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=SRgOykne; 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 1sOS2V-0005Qv-G8; Mon, 01 Jul 2024 21:10:36 -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 1sOS2L-0005P4-1v for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:25 -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 1sOS2J-0002A3-Fe for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:24 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1f9cd92b146so23690795ad.3 for ; Mon, 01 Jul 2024 18:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882621; x=1720487421; 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=SRgOykneNf94xyN/fiGnE7RH3grYY5wiszuViIjhegM64e3Y3oegaFCUnJX3m8WG8K mjNPoUS4Vvl4uus17uBH/j3OKtFufH9U0rH63PmddEN9/NwpO8oGocEmwqfMo5Ut5W0+ eUSCjLnVmWT16d2RPH+oHgujTbvcgwTDahh+4cvvbxRXYpwzXMX9rupwdbbhOjuiQQuI 6FHDkAP5wuOlcPC2/kCYgIxlO6fWR0+hT1HUAVjAXtmr+i3/GA13I9HU8VJ8Qt+FFBgy smaDc+g9i3v6bJnkv4ulFWpVxFesnMpKGfGiIZJfIWSWHWcYIIY21+kHeUuPaJWs1eCt 4tAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882621; x=1720487421; 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=fx3GLRq4iOJ5umqwNiP6lWJ70KIZ36p/x0Iuulx5SJVWzbkjQIGi3nOwe7jriuWdRs FNQWGTKe/8/NWZ8UO6ONTVxIEZIrD2jzcF5y5h+QyURQPrTbxfnltrTE+gO6aEJh88QC /dlov6Y/XddyNKQ/hY2fb4PvLKmHdq4yBD4LNnhLAjr6m6aphh6K6TFgvNS/vpRVz3xu 3Pj5l+sXgRDQV0kBhkyTvi7kEp7lOtPVkCYrB/puJDOQXWYVd7uD93HtDRrUOcl7Ugc5 i+XmUKNZezm5qQZin1lrsSuRGmEycBOz97x0QMtSUpmX28fYiurF9fZWlBHAVDt5LvrU ZjHQ== X-Gm-Message-State: AOJu0YwKiB2Fo1vFTVivmNJC8ZIFKCW+XRfg2W/sTUXIyDOCB36npKz4 B6pqGoj5fy7zJME10Vj+Cf4v4rLY9zffvpixXJvR91B4ReLKOuM4P3TM5gl5/jUqhXb2+GWkClJ z X-Received: by 2002:a17:90a:9e6:b0:2c8:4fd5:f647 with SMTP id 98e67ed59e1d1-2c93d7143f0mr5241630a91.24.1719882620829; Mon, 01 Jul 2024 18:10:20 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:20 -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 1/7] plugins: fix mem callback array size Date: Mon, 1 Jul 2024 18:10:09 -0700 Message-Id: <20240702011015.325609-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-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 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 Reviewed-by: Xingtao Yao --- 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 Tue Jul 2 01:10:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809015 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830639wrr; Mon, 1 Jul 2024 18:11:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVuHW58rxQ3bysHXzOmTs0r6jXJpGOgyoatabzWL1V7q+7ltjA2oZ83eCHS1XqcBehFz2FOAJ6uDiE7wnhoRy6F X-Google-Smtp-Source: AGHT+IHGpgWkhznewQ0kz3LcumBd/aQSYoCf13ybg8ZT62AxuqlajdeeeNpfJTY6INgbhJS9arv4 X-Received: by 2002:a05:620a:28d4:b0:79c:2d:1f40 with SMTP id af79cd13be357-79d7b9e124amr1125723985a.26.1719882678127; 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=drJRaNtj7biYDLlwO/DqmAhO+/LZgaY0Ecn14wMc3GIcOv5QgPgCEsBa7C98D0LiOx zSsR1kexHY0kgAoBj3lSQQ7PXC6ppcokd6lRfxIFM38qAAv0FGqBskCdsnj9QYrkL4c5 33nrDCWqe1/IzCaQWYFdbxY5T3t+AkFGc0Mfaw0KOlkLit7GPou0c3oe9vRls5qU0tkj 5YEyIwVG5/FTCWjMAsgk/tN4HrXPMjdgx+79+FdwuG/i05nMDP/RSBX+yFLzVmB86Y3D xTdTTcJVqGkdhmVw1rVRjHiPLa1YEEmF9/DUbAelIWgmCWO+KXUYdhvMggA9NSEZskge vcGA== 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=+uOK153DyUSUd29q8p0lc894A904pRYCTbUBrjTr8eI=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=JaaWnBPvszMU9BGqIy9rDYe20XSA+vItQrB4K4gjO0bOhA2xv2XQjRynAFFWPIfc4m 3/vSeE14XPb9q3VPuZhlwdnvOfxwUo1igze/1LtLQMXqihRyD7UIkThTb4xninGG+Rs1 v8keBsJbDqi9ErlyVQktJlTIWuddQD+FIAef8WZAo9H52q7EMe3qRJLXCf8cgAj9XbaW NU07CNG76AnlAExP4A0Y3HJ232Fnuc1gCRaNW14+vfVjffps4SutA7BiQuUG1hgmVDHy YVQ45pp9YHN360e15QpGfnSGF6sut3fiZOMerKOsVCav7O6+5Ifs9KCv3Uor4KaMu6H0 yGgg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="l3l//Hy6"; 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-79d69289936si991165685a.213.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="l3l//Hy6"; 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 1sOS2c-0005SB-Q7; Mon, 01 Jul 2024 21:10:43 -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 1sOS2N-0005Pj-Ex for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:27 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2K-0002AD-TI for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:27 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-70699b6afddso2327861b3a.1 for ; Mon, 01 Jul 2024 18:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882623; x=1720487423; 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=+uOK153DyUSUd29q8p0lc894A904pRYCTbUBrjTr8eI=; b=l3l//Hy6+LDjhwqet/KZ+W8+0Hh9wPC2VWseHIwekZSbxBN4ETMG+fJS5IREOcDXGb +7C6qUt9CcF6FR3eh0Zl9U4eo5Tb2xqgiqcxrlSGOY6cGgY7kkOPBb/idIkfaCVpo16M mWRPfMNMGfN7QoLZ80twTUM7QhHk9656dPTiMjuqQ5lnfxDeOX2HV/t/AfXUNjGLMnhu MpKIGn79+R4jt7X7Rm9iQ4w6c7V5LqJI2cy3lgQ1Qshtbyb8FpiYJwV9ZwSE+DpB+nad GT4qFaRaRtUsI87WyX9gkRm7CDZuBbZzvdl9eciLEF+nhG9+4HmBrDsvxClphGx8xxZu En9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882623; x=1720487423; 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=+uOK153DyUSUd29q8p0lc894A904pRYCTbUBrjTr8eI=; b=ITeGRdQgY6V0ZVLSD6LMthhqUuHOdNsM9otUDrJ5Mv7PHKp6Ek5kcytEg9H2GPhXS0 pavXfxqVqDuPwy1gyHzRshDX/jgAg/J6Hha8Q0UqdUttXyQrNYMyap7rI5hV56yn3XIa iy34wKsYoUQqH6cykCCwdMi0pMbHlGIjAsitzGbYDKWmn0rlwi0+GZtQ5rwo5V8bHF1w hLEDSdvIHBimbyk//KFogIiSuvImUTAVVYe3LYV2Y/eA0DV4x8WnD9K8h8nN8pznKY64 cdskBZmZTM017CbC/lMVA36CU3Vi8cgvHiKF0Frb0fJKfXe253w9Sy2/3v6B8mmxiKfg DIew== X-Gm-Message-State: AOJu0YwctrhS4b1qrKYCpqAgwc+pdNDudR6C7MvOKe05bOzT8+RBnASv SAU5JDtIBuyO1PI0q/ZOg0alnAs58m7pZQEsoXVa+t2kww4rFBMnYeX108iD/HgMhS6Af/FraAB z X-Received: by 2002:a05:6a20:7349:b0:1be:c63c:f7b3 with SMTP id adf61e73a8af0-1bef6198801mr6287364637.31.1719882622537; Mon, 01 Jul 2024 18:10:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:21 -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 2/7] plugins: save value during memory accesses Date: Mon, 1 Jul 2024 18:10:10 -0700 Message-Id: <20240702011015.325609-3-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x42f.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. For now, we can have access only up to 128 bits, thus split this in two 64 bits words. When QEMU will support wider operations, we'll be able to reconsider this. 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..89593b2502f 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 VALUE_LOW(val) int128_getlo(val) +# define VALUE_HIGH(val) int128_gethi(val) +#else +# define VALUE_LOW(val) val +# define VALUE_HIGH(val) 0 +#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, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(newv), + VALUE_HIGH(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, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(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, \ + VALUE_LOW(ret), \ + VALUE_HIGH(ret), \ + VALUE_LOW(val), \ + VALUE_HIGH(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, \ + VALUE_LOW(old), \ + VALUE_HIGH(old), \ + VALUE_LOW(xval), \ + VALUE_HIGH(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, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(newv), + VALUE_HIGH(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, + VALUE_LOW(ret), + VALUE_HIGH(ret), + VALUE_LOW(val), + VALUE_HIGH(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, \ + VALUE_LOW(ret), \ + VALUE_HIGH(ret), \ + VALUE_LOW(val), \ + VALUE_HIGH(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, \ + VALUE_LOW(old), \ + VALUE_HIGH(old), \ + VALUE_LOW(xval), \ + VALUE_HIGH(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 VALUE_LOW +#undef VALUE_HIGH diff --git a/include/qemu/plugin.h b/include/qemu/plugin.h index bc5aef979e7..5dc10c5ef65 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_low: 64 lower bits of latest accessed mem value. + * @mem_value_high: 64 higher bits of latest accessed mem value. */ struct CPUPluginState { DECLARE_BITMAP(event_mask, QEMU_PLUGIN_EV_MAX); + uint64_t mem_value_low; + uint64_t mem_value_high; }; /** @@ -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_low, + uint64_t value_high, 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_high, + uint64_t value_low, MemOpIdx oi, enum qemu_plugin_mem_rw rw) { } diff --git a/plugins/core.c b/plugins/core.c index 9d737d82787..a899eaf37af 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_low, + uint64_t value_high, 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_low = value_low; + plugin_state->mem_value_high = value_high; + 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..ea7f4fa8ded 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_low, TCGv_i64 value_high, + 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_low, plugin_state, + offsetof(CPUPluginState, mem_value_low)); + tcg_gen_st_i64(value_high, plugin_state, + offsetof(CPUPluginState, mem_value_high)); + 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(ext_val, tcg_constant_i64(0), + 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(val, tcg_constant_i64(0), + 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_LOW(val), TCGV128_HIGH(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..6056598c23d 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_low, + uint64_t read_value_high, + uint64_t write_value_low, + uint64_t write_value_high, 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_low, read_value_high, + oi, QEMU_PLUGIN_MEM_R); + qemu_plugin_vcpu_mem_cb(env_cpu(env), addr, + write_value_low, write_value_high, + oi, QEMU_PLUGIN_MEM_W); + } } /* diff --git a/accel/tcg/ldst_common.c.inc b/accel/tcg/ldst_common.c.inc index 87ceb954873..ebbf380d767 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_low, + uint64_t value_high, + 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_low, value_high, + 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, ret, 0, 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, ret, 0, 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, ret, 0, 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, ret, 0, 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_getlo(ret), int128_gethi(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_low, + uint64_t value_high, + 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_low, value_high, + 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, val, 0, 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, val, 0, 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, val, 0, 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, val, 0, 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_getlo(val), int128_gethi(val), oi); } /* From patchwork Tue Jul 2 01:10:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809019 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830812wrr; Mon, 1 Jul 2024 18:12:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW5dsCs2pFKFhNdCc++F8RNyR2LON1HkASqeV5pXsXQh/7mMQZRVxc8hTo0oCJdMhLHEYhgRbCGBa+RXVjFdYnI X-Google-Smtp-Source: AGHT+IG8Bc5I1QwUeHD4gk3UmKdlGxIFQHTzttl5p0sarYpDppQgtBQRh0N9/tFen6M2mtlSlA0v X-Received: by 2002:a05:620a:4387:b0:79d:6a8f:cb96 with SMTP id af79cd13be357-79d7ba973ddmr1006094685a.77.1719882720590; Mon, 01 Jul 2024 18:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882720; cv=none; d=google.com; s=arc-20160816; b=e0HeEcfHgJLF/2WKguNeqeNyqMMROAR4poAthG0EyikPiDfkxQGsToIqHuTePn8uko SUN38e/fODShbnkBXeukM3PaoGEaZZwG/CITs7ol0KTVLPbYlK5sVaupZEUB9jygiN1S 6G1BSB53eZugvD0cS0eSU+Bjlr10ZeMvSXxGNsf9d61BAoe3uKvt+tt97oTFDLst4gzU GIPTlL0gpxuKOfrEJY/d8jTTD1Oq7BvLg796+7gNeycttccXrM+g2Y8r1CH0O/8eeR5Z 9xj+sfB9FCQPkeFPiei/i25Zt1cLgE5wDraG+rcrkrQJsC7fG8kh0pnWz0hVAxCj4cM8 NpHw== 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=NgZfKU7tYXfEOC/70NsW0CAjeY4aEJw+E56SlRpuWWc=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=VMlJVBuKJ5JnyZIxgaJ925qPqYxEt5VgH5Jo+TtHj8t0qkQNdmMootrwu+klnQWUXf jw6mrXY4TJdc+8FDeD0OU+1aqPtK+0dAOJSWYOH560TZEoKF5LRmrLme789d/XlTPq9h jnDNkGWsza8pqRkw7HzNho/8J01o016e0N+J/aMFw4o+LiVZKqaDkQg4tmS5nRA5Gbdu oL0CFhSKRBcdI7ieITDgmiTmIbCX/NANhu4wPzZT4uolY8nPdhNZP3km0Gbiy+/dJD/k pzmDaYMkm4QxbbgloUt2PeKTYUS6K495CpWFjNBwLzgedntSs4QR+mdPcvg45HOAQ/5x MVEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=S2FIzis6; 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-79d6933a65dsi1002685485a.651.2024.07.01.18.12.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:12:00 -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=S2FIzis6; 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 1sOS2e-0005Su-Kb; Mon, 01 Jul 2024 21:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOS2X-0005RJ-7J for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:39 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2N-0002AO-EI for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:28 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-70aaab1cb72so2190269b3a.0 for ; Mon, 01 Jul 2024 18:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882625; x=1720487425; 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=NgZfKU7tYXfEOC/70NsW0CAjeY4aEJw+E56SlRpuWWc=; b=S2FIzis6TuagyS4oE6UkA9eIay+PHVQ9n8mLc88hF42+HOl7aNsHNPAkOtT/RvrDY7 gcomdXUznUHd71uHCTgL0v+zoPF1JjG5t2lLDWLm5Y9yZIr113aRwPcyIla8+QXuUSts ws8R5YSsmb6qWKU+GekiKe6qHJH1xH01WTQh7D9WpbkPMr9cbFqu5zvcBaYj1i0P4Igi TaQ7XzV1hMxfxMm+WXYs6q0up/s0h9J/PqnrCRZ2/bkMPcx7q9+vDOIqerE4unU/vz2F dBTSz852nkuyL70ICoDFgEO9f4oaPfarBIi7oPc5c9Y9R99ZFXBv2Q05yoy7dxCk0wSG C7qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882625; x=1720487425; 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=NgZfKU7tYXfEOC/70NsW0CAjeY4aEJw+E56SlRpuWWc=; b=ID3+0kcl9SEFPKRax/A/3nE2+eaXcWMPOoTvC+fpANAiVwvsfm6YBJABwwrC/3vulg n/iVuzGrQ/seUyN03roY4mfd+ptT1CI3ziCyan1WEKNDeeiIIDWjCXaeth/LzMrtekky 8hzIlquXpJZkxPqugIZZQEOrsk0QyMakeIaCOJf4jbQ7acDvHJDDTfu1Vs3yJC/zbIuW yO/2XOsrybQGKMI52YnsYEBcKGgxHxyuZcH0ytpyzdKjmaVIIxj3WspyiOT27tQquudb wBaBNaIOxxjk/uhp4nsRR5y+MqBxXK5avI/iX/NZMgsBw2lnPJ4ICg1lrPXyNBJxM7AB tA9Q== X-Gm-Message-State: AOJu0Yx5SfEjH1VynyVLnJ7fQ52zfkBbedm5axnXIKragZfpXnKT0nVy E+P8t5+pPaXUuymBWBQDFJ/35xtle2ca/5ZbWULJ59JhkleLZ8LuQl6eew2FGH272+W4rsb8ssf Y X-Received: by 2002:a05:6a21:99a5:b0:1be:b312:abd3 with SMTP id adf61e73a8af0-1bef60f5f03mr11530030637.8.1719882624652; Mon, 01 Jul 2024 18:10:24 -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.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:24 -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 3/7] plugins: extend API to get latest memory value accessed Date: Mon, 1 Jul 2024 18:10:11 -0700 Message-Id: <20240702011015.325609-4-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x436.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 value can be accessed only during a memory callback, using new qemu_plugin_mem_get_value function. Returned value can be extended when QEMU will support accesses wider than 128 bits. Signed-off-by: Pierrick Bouvier --- include/qemu/qemu-plugin.h | 32 ++++++++++++++++++++++++++++++++ plugins/api.c | 34 ++++++++++++++++++++++++++++++++++ plugins/qemu-plugins.symbols | 1 + 3 files changed, 67 insertions(+) diff --git a/include/qemu/qemu-plugin.h b/include/qemu/qemu-plugin.h index c71c705b699..649ce89815f 100644 --- a/include/qemu/qemu-plugin.h +++ b/include/qemu/qemu-plugin.h @@ -262,6 +262,29 @@ enum qemu_plugin_mem_rw { QEMU_PLUGIN_MEM_RW, }; +enum qemu_plugin_mem_value_type { + QEMU_PLUGIN_MEM_VALUE_U8, + QEMU_PLUGIN_MEM_VALUE_U16, + QEMU_PLUGIN_MEM_VALUE_U32, + QEMU_PLUGIN_MEM_VALUE_U64, + QEMU_PLUGIN_MEM_VALUE_U128, +}; + +/* typedef qemu_plugin_mem_value - value accessed during a load/store */ +typedef struct { + enum qemu_plugin_mem_value_type type; + union { + uint8_t u8; + uint16_t u16; + uint32_t u32; + uint64_t u64; + struct { + uint64_t low; + uint64_t high; + } u128; + } data; +} qemu_plugin_mem_value; + /** * enum qemu_plugin_cond - condition to enable callback * @@ -551,6 +574,15 @@ 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_mem_value() - return last value loaded/stored + * @info: opaque memory transaction handle + * + * Returns: memory value + */ +QEMU_PLUGIN_API +qemu_plugin_mem_value qemu_plugin_mem_get_value(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..e9c07610052 100644 --- a/plugins/api.c +++ b/plugins/api.c @@ -351,6 +351,40 @@ bool qemu_plugin_mem_is_store(qemu_plugin_meminfo_t info) return get_plugin_meminfo_rw(info) & QEMU_PLUGIN_MEM_W; } +qemu_plugin_mem_value qemu_plugin_mem_get_value(qemu_plugin_meminfo_t info) +{ + uint64_t low = current_cpu->plugin_state->mem_value_low; + uint64_t high = current_cpu->plugin_state->mem_value_high; + qemu_plugin_mem_value value; + + switch (qemu_plugin_mem_size_shift(info)) { + case 0: + value.type = QEMU_PLUGIN_MEM_VALUE_U8; + value.data.u8 = (uint8_t)low; + break; + case 1: + value.type = QEMU_PLUGIN_MEM_VALUE_U16; + value.data.u16 = (uint16_t)low; + break; + case 2: + value.type = QEMU_PLUGIN_MEM_VALUE_U32; + value.data.u32 = (uint32_t)low; + break; + case 3: + value.type = QEMU_PLUGIN_MEM_VALUE_U64; + value.data.u64 = low; + break; + case 4: + value.type = QEMU_PLUGIN_MEM_VALUE_U128; + value.data.u128.low = low; + value.data.u128.high = high; + break; + default: + g_assert_not_reached(); + } + return value; +} + /* * Virtual Memory queries */ diff --git a/plugins/qemu-plugins.symbols b/plugins/qemu-plugins.symbols index ca773d8d9fe..eed9d8abd90 100644 --- a/plugins/qemu-plugins.symbols +++ b/plugins/qemu-plugins.symbols @@ -13,6 +13,7 @@ qemu_plugin_insn_size; qemu_plugin_insn_symbol; qemu_plugin_insn_vaddr; + qemu_plugin_mem_get_value; qemu_plugin_mem_is_big_endian; qemu_plugin_mem_is_sign_extended; qemu_plugin_mem_is_store; From patchwork Tue Jul 2 01:10:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809020 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830823wrr; Mon, 1 Jul 2024 18:12:04 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX60837++//HVodzQTCUbFFefRZJWaZbn4GxhBY6Mh/FSvJqIX8xF3WBN+hYHeAUc52zoEDxDyWxOHh+SyL/hI1 X-Google-Smtp-Source: AGHT+IHd7r06LCA1bHptsb2dNtP1q5N2SoBrD+o5yFpUGtSJdcaYX2TFXD4gUEAq4LIe1oxcmYxZ X-Received: by 2002:ac8:58ca:0:b0:440:9078:f438 with SMTP id d75a77b69052e-44662e4149amr91774171cf.49.1719882723879; Mon, 01 Jul 2024 18:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882723; cv=none; d=google.com; s=arc-20160816; b=fP/9+cNFRkAQddath4qJc6a54cQlbZQLpRqVOAR/XiafXbFYyZqk0AiOHhiJMDPjnx 43fnod/yB3/St+y78WDfvY9VKEc2nfF9kI90AVk6kQ5TGNH4zq5nookPgulShhPHEKW7 geOoTokpfIR4ahUDLl349sokFt4mJlyXPXcudGUiBs3JHnU1IO4mAtwzfAt54i1eLowp gLQdikvJPzhk+kJ5UcZfPOU/N0AHWUDcx+JaEEJSBNfgP/ifN9egoJOZBRaUBWtPmrbp VyUhWZG7BhgXITek0h0oap9zqG0y97MwQvE2jSH0h+39fZ7Q4/9JOhGh2zXbY3aXrrJJ 8UJw== 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=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=GbDjH2cIk00v7dCrxWjzS55S0oAQSDvwmQ3ViH7cQcxF6ZdQUElKruScn9iOlGqPOF 20ic5R9wh8NvW1x8c84px+vm9kZFRisvPIRDMevM1/NWH0bj0Bxjl/4covsVEX/m2sko x6/jpEhgXzkoq2PnYSRdHwLkMcZXCQRRLaoGvRAiUz9/kGtljXS3KGybSrIMrU2S5Yv3 7huUmy3UjmE0yNDfvCs9h8l5phJIMlRi4t8dusU7EkGp8SHIuXTgxWq40yU0Waf6PQXi dRGXmVl68VHmRz0T5zjEyKTJmwSUC7JZSTQtOI6KlkdqahVAc4DBMCIYTnU1vrDFYAks tlIw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CpTK7hSo; 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-446514e538csi90389941cf.732.2024.07.01.18.12.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:12:03 -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=CpTK7hSo; 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 1sOS2e-0005Sv-Rx; Mon, 01 Jul 2024 21:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOS2d-0005Sd-PG for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:43 -0400 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2X-0002Ac-03 for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:43 -0400 Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-2c8e422c40cso2056651a91.2 for ; Mon, 01 Jul 2024 18:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882627; x=1720487427; 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=CpTK7hSo9lCZQR1nv0XPdeMfn3hleLofUS3y/mz7v4bjHjsDogxL4JrsD2Nge/2oyb unHGTXg/DNrpmSKGE38bmQrYifjcpqBPBWLOx0kUtAcvODdPiLNxFY6zFcjEi+W8dbtX SEgzr6nx3eVwZ0MTt3kHB9fuV47huKyUyJLKM39dwHWN+U9/5SZ6z7b5bwuBkDs62XQS nne7lNiHHcGpEUps+1BOSkYgZdvttH0U9s+pZB3Q+xs2VcQxGtNTxDe/yoPOQz4xZ2nn hvMtqYwVxPx+Ckk2LDqAfLPcw/8B8etBLsS2HeQTYlxU21DDCRIHKFJnt3h2KNJRkldB ZjAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882627; x=1720487427; 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=gY8A7veYogdTE1rHogyV0ro0bSN98q0yshlC4zhpQBwWSG88bi6mEPymM4H0NF/N/T YxMOe1HzdHv+D7H7dxCMmIwZl4VbSsOL82VGmrfvKVZ5XZtvNHNrXeJMzaMKmyh/JQtg uHtBYHCNB1uTRwKlMeEq9h9okD397GP4MMBaNxYekO7P/mn1Km2WsxYcnp3HYtWeoq8S Cl1kxCM7HI3zuD//pJyefRvR3wsFPY+jOxj3Gw6bqBHOxXdSYo69SzwUlnZBw2XDnHwC vP2A3VuthpXt5zQL5t3wTpMGjqoQbAgv67Smt2G3lxD554yTdEpsPrLmJ0y+itUHCxSm GONA== X-Gm-Message-State: AOJu0Yxz0gWuSS3Dfd+rFU3QwojYFNIsb9isa5AJM579pcuQ7+xAF4Gq Kx9OwV1eveRc1sTBLL4cXvhSete/LMBHKGPti6VIKkbU526vzvoYPYiHcQOSTEGUd0nlvoAhYxO a X-Received: by 2002:a17:90b:3d8:b0:2c2:dd1d:ce6a with SMTP id 98e67ed59e1d1-2c93d77a623mr3766383a91.45.1719882627597; Mon, 01 Jul 2024 18:10:27 -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.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:27 -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 4/7] tests/tcg: add mechanism to run specific tests with plugins Date: Mon, 1 Jul 2024 18:10:12 -0700 Message-Id: <20240702011015.325609-5-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102d; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pj1-x102d.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 --- 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 Tue Jul 2 01:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809017 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830788wrr; Mon, 1 Jul 2024 18:11:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVqgBt7TDQhb0PRjDiz6d7xjDx4i9yaMcHhbxyoH8c/5tvCXoy8YmQ8cKygL3cgoIjGtM8hWGiQ86TOB4j/2/cv X-Google-Smtp-Source: AGHT+IE9C4hhSqcinlxjzku9lH+/buUi6FEIdUI9mquFGaxyySU9Lk1AVjeNPAd7Yy9VRp4BOLV1 X-Received: by 2002:a25:9e89:0:b0:e02:bd25:9ac8 with SMTP id 3f1490d57ef6-e036eb27ee0mr7498791276.18.1719882715447; Mon, 01 Jul 2024 18:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882715; cv=none; d=google.com; s=arc-20160816; b=N37YHwiR3Qbvw5IVf30+RjBuWpRgx8Hff/gF/jBkJhjiStjhRFIoGsXp5dTKoyurNR 18zwZ9qe+mPGSSJ1rCAeXFMcNmMw9Lzi2sh6lkG8sdus4i08iKsLQ6Mvxg9HHXFsu+ZZ 3LpesAKBTH2O1K/6qfGIYUR9KJjk1DrfFNnFByVdRidwpgSQRkaN4AEHvhlRaa2QsQnj RTB+qlbT9I/1BQa9nfbAH+2ozOhN/YU5YRWSbpKSqVFwhYNXy6wVKRaorSJdRIb6aa2E ZAJFPeZIj97s4/vmSAWebyYx+8Xm2XhgWEgcXVvaOre63my6a3Qosc7JnHcQJO+5WVRs GU2A== 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=tJdBX9SfhlJKk9rWv11IMwaEBO+AoHCZIGuGx9ia+J0=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=G/YLI/QdadHRV63rCyNTAlZV6DZdAX16ep+43VZCEdDALEgn92kf83BJMj/ykasDzb 9khDdLDgDVMFXdFPJQT3CuzbF5RYsGsyAlRlZQi167n1yK2hi51527pvmSip0sFeeklt W1kz0UZlGRGjHQka43SRiA0YFprfEIlPzuJOP0t0sU4EtWxzLxJKUCcBMw5DswtPs58T fBgoZMqE2wtFlfmicPhKmeuOQzJjA6URbzY9RY7PZpoe2OrIp8bq3Siu3c1SFpxCqWmM pGiw7xJ31fWoPASbOvW52m0zb2oSslPWO0Sd+XBg6Wl/s34lUFoKZWChbxGlBtQw02a/ KmDQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FsSPEXY2; 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-446513c213asi90877491cf.99.2024.07.01.18.11.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:11:55 -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=FsSPEXY2; 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 1sOS2h-0005TC-2b; Mon, 01 Jul 2024 21:10:47 -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 1sOS2Y-0005Re-I0 for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:39 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2X-0002Aq-0H for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:38 -0400 Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-7066cba4ebbso2416252b3a.3 for ; Mon, 01 Jul 2024 18:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882629; x=1720487429; 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=tJdBX9SfhlJKk9rWv11IMwaEBO+AoHCZIGuGx9ia+J0=; b=FsSPEXY2foY0iZHcV/z7Tl+PGbKeYp1jhYzGjBwagT9MkGVskczTi9imLlpVCVR9fT 1ZXWsmPdpgj4NCfi3sirhL1g/MOSFxjvmSvm2SsDgLW1kWr2T8sM8k7SPln309X61YXi bDwc71371+noup7KkzYMTZoG2V4Ww6DfTY21jfFBtint0gr2ONeBNgGPFOnWtXVuXMt8 sTJaAWEbOV0KXNZIZHgggcHVVwADJPCR7y/UBn8eeqX6MpWNAzTsY+H2lNB5QwfAj3DS pm8KX7hwsGzPd2eMGMphkwF/8iDJrzs4HMvabFP68B7X+VLQVeo77bdYDLiS/6PDak9y aYvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882629; x=1720487429; 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=tJdBX9SfhlJKk9rWv11IMwaEBO+AoHCZIGuGx9ia+J0=; b=j6Wg/7pe7W9rrCsxQFw0qsHdLjbtigULgQ/b1O8fixXmy/VmNXO/SWm+ndXafKFdXO I3D5p5X9l0diQpzi95ZtDfe5So4Q7bZh4uNHP06+OG1AqcaJ1W3FRxGJafxiSMuadZX+ njtIkJ2koWMtisXSEmHnK+IFiXCbSy+ApQnbtnQcRSYK4+OSijSrPnWGNFjVOXaGqKb1 oBjsHSCtt8iTGLrvURuyL+JsDmRYBe5s5hK0iPU3zFPFSl+hnTLiQKwmBL9PjuHHPk9X QU57OL17iQL7EIYIlVll+pNTl6jzbrC0l6cNW0V85dDvj+0ptcYLM9dBS+lOCrXph4nJ r1kw== X-Gm-Message-State: AOJu0Yw72G/E4mwPZ8WqLa7UDDJ/4jOqq2TY0NZCyo8zupgQw5PsHPWE RGMz8VjPBmh73Ey0x8chixoLTwTsp0cbDXJ0MRgi2aNsoNJPOm1hKrXAR3W5/ivoF9P/vViP7r9 s X-Received: by 2002:a05:6a20:3ca3:b0:1bf:594:ea91 with SMTP id adf61e73a8af0-1bf0594eef1mr4633315637.42.1719882629321; Mon, 01 Jul 2024 18:10:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:28 -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 5/7] tests/tcg: allow to check output of plugins Date: Mon, 1 Jul 2024 18:10:13 -0700 Message-Id: <20240702011015.325609-6-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::433; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x433.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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/tcg/Makefile.target b/tests/tcg/Makefile.target index dc5c8b7a3b4..b78fd99c337 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,9 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(call strip-plugin,$<)) + $(call quiet-command, $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout, \ + TEST, check plugin $(call extract-plugin,$@) output \ + with $(call strip-plugin,$<)) else run-%: % $(call run-test, $<, \ @@ -194,6 +198,9 @@ run-plugin-%: -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(QEMU_OPTS) $(call strip-plugin,$<)) + $(call quiet-command, $(CHECK_PLUGIN_OUTPUT_COMMAND) $*.pout, \ + TEST, check plugin $(call extract-plugin,$@) output \ + with $(call strip-plugin,$<)) endif gdb-%: % From patchwork Tue Jul 2 01:10:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809013 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830637wrr; Mon, 1 Jul 2024 18:11:18 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWJDQUrn8DbKdGVzMUCUZYDdYmvJTxqjPAjwhaGuLp45MY6qnULufMiNIz4KMUUo6mZDWWo7gQ1t1z77+8DQ6WI X-Google-Smtp-Source: AGHT+IHwaiH5HfB30O6mNSEAW+dK+jSF2dXnigFL5FTdjppUMcqackp7XEYpnSS8YcicvlZPrVuJ X-Received: by 2002:a05:622a:144e:b0:446:5f64:f3bf with SMTP id d75a77b69052e-44662ec3827mr106356291cf.63.1719882678115; 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=iXBvR4gX+hoSQTqoFPJYS5UpIrO3lp89KhiL50fbsizcPypOVLdJ819DDCCsEU4egM mBPAfraTt9E++dWUTAS4XZZq3UNlxHFY1drdedmBRWNU0pcaWUPo5t2LYndPhD0MIPhc +wzqYOOmZkJ5dr/hKpBnhnu9mFLcQxfoQpLpe9ozGPFKPnJaoc+W9INjaHprgp55KfT9 aZQm6Zxz8RlyEA+lFRKOaJt0q22VsiVEJXzd4tz7JRuyC9wM0MROJ/nTpzw5qFBDKCZU TiqcxoIijZ6I8n8IggQp+1veyJwlHMToxwCO/T+l2SBWuuMWB1A+1wV1V29hM3YoMNf3 2rFQ== 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=KQGGwWjGBzDeoWSZMlw/pE8YwbdHKTdXx63bixAfqp0=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=jIJhsb7Ee/JT+B4MK5LL66ZtKHf3ZGhd/wN7k+r07DoMFZE0aDP6q6/gVa2UqPEqO6 J6HGdwvXLE5jWkyjbBGTyo4cm6bVxweeGoGj6beXmQms63CNoLQe7DtXqyum6K4q8lYF uCF4Qb6ofyAuMGmNq1N6RKCF9viTfLNIuMrGfI7fCF7FX5+Rf5AswW+MDv1WN8vG6PHs nj4n863WVN6ERk+A0XtCsJgfF2/dn2nhnKOwoGu/EVXZFAhrQtSdVlYKuEeeTkvtH1I3 Y4Q6LF4SV24AUSdMvtZhl7vSklHrk404+yz1z+m7viKtE7bjP0oe27jsB2Nph5wOwdok W/uA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=R0tf5gcJ; 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-446514e2bfasi95295781cf.680.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=R0tf5gcJ; 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 1sOS2i-0005UA-16; Mon, 01 Jul 2024 21:10:48 -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 1sOS2a-0005Ry-2S for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:40 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2X-0002BF-0X for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:39 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-2c86e3fb6e7so2243242a91.1 for ; Mon, 01 Jul 2024 18:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882631; x=1720487431; 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=KQGGwWjGBzDeoWSZMlw/pE8YwbdHKTdXx63bixAfqp0=; b=R0tf5gcJf/EUOb0jQqL7qDC/Au3bC1ysk6NveT/RqtubH44dLAoHTrIO9f4MTbQcwU jmEW1tKt6sGqRUvBm0R6rHh33Y2r6OKrqWxfN+8t0LUPneiZW4g5zksaewcZXnE/rEZN GXNEe9H66Z6AL3/AO+D0c8hRSQMwX4aChNrVQbasquq8GDaEhxsYP6KZKSUBCkNjSkBW JKVy1IscD57lSo7jKZ3BAIXbOe6EoDdHnA3o27foN/+qv5VegP1psrJSCU2meP3IpJYz qP7BdL6ZgREr5rvTIqkK1UiocUlRM6HECLAOdtTIc+4RGemP5/n2C3v+iiG5tF53hKh0 zF4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882631; x=1720487431; 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=KQGGwWjGBzDeoWSZMlw/pE8YwbdHKTdXx63bixAfqp0=; b=Ni2JKuz7QHx8RaUMjkIgm1avdrfRWxqNAReR4QD51h9LBnYsaauZQ6fYXcFmORHVNS AfDigEZj7fvxVYSQP0gL/JEyHffkkGGbkKUt0gejzv5Jb+S7Nf+UV8sqWsCZudiZb5oA K3CXyhsdaHmEvZ9Iz+iBjHGI4/efHZ0668yilU5AAVFkoC1Hfm/3zmwl30OtsVyEwX1i t4NV/1cgfR9lY3WB2j6qAHrSAeSTaLXGsftCC+1vpCT5EWdHPK7No1/0zfWtqlCNbP+Q PRPJjJzKoHX/X/xmVcyS7gByp5wK7+ZUU78bc5NkjiTIGQQolYwbk9sxHgYO4KnhfgHq YN5Q== X-Gm-Message-State: AOJu0Ywu/UoTYbhv9pHO05js07zeZFwdqxvKY+9DFhKckaHKGshSBOql VGbA7q4UDIlvSkGNfbzmbNMmBElMXcrO3z/8ic28LICfyU9snUqlJbAdneEepPoEYrkaP63sZwH f X-Received: by 2002:a17:90a:fe13:b0:2c4:b515:46d4 with SMTP id 98e67ed59e1d1-2c93d6ef057mr3670714a91.3.1719882631002; Mon, 01 Jul 2024 18:10:31 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:29 -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 6/7] tests/plugin/mem: add option to print memory accesses Date: Mon, 1 Jul 2024 18:10:14 -0700 Message-Id: <20240702011015.325609-7-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pj1-x1032.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), symbol, instruction address and phys/virt address accessed. Signed-off-by: Pierrick Bouvier --- tests/plugin/mem.c | 69 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tests/plugin/mem.c b/tests/plugin/mem.c index b650dddcce1..aecbad8e68d 100644 --- a/tests/plugin/mem.c +++ b/tests/plugin/mem.c @@ -21,10 +21,15 @@ typedef struct { uint64_t io_count; } CPUCount; +typedef struct { + uint64_t vaddr; + const char *sym; +} InsnInfo; + 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 +65,44 @@ 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) +{ + InsnInfo *insn_info = udata; + unsigned size = 8 << qemu_plugin_mem_size_shift(meminfo); + const char *type = qemu_plugin_mem_is_store(meminfo) ? "store" : "load"; + qemu_plugin_mem_value value = qemu_plugin_mem_get_value(meminfo); + uint64_t hwaddr = + qemu_plugin_hwaddr_phys_addr(qemu_plugin_get_hwaddr(meminfo, vaddr)); + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, + "0x%"PRIx64",%s,0x%"PRIx64",0x%"PRIx64",%d,%s,", + insn_info->vaddr, insn_info->sym, + vaddr, hwaddr, size, type); + switch (value.type) { + case QEMU_PLUGIN_MEM_VALUE_U8: + g_string_append_printf(out, "0x%"PRIx8, value.data.u8); + break; + case QEMU_PLUGIN_MEM_VALUE_U16: + g_string_append_printf(out, "0x%"PRIx16, value.data.u16); + break; + case QEMU_PLUGIN_MEM_VALUE_U32: + g_string_append_printf(out, "0x%"PRIx32, value.data.u32); + break; + case QEMU_PLUGIN_MEM_VALUE_U64: + g_string_append_printf(out, "0x%"PRIx64, value.data.u64); + break; + case QEMU_PLUGIN_MEM_VALUE_U128: + g_string_append_printf(out, "0x%.0"PRIx64"%"PRIx64, + value.data.u128.high, value.data.u128.low); + break; + default: + g_assert_not_reached(); + } + g_string_append_printf(out, "\n"); + 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 +122,16 @@ 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) { + /* we leak this pointer, to avoid locking to keep track of it */ + InsnInfo *insn_info = g_malloc(sizeof(InsnInfo)); + const char *sym = qemu_plugin_insn_symbol(insn); + insn_info->sym = sym ? sym : ""; + insn_info->vaddr = qemu_plugin_insn_vaddr(insn); + qemu_plugin_register_vcpu_mem_cb(insn, print_access, + QEMU_PLUGIN_CB_NO_REGS, + rw, (void *) insn_info); + } } } @@ -117,6 +170,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; @@ -129,6 +188,14 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id, return -1; } + if (do_print_accesses) { + g_autoptr(GString) out = g_string_new(""); + g_string_printf(out, + "insn_vaddr,insn_symbol,mem_vaddr,mem_hwaddr," + "access_size,access_type,mem_value\n"); + qemu_plugin_outs(out->str); + } + counts = qemu_plugin_scoreboard_new(sizeof(CPUCount)); mem_count = qemu_plugin_scoreboard_u64_in_struct( counts, CPUCount, mem_count); From patchwork Tue Jul 2 01:10:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809016 Delivered-To: patch@linaro.org Received: by 2002:adf:fe0a:0:b0:362:4979:7f74 with SMTP id n10csp1830755wrr; Mon, 1 Jul 2024 18:11:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWRBgKWasFpqCLsfkitJjw+AlM24kksV0enEu6G4cneEW7IaclIlbB/wizO2M69a6dmlyy/ZIcpoLBu/IxtHjKo X-Google-Smtp-Source: AGHT+IGihJNMItNs9tqOguNgaKKd5Sq9vufcV607jG6zM/SxUF9y5YnDvoEG+2RCVc+cCVjdU7Fd X-Received: by 2002:a05:620a:1464:b0:79d:6670:e5af with SMTP id af79cd13be357-79d7ba8b9femr789755785a.50.1719882706079; Mon, 01 Jul 2024 18:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719882706; cv=none; d=google.com; s=arc-20160816; b=awDwoA5BlhTnfVsUOAnwdvz+k40T2Q66xs7f9IFv4JOMh5gyd6dgkVXEyaJbThzZql QHAJbFjUgLl3UPBJa7uxhlHdRVcDp36ESrrzkmaJHdsmlo6DIpBQMOL4PT7X6OcRthzy 9nXc1CLWrERe3b5rSaJArsbiu/C3SWfvQ0o6mDKi2kYuQC3DfWkukCgod5CP/P8/EyBu oxeJoyxwJVqiBqoYIJFzisj4X1k8Gri9pb5CJW+pGnqLa9qxIlg8mGUTnEO+7qeN2Reu qH5GTXasewoDfErzGrq4+76irsBQ9+FpwZdqHg36McMWL77s+PUUCnhie5SfDa6PdC8k meJQ== 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=niG05aeHHNe9KFZ6CFq0rHqwgfpKzMy35BwCLWmdTuk=; fh=Dj7LLbUmtY/f5f9pW73RWc2Os2c72ErjJBZ6EuA7pXE=; b=ZIwzCWJSGVNlR0OHbs2Uiafucbw4ArQRGDcSsyIEFsxxmpewWEMW3m0AshE+CmUPJT /GIf3mQYuIh85ZGADUPBDTaZ/hCB8AbfpL/FnjzoC11crNqgYJad6C8i5a4chl6YAgg1 SJCPT8AkRmDTViOmTBptJbyc2qUg68zeZA48QUq9wrBiaL1uFFHslJZv4VeudnOi/qv5 bdv6M4kBumCv4wXMu1ZWE9SGNqwRjJ4t8VOArpA5l9XF6IkyIao2IoGaV79/DwVRhaAW 6BFl5/dfNpsRQISMCAHn3OogmC1QkCyM2RaCIZ79e+dVMOfxh1jssLtgKcIV9hrP94bE MHTA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GLC0jB47; 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-6b59e5ae9a7si93490906d6.195.2024.07.01.18.11.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 01 Jul 2024 18:11:46 -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=GLC0jB47; 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 1sOS2e-0005St-Jz; Mon, 01 Jul 2024 21:10:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOS2a-0005S0-6k for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:40 -0400 Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOS2X-0002Ch-0L for qemu-devel@nongnu.org; Mon, 01 Jul 2024 21:10:39 -0400 Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-2c8e422c40cso2056688a91.2 for ; Mon, 01 Jul 2024 18:10:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719882633; x=1720487433; 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=niG05aeHHNe9KFZ6CFq0rHqwgfpKzMy35BwCLWmdTuk=; b=GLC0jB47ZWvdDlN0m0r3gkdVfxLqoVYonXWx9ynkwVPkT6KMbZ/LoqD0URRdGtwHkK aaOJMUJVV5PLt8EENmwMSeoDZh4qZ5HFzs2EcHttAzwWryEeQbhetv7gDYt776w6xYcJ kU4Hnae5P/PArfw4uUVwG/uEYPl8BUiYcZFxIDjyEb5IJzGwoLnj8pwxjvFE6wsYuYsS pa1uMJHzt56g7RFhuc4G+8oT92SkXNFUhXoQ9RPDH7ivne1oreVcqoi1TaGHJ1Kb9ulU SpDoVZk8pA2LBD9rjluRBYj362AJ/O1e8SzBCy2bknIPn1Kcx6BLUGDVPQsEKJfiVt2j OrNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719882633; x=1720487433; 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=niG05aeHHNe9KFZ6CFq0rHqwgfpKzMy35BwCLWmdTuk=; b=UDeZBZms6QRJlKA/TeKUeSC5XcINidnfNn9ufAEXBG4uD/kjPuVRyvzrXDLSLnmw/Y gaMX1DlfLLtgBb+NU1icPkO/qO5SoQ6o2KgoIoiWRLKAdXqbqSwtC5d0V+j6t0t+ZiQ8 olqeIyFMXgV0mQNUjkpuTmd6J1NZlB5kvW0KD2+Lus2zsOConfAaaQINofcpdSJKPFpG 9MrUHWrPjLdy8DANTvFl969W0PpcuRx7WD43NnEhcJfNLUbdcea+vb7iWzCs79KZ/+u/ r4N2ccRhodKQdUs5PrcB6bCFJ8sQE8Bt5QxDVKpuBr75ojBlbilr4Ro+t2wjHlP+zgs+ g1IQ== X-Gm-Message-State: AOJu0Yyw+8DyPWrfjaFpvdg5PBk/fc+8oBheBepqbLpfa13HwUqYcOkV ozpZqbQB30wBmYKpJM6cuWeKtibFAiQZJiIKjrj96np3Vemn+m65ugSwziFMA9/m7Mi03kYFBdJ W X-Received: by 2002:a17:90b:230f:b0:2bf:8824:c043 with SMTP id 98e67ed59e1d1-2c93d700070mr4251981a91.18.1719882632648; Mon, 01 Jul 2024 18:10:32 -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.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 18:10:31 -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 7/7] tests/tcg/x86_64: add test for plugin memory access Date: Mon, 1 Jul 2024 18:10:15 -0700 Message-Id: <20240702011015.325609-8-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702011015.325609-1-pierrick.bouvier@linaro.org> References: <20240702011015.325609-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102f; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pj1-x102f.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..92008e25a93 --- /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 +,store_u8,.*,8,store,0xf1 +,atomic_op_u8,.*,8,load,0x42 +,atomic_op_u8,.*,8,store,0xf1 +,load_u8,.*,8,load,0xf1 +,store_u16,.*,16,store,0xf123 +,atomic_op_u16,.*,16,load,0x42 +,atomic_op_u16,.*,16,store,0xf123 +,load_u16,.*,16,load,0xf123 +,store_u32,.*,32,store,0xff112233 +,atomic_op_u32,.*,32,load,0x42 +,atomic_op_u32,.*,32,store,0xff112233 +,load_u32,.*,32,load,0xff112233 +,store_u64,.*,64,store,0xf123456789abcdef +,atomic_op_u64,.*,64,load,0x42 +,atomic_op_u64,.*,64,store,0xf123456789abcdef +,load_u64,.*,64,load,0xf123456789abcdef +,store_u128,.*,128,store,0xf122334455667788f123456789abcdef +,load_u128,.*,128,load,0xf122334455667788f123456789abcdef +EOF +} + +expected | while read line; do + check "$plugin_out" "$line" +done