1 /* SPDX-License-Identifier: GPL-2.0 */
6 * ABI defined by Clang's UBSAN enum SanitizerHandler:
7 * https://github.com/llvm/llvm-project/blob/release/16.x/clang/lib/CodeGen/CodeGenFunction.h#L113
11 ubsan_builtin_unreachable
,
13 ubsan_divrem_overflow
,
14 ubsan_dynamic_type_cache_miss
,
15 ubsan_float_cast_overflow
,
16 ubsan_function_type_mismatch
,
17 ubsan_implicit_conversion
,
18 ubsan_invalid_builtin
,
19 ubsan_invalid_objc_cast
,
20 ubsan_load_invalid_value
,
23 ubsan_negate_overflow
,
24 ubsan_nullability_arg
,
25 ubsan_nullability_return
,
29 ubsan_pointer_overflow
,
30 ubsan_shift_out_of_bounds
,
33 ubsan_alignment_assumption
,
34 ubsan_vla_bound_not_positive
,
43 struct type_descriptor
{
49 struct source_location
{
50 const char *file_name
;
52 unsigned long reported
;
60 struct overflow_data
{
61 struct source_location location
;
62 struct type_descriptor
*type
;
65 struct type_mismatch_data
{
66 struct source_location location
;
67 struct type_descriptor
*type
;
68 unsigned long alignment
;
69 unsigned char type_check_kind
;
72 struct type_mismatch_data_v1
{
73 struct source_location location
;
74 struct type_descriptor
*type
;
75 unsigned char log_alignment
;
76 unsigned char type_check_kind
;
79 struct type_mismatch_data_common
{
80 struct source_location
*location
;
81 struct type_descriptor
*type
;
82 unsigned long alignment
;
83 unsigned char type_check_kind
;
86 struct nonnull_arg_data
{
87 struct source_location location
;
88 struct source_location attr_location
;
92 struct out_of_bounds_data
{
93 struct source_location location
;
94 struct type_descriptor
*array_type
;
95 struct type_descriptor
*index_type
;
98 struct shift_out_of_bounds_data
{
99 struct source_location location
;
100 struct type_descriptor
*lhs_type
;
101 struct type_descriptor
*rhs_type
;
104 struct unreachable_data
{
105 struct source_location location
;
108 struct invalid_value_data
{
109 struct source_location location
;
110 struct type_descriptor
*type
;
113 struct alignment_assumption_data
{
114 struct source_location location
;
115 struct source_location assumption_location
;
116 struct type_descriptor
*type
;
119 #if defined(CONFIG_ARCH_SUPPORTS_INT128)
120 typedef __int128 s_max
;
121 typedef unsigned __int128 u_max
;
128 * When generating Runtime Calls, Clang doesn't respect the -mregparm=3
129 * option used on i386: https://github.com/llvm/llvm-project/issues/89670
130 * Fix this for earlier Clang versions by forcing the calling convention
131 * to use non-register arguments.
133 #if defined(CONFIG_X86_32) && \
134 defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 190000
135 # define ubsan_linkage asmlinkage
137 # define ubsan_linkage
140 void ubsan_linkage
__ubsan_handle_add_overflow(void *data
, void *lhs
, void *rhs
);
141 void ubsan_linkage
__ubsan_handle_sub_overflow(void *data
, void *lhs
, void *rhs
);
142 void ubsan_linkage
__ubsan_handle_mul_overflow(void *data
, void *lhs
, void *rhs
);
143 void ubsan_linkage
__ubsan_handle_negate_overflow(void *_data
, void *old_val
);
144 void ubsan_linkage
__ubsan_handle_divrem_overflow(void *_data
, void *lhs
, void *rhs
);
145 void ubsan_linkage
__ubsan_handle_type_mismatch(struct type_mismatch_data
*data
, void *ptr
);
146 void ubsan_linkage
__ubsan_handle_type_mismatch_v1(void *_data
, void *ptr
);
147 void ubsan_linkage
__ubsan_handle_out_of_bounds(void *_data
, void *index
);
148 void ubsan_linkage
__ubsan_handle_shift_out_of_bounds(void *_data
, void *lhs
, void *rhs
);
149 void ubsan_linkage
__ubsan_handle_builtin_unreachable(void *_data
);
150 void ubsan_linkage
__ubsan_handle_load_invalid_value(void *_data
, void *val
);
151 void ubsan_linkage
__ubsan_handle_alignment_assumption(void *_data
, unsigned long ptr
,
153 unsigned long offset
);