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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zw1_rXUyjTBOh0QH@boqun-archlinux>
Date: Mon, 14 Oct 2024 13:31:41 -0700
From: Boqun Feng <boqun.feng@...il.com>
To: Eder Zulian <ezulian@...hat.com>
Cc: rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org,
	williams@...hat.com, ojeda@...nel.org, alex.gaynor@...il.com,
	gary@...yguo.net, bjorn3_gh@...tonmail.com, benno.lossin@...ton.me,
	a.hindborg@...nel.org, aliceryhl@...gle.com, tmgross@...ch.edu
Subject: Re: [PATCH] rust: Fix build error

Hi Eder,

Thanks for the patch!

On Mon, Oct 14, 2024 at 09:52:53PM +0200, Eder Zulian wrote:
> When CONFIG_DEBUG_SPINLOCK=y and CONFIG_PREEMPT_RT=y the following build
> error occurs:
> 
>     In file included from rust/helpers/helpers.c:22:
>     rust/helpers/spinlock.c: In function ‘rust_helper___spin_lock_init’:
>     rust/helpers/spinlock.c:10:30: error: implicit declaration of function ‘spinlock_check’; did you mean ‘spin_lock_bh’? [-Wimplicit-function-declaration]
>        10 |         __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
>           |                              ^~~~~~~~~~~~~~
>           |                              spin_lock_bh
>     rust/helpers/spinlock.c:10:30: error: passing argument 1 of ‘__raw_spin_lock_init’ makes pointer from integer without a cast [-Wint-conversion]
>        10 |         __raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
>           |                              ^~~~~~~~~~~~~~~~~~~~
>           |                              |
>           |                              int
>     In file included from ./include/linux/wait.h:9,
>                      from ./include/linux/wait_bit.h:8,
>                      from ./include/linux/fs.h:6,
>                      from ./include/linux/highmem.h:5,
>                      from ./include/linux/bvec.h:10,
>                      from ./include/linux/blk_types.h:10,
>                      from ./include/linux/blkdev.h:9,
>                      from ./include/linux/blk-mq.h:5,
>                      from rust/helpers/blk.c:3,
>                      from rust/helpers/helpers.c:10:
>     ./include/linux/spinlock.h:101:52: note: expected ‘raw_spinlock_t *’ {aka ‘struct raw_spinlock *’} but argument is of type ‘int’
>       101 |   extern void __raw_spin_lock_init(raw_spinlock_t *lock, const char *name,
>           |                                    ~~~~~~~~~~~~~~~~^~~~
>     make[2]: *** [scripts/Makefile.build:229: rust/helpers/helpers.o] Error 1
> 
> Error observed while building a rt-debug kernel for aarch64.
> 
> On a PREEMPT_RT build, spin locks have been mapped to rt_mutex types, so
> avoid the raw_spinlock_init call for RT.
> 

This is true, but to keep lockdep working I think we need to open code
the PREEMPT_RT version of spin_lock_init(), please see below

> Suggested-by: Clark Williams <williams@...hat.com>
> 

^ unnecessary emtpy line here.

> Signed-off-by: Eder Zulian <ezulian@...hat.com>
> ---
>  rust/helpers/spinlock.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
> index acc1376b833c..924c1a380448 100644
> --- a/rust/helpers/spinlock.c
> +++ b/rust/helpers/spinlock.c
> @@ -6,7 +6,7 @@
>  void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
>  				  struct lock_class_key *key)
>  {
> -#ifdef CONFIG_DEBUG_SPINLOCK
> +#if defined(CONFIG_DEBUG_SPINLOCK) && !defined(CONFIG_PREEMPT_RT)
>  	__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
>  #else
>  	spin_lock_init(lock);

This should be:

void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
 				  struct lock_class_key *key)
{
#ifdef CONFIG_DEBUG_SPINLOCK
# if defined(CONFIG_PREEMPT_RT)
	rt_mutex_base_init(&(lock)->lock);
	__rt_spin_lock_init(lock, name, key, false);
# else /* !CONFIG_PREEMPT_RT */
  	__raw_spin_lock_init(spinlock_check(lock), name, key, LD_WAIT_CONFIG);
# endif /* CONFIG_PREEMPT_RT */
#else
	spin_lock_init(lock);
#endif
}

Regards,
Boqun

> -- 
> 2.46.2
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