Library mcertikos.mm.MPTInit


This file defines the abstract data and the primitives for the MPTInit layer, which will initialize the page tables and enable the paging mechanism
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 Export ObjCPU.
Require Export ObjFlatMem.
Require Export ObjContainer.
Require Export ObjPMM.
Require Export ObjVMM.
Require Export ObjLMM.
Require Export ObjMultiprocessor.

Require Import INVLemmaQLock.
Require Import INVLemmaInterrupt.
Require Import INVLemmaDriver.
Require Import DeviceStateDataType.
Require Import FutureTactic.
Require Export ObjMultiprocessor.
Require Export ObjQLock.
Require Export ObjInterruptManagement.
Require Export ObjInterruptController.
Require Export ObjConsole.
Require Export ObjSerialDriver.

Section WITHMEM.

  Local Open Scope Z_scope.

  Context `{oracle_prop: MultiOracleProp}.
  Context `{real_params: RealParams}.

  Definition LATC_valid (a: LATCTable) (nps: Z) :=
     i, 0 i < nps
              → l, ZMap.get i a = LATCValid l.

  Lemma real_latc_valid:
     AT, LATC_valid (real_LAT AT) real_nps.
  Proof.
    generalize real_nps_range; intro.
    unfold LATC_valid.
    intros.
    specialize (cal_lat_correct´ (real_nps-1 -i)).
    intros.
    assert(0 real_nps - 1 - i) by omega.
    unfold real_LAT.
    specialize (H1 H2).
    unfold Cal_lat_Well in H1.
    assert(Hrange1: 0 i) by omega.
    assert(Hrange2: i i real_nps - 1) by omega.
    specialize (H1 i (real_nps -1) i real_nps AT Hrange1 Hrange2 refl_equal).
    rewrite <- H1.
    clear H1.
    case_eq (Z.to_nat i).
    - simpl. intros.
      assert(HI: i = 0).
      {
        case_eq (Z_eq_dec i 0).
        intros.
        trivial.
        intros.
        assert(HI: 0< i).
        omega.
        specialize (Z2Nat.inj_lt 0 i).
        intros.
        assert(HI1: 00).
        omega.
        assert(HI2:0i).
        omega.
        specialize (H4 HI1 HI2).
        inv H4.
        specialize (H5 HI).
        rewrite H1 in H5.
        change (0%nat) with (Z.to_nat 0) in H1.
        apply Z2Nat.inj in H1.
        assumption.
        omega.
        omega.
      }
      subst i.
      rewrite ZMap.gss. eauto.
    - intros.
      Local Opaque Z.of_nat. simpl.
      rewrite <- H1.
      rewrite Z2Nat.id; try omega.
      rewrite ZMap.gss. eauto.
  Qed.

  Local Transparent Z.of_nat.

Invariants at this layer

