blob: 9a0b71c5ff9fbf45492c0043f24a8578f06acaf6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Andrey Ryabininc6d30852016-01-20 15:00:55 -08002#ifndef _LIB_UBSAN_H
3#define _LIB_UBSAN_H
4
5enum {
6 type_kind_int = 0,
7 type_kind_float = 1,
8 type_unknown = 0xffff
9};
10
11struct type_descriptor {
12 u16 type_kind;
13 u16 type_info;
14 char type_name[1];
15};
16
17struct source_location {
18 const char *file_name;
19 union {
20 unsigned long reported;
21 struct {
22 u32 line;
23 u32 column;
24 };
25 };
26};
27
28struct overflow_data {
29 struct source_location location;
30 struct type_descriptor *type;
31};
32
33struct type_mismatch_data {
34 struct source_location location;
35 struct type_descriptor *type;
36 unsigned long alignment;
37 unsigned char type_check_kind;
38};
39
Andrey Ryabinin42440c12018-02-06 15:40:42 -080040struct type_mismatch_data_v1 {
41 struct source_location location;
42 struct type_descriptor *type;
43 unsigned char log_alignment;
44 unsigned char type_check_kind;
45};
46
47struct type_mismatch_data_common {
48 struct source_location *location;
49 struct type_descriptor *type;
50 unsigned long alignment;
51 unsigned char type_check_kind;
52};
53
Andrey Ryabininc6d30852016-01-20 15:00:55 -080054struct nonnull_arg_data {
55 struct source_location location;
56 struct source_location attr_location;
57 int arg_index;
58};
59
Andrey Ryabininc6d30852016-01-20 15:00:55 -080060struct out_of_bounds_data {
61 struct source_location location;
62 struct type_descriptor *array_type;
63 struct type_descriptor *index_type;
64};
65
66struct shift_out_of_bounds_data {
67 struct source_location location;
68 struct type_descriptor *lhs_type;
69 struct type_descriptor *rhs_type;
70};
71
72struct unreachable_data {
73 struct source_location location;
74};
75
76struct invalid_value_data {
77 struct source_location location;
78 struct type_descriptor *type;
79};
80
Nathan Chancellorcf1cab62021-02-04 18:32:57 -080081struct alignment_assumption_data {
82 struct source_location location;
83 struct source_location assumption_location;
84 struct type_descriptor *type;
85};
86
Ard Biesheuvelc12d3362019-11-08 13:22:27 +010087#if defined(CONFIG_ARCH_SUPPORTS_INT128)
Andrey Ryabininc6d30852016-01-20 15:00:55 -080088typedef __int128 s_max;
89typedef unsigned __int128 u_max;
90#else
91typedef s64 s_max;
92typedef u64 u_max;
93#endif
94
95#endif