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,