From nobody Mon Feb 9 04:14:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1690882892; cv=none; d=zohomail.com; s=zohoarc; b=iONCvSuMY+/JiYB2X4tWCwjD7nARpPZOwXiawUU33YSFzSNydKfCcPSl13plZIG6dzCQqr2rWoWcRCysSxLhlQGWBH60wGnUGXgpXS3meeEwzYBgz138FHYyjXHdRl3bEXJkywhOJATFonUN8JDFnASiBE8PaQyDnbTuWBnNJJ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1690882892; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=oBW4VAJRIJGrMVgsfzw2Q8HSW3WyK2h/s2OwQHWlyOo=; b=XMgLVn6SNjCeqXeobKr9vQSYJ2T9W5wOZMpKSNEo/PjgKTHFiyKirWMQ6J3JIozN3/2QgEYFUS+V+TYxiPLGDXDAgARGjpVnl1NFUZrcrGlLEjJruH7tWzFfY38xuo3Lwi61zuxd20BRPS1EVnAgAwYqyh2nTB0EAAoIKX+ISIY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1690882892687430.5122534252753; Tue, 1 Aug 2023 02:41:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qQlsB-0003A6-7B; Tue, 01 Aug 2023 05:40:59 -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 1qQls8-000390-KZ for qemu-devel@nongnu.org; Tue, 01 Aug 2023 05:40:56 -0400 Received: from esa3.hc3370-68.iphmx.com ([216.71.145.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qQls5-0005BW-T9 for qemu-devel@nongnu.org; Tue, 01 Aug 2023 05:40:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1690882853; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RMnHk4oHNHgKLRqUgkxXuacyu+rVLju3q0tzvXy0Muc=; b=hsmKLbIOKMyDyT5taWAldeOcOpQXvufpg0Qd4jmzeRiDhcsQHXV2CBCW lIS9goneIXhgrSYde2Y60xNfPWrGk4BG+gYU/Bmk2ff/0kEKc1he9JJ51 pN/QOLVDNI0vcEtuSOCNH8asDV++PHBoVHI7q9rxEt1cmw3U74LXQh/w2 g=; Authentication-Results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 4.0 X-MesageID: 118110419 X-Ironport-Server: esa3.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.123 X-Policy: $RELAYED IronPort-Data: A9a23:6SG836+6T+O9vLjVNAFhDrUD9H6TJUtcMsCJ2f8bNWPcYEJGY0x3n WAWXmHVPvyLa2OmeN4na9+x8hwD65XWnd9mQFdp/Ck8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks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os-CUID: 9a23:bOs7p2H0N0dRsVSKqmJs8E0TCscgNUTi60vME2GRWD5uRIa8HAo= X-Talos-MUID: 9a23:9/NO9QmOLsaXnjXzDpN+dnpTKeMw6bSKS3k8vpAvt/G6NTJCNweC2WE= X-IronPort-AV: E=Sophos;i="6.01,246,1684814400"; d="scan'208";a="118110419" To: CC: Peter Maydell , Anthony PERARD Subject: [PULL 4/5] xen: Don't pass MemoryListener around by value Date: Tue, 1 Aug 2023 10:40:37 +0100 Message-ID: <20230801094038.11026-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230801094038.11026-1-anthony.perard@citrix.com> References: <20230801094038.11026-1-anthony.perard@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.71.145.155; envelope-from=prvs=570bccec8=anthony.perard@citrix.com; helo=esa3.hc3370-68.iphmx.com X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: , Reply-to: Anthony PERARD From: Anthony PERARD via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1690882894777100001 From: Peter Maydell Coverity points out (CID 1513106, 1513107) that MemoryListener is a 192 byte struct which we are passing around by value. Switch to passing a const pointer into xen_register_ioreq() and then to xen_do_ioreq_register(). We can also make the file-scope MemoryListener variables const, since nothing changes them. Signed-off-by: Peter Maydell Acked-by: Anthony PERARD Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20230718101057.1110979-1-peter.maydell@linaro.org> Signed-off-by: Anthony PERARD --- hw/arm/xen_arm.c | 4 ++-- hw/i386/xen/xen-hvm.c | 4 ++-- hw/xen/xen-hvm-common.c | 8 ++++---- include/hw/xen/xen-hvm-common.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hw/arm/xen_arm.c b/hw/arm/xen_arm.c index 044093fec7..1d3e6d481a 100644 --- a/hw/arm/xen_arm.c +++ b/hw/arm/xen_arm.c @@ -37,7 +37,7 @@ #define TYPE_XEN_ARM MACHINE_TYPE_NAME("xenpvh") OBJECT_DECLARE_SIMPLE_TYPE(XenArmState, XEN_ARM) =20 -static MemoryListener xen_memory_listener =3D { +static const MemoryListener xen_memory_listener =3D { .region_add =3D xen_region_add, .region_del =3D xen_region_del, .log_start =3D NULL, @@ -108,7 +108,7 @@ static void xen_arm_init(MachineState *machine) =20 xam->state =3D g_new0(XenIOState, 1); =20 - xen_register_ioreq(xam->state, machine->smp.cpus, xen_memory_listener); + xen_register_ioreq(xam->state, machine->smp.cpus, &xen_memory_listener= ); =20 #ifdef CONFIG_TPM if (xam->cfg.tpm_base_addr) { diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 3da5a2b23f..f42621e674 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -458,7 +458,7 @@ static void xen_log_global_stop(MemoryListener *listene= r) xen_in_migration =3D false; } =20 -static MemoryListener xen_memory_listener =3D { +static const MemoryListener xen_memory_listener =3D { .name =3D "xen-memory", .region_add =3D xen_region_add, .region_del =3D xen_region_del, @@ -582,7 +582,7 @@ void xen_hvm_init_pc(PCMachineState *pcms, MemoryRegion= **ram_memory) =20 state =3D g_new0(XenIOState, 1); =20 - xen_register_ioreq(state, max_cpus, xen_memory_listener); + xen_register_ioreq(state, max_cpus, &xen_memory_listener); =20 QLIST_INIT(&xen_physmap); xen_read_physmap(state); diff --git a/hw/xen/xen-hvm-common.c b/hw/xen/xen-hvm-common.c index 886c3ee944..565dc39c8f 100644 --- a/hw/xen/xen-hvm-common.c +++ b/hw/xen/xen-hvm-common.c @@ -765,8 +765,8 @@ void xen_shutdown_fatal_error(const char *fmt, ...) } =20 static void xen_do_ioreq_register(XenIOState *state, - unsigned int max_cpus, - MemoryListener xen_memory_liste= ner) + unsigned int max_cpus, + const MemoryListener *xen_memory_listene= r) { int i, rc; =20 @@ -824,7 +824,7 @@ static void xen_do_ioreq_register(XenIOState *state, =20 qemu_add_vm_change_state_handler(xen_hvm_change_state_handler, state); =20 - state->memory_listener =3D xen_memory_listener; + state->memory_listener =3D *xen_memory_listener; memory_listener_register(&state->memory_listener, &address_space_memor= y); =20 state->io_listener =3D xen_io_listener; @@ -842,7 +842,7 @@ static void xen_do_ioreq_register(XenIOState *state, } =20 void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, - MemoryListener xen_memory_listener) + const MemoryListener *xen_memory_listener) { int rc; =20 diff --git a/include/hw/xen/xen-hvm-common.h b/include/hw/xen/xen-hvm-commo= n.h index f9559e2885..4e9904f1a6 100644 --- a/include/hw/xen/xen-hvm-common.h +++ b/include/hw/xen/xen-hvm-common.h @@ -93,7 +93,7 @@ void xen_device_unrealize(DeviceListener *listener, Devic= eState *dev); =20 void xen_hvm_change_state_handler(void *opaque, bool running, RunState rst= ate); void xen_register_ioreq(XenIOState *state, unsigned int max_cpus, - MemoryListener xen_memory_listener); + const MemoryListener *xen_memory_listener); =20 void cpu_ioreq_pio(ioreq_t *req); #endif /* HW_XEN_HVM_COMMON_H */ --=20 Anthony PERARD