Commit Graph

5275 Commits

Author SHA1 Message Date
Gerwin Klein 126fdfef77
aarch64 haskell: eliminate isValidNativeRoot
Define isValidVTableRoot directly as on the other architectures.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:19 +11:00
Gerwin Klein 6461e9223c
aarch64 haskell: defer reader monad FIXMEs to MCS
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:19 +11:00
Gerwin Klein f543ad0642
haskell: move countTrailingZeros to Data.Word_Lib
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:18 +11:00
Gerwin Klein 4a42803c6d
cspec: make remaining relative paths absolute (#607)
Previous commit 1a7eb92111 on fixing up overlay paths in kernel.mk
missed two instances.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:14:17 +11:00
Rafal Kolanski 19a56421c6 aarch64 haskell: resolve FIXMEs in Hardware
* getHSR confirmed unusued
* setHCR confirmed used on C side for hyp
* addressTranslateS1 was merged into C

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-08 18:04:03 +11:00
Rafal Kolanski 2155afbac4 aarch64 machine: clear up some FIXMEs in Platform.thy
* explain how canonical_bit concept applies to AArch64
* use powers of 2 for kernelELFBase
* pptrBase unlikely to migrate to 0 in near future
* pptrUserTop_def' is not used on AARCH64, and should not be used as we
  try to avoid expanding config_ARM_PA_SIZE_BITS_40 whenever possible

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-08 18:04:03 +11:00
Gerwin Klein 9d5c8be3dc
aarch64 ainvs: convert 2 FIXMEs into longer term issues (#601)
Both of these affect other architectures and need more discussion.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-08 17:04:37 +11:00
Gerwin Klein a454a093c0
lib: connection between exs_valid and wp conjugate (#588)
Draw connection between conjugate wp in the literature and our
exs_valid definition.

Add exs_valid_alt lemma, which is one of the main rules that is
different between wp and conjugate wp (or vs and).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-08 13:02:54 +11:00
Gerwin Klein 1a7eb92111
cspec: use absolute path for overlay targets (#597)
The `export-kernel-builds.py` script expects to be able to run the
build from an arbitrary temporary directory.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-08 07:59:32 +11:00
Gerwin Klein 42c4e78e9f
cspec: provide mechanism for adding dts overlays (#591)
Add mechanism for adding overlay.dts files to the l4v build for all
architectures apart from X64 (which does not use dts files).

For example, place a file `overlays/ARM/overlay.dts` into the tree and
the build will pick it up as custom overlay file with the correct proof
session dependencies.

If no file is provided, an empty default overlay file is used.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-07 14:35:53 +11:00
Rafal Kolanski c2a9ec60a8 arm-hyp crefine: update for physBase-as-function
In order to parametrise the kernel's physical address in verification,
physBase becomes a function in C.
This updates the functional correctness proofs so that they work again.
Proper abstraction of physBase in the proof is forthcoming.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-07 00:04:38 +11:00
Gerwin Klein c072a9c531
cspec: extract physBase from C headers
Extract the numeric value PHYS_BASE_RAW from the generated header
gen_headers/plat/machine/devices_gen.h and provide it as the constant
physBase in Kernel_Config.thy.

In C this will later match up with the value returned by physBase().

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-06 11:58:08 +11:00
Matthew Brecknell f694aeb6fe ci bv: Use bv-trigger action
Use the bv-trigger action to trigger a binary verification run, rather
than a called workflow.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2023-03-05 16:09:39 +11:00
Matthew Brecknell 2bed1814aa c-kernel: Support pre-built standalone C parser
Allow more settings to be overridden when using the standalone C parser
to generate kernel.sigs in the l4v kernel make files.

This makes it easier to use a pre-built standalone C parser, say, from a
Docker image.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2023-03-04 08:38:33 +11:00
Matthew Brecknell 7225fb3989 ci: Move decompilation workflow to graph-refine repository
The decompilation process (part of binary verification) is more tightly
coupled to the graph-refine repository than l4v, so it makes more sense
to perform decompilation in graph-refine. (It was temporarily performed
here in l4v because the graph-refine branches needed some stabilisation
work.)

This also modifies proof workflows:
- All proof workflows now upload kernel build artifacts. These can be
  used as inputs to binary verification.
- Proof workflows other than the one for pull requests (proof.yml)
  automatically trigger a decompilation workflow. We can still manually
  initiate a decompilation workflow using the uploaded artifacts, but
  doint so automatically would consume too many parallel runners.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2023-03-04 08:38:33 +11:00
Matthew Brecknell 4607098ded ci: Add a script to export kernel build artifacts
This can be used by l4v proof runs in GitHub CI to save kernel build outputs
for later use by binary verification.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2023-03-04 08:38:33 +11:00
Gerwin Klein eaf735c38f
cspec: adjust Kernel_Config generation (#590)
seL4/seL4#975 slightly changed how the config headers are generated.
They now need a (short) `ninja` build step and they produce less spaces
in the header file.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-02 11:54:20 +11:00
Gerwin Klein 244e7d464f
readme: explain L4V_ARCH and spec generation (#586)
We have so far not been mentioning L4V_ARCH in the instructions and
haven't pointed out which sessions need generated input.

Add this information to the instructions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-01 16:53:37 +11:00
Gerwin Klein aa53e9a84c
github: provide nl-unescape script to BV trigger job
Need to check out the ci-actions repo first (where the nl-unescape.sh
script is located).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-01 14:51:52 +11:00
Peter Chubb 5fcec5f56a
Unescape verification-manifest.xml before saving it (#583)
The current xmllint tools don't like %0A to mean newline
so are crashing.

Signed-off-by: Peter Chubb <peter.chubb@unsw.edu.au>
2023-02-22 15:32:28 +11:00
Corey Lewis a2ffb3b4f5 proof: remove is_thread_control and thread_control_target
Instead use discriminator and selector provided by the datatype
package.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-02-14 18:33:44 +11:00
Corey Lewis b825663924 aspec: name remaining ThreadControl fields
This automatically generates matching selectors.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-02-14 18:33:44 +11:00
Michael McInerney cf1af81384 lib: add more rules from MCS work
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-02-14 14:05:05 +10:30
Michael McInerney 015fe74f04 lib: add some lemmas from MCS work to OptionMonadWP.thy
This includes some style improvements, too

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-02-14 11:15:32 +10:30
Gerwin Klein 81513b894f
lib: fix link in Monads README (#576)
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-10 09:12:34 +11:00
michaelmcinerney 087a01ee7c
lib: add hoare_case_option_wp2 (#575)
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-02-10 08:58:35 +11:00
Gerwin Klein 0bee918631
Word_Lib: enable "eval" for word quantifiers (#574)
Enable use of "eval" and "value" for formulas that quantify over word
values. The code generator will exhaustively run all possible values.

For small word sizes, this works in very reasonable time. E.g. try

    lemma "∀(x::8 word) y. x + y = (x AND y) + (x OR y)"
      by eval

or

    value "∀(x::4 word) y z. y mod z = 0 ⟶
                             (x * y) div z = x * (y div z)"

Note that as usual for "eval" and "value" terms have to be close, i.e.
you need to use object logic quantifiers.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-10 08:54:18 +11:00
Gerwin Klein e89813ecf2
proofs: updates for monad refactor
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:55 +11:00
Gerwin Klein 409d780e07
x64 ainvs: resolve FIXME move
These lemmas are in the right place, they should not be moved.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:52 +11:00
Gerwin Klein 91533a274e
ainvs: add invs_strengthen
A lemma set for the strengthen method to pull `invs` out of
implications. Together with simp and conj_cong, this can help avoid
proving `invs` multiple times (which tends to blow up the proof state).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:52 +11:00
Gerwin Klein a6dee7bf17
access: constrain auto
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:52 +11:00
Gerwin Klein 2da61f7373
access: remove unused lemma
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:52 +11:00
Gerwin Klein 8c1d67945d
crefine: NonDetMonad.valid -> NonDetMonadVCG.valid
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein 8791c1be22
proofs: hoare_pre_cont variable renamed
s/hoare_pre_cont[where a=/hoare_pre_cont[where f=/

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein 7b1e140912
proofs: valid_def moved to NonDetMonadVCG
NonDetMonad.valid_def -> NonDetMonadVCG.valid_def

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein 0733fa582a
proofs: alternative_valid -> alternative_wp
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein bafe2586f4
clib: fix up qualified names
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein bd449a071d
lib: theory imports + proof updates for monad refactor
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein 549cb893de
lib+ainvs: pull up more empty_fail lemmas
- pull base-level empty_fail lemmas from AInvs into Monads.Empty_Fail
- apply consistent naming
- apply consistent [intro!, wp]
- make all non-conditional lemmas [simp]
- re-add context building to empty_fail rules, because the select_*
  rules may need context to solve their side condition

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein a6e2d73e72
lib: introduce [empty_fail] and merge EmptyFailLib
- merge EmptyFailLib into Monads.Empty_Fail
- group Empty_Fail lemmas so it is clear where to add new ones
- add [empty_fail] so not every lemma has to declare multiple attributes
- add instructions

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein e3c74c2b6e
lib/monads: remove alternative_valid in TraceMonad
subsumed by alternative_wp

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein c679117676
lib/monads: style cleanup in NonDetMonadLemmas
- apply modern style
- contract some proofs
- this commit includes some lemmas factored out from NonDetMonadVCG in
  a previous commit

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein 9573e5cb85
lib/monads: style cleanup in NonDetMonad
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein b0da6b3ee9
lib/monads: style cleanup in MonadEq+MonadEq_Lemmas
Style and proof contraction.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Gerwin Klein 4f44b1ce7e
lib/monads: style cleanup in In_Monad
- style and some proof contraction
- `in_monad` set remains unchanged for now (could now add additional
  lemmas, but they might break things)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:49 +11:00
Gerwin Klein 708cee52f6
lib/monads: style cleanup in WhileLoopRules
- adjusted thy imports for new theories
- apply consistent style
- fix indentation
- minor proof contraction

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:49 +11:00
Gerwin Klein 8e81962b47
lib/monads: refactor + cleanup in No_Fail
- factor out valid_NF definition and lemmas into NonDetMonad_Total
- apply modern style and (very) occasional proof contraction in both

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:49 +11:00
Gerwin Klein 6758f2b3e7
lib/monads: refactor + cleanup in NonDetMonadVCG
- factor out valid_exs definition and properties into NonDetMonad_Sat
- apply modern style to both of these and More_NonDetMonadVCG
- factor out one lemma into Monad_Lib
- better grouping of lemmas in NonDetMonadVCG
- occasional proof contraction

Should contain no real semantic differences, but might have subtle
wp set changes due to reordering (to be fixed up in a later commit).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:49 +11:00
Gerwin Klein dfc7699407
lib/monads: add sum type to Datatype_Schematic
This should allow wpfix to automatically fix up projl/projr proofs.
This was previously not possible without drawing in Lib, but will now
be picked up by Lib since theLeft/theRight are now abbreviations.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:49 +11:00
Gerwin Klein b93335745e
lib/monads: style cleanup in Empty_Fail
Mostly contraction and some refactoring.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:48 +11:00