Commit Graph

1149 Commits

Author SHA1 Message Date
Gerwin Klein bba173cb99
lib+READMEs: rename Monad_WP to Monads
In preparation for a separate Monads session.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein 79eccd3c10
lib+spec+proofs: proof fixes for NonDetMonadLemmaBucket split
Very minor changes, but in many modules.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:34 +11:00
Michael McInerney 9b33cfad36 update copyright
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2022-11-09 15:52:50 +11:00
Corey Lewis 4d46308d9e isabelle2022 cspec: update mk_umm_types.py
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-11-09 11:45:46 +11:00
Gerwin Klein 1f8eff2fa9 aarch64 spec+haskell: atomic write in delete_asid
At the point we call set_asid_pool, the pool we are writing is out
of date, because invalidate_asid_entry will have changed it. This
commit adds another read operation after invalidate_asid_entry to
perform a write that is similarly atomic as the corresponding C code.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 2c8ccb8c81 aarch64 aspec: update arch_is_frame_type
Did not take into account VCPUs previously.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 314abe617d aarch64 aspec: require VSRootPT for ASIDPoolAssign
Haskell already does this correctly, this was just missed in ASpec.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein f775c18d51 aarch64 aspec+haskell: use cap level in pt_unmap
We previously made use of the fact that the table to be unmapped will
be a NormalPT_T. This is still true, but to avoid an unnecessary proof
obligation here, we take the pt_type provided by the cap instead, which
coincides with the pt_type the proof uses.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 22ee1150d3 aarch64 aspec: make naming consistent
There were still a few old `hw_asid` left over that now are `vmid`.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 2098719494 aarch64 aspec: align storePTE with ptes_of
Check that the type of the page table that is present is the type we
are requested to update. The same assert is already present for ptes_of.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein ba033cc300 riscv haskell+proofs: fix PageTablePTE encoding
According to the RISC-V spec, PageTablePTEs must have the access,
dirty, and user bits set to 0. This means that

- there is no user attribute that can be set on PageTablePTEs
  (removed from Haskell spec)
- the encoding for PageTablePTEs in C must have 0 in these fields
  instead of 1.

See PR seL4/seL4#880 for discussion and corresponding C changes.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-07-18 10:40:17 +10:00
Gerwin Klein 3e8114fd8f haskell: remove use of strict $ operator
The strict function application operator made sense when performance
mattered because the model was used from a simulator. Now it's just
noise.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-24 13:07:17 +10:00
Gerwin Klein 3079ff5763 haskell: ! operator needs space separation
GHC 9.0.2 requires a space between ! and the operand to distinguish
the expression from a bang pattern.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-24 13:07:17 +10:00
Gerwin Klein d5f36c023a haskell: no parentheses around @ patterns
GHC 9.0.2 is more strict in its pattern syntax and rejects @ patterns
that are surrounded by parentheses.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-24 13:07:17 +10:00
Gerwin Klein 68ee57a1b2 haskell: `fail` requires `MonadFail` in ghc-8.8.4
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-24 13:07:17 +10:00
Gerwin Klein 02cc37a0e3 haskell: use ghc-9.0.2 and cabal v2 commands
- switch to lts-19.12 (GHC 9.0.2)
- use cabal v2 commands, which build locally by default and don't
  need a separate sandbox
- update SEL4.cabal file to cabal spec version 3
- remove generated `cabal.project.local~*` backup files after configure
  to avoid flooding the directory

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-24 13:07:17 +10:00
Ryan Barry 23b6184766 dspec+drefine+infoflow: update misc. proofs
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Gerwin Klein 0d344f0c2e haskell: update for seL4/seL4#846
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Gerwin Klein 8effcb0e42 aspec: generate proper kernel reply for PageGetAddr
The previous spec was trying to set message registers manually
when instead it should have just returned the list of data words
that forms the reply. This correctly modeled the currently wrong
behaviour in C, which seL4/seL4#243 fixes.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Rafal Kolanski 6c2e8fc4eb arm-hyp+aarch64: update for stage 1 translation changes
C code changed to drop stage 1 translation from constructing VM fault
messages when in a hypervisor context.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:11:40 +10:00
Rafal Kolanski f04a6319cc arm-hyp: rename addressTranslateS1CPR
renamed to: addressTranslateS1

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:11:40 +10:00
Gerwin Klein 794c2475e9 aarch64 aspec+haskell: arch_same_region_as fix
arch_same_region_as must respect the type of the object the cap points
to, so we need to constrain PageTableCap to the same type.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 1edf35a287 aarch64 aspec+ainvs: make pt_walk_is_aligned true
On RISCV64, we had the nice property that pt_walk can only produce
aligned addresses. This alignment is important for further address
computation.

