Line data Source code
1 :
2 : struct device;
3 :
4 : void *ldv_dev_get_drvdata(const struct device *dev);
5 : int ldv_dev_set_drvdata(struct device *dev, void *data);
6 :
7 : struct spi_master;
8 : struct device;
9 : struct spi_master *ldv_spi_alloc_master(struct device *host, unsigned size);
10 :
11 : #include <linux/ldv/err.h>
12 :
13 : #include <linux/types.h>
14 : void *ldv_kzalloc(size_t size, gfp_t flags);
15 :
16 : struct clk;
17 :
18 : extern void ldv_clk_disable(struct clk *clk);
19 : extern int ldv_clk_enable(void);
20 :
21 : #include <linux/ldv/common.h>
22 : #include <linux/ldv/irq.h>
23 : #include <verifier/common.h>
24 : #include <verifier/nondet.h>
25 : #include <verifier/memory.h>
26 : #include <verifier/thread.h>
27 :
28 :
29 :
30 : struct ldv_struct_insmod_2 {
31 : int signal_pending;
32 : };
33 :
34 : /* EMG Function declarations */
35 : void ldv_dispatch_default_deregister_1_2_4(void);
36 : void ldv_dispatch_default_register_1_2_5(void);
37 : void ldv_dispatch_insmod_deregister_3_2(void);
38 : void ldv_dispatch_insmod_register_3_3(void);
39 : void ldv_insmod_2(void *);
40 : void ldv_insmod_cdrom_exit_2_2(void (*)(void));
41 : int ldv_insmod_cdrom_init_2_9(int (*)(void));
42 : void ldv_main_3(void *);
43 : void ldv_random_containerless_scenario_1(void *);
44 : void ldv_random_containerless_scenario_callback_1_10(int (*)(char *, struct kernel_param *), char *, struct kernel_param *);
45 : void ldv_random_containerless_scenario_callback_1_4(int (*)(char *, struct kernel_param *), char *, struct kernel_param *);
46 : int main(void);
47 :
48 : /* EMG variable declarations */
49 1 : struct ldv_thread ldv_thread_1;
50 1 : struct ldv_thread ldv_thread_2;
51 1 : struct ldv_thread ldv_thread_3;
52 :
53 : /* EMG variable initialization */
54 :
55 : /* EMG function definitions */
56 : /* AUX_FUNC ldv_dispatch_default_deregister_1_2_4 */
57 : void ldv_dispatch_default_deregister_1_2_4() {
58 : struct ldv_struct_insmod_2 *cf_arg_1;
59 : /* Skip thread join call */
60 1 : return;
61 : }
62 :
63 : /* AUX_FUNC ldv_dispatch_default_register_1_2_5 */
64 : void ldv_dispatch_default_register_1_2_5() {
65 : struct ldv_struct_insmod_2 *cf_arg_1;
66 4 : cf_arg_1 = ldv_xmalloc(sizeof(struct ldv_struct_insmod_2));
67 3 : ldv_random_containerless_scenario_1(cf_arg_1);
68 1 : return;
69 : }
70 :
71 : /* AUX_FUNC ldv_dispatch_insmod_deregister_3_2 */
72 : void ldv_dispatch_insmod_deregister_3_2() {
73 : struct ldv_struct_insmod_2 *cf_arg_2;
74 : /* Skip thread join call */
75 1 : return;
76 : }
77 :
78 : /* AUX_FUNC ldv_dispatch_insmod_register_3_3 */
79 : void ldv_dispatch_insmod_register_3_3() {
80 : struct ldv_struct_insmod_2 *cf_arg_2;
81 4 : cf_arg_2 = ldv_xmalloc(sizeof(struct ldv_struct_insmod_2));
82 4 : ldv_insmod_2(cf_arg_2);
83 1 : return;
84 : }
85 :
86 : /* AUX_FUNC ldv_insmod_2 */
87 : void ldv_insmod_2(void *arg0) {
88 : /* LDV {"thread": 2, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'insmod(artificial)'", "function": "ldv_insmod_2"} */
89 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
90 1 : void (*ldv_2_cdrom_exit_default)(void);
91 1 : int (*ldv_2_cdrom_init_default)(void);
92 1 : int ldv_2_ret_default;
93 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
94 : /* LDV {"action": "INSMOD_REGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module initialization."} */
95 2 : ldv_free(arg0);
96 : /* LDV {"action": "INSMOD_REGISTER", "type": "RECEIVE_END"} */
97 :
98 : /* LDV {"action": "CDROM_INIT", "type": "CALL_BEGIN", "callback": true, "comment": "Initialize the module after insmod with 'cdrom_init' function. Invoke callback cdrom_init from ARTIFICIAL."} */
99 : /* LDV {"type": "CALLBACK", "call": "ldv_2_ret_default = (cdrom_init)();", "comment": "cdrom_init"} */
100 2 : ldv_2_ret_default = ldv_insmod_cdrom_init_2_9(ldv_2_cdrom_init_default);
101 : /* Callback post-call */
102 2 : ldv_2_ret_default = ldv_post_init(ldv_2_ret_default);
103 : /* LDV {"action": "CDROM_INIT", "type": "CALL_END"} */
104 :
105 4 : if (ldv_undef_int()) {
106 : /* LDV {"action": "INIT_FAILED", "type": "CONDITION_BEGIN", "comment": "Failed to initialize the module."} */
107 2 : ldv_assume(ldv_2_ret_default != 0);
108 : /* LDV {"action": "INIT_FAILED", "type": "CONDITION_END"} */
109 :
110 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module exit."} */
111 : /* Skip a non-replicative signal receiving */
112 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_END"} */
113 :
114 : /* Exit function at a terminal state */
115 1 : return;
116 : }
117 : else {
118 : /* LDV {"action": "INIT_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Module has been initialized."} */
119 2 : ldv_assume(ldv_2_ret_default == 0);
120 : /* LDV {"action": "INIT_SUCCESS", "type": "CONDITION_END"} */
121 :
122 4 : if (ldv_undef_int()) {
123 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "DISPATCH_BEGIN", "comment": "Register 'STRUCT_KERNEL_PARAM' callbacks with unknown registration function."} */
124 2 : ldv_dispatch_default_register_1_2_5();
125 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "DISPATCH_END"} */
126 :
127 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "DISPATCH_BEGIN", "comment": "Deregister 'STRUCT_KERNEL_PARAM' callbacks with unknown deregistration function."} */
128 2 : ldv_dispatch_default_deregister_1_2_4();
129 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "DISPATCH_END"} */
130 :
131 : }
132 : else {
133 : /* LDV {"action": "NONE", "type": "CONDITION_BEGIN", "comment": "Skip default callbacks registrations and deregistrations."} */
134 : /* LDV {"action": "NONE", "type": "CONDITION_END"} */
135 :
136 : }
137 : /* LDV {"action": "CDROM_EXIT", "type": "CALL_BEGIN", "callback": true, "comment": "Exit the module before its unloading with 'cdrom_exit' function. Invoke callback cdrom_exit from ARTIFICIAL."} */
138 : /* LDV {"type": "CALLBACK", "call": "(cdrom_exit)();", "comment": "cdrom_exit"} */
139 4 : ldv_insmod_cdrom_exit_2_2(ldv_2_cdrom_exit_default);
140 : /* LDV {"action": "CDROM_EXIT", "type": "CALL_END"} */
141 :
142 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module exit."} */
143 : /* Skip a non-replicative signal receiving */
144 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_END"} */
145 :
146 : /* Exit function at a terminal state */
147 1 : return;
148 : }
149 : /* End of the process */
150 : return;
151 : /* LDV {"comment": "End of control function based on process 'insmod(artificial)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_insmod_2"} */
152 : }
153 :
154 : /* AUX_FUNC_CALLBACK ldv_insmod_cdrom_exit_2_2 */
155 : void ldv_insmod_cdrom_exit_2_2(void (*arg0)(void)) {
156 4 : (cdrom_exit)();
157 2 : }
158 :
159 : /* AUX_FUNC_CALLBACK ldv_insmod_cdrom_init_2_9 */
160 : int ldv_insmod_cdrom_init_2_9(int (*arg0)(void)) {
161 3 : return (cdrom_init)();
162 1 : }
163 :
164 : /* AUX_FUNC ldv_main_3 */
165 : void ldv_main_3(void *arg0) {
166 : /* LDV {"thread": 3, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'main(main)'", "function": "ldv_main_3"} */
167 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
168 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
169 : /* LDV {"action": "INIT", "type": "CONDITION_BEGIN", "comment": "Initialize rule models."} */
170 1 : ldv_initialize();
171 : /* LDV {"action": "INIT", "type": "CONDITION_END"} */
172 :
173 : /* LDV {"action": "INSMOD_REGISTER", "type": "DISPATCH_BEGIN", "comment": "Start environment model scenarios."} */
174 2 : ldv_dispatch_insmod_register_3_3();
175 : /* LDV {"action": "INSMOD_REGISTER", "type": "DISPATCH_END"} */
176 :
177 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "DISPATCH_BEGIN", "comment": "Stop environment model scenarios."} */
178 2 : ldv_dispatch_insmod_deregister_3_2();
179 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "DISPATCH_END"} */
180 :
181 : /* LDV {"action": "FINAL", "type": "CONDITION_BEGIN", "comment": "Check rule model state at the exit."} */
182 1 : ldv_check_final_state();
183 1 : ldv_stop();
184 : /* LDV {"action": "FINAL", "type": "CONDITION_END"} */
185 :
186 : /* Exit function at a terminal state */
187 0 : return;
188 : /* End of the process */
189 : return;
190 : /* LDV {"comment": "End of control function based on process 'main(main)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_main_3"} */
191 : }
192 :
193 : /* AUX_FUNC ldv_random_containerless_scenario_1 */
194 : void ldv_random_containerless_scenario_1(void *arg0) {
195 : /* LDV {"thread": 1, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'random_containerless_scenario(struct_kernel_param)'", "function": "ldv_random_containerless_scenario_1"} */
196 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
197 1 : int (*ldv_1_callback_get)(char *, struct kernel_param *);
198 1 : int (*ldv_1_callback_set)(char *, struct kernel_param *);
199 1 : struct kernel_param *ldv_1_container_struct_kernel_param;
200 1 : char *ldv_1_ldv_param_10_0_default;
201 1 : char *ldv_1_ldv_param_4_0_default;
202 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
203 1 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Begin STRUCT_KERNEL_PARAM callbacks invocations scenario."} */
204 3 : ldv_free(arg0);
205 1 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_END"} */
206 :
207 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_BEGIN", "comment": "Allocate memory after default registration."} */
208 3 : ldv_1_container_struct_kernel_param = ldv_xmalloc_unknown_size(0);
209 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_END"} */
210 :
211 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Prepare to call a random callback or deregister the callbacks."} */
212 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
213 :
214 : /* Jump to a subprocess 'call' initial state */
215 1 : goto ldv_call_1;
216 : /* End of the process */
217 : return;
218 1 :
219 : /* Sbprocess call */
220 : ldv_call_1:
221 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
222 :
223 4 : if (ldv_undef_int()) {
224 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
225 3 : ldv_1_ldv_param_4_0_default = ldv_xmalloc_unknown_size(0);
226 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_END"} */
227 :
228 4 : if (ldv_undef_int()) {
229 : /* LDV {"action": "PRE_CALL_10", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
230 3 : ldv_1_ldv_param_10_0_default = ldv_xmalloc_unknown_size(0);
231 : /* LDV {"action": "PRE_CALL_10", "type": "CONDITION_END"} */
232 :
233 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Call any random callback. Invoke callback set from kernel_param."} */
234 : /* LDV {"type": "CALLBACK", "call": "((& param_set_bool))(ldv_1_ldv_param_10_0_default, ldv_1_container_struct_kernel_param);", "comment": "callback"} */
235 2 : ldv_random_containerless_scenario_callback_1_10(ldv_1_callback_set, ldv_1_ldv_param_10_0_default, ldv_1_container_struct_kernel_param);
236 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
237 :
238 : /* LDV {"action": "POST_CALL_10", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
239 2 : ldv_free(ldv_1_ldv_param_10_0_default);
240 : /* LDV {"action": "POST_CALL_10", "type": "CONDITION_END"} */
241 :
242 : }
243 : else {
244 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Call any random callback. Invoke callback get from kernel_param."} */
245 : /* LDV {"type": "CALLBACK", "call": "((& param_get_bool))(ldv_1_ldv_param_4_0_default, ldv_1_container_struct_kernel_param);", "comment": "callback"} */
246 2 : ldv_random_containerless_scenario_callback_1_4(ldv_1_callback_get, ldv_1_ldv_param_4_0_default, ldv_1_container_struct_kernel_param);
247 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
248 :
249 : }
250 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
251 4 : ldv_free(ldv_1_ldv_param_4_0_default);
252 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_END"} */
253 :
254 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Prepare to call a random callback or deregister the callbacks."} */
255 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
256 :
257 : /* Jump to a subprocess 'call' initial state */
258 1 : goto ldv_call_1;
259 : }
260 : else {
261 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_BEGIN", "comment": "Free memory before default deregistration."} */
262 2 : ldv_free(ldv_1_container_struct_kernel_param);
263 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_END"} */
264 :
265 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Finish STRUCT_KERNEL_PARAM callbacks invocations scenario."} */
266 : /* Skip a non-replicative signal receiving */
267 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_END"} */
268 :
269 : /* Exit function at a terminal state */
270 1 : return;
271 : }
272 : /* End of the subprocess 'call' */
273 : return;
274 : /* LDV {"comment": "End of control function based on process 'random_containerless_scenario(struct_kernel_param)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_random_containerless_scenario_1"} */
275 : }
276 :
277 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_1_10 */
278 : void ldv_random_containerless_scenario_callback_1_10(int (*arg0)(char *, struct kernel_param *), char *arg1, struct kernel_param *arg2) {
279 1 : ((& param_set_bool))(arg1, arg2);
280 1 : }
281 :
282 : /* AUX_FUNC_CALLBACK ldv_random_containerless_scenario_callback_1_4 */
283 : void ldv_random_containerless_scenario_callback_1_4(int (*arg0)(char *, struct kernel_param *), char *arg1, struct kernel_param *arg2) {
284 1 : ((& param_get_bool))(arg1, arg2);
285 1 : }
286 :
287 : /* AUX_FUNC main */
288 : int main() {
289 1 : ldv_main_3(0);
290 0 : return 0;
291 : }
292 :
293 :
294 : /* AUX_FUNC ERR_PTR */
295 : static inline void *ERR_PTR (long int error)
296 : {
297 :
298 : return ldv_err_ptr(error);
299 : }
300 :
301 : /* AUX_FUNC PTR_ERR */
302 : static inline long int PTR_ERR (void const *ptr)
303 : {
304 :
305 : return ldv_ptr_err(ptr);
306 : }
307 :
308 : /* AUX_FUNC IS_ERR */
309 : static inline long int IS_ERR (void const *ptr)
310 : {
311 :
312 : return ldv_is_err(ptr);
313 : }
314 :
315 : /* AUX_FUNC IS_ERR_OR_NULL */
316 : static inline long int IS_ERR_OR_NULL (void const *ptr)
317 : {
318 :
319 : return ldv_is_err_or_null(ptr);
320 : }
321 :
322 : /* AUX_FUNC kzalloc */
323 : static inline void *kzalloc (size_t size, gfp_t flags)
324 : {
325 :
326 : return ldv_kzalloc(size, flags);
327 : }
|