xref: /linux/include/linux/bug.h (revision 608e2619682e951f525b08e7a48669a3c0263b41)
17664c5a1SJeremy Fitzhardinge #ifndef _LINUX_BUG_H
27664c5a1SJeremy Fitzhardinge #define _LINUX_BUG_H
37664c5a1SJeremy Fitzhardinge 
47664c5a1SJeremy Fitzhardinge #include <linux/module.h>
57664c5a1SJeremy Fitzhardinge #include <asm/bug.h>
67664c5a1SJeremy Fitzhardinge 
77664c5a1SJeremy Fitzhardinge enum bug_trap_type {
87664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_NONE = 0,
97664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_WARN = 1,
107664c5a1SJeremy Fitzhardinge 	BUG_TRAP_TYPE_BUG = 2,
117664c5a1SJeremy Fitzhardinge };
127664c5a1SJeremy Fitzhardinge 
13*608e2619SHeiko Carstens struct pt_regs;
14*608e2619SHeiko Carstens 
157664c5a1SJeremy Fitzhardinge #ifdef CONFIG_GENERIC_BUG
167664c5a1SJeremy Fitzhardinge #include <asm-generic/bug.h>
177664c5a1SJeremy Fitzhardinge 
187664c5a1SJeremy Fitzhardinge static inline int is_warning_bug(const struct bug_entry *bug)
197664c5a1SJeremy Fitzhardinge {
207664c5a1SJeremy Fitzhardinge 	return bug->flags & BUGFLAG_WARNING;
217664c5a1SJeremy Fitzhardinge }
227664c5a1SJeremy Fitzhardinge 
237664c5a1SJeremy Fitzhardinge const struct bug_entry *find_bug(unsigned long bugaddr);
247664c5a1SJeremy Fitzhardinge 
25*608e2619SHeiko Carstens enum bug_trap_type report_bug(unsigned long bug_addr, struct pt_regs *regs);
267664c5a1SJeremy Fitzhardinge 
277664c5a1SJeremy Fitzhardinge int  module_bug_finalize(const Elf_Ehdr *, const Elf_Shdr *,
287664c5a1SJeremy Fitzhardinge 			 struct module *);
297664c5a1SJeremy Fitzhardinge void module_bug_cleanup(struct module *);
307664c5a1SJeremy Fitzhardinge 
317664c5a1SJeremy Fitzhardinge /* These are defined by the architecture */
327664c5a1SJeremy Fitzhardinge int is_valid_bugaddr(unsigned long addr);
337664c5a1SJeremy Fitzhardinge 
347664c5a1SJeremy Fitzhardinge #else	/* !CONFIG_GENERIC_BUG */
357664c5a1SJeremy Fitzhardinge 
36*608e2619SHeiko Carstens static inline enum bug_trap_type report_bug(unsigned long bug_addr,
37*608e2619SHeiko Carstens 					    struct pt_regs *regs)
387664c5a1SJeremy Fitzhardinge {
397664c5a1SJeremy Fitzhardinge 	return BUG_TRAP_TYPE_BUG;
407664c5a1SJeremy Fitzhardinge }
417664c5a1SJeremy Fitzhardinge static inline int  module_bug_finalize(const Elf_Ehdr *hdr,
427664c5a1SJeremy Fitzhardinge 					const Elf_Shdr *sechdrs,
437664c5a1SJeremy Fitzhardinge 					struct module *mod)
447664c5a1SJeremy Fitzhardinge {
457664c5a1SJeremy Fitzhardinge 	return 0;
467664c5a1SJeremy Fitzhardinge }
477664c5a1SJeremy Fitzhardinge static inline void module_bug_cleanup(struct module *mod) {}
487664c5a1SJeremy Fitzhardinge 
497664c5a1SJeremy Fitzhardinge #endif	/* CONFIG_GENERIC_BUG */
507664c5a1SJeremy Fitzhardinge #endif	/* _LINUX_BUG_H */
51