Commit Graph

1205 Commits

Author SHA1 Message Date
Gerwin Klein 540bb64383 arm-hyp abstract+design: object_type enum reorder
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-08-14 15:51:34 +02:00
Gerwin Klein f6eaad52f3 arm abstract+design: reorder object_type enum
AArch64 C code changes now designate PageDirectoryObj as the VSpace
object type, which comes first in the enum.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-08-14 15:51:34 +02:00
Corey Lewis 2c8f9eeff1 lib+spec+proof+autocorres: consistent Nondet filename prefix
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-08-09 12:07:06 +10:00
Corey Lewis 9b90b9e34a lib+spec+proof+autocorres: update for renamed Reader_Option_Monad
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2023-08-09 12:07:06 +10:00
Gerwin Klein 460d99b2e0 haskell: upgrade to lts-20.25 and ghc 9.2.8
GHC 9.2.8 has better support for Linux/aarch64/v8 for use in Docker.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-06-19 10:00:45 +10:00
Michael McInerney fc44f65175 aspec+haskell: add accessor names for scheduler_action datatype
This adds sch_act_target/schActTarget accessor names for the
switch_thread/SwitchToThread constructor of the scheduler_action
datatype at the aspec and Haskell level, respectively

Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-06-05 17:52:06 +10:00
Matthew Brecknell c4d673b96d cspec: Use L4V_PLAT in build export script
CI is introducing an `L4V_PLAT` variable to support proof runs across
more platform configurations. This commit incorporates `L4V_PLAT` into
the paths generated by `export-kernel-builds.py`, to ensure that
exported builds can be disambiguated.

Signed-off-by: Matthew Brecknell <matt@kry10.com>
2023-06-05 13:34:14 +10:00
Gerwin Klein 7c422d7839 cspec: introduce L4V_PLAT
L4V_PLAT selects a platform variation within a L4V_ARCH. This mostly
affects which seL4 cmake config file is loaded when building config
data and the kernel C code. This in turn affects (and will rebuild)
ASpec, ExecSpec, and CSpec.

Examples:

    L4V_ARCH=ARM L4V_FEATURES="" L4V_PLAT=""

will load `ARM_verified.cmake`

    L4V_ARCH=ARM L4V_FEATURES="" L4V_PLAT=imx8mm

will load `ARM_imx8mm_verified.cmake`, and

    L4V_ARCH=ARM L4V_FEATURES=MCS L4V_PLAT=imx8mm

will load `ARM_MCS_imx8mm_verified.cmake`

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-06-05 12:04:29 +10:00
Gerwin Klein 971be5fe2d haskell: constrain run_tests to current L4V_ARCH
Provide L4V_ARCH targets in the Haskell Makefile and constrain
run_tests to use only the current L4V_ARCH, to avoid building all
architectures in all tests.

A manual invocation of just `make` will still build all architectures
for easier checking.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-31 14:46:35 +10:00
Gerwin Klein aa2eb9ad6d
design: fix ExecSpec for other architectures
Include the new ArchPSpace_H file, which on the other (non-AArch64)
architectures will only contain an empty placeholder function.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-26 18:04:48 +10:00
Gerwin Klein 064d102047
aarch64 ainvs+refine: proof updates for PT type ghost state
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-26 18:04:47 +10:00
Gerwin Klein e0ae44a577
aarch64 haskell+design: record PT types in ghost state
For making the state relation functional in refine/ADH_H we need to
know to which type of page table each PTE belongs. Record this
information in ghost state, similar to what we do for CNode size and
user page size.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-26 18:04:47 +10:00
Rafal Kolanski 7ed847638d
aarch64 haskell: update decodeARMASIDPoolInvocation
Check for mapping was incorrect (attempted to check the ASID cap for
ptIsMapped) and it turns out not necessary.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-05-26 18:04:45 +10:00
Rafal Kolanski 7cea1dc893
aarch64 aspec: attribs_from_word used wrong bits
bit 0 set = cachable = NOT Device
bit 2 set = execute never = NOT execute

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-05-26 18:04:45 +10:00
Gerwin Klein f3bbd47537
aarch64 haskell: prefer fail over error
`error` is mapped to `undefined` which does not work well with `crunch`.
`fail` is mapped to monadic `fail` in Isabelle, works fine with crunch
and we have to prove that it's not called in `corres`.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-26 18:04:45 +10:00
Gerwin Klein 9f25a4e8f6
aarch64 haskell: use ppn concept for PageTablePTEs
Don't store the bottom 12 bits of the base address for page table PTEs,
because we know they are zero. This gives us implicit alignment to
pageBits in the page table walker.

