From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796357054; b=njBO17A5zRrRgPCMJPgW8NUwlBXYj0F+I30REo7ee/FJIjE7GKvnDYp35ocE+hj+N/b6 MGn5sPCI/fbygYPisNarv2Asc4ZFpZk30Pl2CLX396mTa63W7dnrKtMXzTDEeyf5a/h9e oT+EeAj5KhOCyJR7o5ST3srPLCWeVcutDMm69LNSoCKx3dV9irTxQK5rAyYS/BpLA5aUR /pqBwhSGxoa29oY6YjO3+MHfxyro/S/0kZicguiBHCby1xRHhHK4oZ6k0HYtbd93ZYZ+R m365iqo9BcbQvW+m5HzSrizaCRw+GLA34NQzHt/N32KirvdFe3XSpYrOyBGgRx+Clqg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796357054; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=M9AJ4g5Sa7W7ZtSYGovHgnAjMQ3uFZJF4E6B49qNndY=; b=XX5crf0+twU2+Um7y/bL9cd0P4zdPxl8L5166Q28s+sIF/O5N6icKwvdHWLGo4BBYIau CI6lBHSkQ080sagpFK3LwvkOaS+ctD1UbB42myaZZiIO1OcLXDImK6BZumKd4lhquWous vLk6Q46sgwLIUg22E6bwIed1n8CJFjYB1aCNr4mW6P4HjI2DoL1hDSGdxxoWpZsrLPDWZ +ovLqzlMbe2UdoDh1Uy9uF7LFjaiqwIOrlOCPvxi7cYmQi+dfs1b9sOFLhyCK/EEKJOYP Hm1Tlj5XWJgbitx3rFlUUVb5Y13qaevaeVbQ3nxfFnCZUluzTF8B0C4cTqH8JUxm94Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eT9Obv23; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1445606A322 for ; Fri, 4 Dec 2026 04:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eT9Obv23 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 351EB1F000C2; Fri, 4 Dec 2026 04:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796357054; bh=M9AJ4g5Sa7W7ZtSYGovHgnAjMQ3uFZJF4E6B49qNndY=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=eT9Obv234R2FD9Lzsk61KxzqPcEWsiUYeKg0DVt/tSEbR5l+17wS6NVXz/LK73l0m YknIUc1usjUwBe3rn2smxW/3HQnR4m0jt38KBnB2WJnnaWGJJIGq9uZR1G2F16y7gP TNtublikOX0hjufG41CisaM522vXGtp/xunj734P8Y8N4kuZqrDjInvwh+UhFNKikw CZkV+GuvMSJxkxQfNAqJDce+Q/DS/o2JKJw3bQruD44OxQyd03Tj89+9QUdQLJkaJ4 MmBY4HxdYzeCaS9P6+V3ZcNtwNU6YnOHzXoRhmUpimrlk/jDIFbCkeRuC3GpRMcKv/ JzHLq14ggclpQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] rust: bitfield: implement compile-time bitfield! overlap check Reply-To: sashiko-reviews@lists.linux.dev To: "Boming Kong" Cc: ojeda@kernel.org, "Alexandre Courbot" , gary@garyguo.net, "Danilo Krummrich" , "Alice Ryhl" , "David Airlie" , "Simona Vetter" , "Yury Norov" , "Boqun Feng" , =?utf-8?b?QmrDtnJuIFJveSBCYXJvbg==?= , "Benno Lossin" , "Andreas Hindborg" , "Trevor Gross" , "Daniel Almeida" , "Tamir Duberstein" , =?utf-8?b?T251ciDDlnprYW4=?= , "Greg Kroah-Hartman" , "Jakub Kicinski" , "Alex Deucher" , "Andrew Morton" , "Jens Axboe" , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org In-Reply-To: <20261204034830.117532-1-michaelkongboming@gmail.com> References: <20261204034830.117532-1-michaelkongboming@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 04:04:12 +0000 X-Mailing-List: nova-gpu@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] rust: bitfield: allow_overlap zeroes mask and hides unrelated overlaps - [Low] rust: bitfield: missing docs for overlap check and allow_overlap - [Low] rust: bitfield: unchecked field attr doc forwarding and misnamed @lohi_chk -- commit 4bf24af3cd86e778bdc829070073575d0ee69450 Author: Boming Kong rust: bitfield: implement compile-time bitfield! overlap check This commit adds compile-time overlap checking to bitfield! (and register! by inheritance), introduces a per-field #[allow_overlap] opt-out, and updates nova-core MMU v2 page table definitions and bitfield tests. > diff --git a/rust/kernel/bitfield.rs b/rust/kernel/bitfield.rs > index 8d7d781753363..fe67cfe9a44ad 100644 > --- a/rust/kernel/bitfield.rs > +++ b/rust/kernel/bitfield.rs > @@ -359,7 +359,7 @@ unsafe impl $crate::mem::AsReprMut for $name {} > // Definitions requiring knowledge of individual fields: private and= public field accessors, > // and `Debug` implementation. > (@fields $vis:vis $name:ident $storage:ty { > - $($(#[doc =3D $doc:expr])* $hi:literal:$lo:literal $field:ident > + $($(#[$attr:ident $(=3D $doc:expr)?])* $hi:literal:$lo:literal $= field:ident > $(?=3D> $try_into_type:ty)? > $(=3D> $into_type:ty)? > ; > @@ -371,7 +371,7 @@ impl $name { > $( > $crate::bitfield!(@private_field_accessors $vis $name $storage := $hi:$lo $field); > $crate::bitfield!( > - @public_field_accessors $(#[doc =3D $doc])* $vis $name $stor= age : $hi:$lo $field > + @public_field_accessors $($(#[doc =3D $doc])?)* $vis $name $= storage : $hi:$lo $field > $(?=3D> $try_into_type)? > $(=3D> $into_type)? > ); > @@ -379,6 +379,9 @@ impl $name { > } > =20 > $crate::bitfield!(@debug $name { $($field;)* }); > + $crate::bitfield!(@lohi_chk $name $storage { > + $($(#[$attr $(=3D $doc)?])* $field;)* > + }); > }; [Severity: Low] Should @fields match doc =3D $doc:expr and allow_overlap explicitly instead of rewriting any key-value attribute into #[doc =3D $doc]? A malformed #[allow_overlap =3D true] gets expanded as #[doc =3D true] on every public accessor, causing spurious doc errors alongside the @allow_overlap error. Also, @lohi_chk is a misleading name since it checks mask overlap rather than lo/hi ordering, and both @allow_overlap and @lohi_chk omit the descriptive comments present on the other helper arms in bitfield!. [ ... ] > @@ -540,6 +543,35 @@ const fn [<__with_ $field>]( > ); > }; > =20 > + (@allow_overlap doc =3D $doc:expr) =3D> { false }; > + (@allow_overlap allow_overlap) =3D> { true }; [Severity: Low] Should the bitfield! syntax documentation in rust/kernel/bitfield.rs (and rust/kernel/io/register.rs, which inherits this behavior) be updated to describe the default compile-time overlap check and the #[allow_overlap] field attribute? > + (@lohi_chk $name:ident $storage:ty { > + $($(#[$attr:ident $(=3D $doc:expr)?])* $field:ident;)* > + }) =3D> { > + ::kernel::macros::paste!( > + const _: () =3D { > + let masks: &[$storage] =3D &[ > + $(if false $(|| $crate::bitfield!(@allow_overlap $attr $= (=3D $doc)?))* { > + 0 > + } else { > + $name::[<$field:upper _MASK>] > + }),* > + ]; > + let err_msg: &[&str] =3D &[ > + $(concat!(stringify!($field), " overlaps a previous fiel= d")),* > + ]; > + let mut used: $storage =3D 0; > + let mut i =3D 0; > + while i < masks.len() { > + ::core::assert!(used & masks[i] =3D=3D 0, "{}", err_msg[= i]); > + used |=3D masks[i]; > + i +=3D 1; > + } > + }; > + ); > + }; [Severity: Medium] Does zeroing the mask for #[allow_overlap] fields disable overlap checks for unrelated fields in both directions? Because the mask becomes 0, the annotated field is never checked against earlier fields, and none of its bits are recorded in used for later unannotated fields. In nova-core's Pde, table_frame_sys (53:8) carries #[allow_overlap], so a typo colliding with no_ats (5:5) would compile. In the same Pde, table_frame_vid (32:8) and peer_id (35:33) leave bits 53:36 unset in used, so a new unannotated field there would silently overlap table_frame_sys. Scoping the opt-out to intended overlapping partners or a mutually exclusive group would keep checking the other bits. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204034830.1175= 32-1-michaelkongboming@gmail.com?part=3D1