From patchwork Tue Jul 2 18:44:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierrick Bouvier X-Patchwork-Id: 809138 Delivered-To: patch@linaro.org Received: by 2002:adf:a199:0:b0:367:895a:4699 with SMTP id u25csp353691wru; Tue, 2 Jul 2024 11:47:03 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXxv28qv4z5I53gtn1WtkVhBsJQLoZoMI3HQh10vHv8kq/XaW+Zy15F9lhKdCVor1K+gOUv2OYXP3rKw6frox3 X-Google-Smtp-Source: AGHT+IGi3z39S3mdqaoYn22wceJDm6auEzg1F5VaNI9RBZhwdKbDnXUvmMYfGgPWAoQgBkEzqu1o X-Received: by 2002:a05:6122:270b:b0:4ed:145:3489 with SMTP id 71dfb90a1353d-4f2a56f27f8mr11363945e0c.13.1719946022937; Tue, 02 Jul 2024 11:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719946022; cv=none; d=google.com; s=arc-20160816; b=uU/sRT9h9DD39I/wrx+VW/4lTKl1mesQYZFd9XaqmXdtpT1f6DGiNYeglNEPJpj2bw 744FI20rbKwfGT+MECVveofV5vCZoxu1r2iqYz7CfC95NzgMEn0wmNN5NT2J00V/xnRC 6+EaaDn8o4ZEKzB/Ms4yBpGCjERqMbmY4TMNzixocpLJ2dHFLKQYchjI0F/CnubvfLNh KxrWmyMDErF3adzeoYu5MRlWs7nQyb/+3poHy3jjt2kKle30FUo0lpoS7fm4r48e29x4 sNXgL0gLNfSY3TQ6figCRn7dYDLGz5I9qS/ckN7h9PwASXEBN6A9zIp30woOixZml/bN 8MTA== 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=g07vBTJgnqpvris7VKdjb0Fa8+eQaw4omO7dF9AEhq4=; fh=egaTauEAQXabJZc38H951bHufgGiOKXRhDZnvfOlRE8=; b=FC43lgmg7fYYChS5Ra8WLXYOOCcxqLUq+edS5SQk99v9IWJer1qGnca1hoRH0JRG5b g4fj7ts4Ee/e+9qXEphzGuv40EfnIf8sDsbV9dBXCjIlUi1S9Xaa9mQrE6IGGz3nhj8k qZ7ZiEPpUDmqluctj/2gY53ZcsrQohefacCZ9oPQWQ/sDhEGptSEGNtOKM5OTuGCR43V tTNpDnrrsfz9o8D+BlfD0+iy3pSQRdqs6ZNhofmd8Xsup4xLqbnOw4qORXknKXfLr8GR uiS10VE1lo5LjnnMIM9tulde90aXJZQBN+jFAvNn7MIaeDpGccZo7gbW0lwQIXuLEQCT yjCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=C532kVn2; 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-79d78bdb6basi819877885a.693.2024.07.02.11.47.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Jul 2024 11:47:02 -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=C532kVn2; 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 1sOiV6-0005Md-KR; Tue, 02 Jul 2024 14:45:12 -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 1sOiV2-0005KC-DD for qemu-devel@nongnu.org; Tue, 02 Jul 2024 14:45:08 -0400 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOiV0-0008He-S4 for qemu-devel@nongnu.org; Tue, 02 Jul 2024 14:45:08 -0400 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7066cba4ebbso3189802b3a.3 for ; Tue, 02 Jul 2024 11:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719945903; x=1720550703; 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=g07vBTJgnqpvris7VKdjb0Fa8+eQaw4omO7dF9AEhq4=; b=C532kVn2WGpAESIAhh6ooQBYpH5w76hNGOO9CRr2DAg0Op4DB5TpHSyiln41M7gZns trgYfEHWCNQmrOoUen88l6tzZufM815tdNl7ulL+RLHjSebllM+3cUoJ8JvEjA5Sv4dz QMIoBmhXf63GKrm8GYXxXaf2BaVpGWIew4+oIKiCJzmTmuQ89B6A+1gNbNSIK2cTK9dK jOL0lgqM5g8bPnkgYwC6jrS2NXbR/2EX1FVnG1hVcBQ+x3d8NjtlUBfI6j/DOaEMDLhW J/6EXWlKkFEeICi3kRfSKqIjwowLqLTI1eY0h+ElJU3H7kLuBQ/1algVRI81AOovPuGb tKgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719945903; x=1720550703; 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=g07vBTJgnqpvris7VKdjb0Fa8+eQaw4omO7dF9AEhq4=; b=GRSullZcAonukEyAex5INzRyroSiQY5ZHXtEgbk8wdkv4DO9ZUAEVKgNvkGdSDRPwX 9cbFWOZVxlaVP+ByikGJ2oXg1+LHx159e7Y6TYN4plIhupaJMpq1dfiVo3CBDMxWTaS0 lI5oppynRY6zjFXiUm9/rLFSqofUG6tODR0D3rDDnIfrGcoigSoony+NZnu7pVORf0oU ELHpq0+IKNfDMMX5HSB3BjeG4D/MBOj+WM8CeULiNsoyI2VfYyvfROh2YQkd0bE0OrPc BodLAwVzuvkLX4W8CtTlXSvftNcHgvg6RSuWKTlpuwpIO1mt2Itp4KUwCAO91OMifTkF JMzQ== X-Gm-Message-State: AOJu0YyOCXlW5b5xGD5rMd1Y3sDr78g8iBJ35eVZbuaQ9b+5HZLQtFS9 2gcqJKhPnnM4N1QY5BiKEKRP59TCZVxo5cQnbWfpAnOFGK6xi/ohlq14jGTQ8U2nKvd9Lfs9GKs a X-Received: by 2002:a05:6a21:39b:b0:1bd:2207:3f3f with SMTP id adf61e73a8af0-1bef6245529mr8280911637.39.1719945902829; Tue, 02 Jul 2024 11:45:02 -0700 (PDT) Received: from linaro.vn.shawcable.net ([2604:3d08:9384:1d00::2193]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c91d3e8196sm9257394a91.49.2024.07.02.11.45.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jul 2024 11:45:02 -0700 (PDT) From: Pierrick Bouvier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , Mahmoud Mandour , Pierrick Bouvier , Alexandre Iooss , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Xingtao Yao Subject: [PATCH v4 1/7] plugins: fix mem callback array size Date: Tue, 2 Jul 2024 11:44:42 -0700 Message-Id: <20240702184448.551705-2-pierrick.bouvier@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240702184448.551705-1-pierrick.bouvier@linaro.org> References: <20240702184448.551705-1-pierrick.bouvier@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::435; envelope-from=pierrick.bouvier@linaro.org; helo=mail-pf1-x435.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 Signed-off-by: Pierrick Bouvier Reviewed-by: Richard Henderson --- 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,