@@ -809,17 +809,38 @@ Module TLB.
809809 #[export] Typeclasses Transparent Ctxt.t.
810810
811811 Module Entry.
812- Definition t (lvl : Level) := vec val (S lvl).
813- Definition pte {lvl} (tlbe : t lvl) := Vector.last tlbe.
812+ Record t (lvl : Level) :=
813+ make {
814+ val_ttbr : val;
815+ ptes : vec val (S lvl);
816+ }.
817+ Arguments make {_} _ _.
818+ Arguments val_ttbr {_}.
819+ Arguments ptes {_}.
820+
821+ #[global] Instance eq_dec lvl : EqDecision (t lvl).
822+ Proof . solve_decision. Defined .
823+
824+ #[global] Instance eqdep_dec : EqDepDecision t.
825+ Proof . intros ? ? ? [] []. decide_jmeq. Defined .
826+
827+ #[global] Instance count lvl : Countable (t lvl).
828+ Proof .
829+ eapply (inj_countable' (fun ent => (val_ttbr ent, ptes ent))
830+ (fun x => make x.1 x.2)).
831+ abstract sauto.
832+ Defined .
833+
834+ Definition pte {lvl} (tlbe : t lvl) := Vector.last tlbe.(ptes).
814835
815836 Program Definition append {lvl clvl : Level}
816837 (tlbe : t lvl)
817838 (pte : val)
818839 (CHILD : lvl + 1 = clvl) : t clvl :=
819- ctrans _ (tlbe +++ [#pte]).
840+ make tlbe.(val_ttbr) ( ctrans _ (tlbe.(ptes) +++ [#pte]) ).
820841 Solve All Obligations with lia.
821842 End Entry.
822- #[export] Typeclasses Transparent Entry.t .
843+ Export (hints) Entry.
823844
824845 (* Full Entry *)
825846 Module FE.
@@ -949,7 +970,8 @@ Module TLB.
949970 let asid := bv_extract 48 16 val_ttbr in
950971 let ndctxt := NDCtxt.make va (Some asid) in
951972 let ctxt := existT root_lvl ndctxt in
952- let entry : Entry.t (Ctxt.lvl ctxt) := [#memval] in
973+ let entry : Entry.t (Ctxt.lvl ctxt) :=
974+ Entry.make val_ttbr ([#memval] : vec val (S root_lvl)) in
953975 (* add the entry to vatlb only when it is not in the original vatlb *)
954976 if decide (entry ∉ (VATLB.get ctxt vatlb)) then
955977 Ok (VATLB.add ctxt entry vatlb, true)
@@ -973,8 +995,8 @@ Module TLB.
973995 (te : Entry.t (Ctxt.lvl ctxt))
974996 (index : bv 9)
975997 (ttbr : reg) : result string (VATLB.t * bool) :=
976- guard_or "ASID is not active"
977- $ is_active_asid ts (Ctxt.asid ctxt) ttbr time;;
998+ (* guard_or "ASID is not active"
999+ $ is_active_asid ts (Ctxt.asid ctxt) ttbr time;; *)
9781000 guard_or "The translation entry is not in the TLB"
9791001 (te ∈ VATLB.get ctxt vatlb);;
9801002
@@ -1201,7 +1223,7 @@ Module TLB.
12011223 else filter (λ te, is_block (TLB.Entry.pte te)) tes in
12021224 for te in (elements tes) do
12031225 ti ← invalidation_time mem tid trans_time ctxt te;
1204- mret ((vec_to_list te ), ti)
1226+ mret ((vec_to_list (Entry.ptes te) ), ti)
12051227 end .
12061228
12071229 (** Get all the TLB entries that could translate the given VA
@@ -1263,7 +1285,7 @@ Module TLB.
12631285 if decide (is_valid memval) then mret None
12641286 else
12651287 ti ← invalidation_time mem tid trans_time ctxt te;
1266- mret $ Some ((vec_to_list te ) ++ [memval], ti)
1288+ mret $ Some ((vec_to_list (Entry.ptes te) ) ++ [memval], ti)
12671289 else
12681290 mthrow "The PTE is missing"
12691291 end ;
@@ -1298,9 +1320,11 @@ Module TLB.
12981320 (va : bv 64) (asid : bv 16)
12991321 (ttbr : reg) : result string (list (list val * (option nat))) :=
13001322 candidates_asid ←
1301- get_invalid_ptes_with_inv_time_by_lvl_asid ts init mem tid tlb trans_time lvl va (Some asid) ttbr;
1323+ get_invalid_ptes_with_inv_time_by_lvl_asid
1324+ ts init mem tid tlb trans_time lvl va (Some asid) ttbr;
13021325 candidates_global ←
1303- get_invalid_ptes_with_inv_time_by_lvl_asid ts init mem tid tlb trans_time lvl va None ttbr;
1326+ get_invalid_ptes_with_inv_time_by_lvl_asid
1327+ ts init mem tid tlb trans_time lvl va None ttbr;
13041328 mret (candidates_asid ++ candidates_global).
13051329
13061330 Definition get_invalid_ptes_with_inv_time (ts : TState.t) (init : Memory.initial)
@@ -1741,7 +1765,9 @@ Definition get_invalid_entries_from_snapshots (snapshots : list (TLB.t * nat))
17411765 if decide (is_ets2 ∧ trans_time < ts.(TState.vwr) ⊔ ts.(TState.vrd)) then
17421766 entries
17431767 else
1744- candidates ← TLB.get_invalid_ptes_with_inv_time ts init mem tid tlb trans_time va asid ttbr;
1768+ candidates ←
1769+ TLB.get_invalid_ptes_with_inv_time
1770+ ts init mem tid tlb trans_time va asid ttbr;
17451771 prev ←@{result string} entries;
17461772 let new :=
17471773 omap (λ '(path, ti_opt),
@@ -1771,8 +1797,10 @@ Definition run_trans_start (trans_start : TranslationStartInfo)
17711797 trans_res ←
17721798 if decide (va_in_range va) then
17731799 ttbr ← mlift $ ttbr_of_regime va trans_start.(TranslationStartInfo_regime);
1774- snapshots ← mlift $ TLB.unique_snapshots_until_timestamp ts init mem vmax_t va ttbr;
1775- valid_entries ← mlift $ get_valid_entries_from_snapshots snapshots mem tid va asid;
1800+ snapshots ← mlift $
1801+ TLB.unique_snapshots_until_timestamp ts init mem vmax_t va ttbr;
1802+ valid_entries ← mlift $
1803+ get_valid_entries_from_snapshots snapshots mem tid va asid;
17761804 invalid_entries ← mlift $
17771805 get_invalid_entries_from_snapshots snapshots ts init mem tid is_ets2 va asid ttbr;
17781806 (* update IIS with either a valid translation result or a fault *)
@@ -1847,8 +1875,8 @@ Definition run_take_exception (fault : exn) (vmax_t : view) :
18471875
18481876(** Runs an outcome. *)
18491877Section RunOutcome.
1850- Context (tid : nat) (initmem : memoryMap).
18511878
1879+ Context (tid : nat) (initmem : memoryMap).
18521880 Equations run_outcome (out : outcome) (mem_update : bool) :
18531881 Exec.t (PPState.t TState.t Ev.t IIS.t) string (eff_ret out * option view) :=
18541882 | RegRead reg racc, mem_update =>
0 commit comments