0th page map is reserved for the kernel thread
  Record high_level_invariant (abd: RData) :=
    mkInvariant {
        CPU_ID_range: 0 (CPU_ID abd) < TOTAL_CPU;
        valid_curid: 0 ZMap.get (CPU_ID abd) (cid abd) < num_proc;
        valid_nps: pg abd = truekern_low nps abd maxpage;
        valid_AT_valid: pg abd = trueLATC_valid (LAT abd) (nps abd);
        
        valid_kern: ipt abd = falsepg abd = true;
        valid_iptt: ipt abd = trueikern abd = true;
        valid_iptf: ikern abd = falseipt abd = false;
        valid_ihost: ihost abd = falsepg abd = true ikern abd = true;
        valid_container: Container_valid (AC abd);
        valid_pperm_ppage: consistent_ppage_log (multi_log abd) (pperm abd) (nps abd);
        init_pperm: pg abd = false(pperm abd) = ZMap.init PGUndef;
        valid_PMap: pg abd = true
                    ( i, 0 i < num_proc
                               PMap_valid (ZMap.get i (ptpool abd)));
        
        valid_PT_kern: pg abd = trueipt abd = true(PT abd) = 0;
        valid_PMap_kern: pg abd = truePMap_kern (ZMap.get 0 (ptpool abd));
        valid_PT: pg abd = true → 0 PT abd < num_proc;
        valid_dirty: dirty_ppage (pperm abd) (HP abd);

        valid_idpde: pg abd = trueIDPDE_init (idpde abd);
        valid_pperm_pmap: weak_consistent_pmap (ptpool abd) (pperm abd) (LAT abd) (nps abd);
        valid_pmap_domain: consistent_pmap_domain (ptpool abd) (pperm abd) (LAT abd) (nps abd);
        valid_lat_domain: consistent_lat_domain (ptpool abd) (LAT abd) (nps abd);
        valid_LATable_nil: LATCTable_log (multi_log abd) (LAT abd);
        valid_pg_init: pg abd = init abd;

        valid_multi_oracle_pool_inv: valid_multi_oracle_pool_H1 (multi_oracle abd);
        valid_hlock_pool_inv: valid_hlock_pool1 (multi_log abd);
        valid_AT_oracle_pool_inv: valid_AT_oracle_pool_H (multi_oracle abd);
        valid_AT_log_pool_inv: valid_AT_log_pool_H (multi_log abd);

        valid_cons_buf_rpos: 0 rpos (console abd) < CONSOLE_BUFFER_SIZE;
        valid_cons_buf_length: 0 Zlength (cons_buf (console abd)) < CONSOLE_BUFFER_SIZE

      }.

Definition of the abstract state ops

  Global Instance mptinit_data_ops : CompatDataOps RData :=
    {
      empty_data := init_adt multi_oracle_init3;
      high_level_invariant := high_level_invariant;
      low_level_invariant := low_level_invariant;
      kernel_mode adt := ikern adt = true ihost adt = true
    }.

Proofs that the initial abstract_data should satisfy the invariants

  Section Property_Abstract_Data.

    Lemma empty_data_high_level_invariant:
      high_level_invariant (init_adt multi_oracle_init3).
    Proof.
      constructor; simpl; intros; auto; try inv H.
      - apply current_CPU_ID_range.
      - rewrite ZMap.gi; intuition.
      - apply empty_container_valid.
      - eapply consistent_ppage_log_init.
      - eapply dirty_ppage_init.
      - eapply weak_consistent_pmap_init.
      - eapply consistent_pmap_domain_init.
      - eapply consistent_lat_domain_init.
      - eapply LATCTable_log_init.
      - eapply valid_ticket_oracle3.
      - apply valid_hlock_pool_init1.
      - apply valid_AT_oracle_pool3.
      - eapply valid_AT_log_pool_H_init.
    Qed.

  End Property_Abstract_Data.

