Commit Graph

4655 Commits

Author SHA1 Message Date
Matthew Brecknell bda2c35862 ci proof-deploy: reorganise c-graph-lang artifacts
Combine all C graph-lang outputs into a single artifact, to simplify
downstream workflows.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2022-03-23 11:53:28 +11:00
Matthew Brecknell 96b2dfc1d3 cspec kernel.mk: avoid spurious dependencies
The rule for kernel.sigs previously depended on building standalone C
parsers and tokenizers for all architectures. With this change, we only
build the standalone C parser for the current architecture.

We also explicitly pass a --cpp argument based on the TOOLPREFIX.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2022-03-23 11:53:28 +11:00
Matthew Brecknell 8c68e549d0 cspec kernel.mk: always use TOOLPREFIX for objdump
Some development environments set an environment variable OBJDUMP by
default. With the previous version of kernel.mk, decompilation used the
objdump indicated by that OBJDUMP variable. This could cause
decompilation to fail if OBJDUMP did not match the TOOLPREFIX used for
compilation.

Since we don't currently have a need to specify a different objdump, we
remove the ability to override via the OBJDUMP environment variable.
With this commit, we always use TOOLPREFIX to locate a suitable objdump.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2022-03-23 11:53:28 +11:00
Matthew Brecknell 6673bf03d4 ci proof-deploy: add MCS C graph export
Add a second matrix job that runs SimplExportAndRefine for MCS C kernel
configurations that support it (currently ARM and RISCV64).

Note that this uses the master branch of l4v to generate the CSpec, and
to run SimplExportAndRefine, not the rt branch. This works because the
rt branch does not yet connect to the CSpec, and there are no meaningful
differences between rt and master in CSpec or SimplExportAndRefine. For
now, this simplifies workflows for binary verification. But when MCS
proofs connect to the CSpec, this will need to be refactored to use the
rt branch.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2022-03-14 11:13:47 +11:00
Matthew Brecknell da3c480cd4 ci proof-deploy: save C graph-lang
Upload an artifact for any C graph-lang generated by
SimplExportAndRefine during a proof-deploy workflow.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2022-03-14 11:13:47 +11:00
Michael McInerney de871a7c64 arm_hyp ainvs+refine+crefine: update for change to associate_vcpu_tcb
Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-03-08 21:49:10 +10:30
Michael McInerney 31134da4c4 arm_hyp aspec+haskell: call vcpu_switch in associate_vcpu_tcb
An invocation to bind a thread to a VCPU will perform associate_vcpu_tcb.
Previously, vcpu_switch was called only on a context switch, and so
it was possible to bind the current thread to a VCPU and then not switch
to that VCPU. This change will allow us to prove that the current active
VCPU is the VCPU of the current thread.

Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-03-08 21:49:10 +10:30
Michael McInerney 416a097cec lib: add hoare_seq_ext_skip and friends (from AInvs)
This commit was cherry-picked from the rt branch.

Signed-off-by: Michael McInerney <Michael.McInerney@data61.csiro.au>
2022-03-08 21:49:10 +10:30
Michael McInerney f9234e9f27 lib: add FIXME for repeat_unless
Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-03-08 21:49:10 +10:30
Michael McInerney ce3fc6b9b4 lib: add repeat_unless Eisbach method
The repeat_unless method allows one to repeatedly apply some method
until some other method can be applied. This should be particularly
useful in Hoare triple proofs that use the forward-reasoning style

This commit was cherry-picked from the rt branch.

