Commit Graph

1218 Commits

Author SHA1 Message Date
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 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
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
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 55bf10c1ab
aarch64 aspec+ainvs: provide+use symbolic ppn_len definition
We initially wanted to move ucast_ucast_ppn to Kernel_Config_Lemmas.
This doesn't work, because ppn is only defined in Arch_Structs_A, but
it turns out that ppn_len is exactly the term `ipa_size - pageBits`
that the lemma needs, so instead of moving the lemma up, we make its
proof generic by providing the symbolic form of `ppn_len` instead.

This still unfolds Kernel_Config.config_ARM_PA_SIZE_BITS_40, but it
does so only trivially and directly where ppn_len is defined.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:37 +11:00
Gerwin Klein 8f6373c7ef
aspec + aarch64 ainvs: remove duplicate definition of the_arch_cap
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +11:00
Gerwin Klein 747e1e2531
arm_hyp+aarch64 machine: use standard machine op naming scheme
Implementations for machine ops returning a value should have a _val
postfix. This commit brings vcpuHardwareRegVal in line.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +11:00
Gerwin Klein 02d055fb5e
aarch64 aspec+ainvs: resolve FIXME move
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:35 +11:00
Gerwin Klein ef6ef86de1
aarch64 aspec+design: import flush_type from Haskell
The flush_type definition is an exact duplicate, so it makes sense
to directly re-use the Haskell definition in ASpec.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:35 +11:00
Gerwin Klein 5b7e01e5f7
aarch64 haskell: port associateVCPUTCB fix from ARM_HYP
Apply the vcpuSwitch fix to Haskell as well (was previously added to
ASpec only).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:35 +11:00
Gerwin Klein 1e4b3d7573
aarch64 machine: introduce irq_len
Make it possible to refer to the size of the irq type symbolically.
So far, this is only necessary in an example state for kernel init,
but it's still nicer to avoid magic numbers.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:40 +11:00
Gerwin Klein 2f1493c7ab
aarch64 machine: add relevant non_kernel_IRQs
The non_kernel_IRQs constant collects IRQs that cannot occur in kernel
mode. For non-hyp platforms this is usually empty, for hyp platforms we
add software-generated virtual interrupts.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:39 +11:00
Gerwin Klein b5038beb6d
aarch64 aspec: add associate_vcpu_tcb fix from ARM_HYP
On ARM_HYP we added a fix for a problem discovered during the proof of
the VCPU invariant that the current VCPU always belongs to the current
thread. This commit ports that fix from ARM_HYP to AARCH64.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:39 +11:00
Gerwin Klein 1a1fdffb11
aarch64 aspec: adjust Init_A to satisfy invariants
- align init_irq_node_ptr to its size (which is larger than in RISCV)
- remove ArmVSpaceUserRegion, because kernel has its own page table
- define global_pt_obj, add to initial heap

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:38 +11:00
Gerwin Klein 88dd8d8f7a
aarch64 haskell+machine: sync pptrTop and pptrBase with C
Sync both values with what the C code does. The corresponding comment
in C is wrong and would not produce a safe value for pptrTop (the
comment says 2^48 - 2^30), but the actual definition in C (the
equivalent of 2^40 - 2^30) is safe.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:38 +11:00
Gerwin Klein ea00978a6a
aarch64 aspec: fix decode vspace_root check
Previously the wrong cap argument was checked against being the vspace
root (cap vs vspace_cap).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:38 +11:00
Gerwin Klein a9fd0142be
all: adjust theory imports for TypHeapLib change
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:45 +11:00
Gerwin Klein 6dcbd4f09f
spec+proofs+autocorres: theory import fixes
Adjust theory imports for new sessions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:06 +11:00
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
Rafal Kolanski 37e2a34f28 aarch64 aspec: update handle_vm_fault
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 155d9057dc aarch64 haskell: update handleVMFault address masking
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 1f128472a7 aarch64 haskell: decide on vmid/hw_asid naming
The C code PR still uses the old naming scheme (hw_asid), but even if
it stays that way so it can share code with paths that use a "generic"
hw_asid name, it is better for the specs to use the correct name.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein f7c4fee641 aarch64 haskell: mark SMMU TODOs for later
Rename FIXME AARCH64 into TODO AARCH64 for all SMMU tasks

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 66e67fdd77 aarch64 haskell+aspec: finalise_cap for VSpace
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 61e5a84670 aarch64 aspec+haskell: config dependent vm_level
Using value_type, we can capture both config options.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 47c0ec4bdc aarch64 aspec: validate remaining ASpec theories
These are ArchCSpace_A, ArchIpcCancel_A, ArchRetype_A, ArchTcb_A.
Already in good shape, just some style copyright headers, etc.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 7a914e897a aarch64 aspec: set up Init_A
Minor style update; set up global user page table and example kernel
vspace uses that should satisfy invariants.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein b8efa38453 aarch64 aspec: validate + style ArchInterrupt_A
Also sync handle_reserved_irq phrasing with Haskell and C (sequential
comparison instead of cascaded. Comes out to the same, but no need to
prove that here).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein a9b5a5acc0 aarch64 aspec: validate ArchFault_A + Hypervisor_A
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 17e7ab1d42 aarch64 haskell: remove outdated comment
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 6d8134ef7a aarch64 haskell: sync flush decode with aspec
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein ac7491610b aarch64 aspec+machine: validate ArchDecode
This includes new vspace decode and page flush invocations, as well
as machine constants that are used in those paths.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 8275426a62 aarch64 haskell+design: ObjectType order
The actual order for the ObjectType enum is defined in design. This one
has to correspond to the C enum. Mirroring it here in Haskell for
consistency.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 5ee170d987 aarch64 haskell: fix name shadowing
The parameter pte was shadowed by the object load, resulting in
incorrect semantics.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 539e82858e aarch64 haskell: remove redundant check
The page table size can not be "vspace" here, because the invocation
is only for lower-level tables.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 27922da136 aarch64 haskell: sync invocation names with aspec
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 0c5c0fab57 aarch64 aspec: validate Arch+ArchInvocation
This includes adding flush invocations for page tables and vspace.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 9350978a4b aarch64 aspec: style for ArchVSpace_A
Now that VCPU is in, there is less risk of conflicts.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 4ea3c0c307 aarch64 aspec: add VCPU/HYP infrastucture
Largely adapted from ARM_HYP, modified and checked against Haskell code.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 15dc7d2959 aarch64 design: make vcpuBits available through MachineTypes
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski f86a3944ba aarch64 aspec: prepare_thread_delete with FPU
Use simplified `fpuThreadDeleteOp` machine op abstraction to match
Haskell.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 9c3a02bd65 aarch64 aspec: validate ArchVSpace_A PT operations
VCPU and style still needs to be updated, but the virtual memory
operations in this file are validated.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein cf98dd20dc aarch64 aspec: review+style for ArchVSpaceAcc
This theory file should now be in a reasonably final state.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 1ce09ded7a aarch64 aspec: import handle_vm_fault from ARM
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 8c0eaa973f aarch64 aspec: asid_map and vmid operations
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 90f22d2b93 aarch64 machine+design: cache+barrier machine ops
This replaces the RISC-V operations; for now commented out in ASpec.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 03ea580a29 aarch64 aspec: add asid_pool_entry type
This only updates the rest of the spec to type check, it does not
yet use the vmid information stored in the new type.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 89815424cf aarch64 aspec/haskell: sync attribs_from_word
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 29518b9bb0 aarch64 aspec: validate pte type
The pte type is now in sync with Haskell and C.

Note that there is a trade-off in storing the entire paddr (base
address) in the pte. In RISC-V we don't store the bottom bits, so get
an invariant for free that these are always 0, but we need to do a
bunch of shifting and casting to convert addresses. The shifting there
aligns with the C code.

On AArch64, the address field instead uses field_high, which does the
shifting inside the bitfield generator and makes it invisible to the
rest of the C code. To model that there is no such shifting going on,
we choose to store the entire base address here (as in ARM/ARM_HYP).
This means we will need an invariant that they are all aligned to
pageBits.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 77dc7e0dc4 aarch64 aspec: use map union for ptes_of levels
Use a more principled way to define ptes_of/get_pte by defining
level_pte_of parametric in the level and setting ptes_of to the union
of all levels. This works because objects must be distinct.

For store_pte a simple union doesn't work, but we can still first
extract the level, and then use the level to update the object for that
level.

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