Commit Graph

4682 Commits

Author SHA1 Message Date
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
Rafal Kolanski 11ce90f8cc aarch64 haskell: some RISCV->ARM renames
Previously renamed invocation labels, as well as decodeARMMMUInvocation
and performARMMMUInvocation.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski d85201d2f1 aarch64 haskell: add Arm memory barriers
Copied from ARM_HYP.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Rafal Kolanski e3f6caee72 aarch64 haskell: add VCPU/HYP infrastucture
Largely adapted from ARM_HYP, modified and checked against C code.
Remaining known issues marked with FIXMEs.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 0b023a4fc1 aarch64 github: provide repo token and cache
The repo token allows the action to work on a private repo, and
the S3 cache bucket name allows it to charge a different org.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein d98d3ea703 github: enable standard checks on aarch64 branch
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 98f0338877 aarch64 haskell: global kernel data
Model AARCH64-specific global kernel data, which means:

- adjust vspace region mapping names
- remove global page tables, including accesses (copyGlobalMappings)
- add pointer to empty user page table

This commit does not yet include VCPU and SMMU.

As on 32-bit ARM_HYP, global page tables exist on AARCH64, but are not
accessed by any code after boot, so are not visible in verified code
apart from defining the (constant) kernel window and kernel mappings
during execution. User code without a valid VSpace root is assigned a
pointer to an empty table.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein c3a2f39762 aarch64 haskell: global state component naming
Set the naming convention for global state components to armKS..
This overlaps with ARM and ARM_HYP, but so do the concepts as well
as the C convention.

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