Library mcertikos.multicore.semantics.EnvSemImpl
This file provide the semantics for the Asm instructions. Since we introduce paging mechanisms, the semantics of memory load and store are different from Compcert Asm
Require Import Coqlib.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Events.
Require Import Globalenvs.
Require Import Conventions.
Require Import AuxLemma.
Require Import GlobIdent.
Require Import Smallstep.
Require Import CommonTactic.
Require Import Coq.Logic.FunctionalExtensionality.
Require Import AuxFunctions.
Require Import LAsm.
Require Import GlobalOracle.
Require Import liblayers.compat.CompatLayers.
Require Import MBoot.
Require Import RealParams.
Require Import AbstractDataType.
Require Import FlatMemory.
Require Import Decision.
Require Import LAsmModuleSem.
Require Import Soundness.
Require Import CompatExternalCalls.
Require Import LinkTactic.
Require Import I64Layer.
Require Import StencilImpl.
Require Import MakeProgram.
Require Import MakeProgramImpl.
Require Import LAsmModuleSemAux.
Require Import Concurrent_Linking_Lib.
Require Import Concurrent_Linking_Def.
Require Import Concurrent_Linking_Prop.
Require Import HWSemImpl.
Require Import ConcurrentOracle.
Require Import Machregs.
Require Import DeviceStateDataType.
Require Import liblayers.compat.CompatGenSem.
Require Import FutureTactic.
Section ENVSEM.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Context `{builtin_idents_norepet_prf: CompCertBuiltins.BuiltinIdentsNorepet}.
Notation LDATA := RData.
Notation LDATAOps := (cdata (cdata_ops := mboot_data_ops) LDATA).
Local Open Scope Z_scope.
Context `{pmap: PartialMap}.
Context `{fair: Fairness}.
Context `{zset_op: ZSet_operation}.
Existing Instance hdseting.
Existing Instance op_reorder.
Context `{mc_oracle: !MCLinkOracle}.
Context `{mc_oracle_cond: !MCLinkOracleCond}.
Section WITH_GE.
Variable cores : ZSet.
Variable o : GeneralOracleType.
Variables (ge: genv) (sten: stencil) (M: module).
Context {Hmakege: make_globalenv (module_ops:= LAsm.module_ops) (mkp_ops:= make_program_ops)
sten M (mboot ⊕ L64) = ret ge}.
Local Obligation Tactic := intros.
Definition hdsem_instance := @hdsem mem memory_model_ops Hmem Hmwd real_params_ops oracle_ops0
oracle_ops big_ops builtin_idents_norepet_prf ge sten M Hmakege.
Definition env_step_aux:=
@env_step zset_op hdseting op_general hdsem_instance pmap cores o.
Inductive env_step_aux_ge : genv → (estate (A:= cores)) → trace → (estate (A:= cores)) → Prop :=
| env_step_aux_ge_intro :
∀ s t s´,
env_step_aux s t s´ → env_step_aux_ge ge s t s´.
Inductive env_initial_state (p: AST.program fundef unit):
(estate (A := cores) (hdset := hdseting)) → Prop :=
| initial_env_state_intro:
∀ (m0: mwd LDATAOps),
Genv.init_mem p = Some m0 →
let ge := Genv.globalenv p in
let rs0 :=
(Pregmap.init Vundef)
# Asm.PC <- (symbol_offset ge p.(prog_main) Int.zero)
# ESP <- Vzero in
env_initial_state p (EState current_CPU_ID
(pset current_CPU_ID (LState (Asm.State rs0 m0) true)
(pinit (B := cores) (LState (Asm.State rs0 m0) false)))
nil).
Definition env_final_state (s : estate (A:=cores) (hdset := hdseting)) (i : int) : Prop :=
False.
Ltac subst_except v :=
repeat match goal with
| [ H: v = _ |- _ ] ⇒ generalize H; clear H
| [ H: _ = v |- _ ] ⇒ generalize H; clear H
end; subst; intros.
Ltac clear_eq v :=
repeat match goal with
| [ H: v = _ |- _ ] ⇒ clear H
| [ H: _ = v |- _ ] ⇒ clear H
end.
Definition env_semantics (p: program) :=
Smallstep.Semantics env_step_aux_ge (env_initial_state p)
env_final_state (Genv.globalenv p).
Lemma env_semantics_single_events:
∀ p, single_events (env_semantics p).
Proof.
intros p s t s´ Hstep; inversion Hstep.
inversion H.
simpl; omega.
simpl; omega.
simpl; omega.
Qed.
Lemma env_semantics_receptive (pl: program):
receptive (env_semantics pl).
Proof.
intros; constructor.
- inversion 1.
inversion H0.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
econstructor; eauto.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
econstructor; eauto.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
substx.
eapply env_exec_step_skip; eauto.
- eapply env_semantics_single_events.
Qed.
Lemma env_semantics_determinate (pl: program):
determinate (env_semantics pl).
Proof.
econstructor.
- simpl in ×.
simpl.
intros s t1 s1 t2 s2 Hs1 Hs2.
inversion Hs1; inversion Hs2; subst_except ge; clear Hs1 Hs2.
rename H into Hs1, H4 into Hs2; unfold env_step_aux in ×.
assert (t1 = E0 ∧ t2 = E0 ∧ s1 = s2) as Hs.
{
eapply env_step_determ.
+ exact Hs1.
+ exact Hs2.
}
destruct Hs as (Ht1 & Ht2 & Hs).
split; eauto.
rewrite Ht1, Ht2.
constructor.
- eapply env_semantics_single_events.
- intros.
simpl in ×.
inv H; inv H0.
unfold ge0, rs0, ge1, rs1.
simpl in ×.
rewrite H1 in H; inv H.
eauto.
- intros; simpl in ×.
inv H.
- intros.
simpl in ×.
inv H.
Qed.
End WITH_GE.
End ENVSEM.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Events.
Require Import Globalenvs.
Require Import Conventions.
Require Import AuxLemma.
Require Import GlobIdent.
Require Import Smallstep.
Require Import CommonTactic.
Require Import Coq.Logic.FunctionalExtensionality.
Require Import AuxFunctions.
Require Import LAsm.
Require Import GlobalOracle.
Require Import liblayers.compat.CompatLayers.
Require Import MBoot.
Require Import RealParams.
Require Import AbstractDataType.
Require Import FlatMemory.
Require Import Decision.
Require Import LAsmModuleSem.
Require Import Soundness.
Require Import CompatExternalCalls.
Require Import LinkTactic.
Require Import I64Layer.
Require Import StencilImpl.
Require Import MakeProgram.
Require Import MakeProgramImpl.
Require Import LAsmModuleSemAux.
Require Import Concurrent_Linking_Lib.
Require Import Concurrent_Linking_Def.
Require Import Concurrent_Linking_Prop.
Require Import HWSemImpl.
Require Import ConcurrentOracle.
Require Import Machregs.
Require Import DeviceStateDataType.
Require Import liblayers.compat.CompatGenSem.
Require Import FutureTactic.
Section ENVSEM.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Context `{builtin_idents_norepet_prf: CompCertBuiltins.BuiltinIdentsNorepet}.
Notation LDATA := RData.
Notation LDATAOps := (cdata (cdata_ops := mboot_data_ops) LDATA).
Local Open Scope Z_scope.
Context `{pmap: PartialMap}.
Context `{fair: Fairness}.
Context `{zset_op: ZSet_operation}.
Existing Instance hdseting.
Existing Instance op_reorder.
Context `{mc_oracle: !MCLinkOracle}.
Context `{mc_oracle_cond: !MCLinkOracleCond}.
Section WITH_GE.
Variable cores : ZSet.
Variable o : GeneralOracleType.
Variables (ge: genv) (sten: stencil) (M: module).
Context {Hmakege: make_globalenv (module_ops:= LAsm.module_ops) (mkp_ops:= make_program_ops)
sten M (mboot ⊕ L64) = ret ge}.
Local Obligation Tactic := intros.
Definition hdsem_instance := @hdsem mem memory_model_ops Hmem Hmwd real_params_ops oracle_ops0
oracle_ops big_ops builtin_idents_norepet_prf ge sten M Hmakege.
Definition env_step_aux:=
@env_step zset_op hdseting op_general hdsem_instance pmap cores o.
Inductive env_step_aux_ge : genv → (estate (A:= cores)) → trace → (estate (A:= cores)) → Prop :=
| env_step_aux_ge_intro :
∀ s t s´,
env_step_aux s t s´ → env_step_aux_ge ge s t s´.
Inductive env_initial_state (p: AST.program fundef unit):
(estate (A := cores) (hdset := hdseting)) → Prop :=
| initial_env_state_intro:
∀ (m0: mwd LDATAOps),
Genv.init_mem p = Some m0 →
let ge := Genv.globalenv p in
let rs0 :=
(Pregmap.init Vundef)
# Asm.PC <- (symbol_offset ge p.(prog_main) Int.zero)
# ESP <- Vzero in
env_initial_state p (EState current_CPU_ID
(pset current_CPU_ID (LState (Asm.State rs0 m0) true)
(pinit (B := cores) (LState (Asm.State rs0 m0) false)))
nil).
Definition env_final_state (s : estate (A:=cores) (hdset := hdseting)) (i : int) : Prop :=
False.
Ltac subst_except v :=
repeat match goal with
| [ H: v = _ |- _ ] ⇒ generalize H; clear H
| [ H: _ = v |- _ ] ⇒ generalize H; clear H
end; subst; intros.
Ltac clear_eq v :=
repeat match goal with
| [ H: v = _ |- _ ] ⇒ clear H
| [ H: _ = v |- _ ] ⇒ clear H
end.
Definition env_semantics (p: program) :=
Smallstep.Semantics env_step_aux_ge (env_initial_state p)
env_final_state (Genv.globalenv p).
Lemma env_semantics_single_events:
∀ p, single_events (env_semantics p).
Proof.
intros p s t s´ Hstep; inversion Hstep.
inversion H.
simpl; omega.
simpl; omega.
simpl; omega.
Qed.
Lemma env_semantics_receptive (pl: program):
receptive (env_semantics pl).
Proof.
intros; constructor.
- inversion 1.
inversion H0.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
econstructor; eauto.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
econstructor; eauto.
+ substx; try solve [inversion 1; substx; eauto].
intros.
inversion H8; substx.
∃ s1.
simpl.
unfold env_step_aux.
simpl in H1.
rewrite <- H1.
eapply env_step_aux_ge_intro.
unfold env_step_aux.
rewrite <- H7.
substx.
eapply env_exec_step_skip; eauto.
- eapply env_semantics_single_events.
Qed.
Lemma env_semantics_determinate (pl: program):
determinate (env_semantics pl).
Proof.
econstructor.
- simpl in ×.
simpl.
intros s t1 s1 t2 s2 Hs1 Hs2.
inversion Hs1; inversion Hs2; subst_except ge; clear Hs1 Hs2.
rename H into Hs1, H4 into Hs2; unfold env_step_aux in ×.
assert (t1 = E0 ∧ t2 = E0 ∧ s1 = s2) as Hs.
{
eapply env_step_determ.
+ exact Hs1.
+ exact Hs2.
}
destruct Hs as (Ht1 & Ht2 & Hs).
split; eauto.
rewrite Ht1, Ht2.
constructor.
- eapply env_semantics_single_events.
- intros.
simpl in ×.
inv H; inv H0.
unfold ge0, rs0, ge1, rs1.
simpl in ×.
rewrite H1 in H; inv H.
eauto.
- intros; simpl in ×.
inv H.
- intros.
simpl in ×.
inv H.
Qed.
End WITH_GE.
End ENVSEM.