Commit Graph

1118 Commits

Author SHA1 Message Date
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