diff options
| author | FUJITA Tomonori <[email protected]> | 2025-05-02 09:45:36 +0000 |
|---|---|---|
| committer | Miguel Ojeda <[email protected]> | 2025-07-23 00:05:58 +0000 |
| commit | dff64b072708ffef23c117fa1ee1ea59eb417807 (patch) | |
| tree | 99ed37fa488992927df083ec1bd40243d61339e5 /rust/helpers/helpers.c | |
| parent | arm64/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust (diff) | |
| download | kernel-dff64b072708ffef23c117fa1ee1ea59eb417807.tar.gz kernel-dff64b072708ffef23c117fa1ee1ea59eb417807.zip | |
rust: Add warn_on macro
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 <[email protected]>
Reviewed-by: Alice Ryhl <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[ 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 <[email protected]>
Diffstat (limited to 'rust/helpers/helpers.c')
0 files changed, 0 insertions, 0 deletions