Definition of the abstract state

  Global Instance mptinit_data_prf : CompatData RData.
  Proof.
    constructor.
    - apply low_level_invariant_incr.
    - apply empty_data_low_level_invariant.
    - apply empty_data_high_level_invariant.
  Qed.

  Context `{Hstencil: Stencil}.
  Context `{Hmem: Mem.MemoryModelX}.
  Context `{Hmwd: UseMemWithData mem}.

Proofs that the primitives satisfies the invariants at this layer

  Section INV.

    Global Instance cli_inv: PreservesInvariants cli_spec.
    Proof.
      preserves_invariants_direct low_level_invariant high_level_invariant; eauto 2.
    Qed.

    Global Instance sti_inv: PreservesInvariants sti_spec.
    Proof.
      preserves_invariants_direct low_level_invariant high_level_invariant; eauto 2.
    Qed.

    Global Instance cons_buf_read_inv:
      PreservesInvariants cons_buf_read_spec.
    Proof.
      preserves_invariants_nested low_level_invariant high_level_invariant; eauto 2.
    Qed.

    Global Instance serial_putc_inv:
      PreservesInvariants serial_putc_spec.
    Proof.
      preserves_invariants_simpl_auto.
    Qed.

    Global Instance serial_intr_disable_inv: PreservesInvariants serial_intr_disable_spec.
    Proof.
      constructor; simpl; intros; inv_generic_sem H.
      - inversion H0; econstructor; eauto 2 with serial_intr_disable_invariantdb.
        generalize (serial_intr_disable_preserves_tf _ _ H2); intro tmprw; rewrite <- tmprw; assumption.
      - inversion H0; econstructor; eauto with serial_intr_disable_invariantdb; rest.
      - eauto 2 with serial_intr_disable_invariantdb.
   Qed.

    Global Instance serial_intr_enable_inv:
      PreservesInvariants serial_intr_enable_spec.
    Proof.
      constructor; simpl; intros; inv_generic_sem H.
      - inversion H0; econstructor; eauto 2 with serial_intr_enable_invariantdb.
        generalize (serial_intr_enable_preserves_tf _ _ H2); intro tmprw; rewrite <- tmprw; assumption.
      - inversion H0; econstructor; eauto 2 with serial_intr_enable_invariantdb; rest.
      - eauto 2 with serial_intr_enable_invariantdb.
    Qed.

    Global Instance set_curid_inv: PreservesInvariants set_curid_spec.
    Proof.
      preserves_invariants_simpl_auto.
      rewrite ZMap.gss; eauto.
    Qed.

    Global Instance set_curid_init_inv: PreservesInvariants set_curid_init_spec.
    Proof.
      preserves_invariants_simpl_auto; eauto 2.
      case_eq (zeq (CPU_ID d) (Int.unsigned i)); intros; subst.
      - rewrite e; rewrite ZMap.gss; omega.
      - rewrite ZMap.gso; auto.
    Qed.

    Global Instance release_lock_inv: ReleaseInvariants release_lock_spec1.
    Proof.
      constructor; unfold release_lock_spec; intros; subdestruct;
      inv H; inv H0; constructor; auto; simpl; intros.
      - eapply consistent_ppage_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
      - eapply LATCTable_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
      - eapply valid_hlock_pool1_gss´; eauto.
      - eapply valid_AT_log_pool_H_gso; eauto.
        eapply Shared2ID1_neq; eauto.
    Qed.

    Global Instance acquire_lock_inv: AcquireInvariants acquire_lock_spec1.
    Proof.
      constructor; unfold acquire_lock_spec; intros; subdestruct;
      inv H; inv H0; constructor; auto; simpl; intros.
      - eapply consistent_ppage_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
      - eapply LATCTable_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
      - eapply valid_hlock_pool1_gss´; eauto.
      - eapply valid_AT_log_pool_H_gso; eauto.
        eapply Shared2ID1_neq; eauto.
    Qed.


    Section PALLOC.


      Lemma LATC_valid_gss:
         a np l n,
          LATC_valid a np
          LATC_valid (ZMap.set n (LATCValid l) a) np.
      Proof.
        unfold LATC_valid; intros.
        destruct (zeq i n); subst.
        - rewrite ZMap.gss. eauto.
        - rewrite ZMap.gso; eauto.
      Qed.

      Lemma palloc_high_level_inv:
         d i n,
          palloc_spec i d = Some (, n)
          high_level_invariant d
          high_level_invariant .
      Proof.
        unfold palloc_spec; intros.
        subdestruct; inv H; subst; eauto;
        inv H0; constructor; simpl; eauto; intros.
        + eapply LATC_valid_gss; eauto.
        + rewrite <- Hdestruct3.
          eapply alloc_container_valid´; eauto.
        + eapply consistent_ppage_log_norm_alloc; eauto. omega.
        + subst; simpl;
          intros; congruence.
        + eapply dirty_ppage_gso_alloc; eauto.
        + eapply (weak_consistent_pmap_gso_at_palloc n); eauto; try apply a0.
        + eapply consistent_pmap_domain_gso_at; eauto.
          intros. intro HF.
          exploit (LATCTable_log_gss (ZMap.get 0 (multi_oracle d) (CPU_ID d) l) _ _ _
                                        valid_LATable_nil0 Hdestruct6); eauto.
          × rewrite ZMap.gss. trivial.
          × eapply a0.
        + eapply consistent_lat_domain_gss_nil; eauto.
        + eapply LATCTable_log_alloc´; eauto.
        + eapply valid_hlock_pool1_gso; eauto.
        + eapply valid_AT_log_pool_H_n; eauto.
          eapply a0.
        + rewrite app_comm_cons.
          eapply consistent_ppage_log_gss; eauto.
        + eapply LATCTable_log_alloc; eauto.
        + eapply valid_hlock_pool1_gso; eauto.
        + eapply valid_AT_log_pool_H_0; eauto.
        + rewrite app_comm_cons.
          eapply consistent_ppage_log_gss; eauto.
        + eapply LATCTable_log_alloc; eauto.
        + eapply valid_hlock_pool1_gso; eauto.
        + eapply valid_AT_log_pool_H_0´; eauto.
      Qed.


      Lemma palloc_low_level_inv:
         d i n ,
          palloc_spec i d = Some (, n)
          low_level_invariant d
          low_level_invariant .
      Proof.
        unfold palloc_spec; intros.
        subdestruct; inv H; subst; eauto;
        inv H0; constructor; eauto.
      Qed.


      Lemma palloc_kernel_mode:
         d i n,
          palloc_spec i d = Some (, n)
          kernel_mode d
          kernel_mode .
      Proof.
        unfold palloc_spec; intros.
        subdestruct; inv H; simpl; eauto.
      Qed.

      Global Instance palloc_inv: PreservesInvariants palloc_spec.
      Proof.
        preserves_invariants_simpl´.
        - eapply palloc_low_level_inv; eassumption.
        - eapply palloc_high_level_inv; eassumption.
        - eapply palloc_kernel_mode; eassumption.
      Qed.

    End PALLOC.


    Global Instance container_split_inv: PreservesInvariants container_split_spec.
    Proof.
      preserves_invariants_simpl_auto.
      rewrite <- H1 in H0.
      exploit split_container_valid; eauto.
    Qed.

    Global Instance trapin_inv: PrimInvariants trapin_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance trapout_inv: PrimInvariants trapout_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance hostin_inv: PrimInvariants hostin_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance hostout_inv: PrimInvariants hostout_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance ptin_inv: PrimInvariants ptin_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance ptout_inv: PrimInvariants ptout_spec.
    Proof.
      PrimInvariants_simpl_auto.
    Qed.

    Global Instance fstore_inv: PreservesInvariants fstore_spec.
    Proof.
      split; intros; inv_generic_sem H; inv H0; functional inversion H2.
      - functional inversion H. split; trivial.
      - functional inversion H.
        split; subst; simpl;
        try (eapply dirty_ppage_store_unmaped; try reflexivity; try eassumption); trivial.
      - functional inversion H0.
        split; simpl; try assumption.
    Qed.

    Global Instance setPT_inv: PreservesInvariants setPT_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant; auto.
    Qed.

    Global Instance pt_init_inv: PreservesInvariants pt_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_pperm0; [|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.

    Global Instance ptRmv_inv: PreservesInvariants ptRmv0_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant; eauto;
      try (rewrite ZMap.gso; eauto; fail).
      - eapply LATC_valid_gss; eauto.
      - eapply PMap_valid_gso_unp; eauto.
      - functional inversion H1.
        eapply PMap_kern_gso; eauto.
      - functional inversion H1.
        eapply weak_consistent_pmap_at_ptp_same; try eassumption; omega.
      - eapply consistent_pmap_domain_remove; eauto.
      - functional inversion H1.
        eapply consistent_lat_domain_gss_remove; eauto; omega.
      - eapply LATCTable_log_nil_gso; eauto.
        intro HF; subst. simpl in _x1. omega.
    Qed.

    Section PTINSERT.

      Section PTINSERT_PTE.

        Lemma ptInsertPTE_high_level_inv:
           d n vadr padr p,
            ptInsertPTE0_spec n vadr padr p d = Some
            high_level_invariant d
            high_level_invariant .
        Proof.
          intros. functional inversion H; subst; eauto.
          inv H0; constructor_gso_simpl_tac; intros.
          - eapply LATC_valid_gss; eauto.
          - eapply PMap_valid_gso_valid; eauto.
          - functional inversion H2. functional inversion H1.
            eapply PMap_kern_gso; eauto.
          - functional inversion H2. functional inversion H0.
            eapply weak_consistent_pmap_ptp_same; try eassumption.
            eapply weak_consistent_pmap_gso_pperm_alloc´; eassumption.
          - functional inversion H2.
            eapply consistent_pmap_domain_append; eauto.
            destruct (ZMap.get pti pdt); try contradiction;
            red; intros (v0 & p0 & He); contra_inv.
          - eapply consistent_lat_domain_gss_append; eauto.
            subst pti; destruct (ZMap.get (PTX vadr) pdt); try contradiction;
            red; intros (v0 & p0 & He); contra_inv.
          - eapply LATCTable_log_not_nil_gso_true; eauto.
            functional inversion H2. omega.
        Qed.

        Lemma ptInsertPTE_low_level_inv:
           d n vadr padr p ,
            ptInsertPTE0_spec n vadr padr p d = Some
            low_level_invariant d
            low_level_invariant .
        Proof.
          intros. functional inversion H; subst; eauto.
          inv H0. constructor; eauto.
        Qed.

        Lemma ptInsertPTE_kernel_mode:
           d n vadr padr p,
            ptInsertPTE0_spec n vadr padr p d = Some
            kernel_mode d
            kernel_mode .
        Proof.
          intros. functional inversion H; subst; eauto.
        Qed.

      End PTINSERT_PTE.

      Section PTPALLOCPDE.

        Lemma ptAllocPDE_high_level_inv:
           d n vadr v,
            ptAllocPDE0_spec n vadr d = Some (, v)
            high_level_invariant d
            high_level_invariant .
        Proof.
          intros. functional inversion H; subst; eauto.
          - eapply palloc_high_level_inv; eauto.
          - exploit palloc_high_level_inv; eauto.
            intros.
            exploit palloc_inv_prop; eauto. intros (HPT & Halloc & Hpg).
            clear H11.
            rewrite <- HPT in ×.
            inv H1; constructor_gso_simpl_tac; try (intros; congruence); intros.
            + apply consistent_ppage_log_alloc_hide; eauto.
              eapply Halloc; eauto.
            + eapply PMap_valid_gso_pde_unp; eauto.
              eapply real_init_PTE_defined.
            + functional inversion H3.
              eapply PMap_kern_gso; eauto.
            + eapply dirty_ppage_gss; eauto.
            + eapply weak_consistent_pmap_ptp_gss0; eauto; apply Halloc; eauto.
            + eapply consistent_pmap_domain_gso_at_00; eauto; try apply Halloc; eauto.
              eapply consistent_pmap_domain_ptp_unp; eauto.
              apply real_init_PTE_unp.
            + apply consistent_lat_domain_gso_p; eauto.
        Qed.

        Lemma ptAllocPDE_low_level_inv:
           d n vadr v ,
            ptAllocPDE0_spec n vadr d = Some (, v)
            low_level_invariant d
            low_level_invariant .
        Proof.
          intros. functional inversion H; subst; eauto.
          - eapply palloc_low_level_inv; eauto.
          - exploit palloc_low_level_inv; eauto.
            intros. inv H1. constructor; eauto.
        Qed.

        Lemma ptAllocPDE_kernel_mode:
           d n vadr v,
            ptAllocPDE0_spec n vadr d = Some (, v)
            kernel_mode d
            kernel_mode .
        Proof.
          intros. functional inversion H; subst; eauto.
          - eapply palloc_kernel_mode; eauto.
          - exploit palloc_kernel_mode; eauto.
        Qed.

      End PTPALLOCPDE.

      Lemma ptInsert_high_level_inv:
         d n vadr padr p v,
          ptInsert0_spec n vadr padr p d = Some (, v)
          high_level_invariant d
          high_level_invariant .
      Proof.
        intros. functional inversion H; subst; eauto.
        - eapply ptInsertPTE_high_level_inv; eassumption.
        - eapply ptAllocPDE_high_level_inv; eassumption.
        - eapply ptInsertPTE_high_level_inv; try eassumption.
          eapply ptAllocPDE_high_level_inv; eassumption.
      Qed.

      Lemma ptInsert_low_level_inv:
         d n vadr padr p v,
          ptInsert0_spec n vadr padr p d = Some (, v)
          low_level_invariant d
          low_level_invariant .
      Proof.
        intros. functional inversion H; subst; eauto.
        - eapply ptInsertPTE_low_level_inv; eassumption.
        - eapply ptAllocPDE_low_level_inv; eassumption.
        - eapply ptInsertPTE_low_level_inv; try eassumption.
          eapply ptAllocPDE_low_level_inv; eassumption.
      Qed.

      Lemma ptInsert_kernel_mode:
         d n vadr padr p v,
          ptInsert0_spec n vadr padr p d = Some (, v)
          kernel_mode d
          kernel_mode .
      Proof.
        intros. functional inversion H; subst; eauto.
        - eapply ptInsertPTE_kernel_mode; eassumption.
        - eapply ptAllocPDE_kernel_mode; eassumption.
        - eapply ptInsertPTE_kernel_mode; try eassumption.
          eapply ptAllocPDE_kernel_mode; eassumption.
      Qed.

      Global Instance ptInsert_inv: PreservesInvariants ptInsert0_spec.
      Proof.
        preserves_invariants_simpl´.
        - eapply ptInsert_low_level_inv; eassumption.
        - eapply ptInsert_high_level_inv; eassumption.
        - eapply ptInsert_kernel_mode; eassumption.
      Qed.

    End PTINSERT.



    Global Instance page_copy_inv: PreservesInvariants page_copy_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant; eauto.
      - eapply consistent_ppage_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
        unfold Shared2ID1; reflexivity.
      - eapply LATCTable_log_gso; eauto.
        eapply Shared2ID1_neq; eauto.
        unfold Shared2ID1; reflexivity.
      - eapply valid_hlock_pool1_gss´; eauto.
      - eapply valid_AT_log_pool_H_gso; eauto.
        eapply Shared2ID1_neq; eauto.
        unfold Shared2ID1; reflexivity.
    Qed.

    Global Instance page_copy_back_inv: PreservesInvariants page_copy_back_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant;
      try eapply dirty_ppage_gss_page_copy_back; eauto.
    Qed.

    Global Instance proc_create_postinit_inv:
      PreservesInvariants proc_create_postinit_spec.
    Proof.
      preserves_invariants_simpl low_level_invariant high_level_invariant; eauto 2.
    Qed.

  End INV.

Specification of primitives that will be implemented at this layer

  Definition exec_loadex {F V} := exec_loadex2 (F := F) (V := V).

  Definition exec_storeex {F V} := exec_storeex2 (flatmem_store:= flatmem_store) (F := F) (V := V).

  Global Instance flatmem_store_inv: FlatmemStoreInvariant (flatmem_store:= flatmem_store).
  Proof.
    split; inversion 1; intros.
    - functional inversion H0. split; trivial.
    - functional inversion H1.
      split; simpl; try (eapply dirty_ppage_store_unmaped´; try reflexivity; try eassumption); trivial.
  Qed.

  Global Instance trapinfo_set_inv: TrapinfoSetInvariant.
  Proof.
    split; inversion 1; intros; constructor; auto.
  Qed.

Layer Definition

Layer Definition newly introduced

  Definition mptinit_fresh : compatlayer (cdata RData) :=
    pt_init gensem pt_init_spec.

Layer Definition passthrough

  Definition mptinit_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_insert gensem ptInsert0_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_parent gensem container_get_parent_spec
           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
           container_split gensem container_split_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; exec_store := @exec_storeex |}.

Layer Definition

  Definition mptinit : compatlayer (cdata RData) := mptinit_fresh mptinit_passthrough.

End WITHMEM.