-
Notifications
You must be signed in to change notification settings - Fork 1
/
AsmProof.v
478 lines (462 loc) · 26.4 KB
/
AsmProof.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
Require Import Coqlib.
Require Import AST.
Require Import Integers.
Require Import Smallstep.
Require Import Events.
Require Import Globalenvs.
Require Import Memory.
Require Import Values.
Require Import Constants.
Require Import RData.
Require Import Asm.
Require Import AsmCode.
Require Import CommonLib.
Require Import RefTactics.
Require Import Assembly.Asm.
Require Import Assembly.AsmCode.
Require Import Assembly.AsmSpec.
Require Import RefTactics.
Variable ge: genv.
Inductive StarStep: RData -> RData -> Prop :=
| NoStep: forall d, StarStep d d
| OneStep:
forall d d' d'',
step ge d d' -> StarStep d' d'' -> StarStep d d''.
Ltac asm_one_internal_step Hf :=
eapply OneStep; [
eapply exec_step_internal; repeat autounfold;
[simpl; grewrite; reflexivity | eapply Hf | reflexivity |
simpl; repeat (autounfold; simpl; repeat grewrite; simpl);
repeat (simpl_update_reg; simpl; repeat grewrite; simpl);
repeat simpl_field; repeat swap_fields; repeat simpl_field; simpl_htarget; try reflexivity]
| idtac ].
Ltac asm_prep_one_internal_step Hf :=
eapply OneStep; [
eapply exec_step_internal; repeat autounfold;
[simpl; grewrite; reflexivity | eapply Hf | reflexivity |]|].
Definition el3_sync_lel_func : function :=
{| fn_sig := null_signature;
fn_code := el3_sync_lel_insn |}.
Definition save_el2_state_func : function :=
{| fn_sig := null_signature;
fn_code := save_el2_state_insn |}.
Definition restore_el2_state_func : function :=
{| fn_sig := null_signature;
fn_code := restore_el2_state_insn |}.
Hypothesis el3_sync_lel_function:
Genv.find_funct_ptr ge (Z.to_pos el3_sync_lel) = Some (Internal el3_sync_lel_func).
Hypothesis save_el2_state_function:
Genv.find_funct_ptr ge (Z.to_pos save_el2_state) = Some (Internal save_el2_state_func).
Hypothesis restore_el2_state_function:
Genv.find_funct_ptr ge (Z.to_pos restore_el2_state) = Some (Internal restore_el2_state_func).
Variable f_handle_std_service: external_function.
Hypothesis handle_std_service_function:
Genv.find_funct_ptr ge (Z.to_pos handle_std_service) = Some (External f_handle_std_service).
Hint Unfold
get_creg set_creg get_pc set_pc get_sp set_sp extend_stack shrink_stack
nextinstr compare_long eval_testcond eval_testbit eval_testzero
mem_load mem_store get_stack set_stack goto_label RA get_el3_regs set_el3_regs.
Lemma realm_save_el2_state:
forall d lb ofs d'
(Hpc: get_pc d = (save_el2_state, 0))
(Hlabel: get_creg RA d / 10000 = lb)
(Hoffset: get_creg RA d mod 10000 = ofs)
(Harg: get_creg x0 d = percpu_data_start + CPUSTATE_REALM_OFFSET),
let cregs := cpu_regs (priv d) in
let realm_regs' :=
(realm_regs_el3 (priv d)) {r_spsr_el3: (r_spsr_el3 cregs)} {r_elr_el3: (r_elr_el3 cregs)} {r_actlr_el2: (r_actlr_el2 cregs)}
{r_afsr0_el2: (r_afsr0_el2 cregs)} {r_afsr1_el2: (r_afsr1_el2 cregs)} {r_amair_el2: (r_amair_el2 cregs)}
{r_cnthctl_el2: (r_cnthctl_el2 cregs)} {r_cntvoff_el2: (r_cntvoff_el2 cregs)}
{r_cptr_el2: (r_cptr_el2 cregs)} {r_elr_el2: (r_elr_el2 cregs)} {r_esr_el2: (r_esr_el2 cregs)}
{r_far_el2: (r_far_el2 cregs)} {r_hacr_el2: (r_hacr_el2 cregs)} {r_hcr_el2: (r_hcr_el2 cregs)}
{r_hpfar_el2: (r_hpfar_el2 cregs)} {r_hstr_el2: (r_hstr_el2 cregs)} {r_mair_el2: (r_mair_el2 cregs)}
{r_mpam_el2: (r_mpam_el2 cregs)} {r_mpamhcr_el2: (r_mpamhcr_el2 cregs)} {r_pmscr_el2: (r_pmscr_el2 cregs)}
{r_sctlr_el2: (r_sctlr_el2 cregs)} {r_scxtnum_el2: (r_scxtnum_el2 cregs)} {r_sp_el2: (r_sp_el2 cregs)}
{r_spsr_el2: (r_spsr_el2 cregs)} {r_tcr_el2: (r_tcr_el2 cregs)} {r_tfsr_el2: (r_tfsr_el2 cregs)}
{r_tpidr_el2: (r_tpidr_el2 cregs)} {r_trfcr_el2: (r_trfcr_el2 cregs)} {r_ttbr0_el2: (r_ttbr0_el2 cregs)}
{r_ttbr1_el2: (r_ttbr1_el2 cregs)} {r_vbar_el2: (r_vbar_el2 cregs)} {r_vdisr_el2: (r_vdisr_el2 cregs)}
{r_vmpidr_el2: (r_vmpidr_el2 cregs)} {r_vncr_el2: (r_vncr_el2 cregs)} {r_vpidr_el2: (r_vpidr_el2 cregs)}
{r_vsesr_el2: (r_vsesr_el2 cregs)} {r_vstcr_el2: (r_vstcr_el2 cregs)} {r_vsttbr_el2: (r_vsttbr_el2 cregs)}
{r_vtcr_el2: (r_vtcr_el2 cregs)} {r_vttbr_el2: (r_vttbr_el2 cregs)} {r_zcr_el2: (r_zcr_el2 cregs)}
in
let d0 := d {priv: (priv d) {realm_regs_el3: realm_regs'}
{cpu_regs: (cpu_regs (priv d)) {r_x1: r_zcr_el2 (cpu_regs (priv d))}
{r_x2: r_vttbr_el2 (cpu_regs (priv d))}
{r_x30: -1}}
{asm_regs : ((asm_regs (priv d)) {a_CZ : None} {a_PC: (lb, ofs)})}} in
StarStep d0 d' -> StarStep d d'.
Proof.
intros until d'.
repeat autounfold. repeat simpl_update_reg. repeat simpl_field. repeat swap_fields. simpl. intros.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 4096 = false).
grewrite. bool_rel. omega.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 0 = true).
grewrite. bool_rel. omega.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
apply H.
Qed.
Lemma ns_save_el2_state:
forall d lb ofs d'
(Hpc: get_pc d = (save_el2_state, 0))
(Hlabel: get_creg RA d / 10000 = lb)
(Hoffset: get_creg RA d mod 10000 = ofs)
(Harg: get_creg x0 d = percpu_data_start + CPUSTATE_NS_OFFSET),
let cregs := cpu_regs (priv d) in
let ns_regs' :=
(ns_regs_el3 (priv d)) {r_spsr_el3: (r_spsr_el3 cregs)} {r_elr_el3: (r_elr_el3 cregs)} {r_actlr_el2: (r_actlr_el2 cregs)}
{r_afsr0_el2: (r_afsr0_el2 cregs)} {r_afsr1_el2: (r_afsr1_el2 cregs)} {r_amair_el2: (r_amair_el2 cregs)}
{r_cnthctl_el2: (r_cnthctl_el2 cregs)} {r_cntvoff_el2: (r_cntvoff_el2 cregs)}
{r_cptr_el2: (r_cptr_el2 cregs)} {r_elr_el2: (r_elr_el2 cregs)} {r_esr_el2: (r_esr_el2 cregs)}
{r_far_el2: (r_far_el2 cregs)} {r_hacr_el2: (r_hacr_el2 cregs)} {r_hcr_el2: (r_hcr_el2 cregs)}
{r_hpfar_el2: (r_hpfar_el2 cregs)} {r_hstr_el2: (r_hstr_el2 cregs)} {r_mair_el2: (r_mair_el2 cregs)}
{r_mpam_el2: (r_mpam_el2 cregs)} {r_mpamhcr_el2: (r_mpamhcr_el2 cregs)} {r_pmscr_el2: (r_pmscr_el2 cregs)}
{r_sctlr_el2: (r_sctlr_el2 cregs)} {r_scxtnum_el2: (r_scxtnum_el2 cregs)} {r_sp_el2: (r_sp_el2 cregs)}
{r_spsr_el2: (r_spsr_el2 cregs)} {r_tcr_el2: (r_tcr_el2 cregs)} {r_tfsr_el2: (r_tfsr_el2 cregs)}
{r_tpidr_el2: (r_tpidr_el2 cregs)} {r_trfcr_el2: (r_trfcr_el2 cregs)} {r_ttbr0_el2: (r_ttbr0_el2 cregs)}
{r_ttbr1_el2: (r_ttbr1_el2 cregs)} {r_vbar_el2: (r_vbar_el2 cregs)} {r_vdisr_el2: (r_vdisr_el2 cregs)}
{r_vmpidr_el2: (r_vmpidr_el2 cregs)} {r_vncr_el2: (r_vncr_el2 cregs)} {r_vpidr_el2: (r_vpidr_el2 cregs)}
{r_vsesr_el2: (r_vsesr_el2 cregs)} {r_vstcr_el2: (r_vstcr_el2 cregs)} {r_vsttbr_el2: (r_vsttbr_el2 cregs)}
{r_vtcr_el2: (r_vtcr_el2 cregs)} {r_vttbr_el2: (r_vttbr_el2 cregs)} {r_zcr_el2: (r_zcr_el2 cregs)}
in
let d0 := d {priv: (priv d) {ns_regs_el3: ns_regs'}
{cpu_regs: (cpu_regs (priv d)) {r_x1: r_zcr_el2 (cpu_regs (priv d))}
{r_x2: r_vttbr_el2 (cpu_regs (priv d))}
{r_x30: -1}}
{asm_regs : ((asm_regs (priv d)) {a_CZ : None} {a_PC: (lb, ofs)})}} in
StarStep d0 d' -> StarStep d d'.
Proof.
intros until d'.
repeat autounfold. repeat simpl_update_reg. repeat simpl_field. repeat swap_fields. simpl. intros.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 4096 = true).
grewrite. bool_rel. omega.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 0 = false).
grewrite. bool_rel. omega.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
asm_one_internal_step save_el2_state_function.
apply H.
Qed.
Lemma ns_restore_el2_state:
forall d lb ofs d'
(Hpc: get_pc d = (restore_el2_state, 0))
(Hlabel: get_creg RA d / 10000 = lb)
(Hoffset: get_creg RA d mod 10000 = ofs)
(Harg: get_creg x0 d = percpu_data_start + CPUSTATE_NS_OFFSET),
let cregs := ns_regs_el3 (priv d) in
let ns_regs' :=
(cpu_regs (priv d)) {r_spsr_el3: (r_spsr_el3 cregs)} {r_elr_el3: (r_elr_el3 cregs)} {r_actlr_el2: (r_actlr_el2 cregs)}
{r_afsr0_el2: (r_afsr0_el2 cregs)} {r_afsr1_el2: (r_afsr1_el2 cregs)} {r_amair_el2: (r_amair_el2 cregs)}
{r_cnthctl_el2: (r_cnthctl_el2 cregs)} {r_cntvoff_el2: (r_cntvoff_el2 cregs)}
{r_cptr_el2: (r_cptr_el2 cregs)} {r_elr_el2: (r_elr_el2 cregs)} {r_esr_el2: (r_esr_el2 cregs)}
{r_far_el2: (r_far_el2 cregs)} {r_hacr_el2: (r_hacr_el2 cregs)} {r_hcr_el2: (r_hcr_el2 cregs)}
{r_hpfar_el2: (r_hpfar_el2 cregs)} {r_hstr_el2: (r_hstr_el2 cregs)} {r_mair_el2: (r_mair_el2 cregs)}
{r_mpam_el2: (r_mpam_el2 cregs)} {r_mpamhcr_el2: (r_mpamhcr_el2 cregs)} {r_pmscr_el2: (r_pmscr_el2 cregs)}
{r_sctlr_el2: (r_sctlr_el2 cregs)} {r_scxtnum_el2: (r_scxtnum_el2 cregs)} {r_sp_el2: (r_sp_el2 cregs)}
{r_spsr_el2: (r_spsr_el2 cregs)} {r_tcr_el2: (r_tcr_el2 cregs)} {r_tfsr_el2: (r_tfsr_el2 cregs)}
{r_tpidr_el2: (r_tpidr_el2 cregs)} {r_trfcr_el2: (r_trfcr_el2 cregs)} {r_ttbr0_el2: (r_ttbr0_el2 cregs)}
{r_ttbr1_el2: (r_ttbr1_el2 cregs)} {r_vbar_el2: (r_vbar_el2 cregs)} {r_vdisr_el2: (r_vdisr_el2 cregs)}
{r_vmpidr_el2: (r_vmpidr_el2 cregs)} {r_vncr_el2: (r_vncr_el2 cregs)} {r_vpidr_el2: (r_vpidr_el2 cregs)}
{r_vsesr_el2: (r_vsesr_el2 cregs)} {r_vstcr_el2: (r_vstcr_el2 cregs)} {r_vsttbr_el2: (r_vsttbr_el2 cregs)}
{r_vtcr_el2: (r_vtcr_el2 cregs)} {r_vttbr_el2: (r_vttbr_el2 cregs)} {r_zcr_el2: (r_zcr_el2 cregs)}
in
let d0 := d {priv: (priv d)
{cpu_regs: ns_regs' {r_x1: r_zcr_el2 (ns_regs_el3 (priv d))}
{r_x2: r_vttbr_el2 (ns_regs_el3 (priv d))}
{r_x30: -1}}
{asm_regs : ((asm_regs (priv d)) {a_CZ : None} {a_PC: (lb, ofs)})}} in
StarStep d0 d' -> StarStep d d'.
Proof.
intros until d'.
repeat autounfold. repeat simpl_update_reg. repeat simpl_field. repeat swap_fields. simpl. intros.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 4096 = true).
grewrite. bool_rel. omega.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 0 = false).
grewrite. bool_rel. omega.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
apply H.
Qed.
Lemma realm_restore_el2_state:
forall d lb ofs d'
(Hpc: get_pc d = (restore_el2_state, 0))
(Hlabel: get_creg RA d / 10000 = lb)
(Hoffset: get_creg RA d mod 10000 = ofs)
(Harg: get_creg x0 d = percpu_data_start + CPUSTATE_REALM_OFFSET),
let cregs := realm_regs_el3 (priv d) in
let realm_regs' :=
(cpu_regs (priv d)) {r_spsr_el3: (r_spsr_el3 cregs)} {r_elr_el3: (r_elr_el3 cregs)} {r_actlr_el2: (r_actlr_el2 cregs)}
{r_afsr0_el2: (r_afsr0_el2 cregs)} {r_afsr1_el2: (r_afsr1_el2 cregs)} {r_amair_el2: (r_amair_el2 cregs)}
{r_cnthctl_el2: (r_cnthctl_el2 cregs)} {r_cntvoff_el2: (r_cntvoff_el2 cregs)}
{r_cptr_el2: (r_cptr_el2 cregs)} {r_elr_el2: (r_elr_el2 cregs)} {r_esr_el2: (r_esr_el2 cregs)}
{r_far_el2: (r_far_el2 cregs)} {r_hacr_el2: (r_hacr_el2 cregs)} {r_hcr_el2: (r_hcr_el2 cregs)}
{r_hpfar_el2: (r_hpfar_el2 cregs)} {r_hstr_el2: (r_hstr_el2 cregs)} {r_mair_el2: (r_mair_el2 cregs)}
{r_mpam_el2: (r_mpam_el2 cregs)} {r_mpamhcr_el2: (r_mpamhcr_el2 cregs)} {r_pmscr_el2: (r_pmscr_el2 cregs)}
{r_sctlr_el2: (r_sctlr_el2 cregs)} {r_scxtnum_el2: (r_scxtnum_el2 cregs)} {r_sp_el2: (r_sp_el2 cregs)}
{r_spsr_el2: (r_spsr_el2 cregs)} {r_tcr_el2: (r_tcr_el2 cregs)} {r_tfsr_el2: (r_tfsr_el2 cregs)}
{r_tpidr_el2: (r_tpidr_el2 cregs)} {r_trfcr_el2: (r_trfcr_el2 cregs)} {r_ttbr0_el2: (r_ttbr0_el2 cregs)}
{r_ttbr1_el2: (r_ttbr1_el2 cregs)} {r_vbar_el2: (r_vbar_el2 cregs)} {r_vdisr_el2: (r_vdisr_el2 cregs)}
{r_vmpidr_el2: (r_vmpidr_el2 cregs)} {r_vncr_el2: (r_vncr_el2 cregs)} {r_vpidr_el2: (r_vpidr_el2 cregs)}
{r_vsesr_el2: (r_vsesr_el2 cregs)} {r_vstcr_el2: (r_vstcr_el2 cregs)} {r_vsttbr_el2: (r_vsttbr_el2 cregs)}
{r_vtcr_el2: (r_vtcr_el2 cregs)} {r_vttbr_el2: (r_vttbr_el2 cregs)} {r_zcr_el2: (r_zcr_el2 cregs)}
in
let d0 := d {priv: (priv d)
{cpu_regs: realm_regs' {r_x1: r_zcr_el2 (realm_regs_el3 (priv d))}
{r_x2: r_vttbr_el2 (realm_regs_el3 (priv d))}
{r_x30: -1}}
{asm_regs : ((asm_regs (priv d)) {a_CZ : None} {a_PC: (lb, ofs)})}} in
StarStep d0 d' -> StarStep d d'.
Proof.
intros until d'.
repeat autounfold. repeat simpl_update_reg. repeat simpl_field. repeat swap_fields. simpl. intros.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 4096 = false).
grewrite. bool_rel. omega.
assert(r_x0 (cpu_regs (priv d)) =? percpu_data_start + 0 = true).
grewrite. bool_rel. omega.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
asm_one_internal_step restore_el2_state_function.
apply H.
Qed.