Commit Graph

186 Commits

Author SHA1 Message Date
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
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 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 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
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
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 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 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
Gerwin Klein 88dd8d8f7a
aarch64 haskell+machine: sync pptrTop and pptrBase with C
Sync both values with what the C code does. The corresponding comment
in C is wrong and would not produce a safe value for pptrTop (the
comment says 2^48 - 2^30), but the actual definition in C (the
equivalent of 2^40 - 2^30) is safe.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:38 +11:00
Gerwin Klein 6dcbd4f09f
spec+proofs+autocorres: theory import fixes
Adjust theory imports for new sessions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:06 +11:00
Rafal Kolanski f04a6319cc arm-hyp: rename addressTranslateS1CPR
renamed to: addressTranslateS1

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:11:40 +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 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 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
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 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
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 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 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 0f633ce387 isabelle2021-1 lib: update Lib session, retire wpx
The benefit of the wpx method is not worth the maintenance effort.
There are still a few instances of wpx left in AInvs, which will have
to be fixed later.

We are keeping the wps method from the same file (WPEx.thy), because
that is used more widely and does not break with Isabelle2021-1

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Corey Lewis 6d0c9fb78c arm+arm-hyp machine: match platform constants to C
This change eases any future platform ports by better matching the C
code that it models and by making it so that there is one less constant
that needs modification.

Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-02-09 14:46:21 +11:00
Gerwin Klein 24c0c5c390 spec+proof: use generated config constants
This includes replacing previous ASpec names for such constants with
the names used in Haskell/ExecSpec to avoid duplication. This also
makes some of the proofs slightly more generic.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-23 14:54:13 +11:00
Rafal Kolanski ec79dc3330 aspec+design+haskell: extract numDomains into Kernel_Config
Introduce Kernel_Config theory for storage of non-architecture-specific
seL4 configuration variables that are shared by the abstract and design
specs.

Remove `num_domains`, in lieu of `numDomains` that is now defined only
in `Kernel_Config.thy`. The definition is hidden and must be referred to
as Kernel_Config.numDomains_def when avoiding unfolding is not possible.

