[no subject]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +
>  endif # CONFIG_RUST
> diff --git a/rust/exports.c b/rust/exports.c
> index 587f0e776aba..1b52460b0f4e 100644
> --- a/rust/exports.c
> +++ b/rust/exports.c
> @@ -16,10 +16,13 @@
>  #define EXPORT_SYMBOL_RUST_GPL(sym) extern int sym; EXPORT_SYMBOL_GPL(sym)
>
>  #include "exports_core_generated.h"
> -#include "exports_helpers_generated.h"
>  #include "exports_bindings_generated.h"
>  #include "exports_kernel_generated.h"
>
> +#ifndef CONFIG_RUST_INLINE_HELPERS
> +#include "exports_helpers_generated.h"
> +#endif
> +
>  // For modules using `rust/build_error.rs`.
>  #ifdef CONFIG_RUST_BUILD_ASSERT_ALLOW
>  EXPORT_SYMBOL_RUST_GPL(rust_build_error);
> diff --git a/rust/helpers/blk.c b/rust/helpers/blk.c
> index cc9f4e6a2d23..a96e5ddf384d 100644
> --- a/rust/helpers/blk.c
> +++ b/rust/helpers/blk.c
> @@ -2,13 +2,14 @@
>
>  #include <linux/blk-mq.h>
>  #include <linux/blkdev.h>
> +#include "helpers.h"
>
> -void *rust_helper_blk_mq_rq_to_pdu(struct request *rq)
> +__rust_helper void *rust_helper_blk_mq_rq_to_pdu(struct request *rq)
>  {
>         return blk_mq_rq_to_pdu(rq);
>  }
>
> -struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu)
> +__rust_helper struct request *rust_helper_blk_mq_rq_from_pdu(void *pdu)
>  {
>         return blk_mq_rq_from_pdu(pdu);
>  }
> diff --git a/rust/helpers/bug.c b/rust/helpers/bug.c
> index e2d13babc737..3bff5b730ca8 100644
> --- a/rust/helpers/bug.c
> +++ b/rust/helpers/bug.c
> @@ -1,8 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/bug.h>
> +#include "helpers.h"
>
> -__noreturn void rust_helper_BUG(void)
> +__rust_helper __noreturn void rust_helper_BUG(void)
>  {
>         BUG();
>  }
> diff --git a/rust/helpers/build_bug.c b/rust/helpers/build_bug.c
> index 44e579488037..9dc273fd8db1 100644
> --- a/rust/helpers/build_bug.c
> +++ b/rust/helpers/build_bug.c
> @@ -1,8 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/errname.h>
> +#include "helpers.h"
>
> -const char *rust_helper_errname(int err)
> +__rust_helper const char *rust_helper_errname(int err)
>  {
>         return errname(err);
>  }
> diff --git a/rust/helpers/cred.c b/rust/helpers/cred.c
> index fde7ae20cdd1..9dceeb7f8c87 100644
> --- a/rust/helpers/cred.c
> +++ b/rust/helpers/cred.c
> @@ -1,13 +1,14 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/cred.h>
> +#include "helpers.h"
>
> -const struct cred *rust_helper_get_cred(const struct cred *cred)
> +__rust_helper const struct cred *rust_helper_get_cred(const struct cred *cred)
>  {
>         return get_cred(cred);
>  }
>
> -void rust_helper_put_cred(const struct cred *cred)
> +__rust_helper void rust_helper_put_cred(const struct cred *cred)
>  {
>         put_cred(cred);
>  }
> diff --git a/rust/helpers/device.c b/rust/helpers/device.c
> index b2135c6686b0..b9432cb2f085 100644
> --- a/rust/helpers/device.c
> +++ b/rust/helpers/device.c
> @@ -2,9 +2,9 @@
>
>  #include <linux/device.h>
>
> -int rust_helper_devm_add_action(struct device *dev,
> -                               void (*action)(void *),
> -                               void *data)
> +__rust_helper int rust_helper_devm_add_action(struct device *dev,
> +                                             void (*action)(void *),
> +                                             void *data)
>  {
>         return devm_add_action(dev, action, data);
>  }
> diff --git a/rust/helpers/err.c b/rust/helpers/err.c
> index 544c7cb86632..b05516fce504 100644
> --- a/rust/helpers/err.c
> +++ b/rust/helpers/err.c
> @@ -1,18 +1,19 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/err.h>
> +#include "helpers.h"
>
> -__force void *rust_helper_ERR_PTR(long err)
> +__rust_helper __force void *rust_helper_ERR_PTR(long err)
>  {
>         return ERR_PTR(err);
>  }
>
> -bool rust_helper_IS_ERR(__force const void *ptr)
> +__rust_helper bool rust_helper_IS_ERR(__force const void *ptr)
>  {
>         return IS_ERR(ptr);
>  }
>
> -long rust_helper_PTR_ERR(__force const void *ptr)
> +__rust_helper long rust_helper_PTR_ERR(__force const void *ptr)
>  {
>         return PTR_ERR(ptr);
>  }
> diff --git a/rust/helpers/fs.c b/rust/helpers/fs.c
> index a75c96763372..7d44bda94203 100644
> --- a/rust/helpers/fs.c
> +++ b/rust/helpers/fs.c
> @@ -5,8 +5,9 @@
>   */
>
>  #include <linux/fs.h>
> +#include "helpers.h"
>
> -struct file *rust_helper_get_file(struct file *f)
> +__rust_helper struct file *rust_helper_get_file(struct file *f)
>  {
>         return get_file(f);
>  }
> diff --git a/rust/helpers/helpers.h b/rust/helpers/helpers.h
> new file mode 100644
> index 000000000000..d6ee9bf6f5ae
> --- /dev/null
> +++ b/rust/helpers/helpers.h
> @@ -0,0 +1,13 @@
> +#ifndef RUST_HELPERS_H
> +#define RUST_HELPERS_H
> +
> +#include <linux/compiler_types.h>
> +
> +#ifdef __BINDGEN__
> +// Omit `inline` for bindgen as it ignores inline functions.
> +#define __rust_helper
> +#else
> +#define __rust_helper inline
> +#endif
> +
> +#endif
> diff --git a/rust/helpers/io.c b/rust/helpers/io.c
> index 4c2401ccd720..f61cf77cf9cd 100644
> --- a/rust/helpers/io.c
> +++ b/rust/helpers/io.c
> @@ -1,100 +1,105 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/io.h>
> +#include "helpers.h"
>
> -void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
> +__rust_helper void __iomem *rust_helper_ioremap(phys_addr_t offset, size_t size)
>  {
>         return ioremap(offset, size);
>  }
>
> -void rust_helper_iounmap(volatile void __iomem *addr)
> +__rust_helper void rust_helper_iounmap(volatile void __iomem *addr)
>  {
>         iounmap(addr);
>  }
>
> -u8 rust_helper_readb(const volatile void __iomem *addr)
> +__rust_helper u8 rust_helper_readb(const volatile void __iomem *addr)
>  {
>         return readb(addr);
>  }
>
> -u16 rust_helper_readw(const volatile void __iomem *addr)
> +__rust_helper u16 rust_helper_readw(const volatile void __iomem *addr)
>  {
>         return readw(addr);
>  }
>
> -u32 rust_helper_readl(const volatile void __iomem *addr)
> +__rust_helper u32 rust_helper_readl(const volatile void __iomem *addr)
>  {
>         return readl(addr);
>  }
>
>  #ifdef CONFIG_64BIT
> -u64 rust_helper_readq(const volatile void __iomem *addr)
> +__rust_helper u64 rust_helper_readq(const volatile void __iomem *addr)
>  {
>         return readq(addr);
>  }
>  #endif
>
> -void rust_helper_writeb(u8 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writeb(u8 value, volatile void __iomem *addr)
>  {
>         writeb(value, addr);
>  }
>
> -void rust_helper_writew(u16 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writew(u16 value, volatile void __iomem *addr)
>  {
>         writew(value, addr);
>  }
>
> -void rust_helper_writel(u32 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writel(u32 value, volatile void __iomem *addr)
>  {
>         writel(value, addr);
>  }
>
>  #ifdef CONFIG_64BIT
> -void rust_helper_writeq(u64 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writeq(u64 value, volatile void __iomem *addr)
>  {
>         writeq(value, addr);
>  }
>  #endif
>
> -u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
> +__rust_helper u8 rust_helper_readb_relaxed(const volatile void __iomem *addr)
>  {
>         return readb_relaxed(addr);
>  }
>
> -u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
> +__rust_helper u16 rust_helper_readw_relaxed(const volatile void __iomem *addr)
>  {
>         return readw_relaxed(addr);
>  }
>
> -u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
> +__rust_helper u32 rust_helper_readl_relaxed(const volatile void __iomem *addr)
>  {
>         return readl_relaxed(addr);
>  }
>
>  #ifdef CONFIG_64BIT
> -u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
> +__rust_helper u64 rust_helper_readq_relaxed(const volatile void __iomem *addr)
>  {
>         return readq_relaxed(addr);
>  }
>  #endif
>
> -void rust_helper_writeb_relaxed(u8 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writeb_relaxed(u8 value,
> +                                             volatile void __iomem *addr)
>  {
>         writeb_relaxed(value, addr);
>  }
>
> -void rust_helper_writew_relaxed(u16 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writew_relaxed(u16 value,
> +                                             volatile void __iomem *addr)
>  {
>         writew_relaxed(value, addr);
>  }
>
> -void rust_helper_writel_relaxed(u32 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writel_relaxed(u32 value,
> +                                             volatile void __iomem *addr)
>  {
>         writel_relaxed(value, addr);
>  }
>
>  #ifdef CONFIG_64BIT
> -void rust_helper_writeq_relaxed(u64 value, volatile void __iomem *addr)
> +__rust_helper void rust_helper_writeq_relaxed(u64 value,
> +                                             volatile void __iomem *addr)
>  {
>         writeq_relaxed(value, addr);
>  }
> diff --git a/rust/helpers/jump_label.c b/rust/helpers/jump_label.c
> index fc1f1e0df08e..c97a66c51cce 100644
> --- a/rust/helpers/jump_label.c
> +++ b/rust/helpers/jump_label.c
> @@ -5,9 +5,10 @@
>   */
>
>  #include <linux/jump_label.h>
> +#include "helpers.h"
>
>  #ifndef CONFIG_JUMP_LABEL
> -int rust_helper_static_key_count(struct static_key *key)
> +__rust_helper int rust_helper_static_key_count(struct static_key *key)
>  {
>         return static_key_count(key);
>  }
> diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c
> index b85a4d394c11..f3621a564626 100644
> --- a/rust/helpers/kunit.c
> +++ b/rust/helpers/kunit.c
> @@ -1,8 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <kunit/test-bug.h>
> +#include "helpers.h"
>
> -struct kunit *rust_helper_kunit_get_current_test(void)
> +__rust_helper struct kunit *rust_helper_kunit_get_current_test(void)
>  {
>         return kunit_get_current_test();
>  }
> diff --git a/rust/helpers/mutex.c b/rust/helpers/mutex.c
> index 06575553eda5..8900cd504cb2 100644
> --- a/rust/helpers/mutex.c
> +++ b/rust/helpers/mutex.c
> @@ -1,19 +1,21 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/mutex.h>
> +#include "helpers.h"
>
> -void rust_helper_mutex_lock(struct mutex *lock)
> +__rust_helper void rust_helper_mutex_lock(struct mutex *lock)
>  {
>         mutex_lock(lock);
>  }
>
> -void rust_helper___mutex_init(struct mutex *mutex, const char *name,
> -                             struct lock_class_key *key)
> +__rust_helper void rust_helper___mutex_init(struct mutex *mutex,
> +                                           const char *name,
> +                                           struct lock_class_key *key)
>  {
>         __mutex_init(mutex, name, key);
>  }
>
> -void rust_helper_mutex_assert_is_held(struct mutex *mutex)
> +__rust_helper void rust_helper_mutex_assert_is_held(struct mutex *mutex)
>  {
>         lockdep_assert_held(mutex);
>  }
> diff --git a/rust/helpers/page.c b/rust/helpers/page.c
> index b3f2b8fbf87f..cf7deea25cfa 100644
> --- a/rust/helpers/page.c
> +++ b/rust/helpers/page.c
> @@ -2,18 +2,20 @@
>
>  #include <linux/gfp.h>
>  #include <linux/highmem.h>
> +#include "helpers.h"
>
> -struct page *rust_helper_alloc_pages(gfp_t gfp_mask, unsigned int order)
> +__rust_helper struct page *rust_helper_alloc_pages(gfp_t gfp_mask,
> +                                                  unsigned int order)
>  {
>         return alloc_pages(gfp_mask, order);
>  }
>
> -void *rust_helper_kmap_local_page(struct page *page)
> +__rust_helper void *rust_helper_kmap_local_page(struct page *page)
>  {
>         return kmap_local_page(page);
>  }
>
> -void rust_helper_kunmap_local(const void *addr)
> +__rust_helper void rust_helper_kunmap_local(const void *addr)
>  {
>         kunmap_local(addr);
>  }
> diff --git a/rust/helpers/pci.c b/rust/helpers/pci.c
> index 8ba22f911459..5b1066028d7d 100644
> --- a/rust/helpers/pci.c
> +++ b/rust/helpers/pci.c
> @@ -1,18 +1,20 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/pci.h>
> +#include "helpers.h"
>
> -void rust_helper_pci_set_drvdata(struct pci_dev *pdev, void *data)
> +__rust_helper void rust_helper_pci_set_drvdata(struct pci_dev *pdev, void *data)
>  {
>         pci_set_drvdata(pdev, data);
>  }
>
> -void *rust_helper_pci_get_drvdata(struct pci_dev *pdev)
> +__rust_helper void *rust_helper_pci_get_drvdata(struct pci_dev *pdev)
>  {
>         return pci_get_drvdata(pdev);
>  }
>
> -resource_size_t rust_helper_pci_resource_len(struct pci_dev *pdev, int bar)
> +__rust_helper resource_size_t rust_helper_pci_resource_len(struct pci_dev *pdev,
> +                                                          int bar)
>  {
>         return pci_resource_len(pdev, bar);
>  }
> diff --git a/rust/helpers/pid_namespace.c b/rust/helpers/pid_namespace.c
> index f41482bdec9a..f4419c3ff5bb 100644
> --- a/rust/helpers/pid_namespace.c
> +++ b/rust/helpers/pid_namespace.c
> @@ -2,19 +2,22 @@
>
>  #include <linux/pid_namespace.h>
>  #include <linux/cleanup.h>
> +#include "helpers.h"
>
> -struct pid_namespace *rust_helper_get_pid_ns(struct pid_namespace *ns)
> +__rust_helper struct pid_namespace *
> +rust_helper_get_pid_ns(struct pid_namespace *ns)
>  {
>         return get_pid_ns(ns);
>  }
>
> -void rust_helper_put_pid_ns(struct pid_namespace *ns)
> +__rust_helper void rust_helper_put_pid_ns(struct pid_namespace *ns)
>  {
>         put_pid_ns(ns);
>  }
>
>  /* Get a reference on a task's pid namespace. */
> -struct pid_namespace *rust_helper_task_get_pid_ns(struct task_struct *task)
> +__rust_helper struct pid_namespace *
> +rust_helper_task_get_pid_ns(struct task_struct *task)
>  {
>         struct pid_namespace *pid_ns;
>
> diff --git a/rust/helpers/platform.c b/rust/helpers/platform.c
> index ab9b9f317301..052b2a09f1a9 100644
> --- a/rust/helpers/platform.c
> +++ b/rust/helpers/platform.c
> @@ -1,13 +1,16 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/platform_device.h>
> +#include "helpers.h"
>
> -void *rust_helper_platform_get_drvdata(const struct platform_device *pdev)
> +__rust_helper void *
> +rust_helper_platform_get_drvdata(const struct platform_device *pdev)
>  {
>         return platform_get_drvdata(pdev);
>  }
>
> -void rust_helper_platform_set_drvdata(struct platform_device *pdev, void *data)
> +__rust_helper void
> +rust_helper_platform_set_drvdata(struct platform_device *pdev, void *data)
>  {
>         platform_set_drvdata(pdev, data);
>  }
> diff --git a/rust/helpers/rbtree.c b/rust/helpers/rbtree.c
> index 6d404b84a9b5..784d8796aa1c 100644
> --- a/rust/helpers/rbtree.c
> +++ b/rust/helpers/rbtree.c
> @@ -1,9 +1,11 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/rbtree.h>
> +#include "helpers.h"
>
> -void rust_helper_rb_link_node(struct rb_node *node, struct rb_node *parent,
> -                             struct rb_node **rb_link)
> +__rust_helper void rust_helper_rb_link_node(struct rb_node *node,
> +                                           struct rb_node *parent,
> +                                           struct rb_node **rb_link)
>  {
>         rb_link_node(node, parent, rb_link);
>  }
> diff --git a/rust/helpers/rcu.c b/rust/helpers/rcu.c
> index f1cec6583513..0bd98ab32300 100644
> --- a/rust/helpers/rcu.c
> +++ b/rust/helpers/rcu.c
> @@ -1,13 +1,14 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/rcupdate.h>
> +#include "helpers.h"
>
> -void rust_helper_rcu_read_lock(void)
> +__rust_helper void rust_helper_rcu_read_lock(void)
>  {
>         rcu_read_lock();
>  }
>
> -void rust_helper_rcu_read_unlock(void)
> +__rust_helper void rust_helper_rcu_read_unlock(void)
>  {
>         rcu_read_unlock();
>  }
> diff --git a/rust/helpers/refcount.c b/rust/helpers/refcount.c
> index d6adbd2e45a1..ad80e153bf37 100644
> --- a/rust/helpers/refcount.c
> +++ b/rust/helpers/refcount.c
> @@ -1,18 +1,19 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/refcount.h>
> +#include "helpers.h"
>
> -refcount_t rust_helper_REFCOUNT_INIT(int n)
> +__rust_helper refcount_t rust_helper_REFCOUNT_INIT(int n)
>  {
>         return (refcount_t)REFCOUNT_INIT(n);
>  }
>
> -void rust_helper_refcount_inc(refcount_t *r)
> +__rust_helper void rust_helper_refcount_inc(refcount_t *r)
>  {
>         refcount_inc(r);
>  }
>
> -bool rust_helper_refcount_dec_and_test(refcount_t *r)
> +__rust_helper bool rust_helper_refcount_dec_and_test(refcount_t *r)
>  {
>         return refcount_dec_and_test(r);
>  }
> diff --git a/rust/helpers/security.c b/rust/helpers/security.c
> index 0c4c2065df28..676c82a4a6eb 100644
> --- a/rust/helpers/security.c
> +++ b/rust/helpers/security.c
> @@ -1,19 +1,22 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/security.h>
> +#include "helpers.h"
>
>  #ifndef CONFIG_SECURITY
> -void rust_helper_security_cred_getsecid(const struct cred *c, u32 *secid)
> +__rust_helper void rust_helper_security_cred_getsecid(const struct cred *c,
> +                                                     u32 *secid)
>  {
>         security_cred_getsecid(c, secid);
>  }
>
> -int rust_helper_security_secid_to_secctx(u32 secid, struct lsm_context *cp)
> +__rust_helper int rust_helper_security_secid_to_secctx(u32 secid,
> +                                                      struct lsm_context *cp)
>  {
>         return security_secid_to_secctx(secid, cp);
>  }
>
> -void rust_helper_security_release_secctx(struct lsm_context *cp)
> +__rust_helper void rust_helper_security_release_secctx(struct lsm_context *cp)
>  {
>         security_release_secctx(cp);
>  }
> diff --git a/rust/helpers/signal.c b/rust/helpers/signal.c
> index 1a6bbe9438e2..67d3fe8d5132 100644
> --- a/rust/helpers/signal.c
> +++ b/rust/helpers/signal.c
> @@ -1,8 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/sched/signal.h>
> +#include "helpers.h"
>
> -int rust_helper_signal_pending(struct task_struct *t)
> +__rust_helper int rust_helper_signal_pending(struct task_struct *t)
>  {
>         return signal_pending(t);
>  }
> diff --git a/rust/helpers/slab.c b/rust/helpers/slab.c
> index a842bfbddcba..71dd3fc88d53 100644
> --- a/rust/helpers/slab.c
> +++ b/rust/helpers/slab.c
> @@ -1,15 +1,16 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/slab.h>
> +#include "helpers.h"
>
> -void * __must_check __realloc_size(2)
> -rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags)
> +__rust_helper void *__must_check __realloc_size(2)
> +       rust_helper_krealloc(const void *objp, size_t new_size, gfp_t flags)
>  {
>         return krealloc(objp, new_size, flags);
>  }
>
> -void * __must_check __realloc_size(2)
> -rust_helper_kvrealloc(const void *p, size_t size, gfp_t flags)
> +__rust_helper void *__must_check __realloc_size(2)
> +       rust_helper_kvrealloc(const void *p, size_t size, gfp_t flags)
>  {
>         return kvrealloc(p, size, flags);
>  }
> diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
> index 42c4bf01a23e..023ef3a24913 100644
> --- a/rust/helpers/spinlock.c
> +++ b/rust/helpers/spinlock.c
> @@ -1,9 +1,11 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/spinlock.h>
> +#include "helpers.h"
>
> -void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
> -                                 struct lock_class_key *key)
> +__rust_helper 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)
> @@ -16,22 +18,22 @@ void rust_helper___spin_lock_init(spinlock_t *lock, const char *name,
>  #endif /* CONFIG_DEBUG_SPINLOCK */
>  }
>
> -void rust_helper_spin_lock(spinlock_t *lock)
> +__rust_helper void rust_helper_spin_lock(spinlock_t *lock)
>  {
>         spin_lock(lock);
>  }
>
> -void rust_helper_spin_unlock(spinlock_t *lock)
> +__rust_helper void rust_helper_spin_unlock(spinlock_t *lock)
>  {
>         spin_unlock(lock);
>  }
>
> -int rust_helper_spin_trylock(spinlock_t *lock)
> +__rust_helper int rust_helper_spin_trylock(spinlock_t *lock)
>  {
>         return spin_trylock(lock);
>  }
>
> -void rust_helper_spin_assert_is_held(spinlock_t *lock)
> +__rust_helper void rust_helper_spin_assert_is_held(spinlock_t *lock)
>  {
>         lockdep_assert_held(lock);
>  }
> diff --git a/rust/helpers/task.c b/rust/helpers/task.c
> index 31c33ea2dce6..741e1a4b15ee 100644
> --- a/rust/helpers/task.c
> +++ b/rust/helpers/task.c
> @@ -1,56 +1,57 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/sched/task.h>
> +#include "helpers.h"
>
> -struct task_struct *rust_helper_get_current(void)
> +__rust_helper struct task_struct *rust_helper_get_current(void)
>  {
>         return current;
>  }
>
> -void rust_helper_get_task_struct(struct task_struct *t)
> +__rust_helper void rust_helper_get_task_struct(struct task_struct *t)
>  {
>         get_task_struct(t);
>  }
>
> -void rust_helper_put_task_struct(struct task_struct *t)
> +__rust_helper void rust_helper_put_task_struct(struct task_struct *t)
>  {
>         put_task_struct(t);
>  }
>
> -kuid_t rust_helper_task_uid(struct task_struct *task)
> +__rust_helper kuid_t rust_helper_task_uid(struct task_struct *task)
>  {
>         return task_uid(task);
>  }
>
> -kuid_t rust_helper_task_euid(struct task_struct *task)
> +__rust_helper kuid_t rust_helper_task_euid(struct task_struct *task)
>  {
>         return task_euid(task);
>  }
>
>  #ifndef CONFIG_USER_NS
> -uid_t rust_helper_from_kuid(struct user_namespace *to, kuid_t uid)
> +__rust_helper uid_t rust_helper_from_kuid(struct user_namespace *to, kuid_t uid)
>  {
>         return from_kuid(to, uid);
>  }
>  #endif /* CONFIG_USER_NS */
>
> -bool rust_helper_uid_eq(kuid_t left, kuid_t right)
> +__rust_helper bool rust_helper_uid_eq(kuid_t left, kuid_t right)
>  {
>         return uid_eq(left, right);
>  }
>
> -kuid_t rust_helper_current_euid(void)
> +__rust_helper kuid_t rust_helper_current_euid(void)
>  {
>         return current_euid();
>  }
>
> -struct user_namespace *rust_helper_current_user_ns(void)
> +__rust_helper struct user_namespace *rust_helper_current_user_ns(void)
>  {
>         return current_user_ns();
>  }
>
> -pid_t rust_helper_task_tgid_nr_ns(struct task_struct *tsk,
> -                                 struct pid_namespace *ns)
> +__rust_helper pid_t rust_helper_task_tgid_nr_ns(struct task_struct *tsk,
> +                                               struct pid_namespace *ns)
>  {
>         return task_tgid_nr_ns(tsk, ns);
>  }
> diff --git a/rust/helpers/uaccess.c b/rust/helpers/uaccess.c
> index f49076f813cd..08bf1851c06a 100644
> --- a/rust/helpers/uaccess.c
> +++ b/rust/helpers/uaccess.c
> @@ -1,15 +1,16 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/uaccess.h>
> +#include "helpers.h"
>
> -unsigned long rust_helper_copy_from_user(void *to, const void __user *from,
> -                                        unsigned long n)
> +__rust_helper unsigned long
> +rust_helper_copy_from_user(void *to, const void __user *from, unsigned long n)
>  {
>         return copy_from_user(to, from, n);
>  }
>
> -unsigned long rust_helper_copy_to_user(void __user *to, const void *from,
> -                                      unsigned long n)
> +__rust_helper unsigned long
> +rust_helper_copy_to_user(void __user *to, const void *from, unsigned long n)
>  {
>         return copy_to_user(to, from, n);
>  }
> diff --git a/rust/helpers/vmalloc.c b/rust/helpers/vmalloc.c
> index 80d34501bbc0..6ef908bd45f9 100644
> --- a/rust/helpers/vmalloc.c
> +++ b/rust/helpers/vmalloc.c
> @@ -1,9 +1,10 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/vmalloc.h>
> +#include "helpers.h"
>
> -void * __must_check __realloc_size(2)
> -rust_helper_vrealloc(const void *p, size_t size, gfp_t flags)
> +__rust_helper void *__must_check __realloc_size(2)
> +       rust_helper_vrealloc(const void *p, size_t size, gfp_t flags)
>  {
>         return vrealloc(p, size, flags);
>  }
> diff --git a/rust/helpers/wait.c b/rust/helpers/wait.c
> index ae48e33d9da3..7beaa85494bc 100644
> --- a/rust/helpers/wait.c
> +++ b/rust/helpers/wait.c
> @@ -1,8 +1,9 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/wait.h>
> +#include "helpers.h"
>
> -void rust_helper_init_wait(struct wait_queue_entry *wq_entry)
> +__rust_helper void rust_helper_init_wait(struct wait_queue_entry *wq_entry)
>  {
>         init_wait(wq_entry);
>  }
> diff --git a/rust/helpers/workqueue.c b/rust/helpers/workqueue.c
> index b2b82753509b..4256f8c91ce6 100644
> --- a/rust/helpers/workqueue.c
> +++ b/rust/helpers/workqueue.c
> @@ -1,10 +1,13 @@
>  // SPDX-License-Identifier: GPL-2.0
>
>  #include <linux/workqueue.h>
> +#include "helpers.h"
>
> -void rust_helper_init_work_with_key(struct work_struct *work, work_func_t func,
> -                                   bool onstack, const char *name,
> -                                   struct lock_class_key *key)
> +__rust_helper void rust_helper_init_work_with_key(struct work_struct *work,
> +                                                 work_func_t func,
> +                                                 bool onstack,
> +                                                 const char *name,
> +                                                 struct lock_class_key *key)
>  {
>         __init_work(work, onstack);
>         work->data = (atomic_long_t)WORK_DATA_INIT();
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 08b6380933f5..f7bccb22328b 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -252,7 +252,10 @@ rust_common_cmd = \
>  # would not match each other.
>
>  quiet_cmd_rustc_o_rs = $(RUSTC_OR_CLIPPY_QUIET) $(quiet_modtag) $@
> -      cmd_rustc_o_rs = $(rust_common_cmd) --emit=obj=$@ $< $(cmd_objtool)
> +      cmd_rustc_o_rs = $(rust_common_cmd) --emit=$(if $(CONFIG_RUST_INLINE_HELPERS),llvm-bc=$(patsubst %.o,%.bc,$@),obj=$@) $< \
> +       $(if $(CONFIG_RUST_INLINE_HELPERS),;$(LLVM_LINK) $(patsubst %.o,%.bc,$@) $(objtree)/rust/helpers/helpers.bc -o $(patsubst %.o,%.m.bc,$@); \
> +               $(CC) $(CLANG_FLAGS) $(KBUILD_CFLAGS) -mllvm=--ignore-tti-inline-compatible -c $(patsubst %.o,%.m.bc,$@) -o $@) \
> +       $(cmd_objtool)

Similar question here: should this be defined iff
CONFIG_RUST_INLINE_HELPERS? Always defining them seems like it could
lead to subtle bugs, but perhaps there's Makefile precedent I'm not
aware of.

>
>  define rule_rustc_o_rs
>         $(call cmd_and_fixdep,rustc_o_rs)
> --
> 2.47.2
>





[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux