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: <E29F0B67-9214-48C3-9B58-808C6B1B7659@collabora.com>
Date: Fri, 25 Jul 2025 14:38:59 -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 10/19] gpu: nova-core: register: add fields dispatcher
 internal rule



> On 18 Jul 2025, at 04:26, Alexandre Courbot <acourbot@...dia.com> wrote:
> 
> Fields are complex and cumbersome to match in a rule, and were only
> captured in order to generate the field accessors. However, there are
> other places (like the `Debug` and `Default` implementations) where we
> would benefit from having access to at least some of the field
> information, but refrained from doing so because it would have meant
> matching the whole fields in a rule more complex than we need.
> 
> Introduce a new `@...lds_dispatcher` internal rule that captures all the
> field information and passes it to `@...ld_accessors`. It does not
> provide any functional change in itself, but allows us to reuse the
> captured field information partially to provide better `Debug` and
> `Default` implementations in following patches.
> 
> Signed-off-by: Alexandre Courbot <acourbot@...dia.com>
> ---
> drivers/gpu/nova-core/regs/macros.rs | 42 +++++++++++++++++++++++++++---------
> 1 file changed, 32 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/nova-core/regs/macros.rs b/drivers/gpu/nova-core/regs/macros.rs
> index 0a18a0d76b2265d3138f93ffc7c561b94bca3187..8b081242595de620cbf94b405838a2dac67b8e83 100644
> --- a/drivers/gpu/nova-core/regs/macros.rs
> +++ b/drivers/gpu/nova-core/regs/macros.rs
> @@ -88,37 +88,33 @@
> macro_rules! register {
>     // Creates a register at a fixed offset of the MMIO space.
>     ($name:ident @ $offset:literal $(, $comment:literal)? { $($fields:tt)* } ) => {
> -        register!(@common $name $(, $comment)?);
> -        register!(@field_accessors $name { $($fields)* });
> +        register!(@core $name $(, $comment)? { $($fields)* } );
>         register!(@io $name @ $offset);
>     };
> 
>     // Creates an alias register of fixed offset register `alias` with its own fields.
>     ($name:ident => $alias:ident $(, $comment:literal)? { $($fields:tt)* } ) => {
> -        register!(@common $name $(, $comment)?);
> -        register!(@field_accessors $name { $($fields)* });
> +        register!(@core $name $(, $comment)? { $($fields)* } );
>         register!(@io $name @ $alias::OFFSET);
>     };
> 
>     // Creates a register at a relative offset from a base address.
>     ($name:ident @ + $offset:literal $(, $comment:literal)? { $($fields:tt)* } ) => {
> -        register!(@common $name $(, $comment)?);
> -        register!(@field_accessors $name { $($fields)* });
> +        register!(@core $name $(, $comment)? { $($fields)* } );
>         register!(@io $name @ + $offset);
>     };
> 
>     // Creates an alias register of relative offset register `alias` with its own fields.
>     ($name:ident => + $alias:ident $(, $comment:literal)? { $($fields:tt)* } ) => {
> -        register!(@common $name $(, $comment)?);
> -        register!(@field_accessors $name { $($fields)* });
> +        register!(@core $name $(, $comment)? { $($fields)* } );
>         register!(@io $name @ + $alias::OFFSET);
>     };
> 
>     // All rules below are helpers.
> 
>     // Defines the wrapper `$name` type, as well as its relevant implementations (`Debug`, `BitOr`,
> -    // and conversion to regular `u32`).
> -    (@common $name:ident $(, $comment:literal)?) => {
> +    // and conversion to the value type) and field accessor methods.
> +    (@core $name:ident $(, $comment:literal)? { $($fields:tt)* }) => {
>         $(
>         #[doc=$comment]
>         )?
> @@ -149,6 +145,32 @@ fn from(reg: $name) -> u32 {
>                 reg.0
>             }
>         }
> +
> +        register!(@fields_dispatcher $name { $($fields)* });
> +    };
> +
> +    // Captures the fields and passes them to all the implementers that require field information.
> +    //
> +    // Used to simplify the matching rules for implementers, so they don't need to match the entire
> +    // complex fields rule even though they only make use of part of it.
> +    (@fields_dispatcher $name:ident {
> +        $($hi:tt:$lo:tt $field:ident as $type:tt
> +            $(?=> $try_into_type:ty)?
> +            $(=> $into_type:ty)?
> +            $(, $comment:literal)?
> +        ;
> +        )*
> +    }
> +    ) => {
> +        register!(@field_accessors $name {
> +            $(
> +                $hi:$lo $field as $type
> +                $(?=> $try_into_type)?
> +                $(=> $into_type)?
> +                $(, $comment)?
> +            ;
> +            )*
> +        });
>     };
> 
>     // Defines all the field getter/methods methods for `$name`.
> 
> -- 
> 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