]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/bug.h
1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/compiler.h>
7 #include <linux/build_bug.h>
10 BUG_TRAP_TYPE_NONE
= 0,
11 BUG_TRAP_TYPE_WARN
= 1,
12 BUG_TRAP_TYPE_BUG
= 2,
18 #define MAYBE_BUILD_BUG_ON(cond) (0)
19 #else /* __CHECKER__ */
21 #define MAYBE_BUILD_BUG_ON(cond) \
23 if (__builtin_constant_p((cond))) \
29 #endif /* __CHECKER__ */
31 #ifdef CONFIG_GENERIC_BUG
32 #include <asm-generic/bug.h>
34 static inline int is_warning_bug(const struct bug_entry
*bug
)
36 return bug
->flags
& BUGFLAG_WARNING
;
39 void bug_get_file_line(struct bug_entry
*bug
, const char **file
,
42 struct bug_entry
*find_bug(unsigned long bugaddr
);
44 enum bug_trap_type
report_bug(unsigned long bug_addr
, struct pt_regs
*regs
);
46 /* These are defined by the architecture */
47 int is_valid_bugaddr(unsigned long addr
);
49 void generic_bug_clear_once(void);
51 #else /* !CONFIG_GENERIC_BUG */
53 static inline void *find_bug(unsigned long bugaddr
)
58 static inline enum bug_trap_type
report_bug(unsigned long bug_addr
,
61 return BUG_TRAP_TYPE_BUG
;
65 static inline void bug_get_file_line(struct bug_entry
*bug
, const char **file
,
72 static inline void generic_bug_clear_once(void) {}
74 #endif /* CONFIG_GENERIC_BUG */
77 * Since detected data corruption should stop operation on the affected
78 * structures. Return value must be checked and sanely acted on by caller.
80 static inline __must_check
bool check_data_corruption(bool v
) { return v
; }
81 #define CHECK_DATA_CORRUPTION(condition, fmt, ...) \
82 check_data_corruption(({ \
83 bool corruption = unlikely(condition); \
85 if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
86 pr_err(fmt, ##__VA_ARGS__); \
89 WARN(1, fmt, ##__VA_ARGS__); \
94 #endif /* _LINUX_BUG_H */