2021-07-03 16:42:57 +02:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
2024-09-13 22:29:22 +01:00
|
|
|
# We want to map these types to `isize`/`usize` manually, instead of
|
|
|
|
|
# define them as `int`/`long` depending on platform bitwidth.
|
|
|
|
|
--blocklist-type __kernel_s?size_t
|
|
|
|
|
--blocklist-type __kernel_ptrdiff_t
|
|
|
|
|
|
2021-07-03 16:42:57 +02:00
|
|
|
--opaque-type xregs_state
|
|
|
|
|
--opaque-type desc_struct
|
|
|
|
|
--opaque-type arch_lbr_state
|
|
|
|
|
--opaque-type local_apic
|
|
|
|
|
|
|
|
|
|
# Packed type cannot transitively contain a `#[repr(align)]` type.
|
rust: bindgen: Add `alt_instr` as opaque type
To address this build error:
BINDGEN rust/bindings/bindings_generated.rs
BINDGEN rust/bindings/bindings_helpers_generated.rs
EXPORTS rust/exports_core_generated.h
RUSTC P rust/libmacros.so
RUSTC L rust/compiler_builtins.o
RUSTC L rust/alloc.o
RUSTC L rust/bindings.o
RUSTC L rust/build_error.o
EXPORTS rust/exports_alloc_generated.h
error[E0588]: packed type cannot transitively contain a `#[repr(align)]` type
--> /var/home/acme/git/linux/rust/bindings/bindings_generated.rs:10094:1
|
10094 | / pub struct alt_instr {
10095 | | pub instr_offset: s32,
10096 | | pub repl_offset: s32,
10097 | | pub __bindgen_anon_1: alt_instr__bindgen_ty_1,
10098 | | pub instrlen: u8_,
10099 | | pub replacementlen: u8_,
10100 | | }
| |_^
|
note: `alt_instr__bindgen_ty_1__bindgen_ty_1` has a `#[repr(align)]` attribute
--> /var/home/acme/git/linux/rust/bindings/bindings_generated.rs:10111:1
|
10111 | / pub struct alt_instr__bindgen_ty_1__bindgen_ty_1 {
10112 | | pub _bitfield_1: __BindgenBitfieldUnit<[u8; 4usize], u16>,
10113 | | }
| |_^
note: `alt_instr` contains a field of type `alt_instr__bindgen_ty_1`
--> /var/home/acme/git/linux/rust/bindings/bindings_generated.rs:10097:9
|
10097 | pub __bindgen_anon_1: alt_instr__bindgen_ty_1,
| ^^^^^^^^^^^^^^^^
note: ...which contains a field of type `alt_instr__bindgen_ty_1__bindgen_ty_1`
--> /var/home/acme/git/linux/rust/bindings/bindings_generated.rs:10104:9
|
10104 | pub __bindgen_anon_1: alt_instr__bindgen_ty_1__bindgen_ty_1,
| ^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0588`.
make[1]: *** [rust/Makefile:389: rust/bindings.o] Error 1
make: *** [Makefile:1293: prepare] Error 2
Cc: Derek Barbosa <debarbos@redhat.com>
Cc: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Fixes: 5d1dd961e743 ("x86/alternatives: Add alt_instr.flags")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-03-02 11:16:36 -03:00
|
|
|
--opaque-type alt_instr
|
2021-07-03 16:42:57 +02:00
|
|
|
--opaque-type x86_msi_data
|
|
|
|
|
--opaque-type x86_msi_addr_lo
|
|
|
|
|
|
|
|
|
|
# `try` is a reserved keyword since Rust 2018; solved in `bindgen` v0.59.2,
|
|
|
|
|
# commit 2aed6b021680 ("context: Escape the try keyword properly").
|
|
|
|
|
--opaque-type kunit_try_catch
|
|
|
|
|
|
|
|
|
|
# If SMP is disabled, `arch_spinlock_t` is defined as a ZST which triggers a Rust
|
|
|
|
|
# warning. We don't need to peek into it anyway.
|
|
|
|
|
--opaque-type spinlock
|
|
|
|
|
|
|
|
|
|
# `seccomp`'s comment gets understood as a doctest
|
|
|
|
|
--no-doc-comments
|
2023-10-31 20:19:44 +00:00
|
|
|
|
|
|
|
|
# These functions use the `__preserve_most` calling convention, which neither bindgen
|
|
|
|
|
# nor Rust currently understand, and which Clang currently declares to be unstable.
|
|
|
|
|
--blocklist-function __list_.*_report
|
2024-09-16 01:33:46 +01:00
|
|
|
|
|
|
|
|
# These constants are sometimes not recognized by bindgen depending on config.
|
|
|
|
|
# We use const helpers to aid bindgen, to avoid conflicts when constants are
|
|
|
|
|
# recognized, block generation of the non-helper constants.
|
|
|
|
|
--blocklist-item ARCH_SLAB_MINALIGN
|
rust: alloc: add ARCH_KMALLOC_MINALIGN to bindgen blocklist
For some architectures, such as X86_64, ARCH_KMALLOC_MINALIGN is not
resolvable for bindgen. E.g. due to being defined as
__alignof__(unsigned long long).
Hence, we have to create a rust helper, i.e. let the C compiler evaluate
the expression and store it in a const.
However, if for other architectures, such as arm64,
ARCH_KMALLOC_MINALIGN does evaluate to something that can be directly
processed by bindgen, we end up with multiple definitions of
ARCH_KMALLOC_MINALIGN in the generated bindings.
error[E0428]: the name `ARCH_KMALLOC_MINALIGN` is defined multiple times
--> /builddir/build/BUILD/kernel-6.17.0-build/kernel-next-20250818/linux-6.17.0-0.0.next.20250818.423.vanilla.fc44.aarch64/rust/bindings/bindings_generated.rs:134545:1
|
9622 | pub const ARCH_KMALLOC_MINALIGN: u32 = 8;
| ----------------------------------------- previous definition of the value `ARCH_KMALLOC_MINALIGN` here
...
134545 | pub const ARCH_KMALLOC_MINALIGN: usize = 8;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ARCH_KMALLOC_MINALIGN` redefined here
|
= note: `ARCH_KMALLOC_MINALIGN` must be defined only once in the value namespace of this module
To fix this up, add ARCH_KMALLOC_MINALIGN to the blocklist of bindgen,
such that we always only generate the symbol from the rust helper.
Reported-by: Thorsten Leemhuis <linux@leemhuis.info>
Closes: https://lore.kernel.org/all/8aa05f08-ef6e-4dfe-9453-beaab7b3cb98@leemhuis.info/
Fixes: 1b1a946dc2b5 ("rust: alloc: specify the minimum alignment of each allocator")
Tested-by: Thorsten Leemhuis <linux@leemhuis.info>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/20250818180923.192042-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-08-18 20:08:48 +02:00
|
|
|
--blocklist-item ARCH_KMALLOC_MINALIGN
|
2025-08-14 11:30:29 +02:00
|
|
|
|
|
|
|
|
# Structs should implement `Zeroable` when all of their fields do.
|
|
|
|
|
--with-derive-custom-struct .*=MaybeZeroable
|
|
|
|
|
--with-derive-custom-union .*=MaybeZeroable
|