Commit Graph

1220 Commits

Author SHA1 Message Date
Achim D. Brucker e59d6ad091 Renamed Word_Lib shipped by AutoCorres to Word_Lib_l4v to avoid a name clash with the AFP entry of same name. 2024-01-27 13:44:24 +00:00
Gerwin Klein 52b4ba5091 aarch64 machine+aspec+cspec: pt_type ghost+table array sizes
- add ghost state corresponding to gsPTTypes in Haskell and ASpec
- add ghost type comments
- style update for old definitions since we need to touch most of these
- define vs/pt_array_len for use in C annotations
- make NormalPT_T/VSRootPT_T names available for use in C annotations

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2024-01-16 10:01:47 +11:00
Gerwin Klein a828b996db cspec/c: provide NUM_DOMAINS build override option
Setting the environment variable INPUT_NUM_DOMAINS will cause the
build to override the KernelNumDomains setting in the config file with
the provided setting.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-12-11 08:28:23 +01:00
Gerwin Klein 1fa8d8c08f cspec: adjust for kernel build change
PR seL4/seL4#1105 moves config generation back to configure time.
This means we can revert eaf735c38f.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-10-30 10:39:46 +11:00
Rafal Kolanski 32a672412c
aarch64 cspec: add Kernel_C.thy to base CKernel image on
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2023-10-13 09:12:09 +11:00
Gerwin Klein 450234e062
aspec: mapsto syntax update for Isabelle2023
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-10-06 14:31:26 +11:00
Gerwin Klein c745d4ef57
aarch64 aspec: fix flush type in decode_vspace_invocation
decode_vspace_invocation operates on vspace flush labels, not page
flush labels.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:32 +10:00
Gerwin Klein e2355c7114
aarch64 haskell: check cap type in checkVSpaceRoot
Correctly check the type of the table the PageTableCap points to in
checkVSpaceRoot (must be a VSRootPT, not NormalPT).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:32 +10:00
Gerwin Klein d849c0bea2
aarch64 haskell: fix syscall arg error reporting
The argument numbers in the error messages for
decodeARMFrameInvocationMap are slightly off.

Same bug exists in C, see also seL4/seL4#1075.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:32 +10:00
Gerwin Klein 0e8048b49e
aarch64 aspec+ainvs: sync user_vtop check with C
The user_vtop check in decode_fr_inv_map_wf can be relaxed from >= to >
as done in Haskell and C.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:32 +10:00
Gerwin Klein 4913aa8af9
aarch64 haskell: tweak createNewCaps definition
Tweak formulation of createNewCaps for page tables to be in the expected
"addr ~elem~ map .." form. The previous definition was not wrong, but
the lemmas in Retype_R expect the set membership form.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:30 +10:00
Gerwin Klein c6281810d4
aarch64 aspec+ainvs: add valid_asid_map invariant
Refine needs slightly stricter information about asid maps, in
particular we need to know explicitly that asid 0 never maps to
a VSpace. This is the reverse of valid_vmid_table, but unfortunately
does not fully follow from valid_vmid_table, because there can
be VSpaces mapped without an assigned VMID.

We shift the test for 0 < asid from entry_for_asid to vspace_for_asid
so we can use entry_for_asid in the formulation of the invariant.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:30 +10:00
Gerwin Klein 438e27a8f1
aarch64 aspec: fix do_flush spec bug
cleanInvalidate should be using cleanInvalidateCacheRange_RAM.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:30 +10:00
Gerwin Klein 345818d38f
aarch64 aspec: cleanByVA_PoU in perform_pg_inv_map
Add missing cache machine op.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:29 +10:00
Gerwin Klein c77d6497a7
aarch64 aspec: sync with Haskell
Fix two small spec bugs where ASpec was out of sync with Haskell and C.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-09-27 14:28:29 +10:00
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