From patchwork Thu Jul 18 09:45:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 813155 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp208931wro; Thu, 18 Jul 2024 02:46:58 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX/y7F20Bs1Pw1AMB6540hs+DIAAD9DptahVKr+RrEni/M6LkPk/fbSD/taynwVL8SYPpKQYMMnF63KXvgYnKiM X-Google-Smtp-Source: AGHT+IHau0lOLpMemIt+Z+WncKnq9naYFbdybvnTMCcCay/u3vDCQ7UiXGy77ilSciiC1yaUtjEu X-Received: by 2002:a05:620a:2556:b0:79f:1915:5b3a with SMTP id af79cd13be357-7a1874a2555mr513920485a.38.1721296017944; Thu, 18 Jul 2024 02:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721296017; cv=none; d=google.com; s=arc-20160816; b=Ec0bKeWqLTaySTjJnLzC/EhAAKR/etiQxsxyeVQyF4XSlw+KgyPDxlMzE9kPwxmjOC y2zuoaWIM8iTfVcdHkPuIdq5pW/I71bEs8L98Duu8839dR6Xlq9G4oL3Kp2KuckSmfKK 76kwP1n8fwhvT65Pd6aCX0iAEDgfTRAk+DE5ulgk3C3GsHnKsk2Ly9cTeiqICWl5WetO d71BB6PEHxXIh1WbrZWtwY4O2IHkaslpMAtELwA928YSyziR7dTcMHUB0SXBaHDI46oA /tJ4Ht+Z4lOGvHXqglNvXzaNwW3d33cG+SrsEPIo7V6pH9oolLIe6xi22a7wVWhtZaU/ DM/w== 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=cfJ7q+u8E5nRKTMFGfs4eIENy7w0T/uQLo6/QnXe36U=; fh=Z5LQW3mKTq+A7HY/6JgPpVE63lTkQ66osdawJ+R83Ks=; b=Izyt0EJBq/nTthCo/S6EzTg2cKUwo2NKLg9BeyuR7bqdYpYsvcw26Mw5ot2GU6+1SZ 536pQXKiuDSHUSTsow/fGIk+Uvz3N31anDnFPpefp09tcmvmqSz9eDl/dxURu7dwi39r RceNUrmUIlAbpn/ohosSZjBPj8vZ0/ZRwnMP5HaudghtMV509tXolXm8ZRF3xIuNAo56 4K7BKqKeqBNsePnG5qrKNMsEktHi2OqLvwWA6I7uuB/4avh5vw0fOUbWRJeLSxF4O+lr j3faVy9hq2UAtRDVBI/QHAQVhGO9MZOBeVZPeygYDQeu+zSU28fvAy1kRhZ1zcSrAamO dL6w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="W/vqKplL"; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id af79cd13be357-7a1939b02e7si17028485a.560.2024.07.18.02.46.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jul 2024 02:46:57 -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="W/vqKplL"; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sUNhm-0003s3-6n; Thu, 18 Jul 2024 05:45:42 -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 1sUNhg-0003Td-F7 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 05:45:36 -0400 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sUNhb-0007cp-75 for qemu-devel@nongnu.org; Thu, 18 Jul 2024 05:45:35 -0400 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-5a1337cfbb5so734357a12.3 for ; Thu, 18 Jul 2024 02:45:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721295930; x=1721900730; 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=cfJ7q+u8E5nRKTMFGfs4eIENy7w0T/uQLo6/QnXe36U=; b=W/vqKplLhNsBKwOOa3PbyDmRJaAdSzEezRplQvU2CEc+29BBeT2Kp0GLSllcO19uLn 17UjZeloh61oPoCIbNX65KnaQpwcZZLYGO1gmj3M22ncfQKXSW+bPalIios4ciSUM1LC 6/DehDqNvnn8w4Fa4lAs8EzPxjXRCeKJkXjA1VCH2B0CXCUjxAyrMEI7KlgegxdZN9t9 iixuFOAPez7Wb9i6Fv/9VtUDeucN3DCF6WTD5usyVODB2y5pQXtyB+DkDA+jrGttUXvl KkcSzfRmnrVldonpZpfxQKRTHIqfa/SE9Q5+g1Lk+PsMPpBFyi9oxO1GekV5klnZwJU/ iLvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721295930; x=1721900730; 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=cfJ7q+u8E5nRKTMFGfs4eIENy7w0T/uQLo6/QnXe36U=; b=P7K3bxDqq266tWJnmaysfBzwdKhspjErdpCkRtR/3hk4K9YRUEAuQVk1AJDHyJwbLM yR7qzjlLXUD4CVsoPObvdxMk/ifIcVOXkxo5CEedDMNs4Oo07nY+7Lf+oSnA/G1hZKDg 7BDF71QAssC4XRTRsQ0bIAOYxJ/O/ZZkTMAMlSsNVaHQzR6Et+UYw+kEkGf1IOXsyvTA Us0xHSNYSoTzd3MwBGZB06VMODX9bhkVSba6QuLbEKqtg9yniNFllNbXhe/6YAXZ5QVF YHv8SaVGgzwBlr5GxRNrM3Hf01FGQDQpZToYtf514r1dL6rkQWncr7auBJHmfpypCYYI qN3g== X-Gm-Message-State: AOJu0YwPI1uFksX5pIV31nbv7pIyEArk6Ew5hE/lR0l/bq0Zo0w/hBX7 enBNO6A0x9PWh0UR3TgnxfM0DJal04V7b8LtnREJOIW42xEem81zTIKZp0VRjVM= X-Received: by 2002:a17:906:e0ce:b0:a6f:dc17:500a with SMTP id a640c23a62f3a-a7a0114c017mr296526366b.23.1721295929309; Thu, 18 Jul 2024 02:45:29 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a79bc5a39fasm550343266b.10.2024.07.18.02.45.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Jul 2024 02:45:28 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 7AEE15FA15; Thu, 18 Jul 2024 10:45:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Jiaxun Yang , Aurelien Jarno , Thomas Huth , Daniel Henrique Barboza , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , qemu-arm@nongnu.org, Bin Meng , qemu-riscv@nongnu.org, Aleksandar Rikalo , Pierrick Bouvier , Liu Zhiwei , Peter Maydell , Wainer dos Santos Moschetta , Palmer Dabbelt , Beraldo Leal , Li-Wen Hsu , Ed Maste , Richard Henderson , Weiwei Li , Alistair Francis , Max Filippov , Mahmoud Mandour , Paolo Bonzini , Laurent Vivier , Xingtao Yao Subject: [PATCH 05/15] plugins: fix mem callback array size Date: Thu, 18 Jul 2024 10:45:13 +0100 Message-Id: <20240718094523.1198645-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240718094523.1198645-1-alex.bennee@linaro.org> References: <20240718094523.1198645-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::529; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x529.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 From: Pierrick Bouvier 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 Message-Id: <20240706191335.878142-2-pierrick.bouvier@linaro.org> --- 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 b6bae32b99..ec89a085b4 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,