From patchwork Mon Jul 22 11:04:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 813707 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp1811259wro; Mon, 22 Jul 2024 04:05:43 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV/OUUWdiJYcv329gINfDxcT98vFgTZB4TSpm6K58C48sFIdI56AJS01RheAn0lrXfOMSU6HdFj5uICL5oB/XoP X-Google-Smtp-Source: AGHT+IEYzCGmvgp0xBnD2AqjuJ3G36r5mcYtxwLldYCV661USZeVfWCVGp90vEezr+fJH7WJFHLC X-Received: by 2002:a05:622a:11d5:b0:43a:f1f0:12f with SMTP id d75a77b69052e-44fa5387489mr105593751cf.59.1721646342984; Mon, 22 Jul 2024 04:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721646342; cv=none; d=google.com; s=arc-20160816; b=JP3ur6oCthF+OvBGFW6RSTSBA9tyyFXC1bcpt+Pzvl4STPcBMPreocCwdoCJ1vgj6P Kz6AvcLT2Muoq8I1PC7SJ04Z6eh7jVN48h3fZrEGw4yelErTNvVXJYkU7sOSwoBpmALf 7WxAzV6o0Vo74MJTl75EMxG4/4weJsiF6tSIAGVoKYHtYwJma0Sxt/pG01PNVeUNxOc+ p9shpZaY3EQzWrrH9dHZ9fh88cORfR21pMO0N+8uxFuE9O6/qyCPDZHRKn9CbJ2YWDDm fk/CMECGKOrkbpvn7XI+AIq5FnbhF04Ra+t7j2/xdFEwf7g2oh9uWcA3WBZjphjKHqHc TlZg== 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=CUepoQkJbTEdFdSk4GA6KAzs4URRnm4V9SeWpypNLMA=; fh=eahvdF4yo2f0nbZI9+BnUcTmO+7Zfxk/JvjCmxe9NWc=; b=b83KOod+0gLBtB2V9RTnPYtablCeGtwAs7cJiubZHrc0vkgbDLgk+ukQ0k+vMeSLBA f4GvDy/O9IxrNRgSGSFKZzXSReKTX+x0KtWCxnK+c7eOahU0erIo3E17gHfmOzVNXGjx EYOKAn7z31ChrcJ9D2q2CpscrksRQp02iOMNIZgiZ81Ap2hocfcklJR2JLlpqUnfjIuG dRn6MssOI48fqRuWKrmqUSU3q4dRT5vd+lqMhoBRRGlivw6GHadRqHUozDyZZB0KEUI0 hXrhMrRcdojdqCql3vFVVG/1GZXEzznNA/b7O/yYjSm8/mNPROpG1Z9Ba4KlhcujTB1N lXOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yobLrQ96; 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 d75a77b69052e-44f9cf0cfdesi77194811cf.697.2024.07.22.04.05.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 22 Jul 2024 04:05:42 -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=yobLrQ96; 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 1sVqqB-0005qW-1t; Mon, 22 Jul 2024 07:04:27 -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 1sVqq9-0005iA-2V for qemu-devel@nongnu.org; Mon, 22 Jul 2024 07:04:25 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sVqq7-0002S0-Ch for qemu-devel@nongnu.org; Mon, 22 Jul 2024 07:04:24 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5a10bb7b237so3415590a12.0 for ; Mon, 22 Jul 2024 04:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721646261; x=1722251061; 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=CUepoQkJbTEdFdSk4GA6KAzs4URRnm4V9SeWpypNLMA=; b=yobLrQ96S33VR/w0VHi5hvI56kMEX/b2+bE22ik6Hj9w2A8YEFntd3xXCBIaGfW3j0 8P45FtH68Xx4IXENO3X8DqZfjWUZ9vj5o7VvGI8soBCUGa54odPihJSesbtZa3Kx6rky QpfYnKzabwo339RQhNchZlYsjZxPbvkpt6UOlh0PIoAZCiIyj7GQ9tOpcVlRId6kEIkM AVpZNqCysnGJAhkZFCQZ5PPM20ZOvCILGq/JbUrWMPf9iddwW9HfVkJWe0kAisSXMEm8 J4ubUnmHYp6VEbaydGz7L1/IEu3n+caInBHm2vMWMsHw2in3H2jHgyA1egOmLDV+lo5F FMSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721646261; x=1722251061; 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=CUepoQkJbTEdFdSk4GA6KAzs4URRnm4V9SeWpypNLMA=; b=XSseW87WffNvC5W659T80jQ3DUnMDIloC4442sELOYX3S5M6PbbLrI0J49zYl1OcG5 IKjLXk+KRcXu1giDlq9v1XHTQDSiIWfgnyOeksLk7lTtp7CICLbFqzDvhP3vnHPWWwCX Sv7rkn6ADRNK8O4Etsp0aaXbSKEqDlGEMZ2ZTdMy0NwgOnb4jW04JXY+a55ITv5vQkqO P/xmo9ohvYe/INM00iPWies1tc3Q1wl3W01WpZes7IM1VmOrHeVt8IiZEZ7Ngaxx+ZJM ChyhMQGEz5GPgqXDT5DJIlqs7x0z8x95gfnW0y1pP44r9tx/qFyuspxEPz3PvsOEBK0T 4TeA== X-Gm-Message-State: AOJu0YyvmsUstSGCFO+KRuCE5JapZR8FmFB5TlX3qlOMjR2aJKJZgoZZ KFB2w6bRXe4ASKitYo56PyqmD4xyLYSYbUST0kSvKbGfVqUqGcAubYFblhQJBxI= X-Received: by 2002:a17:906:6a06:b0:a77:b664:c078 with SMTP id a640c23a62f3a-a7a4c010bcemr469474066b.27.1721646260391; Mon, 22 Jul 2024 04:04:20 -0700 (PDT) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7a3c94a9e0sm409565266b.188.2024.07.22.04.04.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 04:04:17 -0700 (PDT) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 15DD95F9F4; Mon, 22 Jul 2024 12:04:14 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , Xingtao Yao , Richard Henderson , =?utf-8?q?Alex_Benn=C3=A9?= =?utf-8?q?e?= , Paolo Bonzini Subject: [PULL 05/16] plugins: fix mem callback array size Date: Mon, 22 Jul 2024 12:04:02 +0100 Message-Id: <20240722110413.118418-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240722110413.118418-1-alex.bennee@linaro.org> References: <20240722110413.118418-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x52e.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 Reviewed-by: Alex Bennée Signed-off-by: Alex Bennée Message-Id: <20240706191335.878142-2-pierrick.bouvier@linaro.org> Message-Id: <20240718094523.1198645-6-alex.bennee@linaro.org> 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,