lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DFQ45GSQLR55.1GRM6DSYTG01D@nvidia.com>
Date: Sat, 17 Jan 2026 00:19:58 +0900
From: "Alexandre Courbot" <acourbot@...dia.com>
To: "Daniel Almeida" <daniel.almeida@...labora.com>
Cc: "Dirk Behme" <Dirk.Behme@...bosch.com>, "Dirk Behme"
 <dirk.behme@...il.com>, "Danilo Krummrich" <dakr@...nel.org>, "Alice Ryhl"
 <aliceryhl@...gle.com>, "Maarten Lankhorst"
 <maarten.lankhorst@...ux.intel.com>, "Maxime Ripard" <mripard@...nel.org>,
 "Thomas Zimmermann" <tzimmermann@...e.de>, "David Airlie"
 <airlied@...il.com>, "Simona Vetter" <simona@...ll.ch>, "Miguel Ojeda"
 <ojeda@...nel.org>, "Boqun Feng" <boqun.feng@...il.com>, "Gary Guo"
 <gary@...yguo.net>, Björn Roy Baron
 <bjorn3_gh@...tonmail.com>, "Benno Lossin" <lossin@...nel.org>, "Andreas
 Hindborg" <a.hindborg@...nel.org>, "Trevor Gross" <tmgross@...ch.edu>,
 "Steven Price" <steven.price@....com>, <dri-devel@...ts.freedesktop.org>,
 <linux-kernel@...r.kernel.org>, <rust-for-linux@...r.kernel.org>
Subject: Re: [PATCH] rust/drm: tyr: Convert to the register!() macro

On Fri Jan 16, 2026 at 9:26 PM JST, Daniel Almeida wrote:
> +cc Alex,
>
>
>>>> +    31:0    l2_pwractive_hi as u32, "Bitmap of L2 caches active (higher 32 bits)";
>>>> +});
>>>> +
>>>>  pub(crate) const MCU_CONTROL_ENABLE: u32 = 1;
>>>>  pub(crate) const MCU_CONTROL_AUTO: u32 = 2;
>>>>  pub(crate) const MCU_CONTROL_DISABLE: u32 = 0;
>>>>  -pub(crate) const MCU_STATUS: Register<0x704> = Register;
>>>> +register!(McuControl @ 0x700, "Controls the execution state of the MCU subsystem" {
>>>> +    1:0     req as u32, "Request state change";
>>>> +});
>>> Any reason why req is a u32 and not a u8? Same for some other places.
>>> And would it be an option to move the const MCU_CONTROL* to an ìmpl
>>> McuControl Same for STATUS below.
>> 
>> Just fyi something like [1] builds for me.
>> 
>> This is inspired by
>> 
>> https://lore.kernel.org/rust-for-linux/20251003154748.1687160-6-joelagnelf@nvidia.com/
>> 
>> Best regards
>> 
>> Dirk
>> 
>> [1]
>> 
>> #[repr(u32)]
>> #[derive(Debug, Default, Clone, Copy, PartialEq)]
>> enum McuControl {
>>    #[default]
>>    Disable = 0,
>>    Enable = 1,
>>    Auto = 2,
>> }
>> 
>> impl From<McuControl> for u8 {
>>    fn from(ctrl: McuControl) -> Self {
>>        ctrl as u8
>>    }
>> }
>> 
>> impl From<u8> for McuControl {
>>    fn from(req: u8) -> Self {
>>        match req & 0x3 {
>>            0 => McuControl::Disable,
>>            1 => McuControl::Enable,
>>            2 => McuControl::Auto,
>>            _ => McuControl::Disable,
>>        }
>>    }
>> }
>> 
>> register!(MCUCONTROL @ 0x700, "Controls the execution state of the MCU subsystem" {
>>    1:0     req as u8 => McuControl, "Request state change";
>> });
>
> Alex, looking at the above, I wonder if a “as Foo” would be a good
> addition to the macro? That would then invoke a TryFrom implementation, i.e.:
>
>
> register!(MCUCONTROL @ 0x700, "Controls the execution state of the MCU subsystem" {
>    1:0     req as McuControl => McuControl, "Request state change";
> });

So the register macro that I will submit for the kernel crate will be
significantly different from the one in Nova. Expect something closer to
[1].

This means that fields won't need to have an explicit integer type
anymore (they will automatically use the corresponding `BoundedInt`
instead).

IIUC this will them behave as you expect.

[1] https://lore.kernel.org/rust-for-linux/20251108-bounded_ints-v4-4-c9342ac7ebd1@nvidia.com/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