Commit Graph

4789 Commits

Author SHA1 Message Date
Gerwin Klein 393ee8b687 aarch64 aspec: sync names with C/Haskell
VSpaceRootObj -> VSpaceObj and
acap_toplevel -> acap_is_vspace

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 5b77789f9d aarch64 haskell/design: sync names with C
The top-level object type is called `VSpaceObject` in C, so we use the
same name here. The top-level cap is `VSpaceCap` in C, but since we
want to keep it as a flag in the PT Cap in the specs, we call the flag
`capPTisVSpace` for consistency.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 325b8b0185 aarch64 design: complete ArchIntermediate_H
Adds creation of top-level tables.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 23ba18eba9 aarch64 aspec: VCPU+VSpaceRoot objs in Structures
This includes the type-checking fallout from those two main additions,
but no real further validation yet downstream from Structures.thy.

PageTable objects now have an inner object that contains either a
normal page table or a page table with the potentially different size
for top-level VSpace roots.

In ArchVSpaceAcc, the follow-on effects include making pte operations
figure out what kind of object is is by first checking for the
potentially smaller-sized object, and if that does not exist, trying
the larger-sized object (which has a different base address). When
pspace_distinct and pspace_aligned invariants hold, this should model
the behaviour of Haskell/C precisely.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 6bac4e887a aarch64 aspec: validate Machine_A
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein a371fdaae2 aarch64 design: enable ArmVSpaceRegionUse
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein cd32136604 enable AARCH64 ASpec test
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein ef2a033bc4 aarch64 aspec: initial setup from RISCV64
This is mostly verbatim copy/paste from RISCV64 to get started. Needs
update and validation everywhere, but type checks for now.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 9284d4305f aarch64 design: incomplete ArchIntermediate_H.thy skeleton
Allows building ExecSpec, but is almost certainly wrong due to not
taking top-level pages into account.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 624ec70eb4 caseconvs: add AARCH64 design spec cases
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 16602556a4 aarch64 design: initial design spec
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 25ad79b28c aarch64 machine: add machine ops and missing magic numbers
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 7f83d32a77 run_tests: enable ExecSpec for AARCH64
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski c9dc9e7d34 aarch64 haskell: fix isValidNativeRoot
Should use `isVTableRoot` rather than accidentally recursing.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski de30b7ee68 design: change include point of Kernel_Config_Lemmas
Also remove some redundant imports in `Types_H`.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein ad1b3116f4 cspec gen-config: add bool config keys + defaults
Enables generation of boolean config keys. Since C for these often
equates absence with `false`, but Isabelle won't be able to deal with
the absence of the config name, we need to manually indicate which ones
we want. For now, we generate `false` for absence for all boolean keys
that have a custom Isabelle name.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski f7a5da5469 aarch64 design+machine: initialise from RISCV64 files
Use RISCV64 design spec skeletons to start work on AARCH64 ExecSpec.

