Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leakage traces #431

Open
wants to merge 91 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
23ef95f
add LS.v
OwenConoly Sep 6, 2024
eb82e5e
modify LS.v
OwenConoly Sep 6, 2024
c697ba1
prettify MetricSemantics eval_expr
OwenConoly Aug 28, 2024
d921b46
add MetricLeakageSemantics
OwenConoly Aug 28, 2024
c2c9992
organize semantics-relation lemmas in MetricLeakageSemantics
OwenConoly Aug 28, 2024
309a4b6
remove unneeded direction of eval_expr equivalence
OwenConoly Aug 28, 2024
7ed12e9
all the desired relations between semantics
OwenConoly Aug 28, 2024
16cb728
make build less noisy
OwenConoly Aug 28, 2024
50f860c
create LWP
OwenConoly Sep 6, 2024
29339e5
modify LeakageWeakestPrecondition.v
OwenConoly Sep 6, 2024
99d33fe
add LWPP
OwenConoly Sep 6, 2024
a444868
modify LWPP.v
OwenConoly Sep 6, 2024
61cb091
add LL.v
OwenConoly Sep 24, 2024
b2002f6
edit LL.v
OwenConoly Sep 24, 2024
f2e3144
add LPL
OwenConoly Sep 27, 2024
16fccea
first pass on editing LPL
OwenConoly Sep 30, 2024
8b30bfa
add kyber file. doesn't work, since straightline needs fixes
OwenConoly Sep 30, 2024
ba5b547
make kyberslash work
OwenConoly Sep 30, 2024
13fba5a
remove garbage (Search commands, etc) from kyberslash proof
OwenConoly Sep 30, 2024
c9c9c57
update FlatImp to use MetricLeakageSemantics
OwenConoly Sep 30, 2024
bdcc388
add 'custom fixpoint' stuff. add comparison of Fix_eq and Fix_eq'.
OwenConoly Sep 30, 2024
8db3172
add leakage function to DCEDef
OwenConoly Sep 30, 2024
6ab1564
switch to using Fix instead of my_Fix.
OwenConoly Sep 30, 2024
b0dbeb7
switch to using Fix_eq' and get unstuck
OwenConoly Sep 30, 2024
8b00511
start on DCE proof
OwenConoly Sep 30, 2024
020ad0f
progress on DCE phase
OwenConoly Sep 30, 2024
2838479
add pick_sp stuff to DCE trace transformation function
OwenConoly Sep 30, 2024
b02a304
finish updating DCE function
OwenConoly Oct 1, 2024
a486229
had an idea about how to simplify function
OwenConoly Oct 1, 2024
3a221fb
DCE progress
OwenConoly Oct 1, 2024
556d288
up to loop case
OwenConoly Oct 1, 2024
9fe2d00
get stuck in sequence (and while) case. IH is no good!
OwenConoly Oct 1, 2024
d08e363
rewrite DCE function in CPS. need to decide how to prove fixpoint eq…
OwenConoly Oct 2, 2024
f5690fd
new version of Fix with dependent types as well as arbitrary equivale…
OwenConoly Oct 2, 2024
e142efe
all the variants of Fix_eq i could imagine wanting
OwenConoly Oct 2, 2024
24bcc75
prove DCE leakage fixpoint equation
OwenConoly Oct 7, 2024
ed7fa64
write DCE proof with leakage (it works now, since leakage function is…
OwenConoly Oct 19, 2024
98f7015
start adapting spilling phase to leakage
OwenConoly Oct 26, 2024
2148f2c
fix align_trace tactic and move it to LeakageSemantics
OwenConoly Oct 26, 2024
4de4f7e
finish adapting spilling proof to leakage traces
OwenConoly Oct 28, 2024
a9ad05f
switch from mit-plv riscv-coq to my fork, and then to the leakage tra…
OwenConoly Oct 29, 2024
075038d
adapt FlattenExpr to leakage traces
OwenConoly Oct 29, 2024
75ef583
add leakage traces to GoFlatToRiscv
OwenConoly Oct 29, 2024
877c92f
add leakage traces to ForeverSafe, RunInstruction
OwenConoly Oct 29, 2024
807f01c
add leakage to RiscvEventLoop
OwenConoly Oct 29, 2024
5195e03
start on FlatToRiscvCommon
OwenConoly Oct 29, 2024
5c8665d
add leakage transformation function for FlatToRiscv.
OwenConoly Oct 29, 2024
0b99a61
rewrite leakage functions in FlatToRiscvDef to return list LeakageEvent
OwenConoly Oct 30, 2024
376ec5a
add leakage traces to FlatToRiscvCommon
OwenConoly Oct 30, 2024
8a01efb
add leakage to FlatToRiscvLiterals
OwenConoly Oct 30, 2024
10fd526
add leakage to load_save_regs_correct
OwenConoly Oct 30, 2024
542434d
start on Functions
OwenConoly Nov 12, 2024
0682f92
finish compile_function_body_correct
OwenConoly Nov 12, 2024
c5ed5ad
finish call case
OwenConoly Nov 12, 2024
b50afb1
up to stackalloc case...
OwenConoly Nov 12, 2024
55f4e95
up to while case
OwenConoly Nov 12, 2024
b75e11b
finish functions
OwenConoly Nov 12, 2024
5cbb5df
leakage in UseImmediate
OwenConoly Nov 12, 2024
5d18d3b
leakage in regalloc
OwenConoly Nov 12, 2024
e4efffd
add leakage to lower pipeline
OwenConoly Nov 13, 2024
07dfe0e
some pipeline
OwenConoly Nov 13, 2024
5eff275
get to dce_correct in pipeline...
OwenConoly Nov 13, 2024
6235cd3
composed_compiler_correct
OwenConoly Nov 13, 2024
2bc8edc
compiler_correct
OwenConoly Nov 13, 2024
f2f175c
memequal source level leakage prooof
OwenConoly Nov 13, 2024
4f8d83e
hacky compiler_correct_wp
OwenConoly Nov 13, 2024
5deac8a
MMIO compiler stuff
OwenConoly Nov 13, 2024
01fdc8f
get to the point where I actually write the low-level spec of memequal
OwenConoly Nov 13, 2024
6652114
prove memequal
OwenConoly Nov 14, 2024
1cadb3d
make memequal basically axiom-free
OwenConoly Nov 14, 2024
6764d5f
add ct.v
OwenConoly Nov 15, 2024
23991bd
clean up most of pipeline.v
OwenConoly Dec 17, 2024
dc436a3
get rid of WeakenCall in Pipeline; use func/prop ext instead
OwenConoly Dec 17, 2024
a710ce7
more cleaning up pipeline. up to spilling_correct
OwenConoly Dec 17, 2024
76f2c60
trying riscv_phase_correct
OwenConoly Dec 17, 2024
d99f342
hooray Pipeline compiles now
OwenConoly Dec 19, 2024
35556b3
remove test_itauto (sam says it is not needed anymore)
OwenConoly Dec 19, 2024
4e8bb1d
get rid of option_map lemmas
OwenConoly Dec 19, 2024
21d12fa
FE310 leakage comment
OwenConoly Dec 19, 2024
f49da82
make some fixpoints local
OwenConoly Dec 19, 2024
83a68f9
make ct.v use FE310CSemantics instead of BasicC32Semantics
OwenConoly Dec 19, 2024
59c91fb
revert BasicC32Semantics to have no leakage traces
OwenConoly Dec 19, 2024
c1fbe27
start adapting examples using FE310 to work with leakage
OwenConoly Dec 19, 2024
191b848
make leakage straightline work way better
OwenConoly Dec 19, 2024
dcc213f
fix straightline in a different way (still using letexists instead of…
OwenConoly Dec 19, 2024
fbbf64f
fixup leakage straightline.
OwenConoly Dec 20, 2024
9250260
fnspec notations
OwenConoly Dec 20, 2024
fbe8100
leakage in LAN9250
OwenConoly Dec 20, 2024
b606efd
add fnspec_ex! notations for specifying constant-time
OwenConoly Dec 20, 2024
d1295c2
work on bedrock2Examples involving leakage (including using the
OwenConoly Dec 20, 2024
8b44f61
make fnspec! exists notation more intuitive
OwenConoly Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "deps/riscv-coq"]
path = deps/riscv-coq
url = https://github.com/mit-plv/riscv-coq.git
url = https://github.com/OwenConoly/riscv-coq.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This git-config change should not be merged, instead the relevant riscv-coq changes should be merged to its upstream.

[submodule "deps/coqutil"]
path = deps/coqutil
url = https://github.com/mit-plv/coqutil.git
Expand Down
21 changes: 13 additions & 8 deletions bedrock2/src/bedrock2/BasicC32Semantics.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.ZArith.ZArith.
Require Import bedrock2.Syntax bedrock2.Semantics.
Require Import bedrock2.Syntax bedrock2.Semantics bedrock2.LeakageSemantics.
OwenConoly marked this conversation as resolved.
Show resolved Hide resolved
Require coqutil.Datatypes.String coqutil.Map.SortedList coqutil.Map.SortedListString.
Require Import coqutil.Word.Interface coqutil.Map.SortedListWord.
Require coqutil.Word.Naive.
Expand All @@ -10,25 +10,27 @@ Require Export coqutil.Word.Bitwidth32.
#[global] Instance locals: Interface.map.map String.string word := SortedListString.map _.
#[global] Instance env: Interface.map.map String.string (list String.string * list String.string * cmd) :=
SortedListString.map _.
#[global] Instance ext_spec: ExtSpec := fun _ _ _ _ _ => False.
#[global] Instance ext_spec: LeakageSemantics.ExtSpec := fun _ _ _ _ _ => False.

Arguments word: simpl never.
Arguments mem: simpl never.
Arguments locals: simpl never.
Arguments env: simpl never.

#[global] Instance weaken_ext_spec trace m0 act args :
(*#[global] Instance weaken_ext_spec :
ext_spec.ok ext_spec.
Morphisms.Proper
(Morphisms.respectful
((Morphisms.respectful
(Morphisms.pointwise_relation Interface.map.rep
(Morphisms.pointwise_relation (list word) Basics.impl))
Basics.impl) (ext_spec trace m0 act args).
(Morphisms.pointwise_relation _
(Morphisms.pointwise_relation _ Basics.impl)))
Basics.impl) Basics.impl) (ext_spec trace m0 act klist args).
Proof.
cbn in *.
unfold Morphisms.Proper, Morphisms.respectful, Morphisms.pointwise_relation, Basics.impl.
intros.
assumption.
Qed.
Qed.*)

#[global] Instance localsok: coqutil.Map.Interface.map.ok locals := SortedListString.ok _.
#[global] Instance envok: coqutil.Map.Interface.map.ok env := SortedListString.ok _.
Expand All @@ -42,5 +44,8 @@ Add Ring wring : (Properties.word.ring_theory (word := word))
#[global] Instance ext_spec_ok : ext_spec.ok ext_spec.
Proof.
constructor; intros; try contradiction.
apply weaken_ext_spec.
cbn in *.
unfold Morphisms.Proper, Morphisms.respectful, Morphisms.pointwise_relation, Basics.impl.
intros.
assumption.
Qed.
26 changes: 15 additions & 11 deletions bedrock2/src/bedrock2/FE310CSemantics.v
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Require Import Coq.ZArith.ZArith.
Require Import bedrock2.Syntax bedrock2.Semantics.
Require Import bedrock2.Syntax bedrock2.Semantics bedrock2.LeakageSemantics.
Require coqutil.Datatypes.String coqutil.Map.SortedList coqutil.Map.SortedListString.
Require Import coqutil.Word.Interface.
Require Export coqutil.Word.Bitwidth32.
Expand Down Expand Up @@ -27,18 +27,18 @@ Section WithParameters.
Definition isMMIOAligned (n : nat) (addr : word) :=
n = 4%nat /\ word.unsigned addr mod 4 = 0.

Global Instance ext_spec: ExtSpec :=
fun (t : trace) (mGive : mem) a (args: list word) (post: mem -> list word -> Prop) =>
Global Instance ext_spec: LeakageSemantics.ExtSpec :=
OwenConoly marked this conversation as resolved.
Show resolved Hide resolved
fun (t : trace) (mGive : mem) a (args: list word) (post: mem -> list word -> list word -> Prop) =>
if String.eqb "MMIOWRITE" a then
exists addr val,
args = [addr; val] /\
(mGive = Interface.map.empty /\ isMMIOAddr addr /\ word.unsigned addr mod 4 = 0) /\
post Interface.map.empty nil
post Interface.map.empty nil [addr]
else if String.eqb "MMIOREAD" a then
exists addr,
args = [addr] /\
(mGive = Interface.map.empty /\ isMMIOAddr addr /\ word.unsigned addr mod 4 = 0) /\
forall val, post Interface.map.empty [val]
forall val, post Interface.map.empty [val] [addr]
else False.

Global Instance ext_spec_ok : ext_spec.ok ext_spec.
Expand All @@ -48,12 +48,16 @@ Section WithParameters.
intros.
all :
repeat match goal with
| H : context[(?x =? ?y)%string] |- _ =>
destruct (x =? y)%string in *
| H: exists _, _ |- _ => destruct H
| H: _ /\ _ |- _ => destruct H
| H: False |- _ => destruct H
end; subst; eauto 8 using Properties.map.same_domain_refl.
| H : context[(?x =? ?y)%string] |- _ =>
destruct (x =? y)%string in *
| H: exists _, _ |- _ => destruct H
| H: _ /\ _ |- _ => destruct H
| H: False |- _ => destruct H
end; subst;
repeat match goal with
| H: _ :: _ = _ :: _ |- _ => injection H; intros; subst; clear H
end;
eauto 8 using Properties.map.same_domain_refl.
Qed.

Global Instance locals: Interface.map.map String.string word := SortedListString.map _.
Expand Down
Loading