]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/bug.h
5 #include <linux/compiler.h>
6 #include <linux/build_bug.h>
9 BUG_TRAP_TYPE_NONE
= 0,
10 BUG_TRAP_TYPE_WARN
= 1,
11 BUG_TRAP_TYPE_BUG
= 2,
17 #define MAYBE_BUILD_BUG_ON(cond) (0)
18 #else /* __CHECKER__ */
20 #define MAYBE_BUILD_BUG_ON(cond) \
22 if (__builtin_constant_p((cond))) \
28 #endif /* __CHECKER__ */
30 #ifdef CONFIG_GENERIC_BUG
31 #include <asm-generic/bug.h>
33 static inline int is_warning_bug(const struct bug_entry
*bug
)
35 return bug
->flags
& BUGFLAG_WARNING
;
38 struct bug_entry
*find_bug(unsigned long bugaddr
);
40 enum bug_trap_type
report_bug(unsigned long bug_addr
, struct pt_regs
*regs
);
42 /* These are defined by the architecture */
43 int is_valid_bugaddr(unsigned long addr
);
45 #else /* !CONFIG_GENERIC_BUG */
47 static inline enum bug_trap_type
report_bug(unsigned long bug_addr
,
50 return BUG_TRAP_TYPE_BUG
;
53 #endif /* CONFIG_GENERIC_BUG */
56 * Since detected data corruption should stop operation on the affected
57 * structures. Return value must be checked and sanely acted on by caller.
59 static inline __must_check
bool check_data_corruption(bool v
) { return v
; }
60 #define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
61 check_data_corruption(({ \
62 bool corruption = unlikely(condition); \
64 if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
65 pr_err(fmt, ##__VA_ARGS__); \
68 WARN(1, fmt, ##__VA_ARGS__); \
73 #endif /* _LINUX_BUG_H */