Only minimal RISCV64 to AARCH64 substitution done, with big FIXMEs
stuck on top to remind people this got no human oversight.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski cfd2990fa6 haskell translator: add AARCH64, platform TX2
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein fc30187eaa stylefilter: do not check make_spec.sh
This is firmly a bash script and not intended to be portable to other
shells, so no point checking portability.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 715212dd41 aarch64 haskell: adjust syntax for translator
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 512fa574db gitignore: add AARCH64 design spec (generated)
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 6052cb4bc0 haskell-translator: allow `\` to continue lines in input files
Haskell translator import statements in skeleton files can get very
long, and keeping them as one line is rather inconvenient. This change
allows a backslash (`\`) at end-of-line to indicate line continuation.

Note: the `\` acts like in shells, i.e. it must be exactly at EOL.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 50ca8ee5da aarch64 haskell: validate ObjectType, add FIXMEs
Mark a number of SMMU issues for later.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski c231670169 aarch64 haskell: validate Thread, Failures, InvocationLabels
Note: left FIXMEs in InvocationLabels where we currently diverge from C,
and the missing SMMU invocations at this time.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 7410c07e02 aarch64 haskell: validate switchToIdleThread
Directly switches to global empty VSpace instead of doing the cap
checks in setVMRoot which we know will fail.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 69ba40e5fe aarch64 haskell: validate setVMRoot
This adds armContextSwitch and setGlobalUserVSpace, the latter a
shorthand for setting the empty VSpace, to be re-used in
switchToIdleThread.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 6337f0c6b5 aarch64 haskell: machine ops for unmapPage
Similar to unmapPageTable, but a new machine op for flushing a single
page.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 6da2771b71 aarch64 haskell: machine ops for unmapPageTable
These line up with ARM/ARM_HYP, but have different names.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 49ca3d032e aarch64 haskell: validate findFreeHWASID
Almost identical to ARM/ARM_HYP, only needs a different machine op
call.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein d37e64fe35 aarch64 haskell: validate ASIDControlInvocation
Including decode+perform. No changes to RISCV64.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 60e202a5d8 aarch64 haskell: decodeARMASIDPoolInvocation
Validate decodeARMASIDPoolInvocation. Main change to RISCV64 is that
VTableRoot caps can now be distinguished and checked-for.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein d8454f9f3d aarch64 haskell: decodeARMFrameInvocationFlush
Validated against C. We seem to be doing some unnecessary calculations
in ARM_HYP there, which are left out here (Haskell now is closer to C).
As follow-on, validated and tweaked decodeARMVSpaceRootInvocation.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein c52dfe953b aarch64 haskell: remove Simulator mention
No plans to resurrect Haskell simulation any more, so the comments are
mostly going to be confusing to people who come at this fresh.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 4262144dfd aarch64 haskell: implement isValidVTableRoot
The C code has an unnecessary name indirection via isValidNativeRoot
here, which I replicated to make more obvious what maps to what.
Eventually this should disappear.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 33f060e249 aarch64 haskell: implement lookupFrame
This is a bit speculative since the C is not there yet, but I think
it's a good candidate, esp turning the VMPageSize parameters into Int,
because that will save the C from converting it back and forth.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 06acbdb742 aarch64 haskell: validate Interrupt and TCB
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 900612734a aarch64 haskell: decodeVSpaceRootInvocation
Uses lookupFrame which still needs to be filled in. We already have
a form of that in the formalisation, and can maybe reuse some of that.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 4c7294452b aarch64 haskell: flush API, including perform
Still missing decodeInvocation, but should otherwise be complete,
including machine ops.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 2215c411a1 aarch64 haskell: deleting ASIDs and ASIDPools
This adds first AArch64-specific flushing. More to come when we add
the explicit flush API.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 3f4428edfa aarch64 haskell: VM faults
Preliminary, depending on how addressTranslateS1 ends up in C.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski e5df18102f aarch64 machine: add preliminary Platform.thy
Very early version, with C changes still in progress.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 4b56c08d3c haskell aarch64: validated Object/Instances
All definitions fine, the commit only removes the FIXME.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein c9d224d79a aarch64 haskell: fill in updateASIDPoolEntry
This refactors getASIDPoolEntry to extract code that is shared between
lookup and update, and should make conversion to reader monad later
easier.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein b1370585fe github: provide auth token for gitlint check
Missed one in c4fe1abb3d

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 92745f3e5b aarch64 haskell: simplify checkIRQ
We are on an Arm board, where <= maxIRQ implies != irqInvalid, so use
original ARM version.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 103d7cfa12 aarch64 haskell: adjust PT lookup code
This adjusts ptBitsLeft and ptIndex to properly take into account
the potentially different-sized top-level table. This is all that is
needed for the rest of the lookup code to be correct.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein f47a798ba9 aarch64 haskell: adjust API Object types
This is a sketch of what I think the API will look like after C code
changes. In particular, this adds a VSpaceRoot API object type
that stands for a top-level page table. The name may change, but a
different API object type for the different page size will probably
stay.

Different top-level table size only applies in some configurations. The
spec attempts to model both cases by making ptBits and
ptTranslationBits dependent on whether it is a top-level table or not.
The rest follows from that.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 74573d88f7 aarch64 haskell: adjust API maxBound
The VCPUObject is the last in the enum, so should be set as maxBound.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 9d851c13bf aarch64 haskell: validate Structures
Validated constants defined in Structures/AARCH64.lhs

PT caps now include a flag whether they are for a top-level table or
not. This could later be generalised to a level, but that's likely not
necessary for AArch64.

Amazingly, only the creation of new PT caps was affected by this
change. That creation will need user-level input which size of table to
create (to be added later).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski 05c5140150 aarch64 haskell: RegisterSet definitions
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00