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_bus_pattern_scenario_1(void *);
36 : void ldv_bus_pattern_scenario_callback_1_9(int (*)(int, gfp_t ), int, unsigned int);
37 : void ldv_dispatch_default_deregister_1_2_4(void);
38 : void ldv_dispatch_default_register_1_2_5(void);
39 : void ldv_dispatch_insmod_deregister_3_2(void);
40 : void ldv_dispatch_insmod_register_3_3(void);
41 : void ldv_insmod_2(void *);
42 : void ldv_insmod_exit_mbcache_2_2(void (*)(void));
43 : int ldv_insmod_init_mbcache_2_9(int (*)(void));
44 : void ldv_main_3(void *);
45 : int main(void);
46 :
47 : /* EMG variable declarations */
48 1 : struct ldv_thread ldv_thread_1;
49 1 : struct ldv_thread ldv_thread_2;
50 1 : struct ldv_thread ldv_thread_3;
51 :
52 : /* EMG variable initialization */
53 :
54 : /* EMG function definitions */
55 : /* AUX_FUNC ldv_bus_pattern_scenario_1 */
56 : void ldv_bus_pattern_scenario_1(void *arg0) {
57 : /* LDV {"thread": 1, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'bus_pattern_scenario(struct_shrinker)'", "function": "ldv_bus_pattern_scenario_1"} */
58 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
59 1 : int (*ldv_1_callback_shrink)(int, gfp_t );
60 1 : int ldv_1_ldv_param_9_0_default;
61 1 : unsigned int ldv_1_ldv_param_9_1_default;
62 1 : int ldv_1_ret_default;
63 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
64 1 : /* Initialize automaton variables */
65 2 : ldv_1_ret_default = 1;
66 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Begin STRUCT_SHRINKER callbacks invocations scenario."} */
67 2 : ldv_free(arg0);
68 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "RECEIVE_END"} */
69 :
70 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_BEGIN", "comment": "Allocate memory after default registration."} */
71 : /* LDV {"action": "DEFAULT_ALLOC_1", "type": "CONDITION_END"} */
72 :
73 : /* LDV {"action": "INIT", "type": "CONDITION_BEGIN", "comment": "Allocate memory of common callback parameters."} */
74 : /* LDV {"action": "INIT", "type": "CONDITION_END"} */
75 :
76 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Try to probe driver."} */
77 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
78 :
79 : /* Jump to a subprocess 'main' initial state */
80 1 : goto ldv_main_1;
81 : /* End of the process */
82 : return;
83 1 :
84 : /* Sbprocess main */
85 : ldv_main_1:
86 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
87 :
88 4 : if (ldv_undef_int()) {
89 : /* LDV {"action": "PROBE", "type": "CALL_BEGIN", "comment": "Call callback 'probe' of a process 'bus_pattern_scenario' of an interface category 'struct_shrinker'"} */
90 : /* Skip callback without implementations */
91 : /* LDV {"action": "PROBE", "type": "CALL_END"} */
92 :
93 4 : if (ldv_undef_int()) {
94 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Probing has been successfull."} */
95 2 : ldv_assume(ldv_1_ret_default == 0);
96 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_END"} */
97 :
98 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Driver is probed, call the other callbacks."} */
99 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
100 :
101 : /* Jump to a subprocess 'call' initial state */
102 1 : goto ldv_call_1;
103 : }
104 : else {
105 : /* LDV {"action": "PROBE_FAILED", "type": "CONDITION_BEGIN", "comment": "Probing has failed."} */
106 2 : ldv_assume(ldv_1_ret_default != 0);
107 : /* LDV {"action": "PROBE_FAILED", "type": "CONDITION_END"} */
108 :
109 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Try to probe driver."} */
110 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
111 :
112 : /* Jump to a subprocess 'main' initial state */
113 1 : goto ldv_main_1;
114 : }
115 : }
116 : else {
117 : /* LDV {"action": "FREE", "type": "CONDITION_BEGIN", "comment": "Free memory of common callback parameters."} */
118 : /* LDV {"action": "FREE", "type": "CONDITION_END"} */
119 :
120 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_BEGIN", "comment": "Free memory before default deregistration."} */
121 : /* LDV {"action": "DEFAULT_FREE_1", "type": "CONDITION_END"} */
122 :
123 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_BEGIN", "comment": "Finish STRUCT_SHRINKER callbacks invocations scenario."} */
124 : /* Skip a non-replicative signal receiving */
125 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "RECEIVE_END"} */
126 :
127 : /* Exit function at a terminal state */
128 1 : return;
129 : }
130 : /* End of the subprocess 'main' */
131 : return;
132 1 :
133 : /* Sbprocess call */
134 : ldv_call_1:
135 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
136 :
137 2 : switch (ldv_undef_int()) {
138 3 : case 1: {
139 : /* LDV {"action": "PRE_CALL_9", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
140 : /* LDV {"action": "PRE_CALL_9", "type": "CONDITION_END"} */
141 :
142 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Call any random callback. Invoke callback shrink from shrinker."} */
143 : /* LDV {"type": "CALLBACK", "call": "((& mb_cache_shrink_fn))(ldv_1_ldv_param_9_0_default, ldv_1_ldv_param_9_1_default);", "comment": "callback"} */
144 2 : ldv_bus_pattern_scenario_callback_1_9(ldv_1_callback_shrink, ldv_1_ldv_param_9_0_default, ldv_1_ldv_param_9_1_default);
145 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
146 :
147 : /* LDV {"action": "POST_CALL_9", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
148 : /* LDV {"action": "POST_CALL_9", "type": "CONDITION_END"} */
149 :
150 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Driver is probed, call the other callbacks."} */
151 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
152 :
153 : /* Jump to a subprocess 'call' initial state */
154 1 : goto ldv_call_1;
155 1 : break;
156 : }
157 3 : case 2: {
158 : /* LDV {"action": "SUSPEND", "type": "CALL_BEGIN", "comment": "Call callback 'suspend' of a process 'bus_pattern_scenario' of an interface category 'struct_shrinker'"} */
159 : /* Skip callback without implementations */
160 : /* LDV {"action": "SUSPEND", "type": "CALL_END"} */
161 :
162 4 : if (ldv_undef_int()) {
163 : /* LDV {"action": "SUSPEND_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Suspending has been successfull."} */
164 2 : ldv_assume(ldv_1_ret_default == 0);
165 : /* LDV {"action": "SUSPEND_SUCCESS", "type": "CONDITION_END"} */
166 :
167 : /* LDV {"action": "RESUME", "type": "CALL_BEGIN", "comment": "Call callback 'resume' of a process 'bus_pattern_scenario' of an interface category 'struct_shrinker'"} */
168 : /* Skip callback without implementations */
169 : /* LDV {"action": "RESUME", "type": "CALL_END"} */
170 :
171 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Driver is probed, call the other callbacks."} */
172 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
173 :
174 : /* Jump to a subprocess 'call' initial state */
175 1 : goto ldv_call_1;
176 : }
177 : else {
178 : /* LDV {"action": "SUSPEND_FAILED", "type": "CONDITION_BEGIN", "comment": "Suspending has failed."} */
179 2 : ldv_assume(ldv_1_ret_default != 0);
180 : /* LDV {"action": "SUSPEND_FAILED", "type": "CONDITION_END"} */
181 :
182 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Driver is probed, call the other callbacks."} */
183 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
184 :
185 : /* Jump to a subprocess 'call' initial state */
186 1 : goto ldv_call_1;
187 : /* Jump to a subprocess 'call' initial state */
188 : goto ldv_call_1;
189 : }
190 1 : break;
191 : }
192 3 : case 3: {
193 : /* LDV {"action": "RELEASE", "type": "CALL_BEGIN", "comment": "Call callback 'release' of a process 'bus_pattern_scenario' of an interface category 'struct_shrinker'"} */
194 : /* Skip callback without implementations */
195 : /* LDV {"action": "RELEASE", "type": "CALL_END"} */
196 :
197 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Try to probe driver."} */
198 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
199 :
200 : /* Jump to a subprocess 'main' initial state */
201 1 : goto ldv_main_1;
202 1 : break;
203 : }
204 2 : default: ldv_stop();
205 1 : }
206 0 : /* End of the subprocess 'call' */
207 0 : return;
208 : /* LDV {"comment": "End of control function based on process 'bus_pattern_scenario(struct_shrinker)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_bus_pattern_scenario_1"} */
209 : }
210 :
211 : /* AUX_FUNC_CALLBACK ldv_bus_pattern_scenario_callback_1_9 */
212 : void ldv_bus_pattern_scenario_callback_1_9(int (*arg0)(int, gfp_t ), int arg1, unsigned int arg2) {
213 3 : ((& mb_cache_shrink_fn))(arg1, arg2);
214 1 : }
215 :
216 : /* AUX_FUNC ldv_dispatch_default_deregister_1_2_4 */
217 : void ldv_dispatch_default_deregister_1_2_4() {
218 : struct ldv_struct_insmod_2 *cf_arg_1;
219 : /* Skip thread join call */
220 1 : return;
221 : }
222 :
223 : /* AUX_FUNC ldv_dispatch_default_register_1_2_5 */
224 : void ldv_dispatch_default_register_1_2_5() {
225 : struct ldv_struct_insmod_2 *cf_arg_1;
226 4 : cf_arg_1 = ldv_xmalloc(sizeof(struct ldv_struct_insmod_2));
227 3 : ldv_bus_pattern_scenario_1(cf_arg_1);
228 1 : return;
229 : }
230 :
231 : /* AUX_FUNC ldv_dispatch_insmod_deregister_3_2 */
232 : void ldv_dispatch_insmod_deregister_3_2() {
233 : struct ldv_struct_insmod_2 *cf_arg_2;
234 : /* Skip thread join call */
235 1 : return;
236 : }
237 :
238 : /* AUX_FUNC ldv_dispatch_insmod_register_3_3 */
239 : void ldv_dispatch_insmod_register_3_3() {
240 : struct ldv_struct_insmod_2 *cf_arg_2;
241 4 : cf_arg_2 = ldv_xmalloc(sizeof(struct ldv_struct_insmod_2));
242 4 : ldv_insmod_2(cf_arg_2);
243 1 : return;
244 : }
245 :
246 : /* AUX_FUNC ldv_insmod_2 */
247 : void ldv_insmod_2(void *arg0) {
248 : /* LDV {"thread": 2, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'insmod(artificial)'", "function": "ldv_insmod_2"} */
249 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
250 1 : void (*ldv_2_exit_mbcache_default)(void);
251 1 : int (*ldv_2_init_mbcache_default)(void);
252 1 : int ldv_2_ret_default;
253 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
254 : /* LDV {"action": "INSMOD_REGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module initialization."} */
255 2 : ldv_free(arg0);
256 : /* LDV {"action": "INSMOD_REGISTER", "type": "RECEIVE_END"} */
257 :
258 : /* LDV {"action": "INIT_MBCACHE", "type": "CALL_BEGIN", "callback": true, "comment": "Initialize the module after insmod with 'init_mbcache' function. Invoke callback init_mbcache from ARTIFICIAL."} */
259 : /* LDV {"type": "CALLBACK", "call": "ldv_2_ret_default = (init_mbcache)();", "comment": "init_mbcache"} */
260 2 : ldv_2_ret_default = ldv_insmod_init_mbcache_2_9(ldv_2_init_mbcache_default);
261 : /* Callback post-call */
262 2 : ldv_2_ret_default = ldv_post_init(ldv_2_ret_default);
263 : /* LDV {"action": "INIT_MBCACHE", "type": "CALL_END"} */
264 :
265 4 : if (ldv_undef_int()) {
266 : /* LDV {"action": "INIT_FAILED", "type": "CONDITION_BEGIN", "comment": "Failed to initialize the module."} */
267 2 : ldv_assume(ldv_2_ret_default != 0);
268 : /* LDV {"action": "INIT_FAILED", "type": "CONDITION_END"} */
269 :
270 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module exit."} */
271 : /* Skip a non-replicative signal receiving */
272 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_END"} */
273 :
274 : /* Exit function at a terminal state */
275 1 : return;
276 : }
277 : else {
278 : /* LDV {"action": "INIT_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Module has been initialized."} */
279 2 : ldv_assume(ldv_2_ret_default == 0);
280 : /* LDV {"action": "INIT_SUCCESS", "type": "CONDITION_END"} */
281 :
282 4 : if (ldv_undef_int()) {
283 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "DISPATCH_BEGIN", "comment": "Register 'STRUCT_SHRINKER' callbacks with unknown registration function."} */
284 2 : ldv_dispatch_default_register_1_2_5();
285 : /* LDV {"action": "DEFAULT_REGISTER_1", "type": "DISPATCH_END"} */
286 :
287 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "DISPATCH_BEGIN", "comment": "Deregister 'STRUCT_SHRINKER' callbacks with unknown deregistration function."} */
288 2 : ldv_dispatch_default_deregister_1_2_4();
289 : /* LDV {"action": "DEFAULT_DEREGISTER_1", "type": "DISPATCH_END"} */
290 :
291 : }
292 : else {
293 : /* LDV {"action": "NONE", "type": "CONDITION_BEGIN", "comment": "Skip default callbacks registrations and deregistrations."} */
294 : /* LDV {"action": "NONE", "type": "CONDITION_END"} */
295 :
296 : }
297 : /* LDV {"action": "EXIT_MBCACHE", "type": "CALL_BEGIN", "callback": true, "comment": "Exit the module before its unloading with 'exit_mbcache' function. Invoke callback exit_mbcache from ARTIFICIAL."} */
298 : /* LDV {"type": "CALLBACK", "call": "(exit_mbcache)();", "comment": "exit_mbcache"} */
299 4 : ldv_insmod_exit_mbcache_2_2(ldv_2_exit_mbcache_default);
300 : /* LDV {"action": "EXIT_MBCACHE", "type": "CALL_END"} */
301 :
302 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_BEGIN", "comment": "Trigger module exit."} */
303 : /* Skip a non-replicative signal receiving */
304 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "RECEIVE_END"} */
305 :
306 : /* Exit function at a terminal state */
307 1 : return;
308 : }
309 : /* End of the process */
310 : return;
311 : /* LDV {"comment": "End of control function based on process 'insmod(artificial)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_insmod_2"} */
312 : }
313 :
314 : /* AUX_FUNC_CALLBACK ldv_insmod_exit_mbcache_2_2 */
315 : void ldv_insmod_exit_mbcache_2_2(void (*arg0)(void)) {
316 4 : (exit_mbcache)();
317 2 : }
318 :
319 : /* AUX_FUNC_CALLBACK ldv_insmod_init_mbcache_2_9 */
320 : int ldv_insmod_init_mbcache_2_9(int (*arg0)(void)) {
321 3 : return (init_mbcache)();
322 1 : }
323 :
324 : /* AUX_FUNC ldv_main_3 */
325 : void ldv_main_3(void *arg0) {
326 : /* LDV {"thread": 3, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'main(main)'", "function": "ldv_main_3"} */
327 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
328 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
329 : /* LDV {"action": "INIT", "type": "CONDITION_BEGIN", "comment": "Initialize rule models."} */
330 1 : ldv_initialize();
331 : /* LDV {"action": "INIT", "type": "CONDITION_END"} */
332 :
333 : /* LDV {"action": "INSMOD_REGISTER", "type": "DISPATCH_BEGIN", "comment": "Start environment model scenarios."} */
334 2 : ldv_dispatch_insmod_register_3_3();
335 : /* LDV {"action": "INSMOD_REGISTER", "type": "DISPATCH_END"} */
336 :
337 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "DISPATCH_BEGIN", "comment": "Stop environment model scenarios."} */
338 2 : ldv_dispatch_insmod_deregister_3_2();
339 : /* LDV {"action": "INSMOD_DEREGISTER", "type": "DISPATCH_END"} */
340 :
341 : /* LDV {"action": "FINAL", "type": "CONDITION_BEGIN", "comment": "Check rule model state at the exit."} */
342 1 : ldv_check_final_state();
343 1 : ldv_stop();
344 : /* LDV {"action": "FINAL", "type": "CONDITION_END"} */
345 :
346 : /* Exit function at a terminal state */
347 0 : return;
348 : /* End of the process */
349 : return;
350 : /* LDV {"comment": "End of control function based on process 'main(main)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_main_3"} */
351 : }
352 :
353 : /* AUX_FUNC main */
354 : int main() {
355 1 : ldv_main_3(0);
356 0 : return 0;
357 : }
358 :
359 :
360 : /* AUX_FUNC ERR_PTR */
361 : static inline void *ERR_PTR (long int error)
362 : {
363 0 :
364 0 : return ldv_err_ptr(error);
365 : }
366 :
367 : /* AUX_FUNC PTR_ERR */
368 : static inline long int PTR_ERR (void const *ptr)
369 : {
370 :
371 : return ldv_ptr_err(ptr);
372 : }
373 :
374 : /* AUX_FUNC IS_ERR */
375 : static inline long int IS_ERR (void const *ptr)
376 : {
377 :
378 : return ldv_is_err(ptr);
379 : }
380 :
381 : /* AUX_FUNC IS_ERR_OR_NULL */
382 : static inline long int IS_ERR_OR_NULL (void const *ptr)
383 : {
384 :
385 : return ldv_is_err_or_null(ptr);
386 : }
387 :
388 : /* AUX_FUNC kzalloc */
389 : static inline void *kzalloc (size_t size, gfp_t flags)
390 : {
391 :
392 : return ldv_kzalloc(size, flags);
393 : }
|