Include required properties of `numDomains` as lemmas.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-12-22 23:50:22 +11:00
Gerwin Klein 614e24ee10 riscv machine: use address size consistently
In the rest of the proofs we use machine_word to refer to addresses.
This commit brings the machine definitions in line with that.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-12-03 17:06:37 +11:00
Rafal Kolanski 7e3b3cab9a isabelle-2021: arm-hyp/x64/riscv machine+aspec update
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2021-09-30 16:53:17 +10:00
Gerwin Klein f2fc2345fe isabelle-2021: update Lib
This includes the removal of the theory Extend_Locale, which was an
(unused) experiment.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2021-09-30 16:53:17 +10:00
Gerwin Klein 6fd6d6bd48 arm/arm-hyp: proof updates for Arm cache fix
This commit updates the proofs for seL4/seL4#485, which fixes
the security and correctness bug seL4/seL4#481. The bug was that
caches are not sufficiently flushed in retype for frames that can
be mapped uncached later.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2021-08-16 16:47:10 +10:00
Matthew Brecknell fd01872121 always use `addrFromKPPtr` for kernel addresses
This verifies a C kernel patch (seL4/seL4#409) which consolidates
translation between virtual and physical addresses, and makes it
consistent across architectures. In particular, we always use
`addrFromKPPtr`, even on architectures that don't use a distinct region
to map the kernel ELF. This will facilitate future improvements which
move the ELF mapping into a distinct virtual address region.

Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-06-25 16:31:22 +10:00
Matthew Brecknell 2aadbf9589 trivial: restyle `spec/machine/ARM*/Platform.thy`
Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2021-06-25 16:31:22 +10:00
Gerwin Klein 3cc7a1c6b7 arm-hyp: proof updates for seL4 c381c7e14c
seL4 commit c381c7e14c changes cache flushing behaviour for the
verified ARM_HYP configuration. This commit adjusts accordingly.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-12-09 19:46:02 +11:00
Rafal Kolanski a422e817a4 machine+design: update for platform constant changes
Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-11-16 16:52:40 +11:00
Rafal Kolanski 9ed45e17bd arm+arm-hyp: kernelBase and physMappingOffset renames
This brings the naming convention closer to the other architectures,
closer to the Haskell, and closer to the constant renames that happened
in C. It is, however, quite an invasive change.

kernelBase_addr -> pptrBase
kernelBase -> pptrBase
physMappingOffset -> ptrBaseOffset

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-11-16 16:52:40 +11:00
Gerwin Klein a45adef66a all: remove theory import path references
In Isabelle2020, when isabelle jedit is started without a session
context, e.g. `isabelle jedit -l ASpec`, theory imports with path
references cause the isabelle process to hang.

Since sessions now declare directories, Isabelle can find those files
without path reference and we therefore remove all such path references
from import statements. With this, `jedit` and `build` should work with
and without explicit session context as before.

Signed-off-by: Gerwin Klein <gerwin.klein@data61.csiro.au>
2020-11-02 10:16:17 +10:00
Matthew Brecknell b77f83c57b riscv: rename sbadaddr -> stval
Signed-off-by: Matthew Brecknell <Matthew.Brecknell@data61.csiro.au>
2020-08-26 15:24:06 +10:00
Rafal Kolanski c160f4053d riscv machine: add alternative definition for pptrUserTop
(presents numeral directly without further unfolding)

Signed-off-by: Rafal Kolanski <rafal.kolanski@data61.csiro.au>
2020-06-08 20:41:10 +08:00
Victor Phan 461a798412 aspec: arch split on invokeIRQHandler
The RISCV implementation of invokeIRQHandler calls plic_complete_claim
instead of maskInterrupt. plicCompleteClaim is added as a machine op
and invokeIRQHandler has been arch split for the ACKIrq case.

Signed-off-by: Victor Phan <Victor.Phan@data61.csiro.au>
2020-06-08 20:41:10 +08:00
Victor Phan 190d3b402a riscv spec/ainvs: update IRQs to target hifive platform
- Increase IRQ word size from 3 to 6 to match IRQ_CNODE_SLOT_BITS in
  sel4 config.
- Bump maxIRQ up to 54.
- Fix broken inequality proof by changing constant that depended on IRQ
  word size.
2020-03-27 15:50:46 +11:00
Gerwin Klein c68915b92b license: provide documentation under CC-BY-SA-4.0
Datat61 provides all docs under CC-BY-SA-4.0.
2020-03-16 14:19:15 +08:00
Gerwin Klein a424d55e3e licenses: convert license tags to SPDX 2020-03-13 14:38:24 +08:00
Gerwin Klein 8d12d8e4be licenses: tag .md and document file 2020-03-02 18:52:15 +08:00
Rafal Kolanski f9ea44ef89 arm-hyp: update spec+proofs for multi-VM support
Highlights:
- new reserved IRQ and associated handler: VPPIEvent
- VPPI events are virtual interrupts we can forward to VMs; currently there is
  only one event: virtual timer interrupt
- VGICMaintenance and VPPIEvent can both receive late interrupts from hardware,
  which are now discarded instead of being delivered to current thread
- given only one possible VPPI event, simplifier tends to mop up more than it
  should, making some proofs fragile w.r.t. adding a new VPPI event
- the order of some lemmas/specs needed shuffling, as now VCPU code needs some
  interrupt code, which uses VCPU code
2020-02-19 10:52:07 +11:00
Victor Phan 1db6ae7cf0 riscv: add kdev_base/kdevBase to handle RISCVVSpaceDeviceWindow and update proofs
- Add HiFive.hs to replace Spike.hs, it's the same except for kdevBase
  addition.
- Originally called KDEV_PPTR in the C Code, to be changed to KDEV_BASE
  across all architectures.
- Add RISCVVSpaceDeviceWindow case for valid_uses_2 definition.
2019-11-13 16:27:30 +11:00
Victor Phan 79513ae604 riscv: update to HiFive platform from Spike
- Increase maxIRQ to 53
- Change keywords to build HiFive instead of Spike
2019-11-13 16:26:55 +11:00
Victor Phan 55408a48af riscv aspec: implement IRQ check, decode and invoke control functions
These functions were originally doing throwError IllegalOperation or
returnOk (). Now they have been reimplemented to match the CSpec.

In arch_check_irq, an error is thrown if IRQ is greater than maxIRQ or
is equal to irqInvalid. The error that gets returned to the user however
is a RangeError from 1 to maxIRQ.
2019-11-12 18:28:40 +11:00