Commit Graph

4789 Commits

Author SHA1 Message Date
Corey Lewis 71b208edf5 lib: add warnings to crunch_ignore
These warn when attempting to add a constant to crunch_ignore that is
already being ignored, or when removing a constant that is not being ignored.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-27 15:03:10 +10:00
Corey Lewis 141983368b lib: add syntax to crunch_ignore multiple instances
Add support to crunch_ignore so that multiple instances can be added to
and removed from simultaneously.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-27 15:03:03 +10:00
Rafal Kolanski 9d404be331 crefine: split fastpath, rearrange Refine-based theory imports
Several parts of CRefine did not or should not depend on anything
C-related, but the import hierarchy (and theory content) did not reflect
this. Namely:
* Move_C and ArchMove_C were intended to hold items that could be moved
  to Refine yet used `kernel_m` locale and imported the C spec.
* IsolatedThreadAction indicates how to rearrange statements in the
  design spec and has nothing to do with the C spec or framework.
* Fastpath_C contained the design spec of the fastpath, the design spec
  rewrite proofs, and the C refinement. Having to rebuild nearly all of
  CRefine to work on rewrite proofs wasted time.

In the new import hierarchy:
* Move_C imports only Refine; ArchMove_C builds on Move_C
* IsolatedThreadAction imports only ArchMove_C
* The fastpath proofs are split into the spec definition (Fastpath_Defs)
  and rewrite proofs (Fastpath_Equiv), which don't depend on anything
  C-related, with their C refinement remaining in Fastpath_C.

While it is possible to separate out the fastpath definitions and rewire
proofs into a separate image or even move them to Refine, development
experience indicates keeping them alongside their C refinement remains
more convenient for the proof engineer involved.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-13 20:02:57 +10:00
Corey Lewis d7867393f0 crefine: remove duplicate lemmas from CLevityCatch
Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-05-11 10:54:33 +10:00
Rafal Kolanski 6095e9ecb2 cparser: annotate AST printing for top-level decls
In order to compare ASTs for appearance/disappearance/modification of
declarations, it is easier to have the annotations obvious to any
external tool for ease of parsing.

Annotations take the form:
"##<decl_type>: <name>", e.g. "##Function: ctzl"

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-10 16:40:42 +10:00
Corey Lewis 6f13828560 crefine: remove duplicate lemma
The lemma map_to_ko_atI2 was exactly the same as map_to_ko_atI.

Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-05-10 08:01:10 +10:00
Gerwin Klein a18d822cfc lib: increase oreturn automation
This is a partial cherry-pick of bcafa85c from the rt branch.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-10 08:00:56 +10:00
Michael McInerney 08fe7d1a63 lib: move map_set definition to OptionMonad.thy
Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka c3a210877f lib: more opt_map lemmas for upd/foldr upd
Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka cba3971a86 lib: add some opt_map/opt_map_Some update lemmas
- for trivial updates, etc.
- also flip opt_map_Some_comp

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka f8235a2fe6 lib: eta_contract opt_map unity/zero lemmas
for better applicability

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka 0daf495578 lib: add opt_predD + unfolding lemmas for opt_pred
Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka dc348b5f23 lib: add some opt_map lemmas
- for unfolding, composition with Some or None (Map.empty), etc.

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Gerwin Klein 68ed2f62c2 lib: rename opt_map_left_Some to opt_map_red
This is partial cherry-pick from Miki's commit d05b80 on the rt branch.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-10 08:00:56 +10:00
Miki Tanaka 5bb2a4cf06 lib: add opt_pred in lib/Monad_WP/OptionMonad.thy
- opt_pred takes a predicate P and an option value x and
  returns P y if x = Some y and False if x = None
- infix notation (|<), which lets us write in the style of
     P |< projections

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka 71c735540e lib: make asks and ogets coexist
- ogets and asks are equivalent
- make ogets a full abrreviation of asks
- provide the original definition of ogets as ogets_def

Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka f6d919f159 lib: add some basic option monad functions
Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Gerwin Klein 65b7139398 lib: support for Haskell Reader monad constructs
Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Miki Tanaka eda47153d1 lib: add more opt_map lemmas; opt_map_left_Some, etc.
Signed-off-by: Miki Tanaka <miki.tanaka@data61.csiro.au>
2022-05-10 08:00:56 +10:00
Gerwin Klein 12c8da5758 docs: split_simps and case over fun/primrec
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:18:47 +10:00
Gerwin Klein 81857be49e aarch64 ainvs: prefer projections where possible
Use projections also for VCPU side conditions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein ece07e6991 aarch64 ainvs: consolidate bit0/bit1 lemmas
Put all lemmas for vm_level from the bit1/bit0 classes into one place
so we can later assign these automatically.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein db70e3ea75 aarch64 aspec+ainvs: symbolic vs_index_len
Making vs_index_len a sybmolic value instead of a plain number means we
have to unfold config_ARM_PA_SIZE_BITS_40 less often (instead, we need
to consider both cases, which forces us to stay generic).

This also makes sure the type vs_index_len is always distinct from
pt_index_len (even if the sizes are the same), which was only
guaranteed in one of the two configurations before.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein a997a65464 aarch64: generic proof for vs_root_pt_idx_distinct
The previous proof inadvertently relied on the fact that
config_ARM_PA_SIZE_BITS_40 is not configured and solved the lemma
trivially instead of really proving that case.

