Library mcertikos.mm.MPTNew


This file defines the abstract data and the primitives for the MPTNew layer, which will introduce the primitves to find and free a page table from the page table pool
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 INVLemmaContainer.
Require Import INVLemmaMemory.

Require Import AbstractDataType.

Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.

Require Export MPTInit.

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}.

  Section INV.

    Global Instance pt_new_inv: PreservesInvariants pt_new_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant; auto.
      - exploit split_container_valid; eauto.
    Qed.

    Global Instance pmap_init_inv: PreservesInvariants pmap_init_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant.
      - apply real_nps_range.
      - apply real_latc_valid.
      - 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.
      - eapply real_valid_hlock_pool1; eauto.
      - assumption.
      - eapply real_valid_AT_log_pool_H; eauto.
    Qed.

    Section PTRESV.

      Lemma ptResv_high_level_inv:
         d n vadr p v,
          ptResv_spec n vadr p d = Some (, v)
          high_level_invariant d
          high_level_invariant .
      Proof.
        intros. functional inversion H; subst; eauto; clear H.
        - eapply palloc_high_level_inv; eassumption.
        - eapply ptInsert_high_level_inv; try eassumption.
          eapply palloc_high_level_inv; eassumption.
      Qed.

      Lemma ptResv_low_level_inv:
         d n vadr p v,
          ptResv_spec n vadr p d = Some (, v)
          low_level_invariant d
          low_level_invariant .
      Proof.
        intros. functional inversion H; subst; eauto.
        eapply palloc_low_level_inv; eassumption.
        eapply ptInsert_low_level_inv; try eassumption.
        eapply palloc_low_level_inv; eassumption.
      Qed.

      Lemma ptResv_kernel_mode:
         d n vadr p v,
          ptResv_spec n vadr p d = Some (, v)
          kernel_mode d
          kernel_mode .
      Proof.
        intros. functional inversion H; subst; eauto.
        eapply palloc_kernel_mode; eassumption.
        eapply ptInsert_kernel_mode; try eassumption.
        eapply palloc_kernel_mode; eassumption.
      Qed.

      Global Instance ptResv_inv: PreservesInvariants ptResv_spec.
      Proof.
        preserves_invariants_simpl´.
        - eapply ptResv_low_level_inv; eassumption.
        - eapply ptResv_high_level_inv; eassumption.
        - eapply ptResv_kernel_mode; eassumption.
      Qed.

    End PTRESV.

    Section PTRESV2.

      Lemma ptResv2_high_level_inv:
         d n vadr p vadr´ v,
          ptResv2_spec n vadr p vadr´ d = Some (, v)
          high_level_invariant d
          high_level_invariant .
      Proof.
        intros; functional inversion H; subst; eauto; clear H.
        - eapply palloc_high_level_inv; eassumption.
        - eapply ptInsert_high_level_inv; try eassumption.
          eapply palloc_high_level_inv; eassumption.
        - eapply ptInsert_high_level_inv; try eassumption.
          eapply ptInsert_high_level_inv; try eassumption.
          eapply palloc_high_level_inv; eassumption.
      Qed.

      Lemma ptResv2_low_level_inv:
         d n vadr p vadr´ l v,
          ptResv2_spec n vadr p vadr´ d = Some (, v)
          low_level_invariant l d
          low_level_invariant l .
      Proof.
        intros; functional inversion H; subst; eauto.
        - eapply palloc_low_level_inv; eassumption.
        - eapply ptInsert_low_level_inv; try eassumption.
          eapply palloc_low_level_inv; eassumption.
        - eapply ptInsert_low_level_inv; try eassumption.
          eapply ptInsert_low_level_inv; try eassumption.
          eapply palloc_low_level_inv; eassumption.
      Qed.

      Lemma ptResv2_kernel_mode:
         d n vadr p vadr´ v,
          ptResv2_spec n vadr p vadr´ d = Some (, v)
          kernel_mode d
          kernel_mode .
      Proof.
        intros; functional inversion H; subst; eauto.
        - eapply palloc_kernel_mode; eassumption.
        - eapply ptInsert_kernel_mode; try eassumption.
          eapply palloc_kernel_mode; eassumption.
        - eapply ptInsert_kernel_mode; try eassumption.
          eapply ptInsert_kernel_mode; try eassumption.
          eapply palloc_kernel_mode; eassumption.
      Qed.

      Global Instance ptResv2_inv: PreservesInvariants ptResv2_spec.
      Proof.
        preserves_invariants_simpl´.
        - eapply ptResv2_low_level_inv; eassumption.
        - eapply ptResv2_high_level_inv; eassumption.
        - eapply ptResv2_kernel_mode; eassumption.
      Qed.

    End PTRESV2.

  End INV.

Layer Definition

Layer Definition newly introduced

  Definition mptnew_fresh : compatlayer (cdata RData) :=
    pt_resv gensem ptResv_spec
             pt_resv2 gensem ptResv2_spec
             pt_new gensem pt_new_spec
            
             pmap_init gensem pmap_init_spec.

Layer Definition passthrough

  Definition mptnew_passthrough : compatlayer (cdata RData) :=
    fload gensem fload_spec
           fstore gensem fstore_spec
          
           page_copy gensem page_copy_spec
           page_copy_back gensem page_copy_back_spec

           vmxinfo_get gensem vmxinfo_get_spec
           palloc gensem palloc_spec
          
           set_pt gensem setPT_spec
           pt_read gensem ptRead_spec
           pt_read_pde gensem ptReadPDE_spec
          
           pt_rmv gensem ptRmv0_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
           release_lock primcall_release_lock_compatsem release_lock release_lock_spec1
           acquire_lock primcall_acquire_lock_compatsem acquire_lock_spec1
          

           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
           accessors {| exec_load := (@exec_loadex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd);
                           exec_store := (@exec_storeex _ _ _ _ _ _ _ _ _ _ _ _ _ _ Hmwd) |}.

Layer Definition

  Definition mptnew : compatlayer (cdata RData) := mptnew_fresh mptnew_passthrough.

End WITHMEM.