From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568608; cv=none; d=zohomail.com; s=zohoarc; b=Cm4PKnRX2F85xvhs1pAsDqA5+yeZbhZc6m/fuPGr5UEYxuwg+a+Gr1vLkPnHpC8tvp09qfW7yz1kNhMClmGxWH3As841T0lEVFCXpebFwiSH9jIWn+BPgxjq0mVIrvHEicMsnEMKzND61ClgXrrhx3TSYXLiCZi3pDi+2lpUX8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568608; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=fgb34YDhjF2+15X33fVIivrp1la32FWAki6vC7PTy2A=; b=Qd4RQeC4LnkucjQ3BDc3wfqA+MeBCDLGZj4WBLUuAYT8OSbNZC0UhO9vZ+BzTLETKFBjMKEWAegQeZWOfYypoDBUOFg09H+dUA8n5pE6ayWhHpML/1CCt2wG1RmLfzVBq1BlHxsNMEKAnFLSVU2y5Vg5Fw0RRjpxwfo/r6bNzdM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568608791205.74111826894375; Thu, 7 Aug 2025 05:10:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzQs-0007XM-Ky; Thu, 07 Aug 2025 08:09:18 -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 1ujzQm-0007RM-Js; Thu, 07 Aug 2025 08:09:12 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQi-000545-PT; Thu, 07 Aug 2025 08:09:11 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:03 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:01 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568549; x=1786104549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MnawxUnvOKw6/CZfAUA3YSLAXwZrIDsAEHY4hJuFuGw=; b=jTo3+0XYMh7bCA06sIAQlY5r9RhD7ExsvghWoAkDDnMgdjFVEkzdBrjo Xbc7hizJAlYJtGzkvmpZ6DOHMJmgH4qKhni4y5S6Pg0Eeor3boWgJBl1h p2Cg4YSfFHo3eSHXGZAtzx7KJsjiXL2UDCXGYeZY2SxeQ35vPyFaJYAHP zpkW4rQvqWqlw3HTUO75ah0YgMNgTjJ1yaW6I3z2+HY+YiQ4XlMDQ2UN0 JrJMDL/DpsYEr7OKzGs2bYjD1HotZy/tyJ/Ba2mgDJ4hBl1tubmZbghKH +GzEUb7YZTVBaeFu2r2Vacd8HXCOdUvpjdK2pNe4o7IyVIK6hBAflHXTz Q==; X-CSE-ConnectionGUID: utDGbuXUTgm90/YUZFgflA== X-CSE-MsgGUID: +FSYt2XtTzqBzX8S3gF0bQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036698" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036698" X-CSE-ConnectionGUID: 7lU+aHq6QSaxtbpbRmePhQ== X-CSE-MsgGUID: oqnQXITGS26YA4vElYBHBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701033" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 01/26] rust/hpet: Fix the error caused by vm-memory Date: Thu, 7 Aug 2025 20:30:02 +0800 Message-Id: <20250807123027.2910950-2-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568611452124100 Content-Type: text/plain; charset="utf-8" error[E0283]: type annotations needed --> hw/timer/hpet/src/device.rs:884:55 | 884 | self.num_timers =3D=3D self.num_timers_save.get().into() | -- ^^^^ | | | type must be known at this point | =3D note: multiple `impl`s satisfying `usize: PartialEq<_>` found in th= e following crates: `core`, `vm_memory`: - impl PartialEq for usize; - impl PartialEq for usize; - impl PartialEq for usize where the constant `host` has type `bool`; help: try using a fully qualified path to specify the expected types | 884 | self.num_timers =3D=3D >::into(self.num_timers_= save.get()) | ++++++++++++++++++++++ = ~ For more information about this error, try `rustc --explain E0283`. error: could not compile `hpet` (lib) due to 1 previous error Signed-off-by: Zhao Liu --- rust/hw/timer/hpet/src/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index acf7251029e9..9fd75bf096e4 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -881,7 +881,7 @@ fn is_offset_needed(&self) -> bool { } =20 fn validate_num_timers(&self, _version_id: u8) -> bool { - self.num_timers =3D=3D self.num_timers_save.get().into() + self.num_timers =3D=3D Into::::into(self.num_timers_save.ge= t()) } } =20 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569133; cv=none; d=zohomail.com; s=zohoarc; b=mau8hzGtfoB8sU+lKKOOACEjR+OqSd2IT2GfkBpkjO8Kcism54UWuXWlFXtbFOZuRLOWCCnmWP+k62BVnUY72b+ikBCzllnF79zYQOQOdIE4wCvI0fM8/3Eqbwz9N+gjiZdra/LYq0PIi9nyVlEobdgmXJwh8Xk92t8KS5wpT6E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569133; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6fwcxpIPb3V9NZsGHn+2eEjG4MuVOP/inIAUUpIcvGI=; b=IbQHkr8iseqQty5BVLPCPYzU32elAH8e8V+YknLhmHpQh+Xhfm8eszegY/9DPavETAEaALFOL3gQVYRkD8DJuGqOFxLgobHbWk2tE90SKbv9t/MZS8U1x3HCRw10Ygi6RlEK3sR9yUXwxgTnEdKpLTTS7nrrrRc5f+feUneEIM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569133172805.484687393388; Thu, 7 Aug 2025 05:18:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRD-0007t1-1M; Thu, 07 Aug 2025 08:09:41 -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 1ujzQn-0007Rn-3b; Thu, 07 Aug 2025 08:09:15 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQk-00054a-Bd; Thu, 07 Aug 2025 08:09:12 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:07 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568550; x=1786104550; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=I+BnrSmaOgS4QOTYt1Xg56BqMt16d9NeDnkZ1ZXGGos=; b=JTdWse8H1M48Nnjk1vXHS+9JmyxIEAn/oZO6xnuqgw3gqVAqafv2mFJ2 HorT7mQ5ZzzOtAn5IEb/9KqILAJo16PONO+4oo8WWrcr2mbGMaJ7Mf3Ws pahy/0mZ87uZ9zAInrfrXzOB9Qsf7xdWwkLCSnAR0wmeSWfIJmJZEWgZo GrihLz9KGd6Xw5J/nwar//AVUhoAHglq3hfGiguYxaekZxHMDoFVYdtHz a52KfxDOXnadsAY115OD/XVx23xeBRXX/IWeVjAbeQDupLIxAx/LG68/8 TBLbSpYMWkHbszIOrP8AMTnzOdC06nYCZdcucHLeIhHoRZWlVRolFdsTd g==; X-CSE-ConnectionGUID: my+/uoYAT/S+DA+k04NqAQ== X-CSE-MsgGUID: /92FSpEwTWy7xD9+YBNiOA== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036705" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036705" X-CSE-ConnectionGUID: PcNirZzsQiSQjyHfgaY9pQ== X-CSE-MsgGUID: CORasR4+QHCEFVLsCCqYew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701039" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 02/26] rust/cargo: Add the support for vm-memory Date: Thu, 7 Aug 2025 20:30:03 +0800 Message-Id: <20250807123027.2910950-3-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569134065116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- rust/Cargo.lock | 52 ++++++++++++++++++++++++++++++++++++++++ rust/qemu-api/Cargo.toml | 11 +++++++++ 2 files changed, 63 insertions(+) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b785c718f315..7aedae239f66 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -133,6 +133,7 @@ dependencies =3D [ "foreign", "libc", "qemu_api_macros", + "vm-memory", ] =20 [[package]] @@ -164,6 +165,26 @@ dependencies =3D [ "unicode-ident", ] =20 +[[package]] +name =3D "thiserror" +version =3D "1.0.65" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057= b3d5" +dependencies =3D [ + "thiserror-impl", +] + +[[package]] +name =3D "thiserror-impl" +version =3D "1.0.65" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f= 8602" +dependencies =3D [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name =3D "unicode-ident" version =3D "1.0.12" @@ -175,3 +196,34 @@ name =3D "version_check" version =3D "0.9.4" source =3D "registry+https://github.com/rust-lang/crates.io-index" checksum =3D "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e= 483f" + +[[package]] +name =3D "vm-memory" +version =3D "0.16.1" +source =3D "git+https://github.com/rust-vmm/vm-memory.git?rev=3D5eb996a060= d7ca3844cbd2f10b1d048c0c91942f#5eb996a060d7ca3844cbd2f10b1d048c0c91942f" +dependencies =3D [ + "thiserror", + "winapi", +] + +[[package]] +name =3D "winapi" +version =3D "0.3.9" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00= f419" +dependencies =3D [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name =3D "winapi-i686-pc-windows-gnu" +version =3D "0.4.0" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51= b7b6" + +[[package]] +name =3D "winapi-x86_64-pc-windows-gnu" +version =3D "0.4.0" +source =3D "registry+https://github.com/rust-lang/crates.io-index" +checksum =3D "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931= 183f" diff --git a/rust/qemu-api/Cargo.toml b/rust/qemu-api/Cargo.toml index db7000dee441..bbed3d2de514 100644 --- a/rust/qemu-api/Cargo.toml +++ b/rust/qemu-api/Cargo.toml @@ -19,6 +19,17 @@ anyhow =3D "~1.0" libc =3D "0.2.162" foreign =3D "~0.3.1" =20 +[dependencies.vm-memory] +# The latest v0.16.2 didn't contain Paolo's commit 5f59e29c3d30 +# ("guest_memory: let multiple regions slice one global bitmap"). +# Once a new release has that change, switch to crates.io. +git =3D "https://github.com/rust-vmm/vm-memory.git" +rev =3D "5eb996a060d7ca3844cbd2f10b1d048c0c91942f" +# Note "rawfd" (as the only default feature) is disabled by default in +# meson. It cause compilation failure on Windows and fortunately, we +# don't need it either. +default-features =3D false + [features] default =3D ["debug_cell"] allocator =3D [] --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568936; cv=none; d=zohomail.com; s=zohoarc; b=DZ2KDEvuYMHTR1XB1V9n5brMhA13oNanbhBJ6VyhacUg6PpsiCYITV5jjm1sORlF1nY+yaUio+fWfD6oTBg16nlOagG1Rfli9ZE4oAu6jK+fkcelDMSAekDhtsZMEwNVkA4VNBpHA8wILXx0pLs3aqpHvn+VswgabJzcreyVZ0U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568936; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3hHNdi3ZoMKE+s2+XXbz2jq9MEMq6zdrNXvvEt1X8pc=; b=ma1XzwugN+pgO3yaft+CTHC9/coylaVeDCAvHRquS8UA8cs7zsXf/ua9nXOSGx+rU+ksX73iGDN8P87dvZkUydozP8JU0mi/H0ZC1ciKExSA4LixTtIpHUKmHmpmTz0cCsyelCTH26CsYJg6AlG4I89QNB3/nR4zL84Zrd86rBY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 175456893638974.42149497380262; Thu, 7 Aug 2025 05:15:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRU-0000O5-5C; Thu, 07 Aug 2025 08:09:56 -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 1ujzQr-0007YN-5u; Thu, 07 Aug 2025 08:09:18 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQn-000545-G1; Thu, 07 Aug 2025 08:09:15 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:10 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568553; x=1786104553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LptemJENmigDfQlxiacW2bd+EUXWgJL0UDSzTxRjZ+w=; b=FiPFlcKvy/zF8XfTeP9kPniEzc2QZw/mQ5eDUHJEcSAOWHSKYo+5BDTv ocYS0h2d8bHmpMyG/IPIclBYVzVt7l3Jw+lYAATO0KeXrHtep3SfZuYsw RTPodHCmZtVgjAz6T/tiXVtupmEvxIxWByv4bpCq8HUtsTRxxHULRg+04 MWZwZkolmEg0PBWgDlM2LmnzmuwdEIBCwlljzje96U1/xryU+8h+OEPp9 fLgS+hYoaPol73EChghdv5tuLHhOCPhcFl28IpWSPQtDkqZJf9NlV+ocs HInr9RoSc46vJDY/AVLHdPcREWrcLwRFDixOHgEKDXlENfQud8sxJapp7 Q==; X-CSE-ConnectionGUID: EXwcMm82R3SXGIOPMTvUwA== X-CSE-MsgGUID: yh2IKBxZRDWasciDbH5Psw== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036711" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036711" X-CSE-ConnectionGUID: ry6T5C7MRO22Kt40Ze4ztw== X-CSE-MsgGUID: G5kdBu2oTGCzFImRLwK+Kg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701045" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 03/26] subprojects: Add thiserror-impl crate Date: Thu, 7 Aug 2025 20:30:04 +0800 Message-Id: <20250807123027.2910950-4-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568951273124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 2 +- scripts/make-release | 2 +- subprojects/.gitignore | 1 + .../thiserror-impl-1-rs/meson.build | 41 +++++++++++++++++++ subprojects/thiserror-impl-1-rs.wrap | 10 +++++ 5 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/thiserror-impl-1-rs/meson.build create mode 100644 subprojects/thiserror-impl-1-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 035828c532e7..8d8a0d37ecdc 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -31,7 +31,7 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs unicode-ident-1-rs" + syn-2-rs thiserror-impl-1-rs unicode-ident-1-rs" sub_deinit=3D"" =20 function cleanup() { diff --git a/scripts/make-release b/scripts/make-release index 4509a9fabf50..3d3d8d4a51bc 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -44,7 +44,7 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs unicode-ident-1-rs" + syn-2-rs thiserror-impl-1-rs unicode-ident-1-rs" =20 src=3D"$1" version=3D"$2" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index f4281934ce11..e6ea570a2286 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -19,4 +19,5 @@ /proc-macro2-1.0.84 /quote-1.0.36 /syn-2.0.66 +/thiserror-impl-1.0.65 /unicode-ident-1.0.12 diff --git a/subprojects/packagefiles/thiserror-impl-1-rs/meson.build b/sub= projects/packagefiles/thiserror-impl-1-rs/meson.build new file mode 100644 index 000000000000..cc5546264035 --- /dev/null +++ b/subprojects/packagefiles/thiserror-impl-1-rs/meson.build @@ -0,0 +1,41 @@ +project('thiserror-impl-1-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '1.0.65', + license: 'MIT OR Apache-2.0', + default_options: []) + +subproject('quote-1-rs', required: true) +subproject('syn-2-rs', required: true) +subproject('proc-macro2-1-rs', required: true) + +quote_dep =3D dependency('quote-1-rs', native: true) +syn_dep =3D dependency('syn-2-rs', native: true) +proc_macro2_dep =3D dependency('proc-macro2-1-rs', native: true) + +rust =3D import('rust') + +_thiserror_impl_rs =3D rust.proc_macro( + 'thiserror_impl', + files('src/lib.rs'), + override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_args: [ + '--cfg', 'feature=3D"proc-macro"', + '--cfg', 'feature=3D"clone-impls"', + '--cfg', 'feature=3D"derive"', + '--cfg', 'feature=3D"extra-traits"', + '--cfg', 'feature=3D"full"', + '--cfg', 'feature=3D"parsing"', + '--cfg', 'feature=3D"printing"', + ], + dependencies: [ + quote_dep, + syn_dep, + proc_macro2_dep + ], +) + +thiserror_impl_dep =3D declare_dependency( + link_with: _thiserror_impl_rs, +) + +meson.override_dependency('thiserror-impl-1-rs', thiserror_impl_dep) diff --git a/subprojects/thiserror-impl-1-rs.wrap b/subprojects/thiserror-i= mpl-1-rs.wrap new file mode 100644 index 000000000000..0f2ca85b8590 --- /dev/null +++ b/subprojects/thiserror-impl-1-rs.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory =3D thiserror-impl-1.0.65 +source_url =3D https://crates.io/api/v1/crates/thiserror-impl/1.0.65/downl= oad +source_filename =3D thiserror-impl-1.0.65.tar.gz +source_hash =3D ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b3= 7f8602 +#method =3D cargo +patch_directory =3D thiserror-impl-1-rs + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569133; cv=none; d=zohomail.com; s=zohoarc; b=O9kS3L8B63D6XQqi+Crhyo+fmNpjKXhFZ1QOcfCyiQnJWoNyQJdIQKlfskMpbo2y3Bb2FpIxwILKQSbbUAlp8b1PRR9rgwJN2GNg0wfmuOJ23Ox03MVhO0LcMHTV9Hhd/TNC5FxLvsatYbmLClCZbK79sKqoVf5QUvnRKTJ+zvU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569133; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zy8fzG3MnPjy8YFdSnSjmsluAmKKTNH556IdfB0snXY=; b=mhTDX1Cvjdu6F1DrjQeG48XqDhy+FSGsvFYkc0uPKWEhc4/IyTXAG/+iWv8Y8DFB4LMJmJUZMmNkkDvIV406wN4eweoRi22ijmhuqs99l5TWwxH6yglKAir/oPyYtoHFDicqy2MO4twglSvBBnpRQn5sa8eFEuU7XzCkqJ5lhRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569133412902.3086029336196; Thu, 7 Aug 2025 05:18:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzS0-0002LP-0y; Thu, 07 Aug 2025 08:10:28 -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 1ujzQt-0007cF-1G; Thu, 07 Aug 2025 08:09:20 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQp-00056D-J6; Thu, 07 Aug 2025 08:09:18 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:14 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:11 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568555; x=1786104555; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mZA5SSrz3FphXmaSjbWuWr8Dg8r0OVF1qFpqD5BZOaI=; b=h7HTzKQ0ISSmi7B5QxWgXOGrZW3Qwcceehcujxp4DaA/amXJfL1nOhKo 3d3ymZLByRhAPksZPq0JTT2OV3y3qKhYJkvNS4ebJKJoY/cr+2WSlnedt CaJGOi3rW1XGlLoqKkGqPWQoLLxqZL+UoHxWF2LHXvHYPJ0idwMrOwIE5 Y3+maWm5yB5ZcwqADeV+R+x/TEnjr4OFT8mn6BmF2VDVLemniw4i1ucTk lsArWMMU+sHNEwD3G7orWoUM/ITf4IUd2kw+9mdMlwpa12Ur0lfxN+lyS LhYJtd+eABndnzdvkLbdfqkAEJboSRngXKsSx8mtmKux6zM7zENH6kAAn A==; X-CSE-ConnectionGUID: nEK8HqWqS56+fLHWDeTpTQ== X-CSE-MsgGUID: KRGaXcxoT9uptnhkZpsemw== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036716" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036716" X-CSE-ConnectionGUID: O1Bsg54tSM+YFD5GR7VkxQ== X-CSE-MsgGUID: HrgiLHD/Q/G2lvjrfUWipw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701053" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 04/26] subprojects: Add thiserror crate Date: Thu, 7 Aug 2025 20:30:05 +0800 Message-Id: <20250807123027.2910950-5-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569135673124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 2 +- scripts/make-release | 2 +- subprojects/.gitignore | 1 + .../packagefiles/thiserror-1-rs/meson.build | 23 +++++++++++++++++++ subprojects/thiserror-1-rs.wrap | 10 ++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/thiserror-1-rs/meson.build create mode 100644 subprojects/thiserror-1-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 8d8a0d37ecdc..3ae064f65263 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -31,7 +31,7 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs thiserror-impl-1-rs unicode-ident-1-rs" + syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs" sub_deinit=3D"" =20 function cleanup() { diff --git a/scripts/make-release b/scripts/make-release index 3d3d8d4a51bc..73a14c12bdeb 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -44,7 +44,7 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs thiserror-impl-1-rs unicode-ident-1-rs" + syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs" =20 src=3D"$1" version=3D"$2" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index e6ea570a2286..3b09ab42da08 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -19,5 +19,6 @@ /proc-macro2-1.0.84 /quote-1.0.36 /syn-2.0.66 +/thiserror-1.0.65 /thiserror-impl-1.0.65 /unicode-ident-1.0.12 diff --git a/subprojects/packagefiles/thiserror-1-rs/meson.build b/subproje= cts/packagefiles/thiserror-1-rs/meson.build new file mode 100644 index 000000000000..bfaf2f8d3eb8 --- /dev/null +++ b/subprojects/packagefiles/thiserror-1-rs/meson.build @@ -0,0 +1,23 @@ +project('thiserror-1-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '1.0.65', + license: 'MIT OR Apache-2.0', + default_options: []) + +subproject('thiserror-impl-1-rs', required: true) +thiserror_impl_rs =3D dependency('thiserror-impl-1-rs') + +_thiserror_rs =3D static_library( + 'thiserror', + files('src/lib.rs'), + gnu_symbol_visibility: 'hidden', + override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_abi: 'rust', + dependencies: [thiserror_impl_rs], +) + +thiserror_dep =3D declare_dependency( + link_with: _thiserror_rs, +) + +meson.override_dependency('thiserror-1-rs', thiserror_dep) diff --git a/subprojects/thiserror-1-rs.wrap b/subprojects/thiserror-1-rs.w= rap new file mode 100644 index 000000000000..0f9303bebf97 --- /dev/null +++ b/subprojects/thiserror-1-rs.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory =3D thiserror-1.0.65 +source_url =3D https://crates.io/api/v1/crates/thiserror/1.0.65/download +source_filename =3D thiserror-1.0.65.tar.gz +source_hash =3D 5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a30= 57b3d5 +#method =3D cargo +patch_directory =3D thiserror-1-rs + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568737; cv=none; d=zohomail.com; s=zohoarc; b=Vqm2USVPHfznZmxAH6cRvdh467afHsMwzPeJ/ZzFFByphTyHDJRTkGxZQmlcuHvAkb6sDzjAtx3RVl3SvWGqBfcDmb8RfblmCtZqSDUzVIihYIglU1w/SoS8zczemDY91p5N30YBXP5V8U02qKALtu3IYwLY62jBrSkWQT0BGZ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568737; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6/bv1mZVVi/5C5l6xvXYO6EYBR5KWdQhbl/uZH8+Dhk=; b=MsKjuMKUyKEMAr3FJ3GGAz51T9uG/VfXe8RcUiXjrW3fmmoua2L1ED+4pWkQLuGVGtSlC/emwQqFJh/QIREEFbVv8XRFRPx8KsTel9Uhy5AyniEF86TgzDP3Tp2WIh+No5J3t8jkNHpvLp2HjXqgV/8zhevO/RB62SAecPXEFyw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 175456873697268.53464536999672; Thu, 7 Aug 2025 05:12:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRT-0000MR-W6; Thu, 07 Aug 2025 08:09:56 -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 1ujzQv-0007eF-ES; Thu, 07 Aug 2025 08:09:24 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQs-000545-LL; Thu, 07 Aug 2025 08:09:20 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:17 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:14 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568559; x=1786104559; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=te8bf6C67vk8RNoSAtSd8hbkT5L5XunTcV4T9AUV3uM=; b=YAMMg/GTKswXyWK8ybmv0y9Bd5WH5rsAgKB5+hu8zaxtSFIVc3LWbh4F nOF4s71V4z5myIClJeFkf6ZKygt7JR6RwmR9lunRjZ2IpSNP+td6zZbM9 hLUhie0F1BSj7L+OvJaN3tXjqsKxMpI9y2WRTFYPW9VVrrDQSu+gvAMQ2 5f59Uuzwlv+EiAR7+X+My/gEyVV9A+LvVcxHyQus5QRAPCYnioW0KJvHC fT3p8k58GNFJ4Go8TSTpl1FdNPe+B70tzKTJxKrBO8Kk099P44deD69DC FZiQ9Rw5hGDJnmTmB4FgToRh3IWz135K5QZ8Pe0VSJYomn68/dmem8ioQ g==; X-CSE-ConnectionGUID: 5b9zeRWyR9WEmQRGQLfozQ== X-CSE-MsgGUID: ozu0uv63SCydiRzM1Zfq4Q== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036724" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036724" X-CSE-ConnectionGUID: D0LDIIGET8GgV/VRXuVkWQ== X-CSE-MsgGUID: 25UiyN6tRoSzRkNQFw28KQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701063" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 05/26] subprojects: Add winapi-i686-pc-windows-gnu crate Date: Thu, 7 Aug 2025 20:30:06 +0800 Message-Id: <20250807123027.2910950-6-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SPACE_RATIO=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568739101116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 3 ++- scripts/make-release | 3 ++- subprojects/.gitignore | 1 + .../meson.build | 20 +++++++++++++++++++ .../winapi-i686-pc-windows-gnu-0.4-rs.wrap | 10 ++++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/winapi-i686-pc-windows-gnu-0.4= -rs/meson.build create mode 100644 subprojects/winapi-i686-pc-windows-gnu-0.4-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 3ae064f65263..2dff5d3d89fe 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -31,7 +31,8 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs" + syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs + winapi-i686-pc-windows-gnu-0.4-rs" sub_deinit=3D"" =20 function cleanup() { diff --git a/scripts/make-release b/scripts/make-release index 73a14c12bdeb..f7a1481f856a 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -44,7 +44,8 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 bilge-impl-0.2-rs either-1-rs foreign-0.3-rs itertools-0.11-rs libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs - syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs" + syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs + winapi-i686-pc-windows-gnu-0.4-rs" =20 src=3D"$1" version=3D"$2" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 3b09ab42da08..838409353fca 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -22,3 +22,4 @@ /thiserror-1.0.65 /thiserror-impl-1.0.65 /unicode-ident-1.0.12 +/winapi-i686-pc-windows-gnu-0.4.0 diff --git a/subprojects/packagefiles/winapi-i686-pc-windows-gnu-0.4-rs/mes= on.build b/subprojects/packagefiles/winapi-i686-pc-windows-gnu-0.4-rs/meson= .build new file mode 100644 index 000000000000..5ae1b87403d2 --- /dev/null +++ b/subprojects/packagefiles/winapi-i686-pc-windows-gnu-0.4-rs/meson.build @@ -0,0 +1,20 @@ +project('winapi-i686-pc-windows-gnu-0.4-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '0.4.0', + license: 'MIT OR Apache-2.0', + default_options: []) + +lib =3D static_library( + 'winapi-i686-pc-windows-gnu', + 'src/lib.rs', + override_options : ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_abi : 'rust', + rust_args: ['--cap-lints', 'allow'], + dependencies: [thiserror_rs], +) + +dep =3D declare_dependency( + link_with : [lib], +) + +meson.override_dependency('winapi-i686-pc-windows-gnu-0.4-rs', dep) diff --git a/subprojects/winapi-i686-pc-windows-gnu-0.4-rs.wrap b/subprojec= ts/winapi-i686-pc-windows-gnu-0.4-rs.wrap new file mode 100644 index 000000000000..8ec2f2351d9e --- /dev/null +++ b/subprojects/winapi-i686-pc-windows-gnu-0.4-rs.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory =3D winapi-i686-pc-windows-gnu-0.4.0 +source_url =3D https://crates.io/api/v1/crates/winapi-i686-pc-windows-gnu/= 0.4.0/download +source_filename =3D winapi-i686-pc-windows-gnu-0.4.0.tar.gz +source_hash =3D ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab= 51b7b6 +#method =3D cargo +patch_directory =3D winapi-i686-pc-windows-gnu-0.4-rs + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568615; cv=none; d=zohomail.com; s=zohoarc; b=Iwj0++tI7xbFfnR66az++Z8BZ7EdNLC7w3SzReta9FGpZ+jsD+aHI9+igp1t2SEX+odWFfukrFvRwif0fqauGZc/Pgw72gwPwsjlxE4Up1TU090xD/TPvPwrGZCRp2mx2fGypddVAPe/NEA7w3Kbw/f5ny4K1/x0d4nT9WBjHJ0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568615; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ct7Jy15zIWQxHZS4gd/2ZNj4SpHP/VDPa6sCpF5iLyU=; b=gTLdBI0VXOdy09GcOxT/XbC8XwTYbjfFPsLJCjOA14RCB0Il5uf/E7ljCxTKkTJIz/czf22kOgFrTGOxYIFJ5Jnn5vDLfbwgLThgh/Hn//5HrMTTcEY0xXdyvGLfsZBxR/FZdhTG8JhM/Ngms/85heoIYwc4Fhag3KRw54UN5iY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568615274307.8985886069238; Thu, 7 Aug 2025 05:10:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRG-0007yl-Hv; Thu, 07 Aug 2025 08:09: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 1ujzR0-0007fo-6v; Thu, 07 Aug 2025 08:09:28 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQv-00056D-Oq; Thu, 07 Aug 2025 08:09:25 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:20 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568562; x=1786104562; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OxhjwyLszdE/5nDOkyohSk0dJTIgi8pKdSOahOmdvyc=; b=a4Efb3I4064+xf7IAaD3gfzKuiNScwTVy3cM3f0Mb0wrdXjcJHEtCIdh aVKSnR6SMD2bwVraeuYBT6Jquikrh64DEMwwKxOTs52gYP3YceNJswajV ZwO5S4O08kz3dxapNdrRybWa7NRA1stavb82DkxWeojutjGWmmopfExei 0xQj/qMHmWdtHnUul3+r2IQtEwmnX3r9FmXYExHBpRbEsk22RpOR3RmF4 r6+9Gjw/xKy94VmkQK9OXEd8K2QLOh4/TnffnZh++IeZU9rVstN+/OH0E ZbrJ4qxhJWpVLPxDVFLVe5Ab/PMDlEWcbz6jtHPpKLUqcByrP3YmaTZVX g==; X-CSE-ConnectionGUID: lJ/lYhdnQp6iexVxMOqRVQ== X-CSE-MsgGUID: l7ZZhBzXTI6X+UIgnlZ60Q== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036739" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036739" X-CSE-ConnectionGUID: r5EH3NTmQH6ZgB52sBuJEg== X-CSE-MsgGUID: VNoGryIpTNiQe4Pc3JpXUg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701077" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 06/26] subprojects: Add winapi-x86_64-pc-windows-gnu crate Date: Thu, 7 Aug 2025 20:30:07 +0800 Message-Id: <20250807123027.2910950-7-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, TVD_SPACE_RATIO=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568617612116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 2 +- scripts/make-release | 2 +- subprojects/.gitignore | 1 + .../meson.build | 20 +++++++++++++++++++ .../winapi-x86_64-pc-windows-gnu-0.4-rs.wrap | 10 ++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/winapi-x86_64-pc-windows-gnu-0= .4-rs/meson.build create mode 100644 subprojects/winapi-x86_64-pc-windows-gnu-0.4-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 2dff5d3d89fe..4caf6078f1ac 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -32,7 +32,7 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-i686-pc-windows-gnu-0.4-rs" + winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" sub_deinit=3D"" =20 function cleanup() { diff --git a/scripts/make-release b/scripts/make-release index f7a1481f856a..eb8b2446ad3a 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -45,7 +45,7 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-i686-pc-windows-gnu-0.4-rs" + winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" =20 src=3D"$1" version=3D"$2" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index 838409353fca..ed51f2012e2c 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -23,3 +23,4 @@ /thiserror-impl-1.0.65 /unicode-ident-1.0.12 /winapi-i686-pc-windows-gnu-0.4.0 +/winapi-x86_64-pc-windows-gnu-0.4.0 diff --git a/subprojects/packagefiles/winapi-x86_64-pc-windows-gnu-0.4-rs/m= eson.build b/subprojects/packagefiles/winapi-x86_64-pc-windows-gnu-0.4-rs/m= eson.build new file mode 100644 index 000000000000..6b06e1d2810e --- /dev/null +++ b/subprojects/packagefiles/winapi-x86_64-pc-windows-gnu-0.4-rs/meson.bu= ild @@ -0,0 +1,20 @@ +project('winapi-x86_64-pc-windows-gnu-0.4-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '0.4.0', + license: 'MIT OR Apache-2.0', + default_options: []) + +lib =3D static_library( + 'winapi-x86_64-pc-windows-gnu', + 'src/lib.rs', + override_options : ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_abi : 'rust', + rust_args: ['--cap-lints', 'allow'], + dependencies: [thiserror_rs], +) + +dep =3D declare_dependency( + link_with : [lib], +) + +meson.override_dependency('winapi-x86_64-pc-windows-gnu-0.4-rs', dep) diff --git a/subprojects/winapi-x86_64-pc-windows-gnu-0.4-rs.wrap b/subproj= ects/winapi-x86_64-pc-windows-gnu-0.4-rs.wrap new file mode 100644 index 000000000000..d75a096980a1 --- /dev/null +++ b/subprojects/winapi-x86_64-pc-windows-gnu-0.4-rs.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory =3D winapi-x86_64-pc-windows-gnu-0.4.0 +source_url =3D https://crates.io/api/v1/crates/winapi-x86_64-pc-windows-gn= u/0.4.0/download +source_filename =3D winapi-x86_64-pc-windows-gnu-0.4.0.tar.gz +source_hash =3D 712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc19= 31183f +#method =3D cargo +patch_directory =3D winapi-x86_64-pc-windows-gnu-0.4-rs + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569048; cv=none; d=zohomail.com; s=zohoarc; b=Beb4PoM4MdldbNW4QFeGCLN0vN7iwBDfc0AZmXF5zlIRqtCP9IDs6sEnsJ0EJSz0sCJvvHjsdxEjkutfwHeCMZQ3FpJ5+sQAtOxUDP7b1JqWFWrOO0ItKI0xNk6D4QsWJbyOAN9SDJBe8lEg1SPHuSdZlMwNSrAOOjcKQUt5ZNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569048; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NkzQ0nQZi6jzjIYuY/uNNXq9hXgJSR6Kl4jyPabow/A=; b=AoUtf1Nr6+gT0HLor1yKLoxVKLWrLSBUQqn78mAVnUy9wcGmg7a/urOFmqY747K2YxgpXG2iYra6wJD+2Gr5bLXoW/XfzD/miszDjcesSjbxKEU5j1cfFPPaeKZiuEVVhrXFfLy7cFXtIN3IPBIUdNVax2mus/Uo9mOnW/Nh2FU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569048373622.4878726248326; Thu, 7 Aug 2025 05:17:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRr-0001UP-S2; Thu, 07 Aug 2025 08:10:20 -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 1ujzR1-0007g0-KG; Thu, 07 Aug 2025 08:09:33 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzQz-000545-7L; Thu, 07 Aug 2025 08:09:27 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:24 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:21 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568565; x=1786104565; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yIyWt4frlWBRZfRYC5czZ1MuxO6aMa3aYBG309ggo+g=; b=AKT0nR7/6KF+lZnCFSEYmDi8KsyfYgSzk6NaChS70ROQBPsh4S/WRfaC +tZsxMIHuorf7wJx7/M1CJvzPXsGN8ZYQXAYG4JCgEdMTI3odI9Cd12by 5ZVXo7R0NSpFUBkA48Uh9THpe+bo6JRt5HzadpQfMfchKQcyMct1VpNY8 sWWM7+WPfCyn9vqaOb59aUU35RSSsgV+J3hrbqPlnpZCAi6AqFXSS8Uxj LUPy7ZC5j9ikKuBS0P371+TrBG1avS/rhD/Esy9UU4V0fcQMN69TQmas+ AasZROKOX0rUS458RkpW/rKmwKXS+tWULLsgGHaxiJm3WvA4ar3dPg/JL A==; X-CSE-ConnectionGUID: pbSJd+QqQ5unHkP1IUFxfw== X-CSE-MsgGUID: KgXoTuIYRiWU/UbualkHNQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036750" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036750" X-CSE-ConnectionGUID: 0O4Z1IR6SNC7izHb9utTTA== X-CSE-MsgGUID: sGZdusAiQvOhxX02QszuTA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701086" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 07/26] subprojects: Add winapi crate Date: Thu, 7 Aug 2025 20:30:08 +0800 Message-Id: <20250807123027.2910950-8-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569049234116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 3 +- scripts/make-release | 3 +- subprojects/.gitignore | 1 + .../packagefiles/winapi-0.3-rs/meson.build | 46 +++++++++++++++++++ subprojects/winapi-0.3-rs.wrap | 10 ++++ 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/winapi-0.3-rs/meson.build create mode 100644 subprojects/winapi-0.3-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 4caf6078f1ac..99d0d898d010 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -32,7 +32,8 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" + winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs + winapi-x86_64-pc-windows-gnu-0.4-rs" sub_deinit=3D"" =20 function cleanup() { diff --git a/scripts/make-release b/scripts/make-release index eb8b2446ad3a..c53dfa0a7f4f 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -45,7 +45,8 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" + winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs + winapi-x86_64-pc-windows-gnu-0.4-rs" =20 src=3D"$1" version=3D"$2" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index ed51f2012e2c..c42adaa928ec 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -22,5 +22,6 @@ /thiserror-1.0.65 /thiserror-impl-1.0.65 /unicode-ident-1.0.12 +/winapi-0.3.9 /winapi-i686-pc-windows-gnu-0.4.0 /winapi-x86_64-pc-windows-gnu-0.4.0 diff --git a/subprojects/packagefiles/winapi-0.3-rs/meson.build b/subprojec= ts/packagefiles/winapi-0.3-rs/meson.build new file mode 100644 index 000000000000..e2cee17ec2d5 --- /dev/null +++ b/subprojects/packagefiles/winapi-0.3-rs/meson.build @@ -0,0 +1,46 @@ +project('winapi-0.3-rs', 'rust', + meson_version: '>=3D1.5.0', + version: '0.3.9', + license: 'MIT OR Apache-2.0' +) + +if host_machine.cpu_family() =3D=3D 'x86_64' + winapi_arch =3D 'winapi-x86_64-pc-windows-gnu-0.4-rs' +elif host_machine.cpu_family() =3D=3D 'x86' + winapi_arch =3D 'winapi-i686-pc-windows-gnu-0.4-rs' +else + error('Unsupported CPU family for winapi: ' + host_machine.cpu_family()) +endif + +subproject(winapi_arch, required: true) +winapi_arch_dep =3D dependency(winapi_arch) + +winapi_features =3D [ + '--cfg', 'feature=3D"errhandlingapi"', + '--cfg', 'feature=3D"sysinfoapi"', + '--cfg', 'feature=3D"excpt"', + '--cfg', 'feature=3D"minwinbase"', + '--cfg', 'feature=3D"ntstatus"', + '--cfg', 'feature=3D"winnt"', + '--cfg', 'feature=3D"basetsd"', + '--cfg', 'feature=3D"ktmtypes"', + '--cfg', 'feature=3D"minwindef"', + '--cfg', 'feature=3D"ntdef"', + '--cfg', 'feature=3D"guiddef"', + '--cfg', 'feature=3D"vcruntime"' +] + +lib =3D static_library( + 'winapi', + 'src/lib.rs', + override_options : ['rust_std=3D2021'], + rust_abi : 'rust', + rust_args: ['--cap-lints', 'allow'] + winapi_features, + dependencies: [winapi_arch_dep] +) + +dep =3D declare_dependency( + link_with: lib, +) + +meson.override_dependency('winapi-0.3-rs', dep) diff --git a/subprojects/winapi-0.3-rs.wrap b/subprojects/winapi-0.3-rs.wrap new file mode 100644 index 000000000000..49a5954ec225 --- /dev/null +++ b/subprojects/winapi-0.3-rs.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory =3D winapi-0.3.9 +source_url =3D https://crates.io/api/v1/crates/winapi/0.3.9/download +source_filename =3D winapi-0.3.9.tar.gz +source_hash =3D 5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b= 00f419 +#method =3D cargo +patch_directory =3D winapi-0.3-rs + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568732; cv=none; d=zohomail.com; s=zohoarc; b=h1WqhIpa9I6Lz09PuvEfeNqw1LgY25v72WM6XHHNAFzEGGaW2qsMAorLEnqBDEvBn6/2m5rKpcb/1+/LrtC6T1WBl41KkH/iLBrum5LpRBLM3bM4BrWjzl/2l5oAAJqhFcYg+UP5PENOwlR9SnRND6G+T0eUf52w+lg9Y62x17g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568732; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qQ0sIRny5cCuDZ5BXdVA9iFtL7C82nYsQWyrZBlXGFY=; b=bByLD2/LOKeNpiqhayIlX6v82x6K8m4+VMY8sxsdVUWI9bZAaS1l0fzgnOtOiT2/YHsbsIFHkPwQGXnOtCBgfTy8FRA2QYXM5DDUfYyGHaDVKJgPVHLRn9UyWn9KLoyKcpbcEh7NviMfUsvc/brlpMw0phaHlAU81RTARqU1KMw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568732836973.605974175926; Thu, 7 Aug 2025 05:12:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRU-0000O4-5U; Thu, 07 Aug 2025 08:09:56 -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 1ujzR5-0007ia-Fw; Thu, 07 Aug 2025 08:09:36 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzR3-00058G-Ac; Thu, 07 Aug 2025 08:09:31 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:27 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568569; x=1786104569; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/6Sn5bBqav7a/VOe4eY0q12wWkysC4c3gYyVvzV9Usk=; b=Qt+efbhmiXKaRCOrrb9VnuvvcnFhD1zKULjJDTVJFsE56o1Q76mXxCN9 9MCrF40LzrKSK2h8ethDltRG9ATgAFqyVKezp7mHX+YiSYpjarJL5EH9H 7q9WXskEzEwF2FKnwVdg1n+U5oSX64B+xVUtmAa8y6mn7Iv/t9fmKcqKv yZdNQM7/PqLHk2nNwTqBEtF/VGmcBmuQV5o9ypqUJwm6nIWfidlb/uDGv CacMftzlqJu6r1UIkNJYH9kIVHnH2nAaOicrbicb1804zREu011dfyaTI nIHI6b1AWL3ZUOy/jg1vMRiFG06Ul8gBBphPzm4x2xYxePhFX8N0egwj4 g==; X-CSE-ConnectionGUID: GVCzBLPCTFiBeieLDvn1JA== X-CSE-MsgGUID: 8luwCznERJ6zALQQSmTtQQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036764" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036764" X-CSE-ConnectionGUID: uK0ipsbsSyqLIfgG7GPzKw== X-CSE-MsgGUID: /RMVBElBQjGkelAahNAIxQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701097" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 08/26] subprojects: Add vm-memory crate Date: Thu, 7 Aug 2025 20:30:09 +0800 Message-Id: <20250807123027.2910950-9-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568735125116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- scripts/archive-source.sh | 2 +- scripts/make-release | 2 +- subprojects/.gitignore | 1 + .../vm-memory-0.16-rs/meson.build | 35 +++++++++++++++++++ subprojects/vm-memory-0.16-rs.wrap | 12 +++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 subprojects/packagefiles/vm-memory-0.16-rs/meson.build create mode 100644 subprojects/vm-memory-0.16-rs.wrap diff --git a/scripts/archive-source.sh b/scripts/archive-source.sh index 99d0d898d010..41cf095ca33d 100755 --- a/scripts/archive-source.sh +++ b/scripts/archive-source.sh @@ -32,7 +32,7 @@ subprojects=3D"keycodemapdb libvfio-user berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs + vm-memory-0.16-rs winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" sub_deinit=3D"" =20 diff --git a/scripts/make-release b/scripts/make-release index c53dfa0a7f4f..115739d31623 100755 --- a/scripts/make-release +++ b/scripts/make-release @@ -45,7 +45,7 @@ SUBPROJECTS=3D"libvfio-user keycodemapdb berkeley-softflo= at-3 libc-0.2-rs proc-macro2-1-rs proc-macro-error-1-rs proc-macro-error-attr-1-rs quote-1-rs syn-2-rs thiserror-1-rs thiserror-impl-1-rs unicode-ident-1-rs - winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs + vm-memory-0.16-rs winapi-0.3-rs winapi-i686-pc-windows-gnu-0.4-rs winapi-x86_64-pc-windows-gnu-0.4-rs" =20 src=3D"$1" diff --git a/subprojects/.gitignore b/subprojects/.gitignore index c42adaa928ec..518dd39199ab 100644 --- a/subprojects/.gitignore +++ b/subprojects/.gitignore @@ -22,6 +22,7 @@ /thiserror-1.0.65 /thiserror-impl-1.0.65 /unicode-ident-1.0.12 +/vm-memory-0.16 /winapi-0.3.9 /winapi-i686-pc-windows-gnu-0.4.0 /winapi-x86_64-pc-windows-gnu-0.4.0 diff --git a/subprojects/packagefiles/vm-memory-0.16-rs/meson.build b/subpr= ojects/packagefiles/vm-memory-0.16-rs/meson.build new file mode 100644 index 000000000000..f0d99bad5b7f --- /dev/null +++ b/subprojects/packagefiles/vm-memory-0.16-rs/meson.build @@ -0,0 +1,35 @@ +project( + 'vm-memory-0.16-rs', + 'rust', + meson_version: '>=3D1.5.0', + #version : '0.2.0', + license : 'Apache-2.0 or BSD-3-Clause', +) + +all_deps =3D [] + +subproject('thiserror-1-rs', required: true) +all_deps +=3D dependency('thiserror-1-rs') + +if host_machine.system() =3D=3D 'windows' + subproject('winapi-0.3-rs', required: true) + all_deps +=3D dependency('winapi-0.3-rs') +endif + +# Note "rawfd" (as the only default feature) is disabled by default in +# meson. It cause compilation failure on Windows and fortunately, we +# don't need it either. +lib =3D static_library( + 'vm_memory', + 'src/lib.rs', + override_options : ['rust_std=3D2021', 'build.rust_std=3D2021'], + rust_abi : 'rust', + rust_args: ['--cap-lints', 'allow'], + dependencies: all_deps, +) + +dep =3D declare_dependency( + link_with : [lib], +) + +meson.override_dependency('vm-memory-0.16-rs', dep) diff --git a/subprojects/vm-memory-0.16-rs.wrap b/subprojects/vm-memory-0.1= 6-rs.wrap new file mode 100644 index 000000000000..a057c8c9efc1 --- /dev/null +++ b/subprojects/vm-memory-0.16-rs.wrap @@ -0,0 +1,12 @@ +[wrap-git] +directory =3D vm-memory-0.16 +# The latest v0.16.2 didn't contain Paolo's commit 5f59e29c3d30 +# ("guest_memory: let multiple regions slice one global bitmap"). +# Once a new release has that change, switch to crates.io. +url =3D https://github.com/rust-vmm/vm-memory.git +revision =3D 5eb996a060d7ca3844cbd2f10b1d048c0c91942f +patch_directory =3D vm-memory-0.16-rs +depth =3D 1 + +# bump this version number on every change to meson.build or the patches: +# v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568748; cv=none; d=zohomail.com; s=zohoarc; b=Vu8l3PLA82t8Og8dxJRRjgJnkwlGWoyj71OmKimzVFdbPmT6UINVk1NsdrDraxEgZdUInet/3ZFq3b45z2gMafC10Dn5XKSv3lraoywJ5NjDKUruEBjQ57JQaMhxy5l2rP3SwKXb9ypi+h4d5e0bm8ky10B3ig4YC2LkRVLOqZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568748; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yRe5c8esBZsh9BRXsvxYZhdlLr/5NBq1Hog5ncWmmco=; b=fEFSIa56KY/s7izWna+dlTjcOLk+zLt6i051gvUc1Bz5yzZtlbNltblLl+W6OskGtBeFKXEbd+KvBU+bHFXUaspnFZDfu+N+z53aIeS6SfMnX7xJplM0lj4unckWaJ3+VKO4ViNHaVok26O/0rz6MXyV91nj5ypncok7k88Eo9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568748334789.3750380939039; Thu, 7 Aug 2025 05:12:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRx-00026G-F4; Thu, 07 Aug 2025 08:10:26 -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 1ujzRD-0007xL-1A; Thu, 07 Aug 2025 08:09:41 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzR7-00058G-1A; Thu, 07 Aug 2025 08:09:37 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:31 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:28 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568573; x=1786104573; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KAVkpOsUfhfxB9jH1McPSIECphxKPwK1MhbX0BF1360=; b=kj9izV4nwjfDGiQvfN31w+sr5r/HsEKjgM+EJbaf47btJdravT9KDQzw sh//UJh1fZfHBy2YfXMJFhrVzCnE6PoB+9wLFOuAlCAjIfzxUFmosdYkL TVUaPtTxdn22OsvPFlTB1nY9lFoEtLOXFXUPJ+ySiDkXu837uGTr5HK3I kG+uvS7vN79InWa1Lat2bGl6scNamzk9N8Ubq2Ang7vLRNmtQ/nSEpaw+ Y/UbjK4i2sqQ6TGskWDkdCQxz9BVQKQFthWQF0IK/Bz6huvk3wEtUqgda Zqz1a0JoPHMdPX69FLNazXBjuETUIz2x7jFkWosWg5aoJJx10EcJZ1PQ5 g==; X-CSE-ConnectionGUID: kPqQZDh7SlGerl9pw2AVLA== X-CSE-MsgGUID: 4uTB3dGWSsGX7Rt8xLYVTA== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036775" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036775" X-CSE-ConnectionGUID: dZ4OSF5MRWa+yUK8vLk8qQ== X-CSE-MsgGUID: UJA19qDJQDGeh6BxxKqNEQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701104" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 09/26] rust: Add vm-memory in meson Date: Thu, 7 Aug 2025 20:30:10 +0800 Message-Id: <20250807123027.2910950-10-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.com X-Spam_score_int: -39 X-Spam_score: -4.0 X-Spam_bar: ---- X-Spam_report: (-4.0 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568749030116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- rust/meson.build | 2 ++ rust/qemu-api/meson.build | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/rust/meson.build b/rust/meson.build index 331f11b7e72a..b7d151fb0349 100644 --- a/rust/meson.build +++ b/rust/meson.build @@ -3,12 +3,14 @@ subproject('bilge-0.2-rs', required: true) subproject('bilge-impl-0.2-rs', required: true) subproject('foreign-0.3-rs', required: true) subproject('libc-0.2-rs', required: true) +subproject('vm-memory-0.16-rs', required: true) =20 anyhow_rs =3D dependency('anyhow-1-rs') bilge_rs =3D dependency('bilge-0.2-rs') bilge_impl_rs =3D dependency('bilge-impl-0.2-rs') foreign_rs =3D dependency('foreign-0.3-rs') libc_rs =3D dependency('libc-0.2-rs') +vm_memory_rs =3D dependency('vm-memory-0.16-rs') =20 subproject('proc-macro2-1-rs', required: true) subproject('quote-1-rs', required: true) diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index a090297c458b..a362d44ed396 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -79,8 +79,8 @@ _qemu_api_rs =3D static_library( override_options: ['rust_std=3D2021', 'build.rust_std=3D2021'], rust_abi: 'rust', rust_args: _qemu_api_cfg, - dependencies: [anyhow_rs, foreign_rs, libc_rs, qemu_api_macros, qemuutil= _rs, - qom, hwcore, chardev, migration], + dependencies: [anyhow_rs, foreign_rs, libc_rs, vm_memory_rs, qemu_api_ma= cros, + qemuutil_rs, qom, hwcore, chardev, migration], ) =20 rust.test('rust-qemu-api-tests', _qemu_api_rs, --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568735; cv=none; d=zohomail.com; s=zohoarc; b=l1H5jPyJuBcvLOGPkV5Vd1XUW1tdY9esJz+o1LsI4CJAai4kH8o0WrzdK1/HFU0vHS9fGxJ3/DfDV/oomD42FhPLSs+xmi9i1ZsvpSOyN9Mgv40FL8QT77PO3K7DkhrFM5bTcMaxLddVhIeW7ym9ao7At77do2yQCqkE2Pted/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568735; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NNYsiC1p6bMiwWlulGMH+f+f/GLMxGDyQGI7yMTFRfM=; b=BDx62dAdpNYV1lTR1S+3hi9tG5izpK0pppWSElw+nlaknZgpq1jqXyHU7RXiBSYXK0Yc5CojkTugVyAR2nxPGIeq5J/klImc/df6E4UA3heIr6J3tVuLjF3E4R/lz/nEx8MOmxkbhBXbJ78ovLYJ9BFU3i/1xhwZ00WKBTp+3Kk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568735171808.8170584235602; Thu, 7 Aug 2025 05:12:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRs-0001Zi-Im; Thu, 07 Aug 2025 08:10:22 -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 1ujzRD-0007xZ-2A; Thu, 07 Aug 2025 08:09:41 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzR9-00058l-L4; Thu, 07 Aug 2025 08:09:37 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:34 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:31 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568576; x=1786104576; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IcxfGX15IY6iFsOKxfs10AFkyWYMXNZqJnwjVx46zZc=; b=f+BtDV4UTcs+iFp/3IsfJt6z9VQDjG/BapuICwVPVJ/Z8pnksyXLB1TJ q1mHNS1Wj1ga9/RjaElYP2m/zWO1HYst68pizeOhpuSo9HqXX09qRyoSH AbjrbKFrSM/pdo7Gbc6nX5tIDppWlQJ6FCvRkVr9UI99qLXwdZYWaxuII gFh0Cpq2z3EQjavjW40LUbsh882RqO3pWMCjESbtwDUxjJwhHXV04B+6z cLqKn03vuv+2RyjRv8cGlYiimw3teBr8uYsgJxnbM2vaNkXb/3q+3lDzh iQgljXj5o4QQXId6mAtFuwA6Hol9a3a/YKuPIOMbW8ZqyNGw0RImFSulw g==; X-CSE-ConnectionGUID: gRCeL4+aQxW+I24AUM+GLA== X-CSE-MsgGUID: 4IMNRqXOQyGiTtnwuMX0DQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036785" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036785" X-CSE-ConnectionGUID: mvEPT2R8R6WHRfp7AlWChg== X-CSE-MsgGUID: DlHmuEwnTeuxQDQ7EjUj4A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701119" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 10/26] subprojects/vm-memory: Patch vm-memory for QEMU memory backend Date: Thu, 7 Aug 2025 20:30:11 +0800 Message-Id: <20250807123027.2910950-11-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568737509116600 Content-Type: text/plain; charset="utf-8" Add 2 patches to support QEMU memory backend implementation. Signed-off-by: Zhao Liu --- .../packagefiles/vm-memory-0.16-rs/0001.diff | 81 +++++++++++++ .../packagefiles/vm-memory-0.16-rs/0002.diff | 111 ++++++++++++++++++ subprojects/vm-memory-0.16-rs.wrap | 2 + 3 files changed, 194 insertions(+) create mode 100644 subprojects/packagefiles/vm-memory-0.16-rs/0001.diff create mode 100644 subprojects/packagefiles/vm-memory-0.16-rs/0002.diff diff --git a/subprojects/packagefiles/vm-memory-0.16-rs/0001.diff b/subproj= ects/packagefiles/vm-memory-0.16-rs/0001.diff new file mode 100644 index 000000000000..037193108d45 --- /dev/null +++ b/subprojects/packagefiles/vm-memory-0.16-rs/0001.diff @@ -0,0 +1,81 @@ +From 298f8ba019b2fe159fa943e0ae4dfd3c83ee64e0 Mon Sep 17 00:00:00 2001 +From: Zhao Liu +Date: Wed, 6 Aug 2025 11:31:11 +0800 +Subject: [PATCH 1/2] guest_memory: Add a marker tarit to implement + Bytes for GuestMemory + +At present, Bytes is implemented as the blanet trait for +all types which implemented GuestMemory. + +QEMU needs to customize its own Bytes implementation. + +So add a marker trait to still provide the default implementation for +GuestRegionCollection and GuestMemoryMmap, and QEMU could have its own +implementation. + +Signed-off-by: Zhao Liu +--- + src/guest_memory.rs | 8 +++++++- + src/lib.rs | 2 +- + src/region.rs | 6 ++++-- + 3 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/guest_memory.rs b/src/guest_memory.rs +index 39e4f10a89d6..5b78038c3c92 100644 +--- a/src/guest_memory.rs ++++ b/src/guest_memory.rs +@@ -457,7 +457,13 @@ pub trait GuestMemory { + } + } +=20 +-impl Bytes for T { ++/// A marker trait that if implemented on a type `M` makes available a de= fault ++/// implementation of `Bytes` for `M`, based on the assumpt= ion ++/// that the entire `GuestMemory` is just traditional Guest memory abstra= ction ++/// without any special access requirements. ++pub trait GuestMemoryBytes: GuestMemory {} ++ ++impl Bytes for M { + type E =3D Error; +=20 + fn write(&self, buf: &[u8], addr: GuestAddress) -> Result { +diff --git a/src/lib.rs b/src/lib.rs +index 2f87f4c8482f..64ed3ec27a36 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -47,7 +47,7 @@ pub use endian::{Be16, Be32, Be64, BeSize, Le16, Le32, L= e64, LeSize}; + pub mod guest_memory; + pub use guest_memory::{ + Error as GuestMemoryError, FileOffset, GuestAddress, GuestAddressSpac= e, GuestMemory, +- GuestUsize, MemoryRegionAddress, Result as GuestMemoryResult, ++ GuestMemoryBytes, GuestUsize, MemoryRegionAddress, Result as GuestMem= oryResult, + }; +=20 + pub mod region; +diff --git a/src/region.rs b/src/region.rs +index e716a6290e75..7114dfbe15a7 100644 +--- a/src/region.rs ++++ b/src/region.rs +@@ -3,8 +3,8 @@ + use crate::bitmap::{Bitmap, BS}; + use crate::guest_memory::Result; + use crate::{ +- Address, AtomicAccess, Bytes, FileOffset, GuestAddress, GuestMemory, = GuestMemoryError, +- GuestUsize, MemoryRegionAddress, ReadVolatile, VolatileSlice, WriteVo= latile, ++ Address, AtomicAccess, Bytes, FileOffset, GuestAddress, GuestMemory, = GuestMemoryBytes, ++ GuestMemoryError, GuestUsize, MemoryRegionAddress, ReadVolatile, Vola= tileSlice, WriteVolatile, + }; + use std::sync::atomic::Ordering; + use std::sync::Arc; +@@ -322,6 +322,8 @@ impl GuestMemory for GuestRegion= Collection { + } + } +=20 ++impl GuestMemoryBytes for GuestRegionCollection = {} ++ + /// A marker trait that if implemented on a type `R` makes available a de= fault + /// implementation of `Bytes` for `R`, based on the = assumption + /// that the entire `GuestMemoryRegion` is just traditional memory withou= t any +--=20 +2.34.1 + diff --git a/subprojects/packagefiles/vm-memory-0.16-rs/0002.diff b/subproj= ects/packagefiles/vm-memory-0.16-rs/0002.diff new file mode 100644 index 000000000000..bfef1bf1fee3 --- /dev/null +++ b/subprojects/packagefiles/vm-memory-0.16-rs/0002.diff @@ -0,0 +1,111 @@ +From 2af7ea12a589fde619690e5060c01710cb6f2e0e Mon Sep 17 00:00:00 2001 +From: Zhao Liu +Date: Wed, 6 Aug 2025 14:27:14 +0800 +Subject: [PATCH 2/2] guest_memory: Add is_write argument for + GuestMemory::try_access() + +QEMU needs to know whether the memory access is for write or not, e.g., +memory region may be read-only, or iommu needs to distinguish write +access. + +The alternative option is to move try_access() into Bytes trait, and +implement Bytes<(GuestAddress, is_write)> for QEMU's GuestMemory +abstraction. However, try_access() seems to lack generality in the +abstraction of Bytes, as only GuestMemory needs it. + +Therefore, just add another argument in try_access() to help handle +more complex memory backend. + +Signed-off-by: Zhao Liu +--- + src/bitmap/mod.rs | 17 +++++++++++------ + src/guest_memory.rs | 10 ++++++---- + 2 files changed, 17 insertions(+), 10 deletions(-) + +diff --git a/src/bitmap/mod.rs b/src/bitmap/mod.rs +index cf1555b29350..de4203166304 100644 +--- a/src/bitmap/mod.rs ++++ b/src/bitmap/mod.rs +@@ -287,12 +287,17 @@ pub(crate) mod tests { + // Finally, let's invoke the generic tests for `Bytes`. + let check_range_closure =3D |m: &M, start: usize, len: usize, cle= an: bool| -> bool { + let mut check_result =3D true; +- m.try_access(len, GuestAddress(start as u64), |_, size, reg_a= ddr, reg| { +- if !check_range(®.bitmap(), reg_addr.0 as usize, size,= clean) { +- check_result =3D false; +- } +- Ok(size) +- }) ++ m.try_access( ++ len, ++ GuestAddress(start as u64), ++ false, ++ |_, size, reg_addr, reg| { ++ if !check_range(®.bitmap(), reg_addr.0 as usize, s= ize, clean) { ++ check_result =3D false; ++ } ++ Ok(size) ++ }, ++ ) + .unwrap(); +=20 + check_result +diff --git a/src/guest_memory.rs b/src/guest_memory.rs +index 5b78038c3c92..53981c4e8e94 100644 +--- a/src/guest_memory.rs ++++ b/src/guest_memory.rs +@@ -353,7 +353,7 @@ pub trait GuestMemory { +=20 + /// Check whether the range [base, base + len) is valid. + fn check_range(&self, base: GuestAddress, len: usize) -> bool { +- match self.try_access(len, base, |_, count, _, _| -> Result { Ok(count) }) { ++ match self.try_access(len, base, false, |_, count, _, _| -> Resul= t { Ok(count) }) { + Ok(count) =3D> count =3D=3D len, + _ =3D> false, + } +@@ -374,7 +374,7 @@ pub trait GuestMemory { + /// - the error code returned by the callback 'f' + /// - the size of the already handled data when encountering the firs= t hole + /// - the size of the already handled data when the whole range has b= een handled +- fn try_access(&self, count: usize, addr: GuestAddress, mut f: F) -= > Result ++ fn try_access(&self, count: usize, addr: GuestAddress, _is_write: = bool, mut f: F) -> Result + where + F: FnMut(usize, usize, MemoryRegionAddress, &Self::R) -> Result, + { +@@ -470,6 +470,7 @@ impl Bytes= for M { + self.try_access( + buf.len(), + addr, ++ true, + |offset, _count, caddr, region| -> Result { + region.write(&buf[offset..], caddr) + }, +@@ -480,6 +481,7 @@ impl Bytes= for M { + self.try_access( + buf.len(), + addr, ++ false, + |offset, _count, caddr, region| -> Result { + region.read(&mut buf[offset..], caddr) + }, +@@ -547,7 +549,7 @@ impl Bytes= for M { + where + F: ReadVolatile, + { +- self.try_access(count, addr, |_, len, caddr, region| -> Result { ++ self.try_access(count, addr, false, |_, len, caddr, region| -> Re= sult { + region.read_volatile_from(caddr, src, len) + }) + } +@@ -575,7 +577,7 @@ impl Bytes= for M { + where + F: WriteVolatile, + { +- self.try_access(count, addr, |_, len, caddr, region| -> Result { ++ self.try_access(count, addr, true, |_, len, caddr, region| -> Res= ult { + // For a non-RAM region, reading could have side effects, so = we + // must use write_all(). + region.write_all_volatile_to(caddr, dst, len).map(|()| len) +--=20 +2.34.1 + diff --git a/subprojects/vm-memory-0.16-rs.wrap b/subprojects/vm-memory-0.1= 6-rs.wrap index a057c8c9efc1..592271300294 100644 --- a/subprojects/vm-memory-0.16-rs.wrap +++ b/subprojects/vm-memory-0.16-rs.wrap @@ -8,5 +8,7 @@ revision =3D 5eb996a060d7ca3844cbd2f10b1d048c0c91942f patch_directory =3D vm-memory-0.16-rs depth =3D 1 =20 +diff_files =3D vm-memory-0.16-rs/0001.diff, vm-memory-0.16-rs/0002.diff + # bump this version number on every change to meson.build or the patches: # v2 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568681; cv=none; d=zohomail.com; s=zohoarc; b=dvU4snhilmuQJW+EhxdCiqW9bVVNZxUOnd+saZpj+DveH16F8/ISgbwdZG2OavLcuvBEnck8E7GPUKaX0Q7ShndRKupSy0cLi+DFYBCvJGMoqVrzLnS2MAhYPA7XxCoHgmPkg3/4pH0hawKYaPVo3iPtE2qlj2cvxNWwWO6HG5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568681; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=jCKVp5eIFZsTeTQjCigPNOh8OcoS0FoHxZsnDSl70EA=; b=LkDaeKrWp7Xq61EoKa29O2aea52Ipa/b1xaK56/wPT2qtwKSM6IXCYBaULY4Ki5fWclg472qDH1INGxnVErUPkTm8tZQ130e0Fh0SOo2YYQOU1hD5XR0blN4l+633LTbgskSxmO6CAdf0DaujW2Ucw/3uoM/usQsmBgfZ2jvoHY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568681281402.46360642778234; Thu, 7 Aug 2025 05:11:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzS9-0003B7-Vc; Thu, 07 Aug 2025 08:10:38 -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 1ujzRH-000860-2B; Thu, 07 Aug 2025 08:09:44 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRD-00059l-HN; Thu, 07 Aug 2025 08:09:42 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:37 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:35 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568579; x=1786104579; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+2PPqAmGP2afLZuYwnnBLPtIfko7sfve40L5NTEpw5c=; b=UbG1DQR+04lNsiVHiiD4OqmtRO3BXYCD+iCW4d9HZujDj3AnmdAl6yYn U18Axp+1OJ9TbScb9OrPTtksuqN+sIMsdtYvhP6S8I0QllyxLq95aav11 BRGE1gFsdCzli0dEMPVnYFRWPpH7f2NVx2MaFh3qojkWtF/yVhiESwVKy bU8VsHzxs+VN7e3A0N15QwF6z/eG51UMP7edU7cpYdoCuAOSRokM3va+x n3/aDTV4zNSRXg1C5SFaRl6vWUdt5mer3UHjbPakaoce6Dlou9cPA9n0X 779UZ0QZPtuTOnJIph3dJzZ7d2/S6ekd9udT3cKwHyo0LsVLfG4GL6P4+ g==; X-CSE-ConnectionGUID: gvJvcOGmQ1e0tv9Leoeblg== X-CSE-MsgGUID: yZHVuPUgR+y642yn3bVE1A== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036790" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036790" X-CSE-ConnectionGUID: PIMXtGVjQdGLyEtidg3p6Q== X-CSE-MsgGUID: sYn8Zyr0S9mIya0bZk6/yg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701125" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 11/26] rust/cargo: Specify the patched vm-memory crate Date: Thu, 7 Aug 2025 20:30:12 +0800 Message-Id: <20250807123027.2910950-12-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568682296124100 Content-Type: text/plain; charset="utf-8" Signed-off-by: Zhao Liu --- rust/Cargo.lock | 1 - rust/Cargo.toml | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 7aedae239f66..f1bb2457e133 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -200,7 +200,6 @@ checksum =3D "49874b5167b65d7193b8aba1567f5c7d93d001caf= c34600cee003eda787e483f" [[package]] name =3D "vm-memory" version =3D "0.16.1" -source =3D "git+https://github.com/rust-vmm/vm-memory.git?rev=3D5eb996a060= d7ca3844cbd2f10b1d048c0c91942f#5eb996a060d7ca3844cbd2f10b1d048c0c91942f" dependencies =3D [ "thiserror", "winapi", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 0868e1b42680..ecb31647f93b 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -15,6 +15,9 @@ license =3D "GPL-2.0-or-later" repository =3D "https://gitlab.com/qemu-project/qemu/" rust-version =3D "1.77.0" =20 +[patch."https://github.com/rust-vmm/vm-memory.git"] +vm-memory =3D { path =3D "./../subprojects/vm-memory-0.16" } + [workspace.lints.rust] unexpected_cfgs =3D { level =3D "deny", check-cfg =3D [ 'cfg(MESON)', 'cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)', --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569211; cv=none; d=zohomail.com; s=zohoarc; b=WKEiWMuGRSrwcXGrqfbUtdTzq4ir8jUFY7n4z4Rh492xUWK/jqXc82GYsQ+DRbjpHApTBgTXyHm3fWvVzwUZ1pRumLsBDdlxL0pcYCsu5BJas3gXaBIK2N4mJgDNZ4FO284vRBKY6y8lKKUXr0FM3ibTaET6qL6syn36+15wLOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569211; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=TqHnJC7J41evATXXnbanKqB+th7IGNlKKXe+k9cRHOM=; b=Mh/IC0jr+L5oszEf+Sqbti9gPXhjoFDWWxWAq/xPMXFkgrnPHPjo4IXWWvfPPNV+0GhIRUzOZqTE9FzwqJ+rrAJGuFxYvI0k4WMVCDRxw86PRr4i82XrrQboPX9wUYVoPKVMHZG4Hs8ic/sTQCW179QnCHMwXZ37xkN86CZPAjM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569211922481.1733956672789; Thu, 7 Aug 2025 05:20:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSD-0003Ze-Vm; Thu, 07 Aug 2025 08:10: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 1ujzRJ-0008Al-F9; Thu, 07 Aug 2025 08:09:46 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRH-0005AS-Gp; Thu, 07 Aug 2025 08:09:45 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:41 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568583; x=1786104583; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0eAU/mU1IVyjxZrqAptdRp3Py54WmvSs7NPummwpoe0=; b=adfinu97wpid4tu8RwagqTUEC9YSyE7kW/Hm+J3G5o7o0bJwgedPF2ig zMoMt1pgeJdKWxRFAyOOHDljTPa4er5eAAL5eJOGEvnXGLiEK0lufvRZs G2XbPeya8rrrcE8WP1CmBt+o8+YwYtsa6Lswd84620+3LJ3xIYfCTvmdZ flgZ9CmYS26nbx1kswC8Qs4EPXIJMzZGizQ/PCvVFK/wBieoVV4c3xVRs i8z8lCqSV8aF5ShARKDw6+u1ymjKWc5Eref2aw37c4L7q5YrgE3NJCrps bC2tjmZ7kNLpC8eg/BOVs7042zEjkWez9DwUtY//wmtM9EoAygOdq3VkA Q==; X-CSE-ConnectionGUID: ZfHCbucORMSzo8jsj30oYg== X-CSE-MsgGUID: 0/aJEPCBQB+/FXvm0mZCCw== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036799" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036799" X-CSE-ConnectionGUID: eOAHi3cMTLWg6dG0LYe7YQ== X-CSE-MsgGUID: Q8vO1LQFT5WLmLedjY/kQg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701129" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 12/26] rcu: Make rcu_read_lock & rcu_read_unlock not inline Date: Thu, 7 Aug 2025 20:30:13 +0800 Message-Id: <20250807123027.2910950-13-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569214716124100 Content-Type: text/plain; charset="utf-8" Make rcu_read_lock & rcu_read_unlock not inline, then bindgen could generate the bindings. Suggested-by: Paolo Bonzini Signed-off-by: Zhao Liu --- include/qemu/rcu.h | 45 ++------------------------------------------- util/rcu.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 43 deletions(-) diff --git a/include/qemu/rcu.h b/include/qemu/rcu.h index 020dbe4d8b77..34d955204b81 100644 --- a/include/qemu/rcu.h +++ b/include/qemu/rcu.h @@ -75,49 +75,8 @@ struct rcu_reader_data { =20 QEMU_DECLARE_CO_TLS(struct rcu_reader_data, rcu_reader) =20 -static inline void rcu_read_lock(void) -{ - struct rcu_reader_data *p_rcu_reader =3D get_ptr_rcu_reader(); - unsigned ctr; - - if (p_rcu_reader->depth++ > 0) { - return; - } - - ctr =3D qatomic_read(&rcu_gp_ctr); - qatomic_set(&p_rcu_reader->ctr, ctr); - - /* - * Read rcu_gp_ptr and write p_rcu_reader->ctr before reading - * RCU-protected pointers. - */ - smp_mb_placeholder(); -} - -static inline void rcu_read_unlock(void) -{ - struct rcu_reader_data *p_rcu_reader =3D get_ptr_rcu_reader(); - - assert(p_rcu_reader->depth !=3D 0); - if (--p_rcu_reader->depth > 0) { - return; - } - - /* Ensure that the critical section is seen to precede the - * store to p_rcu_reader->ctr. Together with the following - * smp_mb_placeholder(), this ensures writes to p_rcu_reader->ctr - * are sequentially consistent. - */ - qatomic_store_release(&p_rcu_reader->ctr, 0); - - /* Write p_rcu_reader->ctr before reading p_rcu_reader->waiting. */ - smp_mb_placeholder(); - if (unlikely(qatomic_read(&p_rcu_reader->waiting))) { - qatomic_set(&p_rcu_reader->waiting, false); - qemu_event_set(&rcu_gp_event); - } -} - +void rcu_read_lock(void); +void rcu_read_unlock(void); void synchronize_rcu(void); =20 /* diff --git a/util/rcu.c b/util/rcu.c index b703c86f15a3..2dfd82796e1e 100644 --- a/util/rcu.c +++ b/util/rcu.c @@ -141,6 +141,49 @@ static void wait_for_readers(void) QLIST_SWAP(®istry, &qsreaders, node); } =20 +void rcu_read_lock(void) +{ + struct rcu_reader_data *p_rcu_reader =3D get_ptr_rcu_reader(); + unsigned ctr; + + if (p_rcu_reader->depth++ > 0) { + return; + } + + ctr =3D qatomic_read(&rcu_gp_ctr); + qatomic_set(&p_rcu_reader->ctr, ctr); + + /* + * Read rcu_gp_ptr and write p_rcu_reader->ctr before reading + * RCU-protected pointers. + */ + smp_mb_placeholder(); +} + +void rcu_read_unlock(void) +{ + struct rcu_reader_data *p_rcu_reader =3D get_ptr_rcu_reader(); + + assert(p_rcu_reader->depth !=3D 0); + if (--p_rcu_reader->depth > 0) { + return; + } + + /* Ensure that the critical section is seen to precede the + * store to p_rcu_reader->ctr. Together with the following + * smp_mb_placeholder(), this ensures writes to p_rcu_reader->ctr + * are sequentially consistent. + */ + qatomic_store_release(&p_rcu_reader->ctr, 0); + + /* Write p_rcu_reader->ctr before reading p_rcu_reader->waiting. */ + smp_mb_placeholder(); + if (unlikely(qatomic_read(&p_rcu_reader->waiting))) { + qatomic_set(&p_rcu_reader->waiting, false); + qemu_event_set(&rcu_gp_event); + } +} + void synchronize_rcu(void) { QEMU_LOCK_GUARD(&rcu_sync_lock); --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568637; cv=none; d=zohomail.com; s=zohoarc; b=DGWagYuj1MwhIucnCdLs+lW2c4tgD7YEVjOg6T/QTOx4d/vdZWtMAVFIIs8txCPxybfuNspyjodMMpTHTgqVSpZS4Lz5+6ExWDI8J4qZ7Cllxfd1U0hum/8Voyt1piGFtMJF4Js80609j7SuxY8aCQ/ZYUs327qeC+Y5WOcEn/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568637; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=GpKqyyjHcFVZoVFtD5khq6zvMzHRpU0caKNY19ZD8SA=; b=UYgCi/0Syq0uEG8AL+XCM3fOw4CNhcInC16Ejs40ydEoSnRYgJgE4bLjDnUoTLglygk4qqHplm8WaBtykTF4Rcz/OQtqwiDT5IOlu/wdO0GqK44pHbpYBvRrLHsWVK7lxLgGEhhFeOExYBGeAajPpO+UMbmMsVt/P52NWqhzpNI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568637024160.99310708313476; Thu, 7 Aug 2025 05:10:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzRs-0001Ye-FS; Thu, 07 Aug 2025 08:10:21 -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 1ujzRM-0008QS-4d; Thu, 07 Aug 2025 08:09:48 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRJ-00059l-Ft; Thu, 07 Aug 2025 08:09:47 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:44 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:42 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568585; x=1786104585; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iavmaBU2SAHqBwyyDCas48yylc85Ev7Gp1UBZohijB8=; b=ZzFW7kwxkX2IrEYPo5lR+YYApuCtNyD8mjKXF8zdP4x8IJPD6ic5va/E MpiY8YnXTvKKrz/UsJivTMGr953lQj2IMy1BWiExKiZfYKus4T/5LvUYA 03lwqr3P6h3/hlOL5cYw21eTUD+/t8HnfAZpQtKMaqJVM1X93Bzw7Luk4 zub9MxFa+yzojUdG01vDxMvhZIpMBnXbCDe72kdjPK7cTZKaaXXWDI5bn s03vdkArLww9Azqz7Z5dpMLf6r7u/SSmc812AdPPwnldDUxFf0H4SLZxb 0vmCf1tpAdfAlubfEJm/riZ0zC5jSY3qG+32yqsZjdnvVWmPxsNYiHvbo w==; X-CSE-ConnectionGUID: oOWLFifkSlKNHP+cCfx41Q== X-CSE-MsgGUID: VbmcbZiGS4qPUvXx8iSzpQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036805" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036805" X-CSE-ConnectionGUID: VS83TYczTT2gR/VOhmLfQg== X-CSE-MsgGUID: qC0+2r7dStWdMJwsds8MUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701132" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 13/26] rust: Add RCU bindings Date: Thu, 7 Aug 2025 20:30:14 +0800 Message-Id: <20250807123027.2910950-14-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568639533124100 Content-Type: text/plain; charset="utf-8" Add rcu_read_lock() & rcu_read_unlock() bindings, then they can be used in memory access. Suggested-by: Paolo Bonzini Signed-off-by: Zhao Liu --- rust/qemu-api/meson.build | 1 + rust/qemu-api/src/lib.rs | 1 + rust/qemu-api/src/rcu.rs | 26 ++++++++++++++++++++++++++ rust/qemu-api/wrapper.h | 1 + 4 files changed, 29 insertions(+) create mode 100644 rust/qemu-api/src/rcu.rs diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build index a362d44ed396..d40472092248 100644 --- a/rust/qemu-api/meson.build +++ b/rust/qemu-api/meson.build @@ -68,6 +68,7 @@ _qemu_api_rs =3D static_library( 'src/prelude.rs', 'src/qdev.rs', 'src/qom.rs', + 'src/rcu.rs', 'src/sysbus.rs', 'src/timer.rs', 'src/uninit.rs', diff --git a/rust/qemu-api/src/lib.rs b/rust/qemu-api/src/lib.rs index 86dcd8ef17a9..4705cf9ccbc5 100644 --- a/rust/qemu-api/src/lib.rs +++ b/rust/qemu-api/src/lib.rs @@ -26,6 +26,7 @@ pub mod module; pub mod qdev; pub mod qom; +pub mod rcu; pub mod sysbus; pub mod timer; pub mod uninit; diff --git a/rust/qemu-api/src/rcu.rs b/rust/qemu-api/src/rcu.rs new file mode 100644 index 000000000000..30d8b9e43967 --- /dev/null +++ b/rust/qemu-api/src/rcu.rs @@ -0,0 +1,26 @@ +// Copyright (C) 2025 Intel Corporation. +// Author(s): Zhao Liu +// SPDX-License-Identifier: GPL-2.0-or-later + +//! Bindings for `rcu_read_lock` and `rcu_read_unlock`. +//! More details about RCU in QEMU, please refer docs/devel/rcu.rst. + +use crate::bindings; + +/// Used by a reader to inform the reclaimer that the reader is +/// entering an RCU read-side critical section. +pub fn rcu_read_lock() { + // SAFETY: no return and no argument, everything is done at C side. + unsafe { bindings::rcu_read_lock() } +} + +/// Used by a reader to inform the reclaimer that the reader is +/// exiting an RCU read-side critical section. Note that RCU +/// read-side critical sections may be nested and/or overlapping. +pub fn rcu_read_unlock() { + // SAFETY: no return and no argument, everything is done at C side. + unsafe { bindings::rcu_read_unlock() } +} + +// FIXME: maybe we need rcu_read_lock_held() to check the rcu context, +// then make it possible to add assertion at any RCU critical section. diff --git a/rust/qemu-api/wrapper.h b/rust/qemu-api/wrapper.h index 15a1b19847f2..ce0ac8d3f550 100644 --- a/rust/qemu-api/wrapper.h +++ b/rust/qemu-api/wrapper.h @@ -69,3 +69,4 @@ typedef enum memory_order { #include "qemu/timer.h" #include "system/address-spaces.h" #include "hw/char/pl011.h" +#include "qemu/rcu.h" --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569132; cv=none; d=zohomail.com; s=zohoarc; b=Lscj5nGShnAzL1UGAJ0Y0xB48tDKoa436JbiBheXsYA4ymnB3/nXE6C7WFs0+pKI+agYxeL4QB0101CmaiSnx/qdJbC3Bu8uvz/oB8TEBJwWHxmTd/r4RHf6n3wCAy+F2lrl3RyC9q6MQToHsSEXYq2t5TtzLQ9xqMFkUWbS1CI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569132; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3ulRyLCscrhXn2g668fKQaK7DZpIscNwBAIsTBrhv1c=; b=RxopxJpQU5Kl2xjk1fQP/UCB0v67SqfMpGysjiKZntk/mihqG+8dGqYJ2GuUisAfFw7yIU/8nlnZyFPOLT363zkVHxJecA8Yv7sIvE55izFLpvxYd6p8Zm0CbsW8+Z9ucumF0H15Qdb8EeGlhe0H0yUO7UHesRaKr7nLSxrF+Jw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569131472163.69857343268382; Thu, 7 Aug 2025 05:18:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzS7-0002ym-5T; Thu, 07 Aug 2025 08:10:37 -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 1ujzRk-0001E9-0r; Thu, 07 Aug 2025 08:10:16 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRh-0005Bp-Rz; Thu, 07 Aug 2025 08:10:11 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:48 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:45 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568610; x=1786104610; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6OOXwbQJVmFdR82woS1dR8ruocVbES2DG+qHdDaUOcA=; b=jRaP2f3Hlu8aQogqs2HKjsWEerEd0nqawWKcPgLK/XmA6QlcZZS4pIN5 d1cUgh3qKxIKypUWWtWb8Fml0CtnS4njjqhCC5ltH8VJlSo5dV7xUcUqx UhmLpf/y5cmTEKaUTDSjlzQ/fPytopUj7JTv9y8DMcfhi5ApWTpg9aA2S 9yxe6U7/6Pskyk01h5YHMHmNcKuDPoOQ27VeAO+9o5nq+sim7AoKtt9EF Fy7/7Vvw31HAB/khLtkBtCZd9TeYW5pYAiwmLR68VMDBdBgrQ14l3Ze4r XU7Bcb8iuMqZf0xhJT1cCrZw7pEZwaXz9u0+c4UkKnnk3J1sEbj+fb42R A==; X-CSE-ConnectionGUID: 6XRjV1JzS3OdXJLFg8W/wA== X-CSE-MsgGUID: +zmjyEJ1TEOvkiikrluWYA== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036811" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036811" X-CSE-ConnectionGUID: jyeXBOXOSBOwEh2ZakcNyA== X-CSE-MsgGUID: UfTu5LChQJSVMyaGEkeRMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701135" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 14/26] memory: Expose interfaces about Flatview reference count to Rust side Date: Thu, 7 Aug 2025 20:30:15 +0800 Message-Id: <20250807123027.2910950-15-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569134861124100 Content-Type: text/plain; charset="utf-8" Expose the following interfaces in include/system/memory.h without `inline`: * address_space_to_flatview * flatview_ref * flatview_unref Then Rust side could generate related bindings. In addtion, add documentations for these 3 interface. Signed-off-by: Zhao Liu --- include/system/memory.h | 69 +++++++++++++++++++++++++++++++++++++--- system/memory-internal.h | 1 - system/memory.c | 7 +++- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index e2cd6ed12614..4b9a2f528d86 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1203,10 +1203,71 @@ struct FlatView { MemoryRegion *root; }; =20 -static inline FlatView *address_space_to_flatview(AddressSpace *as) -{ - return qatomic_rcu_read(&as->current_map); -} +/** + * address_space_to_flatview: Get a transient RCU-protected pointer to + * the current FlatView. + * + * @as: The #AddressSpace to be accessed. + * + * This function retrieves a pointer to the current #FlatView for the + * given #AddressSpace. + * + * Note: This is a low-level, RCU-based accessor. It DOES NOT increment + * the FlatView's reference count. The returned pointer is only + * guaranteed to be valid within an RCU read-side critical section. + * + * Difference from address_space_get_flatview(): + * + * For address_space_to_flatview() (this function), it is a lightweight + * "peek" operation. It is fast but unsafe for long-term use. Use it + * only for very short-lived access where performance is critical. + * + * For address_space_get_flatview(), it acquires a "strong" reference + * by safely incrementing the reference count. The returned pointer is + * stable and can be used for long-lived operations, even outside an + * RCU lock. It is the safer and generally preferred method, but it + * MUST be paired with a call to flatview_unref() after the use of + * #FlatView. + * + * Returns: + * A transient pointer to the current #FlatView, valid only under RCU + * protection. + */ +FlatView *address_space_to_flatview(AddressSpace *as); + +/** + * flatview_ref: Atomically increment the reference count of #FlatView. + * + * @view: The #FlatView whose reference count is to be incremented. + * + * This function attempts to atomically increment the reference count + * of the given @view. This operation is conditional and will only + * succeed if the current reference count is non-zero. + * + * A non-zero reference count indicates that the FlatView is live and + * in use. If the reference count is already zero, it indicates that the + * FlatView is being deinitialized, and no new references can be + * acquired. + * + * Returns: + * 'true' if the reference count was successfully incremented (i.e., it + * was non-zero before the call). + * 'false' if the reference count was already zero and could not be + * incremented. + */ +bool flatview_ref(FlatView *view); + +/** + * flatview_unref: Atomically decrement the reference count of + * #FlatView. + * + * @view: The #FlatView to be unreferenced. + * + * This function atomically decrements the reference count of the given + * @view. When the reference count drops to zero, #FlatView will be + * destroied via RCU. + */ +void flatview_unref(FlatView *view); =20 /** * typedef flatview_cb: callback for flatview_for_each_range() diff --git a/system/memory-internal.h b/system/memory-internal.h index 46f758fa7e47..b0870a6359c3 100644 --- a/system/memory-internal.h +++ b/system/memory-internal.h @@ -26,7 +26,6 @@ static inline AddressSpaceDispatch *address_space_to_disp= atch(AddressSpace *as) } =20 FlatView *address_space_get_flatview(AddressSpace *as); -void flatview_unref(FlatView *view); =20 extern const MemoryRegionOps unassigned_mem_ops; =20 diff --git a/system/memory.c b/system/memory.c index 56465479406f..2a749081fb50 100644 --- a/system/memory.c +++ b/system/memory.c @@ -304,7 +304,7 @@ static void flatview_destroy(FlatView *view) g_free(view); } =20 -static bool flatview_ref(FlatView *view) +bool flatview_ref(FlatView *view) { return qatomic_fetch_inc_nonzero(&view->ref) > 0; } @@ -818,6 +818,11 @@ static void address_space_add_del_ioeventfds(AddressSp= ace *as, } } =20 +FlatView *address_space_to_flatview(AddressSpace *as) +{ + return qatomic_rcu_read(&as->current_map); +} + FlatView *address_space_get_flatview(AddressSpace *as) { FlatView *view; --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569183; cv=none; d=zohomail.com; s=zohoarc; b=DXjy3VkyWYcyb9YuNa935KCnxmNKpy3mGrUsR/vB0EbaLMrGSR06C0mcmKZNX3dUP8u2V/bbk7hxWMZEAzu6uPsc1oyVbe7ZEI7auIkDhDTNI5FKeVku7mfPdC4CTXQZy6pK52M7pleD0skCVpiJY0RZycohOn7sc3KeuAmQK8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569183; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kK+kfqFA9l2hbNjeQAxVPje77a1H4oZhVis+bKVwDCA=; b=SkCAWnXVsqGpwzqyt9znqsBfEo0jE0D1O4BmQqIN3k/NEhy0xWApMmOzHe2UUlw8SKcS4NNIqUPJVZ4dN7ZeZGxmDfbjUEvtU80vDLsG08+7i4KpumZgXMe4JM1ml4AgArWCnuJp5yovBVw2beQZMMmE+s3SCw/1NjGrMIFDgus= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 17545691832808.126958807851224; Thu, 7 Aug 2025 05:19:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSD-0003Op-6F; Thu, 07 Aug 2025 08:10:41 -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 1ujzRs-0001eY-Mk; Thu, 07 Aug 2025 08:10:22 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRm-0005Bt-Nt; Thu, 07 Aug 2025 08:10:20 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:51 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:49 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568615; x=1786104615; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lwh8w+q9CSmEJR/ei3K4JNynEwIGGgyYzFZQuK/O5nE=; b=LdKDLef9XNYlX8qeXbQMbubjWxxWQJcY+CwP6uSFBLiH+LNlK8NI3FwO ShMtCxq+TJBINDkRMD80HsES0XzNCOqML2PuY5xCmJuvONImHuqfWj6CT 055moh/cx4u3mPbJap2VPvDvaiAWtGklX1taH8b9BPgwitezVBeclxYZ1 KYeQz+JI6rABIJDTVPDItjOjr6Z7nG9hXcomWQZZRzmZj51h+CJILATWY VTYYZMDr0lGmJnIamfGCjjCKo42mA3HECKHtP6q0nOYhZFqz09gSJVBqs izI+p1ksZQ5ruKQ/LCzXfbjEDVt56TytYJN5o3WDPikWphEkYOXRCMFXe Q==; X-CSE-ConnectionGUID: c+Fz7rzYRAOObsqoIUeoXg== X-CSE-MsgGUID: OQw3OYUnRR24HGYGZGr/lQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036821" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036821" X-CSE-ConnectionGUID: nCwM6eKXQM+X0rYM57TvaQ== X-CSE-MsgGUID: OlQm2mK/RMOfq0vBSrb09w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701139" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 15/26] memory: Rename address_space_lookup_region and expose it to Rust side Date: Thu, 7 Aug 2025 20:30:16 +0800 Message-Id: <20250807123027.2910950-16-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569186857116600 Content-Type: text/plain; charset="utf-8" address_space_lookup_region() retures the pointer to MemoryRegionSection, instead of MemoryRegion, so it's better to rename it to address_space_lookup_section(). And add its declaration to memory.h so that bindgen could generate its binding. This interface will be used to implement GuestMemory::find_region() of vm_memory crate. In addition, add its documentation in memory.h. Signed-off-by: Zhao Liu --- include/system/memory.h | 21 +++++++++++++++++++++ system/physmem.c | 8 ++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 4b9a2f528d86..f492e1fc78bf 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -1203,6 +1203,27 @@ struct FlatView { MemoryRegion *root; }; =20 +/** + * address_space_lookup_section: Find the MemoryRegionSection by a + * given #AddressSpaceDispatch. + * + * @d: The AddressSpaceDispatch to search within. + * @addr: The address to look up. + * @resolve_subpage: If 'true', resolve to a subpage section if the + * region is a subpage container. + * + * This function translates a address (@addr) into its corresponding + * #MemoryRegionSection within a given address space dispatch (@d). + * Called within RCU critical section. + * + * Returns: + * A pointer to the #MemoryRegionSection. If the address is not + * mapped, this will be a pointer to the 'unassigned' section. + */ +MemoryRegionSection *address_space_lookup_section(AddressSpaceDispatch *d, + hwaddr addr, + bool resolve_subpage); + /** * address_space_to_flatview: Get a transient RCU-protected pointer to * the current FlatView. diff --git a/system/physmem.c b/system/physmem.c index e5dd760e0bca..785c9a4050c6 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -341,9 +341,9 @@ static MemoryRegionSection *phys_page_find(AddressSpace= Dispatch *d, hwaddr addr) } =20 /* Called from RCU critical section */ -static MemoryRegionSection *address_space_lookup_region(AddressSpaceDispat= ch *d, - hwaddr addr, - bool resolve_subpa= ge) +MemoryRegionSection *address_space_lookup_section(AddressSpaceDispatch *d, + hwaddr addr, + bool resolve_subpage) { MemoryRegionSection *section =3D qatomic_read(&d->mru_section); subpage_t *subpage; @@ -369,7 +369,7 @@ address_space_translate_internal(AddressSpaceDispatch *= d, hwaddr addr, hwaddr *x MemoryRegion *mr; Int128 diff; =20 - section =3D address_space_lookup_region(d, addr, resolve_subpage); + section =3D address_space_lookup_section(d, addr, resolve_subpage); /* Compute offset within MemoryRegionSection */ addr -=3D section->offset_within_address_space; =20 --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569181; cv=none; d=zohomail.com; s=zohoarc; b=YOKIpPfcpDh8C7or+qlsm4Moa8Z/8CW8FkkO1VHBW4mZPSuAFCChdnsZeS+NJK3Tas28TQr3bGly1EnC88PatAqrhcQgccvaWOJf3HgbfnmgAMbbyxQ0eCrZBk/IFqYT9aWwyAVbrZTy/qC/WpgIAndInHLpllsKAcFKH2n9a40= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569181; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RxWTSbrk2zLk8DAZx1et0aRrT29sEZnRs/aUhxfL+6U=; b=d0la/U/1Mn9QqI4bET1CnuRzOl6m1tynzVNyr6x1BXnVfvnUPi/19VYTpFiCNTSYdq+NiEf/p0xeVaPRwf443iJlTY59cn+xtWcSSXZRglFiIqZrQCKitPR4MpV4I+UR6Hg4NqjXTQAYSO/+sbZYRku8mNjQGjVNAM//M7C+P6Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569181504619.2951991587346; Thu, 7 Aug 2025 05:19:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSQ-0004Fh-61; Thu, 07 Aug 2025 08:10:54 -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 1ujzRu-0001rw-V7; Thu, 07 Aug 2025 08:10:23 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRp-0005Cn-Jw; Thu, 07 Aug 2025 08:10:22 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:55 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568618; x=1786104618; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lbnpK8OyGgwHu5vkc+8beR3dBNzfXQc8vRTwv8yoFE8=; b=OTpkRXBJWTwAThCzTt2mRXsSFC2YOoV7fqb69UeCUWd3h9UuOp18udKh Nwyg5UqFornxIvZuwta8g6v3AAvD0oDZoe4y1TKE9wIlKYqLDgrCo7Hgk gcwSfymOCqXKD/H01VphATrHrskMvcEz4KAd6QcW7sxnXgqS77vI7cZ3S MsCCAf1UetGQwBQcB/U8QgtchQPct6R7LxnjQug04B0WPIoWCtfUpXUAK hdrlRLxPDFdQCE8Nli5rdWAQHPmJOBjxrt6qFIn+9QJ/Aq4TNC/BCWDjN W7AbDY2WK1EXlVMn7vx405+nSNCUtqGGGzi/pbVZlhmf+r8hsgVpEnTbg A==; X-CSE-ConnectionGUID: l829pqP2QrKqNzOeHri9aQ== X-CSE-MsgGUID: j9VwhQD6RCe1cdpv3Q7+/Q== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036829" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036829" X-CSE-ConnectionGUID: d/BF90LjQYusZ5jvSUIDRQ== X-CSE-MsgGUID: vCBVfKaoToqbg8jWIBvAXg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701142" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 16/26] memory: Make flatview_do_translate() return a pointer to MemoryRegionSection Date: Thu, 7 Aug 2025 20:30:17 +0800 Message-Id: <20250807123027.2910950-17-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569184374124100 Content-Type: text/plain; charset="utf-8" Rust side will use cell::Opaque<> to hide details of C structure, and this could help avoid the direct operation on C memory from Rust side. Therefore, it's necessary to wrap a translation binding and make it only return the pointer to MemoryRegionSection, instead of the copy. As the first step, make flatview_do_translate return a pointer to MemoryRegionSection, so that we can build a wrapper based on it. In addtion, add a global variable `unassigned_section` to help get a pointer to an invalid MemoryRegionSection. Signed-off-by: Zhao Liu --- system/physmem.c | 51 ++++++++++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index 785c9a4050c6..4af29ea2168e 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -103,6 +103,9 @@ AddressSpace address_space_io; AddressSpace address_space_memory; =20 static MemoryRegion io_mem_unassigned; +static MemoryRegionSection unassigned_section =3D { + .mr =3D &io_mem_unassigned +}; =20 typedef struct PhysPageEntry PhysPageEntry; =20 @@ -418,14 +421,11 @@ address_space_translate_internal(AddressSpaceDispatch= *d, hwaddr addr, hwaddr *x * This function is called from RCU critical section. It is the common * part of flatview_do_translate and address_space_translate_cached. */ -static MemoryRegionSection address_space_translate_iommu(IOMMUMemoryRegion= *iommu_mr, - hwaddr *xlat, - hwaddr *plen_out, - hwaddr *page_mask= _out, - bool is_write, - bool is_mmio, - AddressSpace **ta= rget_as, - MemTxAttrs attrs) +static MemoryRegionSection * +address_space_translate_iommu(IOMMUMemoryRegion *iommu_mr, hwaddr *xlat, + hwaddr *plen_out, hwaddr *page_mask_out, + bool is_write, bool is_mmio, + AddressSpace **target_as, MemTxAttrs attrs) { MemoryRegionSection *section; hwaddr page_mask =3D (hwaddr)-1; @@ -463,10 +463,10 @@ static MemoryRegionSection address_space_translate_io= mmu(IOMMUMemoryRegion *iomm if (page_mask_out) { *page_mask_out =3D page_mask; } - return *section; + return section; =20 unassigned: - return (MemoryRegionSection) { .mr =3D &io_mem_unassigned }; + return &unassigned_section; } =20 /** @@ -489,15 +489,10 @@ unassigned: * * This function is called from RCU critical section */ -static MemoryRegionSection flatview_do_translate(FlatView *fv, - hwaddr addr, - hwaddr *xlat, - hwaddr *plen_out, - hwaddr *page_mask_out, - bool is_write, - bool is_mmio, - AddressSpace **target_as, - MemTxAttrs attrs) +static MemoryRegionSection * +flatview_do_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, hwaddr *ple= n_out, + hwaddr *page_mask_out, bool is_write, bool is_mmio, + AddressSpace **target_as, MemTxAttrs attrs) { MemoryRegionSection *section; IOMMUMemoryRegion *iommu_mr; @@ -523,14 +518,14 @@ static MemoryRegionSection flatview_do_translate(Flat= View *fv, *page_mask_out =3D ~TARGET_PAGE_MASK; } =20 - return *section; + return section; } =20 /* Called from RCU critical section */ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, bool is_write, MemTxAttrs attr= s) { - MemoryRegionSection section; + MemoryRegionSection *section; hwaddr xlat, page_mask; =20 /* @@ -542,13 +537,13 @@ IOMMUTLBEntry address_space_get_iotlb_entry(AddressSp= ace *as, hwaddr addr, attrs); =20 /* Illegal translation */ - if (section.mr =3D=3D &io_mem_unassigned) { + if (section->mr =3D=3D &io_mem_unassigned) { goto iotlb_fail; } =20 /* Convert memory region offset into address space offset */ - xlat +=3D section.offset_within_address_space - - section.offset_within_region; + xlat +=3D section->offset_within_address_space - + section->offset_within_region; =20 return (IOMMUTLBEntry) { .target_as =3D as, @@ -569,13 +564,13 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr= addr, hwaddr *xlat, MemTxAttrs attrs) { MemoryRegion *mr; - MemoryRegionSection section; + MemoryRegionSection *section; AddressSpace *as =3D NULL; =20 /* This can be MMIO, so setup MMIO bit. */ section =3D flatview_do_translate(fv, addr, xlat, plen, NULL, is_write, true, &as, attrs); - mr =3D section.mr; + mr =3D section->mr; =20 if (xen_enabled() && memory_access_is_direct(mr, is_write, attrs)) { hwaddr page =3D ((addr & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE) - a= ddr; @@ -3618,7 +3613,7 @@ static inline MemoryRegion *address_space_translate_c= ached( MemoryRegionCache *cache, hwaddr addr, hwaddr *xlat, hwaddr *plen, bool is_write, MemTxAttrs attrs) { - MemoryRegionSection section; + MemoryRegionSection *section; MemoryRegion *mr; IOMMUMemoryRegion *iommu_mr; AddressSpace *target_as; @@ -3636,7 +3631,7 @@ static inline MemoryRegion *address_space_translate_c= ached( section =3D address_space_translate_iommu(iommu_mr, xlat, plen, NULL, is_write, true, &target_as, attrs); - return section.mr; + return section->mr; } =20 /* Called within RCU critical section. */ --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569181; cv=none; d=zohomail.com; s=zohoarc; b=nstRd6rS8t3V7u3Sy5cZuOeGv4xxAE/zyFqh/W2uHH6nEc8NlqqNJrt8RCvW0K4EXtzSt7zVRWZp+PKcMWl9EYHUDffwlADjYLbik9GCxtTv/GjhRjeYgzXIEjnLHDjzaxjfMpEt2kkR2V3SAOTX/oBgddLCDOVgHMGqOHeMSAY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569181; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+5B+5RWWQWc75Kpf8u1yNzXz//6iLSLCReX9mQO3GP8=; b=SZmRAgrHAG0Byk0B9ZhgvpWaJMGwp6yJyOWt7x+i7Zfd6U1tPhw1SA4M0CE67fCx0Z/pCuHVqXajSsjW3H2MV3SPn2yISPY3tmg8sK38NPaVTfyssBEb1B9Msp0lkFJUDPL1JdMnkaMKI1YCQhiSOH8rn+W6Z8W/3cuGwiMIM5s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569181273404.0182027716064; Thu, 7 Aug 2025 05:19:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSM-0003x9-B6; Thu, 07 Aug 2025 08:10:50 -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 1ujzRt-0001fL-8z; Thu, 07 Aug 2025 08:10:22 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRp-0005Bp-4w; Thu, 07 Aug 2025 08:10:20 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:09:58 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:55 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568617; x=1786104617; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=3KxZHVVpZuvJRzJPVQgu9JT9Tqo8Scg+uw8X4qt5Us8=; b=D02IezYPQpoGui1bH8Ekm/y8ERe9bnSc38/98GvBklJWBdZAEQOcx7kl jDRg+p/DliN0wkcZ99YECl7ZKZbZ0QFmQenoeungJsepOZ8XM1d44dfVo sWcljCp6D7C2MN+pnnv2XuE8ZYCogp1sgPrqCeeEGgqmzTiNyCPdbkH/F YATSQeuOe1P8kfu7qLsZ8/xf68IKAJEPIpj07uqMn4b0vflLPRczLFURE PhtvHyYjbemuxyTKqefgHAJixd3MNeubsdNKstks4wRUhN+R8vpYoBGqN mmdHj7Ih0HfmCsmbGj+5AA99VPjQRbV0ymZ0BLIQ9sfrtYscfpWy9zxoP g==; X-CSE-ConnectionGUID: bBojlb6cSua20FBbUrvs2A== X-CSE-MsgGUID: 2O2R87YoRKaNafY6b/VOng== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036835" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036835" X-CSE-ConnectionGUID: xZXWfzx2QHifLiRELRwPMg== X-CSE-MsgGUID: RIi14K4UTd+HVPuuV1JsHQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701146" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 17/26] memory: Add a translation helper to return MemoryRegionSection Date: Thu, 7 Aug 2025 20:30:18 +0800 Message-Id: <20250807123027.2910950-18-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569182653116600 Content-Type: text/plain; charset="utf-8" Rust side will based on MemoryRegionSection to origanize non-overlapping memory "region" abstractions. So it's necessary to provide a translation variant helper to return the MemoryRegionSection directly. Additionally, refine and complete the documentations for translation helpers. Signed-off-by: Zhao Liu --- include/system/memory.h | 68 +++++++++++++++++++++++++++++++++++------ system/physmem.c | 22 ++++++++++--- 2 files changed, 77 insertions(+), 13 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index f492e1fc78bf..eab69e15e10f 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -3053,24 +3053,74 @@ void address_space_cache_destroy(MemoryRegionCache = *cache); IOMMUTLBEntry address_space_get_iotlb_entry(AddressSpace *as, hwaddr addr, bool is_write, MemTxAttrs attr= s); =20 -/* address_space_translate: translate an address range into an address spa= ce - * into a MemoryRegion and an address range into that section. Should be +/** + * flatview_translate_section: translate an guest physical address range + * to the corresponding MemoryRegionSection in Flatview. Should be * called from an RCU critical section, to avoid that the last reference - * to the returned region disappears after address_space_translate returns. - * - * @fv: #FlatView to be accessed - * @addr: address within that address space - * @xlat: pointer to address within the returned memory region section's - * #MemoryRegion. - * @len: pointer to length + * to the memory region (pointed by returned section) disappears after + * flatview_translate_section returns. + * + * @fv: the flat view to be accessed. + * @addr: the address to be translated in above address space. + * @xlat: the translated address offset within the returned section's + * #MemoryRegion. + * @len: pointer to length, and it will be changed to valid read/write + * length of the translated address after this function returns. * @is_write: indicates the transfer direction * @attrs: memory attributes + * + * Returns: + * The #MemoryRegionSection that contains the translated address + */ +MemoryRegionSection *flatview_translate_section(FlatView *fv, hwaddr addr, + hwaddr *xlat, hwaddr *len, + bool is_write, MemTxAttrs = attrs); + +/** + * flatview_translate: translate an guest physical address range + * to the corresponding MemoryRegionSection in Flatview. Should be + * called from an RCU critical section, to avoid that the last reference + * to the returned memory region disappears after flatview_translate + * returns. + * + * This function is the variant of flatview_translate_section(), with the + * difference that it returns the MemoryRegion contained in the + * MemoryRegionSection. + * + * @fv: the flat view to be accessed. + * @addr: the address to be translated in above address space. + * @xlat: the translated address offset within memory region. + * @len: pointer to length, and it will be changed to valid read/write + * length of the translated address after this function returns. + * @is_write: whether the translation operation is for write. + * @attrs: memory transaction attributes. + * + * Returns: + * The #MemoryRegion that contains the translated address. */ MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, hwaddr *len, bool is_write, MemTxAttrs attrs); =20 +/** + * address_space_translate: translate an guest physical address range + * to the corresponding MemoryRegionSection in Flatview. Should be + * called from an RCU critical section, to avoid that the last reference + * to the returned memory region disappears after flatview_translate + * returns. + * + * This function is the variant of flatview_translate(), with the differen= ce + * that it accesses the AddressSpace which contains FlatView. + * + * @as: #AddressSpace to be accessed + * @addr: the address to be translated in above address space. + * @xlat: the translated address offset within memory region. + * @len: pointer to length, and it will be changed to valid read/write + * length of the translated address after this function returns. + * @is_write: whether the translation operation is for write. + * @attrs: memory transaction attributes. + */ static inline MemoryRegion *address_space_translate(AddressSpace *as, hwaddr addr, hwaddr *x= lat, hwaddr *len, bool is_w= rite, diff --git a/system/physmem.c b/system/physmem.c index 4af29ea2168e..d2106d0ffa87 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -559,9 +559,9 @@ iotlb_fail: } =20 /* Called from RCU critical section */ -MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, - hwaddr *plen, bool is_write, - MemTxAttrs attrs) +MemoryRegionSection *flatview_translate_section(FlatView *fv, hwaddr addr, + hwaddr *xlat, hwaddr *plen, + bool is_write, MemTxAttrs = attrs) { MemoryRegion *mr; MemoryRegionSection *section; @@ -577,7 +577,21 @@ MemoryRegion *flatview_translate(FlatView *fv, hwaddr = addr, hwaddr *xlat, *plen =3D MIN(page, *plen); } =20 - return mr; + return section; +} + +/* Called from RCU critical section */ +MemoryRegion *flatview_translate(FlatView *fv, hwaddr addr, hwaddr *xlat, + hwaddr *plen, bool is_write, + MemTxAttrs attrs) +{ + MemoryRegionSection *section; + + /* This can be MMIO, so setup MMIO bit. */ + section =3D flatview_translate_section(fv, addr, xlat, plen, + is_write, attrs); + + return section->mr; } =20 #ifdef CONFIG_TCG --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569012; cv=none; d=zohomail.com; s=zohoarc; b=fQioeRXnqFWTgf/C3ss93RWYp6KIf55RELj0xWt3XXZKEh/iytcxKt2yfTZLKSHMJNd8zXMjYCBH1uMrK2RZEN6MhkxhYJIvQSJQFn4jROttlj1eFZoWoJ98nDDGdhSEJfmCB8FCmPXcaxq6uxnasH/RmrQZyZ5PXkhDOXLAtNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569012; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=27XpbSWF3D+5022emDhSQreOzsZapL9jvznaVyFKvS8=; b=P1dVBLdn5za7a+BA0c0Mr1uufW6diyKdaZcPl183z7LgTfD6hErqpBQhLYVElxTgZa4xiqNBDGEdSevffedtrCgIlhoCvkl0MGCaryQLykuK46f+Sj/eshiR+e74IdtJlv0ihFsTkroLzFYcRvpWYRqnmI0blRYtTC1hrLZyFjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569012562475.51685149656316; Thu, 7 Aug 2025 05:16:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSR-0004J3-Fg; Thu, 07 Aug 2025 08:10:55 -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 1ujzRw-000248-OQ; Thu, 07 Aug 2025 08:10:24 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRu-0005Bt-Gc; Thu, 07 Aug 2025 08:10:24 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:01 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:09:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568622; x=1786104622; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jlCpSuQ5mesdc7DN+lFSCnjeGwm6BIOjo3EmPFLXWfU=; b=hA61kyzr5o5BNZF3jq6WJW6xX/W8b2K5fnQ6Zeg3v3ablYb4hXOfcsUS AoReDmvfDPcJO/mElCME1lyh+fw2SciLauo8MZe1hQdypXXwY1W15r3LW QQPfTKZgg4SCTqfrVGiTp++xQ/cfP53XNAbrfh/VjRzyHrMtasXZ4iLSV fENATiYpbDYAsDPHZmz+3Y26FpNdhFnQ8sGzj2dPjkXVo5EOlPXcUrsMb V7wZrdgxgyAI/54RmxYjgX7lWa8EjE/0a02dI10adyx8CHtFx3pEo7YpR ya7+/HmmsX1S6GgMYtciJeuk6OHJrfdO3FG8+qllm8te7aLNvJ4QEEYy1 g==; X-CSE-ConnectionGUID: ZaMb5jFKShK/twOHL8LGUQ== X-CSE-MsgGUID: VLv08JK5QQaJJx+6ZswO5w== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036840" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036840" X-CSE-ConnectionGUID: Vs+/5aMoRbmJvyuCzG9nRA== X-CSE-MsgGUID: o3hYrEH1SBCKzHJQIf7SGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701151" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 18/26] memory: Rename flatview_access_allowed() to memory_region_access_allowed() Date: Thu, 7 Aug 2025 20:30:19 +0800 Message-Id: <20250807123027.2910950-19-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569014517116600 Content-Type: text/plain; charset="utf-8" flatview_access_allowed() accepts `MemoryRegion *mr` as an argument, so it's based on MemoryRegion and should be named as memory_region_access_allowed(). Signed-off-by: Zhao Liu Reviewed-by: Manos Pitsidianakis --- system/physmem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/system/physmem.c b/system/physmem.c index d2106d0ffa87..8aaaab4d3a74 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2921,7 +2921,7 @@ bool prepare_mmio_access(MemoryRegion *mr) } =20 /** - * flatview_access_allowed + * memory_region_access_allowed * @mr: #MemoryRegion to be accessed * @attrs: memory transaction attributes * @addr: address within that memory region @@ -2931,8 +2931,8 @@ bool prepare_mmio_access(MemoryRegion *mr) * * Returns: true if transaction is allowed, false if denied. */ -static bool flatview_access_allowed(MemoryRegion *mr, MemTxAttrs attrs, - hwaddr addr, hwaddr len) +static bool memory_region_access_allowed(MemoryRegion *mr, MemTxAttrs attr= s, + hwaddr addr, hwaddr len) { if (likely(!attrs.memory)) { return true; @@ -2952,7 +2952,7 @@ static MemTxResult flatview_write_continue_step(MemTx= Attrs attrs, hwaddr len, hwaddr mr_addr, hwaddr *l, MemoryRegion *m= r) { - if (!flatview_access_allowed(mr, attrs, mr_addr, *l)) { + if (!memory_region_access_allowed(mr, attrs, mr_addr, *l)) { return MEMTX_ACCESS_ERROR; } =20 @@ -3036,7 +3036,7 @@ static MemTxResult flatview_write(FlatView *fv, hwadd= r addr, MemTxAttrs attrs, =20 l =3D len; mr =3D flatview_translate(fv, addr, &mr_addr, &l, true, attrs); - if (!flatview_access_allowed(mr, attrs, addr, len)) { + if (!memory_region_access_allowed(mr, attrs, addr, len)) { return MEMTX_ACCESS_ERROR; } return flatview_write_continue(fv, addr, attrs, buf, len, @@ -3048,7 +3048,7 @@ static MemTxResult flatview_read_continue_step(MemTxA= ttrs attrs, uint8_t *buf, hwaddr *l, MemoryRegion *mr) { - if (!flatview_access_allowed(mr, attrs, mr_addr, *l)) { + if (!memory_region_access_allowed(mr, attrs, mr_addr, *l)) { return MEMTX_ACCESS_ERROR; } =20 @@ -3127,7 +3127,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr= addr, =20 l =3D len; mr =3D flatview_translate(fv, addr, &mr_addr, &l, false, attrs); - if (!flatview_access_allowed(mr, attrs, addr, len)) { + if (!memory_region_access_allowed(mr, attrs, addr, len)) { return MEMTX_ACCESS_ERROR; } return flatview_read_continue(fv, addr, attrs, buf, len, --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568804; cv=none; d=zohomail.com; s=zohoarc; b=GZrKm3eyjolNORKxcOb/fjEHqEwIDtIfk0lYf4idcIASSV6pA+kyhETbTpXyPd/co5cS/wxZ0vGHUtqnTzhv+xZi6wFdx3WJ7tj+A09vVHGyaduCg4RlgfNm9v3b2uGwrCMCp64lwFh8pp2M1W8dnCOnVhwjQ26IRw2/CzojI+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568804; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WjDRxZ45m4vh1E95zZvJx3O1FHWeDsYKIQmLIwpZFNw=; b=coLK5Cv+TgJm+3vfaN0MJ1pqVBcWhCYZvLFIIQRcqp/e//U/s3ihAaw6SD+cnhFpXyK4zzopdRw/jeSyEVs6UH1qlToykyb5FKt6/yn85deTfiru1/t3v9R6KLdCRVWY4LEjilpCC27XRzHaxijSQd69iPdT9fwg5kAOA4SLB+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568804307177.4548215577795; Thu, 7 Aug 2025 05:13:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSA-0003DI-1L; Thu, 07 Aug 2025 08:10:38 -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 1ujzRy-0002HO-CL; Thu, 07 Aug 2025 08:10:26 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzRv-0005Bp-6r; Thu, 07 Aug 2025 08:10:26 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:05 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:02 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568623; x=1786104623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zfMJb0g3wXJyLqYM/+6g21n/rbDXZL8PB4EtRlUBfCI=; b=cjrPpsSq8SoJRt3DOpM7dreupnJUpeYWsnNXS1kI4oAwv8jf6sfAL55g nIjM0HKWmie6nQwm6qE2BLaxFXlGwJ97k6dlgAEtfTNtyJlpwtqVhKhpK ykVRkmED5Rt+J3VNzz+FwxdPVCj7gWMZpE0YMoZUsLQyAQogQJhDjg2vK DiY72oMO0i59sVUXQ1Yqd9bdNAAHvPuWY85z0vDcfn5fMIlesd81BqNq9 ZZNgLx0yoZVkyY7nRqX9kBNMqESNxf5ymHVjBAblZY/wLmSjfOq68Kbgk nkhSSk75B0En7vEGQGVGgZzb1Wxy/6fU5XT8cle8KuJoSNQ6sMnTZ4vK9 g==; X-CSE-ConnectionGUID: wo9g8YbnSM6/F6wDmYGlWg== X-CSE-MsgGUID: GnXvD7CpRvyh78dCgjPo5A== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036846" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036846" X-CSE-ConnectionGUID: CufdCPrmTwSW55ApQmSRqA== X-CSE-MsgGUID: RMGy/1g2TpKZrhebzThF1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701168" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 19/26] memory: Add MemoryRegionSection based misc helpers Date: Thu, 7 Aug 2025 20:30:20 +0800 Message-Id: <20250807123027.2910950-20-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568806172116600 Content-Type: text/plain; charset="utf-8" Add the following helpers: * section_access_allowed() - used to check access in GuestMemory::try_access(). * section_covers_region_addr() - used to implement GuestMemoryRegion::check_address(). * section_get_host_addr() - used to implement GuestMemoryRegion::get_host_address(). * section_fuzz_dma_read() - used to insert fuzz hook before read/load. Signed-off-by: Zhao Liu --- include/system/memory.h | 56 +++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 30 ++++++++++++++++++++++ 2 files changed, 86 insertions(+) diff --git a/include/system/memory.h b/include/system/memory.h index eab69e15e10f..110ad0a3b590 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -3357,6 +3357,62 @@ address_space_write_cached(MemoryRegionCache *cache,= hwaddr addr, MemTxResult address_space_set(AddressSpace *as, hwaddr addr, uint8_t c, hwaddr len, MemTxAttrs attrs); =20 +/** + * section_access_allowed + * + * @section: #MemoryRegionSection to be accessed. + * @attrs: memory transaction attributes. + * @addr: address within that memory region. + * @len: the number of bytes to access. + * + * Check if a memory transaction is allowed. + * + * Returns: true if transaction is allowed, false if denied. + */ +bool section_access_allowed(MemoryRegionSection *section, + MemTxAttrs attrs, hwaddr addr, + hwaddr len); + +/** + * section_covers_region_addr + * + * @section: #MemoryRegionSection to be accessed. + * @region_addr: memory region address within the region, which is + * pointed by #MemoryRegionSection. + * + * Check if a region address is coverd by #MemoryRegionSection. + * + * Returns: true if transaction is allowed, false if denied. + */ +bool section_covers_region_addr(const MemoryRegionSection *section, + hwaddr region_addr); + +/** + * section_get_host_addr + * + * @section: #MemoryRegionSection to be accessed. + * @region_addr: memory region address within the region, which is + * pointed by #MemoryRegionSection. + * + * Get the pointer to the host address. + * + * Returns: pointer to the host address. + */ +uint8_t *section_get_host_addr(const MemoryRegionSection *section, + hwaddr region_addr); + +/** + * section_fuzz_dma_read + * + * @section: #MemoryRegionSection to be accessed. + * @addr: memory address to be fuzzed. + * @len: length of the memory + * + * This function is wrapper of fuzz_dma_read_cb(). + */ +void section_fuzz_dma_read(MemoryRegionSection *section, + hwaddr addr, hwaddr len); + /* * Inhibit technologies that require discarding of pages in RAM blocks, e.= g., * to manage the actual amount of memory consumed by the VM (then, the mem= ory diff --git a/system/physmem.c b/system/physmem.c index 8aaaab4d3a74..e06633f4d8a2 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -320,6 +320,29 @@ static inline bool section_covers_addr(const MemoryReg= ionSection *section, int128_getlo(section->size), addr); } =20 +bool section_covers_region_addr(const MemoryRegionSection *section, + hwaddr region_addr) +{ + return section->offset_within_region <=3D region_addr && + section->offset_within_region + int128_get64(section->size) >= =3D region_addr; +} + +uint8_t *section_get_host_addr(const MemoryRegionSection *section, + hwaddr region_addr) +{ + MemoryRegion *mr =3D section->mr; + assert(mr && mr->ram_block); + + return qemu_map_ram_ptr(mr->ram_block, + section->offset_within_region + region_addr); +} + +void section_fuzz_dma_read(MemoryRegionSection *section, + hwaddr addr, hwaddr len) +{ + fuzz_dma_read_cb(addr, len, section->mr); +} + static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr= addr) { PhysPageEntry lp =3D d->phys_map, *p; @@ -2947,6 +2970,13 @@ static bool memory_region_access_allowed(MemoryRegio= n *mr, MemTxAttrs attrs, return false; } =20 +bool section_access_allowed(MemoryRegionSection *section, + MemTxAttrs attrs, hwaddr addr, + hwaddr len) +{ + return memory_region_access_allowed(section->mr, attrs, addr, len); +} + static MemTxResult flatview_write_continue_step(MemTxAttrs attrs, const uint8_t *buf, hwaddr len, hwaddr mr_addr, --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569136; cv=none; d=zohomail.com; s=zohoarc; b=Bk4KS+mJCkDWBwLCdNE9ljltXevwnlc2ytmrNtC2nGFQP9yU4+9heyxJ+mCwm50Cel37ae+IZTZkWT+J1YBsguPdB2hHQiVv+YSoJTobTt3Ih0eR08yjx0VOYOfnpVo8IQFXq6IfXg/7ojJ/omB+0WMTnmiwCPDLfSPNPlx2tEQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569136; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+4pe4GPDD7OkHFandRwQv/AvelM3vE/q8MtAvLYtR00=; b=jFt/uvnLlOIOwYup54aaH6J7LPshDryoARGBf1bTqKZDv10s7VJVP6dwr1J9FTW/x8YyHunBh8mJIREGeC3BB8BAWSzdpLG3bXe45YY09cxtsjWinEAi6a4HKvT8zFJ0PbEURzntMi0Ih1H67H7qhpMpwBU7RLObKnXGPNRg6cY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 175456913675626.936126977890353; Thu, 7 Aug 2025 05:18:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSl-0004ZI-4n; Thu, 07 Aug 2025 08:11:20 -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 1ujzSI-0003tn-BI; Thu, 07 Aug 2025 08:10:46 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSG-0005Cn-1o; Thu, 07 Aug 2025 08:10:46 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:09 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:06 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568644; x=1786104644; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ICNg+pbeHF8H9llJc/4axDzWq6vSvnR3oi+HF/P7AgQ=; b=S4yhd1fKstoBo3hqWgllUKi98kRNAiLlu+qoDHhRofm5k/OcBjKSYudl C+Vl9rSQOFLpdAo0aLUxgh7rWlQ8ONRwWMwqaWhauQvE+7W+U1BfVFBsh KYbaH/WgQeWsfhT0fQ8cZqtOaJY4G95bvEUsnulEH/ZcGvdKKWLQVCucP 8TgXXX3Bc2UYzmpOjEEEUnhHdFcPeV2nrrD7zScJuZ3KG0mOZh9EiAXaD TDrJAeZkBqy8EKSD07ITKznPTQqYsGzUqwXPyeDLF4UifJRwyeQhLgHVU 3Cv1aOT2c0bqk0C8FMPut46qxxUUKyhbqazxloK+6dbzOoMRGlseMfJq4 g==; X-CSE-ConnectionGUID: r4uizmZQScmmECee7Mlj2Q== X-CSE-MsgGUID: 4aIVwCjcQnaT9Urz4ujh1g== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036861" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036861" X-CSE-ConnectionGUID: 0hU21DClSCOqIceceX82LQ== X-CSE-MsgGUID: wrC6lw8VRGC/QhT8EEJ2kw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701194" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 20/26] memory: Add wrappers of intermediate steps for read/write Date: Thu, 7 Aug 2025 20:30:21 +0800 Message-Id: <20250807123027.2910950-21-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569139733124100 Content-Type: text/plain; charset="utf-8" Add these 2 wrappers to allow bindgen to generate the bindings based on MemoryRegionSection: * section_rust_write_continue_step() * section_rust_read_continue_step() Then Rust side could be able to re-build a full write/read processes as address_space_write()/address_space_read_full() did. Signed-off-by: Zhao Liu --- include/system/memory.h | 51 +++++++++++++++++++++++++++++++++++++++++ system/physmem.c | 16 +++++++++++++ 2 files changed, 67 insertions(+) diff --git a/include/system/memory.h b/include/system/memory.h index 110ad0a3b590..a75c8c348f58 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -3413,6 +3413,57 @@ uint8_t *section_get_host_addr(const MemoryRegionSec= tion *section, void section_fuzz_dma_read(MemoryRegionSection *section, hwaddr addr, hwaddr len); =20 +/** + * section_rust_write_continue_step: write to #MemoryRegionSection. + * + * Not: This function should only used by Rust side, and user shouldn't + * call it directly! + * + * This function provides a wrapper of flatview_write_continue_step(), + * and allows Rust side to re-build a full write process as + * address_space_write() did. + * + * Should be called from an RCU critical section. + * + * @section: #MemoryRegionSection to be accessed. + * @attrs: memory transaction attributes. + * @buf: buffer with the data to be written. + * @len: the number of bytes to write. + * @mr_addr: address within that memory region. + * @l: the actual length of the data is written after function returns. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed (eg unassigned memory, device rejected the transaction, + * IOMMU fault). + */ +MemTxResult section_rust_write_continue_step(MemoryRegionSection *section, + MemTxAttrs attrs, const uint8_t *buf, hwaddr len, hwaddr mr_addr, hwad= dr *l); + +/** + * section_read_continue_step: read from #MemoryRegionSection. + * + * Not: This function should only used by Rust side, and user shouldn't + * call it directly! + * + * This function provides a wrapper of flatview_read_continue_step(), + * and allows Rust side to re-build a full write process as + * address_space_read_full() did. + * + * Should be called from an RCU critical section. + * + * @section: #MemoryRegionSection to be accessed. + * @attrs: memory transaction attributes. + * @buf: buffer to be written. + * @len: the number of bytes is expected to read. + * @mr_addr: address within that memory region. + * @l: the actual length of the data is read after function returns. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed. + */ +MemTxResult section_read_continue_step(MemoryRegionSection *section, + MemTxAttrs attrs, uint8_t *buf, hwaddr len, hwaddr mr_addr, hwaddr *l); + /* * Inhibit technologies that require discarding of pages in RAM blocks, e.= g., * to manage the actual amount of memory consumed by the VM (then, the mem= ory diff --git a/system/physmem.c b/system/physmem.c index e06633f4d8a2..0c30dea775ca 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3119,6 +3119,14 @@ static MemTxResult flatview_read_continue_step(MemTx= Attrs attrs, uint8_t *buf, } } =20 +MemTxResult +section_read_continue_step(MemoryRegionSection *section, MemTxAttrs attrs, + uint8_t *buf, hwaddr len, hwaddr mr_addr, + hwaddr *l) +{ + return flatview_read_continue_step(attrs, buf, len, mr_addr, l, sectio= n->mr); +} + /* Called within RCU critical section. */ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *ptr, @@ -3707,6 +3715,14 @@ static MemTxResult address_space_write_continue_cach= ed(MemTxAttrs attrs, return result; } =20 +MemTxResult +section_rust_write_continue_step(MemoryRegionSection *section, MemTxAttrs = attrs, + const uint8_t *buf, hwaddr len, hwaddr mr= _addr, + hwaddr *l) +{ + return flatview_write_continue_step(attrs, buf, len, mr_addr, l, secti= on->mr); +} + /* Called within RCU critical section. */ static MemTxResult address_space_read_continue_cached(MemTxAttrs attrs, void *ptr, hwaddr le= n, --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569180; cv=none; d=zohomail.com; s=zohoarc; b=lfOX9nI6oEVhrxGQpB/RDomyiMenjmlwPa5JruBqqPdZDVZgLHrcNG59pTmV3rvWAEJY2rb7O94cMI4Hh4XnqPt7qthCz28LaghVRyvSRyFgLp5P2ZtbAjH7Tc2aTLNPoSreGDh2NnddScubjTVmqL3MSwvuc82I1g4h7uTPmEo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569180; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=tZq18ItTYindJ6qaBo+SCnqUcOCyKPE2xvelNaRDOf0=; b=Nf1J/egebUwIjww9i/ooS2+ffGqZ4BlKT+GmqNOkxiS3bMX47uZzC7YfHAOj5bcQ3wi9AsdcoR1D+oraKaYtcl9t7uuI1h0rsy9aD3/vQnmkn2Qo7m5CActIMcaLqQKPyde/cTKAp2XlH/KLTjWkooAkDuo0VzWcnbwGSBZL8oQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569180319587.9017158359483; Thu, 7 Aug 2025 05:19:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSV-0004XC-GJ; Thu, 07 Aug 2025 08:11:00 -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 1ujzSM-00045N-3F; Thu, 07 Aug 2025 08:10:50 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSI-0005Bt-3m; Thu, 07 Aug 2025 08:10:48 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:12 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:09 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568646; x=1786104646; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=L9/7AiV5IeaaNeK7AehXkGkn2BxB38AEIVLuEzucq1A=; b=Cfmp4LFTD9KVyFU7xMN1Rkyoza4ECjrTWS02T8LXk0aKvO1hw7u2KY60 gkmmuKzkQPQMCgh4o6Q2uUnltw2p4mugWmZYwgwRYxMREcNIyscFSHcvf N5HLCxZI7bOcC3s6Kw5BZ4otI5mSdq0fxEcXVWtha7ygx31VrfyxE/tg1 7oC7r0iLWf7VhSzAvNK63Du/tEaG0y5UbScpDbolZ36zmsQbXPA2jaSux adSK0VyCj7h4LMynypuHnlmGDNzQBGbAhRAjybBTc5lcVn0uRGnWhb0ks 3/NlJxFiI5v5aqZ9mYFvubwPoNeX4jtHnHcKVXm3ZRjRU1yo1aVjklJs0 Q==; X-CSE-ConnectionGUID: Sz959LUfTnmU1lv9P/E6Vw== X-CSE-MsgGUID: JS20heUoQRuvmLt6EdvoHg== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036870" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036870" X-CSE-ConnectionGUID: P4ljDsr3TpGdx0ODypJrZw== X-CSE-MsgGUID: Tlh/sA68TKigewNTOtyX/w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701226" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 21/26] memory: Add store/load interfaces for Rust side Date: Thu, 7 Aug 2025 20:30:22 +0800 Message-Id: <20250807123027.2910950-22-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569182376124100 Content-Type: text/plain; charset="utf-8" At present, there're many store/load variants defined in memory_ldst.c.inc. However, the Bytes::store() and Bytes::load() of vm-memory are bound with AtomicAccess trait, which makes it (almost) impossible to select proper interface (for l, w or q) based on specific type. So it's necessary to provide such interfaces that hide the type details as much as possible. And compared with address_space_st{size} or address_space_ld{size}, the differences include: * No translation, and only memory access. * Only support native endian. Then Rust side must handle the endian format before/after processing store()/load(). * Use bytes array instead of single uint64_t for the value to be written or read. Then Rust side doesn't need to convert generic type to u64. - But the extra cost is that there's the need for conversation between bytes array and uint64_t inside the interfaces. * Do not handle the cross-region case via MMIO access. Then Rust side will handle such abnormal cases. Signed-off-by: Zhao Liu --- include/system/memory.h | 52 +++++++++++++++++++++++++++++++-- system/physmem.c | 65 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 112 insertions(+), 5 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index a75c8c348f58..f0f51f1c4c89 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -3440,7 +3440,7 @@ MemTxResult section_rust_write_continue_step(MemoryRe= gionSection *section, MemTxAttrs attrs, const uint8_t *buf, hwaddr len, hwaddr mr_addr, hwad= dr *l); =20 /** - * section_read_continue_step: read from #MemoryRegionSection. + * section_rust_read_continue_step: read from #MemoryRegionSection. * * Not: This function should only used by Rust side, and user shouldn't * call it directly! @@ -3461,9 +3461,57 @@ MemTxResult section_rust_write_continue_step(MemoryR= egionSection *section, * Return a MemTxResult indicating whether the operation succeeded * or failed. */ -MemTxResult section_read_continue_step(MemoryRegionSection *section, +MemTxResult section_rust_read_continue_step(MemoryRegionSection *section, MemTxAttrs attrs, uint8_t *buf, hwaddr len, hwaddr mr_addr, hwaddr *l); =20 +/** + * section_rust_store: store data to #MemoryRegionSection. + * + * Not: This function should only used by Rust side, and user shouldn't + * call it directly! + * + * This function provides a wrapper for address_space_st{size} without + * translation, and only supports native endian by default. + * + * Should be called from an RCU critical section. + * + * @section: #MemoryRegionSection to be accessed. + * @mr_offset: address within that memory region. + * @buf: buffer to be written. + * @attrs: memory transaction attributes. + * @len: the number of bytes is expected to read. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed. + */ +MemTxResult section_rust_store(MemoryRegionSection *section, + hwaddr mr_offset, const uint8_t *buf, + MemTxAttrs attrs, hwaddr len); + +/** + * section_rust_load: load data from #MemoryRegionSection. + * + * Not: This function should only used by Rust side, and user shouldn't + * call it directly! + * + * This function provides a wrapper for address_space_st{size} without + * translation, and only supports native endian by default. + * + * Should be called from an RCU critical section. + * + * @section: #MemoryRegionSection to be accessed. + * @mr_offset: address within that memory region. + * @buf: buffer to be written. + * @attrs: memory transaction attributes. + * @len: the number of bytes is expected to read. + * + * Return a MemTxResult indicating whether the operation succeeded + * or failed. + */ +MemTxResult section_rust_load(MemoryRegionSection *section, + hwaddr mr_offset, uint8_t *buf, + MemTxAttrs attrs, hwaddr len); + /* * Inhibit technologies that require discarding of pages in RAM blocks, e.= g., * to manage the actual amount of memory consumed by the VM (then, the mem= ory diff --git a/system/physmem.c b/system/physmem.c index 0c30dea775ca..6048d5faac8c 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3120,9 +3120,9 @@ static MemTxResult flatview_read_continue_step(MemTxA= ttrs attrs, uint8_t *buf, } =20 MemTxResult -section_read_continue_step(MemoryRegionSection *section, MemTxAttrs attrs, - uint8_t *buf, hwaddr len, hwaddr mr_addr, - hwaddr *l) +section_rust_read_continue_step(MemoryRegionSection *section, MemTxAttrs a= ttrs, + uint8_t *buf, hwaddr len, hwaddr mr_addr, + hwaddr *l) { return flatview_read_continue_step(attrs, buf, len, mr_addr, l, sectio= n->mr); } @@ -3239,6 +3239,65 @@ void cpu_physical_memory_rw(hwaddr addr, void *buf, buf, len, is_write); } =20 +MemTxResult section_rust_store(MemoryRegionSection *section, + hwaddr mr_offset, const uint8_t *buf, + MemTxAttrs attrs, hwaddr len) +{ + MemoryRegion *mr =3D section->mr; + MemTxResult r; + uint64_t val; + + val =3D ldn_he_p(buf, len); + if (!memory_access_is_direct(mr, true, attrs)) { + bool release_lock =3D false; + + release_lock |=3D prepare_mmio_access(mr); + r =3D memory_region_dispatch_write(mr, mr_offset, val, + size_memop(len) | + devend_memop(DEVICE_NATIVE_ENDIAN= ), + attrs); + if (release_lock) { + bql_unlock(); + } + } else { + uint8_t *ptr =3D qemu_map_ram_ptr(mr->ram_block, mr_offset); + stn_p(ptr, len, val); + invalidate_and_set_dirty(mr, mr_offset, len); + r =3D MEMTX_OK; + } + + return r; +} + +MemTxResult section_rust_load(MemoryRegionSection *section, + hwaddr mr_offset, uint8_t *buf, + MemTxAttrs attrs, hwaddr len) +{ + MemoryRegion *mr =3D section->mr; + MemTxResult r; + uint64_t val; + + if (!memory_access_is_direct(mr, false, attrs)) { + bool release_lock =3D false; + + release_lock |=3D prepare_mmio_access(mr); + r =3D memory_region_dispatch_read(mr, mr_offset, &val, + size_memop(len) | + devend_memop(DEVICE_NATIVE_ENDIAN), + attrs); + if (release_lock) { + bql_unlock(); + } + } else { + uint8_t *ptr =3D qemu_map_ram_ptr(mr->ram_block, mr_offset); + val =3D ldn_p(ptr, len); + r =3D MEMTX_OK; + } + + stn_he_p(buf, len, val); + return r; +} + enum write_rom_type { WRITE_DATA, FLUSH_CACHE, --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568862; cv=none; d=zohomail.com; s=zohoarc; b=Wa4H6ET4f28JxuGFtGGqGCRQS49yupLSoAkG7pyS1W1MdAwBY9Y8GfQOhslI1fB0dnZooTFwY3X3P1tRtpr9XRHJuCx/kTOvejNW24o+rHVIpg41tg8XS6T3C4MEOJAdpxoXkG0A1d5dO3LOM4HwdZobNVWtjT5Qr9qXRM7QnFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568862; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8Qnmh1BAzfG7g61YMce2oD/I3LKEg7ZC3EpwVS0eurA=; b=GCl07lyNFI6jcKAMEW/MS3X3lJFqbzCu+1RCSi7wecqKWCw+1roDWLmOCorisyCbvy4Xk+Gu1aY/lyKPBe+RcWNhKf2/Ve7ufyAEfvbiVc3wid02L43N6sED2z47tXL2o/g+OTBcsckaAYCl18Q21fHBoAIq9PxRzPz3i6Ft3wQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568862546532.2444745624965; Thu, 7 Aug 2025 05:14:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzTw-00066n-7B; Thu, 07 Aug 2025 08:12:30 -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 1ujzSM-000470-MP; Thu, 07 Aug 2025 08:10:50 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSJ-0005Bp-9L; Thu, 07 Aug 2025 08:10:50 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:16 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568647; x=1786104647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JC5ZB5z1XOiDYFlC6bwMZhTJO84pmbExB9lSlxIwYgU=; b=iNN805iNsxWK7FZZq+WCwnkO6CQTM8oLk8844ZmPOGGNnHhS3ibap6Ks J/502RAT8+QmVXaXbvfLo8QZnCKjXDi9E/FFsCr/TjG9dGepUNYk/jtps uvvkTvcFoAC40jueVR22J80uixCGg0nT4sxSQpkTSuBkmrz+vsBfBh70X 4vIa1WLGXfL4CmLIXGrxjObOEIbNUO/9B2SDDAQ3dDq27R/rPRpzojju3 Xg+0Ex0fSrDZNVYDzLpz30wLCwcmTnmPf1yJq9VZVXbBj37NPoK4yHW07 BNkyYXzBKstMDk8HE+x++8CA3sHTkiLOIAM31+/b75lGfVRQfVcb/bDf6 w==; X-CSE-ConnectionGUID: qVqJsjMeSYmWz0FnXoP3UQ== X-CSE-MsgGUID: Y3rfUZDYS0ay7RAEVN7v/g== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036876" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036876" X-CSE-ConnectionGUID: /99abexeT82kKLGM5NL/bA== X-CSE-MsgGUID: /eCEAMOaSf+WLz7ErDajkw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701269" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 22/26] rust/memory: Implement vm_memory::GuestMemoryRegion for MemoryRegionSection Date: Thu, 7 Aug 2025 20:30:23 +0800 Message-Id: <20250807123027.2910950-23-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568864937116600 Content-Type: text/plain; charset="utf-8" Although QEMU already has native memory region abstraction, this is MemoryRegion, which supports overlapping. But vm-memory doesn't support overlapped memory, so MemoryRegionSection is more proper to implement vm_memory::GuestMemoryRegion trait. Implement vm_memory::GuestMemoryRegion for MemoryRegionSection, and provide low-level memory write/read/store/load bindings based on MemoryRegionSection. Additionally, add necessay helpers (fuzz_dma_read() and is_access_allowed()) for MemoryRegionSection. Signed-off-by: Zhao Liu --- rust/qemu-api/src/memory.rs | 393 +++++++++++++++++++++++++++++++++++- 1 file changed, 391 insertions(+), 2 deletions(-) diff --git a/rust/qemu-api/src/memory.rs b/rust/qemu-api/src/memory.rs index e40fad6cf19e..c8faa3b9c1e9 100644 --- a/rust/qemu-api/src/memory.rs +++ b/rust/qemu-api/src/memory.rs @@ -2,17 +2,33 @@ // Author(s): Paolo Bonzini // SPDX-License-Identifier: GPL-2.0-or-later =20 -//! Bindings for `MemoryRegion`, `MemoryRegionOps` and `MemTxAttrs` +//! Bindings for `MemoryRegion`, `MemoryRegionOps`, `MemTxAttrs` and +//! `MemoryRegionSection`. =20 use std::{ ffi::{c_uint, c_void, CStr, CString}, + io::ErrorKind, marker::PhantomData, + mem::size_of, + ops::Deref, + sync::atomic::Ordering, }; =20 +// FIXME: Convert hwaddr to GuestAddress pub use bindings::{hwaddr, MemTxAttrs}; +pub use vm_memory::GuestAddress; +use vm_memory::{ + bitmap::BS, Address, AtomicAccess, Bytes, GuestMemoryError, GuestMemor= yRegion, + GuestMemoryResult, GuestUsize, MemoryRegionAddress, ReadVolatile, Vola= tileSlice, WriteVolatile, +}; =20 use crate::{ - bindings::{self, device_endian, memory_region_init_io}, + bindings::{ + self, device_endian, memory_region_init_io, section_access_allowed, + section_covers_region_addr, section_fuzz_dma_read, section_get_hos= t_addr, + section_rust_load, section_rust_read_continue_step, section_rust_s= tore, + section_rust_write_continue_step, MEMTX_OK, + }, callbacks::FnCall, cell::Opaque, prelude::*, @@ -202,3 +218,376 @@ unsafe impl ObjectType for MemoryRegion { unspecified: true, ..Zeroable::ZERO }; + +/// A safe wrapper around [`bindings::MemoryRegionSection`]. +/// +/// This struct is fundamental for integrating QEMU's memory model with +/// the [`vm-memory`] ecosystem. It directly maps to the concept of +/// [`GuestMemoryRegion`](vm_memory::GuestMemoryRegion) and implements +/// that trait. +/// +/// ### `MemoryRegion` vs. `MemoryRegionSection` +/// +/// Although QEMU already has native memory region abstraction, this is +/// [`MemoryRegion`], which supports overlapping. But `vm-memory` doesn't +/// support overlapped memory, so `MemoryRegionSection` is more proper +/// to implement [`GuestMemoryRegion`](vm_memory::GuestMemoryRegion) +/// trait. +/// +/// One point should pay attention is, +/// [`MemoryRegionAddress`](vm_memory::MemoryRegionAddress) represents the +/// address or offset within the `MemoryRegionSection`. But traditional C +/// bindings treats memory region address or offset as the offset within +/// `MemoryRegion`. +/// +/// Therefore, it's necessary to do conversion when calling C bindings +/// with `MemoryRegionAddress` from the context of `MemoryRegionSection`. +/// +/// ### Usage +/// +/// Considerring memory access is almost always through `AddressSpace` +/// in QEMU, `MemoryRegionSection` is intended for **internal use only** +/// within the `vm-memory` backend implementation. +/// +/// Device and other external users should **not** use or create +/// `MemoryRegionSection`s directly. Instead, they should work with the +/// higher-level `MemoryRegion` API to create and manage their device's +/// memory. This separation of concerns mirrors the C API and avoids +/// confusion about different memory abstractions. +#[repr(transparent)] +#[derive(qemu_api_macros::Wrapper)] +pub struct MemoryRegionSection(Opaque); + +unsafe impl Send for MemoryRegionSection {} +unsafe impl Sync for MemoryRegionSection {} + +impl Deref for MemoryRegionSection { + type Target =3D bindings::MemoryRegionSection; + + fn deref(&self) -> &Self::Target { + // SAFETY: Opaque<> wraps a pointer from C side. The validity + // of the pointer is confirmed at the creation of Opaque<>. + unsafe { &*self.0.as_ptr() } + } +} + +impl MemoryRegionSection { + /// A fuzz testing hook for DMA read. + /// + /// When CONFIG_FUZZ is not set, this hook will do nothing. + #[allow(dead_code)] + fn fuzz_dma_read(&self, addr: GuestAddress, len: GuestUsize) -> &Self { + // SAFETY: Opaque<> ensures the pointer is valid, and here it + // takes into account the offset conversion between MemoryRegionSe= ction + // and MemoryRegion. + unsafe { + section_fuzz_dma_read( + self.as_mut_ptr(), + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + len, + ) + }; + self + } + + /// A helper to check if the memory access is allowed. + /// + /// This is needed for memory write/read. + #[allow(dead_code)] + fn is_access_allowed(&self, addr: MemoryRegionAddress, len: GuestUsize= ) -> bool { + // SAFETY: Opaque<> ensures the pointer is valid, and here it + // takes into account the offset conversion between MemoryRegionSe= ction + // and MemoryRegion. + let allowed =3D unsafe { + section_access_allowed( + self.as_mut_ptr(), + MEMTXATTRS_UNSPECIFIED, + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + len, + ) + }; + allowed + } +} + +impl Bytes for MemoryRegionSection { + type E =3D GuestMemoryError; + + /// The memory wirte interface based on `MemoryRegionSection`. + /// + /// This function - as an intermediate step - is called by FlatView's + /// write(). And it shouldn't be called to access memory directly. + fn write(&self, buf: &[u8], addr: MemoryRegionAddress) -> GuestMemoryR= esult { + let len =3D buf.len() as u64; + let mut remain =3D len; + + // SAFETY: the pointers and reference are convertible and the + // offset conversion is considerred. + let ret =3D unsafe { + section_rust_write_continue_step( + self.as_mut_ptr(), + MEMTXATTRS_UNSPECIFIED, + buf.as_ptr(), + len, + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + &mut remain, + ) + }; + + if ret =3D=3D MEMTX_OK { + return Ok(remain as usize); + } else { + return Err(GuestMemoryError::InvalidBackendAddress); + } + } + + /// The memory read interface based on `MemoryRegionSection`. + /// + /// This function - as an intermediate step - is called by FlatView's + /// read(). And it shouldn't be called to access memory directly. + fn read(&self, buf: &mut [u8], addr: MemoryRegionAddress) -> GuestMemo= ryResult { + let len =3D buf.len() as u64; + let mut remain =3D len; + + // SAFETY: the pointers and reference are convertible and the + // offset conversion is considerred. + let ret =3D unsafe { + section_rust_read_continue_step( + self.as_mut_ptr(), + MEMTXATTRS_UNSPECIFIED, + buf.as_mut_ptr(), + len, + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + &mut remain, + ) + }; + + if ret =3D=3D MEMTX_OK { + return Ok(remain as usize); + } else { + return Err(GuestMemoryError::InvalidBackendAddress); + } + } + + /// The memory store interface based on `MemoryRegionSection`. + /// + /// This function - as the low-level store implementation - is + /// called by FlatView's store(). And it shouldn't be called to + /// access memory directly. + fn store( + &self, + val: T, + addr: MemoryRegionAddress, + _order: Ordering, + ) -> GuestMemoryResult<()> { + let len =3D size_of::(); + + if len > size_of::() { + return Err(GuestMemoryError::IOError(std::io::Error::new( + ErrorKind::InvalidInput, + "failed to store the data more then 8 bytes", + ))); + } + + // Note: setcion_rust_store() accepts `const uint8_t *buf`. + // + // This is a "compromise" solution: vm-memory requires AtomicAccess + // but QEMU uses uint64_t as the default type. Here we can't conve= rt + // AtomicAccess to u64, since complier will complain "an `as` + // expression can only be used to convert between primitive types = or + // to coerce to a specific trait object", or other endless errors + // about convertion to u64. + // + // Fortunately, we can use a byte array to bridge the Rust wrapper + // and the C binding. This approach is not without a trade-off, + // however: the section_rust_store() function requires an addition= al + // conversion from bytes to a uint64_t. This performance overhead = is + // considered acceptable. + // + // SAFETY: the pointers are convertible and the offset conversion = is + // considerred. + let res =3D unsafe { + section_rust_store( + self.as_mut_ptr(), + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + val.as_slice().as_ptr(), + MEMTXATTRS_UNSPECIFIED, + len as u64, + ) + }; + + match res { + MEMTX_OK =3D> Ok(()), + _ =3D> Err(GuestMemoryError::InvalidBackendAddress), + } + } + + /// The memory load interface based on `MemoryRegionSection`. + /// + /// This function - as the low-level load implementation - is + /// called by FlatView's load(). And it shouldn't be called to + /// access memory directly. + fn load( + &self, + addr: MemoryRegionAddress, + _order: Ordering, + ) -> GuestMemoryResult { + let len =3D size_of::(); + + if len > size_of::() { + return Err(GuestMemoryError::IOError(std::io::Error::new( + ErrorKind::InvalidInput, + "failed to load the data more then 8 bytes", + ))); + } + + let mut val: T =3D T::zeroed(); + + // Note: setcion_rust_load() accepts `uint8_t *buf`. + // + // It has the similar reason as store() with the slight difference, + // which is section_rust_load() requires additional conversion of + // uint64_t to bytes. + // + // SAFETY: the pointers are convertible and the offset conversion = is + // considerred. + let res =3D unsafe { + section_rust_load( + self.as_mut_ptr(), + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + val.as_mut_slice().as_mut_ptr(), + MEMTXATTRS_UNSPECIFIED, + size_of::() as u64, + ) + }; + + match res { + MEMTX_OK =3D> Ok(val), + _ =3D> Err(GuestMemoryError::InvalidBackendAddress), + } + } + + fn write_slice(&self, _buf: &[u8], _addr: MemoryRegionAddress) -> Gues= tMemoryResult<()> { + unimplemented!() + } + + fn read_slice(&self, _buf: &mut [u8], _addr: MemoryRegionAddress) -> G= uestMemoryResult<()> { + unimplemented!() + } + + fn read_volatile_from( + &self, + _addr: MemoryRegionAddress, + _src: &mut F, + _count: usize, + ) -> GuestMemoryResult + where + F: ReadVolatile, + { + unimplemented!() + } + + fn read_exact_volatile_from( + &self, + _addr: MemoryRegionAddress, + _src: &mut F, + _count: usize, + ) -> GuestMemoryResult<()> + where + F: ReadVolatile, + { + unimplemented!() + } + + fn write_volatile_to( + &self, + _addr: MemoryRegionAddress, + _dst: &mut F, + _count: usize, + ) -> GuestMemoryResult + where + F: WriteVolatile, + { + unimplemented!() + } + + fn write_all_volatile_to( + &self, + _addr: MemoryRegionAddress, + _dst: &mut F, + _count: usize, + ) -> GuestMemoryResult<()> + where + F: WriteVolatile, + { + unimplemented!() + } +} + +impl GuestMemoryRegion for MemoryRegionSection { + type B =3D (); + + /// Get the memory size covered by this MemoryRegionSection. + fn len(&self) -> GuestUsize { + self.deref().size as GuestUsize + } + + /// Return the minimum (inclusive) Guest physical address managed by + /// this MemoryRegionSection. + fn start_addr(&self) -> GuestAddress { + GuestAddress(self.deref().offset_within_address_space) + } + + fn bitmap(&self) -> BS<'_, Self::B> { + () + } + + /// Check whether the @addr is covered by this MemoryRegionSection. + fn check_address(&self, addr: MemoryRegionAddress) -> Option { + // SAFETY: the pointer is convertible and the offset conversion is + // considerred. + if unsafe { + section_covers_region_addr( + self.as_mut_ptr(), + addr.checked_add(self.deref().offset_within_region) + .unwrap() + .raw_value(), + ) + } { + Some(addr) + } else { + None + } + } + + /// Get the host virtual address from the offset of this MemoryRegionS= ection + /// (@addr). + fn get_host_address(&self, addr: MemoryRegionAddress) -> GuestMemoryRe= sult<*mut u8> { + self.check_address(addr) + .ok_or(GuestMemoryError::InvalidBackendAddress) + .map(|addr| + // SAFETY: the pointers are convertible and the offset + // conversion is considerred. + unsafe { section_get_host_addr(self.as_mut_ptr(), addr.raw= _value()) }) + } + + fn get_slice( + &self, + _offset: MemoryRegionAddress, + _count: usize, + ) -> GuestMemoryResult>> { + unimplemented!() + } +} --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568953; cv=none; d=zohomail.com; s=zohoarc; b=cwI7aMB2B/woZ+W+AogcNK+p55bxYaA4yD5UsVIqOAIl7C+Y0um8Cv52Z1+mIm60sPF7sLcR1MJKSPdGA4XJC7qzMWfiJHMNkV1fNXW1KN32noyl/gLOYSfw8VpINoLl68nxFMCci0NDFuBnyLzK72Twez0ynu63W15lyeM3MwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568953; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=8nj6d1KDzkAPaPkqzLb02VefmwLtrS7LM50RLSFcrXo=; b=IltZ7wFIJ14sADSX9+2ZOkB3Ge7yq3EFEUBKqZZQ/1+hE8rUHZL9ImFo91hpH4MOaX0IIzJC1CzNdAnCR12b6UbZc1iBCXBIG2X0n7OLa6r9LFrJrA0P9vVcTHA2BvUDaBJKb+7TdALlSDplSFToibzX05AlJQmCoxHBQxwePN0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 17545689535091002.2156694077452; Thu, 7 Aug 2025 05:15:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzSR-0004Jz-QV; Thu, 07 Aug 2025 08:10:56 -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 1ujzSM-00045S-4e; Thu, 07 Aug 2025 08:10:50 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSJ-0005Cn-2l; Thu, 07 Aug 2025 08:10:49 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:19 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:17 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568647; x=1786104647; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RPK/xV4qr+qgQthrCvhKw4L9KVKLhbnVw8l3iY1dEz4=; b=mKozXiytLvsqX8rdwxdojEYoYyTVmTV9XZac4p2Z1yvlJfXzl/Y1TVKp 3HJl7h64otNmrKljRe+2W9HK+vnI+cWHftVHQ+OYAsUBBwcbmBWBxZHMw UC37jru23UkeOA90xeBYNYCSPbWd6LNc6joYKX4Yy3zll0wDsPjy7bqYX 0Z7wB9/lvFGg3VHmFSpzru9MtemF+88yK/2mwsZq6vGowVDADxzV+H5xn Dl6V42XDWE5TkMuPii1VqHXYDb+wnU/nZ9E7L/8w7ErGl2JvnFnhrUfXR mfjZkPiXv7awgESb3noA0ScQTw55AKnv0sDU9t1DXQ0zWj5rtx1PY2cj9 w==; X-CSE-ConnectionGUID: aU0EpJKgTJyMdToMxUHCMA== X-CSE-MsgGUID: eCOg+4e1TJGV4B1XUGVYGg== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036883" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036883" X-CSE-ConnectionGUID: 0QrxE7xYRNy5eC6XN7Hjng== X-CSE-MsgGUID: Lgb+kPdbSnSrNM3q36KSkQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701309" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 23/26] rust/memory: Implement vm_memory::GuestMemory for FlatView Date: Thu, 7 Aug 2025 20:30:24 +0800 Message-Id: <20250807123027.2910950-24-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568956043116600 Content-Type: text/plain; charset="utf-8" Implement vm_memory::GuestMemory for FlafView, and provide memory write/read/store/load bindings. At the meanwhile, add a RAII guard to help protect FlatView's life time at Rust side. Signed-off-by: Zhao Liu --- rust/qemu-api/src/memory.rs | 433 +++++++++++++++++++++++++++++++++++- 1 file changed, 429 insertions(+), 4 deletions(-) diff --git a/rust/qemu-api/src/memory.rs b/rust/qemu-api/src/memory.rs index c8faa3b9c1e9..23347f35e5da 100644 --- a/rust/qemu-api/src/memory.rs +++ b/rust/qemu-api/src/memory.rs @@ -2,8 +2,8 @@ // Author(s): Paolo Bonzini // SPDX-License-Identifier: GPL-2.0-or-later =20 -//! Bindings for `MemoryRegion`, `MemoryRegionOps`, `MemTxAttrs` and -//! `MemoryRegionSection`. +//! Bindings for `MemoryRegion`, `MemoryRegionOps`, `MemTxAttrs` +//! `MemoryRegionSection` and `FlatView`. =20 use std::{ ffi::{c_uint, c_void, CStr, CString}, @@ -11,6 +11,7 @@ marker::PhantomData, mem::size_of, ops::Deref, + ptr::NonNull, sync::atomic::Ordering, }; =20 @@ -18,13 +19,14 @@ pub use bindings::{hwaddr, MemTxAttrs}; pub use vm_memory::GuestAddress; use vm_memory::{ - bitmap::BS, Address, AtomicAccess, Bytes, GuestMemoryError, GuestMemor= yRegion, + bitmap::BS, Address, AtomicAccess, Bytes, GuestMemory, GuestMemoryErro= r, GuestMemoryRegion, GuestMemoryResult, GuestUsize, MemoryRegionAddress, ReadVolatile, Vola= tileSlice, WriteVolatile, }; =20 use crate::{ bindings::{ - self, device_endian, memory_region_init_io, section_access_allowed, + self, address_space_lookup_section, device_endian, flatview_ref, + flatview_translate_section, flatview_unref, memory_region_init_io,= section_access_allowed, section_covers_region_addr, section_fuzz_dma_read, section_get_hos= t_addr, section_rust_load, section_rust_read_continue_step, section_rust_s= tore, section_rust_write_continue_step, MEMTX_OK, @@ -591,3 +593,426 @@ fn get_slice( unimplemented!() } } + +/// A safe wrapper around [`bindings::FlatView`]. +/// +/// [`Flaftview`] represents a collection of memory regions, and maps to +/// [`GuestMemoryRegion`](vm_memory::GuestMemoryRegion). +/// +/// The memory details are hidden beneath this wrapper. Direct memory acce= ss +/// is not allowed. Instead, memory access, e.g., write/read/store/load +/// should process through [`Bytes`]. +#[repr(transparent)] +#[derive(qemu_api_macros::Wrapper)] +pub struct FlatView(Opaque); + +unsafe impl Send for FlatView {} +unsafe impl Sync for FlatView {} + +impl Deref for FlatView { + type Target =3D bindings::FlatView; + + fn deref(&self) -> &Self::Target { + // SAFETY: Opaque<> wraps a pointer from C side. The validity + // of the pointer is confirmed at the creation of Opaque<>. + unsafe { &*self.0.as_ptr() } + } +} + +impl FlatView { + /// Translate guest address to the offset within a MemoryRegionSection. + /// + /// Ideally, this helper should be integrated into + /// GuestMemory::to_region_addr(), but we haven't reached there yet. + fn translate( + &self, + addr: GuestAddress, + len: GuestUsize, + is_write: bool, + ) -> Option<(&MemoryRegionSection, MemoryRegionAddress, GuestUsize)> { + let mut remain =3D len as hwaddr; + let mut raw_addr: hwaddr =3D 0; + + // SAFETY: the pointers and reference are convertible and the + // offset conversion is considerred. + let ptr =3D unsafe { + flatview_translate_section( + self.as_mut_ptr(), + addr.raw_value(), + &mut raw_addr, + &mut remain, + is_write, + MEMTXATTRS_UNSPECIFIED, + ) + }; + + if ptr.is_null() { + return None; + } + + // SAFETY: the pointer is valid and not NULL. + let s =3D unsafe { ::R::from_raw(ptr) }; + Some(( + s, + MemoryRegionAddress(raw_addr) + .checked_sub(s.deref().offset_within_region) + .unwrap(), + remain as GuestUsize, + )) + } +} + +impl Bytes for FlatView { + type E =3D GuestMemoryError; + + /// The memory wirte interface based on `FlatView`. + /// + /// This function is similar to `flatview_write` in C side, but it + /// only supports MEMTXATTRS_UNSPECIFIED for now. + /// + /// Note: This function should be called within RCU critical section. + /// Furthermore, it is only for internal use and should not be called + /// directly. + fn write(&self, buf: &[u8], addr: GuestAddress) -> GuestMemoryResult { + self.try_access( + buf.len(), + addr, + true, + |offset, count, caddr, region| -> GuestMemoryResult { + // vm-memory provides an elegent way to advance (See + // ReadVolatile::read_volatile), but at this moment, + // this simple way is enough. + let sub_buf =3D &buf[offset..offset + count]; + region.write(sub_buf, caddr) + }, + ) + } + + /// The memory wirte interface based on `FlatView`. + /// + /// This function is similar to `flatview_read` in C side, but it + /// only supports MEMTXATTRS_UNSPECIFIED for now. + /// + /// Note: This function should be called within RCU critical section. + /// Furthermore, it is only for internal use and should not be called + /// directly. + fn read(&self, buf: &mut [u8], addr: GuestAddress) -> GuestMemoryResul= t { + if buf.len() =3D=3D 0 { + return Ok(0); + } + + self.try_access( + buf.len(), + addr, + false, + |offset, count, caddr, region| -> GuestMemoryResult { + // vm-memory provides an elegent way to advance (See + // ReadVolatile::write_volatile), but at this moment, + // this simple way is enough. + let sub_buf =3D &mut buf[offset..offset + count]; + region + .fuzz_dma_read(addr, sub_buf.len() as GuestUsize) + .read(sub_buf, caddr) + }, + ) + } + + /// The memory store interface based on `FlatView`. + /// + /// This function supports MEMTXATTRS_UNSPECIFIED, and only supports + /// native endian, which means before calling this function, make sure + /// the endian of value follows target's endian. + /// + /// Note: This function should be called within RCU critical section. + /// Furthermore, it is only for internal use and should not be called + /// directly. + fn store( + &self, + val: T, + addr: GuestAddress, + order: Ordering, + ) -> GuestMemoryResult<()> { + self.translate(addr, size_of::() as GuestUsize, true) + .ok_or(GuestMemoryError::InvalidGuestAddress(addr)) + .and_then(|(region, region_addr, remain)| { + // Though C side handles this cross region case via MMIO + // by default, it still looks very suspicious for store/ + // load. It happens Bytes::store() doesn't support more + // argument to identify this case, so report an error + // directly! + if remain < size_of::() as GuestUsize { + return Err(GuestMemoryError::InvalidBackendAddress); + } + + region.store(val, region_addr, order) + }) + } + + /// The memory load interface based on `FlatView`. + /// + /// This function supports MEMTXATTRS_UNSPECIFIED, and only supports + /// native endian, which means the value returned by this function + /// follows target's endian. + /// + /// Note: This function should be called within RCU critical section. + /// Furthermore, it is only for internal use and should not be called + /// directly. + fn load(&self, addr: GuestAddress, order: Ordering) -= > GuestMemoryResult { + self.translate(addr, size_of::() as GuestUsize, false) + .ok_or(GuestMemoryError::InvalidGuestAddress(addr)) + .and_then(|(region, region_addr, remain)| { + // Though C side handles this cross region case via MMIO + // by default, it still looks very suspicious for store/ + // load. It happens Bytes::load() doesn't support more + // arguments to identify this case, so report an error + // directly! + if remain < size_of::() as GuestUsize { + return Err(GuestMemoryError::InvalidBackendAddress); + } + + region + .fuzz_dma_read(addr, size_of:: as GuestUsize) + .load(region_addr, order) + }) + } + + fn write_slice(&self, _buf: &[u8], _addr: GuestAddress) -> GuestMemory= Result<()> { + unimplemented!() + } + + fn read_slice(&self, _buf: &mut [u8], _addr: GuestAddress) -> GuestMem= oryResult<()> { + unimplemented!() + } + + fn read_volatile_from( + &self, + _addr: GuestAddress, + _src: &mut F, + _count: usize, + ) -> GuestMemoryResult + where + F: ReadVolatile, + { + unimplemented!() + } + + fn read_exact_volatile_from( + &self, + _addr: GuestAddress, + _src: &mut F, + _count: usize, + ) -> GuestMemoryResult<()> + where + F: ReadVolatile, + { + unimplemented!() + } + + fn write_volatile_to( + &self, + _addr: GuestAddress, + _dst: &mut F, + _count: usize, + ) -> GuestMemoryResult + where + F: WriteVolatile, + { + unimplemented!() + } + + fn write_all_volatile_to( + &self, + _addr: GuestAddress, + _dst: &mut F, + _count: usize, + ) -> GuestMemoryResult<()> + where + F: WriteVolatile, + { + unimplemented!() + } +} + +impl GuestMemory for FlatView { + type R =3D MemoryRegionSection; + + /// Get the number of `MemoryRegionSection`s managed by this `FlatView= `. + fn num_regions(&self) -> usize { + self.deref().nr.try_into().unwrap() + } + + /// Find the `MemoryRegionSection` which covers @addr + fn find_region(&self, addr: GuestAddress) -> Option<&Self::R> { + // set resolve_subpage as true by default + // + // SAFETY: bindings::FlatView has `dispatch` field and the pointer= is + // valid, although accessing the field of C structure is ugly. + let raw =3D + unsafe { address_space_lookup_section(self.deref().dispatch, a= ddr.raw_value(), true) }; + + if !raw.is_null() { + let s =3D unsafe { Self::R::from_raw(raw) }; + Some(s) + } else { + None + } + } + + /// Return an empty iterator. + /// + /// This function always triggers panic under debug mode. + fn iter(&self) -> impl Iterator { + assert!(false); // Do not use this iter()! + + // QEMU has a linear iteration in C side named `flatview_for_each_= range`, + // but it iterates `FlatRange` instead of `MemoryRegionSection`. + // + // It is still possible to have a `Iterator` based on `MemoryRegio= nSection`, + // by iterating `FlatView::dispatch::map::sections`. + // + // However, it is not worth it. QEMU has implemented the two-level= "page" + // walk in `phys_page_find`, which is more efficient than linear + // iteration. Therefore, there is no need to reinvent the wheel on= the + // Rust side, at least for now. + // + // Just return an empty iterator to satisfy the trait's contract. + // This makes the code compile, but the iterator won't yield + // any items. + std::iter::empty() + } + + fn to_region_addr(&self, _addr: GuestAddress) -> Option<(&Self::R, Mem= oryRegionAddress)> { + // Note: This method should implement FlatView::translate(), but + // its function signature is unfriendly to QEMU's translation. QEMU + // needs to distinguish write access or not, and care about the + // remianing bytes of the region. + // + // FIXME: Once GuestMemory::to_region_addr() could meet QEMU's + // requirements, move FlatView::translate() here. + unimplemented!() + } + + /// Try to access a contiguous block of guest memory, executing a call= back + /// for each memory region that backs the requested address range. + /// + /// This method is the core of memory access. It iterates through each + /// `MemoryRegionSection` that corresponds to the guest address + /// range [`addr`, `addr` + `count`) and invokes the provided closure = `f` + /// for each section. + fn try_access( + &self, + count: usize, + addr: GuestAddress, + is_write: bool, + mut f: F, + ) -> GuestMemoryResult + where + F: FnMut(usize, usize, MemoryRegionAddress, &Self::R) -> GuestMemo= ryResult, + { + // FIXME: it's tricky to add more argument in try_access(), e.g., + // attrs. Or maybe it's possible to move try_access() to Bytes tra= it, + // then it can accept a generic type which contains the address and + // other arguments. + + if count =3D=3D 0 { + return Ok(count); + } + + let mut total =3D 0; + let mut curr =3D addr; + + while total < count { + let len =3D (count - total) as GuestUsize; + let (region, start, remain) =3D self.translate(curr, len, is_w= rite).unwrap(); + + if !region.is_access_allowed(start, remain) { + // FIXME: could we return something like MEMTX_ACCESS_ERRO= R? + return Err(GuestMemoryError::InvalidGuestAddress(addr)); + } + + match f(total as usize, remain as usize, start, region) { + // no more data + Ok(0) =3D> return Ok(total), + // made some progress + Ok(res) =3D> { + if res as GuestUsize > remain { + return Err(GuestMemoryError::CallbackOutOfRange); + } + + total =3D match total.checked_add(res) { + Some(x) if x < count =3D> x, + Some(x) if x =3D=3D count =3D> return Ok(x), + _ =3D> return Err(GuestMemoryError::CallbackOutOfR= ange), + }; + + curr =3D match curr.overflowing_add(res as GuestUsize)= { + (x @ GuestAddress(0), _) | (x, false) =3D> x, + (_, true) =3D> return Err(GuestMemoryError::GuestA= ddressOverflow), + }; + } + // error happened + e =3D> return e, + } + } + + if total =3D=3D 0 { + Err(GuestMemoryError::InvalidGuestAddress(addr)) + } else { + Ok(total) + } + } +} + +/// A RAII guard that provides temporary access to a `FlatView`. +/// +/// Upon creation, this guard increments the reference count of the +/// underlying `FlatView`. When the guard goes out of of scope, it +/// automatically decrements the count. +/// +/// As long as the guard lives, the access to `FlatView` is valid. +#[derive(Debug)] +pub struct FlatViewRefGuard(NonNull); + +impl Drop for FlatViewRefGuard { + fn drop(&mut self) { + // SAFETY: the pointer is convertible. + unsafe { flatview_unref(self.0.as_ref().as_mut_ptr()) }; + } +} + +impl FlatViewRefGuard { + /// Attempt to create a new RAII guard for the given `FlatView`. + /// + /// This may fail if the `FlatView`'s reference count is already zero. + pub fn new(flat: &FlatView) -> Option { + // SAFETY: the pointer is convertible. + if unsafe { flatview_ref(flat.as_mut_ptr()) } { + Some(FlatViewRefGuard(NonNull::from(flat))) + } else { + None + } + } +} + +impl Deref for FlatViewRefGuard { + type Target =3D FlatView; + + fn deref(&self) -> &Self::Target { + // SAFETY: the pointer and reference are convertible. + unsafe { &*self.0.as_ptr() } + } +} + +impl Clone for FlatViewRefGuard { + /// Clone the guard, which involves incrementing the reference + /// count again. + /// + /// This method will **panic** if the reference count of the underlying + /// `FlatView` cannot be incremented (e.g., if it is zero, meaning the + /// object is being destroyed). This can happen in concurrent scenari= os. + fn clone(&self) -> Self { + FlatViewRefGuard::new(self.deref()).expect( + "Failed to clone FlatViewRefGuard: the FlatView may have been = destroyed concurrently.", + ) + } +} --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754569183; cv=none; d=zohomail.com; s=zohoarc; b=DOVvqzWREEukQx8TzUK16gfWPb/kh8jqWz+xgXf7CI+X8aCsJtJ84SSB6c1jlC76TE+f54Do9S497URS+92oUZ4VWF88z+Cura4tmv94WhWoRpiZ+puPDoFf4gjeYJ557Jl7RRdUcvE87YZzA1G7uv38rp5m032CQJSHRzwoBwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754569183; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MNuFiStX3onNuWg9t0qMLK32Dmq+d+jKSLFiRC2nD5w=; b=eqb4bN3HKtNLgcKV0wkY5AodlpQHEbOC/epdkXc2l4+PswxNBME83r1hTmXTRcY5s5wFwZbx6XJRGmmEIqrOS2zOGZzUAmlVh26Ht8ap7h/NRX4VAOrx3+UYjGvOms5KznrLHgBXFSsClhLH05lK8Rg5IjrJ1L/8emjAkDEkwPM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754569183468538.1574843203429; Thu, 7 Aug 2025 05:19:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzTr-0005ah-8e; Thu, 07 Aug 2025 08:12:24 -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 1ujzSk-0004uY-0D; Thu, 07 Aug 2025 08:11:20 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSh-0005Bt-1z; Thu, 07 Aug 2025 08:11:12 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:23 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:20 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568671; x=1786104671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=HwaA85D1ebnP7sljFlP5CUp7wIWrQyXh6BKaMqw9KoI=; b=kihwz4rJMDfrYbrit18HwOzmevgkwOQjdaP4tjAAE5lbpKUTLmWsflRJ TYr8uMkslv5BoCZ0rSFrbG/6alg5pMWamtEfe24avWDJK+uhE0kfJTQuM db3b8xBDr38Mc0NRpt3RN1JFksBpHL9qEwuPM9tSoAxz4qFoFuubDEX53 UBMNPq53qDH9VxdWBRXU5ekjJSl9Hbr7DEPKTtfuUfNLPgh80SoNt+arC XPC90UfvEMSnB+ZoqiReFWwlfBed5cmZKJ4m5laYb0tT+zKrAo59GymP2 yh2AB5/AueROiI7LvV/YcYUFpc8B6LyRdxgMtEcgXWX0yMiOym7XNRH1g A==; X-CSE-ConnectionGUID: 8bU0UwcoTWK4N4KZJkQyVg== X-CSE-MsgGUID: JCLYadVtR/yQ9SB/IxqXeQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036895" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036895" X-CSE-ConnectionGUID: pBgUH1uQTTKW2pjrCZB+ow== X-CSE-MsgGUID: sOW+MrKyTquBbfV7pekoFg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701342" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 24/26] rust/memory: Provide AddressSpace bindings Date: Thu, 7 Aug 2025 20:30:25 +0800 Message-Id: <20250807123027.2910950-25-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754569184765116600 Content-Type: text/plain; charset="utf-8" QEMU's AddressSpace matches vm_memory::GuestAddressSpace very well, so it's straightforward to implement vm_memory::GuestAddressSpace trait for AddressSpace structure. And since QEMU's memory is almost entirely processed through AddressSpace, provide the high-level memory write/read/store/load interfaces for Rust side use. Additionally, provide the safe binding for address_space_memory. Signed-off-by: Zhao Liu --- rust/qemu-api/src/memory.rs | 149 +++++++++++++++++++++++++++++++++--- 1 file changed, 140 insertions(+), 9 deletions(-) diff --git a/rust/qemu-api/src/memory.rs b/rust/qemu-api/src/memory.rs index 23347f35e5da..42bba23cf3f8 100644 --- a/rust/qemu-api/src/memory.rs +++ b/rust/qemu-api/src/memory.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later =20 //! Bindings for `MemoryRegion`, `MemoryRegionOps`, `MemTxAttrs` -//! `MemoryRegionSection` and `FlatView`. +//! `MemoryRegionSection`, `FlatView` and `AddressSpace`. =20 use std::{ ffi::{c_uint, c_void, CStr, CString}, @@ -11,7 +11,7 @@ marker::PhantomData, mem::size_of, ops::Deref, - ptr::NonNull, + ptr::{addr_of, NonNull}, sync::atomic::Ordering, }; =20 @@ -19,21 +19,25 @@ pub use bindings::{hwaddr, MemTxAttrs}; pub use vm_memory::GuestAddress; use vm_memory::{ - bitmap::BS, Address, AtomicAccess, Bytes, GuestMemory, GuestMemoryErro= r, GuestMemoryRegion, - GuestMemoryResult, GuestUsize, MemoryRegionAddress, ReadVolatile, Vola= tileSlice, WriteVolatile, + bitmap::BS, Address, AtomicAccess, Bytes, GuestAddressSpace, GuestMemo= ry, GuestMemoryError, + GuestMemoryRegion, GuestMemoryResult, GuestUsize, MemoryRegionAddress,= ReadVolatile, + VolatileSlice, WriteVolatile, }; =20 use crate::{ bindings::{ - self, address_space_lookup_section, device_endian, flatview_ref, - flatview_translate_section, flatview_unref, memory_region_init_io,= section_access_allowed, - section_covers_region_addr, section_fuzz_dma_read, section_get_hos= t_addr, - section_rust_load, section_rust_read_continue_step, section_rust_s= tore, - section_rust_write_continue_step, MEMTX_OK, + self, address_space_lookup_section, address_space_memory, address_= space_to_flatview, + device_endian, flatview_ref, flatview_translate_section, flatview_= unref, + memory_region_init_io, section_access_allowed, section_covers_regi= on_addr, + section_fuzz_dma_read, section_get_host_addr, section_rust_load, + section_rust_read_continue_step, section_rust_store, section_rust_= write_continue_step, + MEMTX_OK, }, callbacks::FnCall, cell::Opaque, + error::{Error, Result}, prelude::*, + rcu::{rcu_read_lock, rcu_read_unlock}, uninit::MaybeUninitField, zeroable::Zeroable, }; @@ -1016,3 +1020,130 @@ fn clone(&self) -> Self { ) } } + +/// A safe wrapper around [`bindings::AddressSpace`]. +/// +/// [`AddressSpace`] is the address space abstraction in QEMU, which +/// provides memory access for the Guest memory it managed. +#[repr(transparent)] +#[derive(qemu_api_macros::Wrapper)] +pub struct AddressSpace(Opaque); + +unsafe impl Send for AddressSpace {} +unsafe impl Sync for AddressSpace {} + +impl GuestAddressSpace for AddressSpace { + type M =3D FlatView; + type T =3D FlatViewRefGuard; + + /// Get the memory of the [`AddressSpace`]. + /// + /// This function retrieves the [`FlatView`] for the current + /// [`AddressSpace`]. And it should be called from an RCU + /// critical section. The returned [`FlatView`] is used for + /// short-term memory access. + /// + /// Note, this function method may **panic** if [`FlatView`] is + /// being distroying. Fo this case, we should consider to providing + /// the more stable binding with [`bindings::address_space_get_flatvie= w`]. + fn memory(&self) -> Self::T { + let flatp =3D unsafe { address_space_to_flatview(self.0.as_mut_ptr= ()) }; + FlatViewRefGuard::new(unsafe { Self::M::from_raw(flatp) }).expect( + "Failed to clone FlatViewRefGuard: the FlatView may have been = destroyed concurrently.", + ) + } +} + +/// The helper to convert [`vm_memory::GuestMemoryError`] to +/// [`crate::error::Error`]. +#[track_caller] +fn guest_mem_err_to_qemu_err(err: GuestMemoryError) -> Error { + match err { + GuestMemoryError::InvalidGuestAddress(addr) =3D> { + Error::from(format!("Invalid guest address: {:#x}", addr.raw_v= alue())) + } + GuestMemoryError::InvalidBackendAddress =3D> Error::from("Invalid = backend memory address"), + GuestMemoryError::GuestAddressOverflow =3D> { + Error::from("Guest address addition resulted in an overflow") + } + GuestMemoryError::CallbackOutOfRange =3D> { + Error::from("Callback accessed memory out of range") + } + GuestMemoryError::IOError(io_err) =3D> Error::with_error("Guest me= mory I/O error", io_err), + other_err =3D> Error::with_error("An unexpected guest memory error= occurred", other_err), + } +} + +impl AddressSpace { + /// The write interface of `AddressSpace`. + /// + /// This function is similar to `address_space_write` in C side. + /// + /// But it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. + pub fn write(&self, buf: &[u8], addr: GuestAddress) -> Result { + rcu_read_lock(); + let r =3D self.memory().deref().write(buf, addr); + rcu_read_unlock(); + r.map_err(guest_mem_err_to_qemu_err) + } + + /// The read interface of `AddressSpace`. + /// + /// This function is similar to `address_space_read_full` in C side. + /// + /// But it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. + /// + /// It should also be noted that this function does not support the fa= st + /// path like `address_space_read` in C side. + pub fn read(&self, buf: &mut [u8], addr: GuestAddress) -> Result { + rcu_read_lock(); + let r =3D self.memory().deref().read(buf, addr); + rcu_read_unlock(); + r.map_err(guest_mem_err_to_qemu_err) + } + + /// The store interface of `AddressSpace`. + /// + /// This function is similar to `address_space_st{size}` in C side. + /// + /// But it only assumes @val follows target-endian by default. So ensu= re + /// the endian of `val` aligned with target, before using this method. + /// + /// And it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. + pub fn store(&self, addr: GuestAddress, val: T) -> Re= sult<()> { + rcu_read_lock(); + let r =3D self.memory().deref().store(val, addr, Ordering::Relaxed= ); + rcu_read_unlock(); + r.map_err(guest_mem_err_to_qemu_err) + } + + /// The load interface of `AddressSpace`. + /// + /// This function is similar to `address_space_ld{size}` in C side. + /// + /// But it only support target-endian by default. The returned value = is + /// with target-endian. + /// + /// And it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. + pub fn load(&self, addr: GuestAddress) -> Result { + rcu_read_lock(); + let r =3D self.memory().deref().load(addr, Ordering::Relaxed); + rcu_read_unlock(); + r.map_err(guest_mem_err_to_qemu_err) + } +} + +/// The safe binding around [`bindings::address_space_memory`]. +/// +/// `ADDRESS_SPACE_MEMORY` provides the complete address space +/// abstraction for the whole Guest memory. +pub static ADDRESS_SPACE_MEMORY: &AddressSpace =3D unsafe { + let ptr: *const bindings::AddressSpace =3D addr_of!(address_space_memo= ry); + + // SAFETY: AddressSpace is #[repr(transparent)]. + let wrapper_ptr: *const AddressSpace =3D ptr.cast(); + + // SAFETY: `address_space_memory` structure is valid in C side during + // the whole QEMU life. + &*wrapper_ptr +}; --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568860; cv=none; d=zohomail.com; s=zohoarc; b=anQilF+BPVAVy6MWa5TivwmI1OiKaZMQQlZfq6QhFXqk0s5Pcoo7P6zC0B3hd9zSWiRto/S1gOW2rCt2ErnVEm5C7fcrH9zijFGWIsrZ/q0WhvEOZPHXAfFW6CDVuZqPflqdJoiiO6VPY/zhqrdo2fhauy9h7J31JO3Bx9nXBN0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568860; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cupwHwBPO3x9nWNTjYB8iFvEE8UWoHPXtG5zzvNdpDw=; b=YpvJKAZue6xJ0lf+Zwp+cT/IEWhBvxkzqxknhApFqUZgOoih8pjxZaC8wH6tk3cfiI5r3DdeTjm0vG3e43IbZVQNw7GeuzKucHNKK5o5pO84869P6mHA8UYcKsTQe0HNchRVGhBBnIWqz1W/ANCklEF/waqMIPK9fUUvUuRbDGI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568860267554.5375419571727; Thu, 7 Aug 2025 05:14:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzTD-0004yN-RC; Thu, 07 Aug 2025 08:11:49 -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 1ujzSP-0004ES-46; Thu, 07 Aug 2025 08:10:53 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSN-0005Cn-0B; Thu, 07 Aug 2025 08:10:52 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:26 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:24 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568651; x=1786104651; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=YO4ppsApMppmvSjO1TZkcO3ACCoVl7NKzejbdkLlymk=; b=BNggH4HZLYdV3gCOHmA1ZNCcsU0gb1IFJDWqggeMv96IOfJMwYvc25Kx V3fr/mx8MT5ZVQ75CeQ/pF4y1Z/CuNQ8vcU88FOJNwVt4rH7DHhyCIeGz RFamCEGxlH8AvmAO7RF13VbowBKbOYN+aY8wVPJum5amBwNJsKDQpn4gU EQxQGSWuQk/rz8K8JXfxEtQJ7bK+pMjE1283JdOb6p0S9LVaWtVb3J37+ 6J0BGj1OOpIXgz3rfQ67UbmVXeEAdY0qL7ugNqG/jaRPyuM0/15vGEr6C JQ6z57gKoH7AEzi469RqU6zu7aZFFgI67giAXjfns8iYRNwIF/uOqDGCE g==; X-CSE-ConnectionGUID: /QATM6S7Re2vBUZh1vZbpw== X-CSE-MsgGUID: rTO61MxoTBmfFxb3/Ia+tA== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036906" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036906" X-CSE-ConnectionGUID: QnB0AqLoTyOiW+nlg5knlw== X-CSE-MsgGUID: SGplsYhWTzKtdQ0BoEubNA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701368" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 25/26] rust/memory: Add binding to check target endian Date: Thu, 7 Aug 2025 20:30:26 +0800 Message-Id: <20250807123027.2910950-26-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568862321124100 Content-Type: text/plain; charset="utf-8" Add a binding (target_is_big_endian()) to check whether target is big endian or not. This could help user to adjust endian before calling AddresssSpace::store() or after calling AddressSpace::load(). Add the example in the documentation of AddresssSpace::store() to help explain how to use it. Signed-off-by: Zhao Liu Reviewed-by: Manos Pitsidianakis --- rust/qemu-api/src/memory.rs | 28 +++++++++++++++++++++++++--- rust/qemu-api/wrapper.h | 1 + 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/rust/qemu-api/src/memory.rs b/rust/qemu-api/src/memory.rs index 42bba23cf3f8..a8eb83c95ead 100644 --- a/rust/qemu-api/src/memory.rs +++ b/rust/qemu-api/src/memory.rs @@ -31,7 +31,7 @@ memory_region_init_io, section_access_allowed, section_covers_regi= on_addr, section_fuzz_dma_read, section_get_host_addr, section_rust_load, section_rust_read_continue_step, section_rust_store, section_rust_= write_continue_step, - MEMTX_OK, + target_big_endian, MEMTX_OK, }, callbacks::FnCall, cell::Opaque, @@ -1107,9 +1107,25 @@ pub fn read(&self, buf: &mut [u8], addr: GuestAddres= s) -> Result { /// This function is similar to `address_space_st{size}` in C side. /// /// But it only assumes @val follows target-endian by default. So ensu= re - /// the endian of `val` aligned with target, before using this method. + /// the endian of `val` aligned with target, before using this method.= The + /// taget-endian can be checked with [`target_is_big_endian`]. /// /// And it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. + /// + /// # Examples + /// + /// ``` + /// use qemu_api::memory::{ADDRESS_SPACE_MEMORY, target_is_big_endian}; + /// + /// let addr =3D GuestAddress(0x123438000); + /// let val: u32 =3D 5; + /// let val_end =3D if target_is_big_endian() { + /// val.to_be() + /// } else { + /// val.to_le() + /// } + /// + /// assert!(ADDRESS_SPACE_MEMORY.store(addr, val_end).is_ok()); pub fn store(&self, addr: GuestAddress, val: T) -> Re= sult<()> { rcu_read_lock(); let r =3D self.memory().deref().store(val, addr, Ordering::Relaxed= ); @@ -1122,7 +1138,8 @@ pub fn store(&self, addr: GuestAddre= ss, val: T) -> Result<()> { /// This function is similar to `address_space_ld{size}` in C side. /// /// But it only support target-endian by default. The returned value = is - /// with target-endian. + /// with target-endian. The taget-endian can be checked with + /// [`target_is_big_endian`]. /// /// And it assumes the memory attributes is MEMTXATTRS_UNSPECIFIED. pub fn load(&self, addr: GuestAddress) -> Result { @@ -1147,3 +1164,8 @@ pub fn load(&self, addr: GuestAddres= s) -> Result { // the whole QEMU life. &*wrapper_ptr }; + +pub fn target_is_big_endian() -> bool { + // SAFETY: the return value is boolean, so it is always valid. + unsafe { target_big_endian() } +} diff --git a/rust/qemu-api/wrapper.h b/rust/qemu-api/wrapper.h index ce0ac8d3f550..c466b93054aa 100644 --- a/rust/qemu-api/wrapper.h +++ b/rust/qemu-api/wrapper.h @@ -70,3 +70,4 @@ typedef enum memory_order { #include "system/address-spaces.h" #include "hw/char/pl011.h" #include "qemu/rcu.h" +#include "qemu/target-info.h" --=20 2.34.1 From nobody Sun Dec 14 01:41:09 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass header.i=@intel.com; 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=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1754568953; cv=none; d=zohomail.com; s=zohoarc; b=RVR4Kl/fvilicZ7ZF9BRVunSE2yPOl5TBFTcutudWIIOMl2OR/BqjnCew6bc4tLkD6Pi9JTsS7s0oX7sJOYaBQ8uWgxIVNT6f9S24pPvMfyUVpNP3c65FaeA6mcClssvXfl6c/z4AbidGq0oaNT1ptC/0wBs5YYbh3SMAskn+G8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1754568953; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xoN7K6uzSAjg8aBVQcJPlRQxnUc7NOBvZNgWoFh5cQQ=; b=XFmDFmvrr3XvwK1xXi9xAmn9PMSzxbAVKSvDUSqymdClcnAOXBMULi1YDrgFtrEXW+zjNU0EVl6rmufGVXc/QWpBrPLkzE7qdRrLkjBJdlsQYCqUCUckHaTV+9gqzlObxRuW8i4tpQVQk9QdjwxCmm0xWV1MbhfuYFfUp/TtH6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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 1754568953165245.3546959287221; Thu, 7 Aug 2025 05:15:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ujzUj-0006x5-Bx; Thu, 07 Aug 2025 08:13:24 -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 1ujzSq-0004yg-4i; Thu, 07 Aug 2025 08:11:29 -0400 Received: from mgamail.intel.com ([192.198.163.15]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ujzSh-0005Bp-HS; Thu, 07 Aug 2025 08:11:14 -0400 Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Aug 2025 05:10:30 -0700 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.39]) by orviesa009.jf.intel.com with ESMTP; 07 Aug 2025 05:10:27 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1754568671; x=1786104671; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jN3evfjR5JAhw4apUNC93dHaq2BAAIYH0p23ThxZVjo=; b=GsKrB7+63/Z4Y7iBz5YCJC/AfVAvJ0cvB0wUxU5etLMKvcXlro5lD7Oh nymbZf25JJe67hAZHTfK/adq41x7DSj6X6rUHZS8hutee3B0jlrQOHmD6 PYx35Z7iqsBoGp3HnL1tl5Csqzjd1Ms69pD9g2g/dtu7nj9YkzD7Xo8bY zV8SlaTfl6NneL2u+d5efYdifDodDutzUz5HCp1P9d47oufln5MYyD7HY RRG9k9vn2W9+vQCyN+i4dlrm4m0Bzw1oFAgu2hoaYqbwR/6qPoim0B/CW KFJ8G17h+Z3naK+LtdGKnwrc3uXY+CvrW3K/S10NrTQm31hkPl5lQfafI w==; X-CSE-ConnectionGUID: xemCJoOATNy+jLpf6E7ypg== X-CSE-MsgGUID: rFF3pVwNQAaFxZJlcxd4cQ== X-IronPort-AV: E=McAfee;i="6800,10657,11514"; a="57036918" X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="57036918" X-CSE-ConnectionGUID: TEg37fmSRGSdceh1NUe7xw== X-CSE-MsgGUID: 5bLf66UzTlmtIkV+Jq2tVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.17,271,1747724400"; d="scan'208";a="164701391" From: Zhao Liu To: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Manos Pitsidianakis , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Thomas Huth , Junjie Mao Cc: qemu-devel@nongnu.org, qemu-rust@nongnu.org, Dapeng Mi , Chuanxiao Dong , Zhao Liu Subject: [RFC 26/26] rust/hpet: Use safe binding to access address space Date: Thu, 7 Aug 2025 20:30:27 +0800 Message-Id: <20250807123027.2910950-27-zhao1.liu@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250807123027.2910950-1-zhao1.liu@intel.com> References: <20250807123027.2910950-1-zhao1.liu@intel.com> MIME-Version: 1.0 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=192.198.163.15; envelope-from=zhao1.liu@intel.com; helo=mgamail.intel.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, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1754568955542124100 Content-Type: text/plain; charset="utf-8" Currently, HPET uses unsafe address_space_stl_le() to store MSI message. Considerring HPET is used for x86 machines, and they're little endian. So address_space_stl_le() equals to address_space_stl(), which makes it possible to replace address_space_stl_le() with AddressSpace::store(). Therefore, use the safe binding - AddressSpace::store(), to access address space. Since then, the last unsafe piece of HPET has been filled in. Signed-off-by: Zhao Liu --- rust/hw/timer/hpet/src/device.rs | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/rust/hw/timer/hpet/src/device.rs b/rust/hw/timer/hpet/src/devi= ce.rs index 9fd75bf096e4..e7d5b57f2fe2 100644 --- a/rust/hw/timer/hpet/src/device.rs +++ b/rust/hw/timer/hpet/src/device.rs @@ -6,19 +6,17 @@ ffi::{c_int, c_void, CStr}, mem::MaybeUninit, pin::Pin, - ptr::{addr_of_mut, null_mut, NonNull}, + ptr::NonNull, slice::from_ref, }; =20 use qemu_api::{ - bindings::{ - address_space_memory, address_space_stl_le, qdev_prop_bit, qdev_pr= op_bool, - qdev_prop_uint32, qdev_prop_usize, - }, + bindings::{qdev_prop_bit, qdev_prop_bool, qdev_prop_uint32, qdev_prop_= usize}, cell::{BqlCell, BqlRefCell}, irq::InterruptSource, memory::{ - hwaddr, MemoryRegion, MemoryRegionOps, MemoryRegionOpsBuilder, MEM= TXATTRS_UNSPECIFIED, + hwaddr, GuestAddress, MemoryRegion, MemoryRegionOps, MemoryRegionO= psBuilder, + ADDRESS_SPACE_MEMORY, }, prelude::*, qdev::{DeviceImpl, DeviceState, Property, ResetType, ResettablePhasesI= mpl}, @@ -327,17 +325,12 @@ fn set_irq(&mut self, set: bool) { =20 if set && self.is_int_enabled() && self.get_state().is_hpet_enable= d() { if self.is_fsb_route_enabled() { - // SAFETY: - // the parameters are valid. - unsafe { - address_space_stl_le( - addr_of_mut!(address_space_memory), - self.fsb >> 32, // Timer N FSB int addr - self.fsb as u32, // Timer N FSB int value, truncat= e! - MEMTXATTRS_UNSPECIFIED, - null_mut(), - ); - } + ADDRESS_SPACE_MEMORY + .store( + GuestAddress(self.fsb >> 32), // Timer N FSB int a= ddr + self.fsb as u32, // Timer N FSB int v= alue, truncate! + ) + .expect("Failed to store into ADDRESS_SPACE_MEMORY."); } else if self.is_int_level_triggered() { self.get_state().irqs[route].raise(); } else { --=20 2.34.1