drm/dp_mst: Add helper to get port number at specific LCT from RAD
[drm/drm-misc.git] / drivers / misc / lkdtm / lkdtm.h
blob015e0484026b28adc5297963ca75466e8f773747
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LKDTM_H
3 #define __LKDTM_H
5 #define pr_fmt(fmt) "lkdtm: " fmt
7 #include <linux/kernel.h>
9 extern char *lkdtm_kernel_info;
11 #define pr_expected_config(kconfig) \
12 do { \
13 if (IS_ENABLED(kconfig)) \
14 pr_err("Unexpected! This %s was built with " #kconfig "=y\n", \
15 lkdtm_kernel_info); \
16 else \
17 pr_warn("This is probably expected, since this %s was built *without* " #kconfig "=y\n", \
18 lkdtm_kernel_info); \
19 } while (0)
21 #ifndef MODULE
22 int lkdtm_check_bool_cmdline(const char *param);
23 #define pr_expected_config_param(kconfig, param) \
24 do { \
25 if (IS_ENABLED(kconfig)) { \
26 switch (lkdtm_check_bool_cmdline(param)) { \
27 case 0: \
28 pr_warn("This is probably expected, since this %s was built with " #kconfig "=y but booted with '" param "=N'\n", \
29 lkdtm_kernel_info); \
30 break; \
31 case 1: \
32 pr_err("Unexpected! This %s was built with " #kconfig "=y and booted with '" param "=Y'\n", \
33 lkdtm_kernel_info); \
34 break; \
35 default: \
36 pr_err("Unexpected! This %s was built with " #kconfig "=y (and booted without '" param "' specified)\n", \
37 lkdtm_kernel_info); \
38 } \
39 } else { \
40 switch (lkdtm_check_bool_cmdline(param)) { \
41 case 0: \
42 pr_warn("This is probably expected, as this %s was built *without* " #kconfig "=y and booted with '" param "=N'\n", \
43 lkdtm_kernel_info); \
44 break; \
45 case 1: \
46 pr_err("Unexpected! This %s was built *without* " #kconfig "=y but booted with '" param "=Y'\n", \
47 lkdtm_kernel_info); \
48 break; \
49 default: \
50 pr_err("This is probably expected, since this %s was built *without* " #kconfig "=y (and booted without '" param "' specified)\n", \
51 lkdtm_kernel_info); \
52 break; \
53 } \
54 } \
55 } while (0)
56 #else
57 #define pr_expected_config_param(kconfig, param) pr_expected_config(kconfig)
58 #endif
60 /* Crash types. */
61 struct crashtype {
62 const char *name;
63 void (*func)(void);
66 #define CRASHTYPE(_name) \
67 { \
68 .name = __stringify(_name), \
69 .func = lkdtm_ ## _name, \
72 /* Category's collection of crashtypes. */
73 struct crashtype_category {
74 struct crashtype *crashtypes;
75 size_t len;
78 /* Each category's crashtypes list. */
79 extern struct crashtype_category bugs_crashtypes;
80 extern struct crashtype_category heap_crashtypes;
81 extern struct crashtype_category perms_crashtypes;
82 extern struct crashtype_category refcount_crashtypes;
83 extern struct crashtype_category usercopy_crashtypes;
84 extern struct crashtype_category stackleak_crashtypes;
85 extern struct crashtype_category cfi_crashtypes;
86 extern struct crashtype_category fortify_crashtypes;
87 extern struct crashtype_category powerpc_crashtypes;
89 /* Each category's init/exit routines. */
90 void __init lkdtm_bugs_init(int *recur_param);
91 void __init lkdtm_heap_init(void);
92 void __exit lkdtm_heap_exit(void);
93 void __init lkdtm_perms_init(void);
94 void __init lkdtm_usercopy_init(void);
95 void __exit lkdtm_usercopy_exit(void);
97 /* Special declaration for function-in-rodata. */
98 void lkdtm_rodata_do_nothing(void);
100 #endif