This fixes the UBSAN build for GCC 8 and later. The sanitiser checks for
passing 0 to the ctz()/clz() builtins.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
ubsan_epilogue(&flags);
}
+
+void __ubsan_handle_invalid_builtin(struct invalid_builtin_data *data)
+{
+ unsigned long flags;
+ const char *fn = NULL;
+
+ if (suppress_report(&data->location))
+ return;
+
+ ubsan_prologue(&data->location, &flags);
+
+ switch (data->kind) {
+ case kind_ctz: fn = "ctz"; break;
+ case kind_clz: fn = "clz"; break;
+ }
+
+ if (fn)
+ pr_err("passing zero to %s(), which is not a valid argument\n", fn);
+ else
+ pr_err("Unknown kind %u\n", data->kind);
+
+ ubsan_epilogue(&flags);
+}
struct source_location location;
};
+struct invalid_builtin_data {
+ struct source_location location;
+ unsigned char kind;
+};
+enum {
+ kind_ctz,
+ kind_clz,
+};
+
#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
typedef __int128 s_max;
typedef unsigned __int128 u_max;