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: <CAH5fLghOp4+P5SVMAoNbxwjf9HASRRU11SErJary7SZ0qrB-HA@mail.gmail.com>
Date: Wed, 11 Jun 2025 23:32:06 +0200
From: Alice Ryhl <aliceryhl@...gle.com>
To: Andrew Ballance <andrewjballance@...il.com>
Cc: jbaron@...mai.com, jim.cromie@...il.com, daniel.almeida@...labora.com, 
	acourbot@...dia.com, ojeda@...nel.org, alex.gaynor@...il.com, 
	boqun.feng@...il.com, gary@...yguo.net, bjorn3_gh@...tonmail.com, 
	lossin@...nel.org, a.hindborg@...nel.org, tmgross@...ch.edu, dakr@...nel.org, 
	gregkh@...uxfoundation.org, rafael@...nel.org, rostedt@...dmis.org, 
	viresh.kumar@...aro.org, lina+kernel@...hilina.net, tamird@...il.com, 
	jubalh@...oru.org, rust-for-linux@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 1/3] rust: static jump: add support for nested arguments

On Wed, Jun 11, 2025 at 10:30 PM Andrew Ballance
<andrewjballance@...il.com> wrote:
>
> allows for nested arguments to be used with the static_branch macro.
> e.g. `outer.inner.key` can now be accessed by the macro
>
> Signed-off-by: Andrew Ballance <andrewjballance@...il.com>
> ---
>  rust/kernel/jump_label.rs | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/rust/kernel/jump_label.rs b/rust/kernel/jump_label.rs
> index 4e974c768dbd..4ea3cbb340ff 100644
> --- a/rust/kernel/jump_label.rs
> +++ b/rust/kernel/jump_label.rs
> @@ -19,9 +19,9 @@
>  /// The macro must be used with a real static key defined by C.
>  #[macro_export]
>  macro_rules! static_branch_unlikely {
> -    ($key:path, $keytyp:ty, $field:ident) => {{
> +    ($key:path, $keytyp:ty, $field:ident $(.$field_cont:ident)*) => {{

I think this can be:
($key:path, $keytyp:ty, $($field:ident).+) => {{

this means "one or more identifiers separated by dots.

>          let _key: *const $keytyp = ::core::ptr::addr_of!($key);
> -        let _key: *const $crate::bindings::static_key_false = ::core::ptr::addr_of!((*_key).$field);
> +        let _key: *const $crate::bindings::static_key_false = ::core::ptr::addr_of!((*_key).$field$(.$field_cont)*);
>          let _key: *const $crate::bindings::static_key = _key.cast();
>
>          #[cfg(not(CONFIG_JUMP_LABEL))]
> @@ -30,7 +30,7 @@ macro_rules! static_branch_unlikely {
>          }
>
>          #[cfg(CONFIG_JUMP_LABEL)]
> -        $crate::jump_label::arch_static_branch! { $key, $keytyp, $field, false }
> +        $crate::jump_label::arch_static_branch! { $key, $keytyp, $field$(.$field_cont)*, false }
>      }};
>  }
>  pub use static_branch_unlikely;
> @@ -46,14 +46,14 @@ macro_rules! static_branch_unlikely {
>  #[doc(hidden)]
>  #[cfg(CONFIG_JUMP_LABEL)]
>  macro_rules! arch_static_branch {
> -    ($key:path, $keytyp:ty, $field:ident, $branch:expr) => {'my_label: {
> +    ($key:path, $keytyp:ty, $field:ident $(.$field_cont:ident)*, $branch:expr) => {'my_label: {
>          $crate::asm!(
>              include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_static_branch_asm.rs"));
>              l_yes = label {
>                  break 'my_label true;
>              },
>              symb = sym $key,
> -            off = const ::core::mem::offset_of!($keytyp, $field),
> +            off = const ::core::mem::offset_of!($keytyp, $field$(.$field_cont)*),
>              branch = const $crate::jump_label::bool_to_int($branch),
>          );
>
> --
> 2.49.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