effect
stringclasses
48 values
original_source_type
stringlengths
0
23k
opens_and_abbrevs
listlengths
2
92
isa_cross_project_example
bool
1 class
source_definition
stringlengths
9
57.9k
partial_definition
stringlengths
7
23.3k
is_div
bool
2 classes
is_type
null
is_proof
bool
2 classes
completed_definiton
stringlengths
1
250k
dependencies
dict
effect_flags
sequencelengths
0
2
ideal_premises
sequencelengths
0
236
mutual_with
sequencelengths
0
11
file_context
stringlengths
0
407k
interleaved
bool
1 class
is_simply_typed
bool
2 classes
file_name
stringlengths
5
48
vconfig
dict
is_simple_lemma
null
source_type
stringlengths
10
23k
proof_features
sequencelengths
0
1
name
stringlengths
8
95
source
dict
verbose_type
stringlengths
1
7.42k
source_range
dict
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
let get_snd_ocmp (o: ocmp) =
false
null
false
match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ocmp", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Prims.l_or" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_snd_ocmp : o: Vale.X64.Machine_Semantics_s.ocmp -> o2: Vale.X64.Machine_s.operand64 { Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) }
[]
Vale.X64.Machine_Semantics_s.get_snd_ocmp
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_Semantics_s.ocmp -> o2: Vale.X64.Machine_s.operand64 { Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) \/ Prims.op_Negation (OMem? o2 || OStack? o2) }
{ "end_col": 91, "end_line": 76, "start_col": 28, "start_line": 75 }
Prims.Tot
val eval_maddr (m: maddr) (s: machine_state) : int
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
val eval_maddr (m: maddr) (s: machine_state) : int let eval_maddr (m: maddr) (s: machine_state) : int =
false
null
false
match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.maddr", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.int", "Vale.X64.Machine_s.reg", "Prims.op_Addition", "Vale.X64.Machine_Semantics_s.eval_reg_int", "FStar.Mul.op_Star" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_maddr (m: maddr) (s: machine_state) : int
[]
Vale.X64.Machine_Semantics_s.eval_maddr
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.X64.Machine_s.maddr -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.int
{ "end_col": 101, "end_line": 99, "start_col": 2, "start_line": 96 }
Prims.Tot
val update_n (addr: int) (n: nat) (memTaint: memTaint_t) (t: taint) : Tot (m: memTaint_t { (forall i. {:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[ i ] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[ i ] == memTaint.[ i ])) }) (decreases n)
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t
val update_n (addr: int) (n: nat) (memTaint: memTaint_t) (t: taint) : Tot (m: memTaint_t { (forall i. {:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[ i ] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[ i ] == memTaint.[ i ])) }) (decreases n) let rec update_n (addr: int) (n: nat) (memTaint: memTaint_t) (t: taint) : Tot (m: memTaint_t { (forall i. {:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[ i ] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[ i ] == memTaint.[ i ])) }) (decreases n) =
false
null
false
if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[ addr ] <- t) t
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total", "" ]
[ "Prims.int", "Prims.nat", "Vale.Arch.HeapTypes_s.memTaint_t", "Vale.Arch.HeapTypes_s.taint", "Prims.op_Equality", "Prims.bool", "Vale.X64.Machine_Semantics_s.update_n", "Prims.op_Addition", "Prims.op_Subtraction", "Vale.X64.Machine_Semantics_s.op_String_Assignment", "Prims.l_Forall", "Prims.l_and", "Prims.l_imp", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.eq2", "Vale.X64.Machine_Semantics_s.op_String_Access", "Prims.l_or", "FStar.Map.sel" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_n (addr: int) (n: nat) (memTaint: memTaint_t) (t: taint) : Tot (m: memTaint_t { (forall i. {:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[ i ] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[ i ] == memTaint.[ i ])) }) (decreases n)
[ "recursion" ]
Vale.X64.Machine_Semantics_s.update_n
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
addr: Prims.int -> n: Prims.nat -> memTaint: Vale.Arch.HeapTypes_s.memTaint_t -> t: Vale.Arch.HeapTypes_s.taint -> Prims.Tot (m: Vale.Arch.HeapTypes_s.memTaint_t { forall (i: Prims.int). {:pattern FStar.Map.sel m i} (i >= addr /\ i < addr + n ==> m.[ i ] == t) /\ (i < addr \/ i >= addr + n ==> m.[ i ] == memTaint.[ i ]) })
{ "end_col": 59, "end_line": 165, "start_col": 2, "start_line": 164 }
Prims.Tot
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
let get_fst_ocmp (o: ocmp) =
false
null
false
match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ocmp", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Prims.l_or" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; }
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val get_fst_ocmp : o: Vale.X64.Machine_Semantics_s.ocmp -> o1: Vale.X64.Machine_s.operand64 { Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) }
[]
Vale.X64.Machine_Semantics_s.get_fst_ocmp
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_Semantics_s.ocmp -> o1: Vale.X64.Machine_s.operand64 { Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) \/ Prims.op_Negation (OMem? o1 || OStack? o1) }
{ "end_col": 91, "end_line": 73, "start_col": 28, "start_line": 72 }
Prims.Tot
val valid_ocmp (c: ocmp) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
val valid_ocmp (c: ocmp) (s: machine_state) : bool let valid_ocmp (c: ocmp) (s: machine_state) : bool =
false
null
false
match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ocmp", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Prims.op_AmpAmp", "Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_ocmp (c: ocmp) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_ocmp
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
c: Vale.X64.Machine_Semantics_s.ocmp -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 92, "end_line": 291, "start_col": 2, "start_line": 285 }
Prims.Tot
val valid_dst_operand128 (o: operand128) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
val valid_dst_operand128 (o: operand128) (s: machine_state) : bool let valid_dst_operand128 (o: operand128) (s: machine_state) : bool =
false
null
false
match o with | OConst _ -> false | OReg i -> true | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.MachineHeap_s.valid_addr128", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.valid_dst_stack128", "Vale.X64.Machine_Semantics_s.eval_reg_64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_dst_operand128 (o: operand128) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_dst_operand128
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand128 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 88, "end_line": 319, "start_col": 2, "start_line": 315 }
Prims.Tot
val valid_dst_operand64 (o: operand64) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
val valid_dst_operand64 (o: operand64) (s: machine_state) : bool let valid_dst_operand64 (o: operand64) (s: machine_state) : bool =
false
null
false
match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Prims.op_Negation", "Prims.op_Equality", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.MachineHeap_s.valid_addr64", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.valid_dst_stack64", "Vale.X64.Machine_Semantics_s.eval_reg_64", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_dst_operand64 (o: operand64) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_dst_operand64
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand64 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 87, "end_line": 312, "start_col": 2, "start_line": 308 }
Prims.Tot
val valid_src_operand128_and_taint (o: operand128) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
val valid_src_operand128_and_taint (o: operand128) (s: machine_state) : bool let valid_src_operand128_and_taint (o: operand128) (s: machine_state) : bool =
false
null
false
match o with | OConst _ -> false | OReg i -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Prims.op_AmpAmp", "Vale.Arch.MachineHeap_s.valid_addr128", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.match_n", "Vale.Arch.Heap.heap_taint", "Prims.int", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.valid_src_stack128", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_src_operand128_and_taint (o: operand128) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_src_operand128_and_taint
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand128 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 73, "end_line": 282, "start_col": 2, "start_line": 274 }
Prims.Tot
val update_operand128_preserve_flags'' (o: operand128) (v: quad32) (s_orig s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
val update_operand128_preserve_flags'' (o: operand128) (v: quad32) (s_orig s: machine_state) : machine_state let update_operand128_preserve_flags'' (o: operand128) (v: quad32) (s_orig s: machine_state) : machine_state =
false
null
false
match o with | OConst _ -> { s with ms_ok = false } | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand128", "Vale.Def.Types_s.quad32", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_Semantics_s.update_reg_xmm'", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.update_mem128_and_taint", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.update_stack128_and_taint" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_operand128_preserve_flags'' (o: operand128) (v: quad32) (s_orig s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.update_operand128_preserve_flags''
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand128 -> v: Vale.Def.Types_s.quad32 -> s_orig: Vale.X64.Machine_Semantics_s.machine_state -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 74, "end_line": 336, "start_col": 2, "start_line": 332 }
Prims.Tot
val operand_obs (s: machine_state) (o: operand64) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
val operand_obs (s: machine_state) (o: operand64) : list observation let operand_obs (s: machine_state) (o: operand64) : list observation =
false
null
false
match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_s.nat64", "Prims.Nil", "Vale.X64.Machine_s.observation", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Prims.Cons", "Vale.X64.Machine_s.MemAccess", "Vale.X64.Machine_Semantics_s.eval_maddr", "Prims.list" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val operand_obs (s: machine_state) (o: operand64) : list observation
[]
Vale.X64.Machine_Semantics_s.operand_obs
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> o: Vale.X64.Machine_s.operand64 -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 63, "end_line": 485, "start_col": 2, "start_line": 483 }
Prims.Tot
val eval_instr (it: instr_t_record) (oprs: instr_operands_t it.outs it.args) (ann: instr_annotation it) (s0: machine_state) : option machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
val eval_instr (it: instr_t_record) (oprs: instr_operands_t it.outs it.args) (ann: instr_annotation it) (s0: machine_state) : option machine_state let eval_instr (it: instr_t_record) (oprs: instr_operands_t it.outs it.args) (ann: instr_annotation it) (s0: machine_state) : option machine_state =
false
null
false
let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> { s0 with ms_flags = havoc_flags } | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_t_record", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.flag_havoc", "Vale.X64.Instruction_s.instr_t", "FStar.Option.mapTot", "Vale.X64.Instruction_s.instr_ret_t", "Vale.X64.Machine_Semantics_s.instr_write_outputs", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.havoc_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "FStar.Pervasives.Native.option", "Vale.X64.Machine_Semantics_s.instr_apply_eval", "Vale.X64.Instruction_s.instr_eval" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_instr (it: instr_t_record) (oprs: instr_operands_t it.outs it.args) (ann: instr_annotation it) (s0: machine_state) : option machine_state
[]
Vale.X64.Machine_Semantics_s.eval_instr
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
it: Vale.X64.Instruction_s.instr_t_record -> oprs: Vale.X64.Instruction_s.instr_operands_t (InstrTypeRecord?.outs it) (InstrTypeRecord?.args it) -> ann: Vale.X64.Machine_Semantics_s.instr_annotation it -> s0: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 80, "end_line": 683, "start_col": 26, "start_line": 675 }
Prims.Tot
val ins_obs (ins: ins) (s: machine_state) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> []
val ins_obs (ins: ins) (s: machine_state) : list observation let ins_obs (ins: ins) (s: machine_state) : list observation =
false
null
false
match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> []
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.flag_havoc", "Vale.X64.Instruction_s.instr_t", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.InstrTypeRecord", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Machine_Semantics_s.obs_inouts", "Vale.X64.Machine_s.operand64", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.operand_obs", "Vale.X64.Machine_s.nat64", "Prims.Nil", "Vale.X64.Machine_s.observation" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val ins_obs (ins: ins) (s: machine_state) : list observation
[]
Vale.X64.Machine_Semantics_s.ins_obs
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ins: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 35, "end_line": 549, "start_col": 2, "start_line": 545 }
Prims.Tot
val set (s: machine_state) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let set (s:machine_state) : st unit = fun _ -> ((), s)
val set (s: machine_state) : st unit let set (s: machine_state) : st unit =
false
null
false
fun _ -> ((), s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "FStar.Pervasives.Native.tuple2", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val set (s: machine_state) : st unit
[]
Vale.X64.Machine_Semantics_s.set
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 18, "end_line": 397, "start_col": 2, "start_line": 397 }
Prims.Tot
val op_let_Star (#a #b: Type) (m: st a) (f: (a -> st b)) : st b
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok})
val op_let_Star (#a #b: Type) (m: st a) (f: (a -> st b)) : st b let op_let_Star (#a #b: Type) (m: st a) (f: (a -> st b)) : st b =
false
null
false
fun s0 -> let x, s1 = m s0 in let y, s2 = f x s1 in (y, { s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.st", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Prims.op_AmpAmp", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "FStar.Pervasives.Native.tuple2" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val op_let_Star (#a #b: Type) (m: st a) (f: (a -> st b)) : st b
[]
Vale.X64.Machine_Semantics_s.op_let_Star
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
m: Vale.X64.Machine_Semantics_s.st a -> f: (_: a -> Vale.X64.Machine_Semantics_s.st b) -> Vale.X64.Machine_Semantics_s.st b
{ "end_col": 57, "end_line": 389, "start_col": 0, "start_line": 386 }
Prims.Tot
val fail:st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let fail : st unit = fun s -> ((), {s with ms_ok = false})
val fail:st unit let fail:st unit =
false
null
false
fun s -> ((), { s with ms_ok = false })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Mktuple2", "Prims.unit", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "FStar.Pervasives.Native.tuple2" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val fail:st unit
[]
Vale.X64.Machine_Semantics_s.fail
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 39, "end_line": 401, "start_col": 2, "start_line": 401 }
Prims.Tot
val check (valid: (machine_state -> bool)) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail
val check (valid: (machine_state -> bool)) : st unit let check (valid: (machine_state -> bool)) : st unit =
false
null
false
let* s = get in if valid s then return () else fail
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Prims.bool", "Vale.X64.Machine_Semantics_s.op_let_Star", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.return", "Vale.X64.Machine_Semantics_s.fail", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val check (valid: (machine_state -> bool)) : st unit
[]
Vale.X64.Machine_Semantics_s.check
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
valid: (_: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool) -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 8, "end_line": 416, "start_col": 2, "start_line": 412 }
Prims.Tot
val run (f: st unit) (s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let run (f:st unit) (s:machine_state) : machine_state = snd (f s)
val run (f: st unit) (s: machine_state) : machine_state let run (f: st unit) (s: machine_state) : machine_state =
false
null
false
snd (f s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.st", "Prims.unit", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.snd" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val run (f: st unit) (s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.run
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
f: Vale.X64.Machine_Semantics_s.st Prims.unit -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 65, "end_line": 428, "start_col": 56, "start_line": 428 }
Prims.Tot
val apply_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f
val apply_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit let apply_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit =
false
null
false
try_option o f
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.Machine_Semantics_s.st", "Prims.unit", "Vale.X64.Machine_Semantics_s.try_option" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val apply_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit
[]
Vale.X64.Machine_Semantics_s.apply_option
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: FStar.Pervasives.Native.option a -> f: (_: a -> Vale.X64.Machine_Semantics_s.st Prims.unit) -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 16, "end_line": 425, "start_col": 2, "start_line": 425 }
Prims.Tot
val instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state) : option (instr_val_t (IOpIm i))
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags
val instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state) : option (instr_val_t (IOpIm i)) let instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state) : option (instr_val_t (IOpIm i)) =
false
null
false
match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint", "FStar.Pervasives.Native.Some", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Instruction_s.IOpIm", "Vale.X64.Machine_Semantics_s.eval_operand", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.valid_src_operand128_and_taint", "Vale.X64.Machine_Semantics_s.eval_mov128_op", "Vale.X64.Machine_Semantics_s.cf", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.overflow" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr]
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_eval_operand_implicit (i: instr_operand_implicit) (s: machine_state) : option (instr_val_t (IOpIm i))
[]
Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_implicit -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpIm i))
{ "end_col": 37, "end_line": 563, "start_col": 2, "start_line": 559 }
Prims.Tot
val update_reg_64 (r: reg_64) (v: nat64) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s)
val update_reg_64 (r: reg_64) (v: nat64) : st unit let update_reg_64 (r: reg_64) (v: nat64) : st unit =
false
null
false
let* s = get in set (update_reg_64' r v s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.reg_64", "Vale.Def.Types_s.nat64", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_Semantics_s.update_reg_64'", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s)
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_reg_64 (r: reg_64) (v: nat64) : st unit
[]
Vale.X64.Machine_Semantics_s.update_reg_64
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Vale.X64.Machine_s.reg_64 -> v: Vale.Def.Types_s.nat64 -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 28, "end_line": 447, "start_col": 2, "start_line": 446 }
Prims.Tot
val update_of (new_of: bool) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } )
val update_of (new_of: bool) : st unit let update_of (new_of: bool) : st unit =
false
null
false
let* s = get in set ({ s with ms_flags = update_of' s.ms_flags new_of })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.update_of'", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_of (new_of: bool) : st unit
[]
Vale.X64.Machine_Semantics_s.update_of
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
new_of: Prims.bool -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 60, "end_line": 467, "start_col": 2, "start_line": 466 }
Prims.Tot
val update_cf (new_cf: bool) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } )
val update_cf (new_cf: bool) : st unit let update_cf (new_cf: bool) : st unit =
false
null
false
let* s = get in set ({ s with ms_flags = update_cf' s.ms_flags new_cf })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.bool", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.update_cf'", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } )
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_cf (new_cf: bool) : st unit
[]
Vale.X64.Machine_Semantics_s.update_cf
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
new_cf: Prims.bool -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 60, "end_line": 463, "start_col": 2, "start_line": 462 }
Prims.Tot
val update_reg_xmm (x: reg_xmm) (ins: ins) (v: quad32) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } )
val update_reg_xmm (x: reg_xmm) (ins: ins) (v: quad32) : st unit let update_reg_xmm (x: reg_xmm) (ins: ins) (v: quad32) : st unit =
false
null
false
let* s = get in set ({ (update_reg_xmm' x v s) with ms_flags = havoc_flags })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_Semantics_s.ins", "Vale.Def.Types_s.quad32", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.havoc_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.update_reg_xmm'", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s)
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_reg_xmm (x: reg_xmm) (ins: ins) (v: quad32) : st unit
[]
Vale.X64.Machine_Semantics_s.update_reg_xmm
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
x: Vale.X64.Machine_s.reg_xmm -> ins: Vale.X64.Machine_Semantics_s.ins -> v: Vale.Def.Types_s.quad32 -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 66, "end_line": 451, "start_col": 2, "start_line": 450 }
Prims.Tot
val free_stack (start finish: int) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} )
val free_stack (start finish: int) : st unit let free_stack (start finish: int) : st unit =
false
null
false
let* s = get in set ({ s with ms_stack = free_stack' start finish s.ms_stack })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.free_stack'", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } )
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val free_stack (start finish: int) : st unit
[]
Vale.X64.Machine_Semantics_s.free_stack
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
start: Prims.int -> finish: Prims.int -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 66, "end_line": 475, "start_col": 2, "start_line": 474 }
Prims.Tot
val update_mem128_and_taint (ptr: int) (v: quad32) (s: machine_state) (t: taint) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s
val update_mem128_and_taint (ptr: int) (v: quad32) (s: machine_state) (t: taint) : machine_state let update_mem128_and_taint (ptr: int) (v: quad32) (s: machine_state) (t: taint) : machine_state =
false
null
false
if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.int", "Vale.Def.Types_s.quad32", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.MachineHeap_s.valid_addr128", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.Arch.Heap.heap_upd", "Vale.Arch.MachineHeap_s.update_heap128", "Vale.X64.Machine_Semantics_s.update_n", "Vale.Arch.Heap.heap_taint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_mem128_and_taint (ptr: int) (v: quad32) (s: machine_state) (t: taint) : machine_state
[]
Vale.X64.Machine_Semantics_s.update_mem128_and_taint
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ptr: Prims.int -> v: Vale.Def.Types_s.quad32 -> s: Vale.X64.Machine_Semantics_s.machine_state -> t: Vale.Arch.HeapTypes_s.taint -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 8, "end_line": 217, "start_col": 2, "start_line": 211 }
Prims.Tot
val eval_reg_64 (r: reg_64) (s: machine_state) : nat64
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s
val eval_reg_64 (r: reg_64) (s: machine_state) : nat64 let eval_reg_64 (r: reg_64) (s: machine_state) : nat64 =
false
null
false
eval_reg (Reg 0 r) s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.eval_reg", "Vale.X64.Machine_s.Reg", "Vale.Def.Types_s.nat64" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_reg_64 (r: reg_64) (s: machine_state) : nat64
[]
Vale.X64.Machine_Semantics_s.eval_reg_64
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
r: Vale.X64.Machine_s.reg_64 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.Def.Types_s.nat64
{ "end_col": 82, "end_line": 79, "start_col": 62, "start_line": 79 }
Prims.Tot
val update_rsp' (new_rsp: int) (s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s
val update_rsp' (new_rsp: int) (s: machine_state) : machine_state let update_rsp' (new_rsp: int) (s: machine_state) : machine_state =
false
null
false
let Machine_stack init_rsp mem = s.ms_stack in if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.int", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.Def.Types_s.nat64", "Prims.b2t", "Prims.op_GreaterThanOrEqual", "FStar.Map.t", "Vale.Def.Types_s.nat8", "Prims.op_AmpAmp", "Prims.op_Subtraction", "Prims.op_LessThanOrEqual", "Vale.X64.Machine_Semantics_s.update_reg_64'", "Vale.X64.Machine_s.rRsp", "Prims.bool", "Vale.X64.Machine_Semantics_s.machine_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags }
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_rsp' (new_rsp: int) (s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.update_rsp'
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
new_rsp: Prims.int -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 5, "end_line": 354, "start_col": 65, "start_line": 348 }
Prims.Tot
val state_or_fail (s: machine_state) (b: bool) (s': machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false}
val state_or_fail (s: machine_state) (b: bool) (s': machine_state) : machine_state let state_or_fail (s: machine_state) (b: bool) (s': machine_state) : machine_state =
false
null
false
if b then s' else { s with ms_ok = false }
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Prims.bool", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val state_or_fail (s: machine_state) (b: bool) (s': machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.state_or_fail
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> b: Prims.bool -> s': Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 42, "end_line": 618, "start_col": 2, "start_line": 618 }
FStar.Pervasives.Lemma
val lemma_is_machine_heap_update64 (ptr: int) (v: nat64) (mh: machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); ()
val lemma_is_machine_heap_update64 (ptr: int) (v: nat64) (mh: machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] let lemma_is_machine_heap_update64 (ptr: int) (v: nat64) (mh: machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] =
false
null
true
reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); ()
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "lemma" ]
[ "Prims.int", "Vale.Def.Types_s.nat64", "Vale.Arch.MachineHeap_s.machine_heap", "Prims.unit", "Vale.Arch.MachineHeap_s.update_heap64_reveal", "FStar.Pervasives.reveal_opaque", "Prims.bool", "Vale.Arch.MachineHeap_s.valid_addr64", "Prims.b2t", "Prims.squash", "Vale.Arch.MachineHeap_s.is_machine_heap_update", "Vale.Arch.MachineHeap_s.update_heap64", "Prims.Cons", "FStar.Pervasives.pattern", "FStar.Pervasives.smt_pat", "Prims.logical", "Prims.Nil" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val lemma_is_machine_heap_update64 (ptr: int) (v: nat64) (mh: machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))]
[]
Vale.X64.Machine_Semantics_s.lemma_is_machine_heap_update64
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ptr: Prims.int -> v: Vale.Def.Types_s.nat64 -> mh: Vale.Arch.MachineHeap_s.machine_heap -> FStar.Pervasives.Lemma (requires Vale.Arch.MachineHeap_s.valid_addr64 ptr mh) (ensures Vale.Arch.MachineHeap_s.is_machine_heap_update mh (Vale.Arch.MachineHeap_s.update_heap64 ptr v mh)) [ SMTPat (Vale.Arch.MachineHeap_s.is_machine_heap_update mh (Vale.Arch.MachineHeap_s.update_heap64 ptr v mh)) ]
{ "end_col": 4, "end_line": 174, "start_col": 2, "start_line": 172 }
Prims.Tot
val update_of' (flags: flags_t) (new_of: bool) : (new_flags: flags_t{overflow new_flags == Some new_of})
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
val update_of' (flags: flags_t) (new_of: bool) : (new_flags: flags_t{overflow new_flags == Some new_of}) let update_of' (flags: flags_t) (new_of: bool) : (new_flags: flags_t{overflow new_flags == Some new_of}) =
false
null
false
FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.flags_t", "Prims.bool", "FStar.FunctionalExtensionality.on_dom", "Vale.X64.Machine_s.flag", "FStar.Pervasives.Native.option", "Prims.op_Equality", "Vale.X64.Machine_s.fOverflow", "FStar.Pervasives.Native.Some", "Prims.eq2", "Vale.X64.Machine_Semantics_s.overflow" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_of' (flags: flags_t) (new_of: bool) : (new_flags: flags_t{overflow new_flags == Some new_of})
[]
Vale.X64.Machine_Semantics_s.update_of'
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
flags: Vale.X64.Machine_Semantics_s.flags_t -> new_of: Prims.bool -> new_flags: Vale.X64.Machine_Semantics_s.flags_t {Vale.X64.Machine_Semantics_s.overflow new_flags == FStar.Pervasives.Native.Some new_of}
{ "end_col": 102, "end_line": 366, "start_col": 2, "start_line": 366 }
Prims.Tot
val eval_operand (o: operand64) (s: machine_state) : nat64
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
val eval_operand (o: operand64) (s: machine_state) : nat64 let eval_operand (o: operand64) (s: machine_state) : nat64 =
false
null
false
match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_Semantics_s.eval_reg_64", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.eval_mem", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.eval_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.Def.Types_s.nat64" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_operand (o: operand64) (s: machine_state) : nat64
[]
Vale.X64.Machine_Semantics_s.eval_operand
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand64 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.Def.Types_s.nat64
{ "end_col": 59, "end_line": 106, "start_col": 2, "start_line": 102 }
Prims.Tot
val eval_ocmp (s: machine_state) (c: ocmp) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
val eval_ocmp (s: machine_state) (c: ocmp) : bool let eval_ocmp (s: machine_state) (c: ocmp) : bool =
false
null
false
match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.ocmp", "Vale.X64.Machine_s.operand64", "Prims.b2t", "Prims.op_Negation", "Prims.op_BarBar", "Vale.X64.Machine_s.uu___is_OMem", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.uu___is_OStack", "Prims.op_Equality", "Vale.Def.Types_s.nat64", "Vale.X64.Machine_Semantics_s.eval_operand", "Prims.op_disEquality", "Prims.op_LessThanOrEqual", "Prims.op_GreaterThanOrEqual", "Prims.op_LessThan", "Prims.op_GreaterThan", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_ocmp (s: machine_state) (c: ocmp) : bool
[]
Vale.X64.Machine_Semantics_s.eval_ocmp
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> c: Vale.X64.Machine_Semantics_s.ocmp -> Prims.bool
{ "end_col": 57, "end_line": 122, "start_col": 2, "start_line": 116 }
Prims.Tot
val eval_mov128_op (o: operand128) (s: machine_state) : quad32
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
val eval_mov128_op (o: operand128) (s: machine_state) : quad32 let eval_mov128_op (o: operand128) (s: machine_state) : quad32 =
false
null
false
match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.quad32", "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_Semantics_s.eval_reg_xmm", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.eval_mem128", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.eval_stack128", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.Def.Types_s.quad32" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val eval_mov128_op (o: operand128) (s: machine_state) : quad32
[]
Vale.X64.Machine_Semantics_s.eval_mov128_op
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand128 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.Def.Types_s.quad32
{ "end_col": 62, "end_line": 113, "start_col": 2, "start_line": 109 }
Prims.Tot
val valid_src_operand64_and_taint (o: operand64) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
val valid_src_operand64_and_taint (o: operand64) (s: machine_state) : bool let valid_src_operand64_and_taint (o: operand64) (s: machine_state) : bool =
false
null
false
match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Prims.op_AmpAmp", "Vale.Arch.MachineHeap_s.valid_addr64", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.match_n", "Vale.Arch.Heap.heap_taint", "Prims.int", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.valid_src_stack64", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_src_operand64_and_taint (o: operand64) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand64 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 71, "end_line": 271, "start_col": 2, "start_line": 263 }
Prims.Tot
val update_operand64_preserve_flags'' (o: operand64) (v: nat64) (s_orig s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
val update_operand64_preserve_flags'' (o: operand64) (v: nat64) (s_orig s: machine_state) : machine_state let update_operand64_preserve_flags'' (o: operand64) (v: nat64) (s_orig s: machine_state) : machine_state =
false
null
false
match o with | OConst _ -> { s with ms_ok = false } | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand64", "Vale.Def.Types_s.nat64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_Semantics_s.update_reg_64'", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.update_mem_and_taint", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.X64.Machine_Semantics_s.update_stack_and_taint" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val update_operand64_preserve_flags'' (o: operand64) (v: nat64) (s_orig s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags''
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand64 -> v: Vale.Def.Types_s.nat64 -> s_orig: Vale.X64.Machine_Semantics_s.machine_state -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 71, "end_line": 326, "start_col": 2, "start_line": 322 }
Prims.Tot
val machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state = let obs = ins_obs i s in // REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace})
val machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state let machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state =
false
null
false
let obs = ins_obs i s in Some ({ machine_eval_ins i ({ s with ms_trace = [] }) with ms_trace = obs @ s.ms_trace })
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.Some", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "FStar.List.Tot.Base.op_At", "Vale.X64.Machine_s.observation", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.machine_eval_ins", "Prims.Nil", "Prims.list", "Vale.X64.Machine_Semantics_s.ins_obs", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs // Core definition of instruction semantics [@instr_attr] let machine_eval_ins_st (ins:ins) : st unit = let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> check (valid_src_operand64_and_taint src);* let new_src = eval_operand src s in // Evaluate value on initial state let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer update_rsp new_rsp;* // Actually modify the stack pointer let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped update_rsp new_rsp // Finally, update the stack pointer | BC.Alloc n -> // We already check in update_rsp that the new stack pointer is valid update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in update_rsp new_rsp;* // The deallocated stack memory should now be considered invalid free_stack old_rsp new_rsp [@instr_attr] let machine_eval_ins (i:ins) (s:machine_state) : machine_state = run (machine_eval_ins_st i) s
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val machine_eval_code_ins_def (i: ins) (s: machine_state) : option machine_state
[]
Vale.X64.Machine_Semantics_s.machine_eval_code_ins_def
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 87, "end_line": 728, "start_col": 80, "start_line": 725 }
Prims.Tot
val machine_eval_ins (i: ins) (s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_ins (i:ins) (s:machine_state) : machine_state = run (machine_eval_ins_st i) s
val machine_eval_ins (i: ins) (s: machine_state) : machine_state let machine_eval_ins (i: ins) (s: machine_state) : machine_state =
false
null
false
run (machine_eval_ins_st i) s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.run", "Vale.X64.Machine_Semantics_s.machine_eval_ins_st" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs // Core definition of instruction semantics [@instr_attr] let machine_eval_ins_st (ins:ins) : st unit = let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> check (valid_src_operand64_and_taint src);* let new_src = eval_operand src s in // Evaluate value on initial state let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer update_rsp new_rsp;* // Actually modify the stack pointer let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped update_rsp new_rsp // Finally, update the stack pointer | BC.Alloc n -> // We already check in update_rsp that the new stack pointer is valid update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in update_rsp new_rsp;* // The deallocated stack memory should now be considered invalid free_stack old_rsp new_rsp [@instr_attr]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val machine_eval_ins (i: ins) (s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.machine_eval_ins
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 31, "end_line": 723, "start_col": 2, "start_line": 723 }
Prims.Tot
val valid_src_operand (o: operand64) (s: machine_state) : bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
val valid_src_operand (o: operand64) (s: machine_state) : bool let valid_src_operand (o: operand64) (s: machine_state) : bool =
false
null
false
match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Vale.Arch.MachineHeap_s.valid_addr64", "Vale.X64.Machine_Semantics_s.eval_maddr", "Vale.Arch.Heap.heap_get", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.valid_src_stack64", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Prims.bool" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val valid_src_operand (o: operand64) (s: machine_state) : bool
[]
Vale.X64.Machine_Semantics_s.valid_src_operand
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: Vale.X64.Machine_s.operand64 -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.bool
{ "end_col": 66, "end_line": 260, "start_col": 2, "start_line": 256 }
Prims.Tot
val machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_ocmp (s:machine_state) (c:ocmp) : machine_state & bool = let s = run (check (valid_ocmp_opaque c)) s in let b = eval_ocmp_opaque s c in let s = {s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b)::s.ms_trace} in (s, b)
val machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool let machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool =
false
null
false
let s = run (check (valid_ocmp_opaque c)) s in let b = eval_ocmp_opaque s c in let s = { s with ms_flags = havoc_flags; ms_trace = (BranchPredicate b) :: s.ms_trace } in (s, b)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.ocmp", "FStar.Pervasives.Native.Mktuple2", "Prims.bool", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.havoc_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Prims.Cons", "Vale.X64.Machine_s.observation", "Vale.X64.Machine_s.BranchPredicate", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.eval_ocmp_opaque", "Vale.X64.Machine_Semantics_s.run", "Vale.X64.Machine_Semantics_s.check", "Vale.X64.Machine_Semantics_s.valid_ocmp_opaque", "FStar.Pervasives.Native.tuple2" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs // Core definition of instruction semantics [@instr_attr] let machine_eval_ins_st (ins:ins) : st unit = let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> check (valid_src_operand64_and_taint src);* let new_src = eval_operand src s in // Evaluate value on initial state let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer update_rsp new_rsp;* // Actually modify the stack pointer let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped update_rsp new_rsp // Finally, update the stack pointer | BC.Alloc n -> // We already check in update_rsp that the new stack pointer is valid update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in update_rsp new_rsp;* // The deallocated stack memory should now be considered invalid free_stack old_rsp new_rsp [@instr_attr] let machine_eval_ins (i:ins) (s:machine_state) : machine_state = run (machine_eval_ins_st i) s let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state = let obs = ins_obs i s in // REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace}) [@"opaque_to_smt"] let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state = machine_eval_code_ins_def i s
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val machine_eval_ocmp (s: machine_state) (c: ocmp) : machine_state & bool
[]
Vale.X64.Machine_Semantics_s.machine_eval_ocmp
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> c: Vale.X64.Machine_Semantics_s.ocmp -> Vale.X64.Machine_Semantics_s.machine_state * Prims.bool
{ "end_col": 8, "end_line": 737, "start_col": 73, "start_line": 733 }
Prims.Tot
val machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_code_ins (i:ins) (s:machine_state) : option machine_state = machine_eval_code_ins_def i s
val machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state let machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state =
false
null
false
machine_eval_code_ins_def i s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.machine_eval_code_ins_def", "FStar.Pervasives.Native.option" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs // Core definition of instruction semantics [@instr_attr] let machine_eval_ins_st (ins:ins) : st unit = let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> check (valid_src_operand64_and_taint src);* let new_src = eval_operand src s in // Evaluate value on initial state let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer update_rsp new_rsp;* // Actually modify the stack pointer let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped update_rsp new_rsp // Finally, update the stack pointer | BC.Alloc n -> // We already check in update_rsp that the new stack pointer is valid update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in update_rsp new_rsp;* // The deallocated stack memory should now be considered invalid free_stack old_rsp new_rsp [@instr_attr] let machine_eval_ins (i:ins) (s:machine_state) : machine_state = run (machine_eval_ins_st i) s let machine_eval_code_ins_def (i:ins) (s:machine_state) : option machine_state = let obs = ins_obs i s in // REVIEW: drop trace, then restore trace, to make clear that machine_eval_ins shouldn't depend on trace Some ({machine_eval_ins i ({s with ms_trace = []}) with ms_trace = obs @ s.ms_trace}) [@"opaque_to_smt"]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val machine_eval_code_ins (i: ins) (s: machine_state) : option machine_state
[]
Vale.X64.Machine_Semantics_s.machine_eval_code_ins
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Machine_Semantics_s.ins -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 31, "end_line": 731, "start_col": 2, "start_line": 731 }
Prims.Tot
val try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x
val try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit let try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit =
false
null
false
match o with | None -> fail | Some x -> f x
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.option", "Vale.X64.Machine_Semantics_s.st", "Prims.unit", "Vale.X64.Machine_Semantics_s.fail" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val try_option (#a: Type) (o: option a) (f: (a -> st unit)) : st unit
[]
Vale.X64.Machine_Semantics_s.try_option
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
o: FStar.Pervasives.Native.option a -> f: (_: a -> Vale.X64.Machine_Semantics_s.st Prims.unit) -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 17, "end_line": 422, "start_col": 2, "start_line": 420 }
Prims.Tot
val operand_obs128 (s: machine_state) (op: operand128) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
val operand_obs128 (s: machine_state) (op: operand128) : list observation let operand_obs128 (s: machine_state) (op: operand128) : list observation =
false
null
false
match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)]
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_s.quad32", "Prims.Nil", "Vale.X64.Machine_s.observation", "Vale.X64.Machine_s.reg_xmm", "Vale.X64.Machine_s.maddr", "Vale.Arch.HeapTypes_s.taint", "Prims.Cons", "Vale.X64.Machine_s.MemAccess", "Vale.X64.Machine_Semantics_s.eval_maddr", "Prims.list" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val operand_obs128 (s: machine_state) (op: operand128) : list observation
[]
Vale.X64.Machine_Semantics_s.operand_obs128
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
s: Vale.X64.Machine_Semantics_s.machine_state -> op: Vale.X64.Machine_s.operand128 -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 63, "end_line": 491, "start_col": 2, "start_line": 489 }
Prims.Tot
val obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o
val obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : list observation let obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : list observation =
false
null
false
match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.operand_obs", "Vale.X64.Machine_Semantics_s.operand_obs128", "Prims.list", "Vale.X64.Machine_s.observation" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val obs_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : list observation
[]
Vale.X64.Machine_Semantics_s.obs_operand_explicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_explicit -> o: Vale.X64.Instruction_s.instr_operand_t i -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 32, "end_line": 500, "start_col": 2, "start_line": 498 }
Prims.Tot
val obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> []
val obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation let obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation =
false
null
false
match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> []
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.operand_obs", "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.operand_obs128", "Prims.Nil", "Vale.X64.Machine_s.observation", "Prims.list" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit)
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val obs_operand_implicit (i: instr_operand_implicit) (s: machine_state) : list observation
[]
Vale.X64.Machine_Semantics_s.obs_operand_implicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_implicit -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 33, "end_line": 509, "start_col": 2, "start_line": 506 }
Prims.Tot
val obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s
val obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state) : list observation let rec obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state) : list observation =
false
null
false
match args with | [] -> [] | i :: args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.list", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_operands_t_args", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.Nil", "Vale.X64.Machine_s.observation", "Vale.X64.Instruction_s.instr_operand_explicit", "FStar.List.Tot.Base.op_At", "Vale.X64.Machine_Semantics_s.obs_operand_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Machine_Semantics_s.obs_args", "FStar.Pervasives.Native.snd", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.obs_operand_implicit" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val obs_args (args: list instr_operand) (oprs: instr_operands_t_args args) (s: machine_state) : list observation
[ "recursion" ]
Vale.X64.Machine_Semantics_s.obs_args
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
args: Prims.list Vale.X64.Instruction_s.instr_operand -> oprs: Vale.X64.Instruction_s.instr_operands_t_args args -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 62, "end_line": 524, "start_col": 2, "start_line": 516 }
Prims.Tot
val obs_inouts (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (s: machine_state) : list observation
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s
val obs_inouts (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (s: machine_state) : list observation let rec obs_inouts (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (s: machine_state) : list observation =
false
null
false
match inouts with | [] -> obs_args args oprs s | (_, i) :: inouts -> let v, oprs = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.obs_args", "Vale.X64.Instruction_s.instr_operand_inout", "Vale.X64.Machine_s.observation", "FStar.List.Tot.Base.op_At", "Vale.X64.Machine_Semantics_s.obs_inouts", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_explicit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_Semantics_s.obs_operand_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Instruction_s.instr_operand_t", "FStar.Pervasives.Native.snd", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.obs_operand_implicit" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val obs_inouts (inouts: list instr_out) (args: list instr_operand) (oprs: instr_operands_t inouts args) (s: machine_state) : list observation
[ "recursion" ]
Vale.X64.Machine_Semantics_s.obs_inouts
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
inouts: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> oprs: Vale.X64.Instruction_s.instr_operands_t inouts args -> s: Vale.X64.Machine_Semantics_s.machine_state -> Prims.list Vale.X64.Machine_s.observation
{ "end_col": 40, "end_line": 541, "start_col": 2, "start_line": 532 }
Prims.Tot
val instr_eval_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : option (instr_val_t (IOpEx i))
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
val instr_eval_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : option (instr_val_t (IOpEx i)) let instr_eval_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : option (instr_val_t (IOpEx i)) =
false
null
false
match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint", "FStar.Pervasives.Native.Some", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Instruction_s.IOpEx", "Vale.X64.Machine_Semantics_s.eval_operand", "Prims.bool", "FStar.Pervasives.Native.None", "FStar.Pervasives.Native.option", "Vale.X64.Machine_Semantics_s.valid_src_operand128_and_taint", "Vale.X64.Machine_Semantics_s.eval_mov128_op" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr]
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_eval_operand_explicit (i: instr_operand_explicit) (o: instr_operand_t i) (s: machine_state) : option (instr_val_t (IOpEx i))
[]
Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_explicit -> o: Vale.X64.Instruction_s.instr_operand_t i -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpEx i))
{ "end_col": 92, "end_line": 555, "start_col": 2, "start_line": 553 }
Prims.Tot
val instr_apply_eval_args (outs: list instr_out) (args: list instr_operand) (f: instr_args_t outs args) (oprs: instr_operands_t_args args) (s: machine_state) : option (instr_ret_t outs)
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
val instr_apply_eval_args (outs: list instr_out) (args: list instr_operand) (f: instr_args_t outs args) (oprs: instr_operands_t_args args) (s: machine_state) : option (instr_ret_t outs) let rec instr_apply_eval_args (outs: list instr_out) (args: list instr_operand) (f: instr_args_t outs args) (oprs: instr_operands_t_args args) (s: machine_state) : option (instr_ret_t outs) =
false
null
false
match args with | [] -> f | i :: args -> let v, oprs = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_args_t", "Vale.X64.Instruction_s.instr_operands_t_args", "Vale.X64.Machine_Semantics_s.machine_state", "FStar.Pervasives.Native.option", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Machine_Semantics_s.bind_option", "Vale.X64.Instruction_s.instr_ret_t", "Vale.X64.Machine_Semantics_s.instr_apply_eval_args", "Vale.X64.Instruction_s.arrow", "Vale.X64.Instruction_s.coerce", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_explicit", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Instruction_s.instr_operand_t", "FStar.Pervasives.Native.snd", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_apply_eval_args (outs: list instr_out) (args: list instr_operand) (f: instr_args_t outs args) (oprs: instr_operands_t_args args) (s: machine_state) : option (instr_ret_t outs)
[ "recursion" ]
Vale.X64.Machine_Semantics_s.instr_apply_eval_args
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
outs: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> f: Vale.X64.Instruction_s.instr_args_t outs args -> oprs: Vale.X64.Instruction_s.instr_operands_t_args args -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_ret_t outs)
{ "end_col": 73, "end_line": 579, "start_col": 2, "start_line": 570 }
Prims.Tot
val instr_apply_eval_inouts (outs inouts: list instr_out) (args: list instr_operand) (f: instr_inouts_t outs inouts args) (oprs: instr_operands_t inouts args) (s: machine_state) : option (instr_ret_t outs)
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
val instr_apply_eval_inouts (outs inouts: list instr_out) (args: list instr_operand) (f: instr_inouts_t outs inouts args) (oprs: instr_operands_t inouts args) (s: machine_state) : option (instr_ret_t outs) let rec instr_apply_eval_inouts (outs inouts: list instr_out) (args: list instr_operand) (f: instr_inouts_t outs inouts args) (oprs: instr_operands_t inouts args) (s: machine_state) : option (instr_ret_t outs) =
false
null
false
match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i) :: inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i) :: inouts -> let v, oprs = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_inouts_t", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.instr_apply_eval_args", "Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.instr_operand_explicit", "FStar.Pervasives.Native.snd", "Vale.X64.Instruction_s.instr_operand_t", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.instr_operand_implicit", "FStar.Pervasives.Native.option", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Machine_Semantics_s.bind_option", "Vale.X64.Instruction_s.instr_ret_t", "Vale.X64.Instruction_s.arrow", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_Semantics_s.instr_eval_operand_explicit", "FStar.Pervasives.Native.fst", "Vale.X64.Machine_Semantics_s.instr_eval_operand_implicit" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_apply_eval_inouts (outs inouts: list instr_out) (args: list instr_operand) (f: instr_inouts_t outs inouts args) (oprs: instr_operands_t inouts args) (s: machine_state) : option (instr_ret_t outs)
[ "recursion" ]
Vale.X64.Machine_Semantics_s.instr_apply_eval_inouts
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
outs: Prims.list Vale.X64.Instruction_s.instr_out -> inouts: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> f: Vale.X64.Instruction_s.instr_inouts_t outs inouts args -> oprs: Vale.X64.Instruction_s.instr_operands_t inouts args -> s: Vale.X64.Machine_Semantics_s.machine_state -> FStar.Pervasives.Native.option (Vale.X64.Instruction_s.instr_ret_t outs)
{ "end_col": 82, "end_line": 602, "start_col": 2, "start_line": 586 }
Prims.Tot
val instr_write_output_explicit (i: instr_operand_explicit) (v: instr_val_t (IOpEx i)) (o: instr_operand_t i) (s_orig s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
val instr_write_output_explicit (i: instr_operand_explicit) (v: instr_val_t (IOpEx i)) (o: instr_operand_t i) (s_orig s: machine_state) : machine_state let instr_write_output_explicit (i: instr_operand_explicit) (v: instr_val_t (IOpEx i)) (o: instr_operand_t i) (s_orig s: machine_state) : machine_state =
false
null
false
match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Instruction_s.IOpEx", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_Semantics_s.state_or_fail", "Vale.X64.Machine_Semantics_s.valid_dst_operand64", "Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags''", "Vale.X64.Machine_Semantics_s.valid_dst_operand128", "Vale.X64.Machine_Semantics_s.update_operand128_preserve_flags''" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_write_output_explicit (i: instr_operand_explicit) (v: instr_val_t (IOpEx i)) (o: instr_operand_t i) (s_orig s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.instr_write_output_explicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_explicit -> v: Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpEx i) -> o: Vale.X64.Instruction_s.instr_operand_t i -> s_orig: Vale.X64.Machine_Semantics_s.machine_state -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 101, "end_line": 628, "start_col": 2, "start_line": 624 }
Prims.Tot
val instr_write_output_implicit (i: instr_operand_implicit) (v: instr_val_t (IOpIm i)) (s_orig s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v}
val instr_write_output_implicit (i: instr_operand_implicit) (v: instr_val_t (IOpIm i)) (s_orig s: machine_state) : machine_state let instr_write_output_implicit (i: instr_operand_implicit) (v: instr_val_t (IOpIm i)) (s_orig s: machine_state) : machine_state =
false
null
false
match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> { s with ms_flags = update_cf' s.ms_flags v } | IOpFlagsOf -> { s with ms_flags = update_of' s.ms_flags v }
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Instruction_s.IOpIm", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Machine_s.operand64", "Vale.X64.Machine_Semantics_s.state_or_fail", "Vale.X64.Machine_Semantics_s.valid_dst_operand64", "Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags''", "Vale.X64.Machine_s.operand128", "Vale.X64.Machine_Semantics_s.valid_dst_operand128", "Vale.X64.Machine_Semantics_s.update_operand128_preserve_flags''", "Vale.X64.Machine_Semantics_s.Mkmachine_state", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_ok", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_regs", "Vale.X64.Machine_Semantics_s.update_cf'", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_flags", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_heap", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stack", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_stackTaint", "Vale.X64.Machine_Semantics_s.__proj__Mkmachine_state__item__ms_trace", "Vale.X64.Machine_Semantics_s.update_of'" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_write_output_implicit (i: instr_operand_implicit) (v: instr_val_t (IOpIm i)) (s_orig s: machine_state) : machine_state
[]
Vale.X64.Machine_Semantics_s.instr_write_output_implicit
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
i: Vale.X64.Instruction_s.instr_operand_implicit -> v: Vale.X64.Instruction_s.instr_val_t (Vale.X64.Instruction_s.IOpIm i) -> s_orig: Vale.X64.Machine_Semantics_s.machine_state -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 61, "end_line": 640, "start_col": 2, "start_line": 634 }
Prims.Tot
val machine_eval_ins_st (ins: ins) : st unit
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let machine_eval_ins_st (ins:ins) : st unit = let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> check (valid_src_operand64_and_taint src);* let new_src = eval_operand src s in // Evaluate value on initial state let new_rsp = eval_reg_64 rRsp s - 8 in // Compute the new stack pointer update_rsp new_rsp;* // Actually modify the stack pointer let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src // Store the element at the new stack pointer | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in check (valid_src_operand64_and_taint stack_op);* // Ensure that we can read at the initial stack pointer let new_dst = eval_operand stack_op s in // Get the element currently on top of the stack let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in // Compute the new stack pointer update_operand64_preserve_flags dst new_dst;* // Store it in the dst operand free_stack (new_rsp - 8) new_rsp;* // Free the memory that is popped update_rsp new_rsp // Finally, update the stack pointer | BC.Alloc n -> // We already check in update_rsp that the new stack pointer is valid update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in update_rsp new_rsp;* // The deallocated stack memory should now be considered invalid free_stack old_rsp new_rsp
val machine_eval_ins_st (ins: ins) : st unit let machine_eval_ins_st (ins: ins) : st unit =
false
null
false
let* s = get in match ins with | BC.Instr it oprs ann -> apply_option (eval_instr it oprs ann s) set | BC.Push src t -> let* _ = check (valid_src_operand64_and_taint src) in let new_src = eval_operand src s in let new_rsp = eval_reg_64 rRsp s - 8 in let* _ = update_rsp new_rsp in let o_new = OStack (MConst new_rsp, t) in update_operand64_preserve_flags o_new new_src | BC.Pop dst t -> let stack_op = OStack (MReg (Reg 0 rRsp) 0, t) in let* _ = check (valid_src_operand64_and_taint stack_op) in let new_dst = eval_operand stack_op s in let new_rsp = (eval_reg_64 rRsp s + 8) % pow2_64 in let* _ = update_operand64_preserve_flags dst new_dst in let* _ = free_stack (new_rsp - 8) new_rsp in update_rsp new_rsp | BC.Alloc n -> update_rsp (eval_reg_64 rRsp s - n) | BC.Dealloc n -> let old_rsp = eval_reg_64 rRsp s in let new_rsp = old_rsp + n in let* _ = update_rsp new_rsp in free_stack old_rsp new_rsp
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Vale.X64.Machine_Semantics_s.ins", "Vale.X64.Machine_Semantics_s.op_let_Star", "Vale.X64.Machine_Semantics_s.machine_state", "Prims.unit", "Vale.X64.Machine_Semantics_s.get", "Vale.X64.Instruction_s.instr_t_record", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__outs", "Vale.X64.Instruction_s.__proj__InstrTypeRecord__item__args", "Vale.X64.Machine_Semantics_s.instr_annotation", "Vale.X64.Machine_Semantics_s.apply_option", "Vale.X64.Machine_Semantics_s.eval_instr", "Vale.X64.Machine_Semantics_s.set", "Vale.X64.Machine_s.operand64", "Vale.Arch.HeapTypes_s.taint", "Vale.X64.Machine_Semantics_s.check", "Vale.X64.Machine_Semantics_s.valid_src_operand64_and_taint", "Vale.X64.Machine_Semantics_s.update_rsp", "Vale.X64.Machine_Semantics_s.update_operand64_preserve_flags", "Vale.X64.Machine_s.operand", "Vale.Def.Words_s.nat64", "Vale.X64.Machine_s.reg_64", "Vale.X64.Machine_s.OStack", "Vale.X64.Machine_s.nat64", "FStar.Pervasives.Native.Mktuple2", "Vale.X64.Machine_s.maddr", "Vale.X64.Machine_s.MConst", "Vale.X64.Machine_Semantics_s.st", "Prims.int", "Prims.op_Subtraction", "Vale.X64.Machine_Semantics_s.eval_reg_64", "Vale.X64.Machine_s.rRsp", "Vale.X64.Machine_Semantics_s.eval_operand", "Vale.X64.Machine_Semantics_s.free_stack", "Prims.op_Modulus", "Prims.op_Addition", "Vale.Def.Words_s.pow2_64", "Vale.X64.Machine_s.MReg", "Vale.X64.Machine_s.Reg" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s ) [@instr_attr] let eval_instr (it:instr_t_record) (oprs:instr_operands_t it.outs it.args) (ann:instr_annotation it) (s0:machine_state) : option machine_state = let InstrTypeRecord #outs #args #havoc_flags' i = it in let vs = instr_apply_eval outs args (instr_eval i) oprs s0 in let s1 = match havoc_flags' with | HavocFlags -> {s0 with ms_flags = havoc_flags} | PreserveFlags -> s0 in FStar.Option.mapTot (fun vs -> instr_write_outputs outs args vs oprs s0 s1) vs // Core definition of instruction semantics [@instr_attr]
false
true
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val machine_eval_ins_st (ins: ins) : st unit
[]
Vale.X64.Machine_Semantics_s.machine_eval_ins_st
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
ins: Vale.X64.Machine_Semantics_s.ins -> Vale.X64.Machine_Semantics_s.st Prims.unit
{ "end_col": 30, "end_line": 719, "start_col": 2, "start_line": 688 }
Prims.Tot
val instr_write_outputs (outs: list instr_out) (args: list instr_operand) (vs: instr_ret_t outs) (oprs: instr_operands_t outs args) (s_orig s: machine_state) : machine_state
[ { "abbrev": true, "full_module": "Vale.X64.Bytes_Code_s", "short_module": "BC" }, { "abbrev": false, "full_module": "FStar.Seq.Base", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instructions_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Instruction_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Four_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words.Two_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Heap", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.HeapTypes_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.MachineHeap_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.List.Tot", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state) : machine_state = match outs with | [] -> s | (_, i)::outs -> ( let ((v:instr_val_t i), (vs:instr_ret_t outs)) = match outs with | [] -> (vs, ()) | _::_ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s )
val instr_write_outputs (outs: list instr_out) (args: list instr_operand) (vs: instr_ret_t outs) (oprs: instr_operands_t outs args) (s_orig s: machine_state) : machine_state let rec instr_write_outputs (outs: list instr_out) (args: list instr_operand) (vs: instr_ret_t outs) (oprs: instr_operands_t outs args) (s_orig s: machine_state) : machine_state =
false
null
false
match outs with | [] -> s | (_, i) :: outs -> (let (v: instr_val_t i), (vs: instr_ret_t outs) = match outs with | [] -> (vs, ()) | _ :: _ -> let vs = coerce vs in (fst vs, snd vs) in match i with | IOpEx i -> let oprs = coerce oprs in let s = instr_write_output_explicit i v (fst oprs) s_orig s in instr_write_outputs outs args vs (snd oprs) s_orig s | IOpIm i -> let s = instr_write_output_implicit i v s_orig s in instr_write_outputs outs args vs (coerce oprs) s_orig s)
{ "checked_file": "Vale.X64.Machine_Semantics_s.fst.checked", "dependencies": [ "Vale.X64.Machine_s.fst.checked", "Vale.X64.Instructions_s.fsti.checked", "Vale.X64.Instruction_s.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.X64.Bytes_Code_s.fst.checked", "Vale.Lib.Set.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Words.Two_s.fsti.checked", "Vale.Def.Words.Four_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.MachineHeap_s.fst.checked", "Vale.Arch.HeapTypes_s.fst.checked", "Vale.Arch.Heap.fsti.checked", "prims.fst.checked", "FStar.Seq.Base.fsti.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Option.fst.checked", "FStar.Mul.fst.checked", "FStar.Map.fsti.checked", "FStar.List.Tot.fst.checked", "FStar.FunctionalExtensionality.fsti.checked" ], "interface_file": false, "source_file": "Vale.X64.Machine_Semantics_s.fst" }
[ "total" ]
[ "Prims.list", "Vale.X64.Instruction_s.instr_out", "Vale.X64.Instruction_s.instr_operand", "Vale.X64.Instruction_s.instr_ret_t", "Vale.X64.Instruction_s.instr_operands_t", "Vale.X64.Machine_Semantics_s.machine_state", "Vale.X64.Instruction_s.instr_operand_inout", "Vale.X64.Instruction_s.instr_val_t", "Vale.X64.Instruction_s.instr_operand_explicit", "Vale.X64.Machine_Semantics_s.instr_write_outputs", "FStar.Pervasives.Native.snd", "Vale.X64.Instruction_s.instr_operand_t", "Vale.X64.Machine_Semantics_s.instr_write_output_explicit", "FStar.Pervasives.Native.fst", "FStar.Pervasives.Native.tuple2", "Vale.X64.Instruction_s.coerce", "Vale.X64.Instruction_s.instr_operand_implicit", "Vale.X64.Machine_Semantics_s.instr_write_output_implicit", "FStar.Pervasives.Native.Mktuple2" ]
[]
module Vale.X64.Machine_Semantics_s open FStar.Mul open FStar.List.Tot open Vale.Def.Prop_s open Vale.Def.Opaque_s include Vale.Arch.MachineHeap_s open Vale.Arch.HeapTypes_s open Vale.Arch.Heap open Vale.X64.Machine_s open Vale.X64.CPU_Features_s open Vale.Def.Words_s open Vale.Def.Words.Two_s open Vale.Def.Words.Four_s open Vale.Def.Types_s open Vale.X64.Instruction_s open Vale.X64.Instructions_s open FStar.Seq.Base module BC = Vale.X64.Bytes_Code_s //type uint64:eqtype = UInt64.t unfold let (.[]) = Map.sel unfold let (.[]<-) = Map.upd //TODO: [@"opaque_to_smt"] let equals_instr (x1 x2:instr_t_record) : Type0 = squash (x1 == x2) noeq type instr_annotation (it:instr_t_record) = | AnnotateNone : instr_annotation it | AnnotateXor64 : equals_instr it (InstrTypeRecord ins_Xor64) -> instr_annotation it | AnnotatePxor : equals_instr it (InstrTypeRecord ins_Pxor) -> instr_annotation it | AnnotateVPxor : equals_instr it (InstrTypeRecord ins_VPxor) -> instr_annotation it | AnnotateGhost : equals_instr it (InstrTypeRecord ins_Ghost) -> instr_annotation it | AnnotateComment : s:string{it == (InstrTypeRecord (ins_Comment s))} -> instr_annotation it | AnnotateLargeComment : s:string{it == (InstrTypeRecord (ins_LargeComment s))} -> instr_annotation it | AnnotateNewline : equals_instr it (InstrTypeRecord ins_Newline) -> instr_annotation it | AnnotateSpace : n:nat{it == (InstrTypeRecord (ins_Space n))} -> instr_annotation it | AnnotateMovbe64 : equals_instr it (InstrTypeRecord ins_MovBe64) -> instr_annotation it | AnnotateMov64 : equals_instr it (InstrTypeRecord ins_Mov64) -> instr_annotation it | AnnotatePrefetchnta : equals_instr it (InstrTypeRecord ins_Prefetchnta) -> instr_annotation it let ins = BC.instruction_t instr_annotation let ocmp = BC.ocmp let code = BC.code_t instr_annotation let codes = BC.codes_t instr_annotation noeq type machine_stack = | Machine_stack: initial_rsp:nat64{initial_rsp >= 4096} -> // Initial rsp pointer when entering the function stack_mem:Map.t int nat8 -> // Stack contents machine_stack unfold let flag_val_t = option bool // HACK: this shouldn't have to be unfolded (it has to do with the lambda in FStar.FunctionalExtensionality.(^->)) type flags_t = FStar.FunctionalExtensionality.restricted_t flag (fun _ -> flag_val_t) type regs_t = FStar.FunctionalExtensionality.restricted_t reg t_reg noeq type machine_state = { ms_ok: bool; ms_regs: regs_t; ms_flags: flags_t; ms_heap: heap_impl; ms_stack: machine_stack; ms_stackTaint: memTaint_t; ms_trace: list observation; } let get_fst_ocmp (o:ocmp) = match o with | BC.OEq o1 _ | BC.ONe o1 _ | BC.OLe o1 _ | BC.OGe o1 _ | BC.OLt o1 _ | BC.OGt o1 _ -> o1 let get_snd_ocmp (o:ocmp) = match o with | BC.OEq _ o2 | BC.ONe _ o2 | BC.OLe _ o2 | BC.OGe _ o2 | BC.OLt _ o2 | BC.OGt _ o2 -> o2 unfold let eval_reg (r:reg) (s:machine_state) : t_reg r = s.ms_regs r unfold let eval_reg_64 (r:reg_64) (s:machine_state) : nat64 = eval_reg (Reg 0 r) s unfold let eval_reg_xmm (r:reg_xmm) (s:machine_state) : quad32 = eval_reg (Reg 1 r) s unfold let eval_reg_int (r:reg) (s:machine_state) : int = t_reg_to_int r.rf (eval_reg r s) unfold let eval_mem (ptr:int) (s:machine_state) : nat64 = get_heap_val64 ptr (heap_get s.ms_heap) unfold let eval_mem128 (ptr:int) (s:machine_state) : quad32 = get_heap_val128 ptr (heap_get s.ms_heap) unfold let eval_stack (ptr:int) (s:machine_stack) : nat64 = let Machine_stack _ mem = s in get_heap_val64 ptr mem unfold let eval_stack128 (ptr:int) (s:machine_stack) : quad32 = let Machine_stack _ mem = s in get_heap_val128 ptr mem [@va_qattr] let eval_maddr (m:maddr) (s:machine_state) : int = match m with | MConst n -> n | MReg r offset -> (eval_reg_int r s) + offset | MIndex base scale index offset -> (eval_reg_int base s) + scale * (eval_reg_int index s) + offset let eval_operand (o:operand64) (s:machine_state) : nat64 = match o with | OConst n -> n | OReg r -> eval_reg_64 r s | OMem (m, _) -> eval_mem (eval_maddr m s) s | OStack (m, _) -> eval_stack (eval_maddr m s) s.ms_stack let eval_mov128_op (o:operand128) (s:machine_state) : quad32 = match o with | OConst c -> c | OReg i -> eval_reg_xmm i s | OMem (m, _) -> eval_mem128 (eval_maddr m s) s | OStack (m, _) -> eval_stack128 (eval_maddr m s) s.ms_stack let eval_ocmp (s:machine_state) (c:ocmp) : bool = match c with | BC.OEq o1 o2 -> eval_operand o1 s = eval_operand o2 s | BC.ONe o1 o2 -> eval_operand o1 s <> eval_operand o2 s | BC.OLe o1 o2 -> eval_operand o1 s <= eval_operand o2 s | BC.OGe o1 o2 -> eval_operand o1 s >= eval_operand o2 s | BC.OLt o1 o2 -> eval_operand o1 s < eval_operand o2 s | BC.OGt o1 o2 -> eval_operand o1 s > eval_operand o2 s [@"opaque_to_smt"] let eval_ocmp_opaque (s:machine_state) (c:ocmp) : bool = eval_ocmp s c let update_reg' (r:reg) (v:t_reg r) (s:machine_state) : machine_state = {s with ms_regs = FStar.FunctionalExtensionality.on_dom reg (fun r' -> if r' = r then v else s.ms_regs r')} let update_reg_64' (r:reg_64) (v:nat64) (s:machine_state) : machine_state = update_reg' (Reg 0 r) v s let update_reg_xmm' (r:reg_xmm) (v:quad32) (s:machine_state) : machine_state = update_reg' (Reg 1 r) v s //val mod_8: (n:nat{n < pow2_64}) -> nat8 //let mod_8 n = n % 0x100 (* Check if the taint annotation of a memory operand matches the taint in the memory map. Evaluation will fail in case of a mismatch. This allows the taint analysis to learn information about the memory map from the annotation, assuming that the code has been verified not to fail. (Note that this only relates to memory maps, so non-memory operands need no annotation.) *) [@"opaque_to_smt"] let rec match_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (b:bool{b <==> (forall i.{:pattern (memTaint `Map.sel` i)} (i >= addr /\ i < addr + n) ==> memTaint.[i] == t)}) (decreases n) = if n = 0 then true else if memTaint.[addr] <> t then false else match_n (addr + 1) (n - 1) memTaint t [@"opaque_to_smt"] let rec update_n (addr:int) (n:nat) (memTaint:memTaint_t) (t:taint) : Tot (m:memTaint_t{( forall i.{:pattern (m `Map.sel` i)} ((i >= addr /\ i < addr + n) ==> m.[i] == t) /\ ((i < addr \/ i >= addr + n) ==> m.[i] == memTaint.[i]))}) (decreases n) = if n = 0 then memTaint else update_n (addr + 1) (n - 1) (memTaint.[addr] <- t) t let lemma_is_machine_heap_update64 (ptr:int) (v:nat64) (mh:machine_heap) : Lemma (requires valid_addr64 ptr mh) (ensures is_machine_heap_update mh (update_heap64 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap64 ptr v mh))] = reveal_opaque (`%valid_addr64) valid_addr64; update_heap64_reveal (); () let update_mem_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = if valid_addr64 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap64 ptr v (heap_get s.ms_heap)) (update_n ptr 8 (heap_taint s.ms_heap) t) } else s let lemma_is_machine_heap_update128 (ptr:int) (v:quad32) (mh:machine_heap) : Lemma (requires valid_addr128 ptr mh) (ensures is_machine_heap_update mh (update_heap128 ptr v mh)) [SMTPat (is_machine_heap_update mh (update_heap128 ptr v mh))] = let lemma_is_machine_heap_update32 (ptr:int) (v:nat32) (mh:machine_heap) : Lemma (requires valid_addr ptr mh /\ valid_addr (ptr + 1) mh /\ valid_addr (ptr + 2) mh /\ valid_addr (ptr + 3) mh ) (ensures is_machine_heap_update mh (update_heap32 ptr v mh)) = update_heap32_reveal () in let mem1 = update_heap32 ptr v.lo0 mh in let mem2 = update_heap32 (ptr + 4) v.lo1 mem1 in let mem3 = update_heap32 (ptr + 8) v.hi2 mem2 in reveal_opaque (`%valid_addr128) valid_addr128; update_heap128_reveal (); lemma_is_machine_heap_update32 ptr v.lo0 mh; lemma_is_machine_heap_update32 (ptr + 4) v.lo1 mem1; lemma_is_machine_heap_update32 (ptr + 8) v.hi2 mem2; lemma_is_machine_heap_update32 (ptr + 12) v.hi3 mem3 let update_mem128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = if valid_addr128 ptr (heap_get s.ms_heap) then { s with ms_heap = heap_upd s.ms_heap (update_heap128 ptr v (heap_get s.ms_heap)) (update_n ptr 16 (heap_taint s.ms_heap) t) } else s unfold let update_stack64' (ptr:int) (v:nat64) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap64 ptr v mem in Machine_stack init_rsp mem unfold let update_stack128' (ptr:int) (v:quad32) (s:machine_stack) : machine_stack = let Machine_stack init_rsp mem = s in let mem = update_heap128 ptr v mem in Machine_stack init_rsp mem let update_stack_and_taint (ptr:int) (v:nat64) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack64' ptr v s.ms_stack; ms_stackTaint = update_n ptr 8 s.ms_stackTaint t; } let update_stack128_and_taint (ptr:int) (v:quad32) (s:machine_state) (t:taint) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in { s with ms_stack = update_stack128' ptr v s.ms_stack; ms_stackTaint = update_n ptr 16 s.ms_stackTaint t } unfold let valid_src_stack64 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr64 ptr mem unfold let valid_src_stack128 (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in valid_addr128 ptr mem let valid_src_operand (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, t) -> valid_src_stack64 (eval_maddr m s) s.ms_stack let valid_src_operand64_and_taint (o:operand64) (s:machine_state) : bool = match o with | OConst n -> true | OReg r -> true | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr64 ptr (heap_get s.ms_heap) && match_n ptr 8 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack64 ptr s.ms_stack && match_n ptr 8 s.ms_stackTaint t let valid_src_operand128_and_taint (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, t) -> let ptr = eval_maddr m s in valid_addr128 ptr (heap_get s.ms_heap) && match_n ptr 16 (heap_taint s.ms_heap) t | OStack (m, t) -> let ptr = eval_maddr m s in valid_src_stack128 ptr s.ms_stack && match_n ptr 16 s.ms_stackTaint t let valid_ocmp (c:ocmp) (s:machine_state) : bool = match c with | BC.OEq o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.ONe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGe o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OLt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s | BC.OGt o1 o2 -> valid_src_operand64_and_taint o1 s && valid_src_operand64_and_taint o2 s [@"opaque_to_smt"] let valid_ocmp_opaque (c:ocmp) (s:machine_state) : bool = valid_ocmp c s unfold let valid_dst_stack64 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 8 <= init_rsp unfold let valid_dst_stack128 (rsp:nat64) (ptr:int) (st:machine_stack) : bool = let Machine_stack init_rsp mem = st in // We are allowed to store anywhere between rRsp and the initial stack pointer ptr >= rsp && ptr + 16 <= init_rsp let valid_dst_operand64 (o:operand64) (s:machine_state) : bool = match o with | OConst n -> false | OReg r -> not (rRsp = r) | OMem (m, _) -> valid_addr64 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack64 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let valid_dst_operand128 (o:operand128) (s:machine_state) : bool = match o with | OConst _ -> false | OReg i -> true // We leave it to the printer/assembler to object to invalid XMM indices | OMem (m, _) -> valid_addr128 (eval_maddr m s) (heap_get s.ms_heap) | OStack (m, _) -> valid_dst_stack128 (eval_reg_64 rRsp s) (eval_maddr m s) s.ms_stack let update_operand64_preserve_flags'' (o:operand64) (v:nat64) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg r -> update_reg_64' r v s | OMem (m, t) -> update_mem_and_taint (eval_maddr m s_orig) v s t // see valid_buf_maddr64 for how eval_maddr connects to b and i | OStack (m, t) -> update_stack_and_taint (eval_maddr m s_orig) v s t let update_operand64_preserve_flags' (o:operand64) (v:nat64) (s:machine_state) : machine_state = update_operand64_preserve_flags'' o v s s let update_operand128_preserve_flags'' (o:operand128) (v:quad32) (s_orig s:machine_state) : machine_state = match o with | OConst _ -> {s with ms_ok = false} | OReg i -> update_reg_xmm' i v s | OMem (m, t) -> update_mem128_and_taint (eval_maddr m s_orig) v s t | OStack (m, t) -> update_stack128_and_taint (eval_maddr m s_orig) v s t let update_operand128_preserve_flags' (o:operand128) (v:quad32) (s:machine_state) : machine_state = update_operand128_preserve_flags'' o v s s let flags_none (f:flag) : flag_val_t = None let havoc_flags : flags_t = FStar.FunctionalExtensionality.on_dom flag flags_none // Default version havocs flags let update_operand64' (o:operand64) (ins:ins) (v:nat64) (s:machine_state) : machine_state = { (update_operand64_preserve_flags' o v s) with ms_flags = havoc_flags } let update_rsp' (new_rsp:int) (s:machine_state) : machine_state = let Machine_stack init_rsp mem = s.ms_stack in // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page if new_rsp >= init_rsp - 4096 && new_rsp <= init_rsp then update_reg_64' rRsp new_rsp s else s let cf (flags:flags_t) : flag_val_t = flags fCarry let overflow(flags:flags_t) : flag_val_t = flags fOverflow let update_cf' (flags:flags_t) (new_cf:bool) : (new_flags:flags_t{cf new_flags == Some new_cf}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fCarry then Some new_cf else flags f) let update_of' (flags:flags_t) (new_of:bool) : (new_flags:flags_t{overflow new_flags == Some new_of}) = FStar.FunctionalExtensionality.on_dom flag (fun f -> if f = fOverflow then Some new_of else flags f) let free_stack' (start finish:int) (st:machine_stack) : machine_stack = let Machine_stack init_rsp mem = st in let domain = Map.domain mem in // Returns the domain, without elements between start and finish let restricted_domain = Vale.Lib.Set.remove_between domain start finish in // The new domain of the stack does not contain elements between start and finish let new_mem = Map.restrict restricted_domain mem in Machine_stack init_rsp new_mem // Define a stateful monad to simplify defining the instruction semantics let st (a:Type) = machine_state -> a & machine_state unfold let return (#a:Type) (x:a) : st a = fun s -> (x, s) unfold let (let*) (#a:Type) (#b:Type) (m:st a) (f:a -> st b) : st b = fun s0 -> let (x, s1) = m s0 in let (y, s2) = f x s1 in (y, {s2 with ms_ok = s0.ms_ok && s1.ms_ok && s2.ms_ok}) unfold let get : st machine_state = fun s -> (s, s) unfold let set (s:machine_state) : st unit = fun _ -> ((), s) unfold let fail : st unit = fun s -> ((), {s with ms_ok = false}) unfold let check_imm (valid:bool) : st unit = if valid then return () else fail unfold let check (valid: machine_state -> bool) : st unit = let* s = get in if valid s then return () else fail unfold let try_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = match o with | None -> fail | Some x -> f x let apply_option (#a:Type) (o:option a) (f:a -> st unit) : st unit = try_option o f unfold let run (f:st unit) (s:machine_state) : machine_state = snd (f s) // Monadic update operations unfold let update_operand64_preserve_flags (dst:operand64) (v:nat64) : st unit = check (valid_dst_operand64 dst);* let* s = get in set (update_operand64_preserve_flags' dst v s) unfold let update_rsp (i:int) : st unit = // Only modify the stack pointer if the new value is valid, that is in the current stack frame, and in the same page check (fun s -> i >= s.ms_stack.initial_rsp - 4096);* check (fun s -> i <= s.ms_stack.initial_rsp);* let* s = get in set (update_rsp' i s) let update_reg_64 (r:reg_64) (v:nat64) : st unit = let* s = get in set (update_reg_64' r v s) let update_reg_xmm (x:reg_xmm) (ins:ins) (v:quad32) : st unit = let* s = get in set ( { (update_reg_xmm' x v s) with ms_flags = havoc_flags } ) let update_xmm_preserve_flags (x:reg_xmm) (v:quad32) : st unit = let* s = get in set ( update_reg_xmm' x v s ) let update_flags (new_flags:flags_t) : st unit = let* s = get in set ( { s with ms_flags = new_flags } ) let update_cf (new_cf:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' s.ms_flags new_cf } ) let update_of (new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_of' s.ms_flags new_of } ) let update_cf_of (new_cf new_of:bool) : st unit = let* s = get in set ( { s with ms_flags = update_cf' (update_of' s.ms_flags new_of) new_cf } ) let free_stack (start finish:int) : st unit = let* s = get in set ( { s with ms_stack = free_stack' start finish s.ms_stack} ) let bind_option (#a #b:Type) (v:option a) (f:a -> option b) : option b = match v with | None -> None | Some x -> f x let operand_obs (s:machine_state) (o:operand64) : list observation = match o with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let operand_obs128 (s:machine_state) (op:operand128) : list observation = match op with | OConst _ | OReg _ -> [] | OMem (m, _) | OStack (m, _) -> [MemAccess (eval_maddr m s)] [@instr_attr] let obs_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : list observation = match i with | IOp64 -> operand_obs s o | IOpXmm -> operand_obs128 s o [@instr_attr] let obs_operand_implicit (i:instr_operand_implicit) (s:machine_state) : list observation = match i with | IOp64One o -> operand_obs s o | IOpXmmOne o -> operand_obs128 s o | IOpFlagsCf | IOpFlagsOf -> [] [@instr_attr] let rec obs_args (args:list instr_operand) (oprs:instr_operands_t_args args) (s:machine_state) : list observation = match args with | [] -> [] | i::args -> match i with | IOpEx i -> let oprs = coerce oprs in obs_operand_explicit i (fst oprs) s @ obs_args args (snd oprs) s | IOpIm i -> obs_operand_implicit i s @ obs_args args (coerce oprs) s [@instr_attr] let rec obs_inouts (inouts:list instr_out) (args:list instr_operand) (oprs:instr_operands_t inouts args) (s:machine_state) : list observation = match inouts with | [] -> obs_args args oprs s | (_, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (obs_operand_explicit i (fst oprs) s), snd oprs | IOpIm i -> obs_operand_implicit i s, coerce oprs in v @ obs_inouts inouts args oprs s [@instr_attr] let ins_obs (ins:ins) (s:machine_state) : list observation = match ins with | BC.Instr (InstrTypeRecord #outs #args _) oprs _ -> obs_inouts outs args oprs s | BC.Push src _ -> operand_obs s src | BC.Pop dst _ -> operand_obs s dst | BC.Alloc _ | BC.Dealloc _ -> [] [@instr_attr] let instr_eval_operand_explicit (i:instr_operand_explicit) (o:instr_operand_t i) (s:machine_state) : option (instr_val_t (IOpEx i)) = match i with | IOp64 -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmm -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None [@instr_attr] let instr_eval_operand_implicit (i:instr_operand_implicit) (s:machine_state) : option (instr_val_t (IOpIm i)) = match i with | IOp64One o -> if valid_src_operand64_and_taint o s then Some (eval_operand o s) else None | IOpXmmOne o -> if valid_src_operand128_and_taint o s then Some (eval_mov128_op o s) else None | IOpFlagsCf -> cf s.ms_flags | IOpFlagsOf -> overflow s.ms_flags [@instr_attr] let rec instr_apply_eval_args (outs:list instr_out) (args:list instr_operand) (f:instr_args_t outs args) (oprs:instr_operands_t_args args) (s:machine_state) : option (instr_ret_t outs) = match args with | [] -> f | i::args -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_args_t outs args) = coerce f in bind_option v (fun v -> instr_apply_eval_args outs args (f v) oprs s) [@instr_attr] let rec instr_apply_eval_inouts (outs inouts:list instr_out) (args:list instr_operand) (f:instr_inouts_t outs inouts args) (oprs:instr_operands_t inouts args) (s:machine_state) : option (instr_ret_t outs) = match inouts with | [] -> instr_apply_eval_args outs args f oprs s | (Out, i)::inouts -> let oprs = match i with | IOpEx i -> snd #(instr_operand_t i) (coerce oprs) | IOpIm i -> coerce oprs in instr_apply_eval_inouts outs inouts args (coerce f) oprs s | (InOut, i)::inouts -> let (v, oprs) = match i with | IOpEx i -> let oprs = coerce oprs in (instr_eval_operand_explicit i (fst oprs) s, snd oprs) | IOpIm i -> (instr_eval_operand_implicit i s, coerce oprs) in let f:arrow (instr_val_t i) (instr_inouts_t outs inouts args) = coerce f in bind_option v (fun v -> instr_apply_eval_inouts outs inouts args (f v) oprs s) (* Take the all the input operands for an instruction and: - check that they are valid - evaluate them - apply the instruction's evaluator function f to the evaluated operands *) [@instr_attr] let instr_apply_eval (outs:list instr_out) (args:list instr_operand) (f:instr_eval_t outs args) (oprs:instr_operands_t outs args) (s:machine_state) : option (instr_ret_t outs) = instr_apply_eval_inouts outs outs args f oprs s let state_or_fail (s:machine_state) (b:bool) (s':machine_state) : machine_state = if b then s' else {s with ms_ok = false} [@instr_attr] let instr_write_output_explicit (i:instr_operand_explicit) (v:instr_val_t (IOpEx i)) (o:instr_operand_t i) (s_orig s:machine_state) : machine_state = match i with | IOp64 -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmm -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) [@instr_attr] let instr_write_output_implicit (i:instr_operand_implicit) (v:instr_val_t (IOpIm i)) (s_orig s:machine_state) : machine_state = match i with | IOp64One o -> state_or_fail s (valid_dst_operand64 o s_orig) (update_operand64_preserve_flags'' o v s_orig s) | IOpXmmOne o -> state_or_fail s (valid_dst_operand128 o s_orig) (update_operand128_preserve_flags'' o v s_orig s) | IOpFlagsCf -> {s with ms_flags = update_cf' s.ms_flags v} | IOpFlagsOf -> {s with ms_flags = update_of' s.ms_flags v} (* For each output operand: - compute the location of the operand in s_orig - check that the operand is valid and update the current state (in order that the operands appear in "outs") *) [@instr_attr] let rec instr_write_outputs (outs:list instr_out) (args:list instr_operand) (vs:instr_ret_t outs) (oprs:instr_operands_t outs args) (s_orig s:machine_state)
false
false
Vale.X64.Machine_Semantics_s.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val instr_write_outputs (outs: list instr_out) (args: list instr_operand) (vs: instr_ret_t outs) (oprs: instr_operands_t outs args) (s_orig s: machine_state) : machine_state
[ "recursion" ]
Vale.X64.Machine_Semantics_s.instr_write_outputs
{ "file_name": "vale/specs/hardware/Vale.X64.Machine_Semantics_s.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
outs: Prims.list Vale.X64.Instruction_s.instr_out -> args: Prims.list Vale.X64.Instruction_s.instr_operand -> vs: Vale.X64.Instruction_s.instr_ret_t outs -> oprs: Vale.X64.Instruction_s.instr_operands_t outs args -> s_orig: Vale.X64.Machine_Semantics_s.machine_state -> s: Vale.X64.Machine_Semantics_s.machine_state -> Vale.X64.Machine_Semantics_s.machine_state
{ "end_col": 5, "end_line": 669, "start_col": 2, "start_line": 652 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_3p = uint8_1p & uint8_2p
let uint8_3p =
false
null
false
uint8_1p & uint8_2p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_2p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *)
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_3p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_3p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 10, "start_col": 15, "start_line": 10 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t
let uint8_1p =
false
null
false
LowStar.Buffer.buffer FStar.UInt8.t
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "LowStar.Buffer.buffer", "FStar.UInt8.t" ]
[]
module Hacl.Impl.SHA2.Types
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_1p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_1p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 50, "end_line": 4, "start_col": 15, "start_line": 4 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_7p = uint8_1p & uint8_6p
let uint8_7p =
false
null
false
uint8_1p & uint8_6p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_6p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p let uint8_4p = uint8_1p & uint8_3p let uint8_5p = uint8_1p & uint8_4p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_7p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_7p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 14, "start_col": 15, "start_line": 14 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_2p = uint8_1p & uint8_1p
let uint8_2p =
false
null
false
uint8_1p & uint8_1p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_2p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_2p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 9, "start_col": 15, "start_line": 9 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_2x8p = uint8_8p & uint8_8p
let uint8_2x8p =
false
null
false
uint8_8p & uint8_8p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_8p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p let uint8_4p = uint8_1p & uint8_3p let uint8_5p = uint8_1p & uint8_4p let uint8_6p = uint8_1p & uint8_5p let uint8_7p = uint8_1p & uint8_6p let uint8_8p = uint8_1p & uint8_7p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_2x8p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_2x8p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 36, "end_line": 18, "start_col": 17, "start_line": 18 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_6p = uint8_1p & uint8_5p
let uint8_6p =
false
null
false
uint8_1p & uint8_5p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_5p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p let uint8_4p = uint8_1p & uint8_3p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_6p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_6p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 13, "start_col": 15, "start_line": 13 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_5p = uint8_1p & uint8_4p
let uint8_5p =
false
null
false
uint8_1p & uint8_4p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_4p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_5p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_5p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 12, "start_col": 15, "start_line": 12 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_8p = uint8_1p & uint8_7p
let uint8_8p =
false
null
false
uint8_1p & uint8_7p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_7p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p let uint8_4p = uint8_1p & uint8_3p let uint8_5p = uint8_1p & uint8_4p let uint8_6p = uint8_1p & uint8_5p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_8p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_8p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 15, "start_col": 15, "start_line": 15 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_2x4p = uint8_4p & uint8_4p
let uint8_2x4p =
false
null
false
uint8_4p & uint8_4p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_4p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p let uint8_3p = uint8_1p & uint8_2p let uint8_4p = uint8_1p & uint8_3p let uint8_5p = uint8_1p & uint8_4p let uint8_6p = uint8_1p & uint8_5p let uint8_7p = uint8_1p & uint8_6p let uint8_8p = uint8_1p & uint8_7p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_2x4p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_2x4p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 36, "end_line": 17, "start_col": 17, "start_line": 17 }
Prims.Tot
[ { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "Hacl.Impl.SHA2", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let uint8_4p = uint8_1p & uint8_3p
let uint8_4p =
false
null
false
uint8_1p & uint8_3p
{ "checked_file": "Hacl.Impl.SHA2.Types.fst.checked", "dependencies": [ "prims.fst.checked", "LowStar.Buffer.fst.checked", "FStar.UInt8.fsti.checked", "FStar.Pervasives.fsti.checked" ], "interface_file": false, "source_file": "Hacl.Impl.SHA2.Types.fst" }
[ "total" ]
[ "FStar.Pervasives.Native.tuple2", "Hacl.Impl.SHA2.Types.uint8_1p", "Hacl.Impl.SHA2.Types.uint8_3p" ]
[]
module Hacl.Impl.SHA2.Types inline_for_extraction noextract let uint8_1p = LowStar.Buffer.buffer FStar.UInt8.t (* This allows generating pretty names for several types used in SHA2-MB, thus improving code quality. This also avoid an unpleasant dependency from SHA2-128 to SHA2-256. See #523 for discussion. *) let uint8_2p = uint8_1p & uint8_1p
false
true
Hacl.Impl.SHA2.Types.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val uint8_4p : Type0
[]
Hacl.Impl.SHA2.Types.uint8_4p
{ "file_name": "code/sha2-mb/Hacl.Impl.SHA2.Types.fst", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
Type0
{ "end_col": 34, "end_line": 11, "start_col": 15, "start_line": 11 }
Prims.Tot
val va_quick_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg))
[ { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) = (va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b))
val va_quick_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) let va_quick_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) =
false
null
false
(va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([ va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem ]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b))
{ "checked_file": "Vale.AES.X64.AESGCM.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.PolyOps.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.AESGCM.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.quad32", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.AESGCM.va_code_AES_GCM_encrypt_6mult", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.X64.AESGCM.va_wp_AES_GCM_encrypt_6mult", "Vale.AES.X64.AESGCM.va_wpProof_AES_GCM_encrypt_6mult", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.AESGCM open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers //open Vale.Poly1305.Math // For lemma_poly_bits64() open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.Arch.TypesNative open Vale.X64.CPU_Features_s open Vale.AES.X64.PolyOps open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash open Vale.AES.X64.AESopt open Vale.AES.X64.AESopt2 //-- AES_GCM_encrypt_6mult val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
false
false
Vale.AES.X64.AESGCM.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg))
[]
Vale.AES.X64.AESGCM.va_quick_AES_GCM_encrypt_6mult
{ "file_name": "obj/Vale.AES.X64.AESGCM.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> h_LE: Vale.X64.Decls.quad32 -> iv_b: Vale.X64.Memory.buffer128 -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> scratch_b: Vale.X64.Memory.buffer128 -> key_words: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> hkeys_b: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AESGCM.va_code_AES_GCM_encrypt_6mult alg)
{ "end_col": 41, "end_line": 183, "start_col": 2, "start_line": 175 }
Prims.Tot
val va_wp_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wp_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b) `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ (va_get_reg64 rRdx va_s0) `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> (va_get_reg64 rRdx va_s0) `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64) (va_x_rdx: nat64) (va_x_rcx: nat64) (va_x_rbx: nat64) (va_x_r11: nat64) (va_x_r12: nat64) (va_x_r13: nat64) (va_x_r14: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32) (va_x_xmm6: quad32) (va_x_xmm7: quad32) (va_x_xmm8: quad32) (va_x_xmm9: quad32) (va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32) (va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap6: vale_heap) (va_x_heap2: vale_heap) (va_x_heap3: vale_heap) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 ( va_upd_reg64 rRbx va_x_rbx ( va_upd_reg64 rRcx va_x_rcx ( va_upd_reg64 rRdx va_x_rdx ( va_upd_reg64 rRsi va_x_rsi ( va_upd_reg64 rRdi va_x_rdi ( va_upd_reg64 rRax va_x_rax ( va_upd_mem va_x_mem va_s0 ) ) ) ) ) ) ) )) )))))))))) ))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.AESGCM.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.PolyOps.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.AESGCM.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.quad32", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.sse_enabled", "Vale.X64.CPU_Features_s.movbe_enabled", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRbp", "Prims.op_Subtraction", "Vale.X64.Machine_s.rR9", "Prims.l_or", "Vale.X64.Decls.buffers_disjoint128", "Prims.eq2", "Prims.op_LessThan", "Prims.op_Addition", "Prims.op_Multiply", "Vale.X64.Machine_s.pow2_64", "Prims.nat", "Vale.X64.Decls.buffer_length", "Vale.X64.Memory.vuint128", "Vale.X64.Machine_s.pow2_32", "Vale.X64.Memory.buffer_addr", "Vale.AES.X64.AESopt.aes_reqs_offset", "Vale.X64.Machine_s.rRcx", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Words_s.Mkfour", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.GHash.hkeys_reqs_priv", "Vale.X64.Decls.s128", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.int", "Prims.op_Modulus", "Prims.l_imp", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Prims.op_Division", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Memory.nat64", "Vale.X64.Flags.t", "Vale.X64.Decls.modifies_buffer128", "Vale.X64.Decls.modifies_buffer_specific128", "Vale.Def.Types_s.nat64", "Vale.AES.GCTR.gctr_partial", "Vale.AES.GHash.ghash_incremental0", "Vale.X64.Decls.buffer128_read", "Vale.AES.GCTR.inc32lite", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_reg64", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_upd_mem" ]
[]
module Vale.AES.X64.AESGCM open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers //open Vale.Poly1305.Math // For lemma_poly_bits64() open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.Arch.TypesNative open Vale.X64.CPU_Features_s open Vale.AES.X64.PolyOps open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash open Vale.AES.X64.AESopt open Vale.AES.X64.AESopt2 //-- AES_GCM_encrypt_6mult val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
false
true
Vale.AES.X64.AESGCM.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_AES_GCM_encrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.AESGCM.va_wp_AES_GCM_encrypt_6mult
{ "file_name": "obj/Vale.AES.X64.AESGCM.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> h_LE: Vale.X64.Decls.quad32 -> iv_b: Vale.X64.Memory.buffer128 -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> scratch_b: Vale.X64.Memory.buffer128 -> key_words: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> hkeys_b: Vale.X64.Memory.buffer128 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 54, "end_line": 155, "start_col": 2, "start_line": 102 }
Prims.Tot
val va_quick_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg))
[ { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_quick_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) = (va_QProc (va_code_AES_GCM_decrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b))
val va_quick_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) let va_quick_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg)) =
false
null
false
(va_QProc (va_code_AES_GCM_decrypt_6mult alg) ([ va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem ]) (va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b))
{ "checked_file": "Vale.AES.X64.AESGCM.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.PolyOps.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.AESGCM.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.quad32", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.QuickCode.va_QProc", "Prims.unit", "Vale.AES.X64.AESGCM.va_code_AES_GCM_decrypt_6mult", "Prims.Cons", "Vale.X64.QuickCode.mod_t", "Vale.X64.QuickCode.va_Mod_flags", "Vale.X64.QuickCode.va_Mod_mem_heaplet", "Vale.X64.QuickCode.va_Mod_xmm", "Vale.X64.QuickCode.va_Mod_reg64", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRcx", "Vale.X64.Machine_s.rRdx", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRax", "Vale.X64.QuickCode.va_Mod_mem", "Prims.Nil", "Vale.AES.X64.AESGCM.va_wp_AES_GCM_decrypt_6mult", "Vale.AES.X64.AESGCM.va_wpProof_AES_GCM_decrypt_6mult", "Vale.X64.QuickCode.va_quickCode" ]
[]
module Vale.AES.X64.AESGCM open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers //open Vale.Poly1305.Math // For lemma_poly_bits64() open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.Arch.TypesNative open Vale.X64.CPU_Features_s open Vale.AES.X64.PolyOps open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash open Vale.AES.X64.AESopt open Vale.AES.X64.AESopt2 //-- AES_GCM_encrypt_6mult val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) = (va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b)) //-- //-- AES_GCM_decrypt_6mult val va_code_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_decrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_decrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) val va_wpProof_AES_GCM_decrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES_GCM_decrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_decrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32))
false
false
Vale.AES.X64.AESGCM.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_quick_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) : (va_quickCode unit (va_code_AES_GCM_decrypt_6mult alg))
[]
Vale.AES.X64.AESGCM.va_quick_AES_GCM_decrypt_6mult
{ "file_name": "obj/Vale.AES.X64.AESGCM.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> h_LE: Vale.X64.Decls.quad32 -> iv_b: Vale.X64.Memory.buffer128 -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> scratch_b: Vale.X64.Memory.buffer128 -> key_words: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> hkeys_b: Vale.X64.Memory.buffer128 -> Vale.X64.QuickCode.va_quickCode Prims.unit (Vale.AES.X64.AESGCM.va_code_AES_GCM_decrypt_6mult alg)
{ "end_col": 41, "end_line": 330, "start_col": 2, "start_line": 322 }
Prims.Tot
val va_wp_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[ { "abbrev": false, "full_module": "Vale.AES.X64.AESopt2", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.AESopt", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GHash", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GF128_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Lemmas", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2.Bits_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2", "short_module": null }, { "abbrev": false, "full_module": "Vale.Math.Poly2_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64.PolyOps", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.CPU_Features_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.TypesNative", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCTR_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.GCM_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_helpers", "short_module": null }, { "abbrev": false, "full_module": "Vale.Arch.Types", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCodes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.QuickCode", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsAes", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsVector", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsMem", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.InsBasic", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Decls", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.State", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Memory", "short_module": null }, { "abbrev": false, "full_module": "Vale.X64.Machine_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.AES_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Seq", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Types_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Words_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Opaque_s", "short_module": null }, { "abbrev": false, "full_module": "Vale.Def.Prop_s", "short_module": null }, { "abbrev": false, "full_module": "FStar.Mul", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "Vale.AES.X64", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let va_wp_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
val va_wp_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 let va_wp_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0 =
false
null
false
(va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` (va_get_reg64 rRdx va_s0) < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ (Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b) `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ (va_get_reg64 rRdx va_s0) `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0 ==> (va_get_reg64 rRdx va_s0) `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem: vale_heap) (va_x_rax: nat64) (va_x_rdi: nat64) (va_x_rsi: nat64) (va_x_rdx: nat64) (va_x_rcx: nat64) (va_x_rbx: nat64) (va_x_r11: nat64) (va_x_r12: nat64) (va_x_r13: nat64) (va_x_r14: nat64) (va_x_xmm0: quad32) (va_x_xmm1: quad32) (va_x_xmm2: quad32) (va_x_xmm3: quad32) (va_x_xmm4: quad32) (va_x_xmm5: quad32) (va_x_xmm6: quad32) (va_x_xmm7: quad32) (va_x_xmm8: quad32) (va_x_xmm9: quad32) (va_x_xmm10: quad32) (va_x_xmm11: quad32) (va_x_xmm12: quad32) (va_x_xmm13: quad32) (va_x_xmm14: quad32) (va_x_xmm15: quad32) (va_x_heap6: vale_heap) (va_x_heap2: vale_heap) (va_x_heap3: vale_heap) (va_x_efl: Vale.X64.Flags.t). let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 ( va_upd_reg64 rRbx va_x_rbx ( va_upd_reg64 rRcx va_x_rcx ( va_upd_reg64 rRdx va_x_rdx ( va_upd_reg64 rRsi va_x_rsi ( va_upd_reg64 rRdi va_x_rdi ( va_upd_reg64 rRax va_x_rax ( va_upd_mem va_x_mem va_s0 ) ) ) ) ) ) ) )) )))))))))) ))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (())))
{ "checked_file": "Vale.AES.X64.AESGCM.fsti.checked", "dependencies": [ "Vale.X64.State.fsti.checked", "Vale.X64.QuickCodes.fsti.checked", "Vale.X64.QuickCode.fst.checked", "Vale.X64.Memory.fsti.checked", "Vale.X64.Machine_s.fst.checked", "Vale.X64.InsVector.fsti.checked", "Vale.X64.InsMem.fsti.checked", "Vale.X64.InsBasic.fsti.checked", "Vale.X64.InsAes.fsti.checked", "Vale.X64.Flags.fsti.checked", "Vale.X64.Decls.fsti.checked", "Vale.X64.CPU_Features_s.fst.checked", "Vale.Math.Poly2_s.fsti.checked", "Vale.Math.Poly2.Lemmas.fsti.checked", "Vale.Math.Poly2.Bits_s.fsti.checked", "Vale.Math.Poly2.Bits.fsti.checked", "Vale.Math.Poly2.fsti.checked", "Vale.Def.Words_s.fsti.checked", "Vale.Def.Types_s.fst.checked", "Vale.Def.Prop_s.fst.checked", "Vale.Def.Opaque_s.fsti.checked", "Vale.Arch.TypesNative.fsti.checked", "Vale.Arch.Types.fsti.checked", "Vale.AES.X64.PolyOps.fsti.checked", "Vale.AES.X64.AESopt2.fsti.checked", "Vale.AES.X64.AESopt.fsti.checked", "Vale.AES.GHash.fsti.checked", "Vale.AES.GF128_s.fsti.checked", "Vale.AES.GF128.fsti.checked", "Vale.AES.GCTR_s.fst.checked", "Vale.AES.GCTR.fsti.checked", "Vale.AES.GCM_helpers.fsti.checked", "Vale.AES.AES_s.fst.checked", "Vale.AES.AES_helpers.fsti.checked", "prims.fst.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.Native.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Mul.fst.checked" ], "interface_file": false, "source_file": "Vale.AES.X64.AESGCM.fsti" }
[ "total" ]
[ "Vale.AES.AES_common_s.algorithm", "Vale.X64.Decls.quad32", "Vale.X64.Memory.buffer128", "FStar.Seq.Base.seq", "Vale.X64.Memory.nat32", "Vale.X64.Decls.va_state", "Prims.unit", "Prims.l_and", "Prims.b2t", "Vale.X64.Decls.va_get_ok", "Vale.X64.CPU_Features_s.sse_enabled", "Vale.X64.CPU_Features_s.movbe_enabled", "Vale.X64.Decls.validDstAddrs128", "Vale.X64.Decls.va_get_mem_heaplet", "Vale.X64.Decls.va_get_reg64", "Vale.X64.Machine_s.rR8", "Vale.X64.Decls.va_get_mem_layout", "Vale.Arch.HeapTypes_s.Public", "Vale.X64.Decls.validSrcAddrs128", "Vale.X64.Machine_s.rRdi", "Vale.X64.Machine_s.rRdx", "Vale.Arch.HeapTypes_s.Secret", "Vale.X64.Machine_s.rRsi", "Vale.X64.Machine_s.rRbp", "Prims.op_Subtraction", "Vale.X64.Machine_s.rR9", "Prims.l_or", "Vale.X64.Decls.buffers_disjoint128", "Prims.eq2", "Prims.op_LessThan", "Prims.op_Addition", "Prims.op_Multiply", "Vale.X64.Machine_s.pow2_64", "Prims.nat", "Vale.X64.Decls.buffer_length", "Vale.X64.Memory.vuint128", "Vale.X64.Machine_s.pow2_32", "Vale.X64.Memory.buffer_addr", "Vale.AES.X64.AESopt.aes_reqs_offset", "Vale.X64.Machine_s.rRcx", "Vale.Def.Words_s.four", "Vale.Def.Types_s.nat32", "Vale.X64.Decls.va_get_xmm", "Vale.Def.Words_s.Mkfour", "Vale.X64.CPU_Features_s.pclmulqdq_enabled", "Vale.Def.Types_s.quad32", "Vale.AES.AES_s.aes_encrypt_LE", "Vale.AES.GHash.hkeys_reqs_priv", "Vale.X64.Decls.s128", "Vale.Def.Types_s.reverse_bytes_quad32", "Prims.int", "Prims.op_Modulus", "Prims.l_imp", "Prims.op_GreaterThan", "Prims.op_GreaterThanOrEqual", "Prims.op_Division", "Prims.l_Forall", "Vale.X64.InsBasic.vale_heap", "Vale.X64.Memory.nat64", "Vale.X64.Flags.t", "Vale.X64.Decls.modifies_buffer128", "Vale.X64.Decls.modifies_buffer_specific128", "Vale.Def.Types_s.nat64", "Vale.AES.GCTR.gctr_partial", "Vale.AES.GHash.ghash_incremental0", "Vale.X64.Decls.buffer128_read", "Vale.AES.GCTR.inc32lite", "Vale.X64.State.vale_state", "Vale.X64.Decls.va_upd_flags", "Vale.X64.Decls.va_upd_mem_heaplet", "Vale.X64.Decls.va_upd_xmm", "Vale.X64.Decls.va_upd_reg64", "Vale.X64.Machine_s.rR14", "Vale.X64.Machine_s.rR13", "Vale.X64.Machine_s.rR12", "Vale.X64.Machine_s.rR11", "Vale.X64.Machine_s.rRbx", "Vale.X64.Machine_s.rRax", "Vale.X64.Decls.va_upd_mem" ]
[]
module Vale.AES.X64.AESGCM open FStar.Mul open Vale.Def.Prop_s open Vale.Def.Opaque_s open Vale.Def.Words_s open Vale.Def.Types_s open FStar.Seq open Vale.AES.AES_s open Vale.X64.Machine_s open Vale.X64.Memory open Vale.X64.State open Vale.X64.Decls open Vale.X64.InsBasic open Vale.X64.InsMem open Vale.X64.InsVector open Vale.X64.InsAes open Vale.X64.QuickCode open Vale.X64.QuickCodes open Vale.Arch.Types open Vale.AES.AES_helpers //open Vale.Poly1305.Math // For lemma_poly_bits64() open Vale.AES.GCM_helpers open Vale.AES.GCTR_s open Vale.AES.GCTR open Vale.Arch.TypesNative open Vale.X64.CPU_Features_s open Vale.AES.X64.PolyOps open Vale.Math.Poly2_s open Vale.Math.Poly2 open Vale.Math.Poly2.Bits_s open Vale.Math.Poly2.Bits open Vale.Math.Poly2.Lemmas open Vale.AES.GF128_s open Vale.AES.GF128 open Vale.AES.GHash open Vale.AES.X64.AESopt open Vale.AES.X64.AESopt2 //-- AES_GCM_encrypt_6mult val va_code_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_encrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_encrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_encrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) : Type0 = (va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 18) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 3) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32) /\ (forall (va_x_mem:vale_heap) (va_x_rax:nat64) (va_x_rdi:nat64) (va_x_rsi:nat64) (va_x_rdx:nat64) (va_x_rcx:nat64) (va_x_rbx:nat64) (va_x_r11:nat64) (va_x_r12:nat64) (va_x_r13:nat64) (va_x_r14:nat64) (va_x_xmm0:quad32) (va_x_xmm1:quad32) (va_x_xmm2:quad32) (va_x_xmm3:quad32) (va_x_xmm4:quad32) (va_x_xmm5:quad32) (va_x_xmm6:quad32) (va_x_xmm7:quad32) (va_x_xmm8:quad32) (va_x_xmm9:quad32) (va_x_xmm10:quad32) (va_x_xmm11:quad32) (va_x_xmm12:quad32) (va_x_xmm13:quad32) (va_x_xmm14:quad32) (va_x_xmm15:quad32) (va_x_heap6:vale_heap) (va_x_heap2:vale_heap) (va_x_heap3:vale_heap) (va_x_efl:Vale.X64.Flags.t) . let va_sM = va_upd_flags va_x_efl (va_upd_mem_heaplet 3 va_x_heap3 (va_upd_mem_heaplet 2 va_x_heap2 (va_upd_mem_heaplet 6 va_x_heap6 (va_upd_xmm 15 va_x_xmm15 (va_upd_xmm 14 va_x_xmm14 (va_upd_xmm 13 va_x_xmm13 (va_upd_xmm 12 va_x_xmm12 (va_upd_xmm 11 va_x_xmm11 (va_upd_xmm 10 va_x_xmm10 (va_upd_xmm 9 va_x_xmm9 (va_upd_xmm 8 va_x_xmm8 (va_upd_xmm 7 va_x_xmm7 (va_upd_xmm 6 va_x_xmm6 (va_upd_xmm 5 va_x_xmm5 (va_upd_xmm 4 va_x_xmm4 (va_upd_xmm 3 va_x_xmm3 (va_upd_xmm 2 va_x_xmm2 (va_upd_xmm 1 va_x_xmm1 (va_upd_xmm 0 va_x_xmm0 (va_upd_reg64 rR14 va_x_r14 (va_upd_reg64 rR13 va_x_r13 (va_upd_reg64 rR12 va_x_r12 (va_upd_reg64 rR11 va_x_r11 (va_upd_reg64 rRbx va_x_rbx (va_upd_reg64 rRcx va_x_rcx (va_upd_reg64 rRdx va_x_rdx (va_upd_reg64 rRsi va_x_rsi (va_upd_reg64 rRdi va_x_rdi (va_upd_reg64 rRax va_x_rax (va_upd_mem va_x_mem va_s0)))))))))))))))))))))))))))))) in va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) ==> va_k va_sM (()))) val va_wpProof_AES_GCM_encrypt_6mult : alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> va_s0:va_state -> va_k:(va_state -> unit -> Type0) -> Ghost (va_state & va_fuel & unit) (requires (va_t_require va_s0 /\ va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b va_s0 va_k)) (ensures (fun (va_sM, va_f0, va_g) -> va_t_ensure (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) va_s0 va_k ((va_sM, va_f0, va_g)))) [@ "opaque_to_smt" va_qattr] let va_quick_AES_GCM_encrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) : (va_quickCode unit (va_code_AES_GCM_encrypt_6mult alg)) = (va_QProc (va_code_AES_GCM_encrypt_6mult alg) ([va_Mod_flags; va_Mod_mem_heaplet 3; va_Mod_mem_heaplet 2; va_Mod_mem_heaplet 6; va_Mod_xmm 15; va_Mod_xmm 14; va_Mod_xmm 13; va_Mod_xmm 12; va_Mod_xmm 11; va_Mod_xmm 10; va_Mod_xmm 9; va_Mod_xmm 8; va_Mod_xmm 7; va_Mod_xmm 6; va_Mod_xmm 5; va_Mod_xmm 4; va_Mod_xmm 3; va_Mod_xmm 2; va_Mod_xmm 1; va_Mod_xmm 0; va_Mod_reg64 rR14; va_Mod_reg64 rR13; va_Mod_reg64 rR12; va_Mod_reg64 rR11; va_Mod_reg64 rRbx; va_Mod_reg64 rRcx; va_Mod_reg64 rRdx; va_Mod_reg64 rRsi; va_Mod_reg64 rRdi; va_Mod_reg64 rRax; va_Mod_mem]) (va_wp_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b) (va_wpProof_AES_GCM_encrypt_6mult alg h_LE iv_b in_b out_b scratch_b key_words round_keys keys_b hkeys_b)) //-- //-- AES_GCM_decrypt_6mult val va_code_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_code val va_codegen_success_AES_GCM_decrypt_6mult : alg:algorithm -> Tot va_pbool val va_lemma_AES_GCM_decrypt_6mult : va_b0:va_code -> va_s0:va_state -> alg:algorithm -> h_LE:quad32 -> iv_b:buffer128 -> in_b:buffer128 -> out_b:buffer128 -> scratch_b:buffer128 -> key_words:(seq nat32) -> round_keys:(seq quad32) -> keys_b:buffer128 -> hkeys_b:buffer128 -> Ghost (va_state & va_fuel) (requires (va_require_total va_b0 (va_code_AES_GCM_decrypt_6mult alg) va_s0 /\ va_get_ok va_s0 /\ (sse_enabled /\ movbe_enabled /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 2 va_s0) (va_get_reg64 rR8 va_s0) iv_b 1 (va_get_mem_layout va_s0) Public /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRdi va_s0) in_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 6 va_s0) (va_get_reg64 rRsi va_s0) out_b (va_get_reg64 rRdx va_s0) (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validDstAddrs128 (va_get_mem_heaplet 3 va_s0) (va_get_reg64 rRbp va_s0) scratch_b 9 (va_get_mem_layout va_s0) Secret /\ Vale.X64.Decls.validSrcAddrs128 (va_get_mem_heaplet 0 va_s0) (va_get_reg64 rR9 va_s0 - 32) hkeys_b 8 (va_get_mem_layout va_s0) Secret /\ (Vale.X64.Decls.buffers_disjoint128 in_b out_b \/ in_b == out_b) /\ va_get_reg64 rRdi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ va_get_reg64 rRsi va_s0 + 16 `op_Multiply` va_get_reg64 rRdx va_s0 < pow2_64 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 out_b /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b == va_get_reg64 rRdx va_s0 /\ Vale.X64.Decls.buffer_length #Vale.X64.Memory.vuint128 in_b `op_Multiply` 16 < pow2_32 /\ Vale.X64.Memory.buffer_addr #Vale.X64.Memory.vuint128 keys_b (va_get_mem_heaplet 0 va_s0) + 128 < pow2_64 /\ aes_reqs_offset alg key_words round_keys keys_b (va_get_reg64 rRcx va_s0 + 128) (va_get_mem_heaplet 0 va_s0) (va_get_mem_layout va_s0) /\ va_get_xmm 0 va_s0 == Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 202182159 134810123 67438087 66051 /\ pclmulqdq_enabled /\ h_LE == Vale.AES.AES_s.aes_encrypt_LE alg key_words (Vale.Def.Words_s.Mkfour #Vale.Def.Types_s.nat32 0 0 0 0) /\ Vale.AES.GHash.hkeys_reqs_priv (Vale.X64.Decls.s128 (va_get_mem_heaplet 0 va_s0) hkeys_b) (Vale.Def.Types_s.reverse_bytes_quad32 h_LE) /\ va_get_reg64 rRdx va_s0 `op_Modulus` 6 == 0 /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 >= 6) /\ (va_get_reg64 rRdx va_s0 > 0 ==> va_get_reg64 rRdx va_s0 `op_Division` 6 >= 1) /\ 12 + va_get_reg64 rRdx va_s0 + 6 < pow2_32))) (ensures (fun (va_sM, va_fM) -> va_ensure_total va_b0 va_s0 va_sM va_fM /\ va_get_ok va_sM /\ (Vale.X64.Decls.modifies_buffer128 out_b (va_get_mem_heaplet 6 va_s0) (va_get_mem_heaplet 6 va_sM) /\ Vale.X64.Decls.modifies_buffer128 iv_b (va_get_mem_heaplet 2 va_s0) (va_get_mem_heaplet 2 va_sM) /\ Vale.X64.Decls.modifies_buffer_specific128 scratch_b (va_get_mem_heaplet 3 va_s0) (va_get_mem_heaplet 3 va_sM) 1 8 /\ va_get_reg64 rRcx va_sM == va_get_reg64 rRcx va_s0 /\ Vale.AES.GCTR.gctr_partial alg (va_get_reg64 rRdx va_s0) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_sM) out_b) key_words (va_get_xmm 1 va_s0) /\ Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_sM) == Vale.AES.GHash.ghash_incremental0 h_LE (Vale.Def.Types_s.reverse_bytes_quad32 (va_get_xmm 8 va_s0)) (Vale.X64.Decls.s128 (va_get_mem_heaplet 6 va_s0) in_b) /\ l_and (va_get_reg64 rRdx va_s0 < pow2_32) (Vale.X64.Decls.buffer128_read scratch_b 2 (va_get_mem_heaplet 3 va_sM) == Vale.Def.Types_s.reverse_bytes_quad32 (Vale.AES.GCTR.inc32lite (va_get_xmm 1 va_s0) (va_get_reg64 rRdx va_s0)))) /\ va_state_eq va_sM (va_update_flags va_sM (va_update_mem_heaplet 3 va_sM (va_update_mem_heaplet 2 va_sM (va_update_mem_heaplet 6 va_sM (va_update_xmm 15 va_sM (va_update_xmm 14 va_sM (va_update_xmm 13 va_sM (va_update_xmm 12 va_sM (va_update_xmm 11 va_sM (va_update_xmm 10 va_sM (va_update_xmm 9 va_sM (va_update_xmm 8 va_sM (va_update_xmm 7 va_sM (va_update_xmm 6 va_sM (va_update_xmm 5 va_sM (va_update_xmm 4 va_sM (va_update_xmm 3 va_sM (va_update_xmm 2 va_sM (va_update_xmm 1 va_sM (va_update_xmm 0 va_sM (va_update_reg64 rR14 va_sM (va_update_reg64 rR13 va_sM (va_update_reg64 rR12 va_sM (va_update_reg64 rR11 va_sM (va_update_reg64 rRbx va_sM (va_update_reg64 rRcx va_sM (va_update_reg64 rRdx va_sM (va_update_reg64 rRsi va_sM (va_update_reg64 rRdi va_sM (va_update_reg64 rRax va_sM (va_update_ok va_sM (va_update_mem va_sM va_s0)))))))))))))))))))))))))))))))))) [@ va_qattr] let va_wp_AES_GCM_decrypt_6mult (alg:algorithm) (h_LE:quad32) (iv_b:buffer128) (in_b:buffer128) (out_b:buffer128) (scratch_b:buffer128) (key_words:(seq nat32)) (round_keys:(seq quad32)) (keys_b:buffer128) (hkeys_b:buffer128) (va_s0:va_state) (va_k:(va_state -> unit -> Type0)) :
false
true
Vale.AES.X64.AESGCM.fsti
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 0, "max_fuel": 1, "max_ifuel": 1, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": true, "smtencoding_l_arith_repr": "native", "smtencoding_nl_arith_repr": "wrapped", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": false, "z3cliopt": [ "smt.arith.nl=false", "smt.QI.EAGER_THRESHOLD=100", "smt.CASE_SPLIT=3" ], "z3refresh": false, "z3rlimit": 5, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val va_wp_AES_GCM_decrypt_6mult (alg: algorithm) (h_LE: quad32) (iv_b in_b out_b scratch_b: buffer128) (key_words: (seq nat32)) (round_keys: (seq quad32)) (keys_b hkeys_b: buffer128) (va_s0: va_state) (va_k: (va_state -> unit -> Type0)) : Type0
[]
Vale.AES.X64.AESGCM.va_wp_AES_GCM_decrypt_6mult
{ "file_name": "obj/Vale.AES.X64.AESGCM.fsti", "git_rev": "12c5e9539c7e3c366c26409d3b86493548c4483e", "git_url": "https://github.com/hacl-star/hacl-star.git", "project_name": "hacl-star" }
alg: Vale.AES.AES_common_s.algorithm -> h_LE: Vale.X64.Decls.quad32 -> iv_b: Vale.X64.Memory.buffer128 -> in_b: Vale.X64.Memory.buffer128 -> out_b: Vale.X64.Memory.buffer128 -> scratch_b: Vale.X64.Memory.buffer128 -> key_words: FStar.Seq.Base.seq Vale.X64.Memory.nat32 -> round_keys: FStar.Seq.Base.seq Vale.X64.Decls.quad32 -> keys_b: Vale.X64.Memory.buffer128 -> hkeys_b: Vale.X64.Memory.buffer128 -> va_s0: Vale.X64.Decls.va_state -> va_k: (_: Vale.X64.Decls.va_state -> _: Prims.unit -> Type0) -> Type0
{ "end_col": 54, "end_line": 302, "start_col": 2, "start_line": 249 }
Prims.Tot
val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_4 = parse32_bounded_integer' 4
val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4)) let parse32_bounded_integer_4 =
false
null
false
parse32_bounded_integer' 4
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_4 : (parser32 (parse_bounded_integer 4))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 4)
{ "end_col": 58, "end_line": 82, "start_col": 32, "start_line": 82 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
let be_to_n_1 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.be_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_be_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_to_n_1 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
[]
LowParse.SLow.BoundedInt.be_to_n_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
{ "end_col": 112, "end_line": 20, "start_col": 16, "start_line": 20 }
Prims.Tot
val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_3 = parse32_bounded_integer' 3
val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3)) let parse32_bounded_integer_3 =
false
null
false
parse32_bounded_integer' 3
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_3 : (parser32 (parse_bounded_integer 3))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 3)
{ "end_col": 58, "end_line": 81, "start_col": 32, "start_line": 81 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
let be_to_n_2 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.be_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_be_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_to_n_2 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
[]
LowParse.SLow.BoundedInt.be_to_n_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
{ "end_col": 112, "end_line": 30, "start_col": 16, "start_line": 30 }
Prims.Tot
val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_1 = parse32_bounded_integer' 1
val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1)) let parse32_bounded_integer_1 =
false
null
false
parse32_bounded_integer' 1
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_1 : (parser32 (parse_bounded_integer 1))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 1)
{ "end_col": 58, "end_line": 79, "start_col": 32, "start_line": 79 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
let le_to_n_3 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.le_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_le_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_to_n_3 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
[]
LowParse.SLow.BoundedInt.le_to_n_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
{ "end_col": 112, "end_line": 146, "start_col": 16, "start_line": 146 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
let le_to_n_4 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.le_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_le_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_to_n_4 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
[]
LowParse.SLow.BoundedInt.le_to_n_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
{ "end_col": 112, "end_line": 156, "start_col": 16, "start_line": 156 }
Prims.Tot
val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4) let parse32_bounded_integer_le_4 =
false
null
false
parse32_bounded_integer_le' 4
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer_le'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le_4 : parser32 (parse_bounded_integer_le 4)
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 4)
{ "end_col": 64, "end_line": 188, "start_col": 35, "start_line": 188 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
let le_to_n_1 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.le_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_le_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_to_n_1 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
[]
LowParse.SLow.BoundedInt.le_to_n_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
{ "end_col": 112, "end_line": 126, "start_col": 16, "start_line": 126 }
Prims.Tot
val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1) let parse32_bounded_integer_le_1 =
false
null
false
parse32_bounded_integer_le' 1
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer_le'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le_1 : parser32 (parse_bounded_integer_le 1)
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 1)
{ "end_col": 64, "end_line": 185, "start_col": 35, "start_line": 185 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
let be_to_n_4 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.be_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_be_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_to_n_4 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
[]
LowParse.SLow.BoundedInt.be_to_n_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
{ "end_col": 112, "end_line": 50, "start_col": 16, "start_line": 50 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
let be_to_n_3 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.be_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_be_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val be_to_n_3 : LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
[]
LowParse.SLow.BoundedInt.be_to_n_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.be_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
{ "end_col": 112, "end_line": 40, "start_col": 16, "start_line": 40 }
Prims.Tot
val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_2 = parse32_bounded_integer' 2
val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2)) let parse32_bounded_integer_2 =
false
null
false
parse32_bounded_integer' 2
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_2 : (parser32 (parse_bounded_integer 2))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer 2)
{ "end_col": 58, "end_line": 80, "start_col": 32, "start_line": 80 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
let le_to_n_2 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.le_to_n_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_le_to_n" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val le_to_n_2 : LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
[]
LowParse.SLow.BoundedInt.le_to_n_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.le_to_n_t (LowParse.Spec.Endianness.Instances.bounded_integer 2) 2
{ "end_col": 112, "end_line": 136, "start_col": 16, "start_line": 136 }
Prims.Tot
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3) let serialize32_bounded_integer_le_3 =
false
null
false
fun (x: bounded_integer 3) -> n_to_le_3 x
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_le_3", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_le_3 : serializer32 (serialize_bounded_integer_le 3)
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 3)
{ "end_col": 13, "end_line": 223, "start_col": 39, "start_line": 222 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
let n_to_be_3 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_be_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_be" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_be_3 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
[]
LowParse.SLow.BoundedInt.n_to_be_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 3) 3
{ "end_col": 112, "end_line": 106, "start_col": 16, "start_line": 106 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
let n_to_be_1 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_be_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_be" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_be_1 : LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
[]
LowParse.SLow.BoundedInt.n_to_be_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_be_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
{ "end_col": 112, "end_line": 86, "start_col": 16, "start_line": 86 }
Prims.Tot
val parse32_u16_le : parser32 parse_u16_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 ()
val parse32_u16_le : parser32 parse_u16_le let parse32_u16_le =
false
null
false
parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.parse32_synth'", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u16_le", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4
false
true
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_u16_le : parser32 parse_u16_le
[]
LowParse.SLow.BoundedInt.parse32_u16_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 LowParse.Spec.BoundedInt.parse_u16_le
{ "end_col": 6, "end_line": 195, "start_col": 2, "start_line": 191 }
Prims.Tot
val parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz)
val parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) =
false
null
false
[@@ inline_let ]let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.Combinators.make_total_constant_size_parser32", "FStar.UInt32.uint_to_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.decode_bounded_integer", "LowParse.SLow.BoundedInt.decode32_bounded_integer", "Prims.unit", "LowParse.Spec.BoundedInt.decode_bounded_integer_injective", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer sz)
{ "end_col": 33, "end_line": 77, "start_col": 2, "start_line": 72 }
Prims.Tot
val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input)
val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) let serialize32_bounded_integer_1:(serializer32 (serialize_bounded_integer 1)) =
false
null
false
(fun (input: bounded_integer 1) -> n_to_be_1 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_be_1", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 1)
{ "end_col": 20, "end_line": 92, "start_col": 2, "start_line": 91 }
Prims.Tot
val serialize32_u16_le : serializer32 serialize_u16_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip ()
val serialize32_u16_le : serializer32 serialize_u16_le let serialize32_u16_le =
false
null
false
serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.serialize32_synth'", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt16.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u16_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2", "LowParse.Spec.BoundedInt.synth_u16_le_recip" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x
false
true
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_u16_le : serializer32 serialize_u16_le
[]
LowParse.SLow.BoundedInt.serialize32_u16_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 LowParse.Spec.BoundedInt.serialize_u16_le
{ "end_col": 6, "end_line": 239, "start_col": 2, "start_line": 233 }
Prims.Tot
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4) let serialize32_bounded_integer_le_4 =
false
null
false
fun (x: bounded_integer 4) -> n_to_le_4 x
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_le_4", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_le_4 : serializer32 (serialize_bounded_integer_le 4)
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 4)
{ "end_col": 13, "end_line": 230, "start_col": 39, "start_line": 229 }
Prims.Tot
val parse32_u32_le : parser32 parse_u32_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 ()
val parse32_u32_le : parser32 parse_u32_le let parse32_u32_le =
false
null
false
parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.parse32_synth'", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u32_le", "LowParse.SLow.BoundedInt.parse32_bounded_integer_le_4" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 ()
false
true
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_u32_le : parser32 parse_u32_le
[]
LowParse.SLow.BoundedInt.parse32_u32_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 LowParse.Spec.BoundedInt.parse_u32_le
{ "end_col": 6, "end_line": 202, "start_col": 2, "start_line": 198 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
let n_to_le_1 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_le_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_le_1 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
[]
LowParse.SLow.BoundedInt.n_to_le_1
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 1) 1
{ "end_col": 112, "end_line": 206, "start_col": 16, "start_line": 206 }
Prims.Tot
val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input)
val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) let serialize32_bounded_integer_2:(serializer32 (serialize_bounded_integer 2)) =
false
null
false
(fun (input: bounded_integer 2) -> n_to_be_2 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_be_2", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 2)
{ "end_col": 20, "end_line": 102, "start_col": 2, "start_line": 101 }
Prims.Tot
val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input)
val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) let serialize32_bounded_integer_4:(serializer32 (serialize_bounded_integer 4)) =
false
null
false
(fun (input: bounded_integer 4) -> n_to_be_4 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_be_4", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 4)
{ "end_col": 20, "end_line": 122, "start_col": 2, "start_line": 121 }
Prims.Tot
val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input)
val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) let serialize32_bounded_integer_3:(serializer32 (serialize_bounded_integer 3)) =
false
null
false
(fun (input: bounded_integer 3) -> n_to_be_3 input)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_be_3", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer", "LowParse.Spec.BoundedInt.serialize_bounded_integer", "LowParse.SLow.Base.serializer32" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3))
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer 3)
{ "end_col": 20, "end_line": 112, "start_col": 2, "start_line": 111 }
Prims.Tot
val parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz))
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz)
val parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) =
false
null
false
[@@ inline_let ]let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.integer_size", "LowParse.SLow.Combinators.make_total_constant_size_parser32", "FStar.UInt32.uint_to_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.BoundedInt.bounded_integer_of_le", "LowParse.SLow.BoundedInt.bounded_integer_of_le_32", "Prims.unit", "LowParse.Spec.BoundedInt.bounded_integer_of_le_injective", "LowParse.SLow.Base.parser32", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz))
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le'
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
sz: LowParse.Spec.BoundedInt.integer_size -> LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le sz)
{ "end_col": 33, "end_line": 183, "start_col": 2, "start_line": 178 }
Prims.Tot
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2) let serialize32_bounded_integer_le_2 =
false
null
false
fun (x: bounded_integer 2) -> n_to_le_2 x
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.SLow.BoundedInt.n_to_le_2", "LowParse.SLow.Base.bytes32", "LowParse.SLow.Base.serializer32_correct", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_bounded_integer_le_2 : serializer32 (serialize_bounded_integer_le 2)
[]
LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 (LowParse.Spec.BoundedInt.serialize_bounded_integer_le 2)
{ "end_col": 13, "end_line": 216, "start_col": 39, "start_line": 215 }
Prims.Tot
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
let n_to_le_4 =
false
null
false
norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4)
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "FStar.Pervasives.norm", "Prims.Cons", "FStar.Pervasives.norm_step", "FStar.Pervasives.delta_attr", "Prims.string", "Prims.Nil", "FStar.Pervasives.iota", "FStar.Pervasives.zeta", "FStar.Pervasives.primops", "LowParse.SLow.Endianness.n_to_le_t", "LowParse.Spec.BoundedInt.bounded_integer", "LowParse.Spec.Endianness.Instances.bounded_integer", "LowParse.SLow.Endianness.mk_n_to_le" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val n_to_le_4 : LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
[]
LowParse.SLow.BoundedInt.n_to_le_4
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Endianness.n_to_le_t (LowParse.Spec.Endianness.Instances.bounded_integer 4) 4
{ "end_col": 112, "end_line": 227, "start_col": 16, "start_line": 227 }
Prims.Tot
val serialize32_u32_le : serializer32 serialize_u32_le
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let serialize32_u32_le = serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip ()
val serialize32_u32_le : serializer32 serialize_u32_le let serialize32_u32_le =
false
null
false
serialize32_synth' _ synth_u32_le _ serialize32_bounded_integer_le_4 synth_u32_le_recip ()
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.Combinators.serialize32_synth'", "LowParse.Spec.BoundedInt.parse_bounded_integer_kind", "LowParse.Spec.BoundedInt.bounded_integer", "FStar.UInt32.t", "LowParse.Spec.BoundedInt.parse_bounded_integer_le", "LowParse.Spec.BoundedInt.synth_u32_le", "LowParse.Spec.BoundedInt.serialize_bounded_integer_le", "LowParse.SLow.BoundedInt.serialize32_bounded_integer_le_4", "LowParse.Spec.BoundedInt.synth_u32_le_recip" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1 let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2 let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3 let parse32_bounded_integer_le_4 = parse32_bounded_integer_le' 4 let parse32_u16_le = parse32_synth' _ synth_u16_le parse32_bounded_integer_le_2 () let parse32_u32_le = parse32_synth' _ synth_u32_le parse32_bounded_integer_le_4 () inline_for_extraction noextract let n_to_le_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 1) 1) let serialize32_bounded_integer_le_1 = fun (x: bounded_integer 1) -> n_to_le_1 x inline_for_extraction noextract let n_to_le_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 2) 2) let serialize32_bounded_integer_le_2 = fun (x: bounded_integer 2) -> n_to_le_2 x inline_for_extraction noextract let n_to_le_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 3) 3) let serialize32_bounded_integer_le_3 = fun (x: bounded_integer 3) -> n_to_le_3 x inline_for_extraction noextract let n_to_le_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_le (EI.bounded_integer 4) 4) let serialize32_bounded_integer_le_4 = fun (x: bounded_integer 4) -> n_to_le_4 x let serialize32_u16_le = serialize32_synth' _ synth_u16_le _ serialize32_bounded_integer_le_2 synth_u16_le_recip ()
false
true
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val serialize32_u32_le : serializer32 serialize_u32_le
[]
LowParse.SLow.BoundedInt.serialize32_u32_le
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.serializer32 LowParse.Spec.BoundedInt.serialize_u32_le
{ "end_col": 6, "end_line": 248, "start_col": 2, "start_line": 242 }
Prims.Tot
val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le_2 = parse32_bounded_integer_le' 2
val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2) let parse32_bounded_integer_le_2 =
false
null
false
parse32_bounded_integer_le' 2
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer_le'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz)
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le_2 : parser32 (parse_bounded_integer_le 2)
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le_2
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 2)
{ "end_col": 64, "end_line": 186, "start_col": 35, "start_line": 186 }
Prims.Tot
val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3)
[ { "abbrev": true, "full_module": "FStar.Int.Cast", "short_module": "Cast" }, { "abbrev": true, "full_module": "LowParse.Spec.Endianness.Instances", "short_module": "EI" }, { "abbrev": true, "full_module": "LowParse.SLow.Endianness", "short_module": "E" }, { "abbrev": true, "full_module": "FStar.Bytes", "short_module": "B32" }, { "abbrev": true, "full_module": "FStar.UInt32", "short_module": "U32" }, { "abbrev": true, "full_module": "FStar.UInt16", "short_module": "U16" }, { "abbrev": true, "full_module": "FStar.UInt8", "short_module": "U8" }, { "abbrev": true, "full_module": "FStar.Seq", "short_module": "Seq" }, { "abbrev": false, "full_module": "LowParse.SLow.Combinators", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow.Base", "short_module": null }, { "abbrev": false, "full_module": "LowParse.Spec.BoundedInt", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "LowParse.SLow", "short_module": null }, { "abbrev": false, "full_module": "FStar.Pervasives", "short_module": null }, { "abbrev": false, "full_module": "Prims", "short_module": null }, { "abbrev": false, "full_module": "FStar", "short_module": null } ]
false
let parse32_bounded_integer_le_3 = parse32_bounded_integer_le' 3
val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3) let parse32_bounded_integer_le_3 =
false
null
false
parse32_bounded_integer_le' 3
{ "checked_file": "LowParse.SLow.BoundedInt.fst.checked", "dependencies": [ "prims.fst.checked", "LowParse.Spec.Endianness.Instances.fst.checked", "LowParse.Spec.BoundedInt.fst.checked", "LowParse.SLow.Endianness.fst.checked", "LowParse.SLow.Combinators.fst.checked", "FStar.UInt8.fsti.checked", "FStar.UInt32.fsti.checked", "FStar.UInt16.fsti.checked", "FStar.Seq.fst.checked", "FStar.Pervasives.fsti.checked", "FStar.Int.Cast.fst.checked", "FStar.Bytes.fsti.checked" ], "interface_file": true, "source_file": "LowParse.SLow.BoundedInt.fst" }
[ "total" ]
[ "LowParse.SLow.BoundedInt.parse32_bounded_integer_le'" ]
[]
module LowParse.SLow.BoundedInt open LowParse.SLow.Combinators #set-options "--split_queries no" #set-options "--z3rlimit 20" module Seq = FStar.Seq module U8 = FStar.UInt8 module U16 = FStar.UInt16 module U32 = FStar.UInt32 module B32 = FStar.Bytes module E = LowParse.SLow.Endianness module EI = LowParse.Spec.Endianness.Instances module Cast = FStar.Int.Cast friend LowParse.Spec.BoundedInt inline_for_extraction noextract let be_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 1) 1) inline_for_extraction let decode32_bounded_integer_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == decode_bounded_integer 1 (B32.reveal b) } ) = be_to_n_1 b inline_for_extraction noextract let be_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 2) 2) inline_for_extraction let decode32_bounded_integer_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == decode_bounded_integer 2 (B32.reveal b) } ) = be_to_n_2 b inline_for_extraction noextract let be_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 3) 3) inline_for_extraction let decode32_bounded_integer_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == decode_bounded_integer 3 (B32.reveal b) } ) = be_to_n_3 b inline_for_extraction noextract let be_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_be_to_n (EI.bounded_integer 4) 4) inline_for_extraction let decode32_bounded_integer_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == decode_bounded_integer 4 (B32.reveal b) } ) = be_to_n_4 b inline_for_extraction let decode32_bounded_integer (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == decode_bounded_integer sz (B32.reveal b) } ) ) = match sz with | 1 -> decode32_bounded_integer_1 | 2 -> decode32_bounded_integer_2 | 3 -> decode32_bounded_integer_3 | 4 -> decode32_bounded_integer_4 inline_for_extraction let parse32_bounded_integer' (sz: integer_size) : Tot (parser32 (parse_bounded_integer sz)) = [@inline_let] let _ = decode_bounded_integer_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (decode_bounded_integer sz) () (decode32_bounded_integer sz) let parse32_bounded_integer_1 = parse32_bounded_integer' 1 let parse32_bounded_integer_2 = parse32_bounded_integer' 2 let parse32_bounded_integer_3 = parse32_bounded_integer' 3 let parse32_bounded_integer_4 = parse32_bounded_integer' 4 inline_for_extraction noextract let n_to_be_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 1) 1) inline_for_extraction let serialize32_bounded_integer_1 : (serializer32 (serialize_bounded_integer 1)) = (fun (input: bounded_integer 1) -> n_to_be_1 input) inline_for_extraction noextract let n_to_be_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 2) 2) inline_for_extraction let serialize32_bounded_integer_2 : (serializer32 (serialize_bounded_integer 2)) = (fun (input: bounded_integer 2) -> n_to_be_2 input) inline_for_extraction noextract let n_to_be_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 3) 3) inline_for_extraction let serialize32_bounded_integer_3 : (serializer32 (serialize_bounded_integer 3)) = (fun (input: bounded_integer 3) -> n_to_be_3 input) inline_for_extraction noextract let n_to_be_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_n_to_be (EI.bounded_integer 4) 4) inline_for_extraction let serialize32_bounded_integer_4 : (serializer32 (serialize_bounded_integer 4)) = (fun (input: bounded_integer 4) -> n_to_be_4 input) inline_for_extraction noextract let le_to_n_1 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 1) 1) inline_for_extraction let bounded_integer_of_le_32_1 (b: B32.lbytes 1) : Tot (y: bounded_integer 1 { y == bounded_integer_of_le 1 (B32.reveal b) } ) = le_to_n_1 b inline_for_extraction noextract let le_to_n_2 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 2) 2) inline_for_extraction let bounded_integer_of_le_32_2 (b: B32.lbytes 2) : Tot (y: bounded_integer 2 { y == bounded_integer_of_le 2 (B32.reveal b) } ) = le_to_n_2 b inline_for_extraction noextract let le_to_n_3 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 3) 3) inline_for_extraction let bounded_integer_of_le_32_3 (b: B32.lbytes 3) : Tot (y: bounded_integer 3 { y == bounded_integer_of_le 3 (B32.reveal b) } ) = le_to_n_3 b inline_for_extraction noextract let le_to_n_4 = norm [delta_attr [`%E.must_reduce]; iota; zeta; primops] (E.mk_le_to_n (EI.bounded_integer 4) 4) inline_for_extraction let bounded_integer_of_le_32_4 (b: B32.lbytes 4) : Tot (y: bounded_integer 4 { y == bounded_integer_of_le 4 (B32.reveal b) } ) = le_to_n_4 b inline_for_extraction let bounded_integer_of_le_32 (sz: integer_size) : Tot ((b: B32.lbytes sz) -> Tot (y: bounded_integer sz { y == bounded_integer_of_le sz (B32.reveal b) } ) ) = match sz with | 1 -> bounded_integer_of_le_32_1 | 2 -> bounded_integer_of_le_32_2 | 3 -> bounded_integer_of_le_32_3 | 4 -> bounded_integer_of_le_32_4 inline_for_extraction let parse32_bounded_integer_le' (sz: integer_size) : Tot (parser32 (parse_bounded_integer_le sz)) = [@inline_let] let _ = bounded_integer_of_le_injective sz in make_total_constant_size_parser32 sz (U32.uint_to_t sz) (bounded_integer_of_le sz) () (bounded_integer_of_le_32 sz) let parse32_bounded_integer_le_1 = parse32_bounded_integer_le' 1
false
false
LowParse.SLow.BoundedInt.fst
{ "detail_errors": false, "detail_hint_replay": false, "initial_fuel": 2, "initial_ifuel": 1, "max_fuel": 8, "max_ifuel": 2, "no_plugins": false, "no_smt": false, "no_tactics": false, "quake_hi": 1, "quake_keep": false, "quake_lo": 1, "retry": false, "reuse_hint_for": null, "smtencoding_elim_box": false, "smtencoding_l_arith_repr": "boxwrap", "smtencoding_nl_arith_repr": "boxwrap", "smtencoding_valid_elim": false, "smtencoding_valid_intro": true, "tcnorm": true, "trivial_pre_for_unannotated_effectful_fns": true, "z3cliopt": [], "z3refresh": false, "z3rlimit": 20, "z3rlimit_factor": 1, "z3seed": 0, "z3smtopt": [], "z3version": "4.8.5" }
null
val parse32_bounded_integer_le_3 : parser32 (parse_bounded_integer_le 3)
[]
LowParse.SLow.BoundedInt.parse32_bounded_integer_le_3
{ "file_name": "src/lowparse/LowParse.SLow.BoundedInt.fst", "git_rev": "446a08ce38df905547cf20f28c43776b22b8087a", "git_url": "https://github.com/project-everest/everparse.git", "project_name": "everparse" }
LowParse.SLow.Base.parser32 (LowParse.Spec.BoundedInt.parse_bounded_integer_le 3)
{ "end_col": 64, "end_line": 187, "start_col": 35, "start_line": 187 }