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