Library mcertikos.proc.PCVOp
This file defines the abstract data and the primitives for the PAbQueue layer,
which will introduce abstraction of kernel context
Require Import Coqlib.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Memory.
Require Import Events.
Require Import Stacklayout.
Require Import Globalenvs.
Require Import AsmX.
Require Import Smallstep.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import FlatMemory.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import RealParams.
Require Import PrimSemantics.
Require Import LAsm.
Require Import LoadStoreSem2.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import CalRealPTPool.
Require Import CalRealPT.
Require Import CalRealIDPDE.
Require Import CalRealInitPTE.
Require Import CalRealSMSPool.
Require Import CalRealProcModule.
Require Import INVLemmaContainer.
Require Import INVLemmaMemory.
Require Import INVLemmaThread.
Require Import AbstractDataType.
Require Import CalTicketLock.
Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.
Require Export PCVIntro.
Require Import Maps.
Require Import ASTExtra.
Require Import Integers.
Require Import Floats.
Require Import Values.
Require Import Memory.
Require Import Events.
Require Import Stacklayout.
Require Import Globalenvs.
Require Import AsmX.
Require Import Smallstep.
Require Import AuxStateDataType.
Require Import Constant.
Require Import GlobIdent.
Require Import FlatMemory.
Require Import CommonTactic.
Require Import AuxLemma.
Require Import RealParams.
Require Import PrimSemantics.
Require Import LAsm.
Require Import LoadStoreSem2.
Require Import XOmega.
Require Import liblayers.logic.PTreeModules.
Require Import liblayers.logic.LayerLogicImpl.
Require Import liblayers.compat.CompatLayers.
Require Import liblayers.compat.CompatGenSem.
Require Import CalRealPTPool.
Require Import CalRealPT.
Require Import CalRealIDPDE.
Require Import CalRealInitPTE.
Require Import CalRealSMSPool.
Require Import CalRealProcModule.
Require Import INVLemmaContainer.
Require Import INVLemmaMemory.
Require Import INVLemmaThread.
Require Import AbstractDataType.
Require Import CalTicketLock.
Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.
Require Export PCVIntro.
Section WITHMEM.
Local Open Scope Z_scope.
Context `{oracle_prop: MultiOracleProp}.
Context `{real_params: RealParams}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Local Open Scope Z_scope.
Context `{oracle_prop: MultiOracleProp}.
Context `{real_params: RealParams}.
Context `{Hstencil: Stencil}.
Context `{Hmem: Mem.MemoryModelX}.
Context `{Hmwd: UseMemWithData mem}.
Section INV.
Section RECEIVE.
Lemma page_copy_back_high_level_inv:
∀ d d´ chid cound addr,
page_copy_back_spec chid cound addr d = Some d´
→ high_level_invariant d
→ high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0.
constructor; simpl; intros;
try eapply dirty_ppage_gss_page_copy_back; eauto.
Qed.
Lemma page_copy_back_low_level_inv:
∀ d d´ chid cound addr n,
page_copy_back_spec chid cound addr d = Some d´
→ low_level_invariant n d
→ low_level_invariant n d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0. constructor; eauto 2.
Qed.
Lemma page_copy_back_kernel_mode:
∀ d d´ chid cound addr,
page_copy_back_spec chid cound addr d = Some d´
→ kernel_mode d
→ kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
Qed.
Lemma ipc_receive_body_high_level_inv:
∀ fromid vaddr count d d´ n,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_high_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2; simpl; intros.
Qed.
Lemma ipc_receive_body_low_level_inv:
∀ fromid vaddr count d d´ n n´,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_low_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2.
Qed.
Lemma ipc_receive_body_kernel_mode:
∀ fromid vaddr count d d´ n,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_kernel_mode; eauto.
Qed.
Global Instance ipc_receive_body_inv: PreservesInvariants ipc_receive_body_spec.
Proof.
preserves_invariants_simpl´.
- eapply ipc_receive_body_low_level_inv; eassumption.
- eapply ipc_receive_body_high_level_inv; eassumption.
- eapply ipc_receive_body_kernel_mode; eassumption.
Qed.
End RECEIVE.
Section SEND.
Lemma page_copy_high_level_inv:
∀ d d´ chid cound addr,
page_copy_spec chid cound addr d = Some d´
→ high_level_invariant d
→ high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0.
constructor; simpl; intros; eauto.
- eapply consistent_ppage_log_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply LATCTable_log_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply valid_hlock_pool1_gss´; eauto.
- eapply valid_AT_log_pool_H_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply valid_ABTCB_log_pool_gso´; eauto.
reflexivity.
Qed.
Lemma page_copy_low_level_inv:
∀ d d´ chid cound addr n,
page_copy_spec chid cound addr d = Some d´
→ low_level_invariant n d
→ low_level_invariant n d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0. constructor; eauto 2.
Qed.
Lemma page_copy_kernel_mode:
∀ d d´ chid cound addr,
page_copy_spec chid cound addr d = Some d´
→ kernel_mode d
→ kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
Qed.
Lemma ipc_send_body_high_level_inv:
∀ fromid vaddr count d d´ n,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_high_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2; simpl; intros.
Qed.
Lemma ipc_send_body_low_level_inv:
∀ fromid vaddr count d d´ n n´,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_low_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2.
Qed.
Lemma ipc_send_body_kernel_mode:
∀ fromid vaddr count d d´ n,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_kernel_mode; eauto.
Qed.
Global Instance ipc_send_body_inv: PreservesInvariants ipc_send_body_spec.
Proof.
preserves_invariants_simpl´.
- eapply ipc_send_body_low_level_inv; eassumption.
- eapply ipc_send_body_high_level_inv; eassumption.
- eapply ipc_send_body_kernel_mode; eassumption.
Qed.
End SEND.
Global Instance fifobbq_pool_init_inv: PreservesInvariants fifobbq_pool_init_spec.
Proof.
preserves_invariants_simpl low_level_invariant high_level_invariant.
- apply real_nps_range.
- apply AC_init_container_valid.
- rewrite init_pperm; [|try assumption].
apply real_pperm_log_valid.
- eapply real_pt_PMap_valid; eauto.
- apply real_pt_PMap_kern.
- omega.
- assumption.
- apply real_idpde_init.
- apply real_pt_weak_consistent_pmap.
- apply real_pt_consistent_pmap_domain.
- apply Lreal_at_consistent_lat_domain.
- eapply LATCTable_log_real; eauto.
- assumption.
- apply real_abtcb_range; auto.
- apply real_abq_range; auto.
- eapply real_abtcb_abq_QCount; eauto.
- eapply real_abq_tcb_inQ; eauto.
- assumption.
- eapply real_valid_hlock_pool1; eauto.
- assumption.
- eapply real_valid_AT_log_pool_H; eauto.
- assumption.
- eapply real_valid_ABTCB_log_pool; eauto.
Qed.
End INV.
Definition pcvop_fresh : compatlayer (cdata RData) :=
ipc_send_body ↦ gensem ipc_send_body_spec
⊕ ipc_receive_body ↦ gensem ipc_receive_body_spec
⊕ fifobbq_pool_init ↦ gensem fifobbq_pool_init_spec.
Section RECEIVE.
Lemma page_copy_back_high_level_inv:
∀ d d´ chid cound addr,
page_copy_back_spec chid cound addr d = Some d´
→ high_level_invariant d
→ high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0.
constructor; simpl; intros;
try eapply dirty_ppage_gss_page_copy_back; eauto.
Qed.
Lemma page_copy_back_low_level_inv:
∀ d d´ chid cound addr n,
page_copy_back_spec chid cound addr d = Some d´
→ low_level_invariant n d
→ low_level_invariant n d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0. constructor; eauto 2.
Qed.
Lemma page_copy_back_kernel_mode:
∀ d d´ chid cound addr,
page_copy_back_spec chid cound addr d = Some d´
→ kernel_mode d
→ kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
Qed.
Lemma ipc_receive_body_high_level_inv:
∀ fromid vaddr count d d´ n,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_high_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2; simpl; intros.
Qed.
Lemma ipc_receive_body_low_level_inv:
∀ fromid vaddr count d d´ n n´,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_low_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2.
Qed.
Lemma ipc_receive_body_kernel_mode:
∀ fromid vaddr count d d´ n,
ipc_receive_body_spec fromid vaddr count d = Some (d´, n) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_back_kernel_mode; eauto.
Qed.
Global Instance ipc_receive_body_inv: PreservesInvariants ipc_receive_body_spec.
Proof.
preserves_invariants_simpl´.
- eapply ipc_receive_body_low_level_inv; eassumption.
- eapply ipc_receive_body_high_level_inv; eassumption.
- eapply ipc_receive_body_kernel_mode; eassumption.
Qed.
End RECEIVE.
Section SEND.
Lemma page_copy_high_level_inv:
∀ d d´ chid cound addr,
page_copy_spec chid cound addr d = Some d´
→ high_level_invariant d
→ high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0.
constructor; simpl; intros; eauto.
- eapply consistent_ppage_log_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply LATCTable_log_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply valid_hlock_pool1_gss´; eauto.
- eapply valid_AT_log_pool_H_gso; eauto.
eapply Shared2ID2_neq; eauto.
reflexivity.
- eapply valid_ABTCB_log_pool_gso´; eauto.
reflexivity.
Qed.
Lemma page_copy_low_level_inv:
∀ d d´ chid cound addr n,
page_copy_spec chid cound addr d = Some d´
→ low_level_invariant n d
→ low_level_invariant n d´.
Proof.
intros. functional inversion H; subst; eauto.
inv H0. constructor; eauto 2.
Qed.
Lemma page_copy_kernel_mode:
∀ d d´ chid cound addr,
page_copy_spec chid cound addr d = Some d´
→ kernel_mode d
→ kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
Qed.
Lemma ipc_send_body_high_level_inv:
∀ fromid vaddr count d d´ n,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
high_level_invariant d →
high_level_invariant d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_high_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2; simpl; intros.
Qed.
Lemma ipc_send_body_low_level_inv:
∀ fromid vaddr count d d´ n n´,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
low_level_invariant n´ d →
low_level_invariant n´ d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_low_level_inv; eauto.
intros Hh. inv Hh. constructor; eauto 2.
Qed.
Lemma ipc_send_body_kernel_mode:
∀ fromid vaddr count d d´ n,
ipc_send_body_spec fromid vaddr count d = Some (d´, n) →
kernel_mode d →
kernel_mode d´.
Proof.
intros. functional inversion H; subst; eauto.
exploit page_copy_kernel_mode; eauto.
Qed.
Global Instance ipc_send_body_inv: PreservesInvariants ipc_send_body_spec.
Proof.
preserves_invariants_simpl´.
- eapply ipc_send_body_low_level_inv; eassumption.
- eapply ipc_send_body_high_level_inv; eassumption.
- eapply ipc_send_body_kernel_mode; eassumption.
Qed.
End SEND.
Global Instance fifobbq_pool_init_inv: PreservesInvariants fifobbq_pool_init_spec.
Proof.
preserves_invariants_simpl low_level_invariant high_level_invariant.
- apply real_nps_range.
- apply AC_init_container_valid.
- rewrite init_pperm; [|try assumption].
apply real_pperm_log_valid.
- eapply real_pt_PMap_valid; eauto.
- apply real_pt_PMap_kern.
- omega.
- assumption.
- apply real_idpde_init.
- apply real_pt_weak_consistent_pmap.
- apply real_pt_consistent_pmap_domain.
- apply Lreal_at_consistent_lat_domain.
- eapply LATCTable_log_real; eauto.
- assumption.
- apply real_abtcb_range; auto.
- apply real_abq_range; auto.
- eapply real_abtcb_abq_QCount; eauto.
- eapply real_abq_tcb_inQ; eauto.
- assumption.
- eapply real_valid_hlock_pool1; eauto.
- assumption.
- eapply real_valid_AT_log_pool_H; eauto.
- assumption.
- eapply real_valid_ABTCB_log_pool; eauto.
Qed.
End INV.
Definition pcvop_fresh : compatlayer (cdata RData) :=
ipc_send_body ↦ gensem ipc_send_body_spec
⊕ ipc_receive_body ↦ gensem ipc_receive_body_spec
⊕ fifobbq_pool_init ↦ gensem fifobbq_pool_init_spec.
Definition pcvop_passthrough : compatlayer (cdata RData) :=
fload ↦ gensem fload_spec
⊕ fstore ↦ gensem fstore_spec
⊕ vmxinfo_get ↦ gensem vmxinfo_get_spec
⊕ palloc ↦ gensem palloc_spec
⊕ set_pt ↦ gensem setPT_spec
⊕ pt_read ↦ gensem ptRead_spec
⊕ pt_resv ↦ gensem ptResv_spec
⊕ kctxt_new ↦ dnew_compatsem ObjThread.kctxt_new_spec
⊕ shared_mem_status ↦ gensem shared_mem_status_spec
⊕ offer_shared_mem ↦ gensem offer_shared_mem_spec
⊕ get_state ↦ gensem get_state0_spec
⊕ set_state ↦ gensem set_state0_spec
⊕ tcb_get_CPU_ID ↦ gensem get_abtcb_CPU_ID_spec
⊕ tcb_set_CPU_ID ↦ gensem set_abtcb_CPU_ID_spec
⊕ enqueue ↦ gensem enqueue0_spec
⊕ dequeue ↦ gensem dequeue0_spec
⊕ enqueue_atomic ↦ gensem enqueue_atomic_spec
⊕ dequeue_atomic ↦ gensem dequeue_atomic_spec
⊕ pt_in ↦ primcall_general_compatsem´ ptin_spec (prim_ident:= pt_in)
⊕ pt_out ↦ primcall_general_compatsem´ ptout_spec (prim_ident:= pt_out)
⊕ container_get_nchildren ↦ gensem container_get_nchildren_spec
⊕ container_get_quota ↦ gensem container_get_quota_spec
⊕ container_get_usage ↦ gensem container_get_usage_spec
⊕ container_can_consume ↦ gensem container_can_consume_spec
⊕ get_CPU_ID ↦ gensem get_CPU_ID_spec
⊕ get_curid ↦ gensem get_curid_spec
⊕ set_curid ↦ gensem set_curid_spec
⊕ set_curid_init ↦ gensem set_curid_init_spec
⊕ sleeper_inc ↦ gensem sleeper_inc_spec
⊕ sleeper_dec ↦ gensem sleeper_dec_spec
⊕ sleeper_zzz ↦ gensem sleeper_zzz_spec
⊕ acquire_lock_CHAN ↦ gensem acquire_lock_SC_spec
⊕ release_lock_CHAN ↦ gensem release_lock_SC_spec
⊕ get_sync_chan_busy ↦ gensem get_sync_chan_busy_spec
⊕ set_sync_chan_busy ↦ gensem set_sync_chan_busy_spec
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_intr_disable ↦ gensem serial_intr_disable_spec
⊕ serial_intr_enable ↦ gensem serial_intr_enable_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ cons_buf_read ↦ gensem cons_buf_read_spec
⊕ trap_in ↦ primcall_general_compatsem trapin_spec
⊕ trap_out ↦ primcall_general_compatsem trapout_spec
⊕ host_in ↦ primcall_general_compatsem hostin_spec
⊕ host_out ↦ primcall_general_compatsem hostout_spec
⊕ proc_create_postinit ↦ gensem proc_create_postinit_spec
⊕ trap_get ↦ primcall_trap_info_get_compatsem trap_info_get_spec
⊕ trap_set ↦ primcall_trap_info_ret_compatsem trap_info_ret_spec
⊕ kctxt_switch ↦ primcall_kctxt_switch_compatsem kctxt_switch_spec
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd) |}.
Definition pcvop : compatlayer (cdata RData) := pcvop_fresh ⊕ pcvop_passthrough.
End WITHMEM.
fload ↦ gensem fload_spec
⊕ fstore ↦ gensem fstore_spec
⊕ vmxinfo_get ↦ gensem vmxinfo_get_spec
⊕ palloc ↦ gensem palloc_spec
⊕ set_pt ↦ gensem setPT_spec
⊕ pt_read ↦ gensem ptRead_spec
⊕ pt_resv ↦ gensem ptResv_spec
⊕ kctxt_new ↦ dnew_compatsem ObjThread.kctxt_new_spec
⊕ shared_mem_status ↦ gensem shared_mem_status_spec
⊕ offer_shared_mem ↦ gensem offer_shared_mem_spec
⊕ get_state ↦ gensem get_state0_spec
⊕ set_state ↦ gensem set_state0_spec
⊕ tcb_get_CPU_ID ↦ gensem get_abtcb_CPU_ID_spec
⊕ tcb_set_CPU_ID ↦ gensem set_abtcb_CPU_ID_spec
⊕ enqueue ↦ gensem enqueue0_spec
⊕ dequeue ↦ gensem dequeue0_spec
⊕ enqueue_atomic ↦ gensem enqueue_atomic_spec
⊕ dequeue_atomic ↦ gensem dequeue_atomic_spec
⊕ pt_in ↦ primcall_general_compatsem´ ptin_spec (prim_ident:= pt_in)
⊕ pt_out ↦ primcall_general_compatsem´ ptout_spec (prim_ident:= pt_out)
⊕ container_get_nchildren ↦ gensem container_get_nchildren_spec
⊕ container_get_quota ↦ gensem container_get_quota_spec
⊕ container_get_usage ↦ gensem container_get_usage_spec
⊕ container_can_consume ↦ gensem container_can_consume_spec
⊕ get_CPU_ID ↦ gensem get_CPU_ID_spec
⊕ get_curid ↦ gensem get_curid_spec
⊕ set_curid ↦ gensem set_curid_spec
⊕ set_curid_init ↦ gensem set_curid_init_spec
⊕ sleeper_inc ↦ gensem sleeper_inc_spec
⊕ sleeper_dec ↦ gensem sleeper_dec_spec
⊕ sleeper_zzz ↦ gensem sleeper_zzz_spec
⊕ acquire_lock_CHAN ↦ gensem acquire_lock_SC_spec
⊕ release_lock_CHAN ↦ gensem release_lock_SC_spec
⊕ get_sync_chan_busy ↦ gensem get_sync_chan_busy_spec
⊕ set_sync_chan_busy ↦ gensem set_sync_chan_busy_spec
⊕ cli ↦ gensem cli_spec
⊕ sti ↦ gensem sti_spec
⊕ serial_intr_disable ↦ gensem serial_intr_disable_spec
⊕ serial_intr_enable ↦ gensem serial_intr_enable_spec
⊕ serial_putc ↦ gensem serial_putc_spec
⊕ cons_buf_read ↦ gensem cons_buf_read_spec
⊕ trap_in ↦ primcall_general_compatsem trapin_spec
⊕ trap_out ↦ primcall_general_compatsem trapout_spec
⊕ host_in ↦ primcall_general_compatsem hostin_spec
⊕ host_out ↦ primcall_general_compatsem hostout_spec
⊕ proc_create_postinit ↦ gensem proc_create_postinit_spec
⊕ trap_get ↦ primcall_trap_info_get_compatsem trap_info_get_spec
⊕ trap_set ↦ primcall_trap_info_ret_compatsem trap_info_ret_spec
⊕ kctxt_switch ↦ primcall_kctxt_switch_compatsem kctxt_switch_spec
⊕ accessors ↦ {| exec_load := (@exec_loadex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd);
exec_store := (@exec_storeex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd) |}.
Definition pcvop : compatlayer (cdata RData) := pcvop_fresh ⊕ pcvop_passthrough.
End WITHMEM.