From patchwork Wed Jun 26 23:37:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 807521 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp545835wrn; Wed, 26 Jun 2024 16:38:51 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKTipoqs+kW9NOBLP1MmXL/RyW91dAIj6MJ1RN6fl8/WLVKDbuM5hXaw2gEqvYDhZ6k39Ac9i9x0nx8s3zn+uN X-Google-Smtp-Source: AGHT+IEubgBYiGTYaHQ7PNQP/bOeomL+tPlXUuE48aLvlrb2bIn20VTZeC5vv3/HCmuSCBWe3uak X-Received: by 2002:a25:e905:0:b0:e03:435d:befe with SMTP id 3f1490d57ef6-e03454e4e29mr407765276.35.1719445130912; Wed, 26 Jun 2024 16:38:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719445130; cv=none; d=google.com; s=arc-20160816; b=sQLncNecWS06T+P9yFniXsFe9/XTObe5uTWlHmBItdZBz0U9cxbOoGaURZhNOPLiyx h7xd1EHjwqvTHf+ZzchSR+2wUoUOqcQXcDTg0F/r8KNgcTYa5Z3LK7Dr8ErhkZQQIAhl IkNQDqtG18mPRnP8d5c03bXD31UgBNNOMnJeCEKlScdP6pAuvtKI9u8k4Pkql66+C/8J ndXQMyYttTygbQ2HS810XCMbrwfpc5ii6nPgxaVqfzN6geO1kRsZ6ShABNOWwBUZuQyu iQnpBlHTaVFjTeotGpNpatT6aW5wE04UtTHteeZyqduIEe5euTPDHgZCJiMJt0byDa3r YzDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; fh=t+og6vq6PhvWUJH0MmfTYZOEuVFiDGq3dRDviuzY8a8=; b=JtAyijN0mUr8athzEDIyRZISJGulhVgfTV8H6tE5VjR9tClGAHAmg8Ln2WWqeo+PjE 4NRt4xVE0cFvLknpP724ThpEFHZA27/l4zG/M53VeLs9OCD6bvEyXfiawBR14C4sepBt lsDc4dcvlqjWRNkTW6HOOWx0siIfXz5iC/Cq0dTzEVTUsOd9oSyEL92W6PRV3EetLWyr D5xLyoYnI4hPotXNe2ylB2MrCFJ/2XpWmEpHuFtgJ5vdfbxEkfaICKPiZ50xXanvuYaa zUNthOdv9fFGt9sR9XWyOgaR8WAT/Wt2RISL0+bt81cpZjqEyWvfMGBlnDD8KdTnBvOV 6cKQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoGaXvQl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44641efdde9si1161491cf.161.2024.06.26.16.38.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Jun 2024 16:38:50 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BoGaXvQl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMcDO-0007Rp-JX; Wed, 26 Jun 2024 19:38:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sMcDH-0007RU-Di for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:07 -0400 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMcDF-0007Fa-PY for qemu-devel@nongnu.org; Wed, 26 Jun 2024 19:38:07 -0400 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-7180308e90bso3826861a12.1 for ; Wed, 26 Jun 2024 16:38:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719445082; x=1720049882; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=BoGaXvQl02XNNJfhRTX/38eZY8vzQH+Vnlj+PUmWLheho1Xeou5fCsE92k8ulGY3IN QCYHJ9gxjZR/T7Vd4Fxek+oRwuM8EcUqqExIhtG4pROlpWc2/KOOlze4EDQuswyfavKh nVjPyoOicUPUkifIj5IvaN5XdKCj6pJ57zcnkI1omG9cd1LCCF8DLsixN6xYwa/gzjjY +rjxlByMow/+fqCdgkZo0qwSwssrua8es6brHtlsAdsCpLOvLfavfhgUU3+wKiWkzh2k vaQ8A/CgFFkvdF0k1ZcgnroGr8B1Kmk78x6jlpscMMZk+zDF9k+uQkuFZjUXNsq6wSC8 fzVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719445082; x=1720049882; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zs33WUET3TwShkJZi0v92Kdx2DNNU6JjJOAyINKhk/A=; b=jjD6I+PfxSgoOhOjohxMxSlKHzj2r3Pe53xjBalStw3O3i+VFKD7+S3Y+Vl0MUZ7qo 1r1c5Sr6dR/QFwmHl6ASeD4eqDPs74rFRLNvJq8HbkIgmr7sIAMlvIyuZG0tKckBxKmv 0oez8+ai05zBSok57xgVSE71YEnALJjTK/bFyRGae00bKhRy8n8BqeReYBgfAZacXK4a H1cen3UvfHsgtOt+jW1WIjbP1M8XZrKlHuaUKpqJSBEfuENMZgpor9l+2skl+14ISLty QJ5UynSlddgip/DYnJlCYAtH3Y+y9h18HM7bepAvcuMOuiYz3mIm5KUOmW4zR7pQrYja YLog== X-Gm-Message-State: AOJu0Yx8VOFM2ab04WjEWYeXx7/WCesf+P5lwDZe8BMFJ0WaZnCLlZ1B adjrQvU5aRj5wQSdczcJZezRHMKhRRM9rqQQpbDmr9aVeREXQ3zvhif3d6oKbM5duwntVSV6jnJ 0OwI= X-Received: by 2002:a05:6a20:7487:b0:1b7:4adb:1dc2 with SMTP id adf61e73a8af0-1bcf7eaf9acmr12595873637.21.1719445082474; Wed, 26 Jun 2024 16:38:02 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1faac8df624sm563055ad.29.2024.06.26.16.38.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 16:38:02 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Pierrick Bouvier , Mahmoud Mandour , Paolo Bonzini , Eduardo Habkost , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= Subject: [PATCH v2 1/7] plugins: fix mem callback array size Date: Wed, 26 Jun 2024 16:37:51 -0700 Message-Id: <20240626233757.375083-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240626233757.375083-1-pierrick.bouvier@linaro.org> References: <20240626233757.375083-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org data was correctly copied, but size of array was not set (g_array_sized_new only reserves memory, but does not set size). As a result, callbacks were not called for code path relying on plugin_register_vcpu_mem_cb(). Found when trying to trigger mem access callbacks for atomic instructions. Signed-off-by: Pierrick Bouvier --- accel/tcg/plugin-gen.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c index b6bae32b997..ec89a085b43 100644 --- a/accel/tcg/plugin-gen.c +++ b/accel/tcg/plugin-gen.c @@ -85,8 +85,7 @@ static void gen_enable_mem_helper(struct qemu_plugin_tb *ptb, len = insn->mem_cbs->len; arr = g_array_sized_new(false, false, sizeof(struct qemu_plugin_dyn_cb), len); - memcpy(arr->data, insn->mem_cbs->data, - len * sizeof(struct qemu_plugin_dyn_cb)); + g_array_append_vals(arr, insn->mem_cbs->data, len); qemu_plugin_add_dyn_cb_arr(arr); tcg_gen_st_ptr(tcg_constant_ptr((intptr_t)arr), tcg_env,