Library mcertikos.mm.PTCommGen
This file provide the contextual refinement proof between MPTOp layer and MPTComm layer
Require Import Coqlib.
Require Import Errors.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Op.
Require Import Asm.
Require Import Events.
Require Import Globalenvs.
Require Import Smallstep.
Require Import Values.
Require Import Memory.
Require Import Maps.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import FlatMemory.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import RealParams.
Require Import LoadStoreSem2.
Require Import AsmImplLemma.
Require Import LAsm.
Require Import RefinementTactic.
Require Import PrimSemantics.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compcertx.Stencil.
Require Import liblayers.compcertx.MakeProgram.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import compcert.cfrontend.Ctypes.
Require Import PTCommGenSpec.
Require Import LayerCalculusLemma.
Require Import PTOpGen.
Require Import MPTCommon.
Require Import AbstractDataType.
Require Import Errors.
Require Import AST.
Require Import Integers.
Require Import Floats.
Require Import Op.
Require Import Asm.
Require Import Events.
Require Import Globalenvs.
Require Import Smallstep.
Require Import Values.
Require Import Memory.
Require Import Maps.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import FlatMemory.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import RealParams.
Require Import LoadStoreSem2.
Require Import AsmImplLemma.
Require Import LAsm.
Require Import RefinementTactic.
Require Import PrimSemantics.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compcertx.Stencil.
Require Import liblayers.compcertx.MakeProgram.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import compcert.cfrontend.Ctypes.
Require Import PTCommGenSpec.
Require Import LayerCalculusLemma.
Require Import PTOpGen.
Require Import MPTCommon.
Require Import AbstractDataType.
Section Refinement.
Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Notation HDATA := RData.
Notation LDATA := RData.
Notation HDATAOps := (cdata HDATA).
Notation LDATAOps := (cdata LDATA).
Section WITHMEM.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Local Open Scope string_scope.
Local Open Scope error_monad_scope.
Local Open Scope Z_scope.
Context `{real_params: RealParams}.
Context `{multi_oracle_prop: MultiOracleProp}.
Notation HDATA := RData.
Notation LDATA := RData.
Notation HDATAOps := (cdata HDATA).
Notation LDATAOps := (cdata LDATA).
Section WITHMEM.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Section Exists.
Lemma pt_init_comm_exist:
∀ habd habd´ labd i s f,
pt_init_comm_spec i habd = ret habd´
→ relate_AbData s f habd labd
→ ∃ labd´, pt_init_comm_spec i labd = Some labd´ ∧ relate_RData f habd´ labd´
∧ kernel_mode labd.
Proof.
unfold pt_init_comm_spec; intros until f; exist_simpl.
Qed.
Lemma ptAllocPDE_exist:
∀ habd habd´ labd n i v s f,
ptAllocPDE_spec n i habd = ret (habd´, v)
→ relate_AbData s f habd labd
→ ∃ labd´, ptAllocPDE_spec n i labd = Some (labd´, v) ∧ relate_AbData s f habd´ labd´
∧ kernel_mode labd.
Proof.
unfold ptAllocPDE_spec. intros.
revert H. pose proof H0 as HR. inv H0.
subrewrite. simpl.
destruct (ikern labd); contra_inv.
destruct (ihost labd); contra_inv.
destruct (init labd); contra_inv.
destruct (ipt labd); contra_inv.
destruct (cused (ZMap.get n (AC labd))); contra_inv.
destruct (pt_Arg´ n i); contra_inv.
destruct (zeq n (PT labd)); contra_inv.
destruct (ZMap.get (PDX i) (ZMap.get n (ptpool labd))); contra_inv.
destruct (lpalloc_spec n habd) eqn: Halloc; contra_inv.
destruct p.
exploit lpalloc_exist; eauto.
intros (lad´ & → & Hr).
subdestruct; inv HQ; refine_split´; trivial.
inv Hr. constructor; simpl; try assumption; subrewrite´; try reflexivity.
apply FlatMem.free_page_inj´. assumption.
Qed.
End Exists.
Section FRESH_PRIM.
Lemma pt_init_comm_spec_ref:
compatsim (crel HDATA LDATA) (gensem pt_init_comm_spec) pt_init_comm_spec_low.
Proof.
compatsim_simpl (@match_AbData).
exploit pt_init_comm_exist; eauto 1.
intros [labd´ [HP [HM Hkern]]].
refine_split; try econstructor; eauto. constructor.
Qed.
Lemma ptAllocPDE_spec_ref:
compatsim (crel HDATA LDATA) (gensem ptAllocPDE_spec) ptAllocPDE_spec_low.
Proof.
compatsim_simpl (@match_AbData).
exploit ptAllocPDE_exist; eauto 1.
intros [labd´ [HP [HM Hkern]]].
refine_split; try econstructor; eauto. constructor.
Qed.
End FRESH_PRIM.
Section PASSTHROUGH_RPIM.
Lemma passthrough_correct:
sim (crel HDATA LDATA) mptcommon_passthrough mptop.
Proof.
sim_oplus.
- apply fload_sim.
- apply fstore_sim.
- apply page_copy_sim.
- apply page_copy_back_sim.
- apply vmxinfo_get_sim.
- apply setPG1_sim.
- apply get_at_c_sim.
- apply set_at_c0_sim.
- apply lpalloc_sim.
- apply setPT´_sim.
- apply setPDE_sim.
- apply ptRead_sim.
- apply ptReadPDE_sim.
- apply ptInsertAux_sim.
- apply ptRmvAux_sim.
- apply ptin´_sim.
- apply ptout_sim.
- apply container_get_parent_sim.
- apply container_get_nchildren_sim.
- apply container_get_quota_sim.
- apply container_get_usage_sim.
- apply container_can_consume_sim.
- apply container_split_sim.
- apply get_CPU_ID_sim.
- apply get_curid_sim.
- apply set_curid_sim.
- apply set_curid_init_sim.
- apply (release_lock_sim (valid_arg_imply:= Shared2ID1_imply)).
- eapply acquire_lock_sim1; eauto.
intros; inv H.
- apply cli_sim.
- apply sti_sim.
- apply serial_intr_disable_sim.
- apply serial_intr_enable_sim.
- apply serial_putc_sim.
- apply cons_buf_read_sim.
- apply trapin_sim.
- apply trapout_sim.
- apply hostin_sim.
- apply hostout_sim.
- apply proc_create_postinit_sim.
- apply trap_info_get_sim.
- apply trap_info_ret_sim.
- layer_sim_simpl.
+ eapply load_correct2.
+ eapply store_correct2.
Qed.
End PASSTHROUGH_RPIM.
End OneStep_Forward_Relation.
End WITHMEM.
End Refinement.
Lemma pt_init_comm_exist:
∀ habd habd´ labd i s f,
pt_init_comm_spec i habd = ret habd´
→ relate_AbData s f habd labd
→ ∃ labd´, pt_init_comm_spec i labd = Some labd´ ∧ relate_RData f habd´ labd´
∧ kernel_mode labd.
Proof.
unfold pt_init_comm_spec; intros until f; exist_simpl.
Qed.
Lemma ptAllocPDE_exist:
∀ habd habd´ labd n i v s f,
ptAllocPDE_spec n i habd = ret (habd´, v)
→ relate_AbData s f habd labd
→ ∃ labd´, ptAllocPDE_spec n i labd = Some (labd´, v) ∧ relate_AbData s f habd´ labd´
∧ kernel_mode labd.
Proof.
unfold ptAllocPDE_spec. intros.
revert H. pose proof H0 as HR. inv H0.
subrewrite. simpl.
destruct (ikern labd); contra_inv.
destruct (ihost labd); contra_inv.
destruct (init labd); contra_inv.
destruct (ipt labd); contra_inv.
destruct (cused (ZMap.get n (AC labd))); contra_inv.
destruct (pt_Arg´ n i); contra_inv.
destruct (zeq n (PT labd)); contra_inv.
destruct (ZMap.get (PDX i) (ZMap.get n (ptpool labd))); contra_inv.
destruct (lpalloc_spec n habd) eqn: Halloc; contra_inv.
destruct p.
exploit lpalloc_exist; eauto.
intros (lad´ & → & Hr).
subdestruct; inv HQ; refine_split´; trivial.
inv Hr. constructor; simpl; try assumption; subrewrite´; try reflexivity.
apply FlatMem.free_page_inj´. assumption.
Qed.
End Exists.
Section FRESH_PRIM.
Lemma pt_init_comm_spec_ref:
compatsim (crel HDATA LDATA) (gensem pt_init_comm_spec) pt_init_comm_spec_low.
Proof.
compatsim_simpl (@match_AbData).
exploit pt_init_comm_exist; eauto 1.
intros [labd´ [HP [HM Hkern]]].
refine_split; try econstructor; eauto. constructor.
Qed.
Lemma ptAllocPDE_spec_ref:
compatsim (crel HDATA LDATA) (gensem ptAllocPDE_spec) ptAllocPDE_spec_low.
Proof.
compatsim_simpl (@match_AbData).
exploit ptAllocPDE_exist; eauto 1.
intros [labd´ [HP [HM Hkern]]].
refine_split; try econstructor; eauto. constructor.
Qed.
End FRESH_PRIM.
Section PASSTHROUGH_RPIM.
Lemma passthrough_correct:
sim (crel HDATA LDATA) mptcommon_passthrough mptop.
Proof.
sim_oplus.
- apply fload_sim.
- apply fstore_sim.
- apply page_copy_sim.
- apply page_copy_back_sim.
- apply vmxinfo_get_sim.
- apply setPG1_sim.
- apply get_at_c_sim.
- apply set_at_c0_sim.
- apply lpalloc_sim.
- apply setPT´_sim.
- apply setPDE_sim.
- apply ptRead_sim.
- apply ptReadPDE_sim.
- apply ptInsertAux_sim.
- apply ptRmvAux_sim.
- apply ptin´_sim.
- apply ptout_sim.
- apply container_get_parent_sim.
- apply container_get_nchildren_sim.
- apply container_get_quota_sim.
- apply container_get_usage_sim.
- apply container_can_consume_sim.
- apply container_split_sim.
- apply get_CPU_ID_sim.
- apply get_curid_sim.
- apply set_curid_sim.
- apply set_curid_init_sim.
- apply (release_lock_sim (valid_arg_imply:= Shared2ID1_imply)).
- eapply acquire_lock_sim1; eauto.
intros; inv H.
- apply cli_sim.
- apply sti_sim.
- apply serial_intr_disable_sim.
- apply serial_intr_enable_sim.
- apply serial_putc_sim.
- apply cons_buf_read_sim.
- apply trapin_sim.
- apply trapout_sim.
- apply hostin_sim.
- apply hostout_sim.
- apply proc_create_postinit_sim.
- apply trap_info_get_sim.
- apply trap_info_ret_sim.
- layer_sim_simpl.
+ eapply load_correct2.
+ eapply store_correct2.
Qed.
End PASSTHROUGH_RPIM.
End OneStep_Forward_Relation.
End WITHMEM.
End Refinement.