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: <4E14EE9C-727F-49D4-AE01-96CB101705C5@collabora.com>
Date: Fri, 25 Jul 2025 14:49:08 -0300
From: Daniel Almeida <daniel.almeida@...labora.com>
To: Alexandre Courbot <acourbot@...dia.com>
Cc: Danilo Krummrich <dakr@...nel.org>,
 David Airlie <airlied@...il.com>,
 Simona Vetter <simona@...ll.ch>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>,
 Thomas Zimmermann <tzimmermann@...e.de>,
 Beata Michalska <beata.michalska@....com>,
 nouveau@...ts.freedesktop.org,
 dri-devel@...ts.freedesktop.org,
 rust-for-linux@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2 11/19] gpu: nova-core: register: improve `Debug`
 implementation



> On 18 Jul 2025, at 04:26, Alexandre Courbot <acourbot@...dia.com> wrote:
> 
> Now that we have an internal rule to dispatch field information where
> needed, use it to generate a better `Debug` implementation where the raw
> hexadecimal value of the register is displayed, as well as the `Debug`
> values of its individual fields.
> 
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> ---
> drivers/gpu/nova-core/regs/macros.rs | 25 +++++++++++++++----------
> 1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/regs/macros.rs
> index 8b081242595de620cbf94b405838a2dac67b8e83..485cac806e4a6578059c657f3b31f15e361becbd 100644
> --- a/drivers/gpu/nova-core/regs/macros.rs
> +++ b/drivers/gpu/nova-core/regs/macros.rs
> @@ -122,16 +122,6 @@ macro_rules! register {
>         #[derive(Clone, Copy, Default)]
>         pub(crate) struct $name(u32);
> 
> -        // TODO[REGA]: display the raw hex value, then the value of all the fields. This requires
> -        // matching the fields, which will complexify the syntax considerably...
> -        impl ::core::fmt::Debug for $name {
> -            fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
> -                f.debug_tuple(stringify!($name))
> -                    .field(&format_args!("0x{0:x}", &self.0))
> -                    .finish()
> -            }
> -        }
> -
>         impl ::core::ops::BitOr for $name {
>             type Output = Self;
> 
> @@ -171,6 +161,7 @@ fn from(reg: $name) -> u32 {
>             ;
>             )*
>         });
> +        register!(@debug $name { $($field;)* });
>     };
> 
>     // Defines all the field getter/methods methods for `$name`.
> @@ -316,6 +307,20 @@ pub(crate) fn [<set_ $field>](mut self, value: $to_type) -> Self {
>         );
>     };
> 
> +    // Generates the `Debug` implementation for `$name`.
> +    (@debug $name:ident { $($field:ident;)* }) => {
> +        impl ::core::fmt::Debug for $name {
> +            fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
> +                f.debug_struct(stringify!($name))
> +                    .field("<raw>", &format_args!("{:#x}", &self.0))
> +                $(
> +                    .field(stringify!($field), &self.$field())
> +                )*
> +                    .finish()
> +            }
> +        }
> +    };
> +
>     // Generates the IO accessors for a fixed offset register.
>     (@io $name:ident @ $offset:expr) => {
>         #[allow(dead_code)]
> 
> -- 
> 2.50.1
> 

Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