Commit Graph

141 Commits

Author SHA1 Message Date
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
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
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
Ryan Barry 8124b326b4 infoflow+crefine: refine arch split
Signed-off-by: Ryan Barry <ryan.barry@unsw.edu.au>
2021-10-05 08:46:11 +11:00
Gerwin Klein 8730572756 crefine: remove Arch_finaliseInterrupt
The PR seL4/seL4#473 removes Arch_finaliseInterrupt; this commit
updates the C proofs accordingly.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-10-01 15:19:07 +10:00
Gerwin Klein b914029a43 ainvs+crefine: remove redundant lemmas
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein 34873cdd4a isabelle-2021 arm: update CRefine
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Florian Haftmann d61cffcf61 isabelle-2021: adjusted to new naming convention
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Florian Haftmann ea9a25950d isabelle-2021: ad-hoc adjustions to preview
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein b64bd15816 cleanup: fix indent and warnings
This fixes up some atrocious indentation and removes some warnings for
duplicate rules etc.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-16 16:47:10 +10:00
Gerwin Klein 5d895508a2 arm: fix Machine_C assumptions
Some of the assumptions in Machine_C were about C functions that do not
exist (any more, presumably after some change in C). This means these
names were free variables and the rules could in theory be applied to
any function, potentially causing unsoundness. Luckily, we were
disciplined enough in the proofs not to have done that. The proofs with
the names fixed go through unchanged.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-16 16:47:10 +10:00
Gerwin Klein 6fd6d6bd48 arm/arm-hyp: proof updates for Arm cache fix
This commit updates the proofs for seL4/seL4#485, which fixes
the security and correctness bug seL4/seL4#481. The bug was that
caches are not sufficiently flushed in retype for frames that can
be mapped uncached later.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-16 16:47:10 +10:00
Mitchell Buckley 376cc707b6 crefine ARM: fixup for recent cleanup
Signed-off-by: Mitchell Buckley <Mitchell.Buckley@data61.csiro.au>
2021-07-24 12:09:57 +10:00
Mitchell Buckley 2cf89e20c8 Cleanup some FIXMEs in AInvs and related sessions
Mostly moving lemmas up into various lemma bucket theories. Also:
* replace cte_wp_at_eqD with cte_wp_at_norm (equal lemmas)
* pd_shifting_gen generalise pd_shifting' in 2 architectures
* remove some redundant crunch lemmas

