mirror of
https://github.com/torvalds/linux.git
synced 2025-11-03 10:10:33 +02:00
Add warn_on macro, uses the BUG/WARN feature (lib/bug.c) via assembly for x86_64/arm64/riscv. The current Rust code simply wraps BUG() macro but doesn't provide the proper debug information. The BUG/WARN feature can only be used from assembly. This uses the assembly code exported by the C side via ARCH_WARN_ASM macro. To avoid duplicating the assembly code, this approach follows the same strategy as the static branch code: it generates the assembly code for Rust using the C preprocessor at compile time. Similarly, ARCH_WARN_REACHABLE is also used at compile time to generate the assembly code; objtool's reachable annotation code. It's used for only architectures that use objtool. For now, Loongarch and arm just use a wrapper for WARN macro. UML doesn't use the assembly BUG/WARN feature; just wrapping generic BUG/WARN functions implemented in C works. Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20250502094537.231725-5-fujita.tomonori@gmail.com [ Avoid evaluating the condition twice (a good idea in general, but it also matches the C side). Simplify with `as_char_ptr()` to avoid a cast. Cast to `ffi` integer types for `warn_slowpath_fmt`. Avoid cast for `null()`. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org> |
||
|---|---|---|
| .. | ||
| auxiliary.c | ||
| blk.c | ||
| bug.c | ||
| build_assert.c | ||
| build_bug.c | ||
| clk.c | ||
| completion.c | ||
| cpu.c | ||
| cpufreq.c | ||
| cpumask.c | ||
| cred.c | ||
| device.c | ||
| dma.c | ||
| drm.c | ||
| err.c | ||
| fs.c | ||
| helpers.c | ||
| io.c | ||
| jump_label.c | ||
| kunit.c | ||
| mm.c | ||
| mutex.c | ||
| page.c | ||
| pci.c | ||
| pid_namespace.c | ||
| platform.c | ||
| rbtree.c | ||
| rcu.c | ||
| refcount.c | ||
| security.c | ||
| signal.c | ||
| slab.c | ||
| spinlock.c | ||
| sync.c | ||
| task.c | ||
| time.c | ||
| uaccess.c | ||
| vmalloc.c | ||
| wait.c | ||
| workqueue.c | ||
| xarray.c | ||