-
Notifications
You must be signed in to change notification settings - Fork 1
/
DomainSepInv.thy
1412 lines (1242 loc) · 56.9 KB
/
DomainSepInv.thy
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
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
* Copyright 2020, Data61, CSIRO (ABN 41 687 119 230)
*
* SPDX-License-Identifier: GPL-2.0-only
*)
theory DomainSepInv
imports
"Ipc_AC" (* for transfer_caps_loop_pres_dest lec_valid_cap' set_simple_ko_get_tcb thread_set_tcb_fault_update_valid_mdb *)
"Lib.WPBang"
begin
context begin interpretation Arch . (*FIXME: arch_split*)
text \<open>
We define and prove an invariant that is necessary to achieve domain
separation on seL4. In its strongest form, we require that all IRQs, other than
those for the timer, are inactive, and that no IRQControl or
IRQHandler caps are present (to prevent any inactive IRQs from becoming
active in the future).
It always requires that there are no domain caps.
\<close>
text \<open>
When @{term irqs} is @{term False} we require that non-timer IRQs are off permanently.
\<close>
definition domain_sep_inv where
"domain_sep_inv irqs st s \<equiv>
(\<forall> slot. \<not> cte_wp_at ((=) DomainCap) slot s) \<and>
(irqs \<or> (\<forall> irq slot. \<not> cte_wp_at ((=) IRQControlCap) slot s
\<and> \<not> cte_wp_at ((=) (IRQHandlerCap irq)) slot s
\<and> interrupt_states s irq \<noteq> IRQSignal
\<and> interrupt_states s irq \<noteq> IRQReserved
\<and> interrupt_states s = interrupt_states st))"
definition domain_sep_inv_cap where
"domain_sep_inv_cap irqs cap \<equiv> case cap of
IRQControlCap \<Rightarrow> irqs
| IRQHandlerCap irq \<Rightarrow> irqs
| DomainCap \<Rightarrow> False
| _ \<Rightarrow> True"
lemma cte_wp_at_not_domain_sep_inv_cap:
"cte_wp_at (not domain_sep_inv_cap irqs) slot s \<longleftrightarrow>
((irqs \<longrightarrow> False) \<and>
(\<not> irqs \<longrightarrow> (cte_wp_at ((=) IRQControlCap) slot s \<or>
(\<exists> irq. cte_wp_at ((=) (IRQHandlerCap irq)) slot s)))
)
\<or> cte_wp_at ((=) DomainCap) slot s"
apply(rule iffI)
apply(drule cte_wp_at_eqD)
apply clarsimp
apply(case_tac c, simp_all add: domain_sep_inv_cap_def pred_neg_def)
apply(auto elim: cte_wp_at_weakenE split: if_splits)
done
lemma domain_sep_inv_def2:
"domain_sep_inv irqs st s =
((\<forall> slot. \<not> cte_wp_at ((=) DomainCap) slot s) \<and>
(irqs \<or> (\<forall> irq slot. \<not> cte_wp_at ((=) IRQControlCap) slot s
\<and> \<not> cte_wp_at ((=) (IRQHandlerCap irq)) slot s)) \<and>
(irqs \<or> (\<forall> irq.
interrupt_states s irq \<noteq> IRQSignal
\<and> interrupt_states s irq \<noteq> IRQReserved
\<and> interrupt_states s = interrupt_states st)))"
apply(fastforce simp: domain_sep_inv_def)
done
lemma domain_sep_inv_wp:
assumes nctrl: "\<And>slot. \<lbrace>(\<lambda>s. \<not> cte_wp_at (not domain_sep_inv_cap irqs) slot s) and P\<rbrace> f \<lbrace>\<lambda>_ s. \<not> cte_wp_at (not domain_sep_inv_cap irqs) slot s\<rbrace>"
assumes irq_pres: "\<And>P. \<not> irqs \<Longrightarrow> \<lbrace>(\<lambda>s. P (interrupt_states s)) and R\<rbrace> f \<lbrace>\<lambda>_ s. P (interrupt_states s)\<rbrace>"
shows "\<lbrace>domain_sep_inv irqs st and P and (\<lambda>s. irqs \<or> R s)\<rbrace> f \<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply (clarsimp simp: domain_sep_inv_def2 valid_def)
apply (subst conj_assoc[symmetric])
apply (rule conjI)
apply (rule conjI)
apply(intro allI)
apply(erule use_valid[OF _ hoare_strengthen_post[OF nctrl]])
apply(fastforce simp: cte_wp_at_not_domain_sep_inv_cap)
apply(fastforce simp: cte_wp_at_not_domain_sep_inv_cap)
apply(fastforce elim!: use_valid[OF _ hoare_strengthen_post[OF nctrl]] simp: cte_wp_at_not_domain_sep_inv_cap)
apply(case_tac "irqs")
apply blast
apply(rule disjI2)
apply simp
apply(intro allI conjI)
apply(erule_tac P1="\<lambda>x. x irq \<noteq> IRQSignal" in use_valid[OF _ irq_pres], assumption)
apply blast
apply(erule use_valid[OF _ irq_pres], assumption)
apply blast
apply(erule use_valid[OF _ irq_pres], assumption)
apply blast
done
lemma domain_sep_inv_triv:
assumes cte_pres: "\<And>P slot. \<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace> f \<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
assumes irq_pres: "\<And>P. \<lbrace>\<lambda>s. P (interrupt_states s)\<rbrace> f \<lbrace>\<lambda>_ s. P (interrupt_states s)\<rbrace>"
shows
"\<lbrace>domain_sep_inv irqs st\<rbrace> f \<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule domain_sep_inv_wp[where P="\<top>" and R="\<top>", simplified])
apply(rule cte_pres, rule irq_pres)
done
(* FIXME: clagged from FinalCaps *)
lemma set_object_wp:
"\<lbrace> \<lambda> s. P (s\<lparr>kheap := kheap s(ptr \<mapsto> obj)\<rparr>) \<rbrace>
set_object ptr obj
\<lbrace> \<lambda>_. P \<rbrace>"
by (wpsimp wp: set_object_wp)
(* FIXME: following 3 lemmas clagged from FinalCaps *)
lemma set_cap_neg_cte_wp_at_other_helper':
"\<lbrakk>oslot \<noteq> slot;
ko_at (TCB x) (fst oslot) s;
tcb_cap_cases (snd oslot) = Some (ogetF, osetF, orestr);
kheap
(s\<lparr>kheap := kheap s(fst oslot \<mapsto>
TCB (osetF (\<lambda> x. cap) x))\<rparr>)
(fst slot) =
Some (TCB tcb);
tcb_cap_cases (snd slot) = Some (getF, setF, restr);
P (getF tcb)\<rbrakk> \<Longrightarrow>
cte_wp_at P slot s"
apply(case_tac "fst oslot = fst slot")
apply(rule cte_wp_at_tcbI)
apply(fastforce split: if_splits simp: obj_at_def)
apply assumption
apply(fastforce split: if_splits simp: tcb_cap_cases_def dest: prod_eqI)
apply(rule cte_wp_at_tcbI)
apply(fastforce split: if_splits simp: obj_at_def)
apply assumption
apply assumption
done
lemma set_cap_neg_cte_wp_at_other_helper:
"\<lbrakk>\<not> cte_wp_at P slot s; oslot \<noteq> slot; ko_at (TCB x) (fst oslot) s;
tcb_cap_cases (snd oslot) = Some (getF, setF, restr)\<rbrakk> \<Longrightarrow>
\<not> cte_wp_at P slot (s\<lparr>kheap := kheap s(fst oslot \<mapsto> TCB (setF (\<lambda> x. cap) x))\<rparr>)"
apply(rule notI)
apply(erule cte_wp_atE)
apply(fastforce elim: notE intro: cte_wp_at_cteI split: if_splits)
apply(fastforce elim: notE intro: set_cap_neg_cte_wp_at_other_helper')
done
lemma set_cap_neg_cte_wp_at_other:
"oslot \<noteq> slot \<Longrightarrow> \<lbrace> \<lambda> s. \<not> (cte_wp_at P slot s)\<rbrace> set_cap cap oslot \<lbrace> \<lambda>rv s. \<not> (cte_wp_at P slot s) \<rbrace>"
apply(rule hoare_pre)
unfolding set_cap_def
apply(wp set_object_wp get_object_wp | wpc | simp add: split_def)+
apply(intro allI impI conjI)
apply(rule notI)
apply(erule cte_wp_atE)
apply (fastforce split: if_splits dest: prod_eqI elim: notE intro: cte_wp_at_cteI simp: obj_at_def)
apply(fastforce split: if_splits elim: notE intro: cte_wp_at_tcbI)
apply(auto dest: set_cap_neg_cte_wp_at_other_helper)
done
lemma set_cap_neg_cte_wp_at:
"\<lbrace>(\<lambda>s. \<not> cte_wp_at P slot s) and K (\<not> P capa)\<rbrace>
set_cap capa slota
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(case_tac "slot = slota")
apply simp
apply(simp add: set_cap_def set_object_def)
apply(rule hoare_pre)
apply(wp get_object_wp | wpc)+
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
apply(rule hoare_pre)
apply(rule set_cap_neg_cte_wp_at_other, simp+)
done
lemma domain_sep_inv_cap_IRQControlCap:
"\<lbrakk>domain_sep_inv_cap irqs cap; \<not> irqs\<rbrakk> \<Longrightarrow> cap \<noteq> IRQControlCap"
apply(auto simp: domain_sep_inv_cap_def)
done
lemma domain_sep_inv_cap_IRQHandlerCap:
"\<lbrakk>domain_sep_inv_cap irqs cap; \<not> irqs\<rbrakk> \<Longrightarrow> cap \<noteq> IRQHandlerCap irq"
apply(auto simp: domain_sep_inv_cap_def)
done
lemma set_cap_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and K (domain_sep_inv_cap irqs cap)\<rbrace>
set_cap cap slot
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule hoare_gen_asm)
apply(rule hoare_pre)
apply(rule domain_sep_inv_wp)
apply(wp set_cap_neg_cte_wp_at | simp add: pred_neg_def | blast)+
done
lemma cte_wp_at_domain_sep_inv_cap:
"\<lbrakk>domain_sep_inv irqs st s; cte_wp_at ((=) cap) slot s\<rbrakk> \<Longrightarrow> domain_sep_inv_cap irqs cap"
apply(case_tac slot)
apply(auto simp: domain_sep_inv_def domain_sep_inv_cap_def split: cap.splits)
done
lemma weak_derived_irq_handler:
"weak_derived (IRQHandlerCap irq) cap \<Longrightarrow> cap = (IRQHandlerCap irq)"
apply(auto simp: weak_derived_def copy_of_def same_object_as_def split: cap.splits if_splits arch_cap.splits)
done
(* FIXME: move to CSpace_AI *)
lemma weak_derived_DomainCap:
"weak_derived c' c \<Longrightarrow> (c' = cap.DomainCap) = (c = cap.DomainCap)"
apply (clarsimp simp: weak_derived_def)
apply (erule disjE)
apply (clarsimp simp: copy_of_def split: if_split_asm)
apply (auto simp: is_cap_simps same_object_as_def
split: cap.splits arch_cap.splits)[1]
apply simp
done
lemma cte_wp_at_weak_derived_domain_sep_inv_cap:
"\<lbrakk>domain_sep_inv irqs st s; cte_wp_at (weak_derived cap) slot s\<rbrakk> \<Longrightarrow> domain_sep_inv_cap irqs cap"
apply (cases slot)
apply (force simp: domain_sep_inv_def domain_sep_inv_cap_def
split: cap.splits
dest: cte_wp_at_eqD weak_derived_irq_handler weak_derived_DomainCap)
done
lemma is_derived_IRQHandlerCap:
"is_derived m src (IRQHandlerCap irq) cap \<Longrightarrow> (cap = IRQHandlerCap irq)"
apply(clarsimp simp: is_derived_def)
apply(case_tac cap, simp_all add: is_cap_simps cap_master_cap_def)
done
(* FIXME: move to CSpace_AI *)
lemma DomainCap_is_derived:
"is_derived m src cap.DomainCap cap \<Longrightarrow> cap = DomainCap"
by (auto simp: is_derived_def is_reply_cap_def is_pg_cap_def is_master_reply_cap_def cap_master_cap_def split: cap.splits)
lemma cte_wp_at_is_derived_domain_sep_inv_cap:
"\<lbrakk>domain_sep_inv irqs st s; cte_wp_at (is_derived (cdt s) slot cap) slot s\<rbrakk> \<Longrightarrow> domain_sep_inv_cap irqs cap"
apply (cases slot)
apply (fastforce simp: domain_sep_inv_def domain_sep_inv_cap_def
split: cap.splits
dest: cte_wp_at_eqD DomainCap_is_derived is_derived_IRQHandlerCap)
done
lemma domain_sep_inv_exst_update[simp]:
"domain_sep_inv irqs st (trans_state f s) = domain_sep_inv irqs st s"
apply(simp add: domain_sep_inv_def)
done
lemma domain_sep_inv_is_original_cap_update[simp]:
"domain_sep_inv irqs st (s\<lparr>is_original_cap := X\<rparr>) = domain_sep_inv irqs st s"
apply(simp add: domain_sep_inv_def)
done
lemma domain_sep_inv_cdt_update[simp]:
"domain_sep_inv irqs st (s\<lparr>cdt := X\<rparr>) = domain_sep_inv irqs st s"
apply(simp add: domain_sep_inv_def)
done
crunch domain_sep_inv[wp]: update_cdt "domain_sep_inv irqs st"
lemma set_untyped_cap_as_full_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace> set_untyped_cap_as_full a b c \<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(clarsimp simp: set_untyped_cap_as_full_def)
apply(rule hoare_pre)
apply(rule set_cap_domain_sep_inv)
apply(case_tac a, simp_all add: domain_sep_inv_cap_def)
done
lemma cap_insert_domain_sep_inv:
"\<lbrace> domain_sep_inv irqs st and (\<lambda>s. cte_wp_at (is_derived (cdt s) slot cap) slot s) \<rbrace>
cap_insert cap slot dest_slot
\<lbrace> \<lambda>_. domain_sep_inv irqs st \<rbrace>"
apply(simp add: cap_insert_def)
apply(wp set_cap_domain_sep_inv get_cap_wp set_original_wp dxo_wp_weak | simp split del: if_split)+
apply(blast dest: cte_wp_at_is_derived_domain_sep_inv_cap)
done
lemma domain_sep_inv_cap_NullCap[simp]:
"domain_sep_inv_cap irqs NullCap"
apply(simp add: domain_sep_inv_cap_def)
done
lemma cap_move_domain_sep_inv:
"\<lbrace> domain_sep_inv irqs st and (\<lambda>s. cte_wp_at (weak_derived cap) slot s) \<rbrace>
cap_move cap slot dest_slot
\<lbrace> \<lambda>_. domain_sep_inv irqs st \<rbrace>"
apply(simp add: cap_move_def)
apply(wp set_cap_domain_sep_inv get_cap_wp set_original_wp dxo_wp_weak | simp split del: if_split | blast dest: cte_wp_at_weak_derived_domain_sep_inv_cap)+
done
lemma domain_sep_inv_machine_state_update[simp]:
"domain_sep_inv irqs st (s\<lparr>machine_state := X\<rparr>) = domain_sep_inv irqs st s"
apply(simp add: domain_sep_inv_def)
done
lemma set_irq_state_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and (\<lambda>s. stt = interrupt_states s irq)\<rbrace>
set_irq_state stt irq
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: set_irq_state_def)
apply(wp | simp add: do_machine_op_def | wpc)+
done
lemma deleted_irq_handler_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and K irqs\<rbrace> deleted_irq_handler a \<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule hoare_gen_asm)
apply(simp add: deleted_irq_handler_def)
apply(simp add: set_irq_state_def)
apply wp
apply(rule domain_sep_inv_triv, wp+)
apply(simp add: domain_sep_inv_def)
done
lemma empty_slot_domain_sep_inv:
"\<lbrace>\<lambda>s. domain_sep_inv irqs st s \<and> (\<not> irqs \<longrightarrow> b = NullCap)\<rbrace>
empty_slot a b
\<lbrace>\<lambda>_ s. domain_sep_inv irqs st s\<rbrace>"
unfolding empty_slot_def
by (wpsimp wp: get_cap_wp set_cap_domain_sep_inv set_original_wp dxo_wp_weak static_imp_wp
deleted_irq_handler_domain_sep_inv)
lemma set_simple_ko_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace> set_simple_ko f a b \<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(simp add: set_simple_ko_def)
apply(wp set_object_wp_strong get_object_wp
| simp add: partial_inv_def a_type_def split: kernel_object.splits)+
apply(case_tac "a = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch domain_sep_inv[wp]: set_simple_ko "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma set_thread_state_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace> set_thread_state a b \<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(simp add: set_thread_state_def)
apply(wp set_object_wp get_object_wp dxo_wp_weak| simp)+
apply(case_tac "a = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma set_bound_notification_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace> set_bound_notification a b \<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(simp add: set_bound_notification_def)
apply(wp set_object_wp get_object_wp dxo_wp_weak| simp)+
apply(case_tac "a = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch domain_sep_inv[wp]: set_thread_state, set_bound_notification, get_bound_notification "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma thread_set_tcb_fault_update_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
thread_set (tcb_fault_update blah) param_a
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(simp add: thread_set_def)
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "param_a = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma thread_set_tcb_fault_update_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
thread_set (tcb_fault_update blah) param_a
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(wp domain_sep_inv_triv)
done
crunch domain_sep_inv[wp]: cap_delete_one "domain_sep_inv irqs st"
(wp: mapM_x_wp' hoare_unless_wp dxo_wp_weak ignore: tcb_sched_action reschedule_required simp: crunch_simps)
lemma reply_cancel_ipc_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
reply_cancel_ipc t
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: reply_cancel_ipc_def)
apply (wp select_wp)
apply(rule hoare_strengthen_post[OF thread_set_tcb_fault_update_domain_sep_inv])
apply auto
done
lemma domain_sep_inv_arch_state_update[simp]:
"domain_sep_inv irqs st (s\<lparr>arch_state := blah\<rparr>) = domain_sep_inv irqs st s"
apply(simp add: domain_sep_inv_def)
done
lemma set_pt_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
set_pt ptr pt
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
unfolding set_pt_def
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch domain_sep_inv[wp]: set_pt "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma set_pd_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
set_pd ptr pt
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
unfolding set_pd_def
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch domain_sep_inv[wp]: set_pd "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma set_asid_pool_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
set_asid_pool ptr pt
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
unfolding set_asid_pool_def
apply(wp set_object_wp get_object_wp | simp)+
apply(case_tac "ptr = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(fastforce elim: cte_wp_atE simp: obj_at_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
crunch domain_sep_inv[wp]: set_asid_pool "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma as_user_domain_sep_inv[wp]:
"\<lbrace>\<lambda>s. domain_sep_inv irqs st s\<rbrace> as_user a b \<lbrace>\<lambda>_ s. domain_sep_inv irqs st s\<rbrace>"
by (wpsimp simp: domain_sep_inv_def
wp: as_user_cte_wp_at as_user_interrupt_states hoare_vcg_conj_lift
hoare_vcg_all_lift hoare_vcg_disj_lift)
crunch domain_sep_inv[wp]: finalise_cap "domain_sep_inv irqs st"
(wp: crunch_wps dxo_wp_weak simp: crunch_simps ignore: set_object tcb_sched_action)
lemma finalise_cap_domain_sep_inv_cap:
"\<lbrace>\<lambda>s. domain_sep_inv_cap irqs cap\<rbrace> finalise_cap cap b \<lbrace>\<lambda>rv s. domain_sep_inv_cap irqs (fst rv)\<rbrace>"
including no_pre
apply(case_tac cap)
apply(wp | simp add: o_def split del: if_split split: cap.splits arch_cap.splits | fastforce split: if_splits simp: domain_sep_inv_cap_def)+
apply(rule hoare_pre, wp, fastforce)
apply(rule hoare_pre, simp, wp, fastforce simp: domain_sep_inv_cap_def)
apply(simp add: arch_finalise_cap_def)
apply(rule hoare_pre)
apply(wpc | wp | simp)+
done
lemma get_cap_domain_sep_inv_cap:
"\<lbrace>domain_sep_inv irqs st\<rbrace> get_cap cap \<lbrace>\<lambda>rv s. domain_sep_inv_cap irqs rv\<rbrace>"
apply(wp get_cap_wp)
apply(blast dest: cte_wp_at_domain_sep_inv_cap)
done
crunch domain_sep_inv[wp]: cap_swap_for_delete "domain_sep_inv irqs st"
(wp: get_cap_domain_sep_inv_cap dxo_wp_weak simp: crunch_simps ignore: cap_swap_ext)
lemma finalise_cap_returns_NullCap:
"\<lbrace>\<lambda>s. domain_sep_inv_cap irqs cap\<rbrace>
finalise_cap cap b
\<lbrace>\<lambda>rv s. \<not> irqs \<longrightarrow> snd rv = NullCap\<rbrace>"
apply(case_tac cap)
by (wpsimp simp: o_def split_del: if_split | clarsimp simp: domain_sep_inv_cap_def arch_finalise_cap_def)+
lemma rec_del_domain_sep_inv':
notes drop_spec_valid[wp_split del] drop_spec_validE[wp_split del]
rec_del.simps[simp del]
shows
"s \<turnstile> \<lbrace> domain_sep_inv irqs st\<rbrace>
(rec_del call)
\<lbrace>\<lambda> a s. (case call of (FinaliseSlotCall x y) \<Rightarrow> (y \<or> fst a) \<longrightarrow> \<not> irqs \<longrightarrow> snd a = NullCap | _ \<Rightarrow> True) \<and> domain_sep_inv irqs st s\<rbrace>,\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
proof (induct s arbitrary: rule: rec_del.induct, simp_all only: rec_del_fails hoare_fail_any)
case (1 slot exposed s) show ?case
apply(simp add: split_def rec_del.simps)
apply(wp empty_slot_domain_sep_inv drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] | simp)+
apply(rule spec_strengthen_postE[OF "1.hyps"])
apply fastforce
done
next
case (2 slot exposed s) show ?case
apply(simp add: rec_del.simps split del: if_split)
apply(rule hoare_pre_spec_validE)
apply(wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] set_cap_domain_sep_inv
|simp add: split_def split del: if_split)+
apply(rule spec_strengthen_postE)
apply(rule "2.hyps", fastforce+)
apply(rule drop_spec_validE, (wp preemption_point_inv| simp)+)[1]
apply simp
apply(rule spec_strengthen_postE)
apply(rule "2.hyps", fastforce+)
apply(wp finalise_cap_domain_sep_inv_cap get_cap_wp
finalise_cap_returns_NullCap
drop_spec_validE[OF liftE_wp] set_cap_domain_sep_inv
|simp add: without_preemption_def split del: if_split
|wp (once) hoare_drop_imps)+
apply(blast dest: cte_wp_at_domain_sep_inv_cap)
done
next
case (3 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply (wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp])
apply(rule hoare_pre_spec_validE)
apply (wp drop_spec_validE[OF assertE_wp])
apply(fastforce)
done
next
case (4 ptr bits n slot s) show ?case
apply(simp add: rec_del.simps)
apply (wp drop_spec_validE[OF returnOk_wp] drop_spec_validE[OF liftE_wp] set_cap_domain_sep_inv
drop_spec_validE[OF assertE_wp] get_cap_wp | simp)+
apply (rule spec_strengthen_postE[OF "4.hyps"])
apply(simp add: returnOk_def return_def)
apply(clarsimp simp: domain_sep_inv_cap_def)
done
qed
lemma rec_del_domain_sep_inv:
"\<lbrace> domain_sep_inv irqs st\<rbrace>
(rec_del call)
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply (rule validE_valid)
apply (rule use_spec)
apply (rule spec_strengthen_postE[OF rec_del_domain_sep_inv'])
by fastforce
crunch domain_sep_inv[wp]: cap_delete "domain_sep_inv irqs st"
lemma preemption_point_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace> preemption_point \<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
by (wp preemption_point_inv | simp)+
lemma cap_revoke_domain_sep_inv':
notes drop_spec_valid[wp_split del] drop_spec_validE[wp_split del]
shows
"s \<turnstile> \<lbrace> domain_sep_inv irqs st\<rbrace>
cap_revoke slot
\<lbrace> \<lambda>_. domain_sep_inv irqs st\<rbrace>, \<lbrace> \<lambda>_. domain_sep_inv irqs st\<rbrace>"
proof(induct rule: cap_revoke.induct[where ?a1.0=s])
case (1 slot s)
show ?case
apply(subst cap_revoke.simps)
apply(rule hoare_pre_spec_validE)
apply (wp "1.hyps")
apply(wp spec_valid_conj_liftE2 | simp)+
apply(wp drop_spec_validE[OF valid_validE[OF preemption_point_domain_sep_inv]]
drop_spec_validE[OF valid_validE[OF cap_delete_domain_sep_inv]]
drop_spec_validE[OF assertE_wp] drop_spec_validE[OF returnOk_wp]
drop_spec_validE[OF liftE_wp] select_wp
| simp | wp (once) hoare_drop_imps)+
done
qed
lemmas cap_revoke_domain_sep_inv[wp] = use_spec(2)[OF cap_revoke_domain_sep_inv']
lemma cap_move_cte_wp_at_other:
"\<lbrace> cte_wp_at P slot and K (slot \<noteq> dest_slot \<and> slot \<noteq> src_slot) \<rbrace>
cap_move cap src_slot dest_slot
\<lbrace> \<lambda>_. cte_wp_at P slot \<rbrace>"
unfolding cap_move_def
apply (rule hoare_pre)
apply (wp set_cdt_cte_wp_at set_cap_cte_wp_at' dxo_wp_weak static_imp_wp
set_original_wp | simp)+
done
lemma cte_wp_at_weak_derived_ReplyCap:
"cte_wp_at ((=) (ReplyCap x False R)) slot s
\<Longrightarrow> cte_wp_at (weak_derived (ReplyCap x False R)) slot s"
apply(erule cte_wp_atE)
apply(rule cte_wp_at_cteI)
apply assumption
apply assumption
apply assumption
apply simp
apply(rule cte_wp_at_tcbI)
apply auto
done
lemma thread_set_tcb_registers_caps_merge_default_tcb_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
thread_set (tcb_registers_caps_merge default_tcb) word
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
unfolding thread_set_def
apply(wp set_object_wp | simp)+
apply(case_tac "word = fst slot")
apply(clarsimp split: kernel_object.splits)
apply(erule notE)
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(drule get_tcb_SomeD)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply assumption
apply (clarsimp simp: tcb_cap_cases_def tcb_registers_caps_merge_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma thread_set_tcb_registers_caps_merge_default_tcb_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
thread_set (tcb_registers_caps_merge default_tcb) word
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(wp domain_sep_inv_triv)
done
lemma cancel_badged_sends_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
cancel_badged_sends epptr badge
\<lbrace>\<lambda>rv. domain_sep_inv irqs st\<rbrace>"
apply(simp add: cancel_badged_sends_def)
apply(rule hoare_pre)
apply(wp dxo_wp_weak mapM_wp | wpc | simp add: filterM_mapM | rule subset_refl | wp (once) hoare_drop_imps)+
done
crunch domain_sep_inv[wp]: finalise_slot "domain_sep_inv irqs st"
lemma invoke_cnode_domain_sep_inv:
"\<lbrace> domain_sep_inv irqs st and valid_cnode_inv ci\<rbrace>
invoke_cnode ci
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding invoke_cnode_def
apply(case_tac ci)
apply(wp cap_insert_domain_sep_inv cap_move_domain_sep_inv | simp split del: if_split)+
apply(rule hoare_pre)
apply (wpsimp wp: cap_move_domain_sep_inv cap_move_cte_wp_at_other get_cap_wp,
blast dest: cte_wp_at_weak_derived_domain_sep_inv_cap)+
apply (wpsimp wp: cap_move_domain_sep_inv get_cap_wp)
apply(fastforce dest: cte_wp_at_weak_derived_ReplyCap)
apply(wp | simp | wpc | rule hoare_pre)+
done
lemma create_cap_domain_sep_inv[wp]:
"\<lbrace> domain_sep_inv irqs st\<rbrace>
create_cap tp sz p dev slot
\<lbrace> \<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: create_cap_def)
apply(rule hoare_pre)
apply(wp set_cap_domain_sep_inv dxo_wp_weak | wpc | simp)+
apply clarsimp
apply(case_tac tp, simp_all add: domain_sep_inv_cap_def)
done
lemma detype_interrupts_states[simp]:
"interrupt_states (detype S s) = interrupt_states s"
apply(simp add: detype_def)
done
lemma detype_domain_sep_inv[simp]:
"domain_sep_inv irqs st s \<longrightarrow> domain_sep_inv irqs st (detype S s)"
apply(fastforce simp: domain_sep_inv_def)
done
lemma domain_sep_inv_detype_lift:
"\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv. domain_sep_inv irqs st\<rbrace> \<Longrightarrow>
\<lbrace>P\<rbrace> f \<lbrace>\<lambda>rv s. domain_sep_inv irqs st (detype S s)\<rbrace>"
apply(strengthen detype_domain_sep_inv, assumption)
done
lemma retype_region_neg_cte_wp_at_not_domain_sep_inv_cap:
"\<lbrace>\<lambda>s. \<not> cte_wp_at (not domain_sep_inv_cap irqs) slot s \<rbrace>
retype_region base n sz ty dev
\<lbrace>\<lambda>rv s. \<not> cte_wp_at (not domain_sep_inv_cap irqs) slot s\<rbrace>"
apply(rule hoare_pre)
apply(simp only: retype_region_def retype_addrs_def
foldr_upd_app_if fun_app_def K_bind_def)
apply(wp dxo_wp_weak |simp)+
apply clarsimp
apply(case_tac "fst slot \<in> (\<lambda>p. ptr_add base (p * 2 ^ obj_bits_api ty sz)) `
{0..<n}")
apply clarsimp
apply(erule cte_wp_atE)
apply(clarsimp simp: default_object_def empty_cnode_def split: apiobject_type.splits if_splits simp: pred_neg_def)
apply(clarsimp simp: default_object_def default_tcb_def tcb_cap_cases_def split: apiobject_type.splits if_splits simp: pred_neg_def)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_tcbI cte_wp_at_cteI)
done
lemma retype_region_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
retype_region base n sz tp dev
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule domain_sep_inv_wp[where P="\<top>" and R="\<top>", simplified])
apply(rule retype_region_neg_cte_wp_at_not_domain_sep_inv_cap)
apply wp
done
lemma domain_sep_inv_cap_UntypedCap[simp]:
"domain_sep_inv_cap irqs (UntypedCap dev base sz n)"
apply(simp add: domain_sep_inv_cap_def)
done
crunch domain_sep_inv[wp]: invoke_untyped "domain_sep_inv irqs st"
(ignore: freeMemory retype_region wp: crunch_wps domain_sep_inv_detype_lift
get_cap_wp mapME_x_inv_wp
simp: crunch_simps mapM_x_def_bak unless_def)
lemma perform_page_invocation_domain_sep_inv_get_cap_helper:
"\<lbrace>\<top>\<rbrace>
get_cap blah
\<lbrace>\<lambda>rv s.
domain_sep_inv_cap irqs
(ArchObjectCap (F rv))\<rbrace>"
apply(simp add: domain_sep_inv_cap_def)
apply(rule wp_post_taut)
done
lemma set_object_tcb_context_update_neg_cte_wp_at:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s \<and> obj_at ((=) (TCB tcb)) ptr s\<rbrace>
set_object ptr (TCB (tcb\<lparr>tcb_arch := arch_tcb_context_set X (arch_tcb tcb)\<rparr>))
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
apply(wp set_object_wp)
apply clarsimp
apply(case_tac "ptr = fst slot")
apply(erule cte_wp_atE)
apply(fastforce simp: obj_at_def)
apply(erule notE)
apply(clarsimp simp: obj_at_def)
apply(rule cte_wp_at_tcbI)
apply(simp)
apply(fastforce)
apply(fastforce simp: tcb_cap_cases_def split: if_splits)
apply(fastforce elim: cte_wp_atE intro: cte_wp_at_cteI cte_wp_at_tcbI)
done
lemma as_user_neg_cte_wp_at[wp]:
"\<lbrace>\<lambda>s. \<not> cte_wp_at P slot s\<rbrace>
as_user t f
\<lbrace>\<lambda>_ s. \<not> cte_wp_at P slot s\<rbrace>"
unfolding as_user_def
apply(wp set_object_tcb_context_update_neg_cte_wp_at | simp add: split_def)+
apply(fastforce simp: obj_at_def)
done
crunch domain_sep_inv[wp]: as_user "domain_sep_inv irqs st"
(wp: domain_sep_inv_triv)
lemma set_object_tcb_context_update_domain_sep_inv:
"\<lbrace>\<lambda>s. domain_sep_inv irqs st s \<and> obj_at ((=) (TCB tcb)) ptr s\<rbrace>
set_object ptr (TCB (tcb\<lparr>tcb_arch := arch_tcb_context_set X (tcb_arch tcb)\<rparr>))
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule hoare_pre)
apply(rule domain_sep_inv_wp)
apply(rule hoare_pre)
apply(rule set_object_tcb_context_update_neg_cte_wp_at)
apply(fastforce)
apply(wp | simp | elim conjE | assumption)+
apply blast
done
crunch domain_sep_inv[wp]: set_mrs "domain_sep_inv irqs st"
(ignore: set_object
wp: crunch_wps set_object_tcb_context_update_domain_sep_inv
simp: crunch_simps arch_tcb_set_registers_def)
crunch domain_sep_inv[wp]: send_signal "domain_sep_inv irqs st" (wp: dxo_wp_weak ignore: possible_switch_to)
crunch domain_sep_inv[wp]: copy_mrs, set_message_info, invalidate_tlb_by_asid "domain_sep_inv irqs st"
(wp: crunch_wps)
lemma perform_page_invocation_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_page_inv pgi\<rbrace>
perform_page_invocation pgi
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule hoare_pre)
apply(wp mapM_wp[OF _ subset_refl] set_cap_domain_sep_inv
mapM_x_wp[OF _ subset_refl]
perform_page_invocation_domain_sep_inv_get_cap_helper static_imp_wp
| simp add: perform_page_invocation_def o_def | wpc)+
apply(clarsimp simp: valid_page_inv_def)
apply(case_tac xa, simp_all add: domain_sep_inv_cap_def is_pg_cap_def)
done
lemma perform_page_table_invocation_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_pti pgi\<rbrace>
perform_page_table_invocation pgi
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(rule hoare_pre)
apply(simp add: perform_page_table_invocation_def)
apply(wp crunch_wps perform_page_invocation_domain_sep_inv_get_cap_helper
set_cap_domain_sep_inv
| wpc
| simp add: o_def)+
apply(clarsimp simp: valid_pti_def)
apply(case_tac x, simp_all add: domain_sep_inv_cap_def is_pt_cap_def)
done
lemma perform_page_directory_invocation_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
perform_page_directory_invocation pti
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply (simp add: perform_page_directory_invocation_def)
apply (cases pti)
apply (simp | wp)+
done
lemma cap_insert_domain_sep_inv':
"\<lbrace> domain_sep_inv irqs st and K (domain_sep_inv_cap irqs cap) \<rbrace>
cap_insert cap slot dest_slot
\<lbrace> \<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: cap_insert_def)
apply(wp set_cap_domain_sep_inv get_cap_wp dxo_wp_weak | simp split del: if_split)+
done
lemma domain_sep_inv_cap_max_free_index_update[simp]:
"domain_sep_inv_cap irqs (max_free_index_update cap) =
domain_sep_inv_cap irqs cap"
apply(simp add: max_free_index_def free_index_update_def split: cap.splits)
done
lemma domain_sep_inv_cap_ArchObjectCap[simp]:
"domain_sep_inv_cap irqs (ArchObjectCap arch_cap)"
by(simp add: domain_sep_inv_cap_def)
lemma perform_asid_control_invocation_domain_sep_inv:
notes blah[simp del] = atLeastAtMost_iff atLeastatMost_subset_iff atLeastLessThan_iff
shows
"\<lbrace>domain_sep_inv irqs st\<rbrace>
perform_asid_control_invocation blah
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding perform_asid_control_invocation_def
apply(rule hoare_pre)
apply (wp modify_wp cap_insert_domain_sep_inv' set_cap_domain_sep_inv
get_cap_domain_sep_inv_cap[where st=st] static_imp_wp
| wpc | simp )+
done
lemma perform_asid_pool_invocation_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
perform_asid_pool_invocation blah
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: perform_asid_pool_invocation_def)
apply(rule hoare_pre)
apply(wp set_cap_domain_sep_inv get_cap_wp | wpc | simp)+
done
lemma arch_perform_invocation_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_arch_inv ai\<rbrace>
arch_perform_invocation ai
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding arch_perform_invocation_def
apply(rule hoare_pre)
apply(wp perform_page_table_invocation_domain_sep_inv
perform_page_directory_invocation_domain_sep_inv
perform_page_invocation_domain_sep_inv
perform_asid_control_invocation_domain_sep_inv
perform_asid_pool_invocation_domain_sep_inv
| wpc)+
apply(clarsimp simp: valid_arch_inv_def split: arch_invocation.splits)
done
(* when blah is AckIRQ the preconditions here contradict each other, which
is why this lemma is true *)
lemma invoke_irq_handler_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and irq_handler_inv_valid blah\<rbrace>
invoke_irq_handler blah
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(case_tac blah)
apply(wp cap_insert_domain_sep_inv' | simp)+
apply(rename_tac irq cap cslot_ptr s)
apply(case_tac cap, simp_all add: domain_sep_inv_cap_def)[1]
apply(wp | auto simp: domain_sep_inv_def)+
done
(* similarly, the preconditions here tend to contradict one another *)
lemma invoke_control_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and irq_control_inv_valid blah\<rbrace>
invoke_irq_control blah
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
including no_pre
apply (case_tac blah)
apply (case_tac irqs)
apply (wp cap_insert_domain_sep_inv' | simp )+
apply (simp add: set_irq_state_def, wp, simp)
apply (fastforce simp: domain_sep_inv_def domain_sep_inv_cap_def)
apply (fastforce simp: valid_def domain_sep_inv_def)
apply (wp | simp)+
apply (case_tac x2)
apply (simp)
apply (rule hoare_seq_ext[where B="\<lambda>_. domain_sep_inv irqs st and irq_control_inv_valid blah"])
apply simp
apply (case_tac irqs)
prefer 2
apply (fastforce simp: valid_def domain_sep_inv_def arch_irq_control_inv_valid_def)
apply (wp cap_insert_domain_sep_inv' | simp )+
apply (simp add: set_irq_state_def, wp, simp)
apply (fastforce simp: domain_sep_inv_def domain_sep_inv_cap_def)
apply wpsimp
apply (simp add: arch_irq_control_inv_valid_def)
apply (rule hoare_pre)
apply (wpsimp wp: do_machine_op_domain_sep_inv)
apply clarsimp
done
crunch domain_sep_inv[wp]: receive_signal "domain_sep_inv irqs st"
lemma domain_sep_inv_cap_ReplyCap[simp]:
"domain_sep_inv_cap irqs (ReplyCap param_a param_b param_c)"
by(simp add: domain_sep_inv_cap_def)
lemma setup_caller_cap_domain_sep_inv[wp]:
"\<lbrace>domain_sep_inv irqs st\<rbrace>
setup_caller_cap a b c
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
apply(simp add: setup_caller_cap_def split del:if_split)
apply(wp cap_insert_domain_sep_inv' | simp)+
done
crunch domain_sep_inv[wp]: set_extra_badge "domain_sep_inv irqs st"
lemma derive_cap_domain_sep_inv_cap:
"\<lbrace>\<lambda>s. domain_sep_inv_cap irqs cap\<rbrace>
derive_cap slot cap
\<lbrace>\<lambda>rv s. domain_sep_inv_cap irqs rv\<rbrace>,-"
apply(simp add: derive_cap_def)
apply(rule hoare_pre)
apply(wp | wpc | simp add: arch_derive_cap_def)+
apply auto
done
lemma transfer_caps_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_objs and valid_mdb
and (\<lambda> s. (\<forall>x\<in>set caps.
s \<turnstile> fst x) \<and>
(\<forall>x\<in>set caps.
cte_wp_at
(\<lambda>cp. fst x \<noteq> NullCap \<longrightarrow>
cp = fst x)
(snd x) s \<and>
real_cte_at (snd x) s))\<rbrace>
transfer_caps mi caps endpoint receiver receive_buffer
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding transfer_caps_def
apply (wpsimp wp: transfer_caps_loop_pres_dest cap_insert_domain_sep_inv hoare_vcg_all_lift hoare_vcg_imp_lift)
apply (fastforce elim: cte_wp_at_weakenE)
done
lemma do_normal_transfer_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_objs and valid_mdb\<rbrace>
do_normal_transfer sender send_buffer ep badge grant receiver recv_buffer
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding do_normal_transfer_def
apply (wp transfer_caps_domain_sep_inv hoare_vcg_ball_lift lec_valid_cap' | simp)+
done
crunch domain_sep_inv[wp]: do_fault_transfer "domain_sep_inv irqs st"
lemma do_ipc_transfer_domain_sep_inv:
"\<lbrace>domain_sep_inv irqs st and valid_objs and valid_mdb\<rbrace>
do_ipc_transfer sender ep badge grant receiver
\<lbrace>\<lambda>_. domain_sep_inv irqs st\<rbrace>"
unfolding do_ipc_transfer_def
apply (wp do_normal_transfer_domain_sep_inv hoare_vcg_all_lift | wpc | wp (once) hoare_drop_imps)+
apply clarsimp
done
(* FIXME: clagged from FinalCaps *)
lemma valid_ep_recv_dequeue':
"\<lbrakk> ko_at (Endpoint (Structures_A.endpoint.RecvEP (t # ts))) epptr s;
valid_objs s\<rbrakk>
\<Longrightarrow> valid_ep (case ts of [] \<Rightarrow> Structures_A.endpoint.IdleEP
| b # bs \<Rightarrow> Structures_A.endpoint.RecvEP ts) s"