It turns out that the same is true on AARCH64, because the bottom 12
bits of page table addresses are not stored in PTEs. PagePTEs can only
point to normal page tables, so there is not variation in the size of
the alignment.

This commit uses a similar encoding to RISCV64 to achieve this pt_walk
property without using an additional invariant.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 98bb90e0c3 Makefiles: remove unused report-regression target
This target was used in the regression test setup before this repo
switched to `run_tests` and has been unused for some time.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 30f50d5506 aarch64 aspec+ainvs: declare level_type a coercion
This means Isabelle will automatically insert `level_type` when it
finds a term of type `vm_level` but expects one of type `pt_type`.
This only works when the context is unambiguous, but it does make quite
a few terms shorter.

This is input-only, `level_type` will still show up in output.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein d87cf0bed8 aarch64 aspec: adjust for Haskell-defined PT type
This includes a new type for ptTranslationBits, which is also shared
from Haskell.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 8ff19483a8 aarch64 design: ExecSpec with PT types
adjusting caseconvs and pulling in the type at the right place for
sharing with ASpec.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 6b6f087184 aarch64 haskell: use PT types in Haskell as well
Same principle as for ASpec, set up in a way that PT_Type can be shared
between the specs. Fewer occurrences in Haskell, because does not have
explicit page table objects, only PTEs.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein e28bf2d681 aarch64 aspec+ainvs: introduce pt types
Replaces bool with a dedicated type for page table types. This should
generalise nicely to more different levels and removes the slightly
confusing occurrence of bool.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 6c229d7b0d aarch64 ainvs: use machine_word for table indices
This replaces 'a word for indices with machine_word. Since we can't use
a specific word length for a generic table index (because different
tables can have different index types), we don't win much by using 'a
word, but we do lose something: we must instantiate 'a when we use the
term, which means we need to decide at that point which type of table
we are talking about. This forces early case distinctions in proofs.

Using machine_word allows us to delay committing to a particular table
type and instead write a generic condition on the width of the index.

We are using machine_word instead of nat or a different specific word
length, because the index into the table is a slice of either an
obj_ref (in ptes_of) or a vref (when we do page table walks), both of
which are compatible with machine_word.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein bdd37a3307 aarch64 aspec: make pte levels separate
Instead of modeling uniform PTE access between levels from Haskell and
C, it comes out cleaner in the abstract spec to keep PTE access
separate per level. This means that get/storePTE take an is_vspace
argument, which in turn is propagated up, so a few more functions now
have a level/is_vspace argument.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +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 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
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 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 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 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
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
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
Gerwin Klein 69aa2d135c aarch64 haskell: sync invocation type with ASpec
The page-map case was still using Cap instead of ArchObjectCap.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 15f8da4688 aarch64 aspec: sync arch_state order with Haskell
As Corey points out, the rest of the fields are in perfect order with
Haskell, and keeping all of them fully in sync will save us shuffling
and looking up things later in the proofs.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein d3a33e85e4 aarch64 ainvs: make vs_index_len generic
- tune comment
- make vs_index_len the generic interface for vs_index_len_def
- provide relationship to ptTranslationBits

The two latter points will help to keep invariant proofs generic over
the size of the top-level table.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein a74879293d aarch64 machine: style
consolidate the different styles used over the ages into the current
one.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein f5acf1cecd gen_config: add generator as dependency
Config files should be re-generated when generator content changes,
because that generally changes the content of the output.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 776ec65564 aarch64 aspec: sync pptrUserTop with C
On AArch64 pptrUserTop is not page aligned, which also suits us fine for
reusing the value later in AInvs.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein f46f9bd74e machine: make Kernel_Config available earlier
Definitions in Platform.thy may depend on kernel config options, so
we need Kernel_Config_Lemmas there already, and need to replace the
dependency in Machine_Types to avoid a dependency circle.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 1378d1a200 aarch64 design: remove stale FIXMEs
These files have been reviewed, but the FIXMEs stuck around.

Update copyright on files we modified, and leave as is for only
copy+sed.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein ab76f0a250 aarch64 haskell: prefer "maybe" over "case"
More clear and concise.

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