This is only relevant for the config_ARM_PA_SIZE_BITS_40 configuration,
which is not the current verification target, but it is nicer to stay
generic in config_ARM_PA_SIZE_BITS_40 as far as we can.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 1a3cac0a5d aarch64 ainvs: close sorries in ArchInvariants_AI
This means that the invariants are strong enough to support all of the
basic properties of page table walks and vspace address arithmetic.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein d7b2098095 aarch64 ainvs: introduce invalid_mapping_slots
In some AArch64 configurations, some slots in the top-level table are
not accessible, because the IPA space size is smaller than the number
of bits the page tables can translate. invalid_mapping_slots indicates
which slots have to remain set to InvalidPTE in those tables.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 5b4592d1c6 aarch64 aspec: define an explicit IPA size
The bit width of intermediate physical addresses (IPA) is occasionally
useful in the invariants later.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Michael McInerney b84b6c3abe aarch64 ainvs: reduce sorries in ArchInvariants_AI
Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-05-05 09:17:25 +10:00
Gerwin Klein 502c143f05 aarch64 ainvs: ArchInvariant_AI proof progress
- update lemma statements to include pspace_distinct where needed,
  and adjust for multiple PT sizes.

- update most proofs accordingly, leave the rest sorried.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 1e0c99e774 aarch64 ainvs: strengthen level invariants
- introduce max_page_level to express that PagePTEs can only occur
  on levels 0-2 (regardless of PA/IPA space size)
- PageTablePTEs must always point to normal tables (can't point back
  to the top)
- PageTables at max_pt_level must be VSRootPTs

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 6f6e70ae2b aarch64 aspec+haskell: generalise pt_bits_left
Make the function usable not only in the code+specs, but also in the
invariants by adding a case for asid_pool_level (= max_pt_level + 1).
At this level, we also need to translate the bits of the top-level
table.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 3f00c71a77 aarch64 ainvs: relationship between ptes_of and pts_of
This is a bit more complex than before. The general approach is to do
lemmas per level first, then combine them in the map union of pte_of.

For ptes_of_Some, with pspace_distinct, we get the expected two cases.
Without pspace_distinct we need in the second case a condition that the
first case doesn't apply (they are only mutually exclusive when
pspace_distinct holds).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 9ac8e43b7e aarch64 ainvs: prove sync for level_pte_of/pt_of
Confirms that the two concepts line up as intended.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 8855fabb78 aarch64 aspec: assert object type in level_pte_of
This makes sure we're accessing the right kind of object for the level
we are interested in. Relying on alignment is Ok when the invariants
are in scope, but this check is more immediate and avoids us needing
pspace_aligned and pspace_distinct in all lemmas.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein f26a37cef7 aarch64 ainvs: resolve AInvs formulation FIXMEs
- void type is not used in AArch64
- remove duplication of level_of_vmsize
- state equivalence lemma
- unified formulation of valid_vspace_obj turned out to be usable so far
- confirmed that no further vmid properties are needed (in addition to
  inverse)
- removed alternative version of arch_valid_obj (but remains in history)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 00a9f40c51 aarch64 ainvs: adapt to Isabelle2021-1
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein e54d98f025 aarch64 aspec+ainvs: adjust canonical_user to IPA
Since user addresses are intermediate physical addresses in hyp mode,
the concept of canonical_user is different to other architectures.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 9a0c45a7ea aarch64 ainvs: update lemmas for cur_vcpu and vmid
These are required as interface for Invariants_AI (and generally useful)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein f49386bb09 aarch64 ainvs: sorry ArchInvariants_AI
At this stage ArchInvariants_AI should process cleanly, but is still
missing some interface lemmas for Invariants_AI.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski 14160ded02 aarch64 ainvs: VCPU-related invariants
Referenced from ARM_HYP and updated for AARCH64, and some tuning.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 291133761f aarch64 ainvs: first draft of AArch64 invariants
This is a first draft of what we think needs to change in the
invariants to model AArch64. VCPU-related definitions are still
missing, and further tweaks are likely.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein e6739fdbaa aarch64 aspec+haskell: remove kernel ELF window
AArch64 has no separate kernel ELF window, so ArmVSpaceKernelELFWindow
is not needed.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski 4ba24d0445 ainvs: remove unused requalify_consts
`wellformed_vspace_obj` is not used outside Arch locale.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 229d56cb05 aarch64 ainvs: set up ArchInvariants dependencies
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski a23e792737 aarch64 ainvs: update ArchBCorres_AI
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski ceb63634da aarch64 ainvs: init up to ArchInvariants_AI
Copied from RISCV64 with minimal search/replace, added FIXMEs.
Should be enough for formulating architecture-specific invariants.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 187168a209 run_tests: increase timeout for Haskell kernel
Give more time for downloading and compiling dependencies for runs
where these are not cached.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-02 12:54:10 +10:00
Gerwin Klein b7b9c03dfc run_tests: run design-spec from spec dir
This makes sure we're catching all dependencies that are declared for
`design-spec` in the top-level Makefile. In particular, we want
`c-config` to run at least once before either `ASpec` or `ExecSpec` run
it, to make sure these two are not racing on config generation in
`-j 2`.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-02 12:54:10 +10:00
Corey Lewis 1cef25b49a Import documentation: CRefine notes
We import some documentation with notes/issues on the refinement from
Haskell to C.

The file is a Markdown-ified version of previous documentation hosted at
UNSW.

Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-04-27 15:37:37 +10:00
Gerwin Klein d79032a1a3 aarch64 aspec: factor out VCPU functions
We had put a lot of VCPU content into ArchVSpace and ArchVSpaceAcc even
though VCPUs aren't really very related to VSpace. These functions now
live in a separate files VCPUAcc in analogy to VSpaceAcc and TcbAcc.

Some of these functions could also move into VCPU_A instead.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00