-
Notifications
You must be signed in to change notification settings - Fork 1
/
Layer.v
618 lines (520 loc) · 18.7 KB
/
Layer.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
Require Import LayerDeps.
Require Import Ident.
Require Import RData.
Require Import EventReplay.
Require Import MoverTypes.
Require Import Constants.
Require Import CommonLib.
Require Import AbsAccessor.Spec.
Require Import BaremoreHandler.Spec.
Require Import RmiSMC.Spec.
Require Import CtxtSwitch.Spec.
Require Import RealmExitHandler.Spec.
Local Open Scope Z_scope.
Section Layer.
Context `{real_params: RealParams}.
Section InvDef.
Record high_level_invariant (adt: RData) :=
mkInvariants { }.
Global Instance RealmExitHandler_ops : CompatDataOps RData :=
{
empty_data := empty_adt;
high_level_invariant := high_level_invariant;
low_level_invariant := fun (b: block) (d: RData) => True;
kernel_mode adt := True
}.
End InvDef.
Section InvInit.
Global Instance RealmExitHandler_prf : CompatData RData.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
End InvInit.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Section InvProof.
Global Instance handle_realm_exit_inv: PreservesInvariants handle_realm_exit_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance shiftl_inv: PreservesInvariants shiftl_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance addr_to_idx_inv: PreservesInvariants addr_to_idx_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance el3_sync_lel_inv: PreservesInvariants el3_sync_lel_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_wi_index_inv: PreservesInvariants set_wi_index_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_refcount_inc_inv: PreservesInvariants granule_refcount_inc_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_unlock_inv: PreservesInvariants granule_unlock_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance ns_buffer_read_rec_run_inv: PreservesInvariants ns_buffer_read_rec_run_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_put_inv: PreservesInvariants granule_put_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance exit_rmm_inv: PreservesInvariants exit_rmm_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance measurement_extend_data_inv: PreservesInvariants measurement_extend_data_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_granule_undelegate_inv: PreservesInvariants smc_granule_undelegate_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance entry_is_table_inv: PreservesInvariants entry_is_table_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance barrier_inv: PreservesInvariants barrier_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance access_mask_inv: PreservesInvariants access_mask_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance atomic_granule_put_release_inv: PreservesInvariants atomic_granule_put_release_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_rec_destroy_inv: PreservesInvariants smc_rec_destroy_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance configure_realm_stage2_inv: PreservesInvariants configure_realm_stage2_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_run_gprs_inv: PreservesInvariants get_rec_run_gprs_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance esr_sign_extend_inv: PreservesInvariants esr_sign_extend_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_rec_dispose_pending_inv: PreservesInvariants set_rec_dispose_pending_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rd_g_rtt_inv: PreservesInvariants get_rd_g_rtt_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_rec_last_run_info_esr_inv: PreservesInvariants set_rec_last_run_info_esr_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_run_is_emulated_mmio_inv: PreservesInvariants get_rec_run_is_emulated_mmio_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_memzero_inv: PreservesInvariants granule_memzero_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance read_reg_inv: PreservesInvariants read_reg_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_refcount_dec_inv: PreservesInvariants granule_refcount_dec_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance measurement_extend_data_header_inv: PreservesInvariants measurement_extend_data_header_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_lock_inv: PreservesInvariants granule_lock_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance ns_buffer_unmap_inv: PreservesInvariants ns_buffer_unmap_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_memzero_mapped_inv: PreservesInvariants granule_memzero_mapped_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance atomic_granule_put_inv: PreservesInvariants atomic_granule_put_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rd_state_inv: PreservesInvariants get_rd_state_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance esr_sixty_four_inv: PreservesInvariants esr_sixty_four_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance run_realm_inv: PreservesInvariants run_realm_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_g_rtt_refcount_inv: PreservesInvariants get_g_rtt_refcount_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance restore_hcr_el2_inv: PreservesInvariants restore_hcr_el2_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance esr_srt_inv: PreservesInvariants esr_srt_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_realm_activate_inv: PreservesInvariants smc_realm_activate_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_pc_inv: PreservesInvariants get_rec_pc_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_mapping_inv: PreservesInvariants set_mapping_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_rec_pc_inv: PreservesInvariants set_rec_pc_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_rec_regs_inv: PreservesInvariants set_rec_regs_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_runnable_inv: PreservesInvariants get_rec_runnable_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance ns_granule_map_inv: PreservesInvariants ns_granule_map_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_get_inv: PreservesInvariants granule_get_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance buffer_unmap_inv: PreservesInvariants buffer_unmap_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance access_len_inv: PreservesInvariants access_len_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance enter_rmm_inv: PreservesInvariants enter_rmm_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_granule_delegate_inv: PreservesInvariants smc_granule_delegate_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_run_emulated_read_val_inv: PreservesInvariants get_rec_run_emulated_read_val_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance save_ns_state_inv: PreservesInvariants save_ns_state_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_set_state_inv: PreservesInvariants granule_set_state_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance null_ptr_inv: PreservesInvariants null_ptr_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_wi_g_llt_inv: PreservesInvariants get_wi_g_llt_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_rec_create_inv: PreservesInvariants smc_rec_create_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance granule_map_inv: PreservesInvariants granule_map_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance find_lock_granule_inv: PreservesInvariants find_lock_granule_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance is_null_inv: PreservesInvariants is_null_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance assert_cond_inv: PreservesInvariants assert_cond_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_g_rtt_rd_inv: PreservesInvariants set_g_rtt_rd_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance pgte_read_inv: PreservesInvariants pgte_read_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance ns_buffer_read_data_inv: PreservesInvariants ns_buffer_read_data_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance pgte_write_inv: PreservesInvariants pgte_write_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance set_wi_g_llt_inv: PreservesInvariants set_wi_g_llt_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_rec_last_run_info_esr_inv: PreservesInvariants get_rec_last_run_info_esr_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance find_granule_inv: PreservesInvariants find_granule_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance restore_realm_state_inv: PreservesInvariants restore_realm_state_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance esr_is_write_inv: PreservesInvariants esr_is_write_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_realm_create_inv: PreservesInvariants smc_realm_create_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance find_lock_unused_granule_inv: PreservesInvariants find_lock_unused_granule_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance entry_to_phys_inv: PreservesInvariants entry_to_phys_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance stage2_tlbi_ipa_inv: PreservesInvariants stage2_tlbi_ipa_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance atomic_granule_get_inv: PreservesInvariants atomic_granule_get_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance user_step_inv: PreservesInvariants user_step_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance get_wi_index_inv: PreservesInvariants get_wi_index_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance link_table_inv: PreservesInvariants link_table_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance smc_realm_destroy_inv: PreservesInvariants smc_realm_destroy_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
Global Instance addr_is_level_aligned_inv: PreservesInvariants addr_is_level_aligned_spec.
Proof.
constructor; intros; simpl; eauto.
constructor.
Qed.
End InvProof.
Section LayerDef.
Definition RealmExitHandler_fresh : compatlayer (cdata RData) :=
_handle_realm_exit ↦ gensem handle_realm_exit_spec
.
Definition RealmExitHandler_passthrough : compatlayer (cdata RData) :=
_shiftl ↦ gensem shiftl_spec
⊕ _addr_to_idx ↦ gensem addr_to_idx_spec
⊕ _el3_sync_lel ↦ gensem el3_sync_lel_spec
⊕ _set_wi_index ↦ gensem set_wi_index_spec
⊕ _granule_refcount_inc ↦ gensem granule_refcount_inc_spec
⊕ _granule_unlock ↦ gensem granule_unlock_spec
⊕ _ns_buffer_read_rec_run ↦ gensem ns_buffer_read_rec_run_spec
⊕ _granule_put ↦ gensem granule_put_spec
⊕ _exit_rmm ↦ gensem exit_rmm_spec
⊕ _measurement_extend_data ↦ gensem measurement_extend_data_spec
⊕ _smc_granule_undelegate ↦ gensem smc_granule_undelegate_spec
⊕ _entry_is_table ↦ gensem entry_is_table_spec
⊕ _barrier ↦ gensem barrier_spec
⊕ _access_mask ↦ gensem access_mask_spec
⊕ _atomic_granule_put_release ↦ gensem atomic_granule_put_release_spec
⊕ _smc_rec_destroy ↦ gensem smc_rec_destroy_spec
⊕ _configure_realm_stage2 ↦ gensem configure_realm_stage2_spec
⊕ _get_rec_run_gprs ↦ gensem get_rec_run_gprs_spec
⊕ _esr_sign_extend ↦ gensem esr_sign_extend_spec
⊕ _set_rec_dispose_pending ↦ gensem set_rec_dispose_pending_spec
⊕ _get_rd_g_rtt ↦ gensem get_rd_g_rtt_spec
⊕ _set_rec_last_run_info_esr ↦ gensem set_rec_last_run_info_esr_spec
⊕ _get_rec_run_is_emulated_mmio ↦ gensem get_rec_run_is_emulated_mmio_spec
⊕ _granule_memzero ↦ gensem granule_memzero_spec
⊕ _read_reg ↦ gensem read_reg_spec
⊕ _granule_refcount_dec ↦ gensem granule_refcount_dec_spec
⊕ _measurement_extend_data_header ↦ gensem measurement_extend_data_header_spec
⊕ _granule_lock ↦ gensem granule_lock_spec
⊕ _ns_buffer_unmap ↦ gensem ns_buffer_unmap_spec
⊕ _granule_memzero_mapped ↦ gensem granule_memzero_mapped_spec
⊕ _atomic_granule_put ↦ gensem atomic_granule_put_spec
⊕ _get_rd_state ↦ gensem get_rd_state_spec
⊕ _esr_sixty_four ↦ gensem esr_sixty_four_spec
⊕ _run_realm ↦ gensem run_realm_spec
⊕ _get_g_rtt_refcount ↦ gensem get_g_rtt_refcount_spec
⊕ _restore_hcr_el2 ↦ gensem restore_hcr_el2_spec
⊕ _esr_srt ↦ gensem esr_srt_spec
⊕ _smc_realm_activate ↦ gensem smc_realm_activate_spec
⊕ _get_rec_pc ↦ gensem get_rec_pc_spec
⊕ _set_mapping ↦ gensem set_mapping_spec
⊕ _set_rec_pc ↦ gensem set_rec_pc_spec
⊕ _set_rec_regs ↦ gensem set_rec_regs_spec
⊕ _get_rec_runnable ↦ gensem get_rec_runnable_spec
⊕ _ns_granule_map ↦ gensem ns_granule_map_spec
⊕ _granule_get ↦ gensem granule_get_spec
⊕ _buffer_unmap ↦ gensem buffer_unmap_spec
⊕ _access_len ↦ gensem access_len_spec
⊕ _enter_rmm ↦ gensem enter_rmm_spec
⊕ _smc_granule_delegate ↦ gensem smc_granule_delegate_spec
⊕ _get_rec_run_emulated_read_val ↦ gensem get_rec_run_emulated_read_val_spec
⊕ _save_ns_state ↦ gensem save_ns_state_spec
⊕ _granule_set_state ↦ gensem granule_set_state_spec
⊕ _null_ptr ↦ gensem null_ptr_spec
⊕ _get_wi_g_llt ↦ gensem get_wi_g_llt_spec
⊕ _smc_rec_create ↦ gensem smc_rec_create_spec
⊕ _granule_map ↦ gensem granule_map_spec
⊕ _find_lock_granule ↦ gensem find_lock_granule_spec
⊕ _is_null ↦ gensem is_null_spec
⊕ _assert_cond ↦ gensem assert_cond_spec
⊕ _set_g_rtt_rd ↦ gensem set_g_rtt_rd_spec
⊕ _pgte_read ↦ gensem pgte_read_spec
⊕ _ns_buffer_read_data ↦ gensem ns_buffer_read_data_spec
⊕ _pgte_write ↦ gensem pgte_write_spec
⊕ _set_wi_g_llt ↦ gensem set_wi_g_llt_spec
⊕ _get_rec_last_run_info_esr ↦ gensem get_rec_last_run_info_esr_spec
⊕ _find_granule ↦ gensem find_granule_spec
⊕ _restore_realm_state ↦ gensem restore_realm_state_spec
⊕ _esr_is_write ↦ gensem esr_is_write_spec
⊕ _smc_realm_create ↦ gensem smc_realm_create_spec
⊕ _find_lock_unused_granule ↦ gensem find_lock_unused_granule_spec
⊕ _entry_to_phys ↦ gensem entry_to_phys_spec
⊕ _stage2_tlbi_ipa ↦ gensem stage2_tlbi_ipa_spec
⊕ _atomic_granule_get ↦ gensem atomic_granule_get_spec
⊕ _user_step ↦ gensem user_step_spec
⊕ _get_wi_index ↦ gensem get_wi_index_spec
⊕ _link_table ↦ gensem link_table_spec
⊕ _smc_realm_destroy ↦ gensem smc_realm_destroy_spec
⊕ _addr_is_level_aligned ↦ gensem addr_is_level_aligned_spec
.
Definition RealmExitHandler := RealmExitHandler_fresh ⊕ RealmExitHandler_passthrough.
End LayerDef.
End Layer.