Signed-off-by: Michael McInerney <Michael.McInerney@data61.csiro.au>
2022-03-08 21:49:10 +10:30
Rafal Kolanski 6c7798d512 asmrefine: add prefixes for testfiles/*_gref.thy
These currently work with an empty prefix as well, but using the name of
the theory file containing the respective install_C_file is more stable.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-02-22 18:24:02 +11:00
Rafal Kolanski 7f24132581 asmrefine: use "Kernel_C" prefix for SEL4SimplExport
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-02-22 18:24:02 +11:00
Rafal Kolanski 289de4fef7 asmrefine: use a prefix for constant lookups
Add and carry around a `pfx` parameter indicating the prefix under which
constants should be found. Without this prefix, items such as
enumeration constant names are guessed at from unqualified names. If the
unqualified name is hidden for some reason, or clobbered with another
name, the wrong constant gets used and leads to exciting errors.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-02-22 18:24:02 +11:00
Rafal Kolanski 23bfc8dadf cspec: Kernel_C: hide numDomains, sync comments
Since `numDomains` exists both in Kernel_Config in C, and we want to
force people to annotate the C version as `Kernel_C.numDomains`, we hide
it right after the C is parsed.

Some of the comments about hiding/reintroducing vmsize constants became
a bit broken/absent around X64, and adding the above made things extra
confusing. Put back the ARM/ARM_HYP comments to clear up what's going
on, and tweaked a little.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-02-22 18:24:02 +11:00
Corey Lewis 6d0c9fb78c arm+arm-hyp machine: match platform constants to C
This change eases any future platform ports by better matching the C
code that it models and by making it so that there is one less constant
that needs modification.

Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-02-09 14:46:21 +11:00
Gerwin Klein ffcaff6af9 c-parser: provide AARCH64 setup
The setup for L4V_ARCH=AARCH64 is identical to RISCV64, i.e. same word
length, encoding, and endianness. The setup includes the standalone
parser used for compile and preprocess checks in the seL4 repo.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-03 16:13:45 +11:00
Gerwin Klein d3ecd0e451 aarch64 lib: add 64 bit word setup
This is equal to the setup for RISCV64 and X64.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-03 16:13:45 +11:00
Gerwin Klein 04626b0a88 cspec: enable preprocess test for AArch64
This commit adds compiler prefixes for AArch64 so that the preprocess
test finds the right cross compilers for this architecture.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-03 13:41:06 +11:00
Gerwin Klein c4fe1abb3d github: provide auth tokens
These allow the test to run on private repos. If set to empty, they
have no effect.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-02 09:25:58 +11:00
Gerwin Klein a4c80a6887 github: use PR number to distinguish pull requests
${{github.ref}} will resolve to the base branch of the PR, not the
PR branch, so it is not useful for distinguishing PRs. The pull request
number will do the job.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-02-01 14:49:38 +11:00
Gerwin Klein d831ddea67 github: run AWS proofs only on most recent push
By default GitHub spawns a new test for each push event. To avoid
hitting the maximum number of AWS instances too quickly, we run the PR
and master proof tests only on the most recent push since the last test
finished.

The concurrency exclusion is per git ref, i.e. separate PRs and
separate branches still run tests concurrently.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-01-11 18:20:45 +11:00
Gerwin Klein 24c0c5c390 spec+proof: use generated config constants
This includes replacing previous ASpec names for such constants with
the names used in Haskell/ExecSpec to avoid duplication. This also
makes some of the proofs slightly more generic.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-23 14:54:13 +11:00
Gerwin Klein 8929a6d729 machine+C: generate Kernel_Config.thy from C
This script takes the gen_config.h file CMake produces for each kernel
configuration, parses it, and emits corresponding Isabelle definitions
into Kernel_Config.thy in spec/machine/$L4V_ARCH/

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-23 14:54:13 +11:00
Gerwin Klein 3b616f535a cspec: separately generate C config headers
This is in preparation for later turning these config headers into
Isabelle definitions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-23 14:54:13 +11:00
Rafal Kolanski 73911da72d infoflow refine: make proofs independent of number of domains
The InfoFlow proof itself does not care about the number of domains, and
that assumption was removed in another commit.
The specific example in the information flow refinement requires two
domains (one "high" and one "low") to be of any interest. Since it
cannot be instantiated with only one domain, the example theorems in
Example_Valid_StateH now assume that `1 <= maxDomain`.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Rafal Kolanski b57a755e40 crefine: make proofs independent of number of domains
For CRefine, this process is much more complex than for Refine and up,
as the C code both has its own definitions `maxDom` and `numDomains`,
but they are not defined in terms of each other, only numbers.
Similarly, array size types and their corresponding ArrayGuard bounds
checks refer to specific numbers, making a fullproof abstraction impossible.

A reasonably constrained interface to numDomains/maxDomain/maxDom in
Wellformed_C provides a sufficient abstraction to allow the proofs to be
independent of the number of domains (constrained to <= 256). Using the
value_type command allows more abstraction techniques, such as linking
the size of the scheduler queues back to numDomains*numPriorities,
without stating what the numbers are. Finally, for getting past the
ArrayGuard bounds checks, we do leak some information in the form of
`explicit` lemmas. These are the least safe, but short of augmenting the
C parser to re-wrap array sizes into equivalent constants/types, they
constitute a limited risk. Nonetheless, `explicit` lemmas should be used
as sparingly as possible.

Refinement to C proceeds by pretending we don't know the number of
domains, and whenever a control flow decision is made based on
`numDomains > 1`, we follow both branches, as we did for Refine. We also
attempt to avoid clever rewrites such as `(x < 1) = (x = 0)` which mess
up bounds checks into a domain-size array when `numDomains = 1`.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Rafal Kolanski b8fc709d21 refine+orphanage: update proofs to never unfold numDomains
Proofs now don't care about numDomains, except for a small interface in
Invariants_H. The interface is currently by convention only, and has no
enforcement capabilities.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Rafal Kolanski 8052df4ac6 infoflow: remove dependency on domains > 1
The proofs work without knowing the number of domains, including with
only a single domain.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Rafal Kolanski d91afcb5c1 ainvs: update proofs to never unfold numDomains
Make proofs work with any number of domains that fits in the domain type
(at this time an 8-bit word).

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Rafal Kolanski ec79dc3330 aspec+design+haskell: extract numDomains into Kernel_Config
Introduce Kernel_Config theory for storage of non-architecture-specific
seL4 configuration variables that are shared by the abstract and design
specs.

Remove `num_domains`, in lieu of `numDomains` that is now defined only
in `Kernel_Config.thy`. The definition is hidden and must be referred to
as Kernel_Config.numDomains_def when avoiding unfolding is not possible.

Include required properties of `numDomains` as lemmas.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Gerwin Klein 78007a4179 lib: add value_type command
The `value_type` top-level command allows evaluating a term down to a
natural number, and using that number to define an enumerated type, as
well as (optionally) a constant definition.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Gerwin Klein f33b02f3d0 docs: use archive link for locale docs
This link is stable over Isabelle releases and can be updated once
the repo switches over to the next release.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-21 16:28:29 +11:00
Gerwin Klein ce67a725f7 cspec: more compiler options
The new docker containers that upgraded to gcc-10 use a different
version of the gcc Arm toolchain (`arm-linux-gnueabi`).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-09 11:07:22 +11:00
Gerwin Klein 46a1d2509a crefine: update for PR seL4/seL4#321
The aim of the PR was readability, but it actually also brings the
C more in line with the spec.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-06 16:44:39 +11:00
Gerwin Klein 614e24ee10 riscv machine: use address size consistently
In the rest of the proofs we use machine_word to refer to addresses.
This commit brings the machine definitions in line with that.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-03 17:06:37 +11:00
Ryan Barry 72ab7cc180 various: resolve some new fixmes
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry d619052b02 run_tests: enable RISCV64 InfoFlow tests
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 0c2767b197 riscv infoflow refine: add Example_Valid_StateH
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 60e8d4ff17 riscv infoflow: add Example_Valid_State
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 9f1d259f87 infoflow refine + refine: add refinement proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 1b1814c9b1 arm infoflow: update proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 82fd48d769 riscv infoflow: add Noninterference proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 1ec4ee4183 riscv infoflow: add ADT proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry d17d2e3079 riscv infoflow: add UserOp proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 66c5f72a14 riscv infoflow: add Scheduler proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry b55aa6a20a riscv infoflow: add Syscall proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 21a0525e59 riscv infoflow: add PasUpdates proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry ec046f56b7 riscv infoflow: add Tcb proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry f0bb85e7ab riscv infoflow: add Decode proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00
Ryan Barry 78884cdb2b riscv infoflow: add Ipc proofs
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-11-12 09:39:16 +11:00