The C code stores only 36 significant bits, whereas this commit still
uses a full 64-bit machine word for the ppn in Haskell. To be adjusted
in a future change.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-25 19:34:16 +10:00
Gerwin Klein 394f74b615
aarch64 aspec: sync vmid bit width with Haskell+C
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-05-25 19:34:16 +10:00
Gerwin Klein 83ddb4def9
aarch64 ainvs: remove unused physBase lemmas (#625)
The condition `pptrBase < kernelELFBase` is not required on AArch64 in
hyp mode and was left over from the initial RISC-V setup.

Since this check does fail for some platforms (where physBase = 0 and
consequently pptrBase = kernelELFBase) we remove it here.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-04-05 13:50:33 +10:00
Gerwin Klein 0cf64b5498
READMEs: use run_tests consistently in READMEs (#622)
Avoid mixing `isabelle`, `make`, and `run_tests` invocations.
Standardise on `run_tests` and mention `L4V_ARCH` each time to
indicate that you can and should set `L4V_ARCH`.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-30 13:59:18 +11:00
Gerwin Klein 5fc1c13613
riscv machine+ainvs: physBase abstraction
Move physBase into Arch_Kernel_Config_Lemmas, and move basic lemmas
about kernel constants that do not directly unfold physBase into
ArchInvariants_AI.

Because Arch_Kernel_Config_Lemmas does not have all names available
yet, some of the lemmas are folded and shadowed later in
ArchInvariants_AI.

Also refactor translate_address_kernel_elf_window to have two helper
lemmas that can be used in infoflow.

Co-authored-by: Corey Lewis <corey.lewis@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-29 11:05:27 +11:00
Gerwin Klein c969e4769c
riscv aspec: make example init state more flexible
- adjust the example init state such that it does not constrain the
  value of physBase and kernelELFBase too much. We assume 4M physical
  memory and 4k of kernel ELF memory. We need 4M for the infoflow
  example, because it requires a 2M RISCVLargePage plus additional
  kernel objects.

- make the PagePTE for kernelELFBase point to kernelELFPAddrBase so
  that the mapping stays consistent when physBase changes.

- introduce shorthand constants for the index in the page table that
  is responsible for kernelELFBase, and for the number of bits left
  to translate from the top-level page table (= size of the pages in
  that table).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-29 11:05:26 +11:00
Gerwin Klein 662245c8cb
riscv machine+design+crefine: explicitly set pptrTop
Factor out pptrTop from the definition in kernelELFBase and define it
as a constant as on other platforms. Shadows the equivalent definition
in Haskell.

Also remove incorrect comment -- the term was not PADDR_TOP, but
PPTR_TOP in C.

Co-authored-by: Corey Lewis <corey.lewis@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-29 11:05:26 +11:00
Gerwin Klein 6d7b540963
aarch64 machine+ainvs: physBase abstraction
Remove the only unfolding of Kernel_Config.physBase_def in
ArchKernelInit by removing an unused lemma. Move the remaining
unfolding in ArchAInvariants to Kernel_Config_Lemmas.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-29 11:05:26 +11:00
Rafal Kolanski 0fc9a0542c
arm+arm-hyp machine+ainvs+refine+crefine: physBase abstraction
physBase is reduced to be unfolded only in Arch_Kernel_Config_Lemmas.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-29 11:05:25 +11:00
Rafal Kolanski 9288b78694
machine+aspec: add Arch_Kernel_Config_Lemmas
While having a single Kernel_Config_Lemmas was fine for constraining the
number of domains, it does not work for constraining architecture-specific
configuration options/values.

Add an (empty for now) Arch_Kernel_Config_Lemmas theory to every architecture
that imports the generic Kernel_Config_Lemmas. Change all imports of
Kernel_Config_Lemmas to import Arch_Kernel_Config_Lemmas instead.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-29 10:04:47 +11:00
Gerwin Klein e6b080ac38
tests: add kernel-config session (#614)
Make the C kernel config extraction visible as a separate test session
in run_tests so that run_tests can do concurrency control for it.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-21 13:50:37 +11:00
Rafal Kolanski 317164b3b7 machine: prepare Platform for physBase definition
physBase is now a generated definition on all arches except X64, with
the expectation that this value can change (for static multikernel systems).
All definitions that depend on physBase in C must therefore adapt to
depend on the physBase constant instead of its unfolded value.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-20 09:34:42 +11:00
Rafal Kolanski ccce2b8071 arm+arm_hyp machine: update pptrBase comment
Update to match C, the old version was very confusing.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-20 09:34:42 +11:00
Gerwin Klein 126fdfef77
aarch64 haskell: eliminate isValidNativeRoot
Define isValidVTableRoot directly as on the other architectures.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:19 +11:00
Gerwin Klein 6461e9223c
aarch64 haskell: defer reader monad FIXMEs to MCS
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:19 +11:00
Gerwin Klein f543ad0642
haskell: move countTrailingZeros to Data.Word_Lib
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:15:18 +11:00
Gerwin Klein 4a42803c6d
cspec: make remaining relative paths absolute (#607)
Previous commit 1a7eb92111 on fixing up overlay paths in kernel.mk
missed two instances.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-09 10:14:17 +11:00
Rafal Kolanski 19a56421c6 aarch64 haskell: resolve FIXMEs in Hardware
* getHSR confirmed unusued
* setHCR confirmed used on C side for hyp
* addressTranslateS1 was merged into C

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-08 18:04:03 +11:00
Rafal Kolanski 2155afbac4 aarch64 machine: clear up some FIXMEs in Platform.thy
* explain how canonical_bit concept applies to AArch64
* use powers of 2 for kernelELFBase
* pptrBase unlikely to migrate to 0 in near future
* pptrUserTop_def' is not used on AARCH64, and should not be used as we
  try to avoid expanding config_ARM_PA_SIZE_BITS_40 whenever possible

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-03-08 18:04:03 +11:00
Gerwin Klein 1a7eb92111
cspec: use absolute path for overlay targets (#597)
The `export-kernel-builds.py` script expects to be able to run the
build from an arbitrary temporary directory.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-08 07:59:32 +11:00
Gerwin Klein 42c4e78e9f
cspec: provide mechanism for adding dts overlays (#591)
Add mechanism for adding overlay.dts files to the l4v build for all
architectures apart from X64 (which does not use dts files).

For example, place a file `overlays/ARM/overlay.dts` into the tree and
the build will pick it up as custom overlay file with the correct proof
session dependencies.

If no file is provided, an empty default overlay file is used.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-07 14:35:53 +11:00
Gerwin Klein c072a9c531
cspec: extract physBase from C headers
Extract the numeric value PHYS_BASE_RAW from the generated header
gen_headers/plat/machine/devices_gen.h and provide it as the constant
physBase in Kernel_Config.thy.

In C this will later match up with the value returned by physBase().

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-03-06 11:58:08 +11:00
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