-
Notifications
You must be signed in to change notification settings - Fork 0
/
Example_Valid_State.thy
1858 lines (1619 loc) · 76.6 KB
/
Example_Valid_State.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 Example_Valid_State
imports
"Noninterference"
"Lib.Distinct_Cmd"
begin
section \<open>Example\<close>
(* This example is a classic 'one way information flow'
example, where information is allowed to flow from Low to High,
but not the reverse. We consider a typical scenario where
shared memory and an notification for notifications are used to
implement a ring-buffer. We consider the NTFN to be in the domain of High,
and the shared memory to be in the domain of Low. *)
(* basic machine-level declarations that need to happen outside the locale *)
consts s0_context :: user_context
(* define the irqs to come regularly every 10 *)
axiomatization where
irq_oracle_def: "ARM.irq_oracle \<equiv> \<lambda>pos. if pos mod 10 = 0 then 10 else 0"
context begin interpretation Arch . (*FIXME: arch_split*)
subsection \<open>We show that the authority graph does not let
information flow from High to Low\<close>
datatype auth_graph_label = High | Low | IRQ0
abbreviation partition_label where
"partition_label x \<equiv> OrdinaryLabel x"
definition Sys1AuthGraph :: "(auth_graph_label subject_label) auth_graph" where
"Sys1AuthGraph \<equiv>
{ (partition_label High,Read,partition_label Low),
(partition_label Low,Notify,partition_label High),
(partition_label Low,Reset,partition_label High),
(SilcLabel,Notify,partition_label High),
(SilcLabel,Reset,partition_label High)
} \<union> {(x, a, y). x = y}"
lemma subjectReads_Low: "subjectReads Sys1AuthGraph (partition_label Low) = {partition_label Low}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectReads.induct, (fastforce simp: Sys1AuthGraph_def)+)
done
lemma Low_in_subjectReads_High:
"partition_label Low \<in> subjectReads Sys1AuthGraph (partition_label High)"
apply (simp add: Sys1AuthGraph_def reads_read)
done
lemma subjectReads_High: "subjectReads Sys1AuthGraph (partition_label High) = {partition_label High,partition_label Low}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectReads.induct, (fastforce simp: Sys1AuthGraph_def)+)
apply(auto intro: Low_in_subjectReads_High)
done
lemma subjectReads_IRQ0: "subjectReads Sys1AuthGraph (partition_label IRQ0) = {partition_label IRQ0}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectReads.induct, (fastforce simp: Sys1AuthGraph_def)+)
done
lemma High_in_subjectAffects_Low:
"partition_label High \<in> subjectAffects Sys1AuthGraph (partition_label Low)"
apply(rule affects_ep)
apply (simp add: Sys1AuthGraph_def)
apply (rule disjI1, simp+)
done
lemma subjectAffects_Low: "subjectAffects Sys1AuthGraph (partition_label Low) = {partition_label Low, partition_label High}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectAffects.induct, (fastforce simp: Sys1AuthGraph_def)+)
apply(auto intro: affects_lrefl High_in_subjectAffects_Low)
done
lemma subjectAffects_High: "subjectAffects Sys1AuthGraph (partition_label High) = {partition_label High}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectAffects.induct, (fastforce simp: Sys1AuthGraph_def)+)
apply(auto intro: affects_lrefl)
done
lemma subjectAffects_IRQ0: "subjectAffects Sys1AuthGraph (partition_label IRQ0) = {partition_label IRQ0}"
apply(rule equalityI)
apply(rule subsetI)
apply(erule subjectAffects.induct, (fastforce simp: Sys1AuthGraph_def)+)
apply(auto intro: affects_lrefl)
done
lemmas subjectReads = subjectReads_High subjectReads_Low subjectReads_IRQ0
lemma partsSubjectAffects_Low: "partsSubjectAffects Sys1AuthGraph Low = {Partition Low, Partition High}"
apply(auto simp: partsSubjectAffects_def image_def label_can_affect_partition_def subjectReads subjectAffects_Low | case_tac xa, rename_tac xa)+
done
lemma partsSubjectAffects_High: "partsSubjectAffects Sys1AuthGraph High = {Partition High}"
apply(auto simp: partsSubjectAffects_def image_def label_can_affect_partition_def subjectReads subjectAffects_High | rename_tac xa, case_tac xa)+
done
lemma partsSubjectAffects_IRQ0: "partsSubjectAffects Sys1AuthGraph IRQ0 = {Partition IRQ0}"
apply(auto simp: partsSubjectAffects_def image_def label_can_affect_partition_def subjectReads subjectAffects_IRQ0 | rename_tac xa, case_tac xa)+
done
lemmas partsSubjectAffects =
partsSubjectAffects_High partsSubjectAffects_Low partsSubjectAffects_IRQ0
definition example_policy where
"example_policy \<equiv> {(PSched, d)|d. True} \<union>
{(d,e). d = e} \<union>
{(Partition Low, Partition High)}"
lemma "policyFlows Sys1AuthGraph = example_policy"
apply(rule equalityI)
apply(rule subsetI)
apply(clarsimp simp: example_policy_def)
apply(erule policyFlows.cases)
apply(case_tac l, auto simp: partsSubjectAffects)[1]
apply assumption
apply(rule subsetI)
apply(clarsimp simp: example_policy_def)
apply(elim disjE)
apply(fastforce simp: partsSubjectAffects intro: policy_affects)
apply(fastforce intro: policy_scheduler)
apply(fastforce intro: policyFlows_refl refl_onD)
done
subsection \<open>We show there exists a valid initial state associated to the
above authority graph\<close>
text \<open>
This example (modified from ../access-control/ExampleSystem) is a system Sys1 made
of 2 main components Low and High, connected through an notification NTFN.
Both Low and High contains:
. one TCB
. one vspace made up of one page directory
. each pd contains a single page table, with access to a shared page in memory
Low can read/write to this page, High can only read
. one cspace made up of one cnode
. each cspace contains 4 caps:
one to the tcb
one to the cnode itself
one to the vspace
one to the ntfn
Low can send to the ntfn while High can receive from it.
Attempt to ASCII art:
-------- ---- ---- --------
| | | | | | | |
V | | V S R | V | V
Low_tcb(3079)-->Low_cnode(6)--->ntfn(9)<---High_cnode(7)<--High_tcb(3080)
| | | |
V | | V
Low_pd(3063)<----- -------> High_pd(3065)
| |
V R/W R V
Low_pt(3072)---------------->shared_page<-----------------High_pt(3077)
(the references are derived from the dump of the SAC system)
The aim is to be able to prove
valid_initial_state s0_internal Sys1PAS timer_irq utf
where Sys1PAS is the label graph defining the AC policy for Sys1 using
the authority graph defined above and s0 is the state of Sys1 described above.
\<close>
subsubsection \<open>Defining the State\<close>
definition "ntfn_ptr \<equiv> kernel_base + 0x10"
definition "Low_tcb_ptr \<equiv> kernel_base + 0x200"
definition "High_tcb_ptr = kernel_base + 0x400"
definition "idle_tcb_ptr = kernel_base + 0x1000"
definition "Low_pt_ptr = kernel_base + 0x800"
definition "High_pt_ptr = kernel_base + 0xC00"
(* init_globals_frame \<equiv> {kernel_base + 0x5000,... kernel_base + 0x5FFF} *)
definition "shared_page_ptr = kernel_base + 0x6000"
definition "Low_pd_ptr = kernel_base + 0x20000"
definition "High_pd_ptr = kernel_base + 0x24000"
definition "Low_cnode_ptr = kernel_base + 0x10000"
definition "High_cnode_ptr = kernel_base + 0x14000"
definition "Silc_cnode_ptr = kernel_base + 0x18000"
definition "irq_cnode_ptr = kernel_base + 0x1C000"
(* init_global_pd \<equiv> {kernel_base + 0x60000,... kernel_base + 0x603555} *)
definition "timer_irq \<equiv> 10" (* not sure exactly how this fits in *)
definition "Low_mcp \<equiv> 5 :: word8"
definition "Low_prio \<equiv> 5 :: word8"
definition "High_mcp \<equiv> 5 :: word8"
definition "High_prio \<equiv> 5 :: word8"
definition "Low_time_slice \<equiv> 0 :: nat"
definition "High_time_slice \<equiv> 5 :: nat"
definition "Low_domain \<equiv> 0 :: word8"
definition "High_domain \<equiv> 1 :: word8"
lemmas s0_ptr_defs =
Low_cnode_ptr_def High_cnode_ptr_def Silc_cnode_ptr_def ntfn_ptr_def irq_cnode_ptr_def
Low_pd_ptr_def High_pd_ptr_def Low_pt_ptr_def High_pt_ptr_def Low_tcb_ptr_def
High_tcb_ptr_def idle_tcb_ptr_def timer_irq_def Low_prio_def High_prio_def Low_time_slice_def
Low_domain_def High_domain_def init_irq_node_ptr_def init_globals_frame_def init_global_pd_def
kernel_base_def shared_page_ptr_def
(* Distinctness proof of kernel pointers. *)
distinct ptrs_distinct [simp]:
Low_tcb_ptr High_tcb_ptr idle_tcb_ptr
Low_pt_ptr High_pt_ptr
shared_page_ptr ntfn_ptr
Low_pd_ptr High_pd_ptr
Low_cnode_ptr High_cnode_ptr Silc_cnode_ptr irq_cnode_ptr
init_globals_frame init_global_pd
by (auto simp: s0_ptr_defs)
text \<open>We need to define the asids of each pd and pt to ensure that
the object is included in the right ASID-label\<close>
text \<open>Low's ASID\<close>
definition
Low_asid :: machine_word
where
"Low_asid \<equiv> 1<<asid_low_bits"
text \<open>High's ASID\<close>
definition
High_asid :: machine_word
where
"High_asid \<equiv> 2<<asid_low_bits"
lemma "asid_high_bits_of High_asid \<noteq> asid_high_bits_of Low_asid"
by (simp add: Low_asid_def asid_high_bits_of_def High_asid_def asid_low_bits_def)
text \<open>converting a nat to a bool list of size 10 - for the cnodes\<close>
definition
nat_to_bl :: "nat \<Rightarrow> nat \<Rightarrow> bool list option"
where
"nat_to_bl bits n \<equiv>
if n \<ge> 2^bits then
None
else
Some $ bin_to_bl bits (of_nat n)"
lemma nat_to_bl_id [simp]: "nat_to_bl (size (x :: (('a::len) word))) (unat x) = Some (to_bl x)"
apply (clarsimp simp: nat_to_bl_def to_bl_def)
apply (auto simp: uint_nat le_def word_size)
done
definition
the_nat_to_bl :: "nat \<Rightarrow> nat \<Rightarrow> bool list"
where
"the_nat_to_bl sz n \<equiv>
the (nat_to_bl sz (n mod 2^sz))"
abbreviation (input)
the_nat_to_bl_10 :: "nat \<Rightarrow> bool list"
where
"the_nat_to_bl_10 n \<equiv> the_nat_to_bl 10 n"
lemma len_the_nat_to_bl [simp]:
"length (the_nat_to_bl x y) = x"
apply (clarsimp simp: the_nat_to_bl_def nat_to_bl_def)
apply safe
apply (metis le_def mod_less_divisor nat_zero_less_power_iff zero_less_numeral)
apply (clarsimp simp: len_bin_to_bl_aux not_le)
done
lemma tcb_cnode_index_nat_to_bl [simp]:
"the_nat_to_bl_10 n \<noteq> tcb_cnode_index n"
by (clarsimp simp: tcb_cnode_index_def intro!: length_neq)
lemma mod_less_self [simp]:
"a \<le> b mod a \<longleftrightarrow> ((a :: nat) = 0)"
by (metis mod_less_divisor nat_neq_iff not_less not_less0)
lemma split_div_mod:
"a = (b::nat) \<longleftrightarrow> (a div k = b div k \<and> a mod k = b mod k)"
by (metis mult_div_mod_eq)
lemma nat_to_bl_eq:
assumes "a < 2 ^ n \<or> b < 2 ^ n"
shows "nat_to_bl n a = nat_to_bl n b \<longleftrightarrow> a = b"
using assms
apply -
apply (erule disjE_R)
apply (clarsimp simp: nat_to_bl_def)
apply (case_tac "a \<ge> 2 ^ n")
apply (clarsimp simp: nat_to_bl_def)
apply (clarsimp simp: not_le)
apply (induct n arbitrary: a b)
apply (clarsimp simp: nat_to_bl_def)
apply atomize
apply (clarsimp simp: nat_to_bl_def)
apply (erule_tac x="a div 2" in allE)
apply (erule_tac x="b div 2" in allE)
apply (erule impE)
apply (metis power_commutes td_gal_lt zero_less_numeral)
apply (clarsimp simp: bin_rest_def bin_last_def zdiv_int)
apply (rule iffI [rotated], clarsimp)
apply (subst (asm) (1 2 3 4) bin_to_bl_aux_alt)
apply (clarsimp simp: mod_eq_dvd_iff)
apply (subst split_div_mod [where k=2])
apply clarsimp
apply (metis of_nat_numeral not_mod_2_eq_0_eq_1 of_nat_1 of_nat_eq_iff zmod_int)
done
lemma nat_to_bl_mod_n_eq [simp]:
"nat_to_bl n a = nat_to_bl n b \<longleftrightarrow> ((a = b \<and> a < 2 ^ n) \<or> (a \<ge> 2 ^ n \<and> b \<ge> 2 ^ n))"
apply (rule iffI)
apply (clarsimp simp: not_le)
apply (subst (asm) nat_to_bl_eq, simp)
apply clarsimp
apply (erule disjE)
apply clarsimp
apply (clarsimp simp: nat_to_bl_def)
done
lemma the_the_eq:
"\<lbrakk> x \<noteq> None; y \<noteq> None \<rbrakk> \<Longrightarrow> (the x = the y) = (x = y)"
by auto
lemma the_nat_to_bl_eq [simp]:
"(the_nat_to_bl n a = the_nat_to_bl m b) \<longleftrightarrow> (n = m \<and> (a mod 2 ^ n = b mod 2 ^ n))"
apply (case_tac "n = m")
apply (clarsimp simp: the_nat_to_bl_def)
apply (subst the_the_eq)
apply (clarsimp simp: nat_to_bl_def)
apply (clarsimp simp: nat_to_bl_def)
apply simp
apply simp
apply (metis len_the_nat_to_bl)
done
lemma empty_cnode_eq_Some [simp]:
"(empty_cnode n x = Some y) = (length x = n \<and> y = NullCap)"
by (clarsimp simp: empty_cnode_def, metis)
lemma empty_cnode_eq_None [simp]:
"(empty_cnode n x = None) = (length x \<noteq> n)"
by (clarsimp simp: empty_cnode_def)
text \<open>Low's CSpace\<close>
definition
Low_caps :: cnode_contents
where
"Low_caps \<equiv>
(empty_cnode 10)
( (the_nat_to_bl_10 1)
\<mapsto> ThreadCap Low_tcb_ptr,
(the_nat_to_bl_10 2)
\<mapsto> CNodeCap Low_cnode_ptr 10 (the_nat_to_bl_10 2),
(the_nat_to_bl_10 3)
\<mapsto> ArchObjectCap (PageDirectoryCap Low_pd_ptr
(Some Low_asid)),
(the_nat_to_bl_10 318)
\<mapsto> NotificationCap ntfn_ptr 0 {AllowSend} )"
definition
Low_cnode :: kernel_object
where
"Low_cnode \<equiv> CNode 10 Low_caps"
lemma ran_empty_cnode [simp]:
"ran (empty_cnode C) = {NullCap}"
by (auto simp: empty_cnode_def ran_def Ex_list_of_length intro: set_eqI)
lemma empty_cnode_app [simp]:
"length x = n \<Longrightarrow> empty_cnode n x = Some NullCap"
by (auto simp: empty_cnode_def)
lemma in_ran_If [simp]:
"(x \<in> ran (\<lambda>n. if P n then A n else B n))
\<longleftrightarrow> (\<exists>n. P n \<and> A n = Some x) \<or> (\<exists>n. \<not> P n \<and> B n = Some x)"
by (auto simp: ran_def)
lemma Low_caps_ran:
"ran Low_caps = {ThreadCap Low_tcb_ptr,
CNodeCap Low_cnode_ptr 10 (the_nat_to_bl_10 2),
ArchObjectCap (PageDirectoryCap Low_pd_ptr
(Some Low_asid)),
NotificationCap ntfn_ptr 0 {AllowSend},
NullCap}"
apply (rule equalityI)
apply (clarsimp simp: Low_caps_def fun_upd_def empty_cnode_def split: if_split_asm)
apply (clarsimp simp: Low_caps_def fun_upd_def empty_cnode_def split: if_split_asm
cong: conj_cong)
apply (rule exI [where x="the_nat_to_bl_10 0"])
apply simp
done
text \<open>High's Cspace\<close>
definition
High_caps :: cnode_contents
where
"High_caps \<equiv>
(empty_cnode 10)
( (the_nat_to_bl_10 1)
\<mapsto> ThreadCap High_tcb_ptr,
(the_nat_to_bl_10 2)
\<mapsto> CNodeCap High_cnode_ptr 10 (the_nat_to_bl_10 2),
(the_nat_to_bl_10 3)
\<mapsto> ArchObjectCap (PageDirectoryCap High_pd_ptr
(Some High_asid)),
(the_nat_to_bl_10 318)
\<mapsto> NotificationCap ntfn_ptr 0 {AllowRecv}) "
definition
High_cnode :: kernel_object
where
"High_cnode \<equiv> CNode 10 High_caps"
lemma High_caps_ran:
"ran High_caps = {ThreadCap High_tcb_ptr,
CNodeCap High_cnode_ptr 10 (the_nat_to_bl_10 2),
ArchObjectCap (PageDirectoryCap High_pd_ptr
(Some High_asid)),
NotificationCap ntfn_ptr 0 {AllowRecv},
NullCap}"
apply (rule equalityI)
apply (clarsimp simp: High_caps_def ran_def empty_cnode_def split: if_split_asm)
apply (clarsimp simp: High_caps_def ran_def empty_cnode_def split: if_split_asm
cong: conj_cong)
apply (rule exI [where x="the_nat_to_bl_10 0"])
apply simp
done
text \<open>We need a copy of boundary crossing caps owned by SilcLabel.
The only such cap is Low's cap to the notification\<close>
definition
Silc_caps :: cnode_contents
where
"Silc_caps \<equiv>
(empty_cnode 10)
( (the_nat_to_bl_10 2)
\<mapsto> CNodeCap Silc_cnode_ptr 10 (the_nat_to_bl_10 2),
(the_nat_to_bl_10 318)
\<mapsto> NotificationCap ntfn_ptr 0 {AllowSend} )"
definition
Silc_cnode :: kernel_object
where
"Silc_cnode \<equiv> CNode 10 Silc_caps"
lemma Silc_caps_ran:
"ran Silc_caps = {CNodeCap Silc_cnode_ptr 10 (the_nat_to_bl_10 2),
NotificationCap ntfn_ptr 0 {AllowSend},
NullCap}"
apply (rule equalityI)
apply (clarsimp simp: Silc_caps_def ran_def empty_cnode_def)
apply (clarsimp simp: ran_def Silc_caps_def empty_cnode_def cong: conj_cong)
apply (rule_tac x="the_nat_to_bl_10 0" in exI)
apply simp
done
text \<open>notification between Low and High\<close>
definition
ntfn :: kernel_object
where
"ntfn \<equiv> Notification \<lparr>ntfn_obj = WaitingNtfn [High_tcb_ptr], ntfn_bound_tcb=None\<rparr>"
text \<open>Low's VSpace (PageDirectory)\<close>
definition
Low_pt' :: "word8 \<Rightarrow> pte "
where
"Low_pt' \<equiv> (\<lambda>_. InvalidPTE)
(0 := SmallPagePTE shared_page_ptr {} vm_read_write)"
definition
Low_pt :: kernel_object
where
"Low_pt \<equiv> ArchObj (PageTable Low_pt')"
definition
Low_pd' :: "12 word \<Rightarrow> pde "
where
"Low_pd' \<equiv>
global_pd
(0 := PageTablePDE
(addrFromPPtr Low_pt_ptr)
{}
undefined )"
(* used addrFromPPtr because proof gives me ptrFromAddr.. TODO: check
if it's right *)
definition
Low_pd :: kernel_object
where
"Low_pd \<equiv> ArchObj (PageDirectory Low_pd')"
text \<open>High's VSpace (PageDirectory)\<close>
definition
High_pt' :: "word8 \<Rightarrow> pte "
where
"High_pt' \<equiv>
(\<lambda>_. InvalidPTE)
(0 := SmallPagePTE shared_page_ptr {} vm_read_only)"
definition
High_pt :: kernel_object
where
"High_pt \<equiv> ArchObj (PageTable High_pt')"
definition
High_pd' :: "12 word \<Rightarrow> pde "
where
"High_pd' \<equiv>
global_pd
(0 := PageTablePDE
(addrFromPPtr High_pt_ptr)
{}
undefined )"
(* used addrFromPPtr because proof gives me ptrFromAddr.. TODO: check
if it's right *)
definition
High_pd :: kernel_object
where
"High_pd \<equiv> ArchObj (PageDirectory High_pd')"
text \<open>Low's tcb\<close>
definition
Low_tcb :: kernel_object
where
"Low_tcb \<equiv>
TCB \<lparr>
tcb_ctable = CNodeCap Low_cnode_ptr 10 (the_nat_to_bl_10 2),
tcb_vtable = ArchObjectCap
(PageDirectoryCap Low_pd_ptr (Some Low_asid)),
tcb_reply = ReplyCap Low_tcb_ptr True {AllowGrant, AllowWrite}, \<comment> \<open>master reply cap\<close>
tcb_caller = NullCap,
tcb_ipcframe = NullCap,
tcb_state = Running,
tcb_fault_handler = replicate word_bits False,
tcb_ipc_buffer = 0,
tcb_fault = None,
tcb_bound_notification = None,
tcb_mcpriority = Low_mcp,
tcb_arch = \<lparr> tcb_context = undefined \<rparr>\<rparr>"
definition
Low_etcb :: etcb
where
"Low_etcb \<equiv> \<lparr>tcb_priority = Low_prio,
tcb_time_slice = Low_time_slice,
tcb_domain = Low_domain\<rparr>"
text \<open>High's tcb\<close>
definition
High_tcb :: kernel_object
where
"High_tcb \<equiv>
TCB \<lparr>
tcb_ctable = CNodeCap High_cnode_ptr 10 (the_nat_to_bl_10 2) ,
tcb_vtable = ArchObjectCap
(PageDirectoryCap High_pd_ptr (Some High_asid)),
tcb_reply = ReplyCap High_tcb_ptr True {AllowGrant,AllowWrite}, \<comment> \<open>master reply cap to itself\<close>
tcb_caller = NullCap,
tcb_ipcframe = NullCap,
tcb_state = BlockedOnNotification ntfn_ptr,
tcb_fault_handler = replicate word_bits False,
tcb_ipc_buffer = 0,
tcb_fault = None,
tcb_bound_notification = None,
tcb_mcpriority = High_mcp,
tcb_arch = \<lparr> tcb_context = undefined \<rparr>\<rparr>"
definition
High_etcb :: etcb
where
"High_etcb \<equiv> \<lparr>tcb_priority = High_prio,
tcb_time_slice = High_time_slice,
tcb_domain = High_domain\<rparr>"
text \<open>idle's tcb\<close>
definition
idle_tcb :: kernel_object
where
"idle_tcb \<equiv>
TCB \<lparr>
tcb_ctable = NullCap,
tcb_vtable = NullCap,
tcb_reply = NullCap,
tcb_caller = NullCap,
tcb_ipcframe = NullCap,
tcb_state = IdleThreadState,
tcb_fault_handler = replicate word_bits False,
tcb_ipc_buffer = 0,
tcb_fault = None,
tcb_bound_notification = None,
tcb_mcpriority = default_priority,
tcb_arch = \<lparr> tcb_context = empty_context \<rparr>\<rparr>"
definition
"irq_cnode \<equiv> CNode 0 (Map.empty([] \<mapsto> cap.NullCap))"
definition
kh0 :: kheap
where
"kh0 \<equiv> (\<lambda>x. if \<exists>irq::10 word. init_irq_node_ptr + (ucast irq << cte_level_bits) = x
then Some (CNode 0 (empty_cnode 0)) else None)
(Low_cnode_ptr \<mapsto> Low_cnode,
High_cnode_ptr \<mapsto> High_cnode,
Silc_cnode_ptr \<mapsto> Silc_cnode,
ntfn_ptr \<mapsto> ntfn,
irq_cnode_ptr \<mapsto> irq_cnode,
Low_pd_ptr \<mapsto> Low_pd,
High_pd_ptr \<mapsto> High_pd,
Low_pt_ptr \<mapsto> Low_pt,
High_pt_ptr \<mapsto> High_pt,
Low_tcb_ptr \<mapsto> Low_tcb,
High_tcb_ptr \<mapsto> High_tcb,
idle_tcb_ptr \<mapsto> idle_tcb,
init_globals_frame \<mapsto> ArchObj (DataPage False ARMSmallPage),
init_global_pd \<mapsto> ArchObj (PageDirectory global_pd))"
lemma irq_node_offs_min:
"init_irq_node_ptr \<le> init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits)"
apply (rule_tac sz=28 in machine_word_plus_mono_right_split)
apply (simp add: unat_word_ariths mask_def shiftl_t2n s0_ptr_defs cte_level_bits_def)
apply (cut_tac x=irq and 'a=32 in ucast_less)
apply simp
apply (simp add: word_less_nat_alt)
apply (simp add: word_bits_def)
done
lemma irq_node_offs_max:
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) < init_irq_node_ptr + 0x4000"
apply (simp add: s0_ptr_defs cte_level_bits_def shiftl_t2n)
apply (cut_tac x=irq and 'a=32 in ucast_less)
apply simp
apply (simp add: word_less_nat_alt unat_word_ariths)
done
definition irq_node_offs_range where
"irq_node_offs_range \<equiv> {x. init_irq_node_ptr \<le> x \<and> x < init_irq_node_ptr + 0x4000}
\<inter> {x. is_aligned x cte_level_bits}"
lemma irq_node_offs_in_range:
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits)
\<in> irq_node_offs_range"
apply (clarsimp simp: irq_node_offs_min irq_node_offs_max irq_node_offs_range_def)
apply (rule is_aligned_add[OF _ is_aligned_shift])
apply (simp add: is_aligned_def s0_ptr_defs cte_level_bits_def)
done
lemma irq_node_offs_range_correct:
"x \<in> irq_node_offs_range
\<Longrightarrow> \<exists>irq. x = init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits)"
apply (clarsimp simp: irq_node_offs_min irq_node_offs_max irq_node_offs_range_def
s0_ptr_defs cte_level_bits_def)
apply (rule_tac x="ucast ((x - 0xE0008000) >> 4)" in exI)
apply (clarsimp simp: ucast_ucast_mask)
apply (subst aligned_shiftr_mask_shiftl)
apply (rule aligned_sub_aligned)
apply assumption
apply (simp add: is_aligned_def)
apply simp
apply simp
apply (rule_tac n=14 in mask_eqI)
apply (subst mask_add_aligned)
apply (simp add: is_aligned_def)
apply (simp add: mask_twice)
apply (simp add: diff_conv_add_uminus del: add_uminus_conv_diff)
apply (subst add.commute[symmetric])
apply (subst mask_add_aligned)
apply (simp add: is_aligned_def)
apply simp
apply (simp add: diff_conv_add_uminus del: add_uminus_conv_diff)
apply (subst add_mask_lower_bits)
apply (simp add: is_aligned_def)
apply clarsimp
apply (cut_tac x=x and y="0xE000BFFF" and n=14 in neg_mask_mono_le)
apply (force dest: word_less_sub_1)
apply (drule_tac n=14 in aligned_le_sharp)
apply (simp add: is_aligned_def)
apply (simp add: mask_def)
done
lemma irq_node_offs_range_distinct[simp]:
"Low_cnode_ptr \<notin> irq_node_offs_range"
"High_cnode_ptr \<notin> irq_node_offs_range"
"Silc_cnode_ptr \<notin> irq_node_offs_range"
"ntfn_ptr \<notin> irq_node_offs_range"
"irq_cnode_ptr \<notin> irq_node_offs_range"
"Low_pd_ptr \<notin> irq_node_offs_range"
"High_pd_ptr \<notin> irq_node_offs_range"
"Low_pt_ptr \<notin> irq_node_offs_range"
"High_pt_ptr \<notin> irq_node_offs_range"
"Low_tcb_ptr \<notin> irq_node_offs_range"
"High_tcb_ptr \<notin> irq_node_offs_range"
"idle_tcb_ptr \<notin> irq_node_offs_range"
"init_globals_frame \<notin> irq_node_offs_range"
"init_global_pd \<notin> irq_node_offs_range"
by(simp add:irq_node_offs_range_def s0_ptr_defs)+
lemma irq_node_offs_distinct[simp]:
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> Low_cnode_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> High_cnode_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> Silc_cnode_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> ntfn_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> irq_cnode_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> Low_pd_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> High_pd_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> Low_pt_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> High_pt_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> Low_tcb_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> High_tcb_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> idle_tcb_ptr"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> init_globals_frame"
"init_irq_node_ptr + (ucast (irq:: 10 word) << cte_level_bits) \<noteq> init_global_pd"
by (simp add:not_inD[symmetric, OF _ irq_node_offs_in_range])+
lemma kh0_dom:
"dom kh0 = {init_globals_frame, init_global_pd, idle_tcb_ptr, High_tcb_ptr, Low_tcb_ptr,
High_pt_ptr, Low_pt_ptr, High_pd_ptr, Low_pd_ptr, irq_cnode_ptr, ntfn_ptr,
Silc_cnode_ptr, High_cnode_ptr, Low_cnode_ptr} \<union>
irq_node_offs_range"
apply (rule equalityI)
apply (simp add: kh0_def dom_def)
apply (clarsimp simp: irq_node_offs_in_range)
apply (clarsimp simp: dom_def)
apply (rule conjI, clarsimp simp: kh0_def)+
apply (force simp: kh0_def cte_level_bits_def dest: irq_node_offs_range_correct)
done
lemmas kh0_SomeD' = set_mp[OF equalityD1[OF kh0_dom[simplified dom_def]], OF CollectI, simplified, OF exI]
lemma kh0_SomeD:
"kh0 x = Some y \<Longrightarrow>
x = init_globals_frame \<and> y = ArchObj (DataPage False ARMSmallPage) \<or>
x = init_global_pd \<and> y = ArchObj (PageDirectory global_pd) \<or>
x = idle_tcb_ptr \<and> y = idle_tcb \<or>
x = High_tcb_ptr \<and> y = High_tcb \<or>
x = Low_tcb_ptr \<and> y = Low_tcb \<or>
x = High_pt_ptr \<and> y = High_pt \<or>
x = Low_pt_ptr \<and> y = Low_pt \<or>
x = High_pd_ptr \<and> y = High_pd \<or>
x = Low_pd_ptr \<and> y = Low_pd \<or>
x = irq_cnode_ptr \<and> y = irq_cnode \<or>
x = ntfn_ptr \<and> y = ntfn \<or>
x = Silc_cnode_ptr \<and> y = Silc_cnode \<or>
x = High_cnode_ptr \<and> y = High_cnode \<or>
x = Low_cnode_ptr \<and> y = Low_cnode \<or>
x \<in> irq_node_offs_range \<and> y = CNode 0 (empty_cnode 0)"
apply (frule kh0_SomeD')
apply (erule disjE, simp add: kh0_def
| force simp: kh0_def split: if_split_asm)+
done
lemmas kh0_obj_def =
Low_cnode_def High_cnode_def Silc_cnode_def ntfn_def irq_cnode_def Low_pd_def
High_pd_def Low_pt_def High_pt_def Low_tcb_def High_tcb_def idle_tcb_def
definition exst0 :: "det_ext" where
"exst0 \<equiv> \<lparr>work_units_completed_internal = undefined,
scheduler_action_internal = resume_cur_thread,
ekheap_internal = [Low_tcb_ptr \<mapsto> Low_etcb,
High_tcb_ptr \<mapsto> High_etcb,
idle_tcb_ptr \<mapsto> default_etcb],
domain_list_internal = [(0, 10), (1, 10)],
domain_index_internal = 0,
cur_domain_internal = 0,
domain_time_internal = 5,
ready_queues_internal = (const (const [])),
cdt_list_internal = const []\<rparr>"
lemmas ekh0_obj_def =
Low_etcb_def High_etcb_def default_etcb_def
definition machine_state0 :: "machine_state" where
"machine_state0 \<equiv> \<lparr>irq_masks = (\<lambda>irq. if irq = timer_irq then False else True),
irq_state = 0,
underlying_memory = const 0,
device_state = Map.empty,
exclusive_state = undefined,
machine_state_rest = undefined \<rparr>"
definition arch_state0 :: "arch_state" where
"arch_state0 \<equiv> \<lparr>arm_asid_table = Map.empty,
arm_hwasid_table = Map.empty, arm_next_asid = 0, arm_asid_map = Map.empty,
arm_global_pd = init_global_pd, arm_global_pts = [],
arm_kernel_vspace =
\<lambda>ref. if ref \<in> {kernel_base..kernel_base + mask 20} then ArmVSpaceKernelWindow
else ArmVSpaceInvalidRegion\<rparr>"
definition
s0_internal :: "det_ext state"
where
"s0_internal \<equiv> \<lparr>
kheap = kh0,
cdt = Map.empty,
is_original_cap = (\<lambda>_. False) ((Low_tcb_ptr, tcb_cnode_index 2) := True,
(High_tcb_ptr, tcb_cnode_index 2) := True),
cur_thread = Low_tcb_ptr,
idle_thread = idle_tcb_ptr,
machine_state = machine_state0,
interrupt_irq_node = (\<lambda>irq. init_irq_node_ptr + (ucast irq << cte_level_bits)),
interrupt_states = (\<lambda>_. irq_state.IRQInactive) (timer_irq := irq_state.IRQTimer),
arch_state = arch_state0,
exst = exst0
\<rparr>"
subsubsection \<open>Defining the policy graph\<close>
(* FIXME: should incorporate SharedPage above *)
(* There is an NTFN in the High label, a SharedPage in the Low label *)
definition
Sys1AgentMap :: "(auth_graph_label subject_label) agent_map"
where
"Sys1AgentMap \<equiv>
(\<lambda>p. if ptrFromPAddr shared_page_ptr \<le> p \<and> p < ptrFromPAddr shared_page_ptr + 0x1000
then partition_label Low else partition_label IRQ0)
\<comment> \<open>set the range of the shared_page to Low, default everything else to IRQ0\<close>
(Low_cnode_ptr := partition_label Low,
High_cnode_ptr := partition_label High,
ntfn_ptr := partition_label High,
irq_cnode_ptr := partition_label IRQ0,
Silc_cnode_ptr := SilcLabel,
Low_pd_ptr := partition_label Low,
High_pd_ptr := partition_label High,
Low_pt_ptr := partition_label Low,
High_pt_ptr := partition_label High,
Low_tcb_ptr := partition_label Low,
High_tcb_ptr := partition_label High,
idle_tcb_ptr := partition_label Low)"
lemma Sys1AgentMap_simps:
"Sys1AgentMap Low_cnode_ptr = partition_label Low"
"Sys1AgentMap High_cnode_ptr = partition_label High"
"Sys1AgentMap ntfn_ptr = partition_label High"
"Sys1AgentMap irq_cnode_ptr = partition_label IRQ0"
"Sys1AgentMap Silc_cnode_ptr = SilcLabel"
"Sys1AgentMap Low_pd_ptr = partition_label Low"
"Sys1AgentMap High_pd_ptr = partition_label High"
"Sys1AgentMap Low_pt_ptr = partition_label Low"
"Sys1AgentMap High_pt_ptr = partition_label High"
"Sys1AgentMap Low_tcb_ptr = partition_label Low"
"Sys1AgentMap High_tcb_ptr = partition_label High"
"Sys1AgentMap idle_tcb_ptr = partition_label Low"
"\<And>p. \<lbrakk>ptrFromPAddr shared_page_ptr \<le> p; p < ptrFromPAddr shared_page_ptr + 0x1000\<rbrakk>
\<Longrightarrow> Sys1AgentMap p = partition_label Low"
unfolding Sys1AgentMap_def
apply simp_all
by (auto simp: ptrFromPAddr_def physMappingOffset_def
kernelBase_addr_def physBase_def s0_ptr_defs)
definition
Sys1ASIDMap :: "(auth_graph_label subject_label) agent_asid_map"
where
"Sys1ASIDMap \<equiv>
(\<lambda>x. if (asid_high_bits_of x = asid_high_bits_of Low_asid)
then partition_label Low
else if (asid_high_bits_of x = asid_high_bits_of High_asid)
then partition_label High else undefined)"
(* We include 2 domains, Low is associated to domain 0, High to domain 1, we default the rest of the possible domains to High *)
definition Sys1PAS :: "(auth_graph_label subject_label) PAS" where
"Sys1PAS \<equiv> \<lparr>
pasObjectAbs = Sys1AgentMap,
pasASIDAbs = Sys1ASIDMap,
pasIRQAbs = (\<lambda>_. partition_label IRQ0),
pasPolicy = Sys1AuthGraph,
pasSubject = partition_label Low,
pasMayActivate = True,
pasMayEditReadyQueues = True, pasMaySendIrqs = False,
pasDomainAbs = ((\<lambda>_. {partition_label High})(0 := {partition_label Low}))
\<rparr>"
subsubsection \<open>Proof of pas_refined for Sys1\<close>
lemma High_caps_well_formed: "well_formed_cnode_n 10 High_caps"
by (auto simp: High_caps_def well_formed_cnode_n_def split: if_split_asm)
lemma Low_caps_well_formed: "well_formed_cnode_n 10 Low_caps"
by (auto simp: Low_caps_def well_formed_cnode_n_def split: if_split_asm)
lemma Silc_caps_well_formed: "well_formed_cnode_n 10 Silc_caps"
by (auto simp: Silc_caps_def well_formed_cnode_n_def split: if_split_asm)
lemma s0_caps_of_state :
"caps_of_state s0_internal p = Some cap \<Longrightarrow>
cap = NullCap \<or>
(p,cap) \<in>
{ ((Low_cnode_ptr::obj_ref,(the_nat_to_bl_10 1)), ThreadCap Low_tcb_ptr),
((Low_cnode_ptr::obj_ref,(the_nat_to_bl_10 2)), CNodeCap Low_cnode_ptr 10 (the_nat_to_bl_10 2)),
((Low_cnode_ptr::obj_ref,(the_nat_to_bl_10 3)), ArchObjectCap (PageDirectoryCap Low_pd_ptr (Some Low_asid))),
((Low_cnode_ptr::obj_ref,(the_nat_to_bl_10 318)),NotificationCap ntfn_ptr 0 {AllowSend}),
((High_cnode_ptr::obj_ref,(the_nat_to_bl_10 1)), ThreadCap High_tcb_ptr),
((High_cnode_ptr::obj_ref,(the_nat_to_bl_10 2)), CNodeCap High_cnode_ptr 10 (the_nat_to_bl_10 2)),
((High_cnode_ptr::obj_ref,(the_nat_to_bl_10 3)), ArchObjectCap (PageDirectoryCap High_pd_ptr (Some High_asid))),
((High_cnode_ptr::obj_ref,(the_nat_to_bl_10 318)),NotificationCap ntfn_ptr 0 {AllowRecv}) ,
((Silc_cnode_ptr::obj_ref,(the_nat_to_bl_10 2)),CNodeCap Silc_cnode_ptr 10 (the_nat_to_bl_10 2)),
((Silc_cnode_ptr::obj_ref,(the_nat_to_bl_10 318)),NotificationCap ntfn_ptr 0 {AllowSend}),
((Low_tcb_ptr::obj_ref, (tcb_cnode_index 0)), CNodeCap Low_cnode_ptr 10 (the_nat_to_bl_10 2)),
((Low_tcb_ptr::obj_ref, (tcb_cnode_index 1)), ArchObjectCap (PageDirectoryCap Low_pd_ptr (Some Low_asid))),
((Low_tcb_ptr::obj_ref, (tcb_cnode_index 2)), ReplyCap Low_tcb_ptr True {AllowGrant, AllowWrite}),
((Low_tcb_ptr::obj_ref, (tcb_cnode_index 3)), NullCap),
((Low_tcb_ptr::obj_ref, (tcb_cnode_index 4)), NullCap),
((High_tcb_ptr::obj_ref, (tcb_cnode_index 0)), CNodeCap High_cnode_ptr 10 (the_nat_to_bl_10 2)),
((High_tcb_ptr::obj_ref, (tcb_cnode_index 1)), ArchObjectCap (PageDirectoryCap High_pd_ptr (Some High_asid))),
((High_tcb_ptr::obj_ref, (tcb_cnode_index 2)), ReplyCap High_tcb_ptr True {AllowGrant, AllowWrite}),
((High_tcb_ptr::obj_ref, (tcb_cnode_index 3)), NullCap),
((High_tcb_ptr::obj_ref, (tcb_cnode_index 4)), NullCap)} "
supply if_cong[cong]
apply (insert High_caps_well_formed)
apply (insert Low_caps_well_formed)
apply (insert Silc_caps_well_formed)
apply (simp add: caps_of_state_cte_wp_at cte_wp_at_cases s0_internal_def kh0_def kh0_obj_def)
apply (case_tac p, clarsimp)
apply (clarsimp split: if_splits)
apply (clarsimp simp: cte_wp_at_cases tcb_cap_cases_def
split: if_split_asm)+
apply (clarsimp simp: Silc_caps_def split: if_splits)
apply (clarsimp simp: High_caps_def split: if_splits)
apply (clarsimp simp: Low_caps_def cte_wp_at_cases split: if_splits)
done
lemma tcb_states_of_state_s0:
"tcb_states_of_state s0_internal = [High_tcb_ptr \<mapsto> thread_state.BlockedOnNotification ntfn_ptr, Low_tcb_ptr \<mapsto> thread_state.Running, idle_tcb_ptr \<mapsto> thread_state.IdleThreadState ]"
unfolding s0_internal_def tcb_states_of_state_def
apply (rule ext)
apply (simp add: get_tcb_def)
apply (simp add: kh0_def kh0_obj_def)
done
lemma thread_bounds_of_state_s0:
"thread_bound_ntfns s0_internal = Map.empty"
unfolding s0_internal_def thread_bound_ntfns_def
apply (rule ext)
apply (simp add: get_tcb_def)
apply (simp add: kh0_def kh0_obj_def)
done