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 : #include <linux/device.h>
29 : #include <linux/cdev.h>
30 : #include <linux/miscdevice.h>
31 : #include <linux/platform_device.h>
32 : #include <linux/pm.h>
33 : #include <linux/rtc.h>
34 : #include <scsi/scsi_host.h>
35 : #include <linux/fs.h>
36 : #include <linux/seq_file.h>
37 : #include <linux/pagemap.h>
38 :
39 :
40 : struct ldv_struct_platform_instance_4 {
41 : int signal_pending;
42 : };
43 :
44 : struct ldv_struct_traverse_kernel_items_scenario_10 {
45 : struct seq_file *arg0;
46 : struct seq_operations *arg1;
47 : int signal_pending;
48 : };
49 :
50 : /* EMG Function declarations */
51 : void ldv_character_driver_scenario_1(void *);
52 : void ldv_character_driver_scenario_callback_1_22(ssize_t (*)(struct file *, char *, size_t , loff_t *), struct file *, char *, long unsigned int, loff_t *);
53 : void ldv_character_driver_scenario_callback_1_5(loff_t (*)(struct file *, loff_t , int), struct file *, long long int, int);
54 : void ldv_character_driver_scenario_callback_2_22(ssize_t (*)(struct file *, char *, size_t , loff_t *), struct file *, char *, long unsigned int, loff_t *);
55 : void ldv_character_driver_scenario_callback_2_5(loff_t (*)(struct file *, loff_t , int), struct file *, long long int, int);
56 : int ldv_character_driver_scenario_probe_1_13(int (*)(struct inode *, struct file *), struct inode *, struct file *);
57 : void ldv_character_driver_scenario_release_1_2(int (*)(struct inode *, struct file *), struct inode *, struct file *);
58 : void ldv_character_driver_scenario_write_1_4(ssize_t (*)(struct file *, char *, size_t , loff_t *), struct file *, char *, long unsigned int, loff_t *);
59 : void ldv_traverse_kernel_items_scenario_show_10_6(int (*)(struct seq_file *, void *), struct seq_file *, void *);
60 :
61 : /* EMG variable declarations */
62 1 : struct ldv_thread ldv_thread_1;
63 :
64 : /* EMG variable initialization */
65 :
66 : /* EMG function definitions */
67 : /* AUX_FUNC ldv_character_driver_scenario_1 */
68 : void ldv_character_driver_scenario_1(void *arg0) {
69 : /* LDV {"thread": 1, "type": "CONTROL_FUNCTION_BEGIN", "comment": "Control function 'character_driver_scenario(file_operations)'", "function": "ldv_character_driver_scenario_1"} */
70 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_BEGIN", "comment": "Declare auxiliary variables."} */
71 1 : loff_t (*ldv_1_callback_llseek)(struct file *, loff_t , int);
72 1 : ssize_t (*ldv_1_callback_read)(struct file *, char *, size_t , loff_t *);
73 1 : struct file_operations *ldv_1_container_file_operations;
74 1 : char *ldv_1_ldv_param_22_1_default;
75 1 : long long int *ldv_1_ldv_param_22_3_default;
76 1 : char *ldv_1_ldv_param_4_1_default;
77 1 : long long int *ldv_1_ldv_param_4_3_default;
78 1 : long long int ldv_1_ldv_param_5_1_default;
79 1 : int ldv_1_ldv_param_5_2_default;
80 1 : struct file *ldv_1_resource_file;
81 1 : struct inode *ldv_1_resource_inode;
82 1 : int ldv_1_ret_default;
83 1 : long unsigned int ldv_1_size_cnt_write_size;
84 1 : /* LDV {"type": "CONTROL_FUNCTION_INIT_END", "comment": "Declare auxiliary variables."} */
85 1 : /* Initialize automaton variables */
86 2 : ldv_1_ret_default = 1;
87 1 : /* LDV {"action": "DEFAULT_REGISTER_2", "type": "RECEIVE_BEGIN", "comment": "Begin FILE_OPERATIONS callbacks invocations scenario."} */
88 3 : ldv_free(arg0);
89 1 : /* LDV {"action": "DEFAULT_REGISTER_2", "type": "RECEIVE_END"} */
90 1 :
91 1 : /* LDV {"action": "DEFAULT_ALLOC_2", "type": "CONDITION_BEGIN", "comment": "Allocate memory after default registration."} */
92 4 : ldv_1_container_file_operations = ldv_xmalloc_unknown_size(0);
93 1 : /* LDV {"action": "DEFAULT_ALLOC_2", "type": "CONDITION_END"} */
94 1 :
95 : /* LDV {"action": "INIT", "type": "CONDITION_BEGIN", "comment": "Allocate memory for file and inode structures."} */
96 3 : ldv_1_resource_file = ldv_xmalloc(sizeof(struct file));
97 3 : ldv_1_resource_inode = ldv_xmalloc(sizeof(struct inode));
98 3 : ldv_1_size_cnt_write_size = ldv_undef_int();
99 : /* LDV {"action": "INIT", "type": "CONDITION_END"} */
100 :
101 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
102 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
103 :
104 : /* Jump to a subprocess 'main' initial state */
105 1 : goto ldv_main_1;
106 : /* End of the process */
107 : return;
108 1 :
109 : /* Sbprocess main */
110 : ldv_main_1:
111 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
112 :
113 4 : if (ldv_undef_int()) {
114 : /* LDV {"action": "PROBE", "type": "CALL_BEGIN", "callback": true, "comment": "Open the device file. Invoke callback open from file_operations."} */
115 : /* LDV {"type": "CALLBACK", "call": "ldv_1_ret_default = ((& proc_scsi_open))(ldv_1_resource_inode, ldv_1_resource_file);", "comment": "probe"} */
116 2 : ldv_1_ret_default = ldv_character_driver_scenario_probe_1_13(ldv_1_container_file_operations->open, ldv_1_resource_inode, ldv_1_resource_file);
117 : /* Callback post-call */
118 2 : ldv_1_ret_default = ldv_filter_err_code(ldv_1_ret_default);
119 : /* LDV {"action": "PROBE", "type": "CALL_END"} */
120 :
121 4 : if (ldv_undef_int()) {
122 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_BEGIN", "comment": "Device file is opened successfully."} */
123 2 : ldv_assume(ldv_1_ret_default == 0);
124 : /* LDV {"action": "PROBE_SUCCESS", "type": "CONDITION_END"} */
125 :
126 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
127 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
128 :
129 : /* Jump to a subprocess 'call' initial state */
130 1 : goto ldv_call_1;
131 : }
132 : else {
133 : /* LDV {"action": "PROBE_FAIL", "type": "CONDITION_BEGIN", "comment": "Failed to open devices file."} */
134 2 : ldv_assume(ldv_1_ret_default != 0);
135 : /* LDV {"action": "PROBE_FAIL", "type": "CONDITION_END"} */
136 :
137 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
138 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
139 :
140 : /* Jump to a subprocess 'main' initial state */
141 1 : goto ldv_main_1;
142 : }
143 : }
144 : else {
145 : /* LDV {"action": "FREE", "type": "CONDITION_BEGIN", "comment": "Free memory of file and inode structures."} */
146 2 : ldv_free(ldv_1_resource_file);
147 2 : ldv_free(ldv_1_resource_inode);
148 : /* LDV {"action": "FREE", "type": "CONDITION_END"} */
149 :
150 : /* LDV {"action": "DEFAULT_FREE_2", "type": "CONDITION_BEGIN", "comment": "Free memory before default deregistration."} */
151 2 : ldv_free(ldv_1_container_file_operations);
152 : /* LDV {"action": "DEFAULT_FREE_2", "type": "CONDITION_END"} */
153 :
154 : /* LDV {"action": "DEFAULT_DEREGISTER_2", "type": "RECEIVE_BEGIN", "comment": "Finish FILE_OPERATIONS callbacks invocations scenario."} */
155 : /* Skip a non-replicative signal receiving */
156 : /* LDV {"action": "DEFAULT_DEREGISTER_2", "type": "RECEIVE_END"} */
157 :
158 : /* Exit function at a terminal state */
159 1 : return;
160 : }
161 : /* End of the subprocess 'main' */
162 : return;
163 1 :
164 : /* Sbprocess call */
165 : ldv_call_1:
166 : /* LDV {"action": null, "type": "ARTIFICIAL", "comment": "Artificial state in scenario"} */
167 :
168 2 : switch (ldv_undef_int()) {
169 3 : case 1: {
170 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
171 3 : ldv_1_ldv_param_4_1_default = ldv_xmalloc_unknown_size(0);
172 3 : ldv_1_ldv_param_4_3_default = ldv_xmalloc_unknown_size(0);
173 : /* LDV {"action": "PRE_CALL_4", "type": "CONDITION_END"} */
174 :
175 : /* LDV {"action": "WRITE", "type": "CALL_BEGIN", "callback": true, "comment": "Write data to the device. Invoke callback write from file_operations."} */
176 : /* Callback pre-call */
177 2 : ldv_assume(ldv_1_size_cnt_write_size <= (INT_MAX & PAGE_CACHE_MASK));
178 : /* LDV {"type": "CALLBACK", "call": "((& proc_scsi_write))(ldv_1_resource_file, ldv_1_ldv_param_4_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_4_3_default);", "comment": "write"} */
179 3 : ldv_character_driver_scenario_write_1_4(ldv_1_container_file_operations->write, ldv_1_resource_file, ldv_1_ldv_param_4_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_4_3_default);
180 : /* LDV {"action": "WRITE", "type": "CALL_END"} */
181 :
182 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
183 2 : ldv_free(ldv_1_ldv_param_4_1_default);
184 2 : ldv_free(ldv_1_ldv_param_4_3_default);
185 : /* LDV {"action": "POST_CALL_4", "type": "CONDITION_END"} */
186 :
187 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
188 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
189 :
190 : /* Jump to a subprocess 'call' initial state */
191 1 : goto ldv_call_1;
192 1 : break;
193 : }
194 3 : case 2: {
195 : /* LDV {"action": "RELEASE", "type": "CALL_BEGIN", "callback": true, "comment": "File structure is released. Invoke callback release from file_operations."} */
196 : /* LDV {"type": "CALLBACK", "call": "((& single_release))(ldv_1_resource_inode, ldv_1_resource_file);", "comment": "release"} */
197 2 : ldv_character_driver_scenario_release_1_2(ldv_1_container_file_operations->release, ldv_1_resource_inode, ldv_1_resource_file);
198 : /* LDV {"action": "RELEASE", "type": "CALL_END"} */
199 :
200 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_BEGIN", "comment": "Device appeared in the system."} */
201 : /* LDV {"action": "MAIN", "type": "SUBPROCESS_END"} */
202 :
203 : /* Jump to a subprocess 'main' initial state */
204 1 : goto ldv_main_1;
205 1 : break;
206 : }
207 3 : case 3: {
208 : /* LDV {"action": "PRE_CALL_5", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
209 : /* LDV {"action": "PRE_CALL_5", "type": "CONDITION_END"} */
210 :
211 4 : if (ldv_undef_int()) {
212 : /* LDV {"action": "PRE_CALL_22", "type": "CONDITION_BEGIN", "comment": "Allocate memory for adhoc callback parameters."} */
213 3 : ldv_1_ldv_param_22_1_default = ldv_xmalloc_unknown_size(0);
214 3 : ldv_1_ldv_param_22_3_default = ldv_xmalloc_unknown_size(0);
215 : /* LDV {"action": "PRE_CALL_22", "type": "CONDITION_END"} */
216 :
217 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Invoke callback read from file_operations."} */
218 : /* LDV {"type": "CALLBACK", "call": "((& seq_read))(ldv_1_resource_file, ldv_1_ldv_param_22_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_22_3_default);", "comment": "callback"} */
219 2 : ldv_character_driver_scenario_callback_1_22(ldv_1_callback_read, ldv_1_resource_file, ldv_1_ldv_param_22_1_default, ldv_1_size_cnt_write_size, ldv_1_ldv_param_22_3_default);
220 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
221 :
222 : /* LDV {"action": "POST_CALL_22", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
223 2 : ldv_free(ldv_1_ldv_param_22_1_default);
224 2 : ldv_free(ldv_1_ldv_param_22_3_default);
225 : /* LDV {"action": "POST_CALL_22", "type": "CONDITION_END"} */
226 :
227 : }
228 : else {
229 : /* LDV {"action": "CALLBACK", "type": "CALL_BEGIN", "callback": true, "comment": "Invoke callback llseek from file_operations."} */
230 : /* LDV {"type": "CALLBACK", "call": "((& seq_lseek))(ldv_1_resource_file, ldv_1_ldv_param_5_1_default, ldv_1_ldv_param_5_2_default);", "comment": "callback"} */
231 2 : ldv_character_driver_scenario_callback_1_5(ldv_1_callback_llseek, ldv_1_resource_file, ldv_1_ldv_param_5_1_default, ldv_1_ldv_param_5_2_default);
232 : /* LDV {"action": "CALLBACK", "type": "CALL_END"} */
233 :
234 : }
235 2 : break;
236 1 : }
237 2 : default: ldv_stop();
238 1 : }
239 0 : /* LDV {"action": "POST_CALL_5", "type": "CONDITION_BEGIN", "comment": "Free memory of adhoc callback parameters."} */
240 : /* LDV {"action": "POST_CALL_5", "type": "CONDITION_END"} */
241 0 :
242 : /* LDV {"action": "CALL", "type": "SUBPROCESS_BEGIN", "comment": "Device file is opened, ready to read and write."} */
243 : /* LDV {"action": "CALL", "type": "SUBPROCESS_END"} */
244 :
245 : /* Jump to a subprocess 'call' initial state */
246 2 : goto ldv_call_1;
247 : /* Jump to a subprocess 'call' initial state */
248 : goto ldv_call_1;
249 : /* End of the subprocess 'call' */
250 : return;
251 : /* LDV {"comment": "End of control function based on process 'character_driver_scenario(file_operations)'", "type": "CONTROL_FUNCTION_END", "function": "ldv_character_driver_scenario_1"} */
252 : }
253 :
254 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_1_22 */
255 : void ldv_character_driver_scenario_callback_1_22(ssize_t (*arg0)(struct file *, char *, size_t , loff_t *), struct file *arg1, char *arg2, long unsigned int arg3, long long int *arg4) {
256 1 : ((& seq_read))(arg1, arg2, arg3, arg4);
257 1 : }
258 :
259 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_1_5 */
260 : void ldv_character_driver_scenario_callback_1_5(loff_t (*arg0)(struct file *, loff_t , int), struct file *arg1, long long int arg2, int arg3) {
261 1 : ((& seq_lseek))(arg1, arg2, arg3);
262 1 : }
263 :
264 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_2_22 */
265 : void ldv_character_driver_scenario_callback_2_22(ssize_t (*arg0)(struct file *, char *, size_t , loff_t *), struct file *arg1, char *arg2, long unsigned int arg3, long long int *arg4) {
266 1 : ((& seq_read))(arg1, arg2, arg3, arg4);
267 1 : }
268 :
269 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_callback_2_5 */
270 : void ldv_character_driver_scenario_callback_2_5(loff_t (*arg0)(struct file *, loff_t , int), struct file *arg1, long long int arg2, int arg3) {
271 1 : ((& seq_lseek))(arg1, arg2, arg3);
272 1 : }
273 :
274 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_probe_1_13 */
275 : int ldv_character_driver_scenario_probe_1_13(int (*arg0)(struct inode *, struct file *), struct inode *arg1, struct file *arg2) {
276 3 : return ((& proc_scsi_open))(arg1, arg2);
277 : }
278 1 :
279 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_release_1_2 */
280 : void ldv_character_driver_scenario_release_1_2(int (*arg0)(struct inode *, struct file *), struct inode *arg1, struct file *arg2) {
281 1 : ((& single_release))(arg1, arg2);
282 1 : }
283 :
284 : /* AUX_FUNC_CALLBACK ldv_character_driver_scenario_write_1_4 */
285 : void ldv_character_driver_scenario_write_1_4(ssize_t (*arg0)(struct file *, char *, size_t , loff_t *), struct file *arg1, char *arg2, long unsigned int arg3, long long int *arg4) {
286 5 : ((& proc_scsi_write))(arg1, arg2, arg3, arg4);
287 1 : }
288 :
289 : /* AUX_FUNC_CALLBACK ldv_traverse_kernel_items_scenario_show_10_6 */
290 : void ldv_traverse_kernel_items_scenario_show_10_6(int (*arg0)(struct seq_file *, void *), struct seq_file *arg1, void *arg2) {
291 2 : ((proc_scsi_show))(arg1, arg2);
292 1 : }
293 :
294 :
295 : /* AUX_FUNC ERR_PTR */
296 : static inline void *ERR_PTR (long int error)
297 : {
298 :
299 : return ldv_err_ptr(error);
300 : }
301 :
302 : /* AUX_FUNC PTR_ERR */
303 : static inline long int PTR_ERR (void const *ptr)
304 : {
305 :
306 : return ldv_ptr_err(ptr);
307 : }
308 :
309 : /* AUX_FUNC IS_ERR */
310 : static inline long int IS_ERR (void const *ptr)
311 : {
312 :
313 : return ldv_is_err(ptr);
314 : }
315 :
316 : /* AUX_FUNC IS_ERR_OR_NULL */
317 : static inline long int IS_ERR_OR_NULL (void const *ptr)
318 : {
319 :
320 : return ldv_is_err_or_null(ptr);
321 : }
322 :
323 : /* AUX_FUNC kzalloc */
324 : static inline void *kzalloc (size_t size, gfp_t flags)
325 : {
326 :
327 : return ldv_kzalloc(size, flags);
328 : }
|