XenevaOS
Loading...
Searching...
No Matches
XenevaOS
BaseHdr
linux
bug.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: GPL-2.0 */
2
#ifndef _LINUX_BUG_H
3
#define _LINUX_BUG_H
4
5
#include <
asm/bug.h
>
6
#include <
linux/compiler.h
>
7
#include <
linux/build_bug.h
>
8
9
enum
bug_trap_type
{
10
BUG_TRAP_TYPE_NONE
= 0,
11
BUG_TRAP_TYPE_WARN
= 1,
12
BUG_TRAP_TYPE_BUG
= 2,
13
};
14
15
struct
pt_regs;
16
17
#ifdef __CHECKER__
18
#define MAYBE_BUILD_BUG_ON(cond) (0)
19
#else
/* __CHECKER__ */
20
21
#define MAYBE_BUILD_BUG_ON(cond) \
22
do { \
23
if (__builtin_constant_p((cond))) \
24
BUILD_BUG_ON(cond); \
25
else \
26
BUG_ON(cond); \
27
} while (0)
28
29
#endif
/* __CHECKER__ */
30
31
#ifdef CONFIG_GENERIC_BUG
32
#include <asm-generic/bug.h>
33
34
static
inline
int
is_warning_bug(
const
struct
bug_entry *bug)
35
{
36
return
bug->flags & BUGFLAG_WARNING;
37
}
38
39
void
bug_get_file_line(
struct
bug_entry *bug,
const
char
**
file
,
40
unsigned
int
*line);
41
42
struct
bug_entry *find_bug(
unsigned
long
bugaddr);
43
44
enum
bug_trap_type
report_bug(
unsigned
long
bug_addr,
struct
pt_regs *regs);
45
enum
bug_trap_type
report_bug_entry(
struct
bug_entry *bug,
struct
pt_regs *regs);
46
47
/* These are defined by the architecture */
48
int
is_valid_bugaddr(
unsigned
long
addr);
49
50
void
generic_bug_clear_once(
void
);
51
52
#else
/* !CONFIG_GENERIC_BUG */
53
54
/*
55
* These stubs keep the prototypes' parameter names for signature parity with
56
* the CONFIG_GENERIC_BUG declarations above, so the (void) casts are what
57
* keeps -Wextra's unused-parameter warning quiet. That matters here because
58
* <linux/bitops.h> includes this header at its bottom (WARN_ONCE
59
* reachability), so every DRM TU in the KernelAA64 link parses these lines.
60
*/
61
static
inline
void
*find_bug(
unsigned
long
bugaddr)
62
{
63
(void)bugaddr;
64
return
NULL
;
65
}
66
67
static
inline
enum
bug_trap_type
report_bug(
unsigned
long
bug_addr,
68
struct
pt_regs *regs)
69
{
70
(void)bug_addr;
71
(void)regs;
72
return
BUG_TRAP_TYPE_BUG
;
73
}
74
75
struct
bug_entry;
76
77
static
inline
enum
bug_trap_type
78
report_bug_entry(
struct
bug_entry *bug,
struct
pt_regs *regs)
79
{
80
(void)bug;
81
(void)regs;
82
return
BUG_TRAP_TYPE_BUG
;
83
}
84
85
static
inline
void
bug_get_file_line(
struct
bug_entry *bug,
const
char
**
file
,
86
unsigned
int
*line)
87
{
88
(void)bug;
89
*
file
=
NULL
;
90
*line = 0;
91
}
92
93
static
inline
void
generic_bug_clear_once(
void
) {}
94
95
#endif
/* CONFIG_GENERIC_BUG */
96
97
#ifdef CONFIG_PRINTK
98
void
mem_dump_obj(
void
*
object
);
99
#else
100
static
inline
void
mem_dump_obj(
void
*
object
) { (void)
object
; }
101
#endif
102
103
/*
104
* Since detected data corruption should stop operation on the affected
105
* structures. Return value must be checked and sanely acted on by caller.
106
*/
107
/*
108
* WARN_ONCE(cond, fmt, ...) -- report a condition once per call site and
109
* return its truth, mainline's "warn but do not flood" spelling.
110
*
111
* The consumers are the DRM set's WARN_ONCE uses, reached three ways: the
112
* files that include this header directly, the ones that include it through
113
* <linux/kernel.h> -> <linux/bitmap.h> -> <linux/bitops.h> (which includes
114
* it at its bottom for exactly this), and drm_print.h:783's drm_WARN_ONCE,
115
* which folds a device prefix into it. drm_drv.c:579 is the shape that
116
* makes the return value load-bearing:
117
*
118
* if (drm_WARN_ONCE(dev, !recovery, "invalid recovery method %u\n", opt))
119
* break;
120
*
121
* -- the loop over set recovery method bits must not continue on an unknown
122
* bit, and the warning is not an error (unlike BUG). It is also why this
123
* cannot be a DCL shim function: fmt and __VA_ARGS__ are spliced into the
124
* report at the call site, which only a macro can do.
125
*
126
* The `static int` inside the statement expression is one object per
127
* expansion, which is what "once" means here; a per-frame call such as the
128
* vkms or vblank paths would otherwise print on every scanout. The body is
129
* kernel.h's WARN_ON_ONCE with the fmt form of WARN added, so the UART sink
130
* and the file:line trailer stay identical to every other warning this tree
131
* prints. Return is the condition's truth (mainline's contract), not
132
* WARN_ON_ONCE's `!cond`.
133
*/
134
#ifndef WARN_ONCE
135
#define WARN_ONCE(cond, fmt, ...) \
136
({ \
137
static int __warned_once; \
138
int __wret = !!(cond); \
139
if (__wret && !__warned_once) { \
140
__warned_once = 1; \
141
UARTDebugOut("[WARN] " fmt " (%s:%d)\r\n", \
142
##__VA_ARGS__, __FILE__, __LINE__); \
143
} \
144
__wret; \
145
})
146
#endif
147
148
static
inline
__must_check
bool
check_data_corruption(
bool
v) {
return
v; }
149
#define CHECK_DATA_CORRUPTION(condition, addr, fmt, ...) \
150
check_data_corruption(({ \
151
bool corruption = unlikely(condition); \
152
if (corruption) { \
153
if (addr) \
154
mem_dump_obj(addr); \
155
if (IS_ENABLED(CONFIG_BUG_ON_DATA_CORRUPTION)) { \
156
pr_err(fmt, ##__VA_ARGS__); \
157
BUG(); \
158
} else \
159
WARN(1, fmt, ##__VA_ARGS__); \
160
} \
161
corruption; \
162
}))
163
164
#endif
/* _LINUX_BUG_H */
NULL
#define NULL
Definition
actypes.h:561
bug.h
build_bug.h
compiler.h
__must_check
#define __must_check
Definition
compiler.h:114
bug_trap_type
bug_trap_type
Definition
bug.h:9
BUG_TRAP_TYPE_NONE
@ BUG_TRAP_TYPE_NONE
Definition
bug.h:10
BUG_TRAP_TYPE_WARN
@ BUG_TRAP_TYPE_WARN
Definition
bug.h:11
BUG_TRAP_TYPE_BUG
@ BUG_TRAP_TYPE_BUG
Definition
bug.h:12
file
Definition
fs.h:142
Generated by
1.9.8