From patchwork Fri Jul 5 00:34: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: 810344 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp1388112wru; Thu, 4 Jul 2024 17:35:15 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVLZaFNYitI9dJEIe80xCDhZSGHqcbfKINqelBQNg9i7ZPoxGGStEGdcr2l9f/ItyuPre+ma3woParsrNGiIrIs X-Google-Smtp-Source: AGHT+IH03nc8m70QTtqRSoKdGsyVPZrd7n3a4LPQG6YmMMlIhX02xlh7DuFV6xQjOMEhZwEPE1PB X-Received: by 2002:ad4:5ca8:0:b0:6b5:213e:c30e with SMTP id 6a1803df08f44-6b5ed034692mr42318236d6.45.1720139715453; Thu, 04 Jul 2024 17:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720139715; cv=none; d=google.com; s=arc-20160816; b=Uyk3v2y3BhtZqpiIPXhP/c7ymXO8w7hmnDzjn6k18PXV0Oqrupj1PyeO20NsyembhF otLN8LYdKK3cL3Ev7fx1KRaXCnpmwQ6d8IgrUz9gI9mKPogqNWPhm5mtWeaJfKoczyCk +y6ZVj5pe97Lg0FtetT33UR4j2h3VpjKi/QsQqXExlFRF1CoW+S5p0eCifxz90Yahuj3 iYuf8tnWxrzsaAA1x8cmK+j4A26ekG+yNiSrXZpWdU74v1igYkSM9x8Pyb+/iY8/T9iD xDtB15iiD6A6qbtzu1/A83ARJCY7OOKAIbWr/DEqbgttZYnzak8cx3Q4HlnXwf7KIR15 zPnA== 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=h1iFjXkNAAiUT1/HXJR1NSUSkejcZSCzgqp885X9UqQ=; fh=bvAuOvh1AKvMo7NXObJGN9xe0u3hHEkijA6HXPQQm8c=; b=NNWnUCnT5ToXL1KOWaxofy8E10Yfg+mQPKsppvoyew5zd7fc/0TYkph0SDhGa5IWCD TVqrUJG1qyq+9A1IgjyuGxYLyhso7eYFIsNRCACaQobjGN5d3/u5rCFxuCOU/0abuxM3 DFA27dL6GO9mAHtZpexi1lAi/oOnqBjZfqda1QC6inYMvZURKLvbQU51I4dY8GhcYSea MiIqia72LqMu0ZErkha7BITQnxCXiI9vA1UvpzYGHNJ9EZuXWcTYjCQdcg3+CEeH36Z6 NC183EaC4UzC5t2AJ+qGptvl0FeoHn6YI4E5/kPTCqTmeMSJMkgHJxrAAiX530TDlUDB 0Eqw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eD4XBSFp; 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-6b5f20bbb4esi12994876d6.218.2024.07.04.17.35.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2024 17:35:15 -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=eD4XBSFp; 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 1sPWuW-0002qv-BF; Thu, 04 Jul 2024 20:34: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 1sPWuU-0002qW-UH for qemu-devel@nongnu.org; Thu, 04 Jul 2024 20:34:47 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sPWuT-00005m-GE for qemu-devel@nongnu.org; Thu, 04 Jul 2024 20:34:46 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1fb472eacf4so1480695ad.1 for ; Thu, 04 Jul 2024 17:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720139682; x=1720744482; 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=h1iFjXkNAAiUT1/HXJR1NSUSkejcZSCzgqp885X9UqQ=; b=eD4XBSFpAs7y3Ufc8Gm8AsEe4iKkEAv/bkM7Dm4nn2sohe65wfajiK/PUyem1okib4 1aKgjvgN2vir1mydEqCpE9RVEmMnqeMUbl7RxSfGM0A7n6YR9jvDKzPs8qhUYBioQBHc WhCXSgzSWI+MgAtH2RNTXVSg87bDTMsJsDhPmj/frnO47VrfOtfps9+nyAHmaGe9UDdx /yAHrAj/qAbzDO4zQrw3s1lBYVOZ9JYZGwwSuywxPpknIr8sLNBMzDnSNuChrBxyWX6m CO1I+iWzyP7XplcCuRgZEnsfXbpED7N/YJNHRmxdf0305+8dkVwF3RvTtigLq6fRqi6G XolA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720139682; x=1720744482; 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=h1iFjXkNAAiUT1/HXJR1NSUSkejcZSCzgqp885X9UqQ=; b=u+1pRWpwu7fRW3qfpU1CRdFA4hzz4hgTJeNah77s4YC3gQGhCU8T/h2W1tcxQhqQrK 6mnhog/19o5qvB+Qj6W/PQaounrwc3S3nPCg2Dk5WGUDrOrSiEgUPANPFylVuBlQY2FD IbEThNLkVdoYfCokYyd9aiA5+mOoD9DFoLVxn/KTC2XN3FrqaZw+ULi/63+PEfVeiba2 pG4ieIV4i1E6R2UgN8IkiIjkfX7sEzNmKlH6nZgb1f3Z9BSvfFtQzCLpkNNIkv7pYeNt b/Izk+KqCLovThHt3XTQLmZPSuw7L6tNKzf8Jfqvh2DiFnBrJdrNcdSALPKxYxdXaQbX olfg== X-Gm-Message-State: AOJu0YylzvREgywqHncK/SF8I9u6BuMPxhtS8mXaNiSVhI1kxYBxfeRq qFfsytB/fCegdkG2KTeUE2rm2GTZFHqQVQD7OT8Pwy05TLe2MjduUCfyG1G3q40rImTO9HlWOsd WKn0= X-Received: by 2002:a17:903:244a:b0:1f7:345a:e23d with SMTP id d9443c01a7336-1fb33e7ef9emr26496615ad.31.1720139682084; Thu, 04 Jul 2024 17:34:42 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fb1a075616sm39008595ad.15.2024.07.04.17.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 17:34:41 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Alexandre Iooss , Richard Henderson , Marcel Apfelbaum , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini , Yanan Wang , Mahmoud Mandour , Eduardo Habkost , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Xingtao Yao Subject: [PATCH v5 1/7] plugins: fix mem callback array size Date: Thu, 4 Jul 2024 17:34:15 -0700 Message-Id: <20240705003421.750895-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240705003421.750895-1-pierrick.bouvier@linaro.org> References: <20240705003421.750895-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pl1-x62e.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. Reviewed-by: Xingtao Yao Reviewed-by: Richard Henderson 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,