Skip to content

Commit a61d148

Browse files
committed
Re-add the computational model without promise-free optimization
1 parent 73e82a9 commit a61d148

File tree

5 files changed

+91
-8
lines changed

5 files changed

+91
-8
lines changed

ArchSem/GenPromising.v

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,17 @@ Module GenPromising (IWA : InterfaceWithArch) (TM : TermModelsT IWA).
426426
Arguments to_final_archState {_ _ _}.
427427
End CPState.
428428

429-
(** Create a computational model from an ISA model and promising model *)
429+
(** Create computational models from an ISA model and promising model *)
430430
Definition Promising_to_Modelc (isem : iMon ()) (prom : BasicExecutablePM)
431431
(fuel : nat) : archModel.c ∅ :=
432+
λ n term (initMs : archState n),
433+
PState.from_archState prom initMs |>
434+
archModel.Res.from_exec
435+
$ CPState.to_final_archState
436+
<$> CPState.run isem prom term fuel.
437+
438+
Definition Promising_to_Modelc_pf (isem : iMon ()) (prom : BasicExecutablePM)
439+
(fuel : nat) : archModel.c ∅ :=
432440
λ n term (initMs : archState n),
433441
PState.from_archState prom initMs |>
434442
archModel.Res.from_exec

ArchSemArm/UMPromising.v

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,9 @@ Section ComputeProm.
685685
let base := List.length mem in
686686
let res_proms := Exec.results $
687687
run_to_termination_promise isem fuel base (CProm.init, PPState.Make ts mem IIS.init) in
688-
guard_or ("Could not finish promises within the size of the fuel")%string
688+
guard_or ("Out of fuel when searching for new promises")%string
689689
(∀ r ∈ res_proms, r.2 = true);;
690-
let promises := res_proms.*1.*1 |> CProm.proms ∘ union_list in
690+
let promises := res_proms.*1.*1 |> union_list |> CProm.proms in
691691
let tstates :=
692692
res_proms
693693
|> omap (λ '((cp, st), _),
@@ -780,3 +780,6 @@ Next Obligation. Admitted.
780780

781781
Definition UMPromising_cert_c isem fuel :=
782782
Promising_to_Modelc isem (UMPromising_exe' isem) fuel.
783+
784+
Definition UMPromising_cert_c_pf isem fuel :=
785+
Promising_to_Modelc_pf isem (UMPromising_exe' isem) fuel.

ArchSemArm/VMPromising.v

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1967,9 +1967,9 @@ Section ComputeProm.
19671967
let base := List.length mem in
19681968
let res_proms := Exec.results $
19691969
run_to_termination_promise isem fuel base (CProm.init, PPState.Make ts mem IIS.init) in
1970-
guard_or ("Could not finish promises within the size of the fuel")%string
1970+
guard_or ("Out of fuel when searching for new promises")%string
19711971
(∀ r ∈ res_proms, r.2 = true);;
1972-
let promises := res_proms.*1.*1 |> CProm.proms ∘ union_list in
1972+
let promises := res_proms.*1.*1 |> union_list |> CProm.proms in
19731973
let tstates :=
19741974
res_proms
19751975
|> omap (λ '((cp, st), _),
@@ -2056,3 +2056,6 @@ Next Obligation. Admitted.
20562056

20572057
Definition VMPromising_cert_c isem fuel :=
20582058
Promising_to_Modelc isem (VMPromising_exe' isem) fuel.
2059+
2060+
Definition VMPromising_cert_c_pf isem fuel :=
2061+
Promising_to_Modelc_pf isem (VMPromising_exe' isem) fuel.

ArchSemArm/tests/UMPromisingTest.v

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ Module LDR. (* LDR X0, [X1, X0] at 0x500, loading from 0x1000 *)
153153
vm_compute (_ <$> _).
154154
reflexivity.
155155
Qed.
156+
157+
Definition test_results_pf :=
158+
UMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
159+
160+
Goal reg_extract R0 0%fin <$> test_results_pf = Listset [Ok 0x2a%Z].
161+
vm_compute (_ <$> _).
162+
reflexivity.
163+
Qed.
156164
End LDR.
157165

158166
Module STRLDR. (* STR X2, [X1, X0]; LDR X0, [X1, X0] at 0x500, using address 0x1100 *)
@@ -190,6 +198,14 @@ Module STRLDR. (* STR X2, [X1, X0]; LDR X0, [X1, X0] at 0x500, using address 0x1
190198
vm_compute (_ <$> _).
191199
set_solver.
192200
Qed.
201+
202+
Definition test_results_pf :=
203+
UMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
204+
205+
Goal reg_extract R0 0%fin <$> test_results_pf ≡ Listset [Ok 0x2a%Z].
206+
vm_compute (_ <$> _).
207+
set_solver.
208+
Qed.
193209
End STRLDR.
194210

195211
Module MP.
@@ -261,6 +277,16 @@ Module MP.
261277
vm_compute (elements _).
262278
apply NoDup_Permutation; try solve_NoDup; set_solver.
263279
Qed.
280+
281+
Definition test_results_pf :=
282+
UMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
283+
284+
Goal elements (regs_extract [(1%fin, R5); (1%fin, R2)] <$> test_results) ≡ₚ
285+
[Ok [0x0%Z;0x2a%Z]; Ok [0x0%Z;0x0%Z]; Ok [0x1%Z; 0x2a%Z]; Ok [0x1%Z; 0x0%Z]].
286+
Proof.
287+
vm_compute (elements _).
288+
apply NoDup_Permutation; try solve_NoDup; set_solver.
289+
Qed.
264290
End MP.
265291

266292
Module MPDMBS.
@@ -335,4 +361,15 @@ Module MPDMBS.
335361
vm_compute (elements _).
336362
apply NoDup_Permutation; try solve_NoDup; set_solver.
337363
Qed.
364+
365+
Definition test_results_pf :=
366+
UMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
367+
368+
(** The test is fenced enough, the 0x1;0x0 outcome is impossible*)
369+
Goal elements (regs_extract [(1%fin, R5); (1%fin, R2)] <$> test_results) ≡ₚ
370+
[Ok [0x0%Z;0x2a%Z]; Ok [0x0%Z;0x0%Z]; Ok [0x1%Z; 0x2a%Z]].
371+
Proof.
372+
vm_compute (elements _).
373+
apply NoDup_Permutation; try solve_NoDup; set_solver.
374+
Qed.
338375
End MPDMBS.

ArchSemArm/tests/VMPromisingTest.v

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ Module EORMMUOFF.
128128
vm_compute (_ <$> _).
129129
reflexivity.
130130
Qed.
131+
132+
Definition test_results_pf :=
133+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
134+
135+
Goal reg_extract R0 0%fin <$> test_results_pf = Listset [Ok 0x110%Z].
136+
vm_compute (_ <$> _).
137+
reflexivity.
138+
Qed.
131139
End EORMMUOFF.
132140

133141
(* Run EOR X0, X1, X2 at PC.
@@ -194,6 +202,14 @@ Module EOR.
194202
vm_compute (_ <$> _).
195203
reflexivity.
196204
Qed.
205+
206+
Definition test_results_pf :=
207+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
208+
209+
Goal reg_extract R0 0%fin <$> test_results_pf = Listset [Ok 0x110%Z].
210+
vm_compute (_ <$> _).
211+
reflexivity.
212+
Qed.
197213
End EOR.
198214

199215
(* LDR X0, [X1, X0] at VA 0x8000000500, loading from VA 0x8000001000
@@ -247,6 +263,14 @@ Module LDR.
247263
vm_compute (_ <$> _).
248264
reflexivity.
249265
Qed.
266+
267+
Definition test_results_pf :=
268+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
269+
270+
Goal reg_extract R0 0%fin <$> test_results_pf = Listset [Ok 0x2a%Z].
271+
vm_compute (_ <$> _).
272+
reflexivity.
273+
Qed.
250274
End LDR.
251275

252276
(* STR X2, [X1, X0]; LDR X0, [X1, X0] at VA 0x8000000500,
@@ -299,6 +323,14 @@ Module STRLDR.
299323
vm_compute (_ <$> _).
300324
set_solver.
301325
Qed.
326+
327+
Definition test_results_pf :=
328+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
329+
330+
Goal reg_extract R0 0%fin <$> test_results_pf ≡ Listset [Ok 0x2a%Z].
331+
vm_compute (_ <$> _).
332+
set_solver.
333+
Qed.
302334
End STRLDR.
303335

304336
(* Sequential page table modification in single thread *)
@@ -362,7 +394,7 @@ Module LDRPT.
362394
Definition fuel := 5%nat.
363395

364396
Definition test_results :=
365-
VMPromising_cert_c arm_sem fuel n_threads termCond initState.
397+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
366398

367399
(* R0 should be 0x2a (from old mapping), R4 should be 0x42 (from new mapping) *)
368400
Goal elements (regs_extract [(0%fin, R0); (0%fin, R4)] <$> test_results) ≡ₚ
@@ -455,7 +487,7 @@ Module MP.
455487
Definition fuel := 8%nat.
456488

457489
Definition test_results :=
458-
VMPromising_cert_c arm_sem fuel n_threads termCond initState.
490+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
459491

460492
Goal elements (regs_extract [(1%fin, R5); (1%fin, R2)] <$> test_results) ≡ₚ
461493
[Ok [0x0%Z;0x2a%Z]; Ok [0x0%Z;0x0%Z]; Ok [0x1%Z; 0x2a%Z]; Ok [0x1%Z; 0x0%Z]].
@@ -547,7 +579,7 @@ Module MPDMBS.
547579
Definition fuel := 8%nat.
548580

549581
Definition test_results :=
550-
VMPromising_cert_c arm_sem fuel n_threads termCond initState.
582+
VMPromising_cert_c_pf arm_sem fuel n_threads termCond initState.
551583

552584
(** The test is fenced enough, the 0x1; 0x0 outcome is impossible*)
553585
Goal elements (regs_extract [(1%fin, R5); (1%fin, R2)] <$> test_results) ≡ₚ

0 commit comments

Comments
 (0)