Signed-off-by: Mitchell Buckley <Mitchell.Buckley@data61.csiro.au>
2021-07-16 14:13:07 +10:00
Matthew Brecknell fd01872121 always use `addrFromKPPtr` for kernel addresses
This verifies a C kernel patch (seL4/seL4#409) which consolidates
translation between virtual and physical addresses, and makes it
consistent across architectures. In particular, we always use
`addrFromKPPtr`, even on architectures that don't use a distinct region
to map the kernel ELF. This will facilitate future improvements which
move the ELF mapping into a distinct virtual address region.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-06-25 16:31:22 +10:00
Matthew Brecknell 73649d2ce4 arm crefine: fix `decodeARMMMUInvocation` branch hint
A previous update to C code added a disjunct to an `if` condition
outside the existing `unlikely` branch hint. This commit is the proof
update for a C patch that extends the branch hint to the full `if`
condition.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-05-20 11:52:45 +10:00
Matthew Brecknell d020be3b89
riscv: fix CLZ and CTZ for riscv32 builds (#257)
This commit verifies seL4 PR [#325][], which fixes the riscv32 build
broken by seL4 commit [9ec5df5f][].

[#325]: https://github.com/seL4/seL4/pull/325
[9ec5df5]: https://github.com/seL4/seL4/commit/9ec5df5f

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-30 13:17:41 +11:00
Matthew Brecknell 76ec8dfc47 crefine: remove all uses of `csymbr_legacy`
When exception-aware lifting was enabled in `csymbr`, a small number of
existing proofs were broken. The `csymbr_legacy` method was added to
preserve the old behaviour of `csymbr` for those proofs.

This commit updates those proofs to use the new `csymbr` behaviour.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 13:01:44 +11:00
Matthew Brecknell 6d5391cf4b crefine: remove large structs passed by value
The RISC-V calling convention specifies that when a C function takes an
argument by value, the binary function should take the argument by
reference, if the value is larger than 2 pointer words.

For binary verification, we avoid implementing this aspect of the RISC-V
calling convention, by eliminating all such function arguments for
functions which are not inlined. This commit includes the proof updates
corresponding to the kernel source update, which is in the seL4
repository.

This includes arguments of types `slot_range_t` and `extra_caps_t`.

`slot_range_t` is only used in two functions, so for those cases, we
unpack the arguments, and remove the type altogether.

`extra_caps_t` is used extensively in invocation decoding, and also in
inter-process communication. Since extra caps are already stored in a
global variable `current_extra_caps`, we remove the function argument,
and use the global variable instead. However, this adds significant
difficulty to the proofs, because the variable lifting performed by
`cinit` worked for the function argument, but not for the global
variable. We have therefore recently improved the `cinit` automation to
support this change to the kernel.

Even though this change was for the benefit of RISC-V binary
verification, we update all architectures for consistency.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 13:01:44 +11:00
Matthew Brecknell 337c0d62ea crefine: generalise `ccorres_tmp_lift2`
Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 13:01:44 +11:00
Matthew Brecknell e72bb9976e crefine: enable exception-aware lifting for csymbr
The new variable lifting behaviour that was recently added to the
`cinit`, `clift` and `ctac` commands is now also added to `csymbr`.
This means `csymbr` variable lifting is now sensitive to exceptional
control flow.

Since this breaks some existing proofs, we add a new `csymbr_legacy`
command with the old behaviour, and use it where necessary.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-03-19 13:01:44 +11:00
Corey Lewis 5323aad95a refine: remove duplicated lemmas
Signed-off-by: Corey Lewis <Corey.Lewis@data61.csiro.au>
2021-03-11 10:42:49 +11:00
Corey Lewis 008969fc02 lib proof: reorder the assumptions of corres_split
Currently this just modifies the rule but not any of the proofs that use
it. The old version is kept for now but should be removed once all of
the proofs are updated.

Signed-off-by: Corey Lewis <Corey.Lewis@data61.csiro.au>
2021-02-19 11:37:12 +11:00
Gerwin Klein 83cbc07cd8 crefine: proof update for seL4 7cc50c3039
The corresponding seL4 patch removes an unused line in
invokeUntyped_Retype

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-11-30 16:22:31 +11:00
Rafal Kolanski 7d998ac2ba arm+arm-hyp crefine: update for platform constant changes
Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-11-16 16:52:40 +11:00
Rafal Kolanski 9ed45e17bd arm+arm-hyp: kernelBase and physMappingOffset renames
This brings the naming convention closer to the other architectures,
closer to the Haskell, and closer to the constant renames that happened
in C. It is, however, quite an invasive change.

kernelBase_addr -> pptrBase
kernelBase -> pptrBase
physMappingOffset -> ptrBaseOffset

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-11-16 16:52:40 +11:00
Gerwin Klein a45adef66a all: remove theory import path references
In Isabelle2020, when isabelle jedit is started without a session
context, e.g. `isabelle jedit -l ASpec`, theory imports with path
references cause the isabelle process to hang.

Since sessions now declare directories, Isabelle can find those files
without path reference and we therefore remove all such path references
from import statements. With this, `jedit` and `build` should work with
and without explicit session context as before.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-11-02 10:16:17 +10:00
Gerwin Klein 875c313e71 arm crefine: Isabelle2020 update
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-10-27 15:52:31 +10:00
Gerwin Klein 68b71f99b5 crefine: session structure update for Isabelle2020
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-10-27 15:52:31 +10:00
Gerwin Klein bbacd7079f proof/ROOT: more Isabelle2020 session structure
SimplExportAndRefine is now split into two steps;
AutoCorresTest moved to its own directory.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-10-27 15:52:31 +10:00
Matthew Brecknell ea1be49908 crefine: make C state relation non-empty
We believe this commit fixes the issue described in the previous commit.
It also reverts that commit, since the proofs that the C state relation
is empty no longer work.

As the previous commit demonstrated, it is important to demonstrate the
non-triviality of properties. In this case, we should exhibit a witness
of the non-emptiness of the C state relation. We have not yet done that.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2020-08-19 16:15:05 +10:00
Gerwin Klein c3f3656942 refine + crefine: proof updates for haskell datatype selectors
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-07-09 10:06:31 +08:00
Gerwin Klein 24b119f338 crefine + infoflowc: adjust proofs for new Haskell assertion
The new kernelExitAssertions need to be threaded through the fastpath
and integrated in the right place in the theorems about callKernel.

In InfoFlowC we have yet another refinement framework, and we're taking apart
callKernel to isolate the `schedule` call which is significant in the
infoflow proof and needs the new assertion inserted as wel. After some force
applied, this does work as well.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-07-02 11:30:56 +08:00
Rafal Kolanski 4515e1e78e crefine: remove ccorres_from_vcg_throws_nofail
(now present in lib)

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-06-08 20:41:11 +08:00
Gerwin Klein e7f6e97c6b cleanup: remove stray diagnostic commands and comments
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-06-08 20:41:10 +08:00
Gerwin Klein 35d513c0e4 arm crefine: proof updates for new arch split functions
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-06-08 20:41:10 +08:00
Rafal Kolanski a2ea423e76 crefine: valid_untyped' lemma is not generic
Move it to ArchMove_C for each architecture except RISCV64. On RISCV64
the definitions of obj_range has changed to use mask_range and hence the
lemma statement would look different.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-06-04 23:29:52 +10:00
Rafal Kolanski c4f6572aff arm+arm-hyp: move TPIDRURO from vcpu to tcb context
Update specs and proofs for ARM platforms to contain TPIDRURO in the
TCB user context rather than treating it as a VCPU register, following
change in C.

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-05-15 13:14:24 +10:00
Gerwin Klein 71e7f87614 haskell/refine/crefine: rename isBlocked to isStopped
sync with corresponding change in C

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-05-06 15:49:02 +10:00
Victor Phan 046a1358f6 crefine: remove lemmas moved into ArchMove_C/Move_C and fix proofs
Signed-off-by: Victor Phan <Victor.Phan@data61.csiro.au>
2020-03-20 13:42:48 +11:00
Victor Phan 70fe3fa943 crefine: arch split for Move theory files and move in lemmas
crefine/[ARCH]/Move.thy is replaced with crefine/Move_C.thy
(arch-generic), and crefine/[ARCH]/ArchMove_C.thy (arch-specific).
The only CRefine theory file that imports ArchMove_C is CLevityCatch,
and ArchMove_C imports Move_C which imports "Refine.Refine".

Lemmas found by looking through "FIXME: Move" comments have been added
to either Move_C or ArchMove_C depending on whether it is arch-generic
or arch-specific respectively.

Signed-off-by: Victor Phan <Victor.Phan@data61.csiro.au>
2020-03-20 13:42:43 +11:00
Gerwin Klein a424d55e3e licenses: convert license tags to SPDX 2020-03-13 14:38:24 +08:00
Victor Phan 966734c69b Collect abstract lemmas in Refine
Create ArchMove_R.thy for transporting arch specific lemmas (and generic
lemmas that are used somewhat specifically by one architecture) to theory
files before Refine.

Create Move_R.thy as an arch generic Refine theory file for transporting
generic lemmas to theory files before Refine.

Also delete some lemmas that have existed earlier already or are not
needed.

Rename Move.thy in CRefine to Move_C.thy for consistency.
2020-02-21 11:49:25 +11:00
Zoltan Kocsis 788b4bd180 refactored irq_t structure (VER-1159) 2020-02-05 17:58:45 +11:00
Victor Phan f2d1f5ada7 refine/crefine: convert crunch with multiple constants into crunches 2020-02-03 16:29:19 +11:00
Victor Phan 285c47f622 cleanup for crunch_ignore in refine and crefine for all arches
Several constants are are added to the top level crunch_ignore statement in
Bits_R.thy, then removed from individual crunch statements across Refine and
CRefine.
2020-02-03 16:29:18 +11:00
Gerwin Klein 430f2c525b crefine: invocation label proof updates 2020-02-03 12:56:19 +08:00
Victor Phan b9c285400d remove diminished (VER-1158)
diminished takes two caps and asserts that one is equal to the other
except that one may have fewer rights. We remove this definition and all
references to it, replacing diminished with equality.
2019-11-16 01:03:36 +11:00
Gerwin Klein 1970ed0ce0 word_lib internal + crefine: remove duplicate lemma 2019-11-15 12:08:22 +11:00
Gerwin Klein c390ba7404 proofs: adjustments for word_lib changes 2019-11-15 12:08:22 +11:00