From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 846CB1917FB; Thu, 4 Sep 2025 11:02:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756983776; cv=pass; b=ADmXjcoKHvIH99yN1wLc41c6wY3oQxRgjtNq7slWYTr8E4jZxkRR2Aujt8x3EdgtYFcFDP3gJKyhv5y8hlC1dBfw4/PXUSqvTrMilinOz3eBTI3FLuLTBlDV1kSu0KMvVP+K2uDDxeFI++ACdx71u7aHUm9WUhmefbxt6DLOwYg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756983776; c=relaxed/simple; bh=3UgIibTB47PeQZqU+bSLcHe5zQ85KUGU4yiKuuPW16U=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=KXP7oCtg+TgRY/wXpQEiN2D+Dp6v/qeJzKmipwbUD0LqWNo9BHFGXCqydoJvIAFxdGhB7c/Uzva2WUhNfQp0pKmEWIoAqpiXIgKMteUR7mE9hBisiVmCBxvvQ0qaRGWmIT1yjtclkV3nyT73GJ+4HdaA21CQ9p/DipuB3jQxMT8= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b=gBHU3Amu; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b="gBHU3Amu" ARC-Seal: i=1; a=rsa-sha256; t=1756983757; cv=none; d=zohomail.com; s=zohoarc; b=YGrZaiFXgz/dcAD/GhG5qWejTWpckke2xtxufSRxDWuIJ8TfsHzsQxzSDX1D1IstkMHOGXUlrdb4GRh0IHLqvh5GLRU0VgsT2nAVtVGcyIr8h/jnKsRO3FhUEoVY1wlOvYsnh2+gXQnqHXqgSWQVQ2yYffpbMCdybTmSIuZbIZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756983757; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=M+c8sBfNK7jTMhcj9S/0VC9pw8RniI4xywgLwf5sppE=; b=bCvYFODO7/KwS+25DN9Px9ISAIUCdCXbhvPcsqXI9TlcLdCp0D1SXxr7hmoIqTni/oj23iG0zWqhnl8s/UZSRsdl4rBmc3Zv0XdOmmL8TAYN3l5QV0t0Dsot0n08onTDCYznArS1n710ERwgk3DfUu9VIc4cwABpL/aXshgkOYU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=daniel.almeida@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1756983756; s=zohomail; d=collabora.com; i=daniel.almeida@collabora.com; h=Content-Type:Mime-Version:Subject:Subject:From:From:In-Reply-To:Date:Date:Cc:Cc:Content-Transfer-Encoding:Message-Id:Message-Id:References:To:To:Reply-To; bh=M+c8sBfNK7jTMhcj9S/0VC9pw8RniI4xywgLwf5sppE=; b=gBHU3AmuyBe8B5E0E8wU5a6jJhJv1uugBOQrrisM+9rIaGMuTo8Rcf4quNHKP8E0 liL6RHiyLZ6rYKSeMfr2d25Il4g17l2rBOreViwmNCxDBEfQbJOCCG+eXjGd8HLPd3R wDIwvWOs8v6Sw3RcjnY+u0UYYMf5EUjtrWad5Z70= Received: by mx.zohomail.com with SMTPS id 1756983753966635.954770851991; Thu, 4 Sep 2025 04:02:33 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: [PATCH 1/2] nova-core: Add a library for bitfields in Rust structs From: Daniel Almeida In-Reply-To: Date: Thu, 4 Sep 2025 08:02:16 -0300 Cc: Joel Fernandes , linux-kernel@vger.kernel.org, Danilo Krummrich , David Airlie , Simona Vetter , Miguel Ojeda , Alex Gaynor , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , John Hubbard , Alistair Popple , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: <8498F151-B4DF-43D3-981E-FAE598964CA2@collabora.com> References: <20250824135954.2243774-1-joelagnelf@nvidia.com> <444ebd64-7a90-46a6-b885-2c114aa59284@nvidia.com> To: Alexandre Courbot X-Mailer: Apple Mail (2.3826.700.81) X-ZohoMailClient: External > On 4 Sep 2025, at 00:16, Alexandre Courbot = wrote: >=20 > On Thu Sep 4, 2025 at 12:15 AM JST, Joel Fernandes wrote: > >>>> +use kernel::prelude::*; >>>> + >>>> +/// Macro for defining bitfield-packed structures in Rust. >>>> +/// The size of the underlying storage type is specified with = #[repr(TYPE)]. >>>> +/// >>>> +/// # Example (just for illustration) >>>> +/// ```rust >>>> +/// bitstruct! { >>>> +/// #[repr(u64)] >>>> +/// pub struct PageTableEntry { >>>> +/// 0:0 present as bool, >>>> +/// 1:1 writable as bool, >>>> +/// 11:9 available as u8, >>>> +/// 51:12 pfn as u64, >>>> +/// 62:52 available2 as u16, >>>> +/// 63:63 nx as bool, >>>=20 >>> A note on syntax: for nova-core, we may want to use the `H:L` = notation, >>> as this is what OpenRM uses, but in the larger kernel we might want = to >>> use inclusive ranges (`L..=3DH`) as it will look more natural in = Rust >>> code (and is the notation the `bits` module already uses). >>=20 >> Perhaps future add-on enhancement to have both syntax? I'd like to = initially >> keep H:L and stabilize the code first, what do you think? >=20 > Let's have the discussion with the other stakeholders (Daniel?). I = think > in Nova we want to keep the `H:L` syntax, as it matches what the = OpenRM > headers do (so Nova would have its own `register` macro that calls = into > the common one, tweaking things as it needs). But in the kernel crate = we > should use something intuitive for everyone. >=20 I don=E2=80=99t specifically care which syntax is used. We will adapt to = it. =E2=80=94 Daniel