Commit Graph

2554 Commits

Author SHA1 Message Date
Gerwin Klein 0733fa582a
proofs: alternative_valid -> alternative_wp
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:51 +11:00
Gerwin Klein 549cb893de
lib+ainvs: pull up more empty_fail lemmas
- pull base-level empty_fail lemmas from AInvs into Monads.Empty_Fail
- apply consistent naming
- apply consistent [intro!, wp]
- make all non-conditional lemmas [simp]
- re-add context building to empty_fail rules, because the select_*
  rules may need context to solve their side condition

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-09 11:46:50 +11:00
Michael McInerney 924209c251 refine: remove bind_dummy_ret_val duplicates (now in Lib)
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-02-07 11:30:30 +10:30
Gerwin Klein 0ec91178fe
aarch64 ainvs: factor out vm_level bit setup
Factor out the bit0/bit1 setup for the vm_level type into its own file.
It doesn't really have anything to do with BCorres where it was before.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 10:34:18 +11:00
Gerwin Klein ed0cd5b282
lib+aarch64 ainvs: make opt_pred a definition
The projection operators should be definitions so that they are stable
under simp and case splits. This enables later projection stacks to
use abbreviations that remain stable.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:37 +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 e5036721df
lib+ainvs+aarch64 ainvs: cleanup + move lemmas into lib
- make kheap crunch for do_machine_op generic
- make None_Some_strg available generically in LevityCatch
- move word lemmas up into Word_Lib
- move wp lemmas up into lib + minor lib cleanup

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:37 +11:00
Gerwin Klein 549157a838
aarch64 ainvs: cleanup and resolve FIXMEs
- minor style/whitespace cleanup
- resolve all smaller AARCH64-local FIXMEs
- move AARCH64-local lemmas
- fix up proof fallout from move (gained some automation in the move)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +11:00
Gerwin Klein 4001debe25
lib+ainvs: clean up LevityCatch_AI
- move proof methods spec and bspec to Eisbach_Methods
- move general lemmas to Lib
- move word lemmas to Word_Lemmas_Internal
- update proof style

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +11:00
Gerwin Klein 1c2f1d84db
ainvs: remove proof method "prove"
The method is mostly unused and easily replaced by prop_tac.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:36 +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 6d31cd631c
aarch64 ainvs: clean up ArchDetSchedAux_AI
Consolidate crunches and update proof style.

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 de9fb23fb8
aarch64 ainvs: resolve FIXMEs
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:35 +11:00
Gerwin Klein 51e22f4533
aarch64 ainvs: automatically rename bit0/bit1 lemmas
This commit automatically renames bit0.*/bit1.* lemmas (depending on
the value of vm_level) to vm_level.*

The idea is that vm_level.* can now generically refer to the right
instance, so that the same proof text works without change for both an
even and odd number of page table levels.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:56:35 +11:00
Gerwin Klein 04a4b37a12
aarch64 ainvs: avoid magic number in ArchKernelInit
- define formally where 14 is coming from instead of trying to explain
  in a comment,
- also remove unused parts of the lemma where it is used.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:40 +11:00
Gerwin Klein d43aa2e296
aarch64 proofs: switch quick_and_dirty to Refine
- switch off quick_and_dirty for AInvs session
- switch on quick_and_dirty for Refine session for development

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:40 +11:00
Gerwin Klein af8a8bb749
aarch64 ainvs: AInvs sorry-freee
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:40 +11:00
Gerwin Klein 7eacca3760
aarch64 ainvs: add valid_global_tables to invariants
For the proofs in ArchAInvsPre we require knowledge that the default
user-level tables do not map any user-space addresses. In hyp mode, the
default user-level table is completely empty, because the kernel has
its own separate table. We encode that empty table in the
`valid_global_tables` predicate analogously to the RISCV64 formulation.

We explicitly leave `valid_global_arch_objs` as a `typ_at` predicate,
because the proofs expect `valid_global_arch_objs` to be liftable.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:40 +11:00
Gerwin Klein 2784c760df
aarch64 ainvs: ArchSyscall_AI sorry-free
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 23f0add6ae
aarch64 ainvs: ArchKernelInit sorry-free
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 13e9cd00c3
aarch64 ainvs: CNodeInvs sorry-free
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 b7df1b7795
aarch64 ainvs: ArchArch sorry-free
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 2ef1c4994c
aarch64 ainvs: progress in ArchArch
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 6dfc95f76d
aarch64 ainvs: progress in ArchArch
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:38 +11:00
Gerwin Klein 379ed93f21
aarch64 ainvs: initial progress on ArchArch_AI
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:37 +11:00
Gerwin Klein 04a4972c6d
aarch64 ainvs: ArchFinalise sorry-free
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:37 +11:00
Gerwin Klein 1a7609b7d1
aarch64 ainvs: unmap_page_table for NormalPT only
Ensure in valid_pti that page table operations, in particular
unmap_page_table, are only called on NormalPTs. This means we can
remove the vspace_for_asid precondition in the associated lemmas.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-06 09:50:36 +11:00
Gerwin Klein 60a1469f20 riscv+aarch64 ainvs+refine: adjust for opt_mapE change
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-02-02 17:56:55 +11:00
Michael McInerney 3c322eab1d cparser+crefine: move h_t_array_valid_array_assertion to cparser session
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-01-30 18:00:42 +10:30
Gerwin Klein e3c2e878b9
lib+proof+autocorres: consolidate when[E]/unless[E]_wp naming
wp rules for most operators such as return, get, gets are named
return_wp, get_wp, etc. Then when, whenE, unless, unlessE operators had
an additional hoare_.. prefix that this commit removes for more
consistency.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:39 +11:00
Gerwin Klein 49c93e64ee
lib: eliminate hoare_gets_post
duplicate of hoare_gets_sp

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:39 +11:00
Gerwin Klein 625c6e359d
lib+proof: eliminate hoare_ex_wp
duplicate of hoare_vcg_ex_lift

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein b4b9a00a28
lib+refine: eliminate select_singleton_is_return
Also make select_singleton [simp], because it is later declared
globally [simp] anyway.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein b1daf38dda
lib+crefine: eliminate list_case_return2
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 11:48:38 +11:00
Gerwin Klein 6bf7c92d22
lib+crefine: zipWith lemma [simp] consolidation
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:19:41 +11:00
Gerwin Klein 2d2cadb86b
lib+proof+tools: move LemmaBucket_C into CParser
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:18:11 +11:00
Gerwin Klein a9fd0142be
all: adjust theory imports for TypHeapLib change
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-25 10:13:45 +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
Gerwin Klein bba173cb99
lib+READMEs: rename Monad_WP to Monads
In preparation for a separate Monads session.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-24 11:30:05 +11:00
Gerwin Klein 2e608b5a5c
crefine+capDL: proof updates for theLeft/theRight
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:41:11 +11:00
Gerwin Klein 9c3a7faefd
lib+proofs: s/non_fail_/no_fail/
Some of the no_fail lemmas had he wrong name (non_fail instead of
no_fail).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:02:10 +11:00
Gerwin Klein 79eccd3c10
lib+spec+proofs: proof fixes for NonDetMonadLemmaBucket split
Very minor changes, but in many modules.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-19 17:01:34 +11:00
Michael McInerney 619e941631 c-parser+crefine+clib: move is_aligned_c_guard to c-parser session
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-01-12 11:48:59 +10:30
Michael McInerney 640d352148 c-parser+crefine: move h_t_array_valid_field to c-parser session
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2023-01-11 14:39:57 +10:30
Gerwin Klein 3960115459
lib+proofs+sys-init+tools: proof updates for Fun_Pred_Syntax
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2023-01-09 14:54:11 +11:00
Michael McInerney 9b33cfad36 update copyright
Signed-off-by: Michael McInerney <michael.mcinerney@proofcraft.systems>
2022-11-09 15:52:50 +11:00
Corey Lewis db6b3b839e isabelle2022 crefine: update CRefine for all architectures
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-11-09 11:45:46 +11:00
Gerwin Klein 9ef097e85f aarch64 ainvs/cleanup: prefer invariant syntax
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 05838c4855 aarch64 ainvs: progress in ArchFinalise_AI
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 46adec77fd aarch64 ainvs: ArchIpc_AI sorry-free
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 52fcfa5f06 aarch64 ainvs: ArchTcb_AI sorry-free
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein ba8f8a6be3 aarch64 ainvs: ArchVSpaceEntries_AI sorry-free
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 3f4f36e05a aarch64 ainvs: ArchEmptyFail_AI sorry-free
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 009fa075d5 aarch64 ainvs: ArchInterrupt_AI sorry-free
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Gerwin Klein 74c525ffcc aarch64 ainvs: asid_map sorries in ArchFinalise
Close some of the more hairy asid_map-related sorries in
ArchFinalise_AI.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 29a997e0fe riscv64+aarch64 ainvs: remove two unused lemmas
set_asid_pool_empty and delete_asid_empty_table_pt aren't used on
RISCV64 (despite being proved and declared [wp]). Hopefully these won't
be needed on AARCH64.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 5040547836 aarch64 ainvs: progress on ArchFinalise_AI
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 8544186298 aarch64 ainvs: ArchSchedule_AI and ArchUntyped_AI sorry-free
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 013c4442de aarch64 ainvs: ArchDetype_AI sorry-free
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski da9939a3be ainvs: add valid_obj_arch_valid_obj
On HYP platforms with projections it's sometimes useful to be able to
grab the `arch_valid_obj` formulation for specific arch types like page
tables before the simplifier breaks them apart for you.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 6b4f875e9e ainvs: LevityCatch: add ranD
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 828a410137 aarch64 ainvs: ArchRetype_AI sorry-free
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 9dfc4c9c5b ainvs: assume invs for valid_vspace_objs in locale
For AARCH64 showing that valid_vspace_objs is preserved over a retype
operation via the retype_region_proofs_invs locale, it is not sufficient
to only know valid_vspace_objs. Since this locale already assumes invs,
use invs, which implies the other requirements for AARCH64.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-09 08:26:44 +11:00
Rafal Kolanski 2909c56924 arm+arm-hyp crefine: indent pass over Fastpath_Equiv
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 536eec39e4 proof: update copyrights for monadic_rewrite improvements
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 60b3573d46 proof: improve monadic_rewrite usage based on new tactics
Deploy monadic_rewrite tactics, misc improvements.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 7c127a65cd proof: apply monadic_rewrite updates (except Fastpath_Equiv in CRefine)
Adapt to changes from previous commit, mostly renames.

Fastpath_Equiv needs more work, pending tactical improvements.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 94f21c8d09 crefine: minor improvements to IsolatedThreadAction
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski d55a65e96b proof: apply monadic_rewrite renames
renamed:
* `monadic_rewrite_refl3` -> `monadic_rewrite_pre_imp_refl`
* `monadic_rewrite_symb_exec2` -> `monadic_rewrite_symb_exec_drop`

removed:
* `monadic_rewrite_refl2`: use `monadic_rewrite_is_refl[OF ext]` instead
* `monadic_rewrite_bind2`: use `monadic_rewrite_bind_l` instead
* `monadic_rewrite_bind_alt`: use `monadic_rewrite_bind_l` instead

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 04552f487a arm+arm-hyp crefine: clear warnings from Fastpath_Equiv
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 82056c9746 proof: apply monadic_rewrite renames
Previous commit renamed the following:
* `monadic_rewrite_imp` -> `monadic_rewrite_guard_imp`
* `monadic_rewrite_weaken` -> `monadic_rewrite_weaken_flags`
* `monadic_rewrite_weaken2` -> `monadic_rewrite_weaken_flags'`

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski 10a814ed67 crefine: use modern datatype tech for tcb_state_regs
Using named constructor arguments added to the datatype package allows
removal of the old way of writing them out explicitly.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Rafal Kolanski f31f689609 drefine: remove unused monadic_rewrite proofs
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-11-02 05:05:44 +11:00
Gerwin Klein ce8646b0f3 aarch64 ainvs: close last sorries in ArchVSpace
This commit weakens some assumptions in previous ArchAcc lemmas and
strengthens some requirements we make on later decode lemmas, hopefully
in a still provable way.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein baf24f80aa aarch64 ainvs: ArchVSpace progress
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 3ec0f7dd34 aarch64 ainvs: ArchVSpace progress
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Rafal Kolanski f182e61664 aarch64 ainvs: tweak proof of asid_high_low_inj
Generalise concept of proving word equality by splitting two words at
bit n and comparing the parts.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein f684d517e1 aarch64 ainvs: ArchVSpace progress
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 773f7d52f1 aarch64 ainvs: consolidate arch do_machine_op
Clean up and consolidate further do_machine_op lemmas on AARCH64.
Includes enabling some crunches and lemmas that were blocked on
do_machine_op.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 96c934f6a5 ainvs: consolidate do_machine_op lemmas in KHeap
Clean up KHeap_AI. It turns out that almost all do_machine_op lemmas
proved here are crunchable, so move them all into on place.

This only proves lemmas originally already in KHeap_AI. It would likely
make sense to collect general do_machine_op lemmas from other places
in AInvs here as well.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 5dfa1066ef ainvs: do not ignore maskInterrupt for crunch
It was likely a mistake from the beginning to single out this machine
op for crunch ignore here.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 940a829321 aarch64 ainvs: prove find_free_vmid_invs
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 7d2af74b22 aarch64 ainvs: use vmid_for_asid as asid_map
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein b8d23e9b79 aarch64 ainvs: clear sorries up to ArchVSpace_AI
Includes some progress inside ArchVSpace_AI as well.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 6beac003cd aarch64 ainvs: introduce asid_table update locale
Introduce a locale similar to Arch_pspace_update_eq, but where also
`asid_table s` is preserved. This preserves most vspace predicates and
is much more widely applicable than the existing locale in the
hierarchy that demands all of `arch_state s` to be preserved.

Since this only makes sense for Arch functions, there is no generic
version of this locale and instantiation happens only in ArchBits_AI,
not in Invariants_AI.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein eb093957eb aarch64 ainvs: close last sorry in ArchAcc_AI
- reduce assumptions of some of the no-loop helper lemmas
- factor out common reasoning for vs_lookup_table/pt_walk stitching
- close last sorry

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 6116655954 aarch64 ainvs: set_asid_pool unmap+vmid lemmas
- includes cur_vcpu lemmas for set_asid_pool and store_pte that were
  masked by the missing vmid_inv results.

- vmid_inv lemmas for the case where an entire asid pool entry is being
  removed. In this case, the vmid entry will already have been reset.

- set_asid_pool unmap lemmas reformulated from map/set restriction to
  single entry unmap, because the vmid lemmas don't make sense for sets.
  The set version was only ever used for single entries anyway, so had
  unnecessary generality.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein cd304e704d aarch64 ainvs: make store_pte_not_ao non-wp
The rule applies to anything that has `aobjs_of` in the abbreviation
stack, e.g. including asid_pools_of and vcpus_of, and is therefore too
eager for `[wp]`.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 2be2760b64 aarch64 ainvs: abbreviation for asid construction
The pattern `(ucast high << asid_low_bits) || ucast low` occurs in
a few places in the proofs and `asid_of high low` is easier to read.

For example, it makes obvious that
`asid_low_bits_of (asid_of hi_bits lo_bits) = lo_bits`
should be a simp rule.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 03ecc6d9fc aarch64 ainvs: make vmid_for_asid real projection
- project out the parts of the state that are needed
  (asid_pools_of and asid_table) to remove need for lifting rules
- fix argument order (state first)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 8a4d17d703 aarch64 ainvs: reduce sorries in ArchAcc_AI
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 595acd2abf riscv ainvs: fix proof indent in ArchAcc_AI
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 050dc0af7d aarch64 ainvs: reduce sorries in ArchAcc_AI
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein de8ebe7219 aarch64 ainvs: reduce sorries in ArchAcc_AI
Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 06ef438713 aarch64 ainvs: reduce sorries in ArchAcc_AI
Two key lemmas are vs_lookup_slot_unique_level and store_pte_valid_objs.
The latter needs the new concept of of valid_mapping_insert to preserve
valid_pt_range (which is part of valid_obj).

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 37962b303d aarch64 ainvs: prove the no-loops property
This is a bit more involved than on RISCV64, but with treating
max_pt_level separately from the rest, most of the argument can be
recovered.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein c1718b29eb aarch64 ainvs: prove vs_lookup_non_PageTablePTE
This includes a few hopefully useful lemmas about page table type
uniqueness.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 89b746ee06 aarch64 ainvs: minor progress in ArchAcc
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 86c497a144 aarch64 ainvs: prove all easy sorries in ArchKHeap
The remaining interesting lemma (which is not proved) is
vs_lookup_non_PageTablePTE which needed two statement adjustments, one
to adjust the ptes_of update (certain that this is correct), and one to
add a new precondition valid_vspace_objs (speculative, but hopefully
enough to solve the lemma).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein 30ba342a20 aarch64 ainvs: basic storePTE/ptes_of lemmas
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein d314fc7c77 aarch64 ainvs: vspace_objs_of instead of aobjs_of
- use vspace_objs_of instead of aobjs_of where possible to reduce
  scope and make lifting rules stronger
- prove remaining lifting rules in ArchKHeap_AI

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein da6f0c2d13 aarch64 ainvs: vspace_objs_of lifting rules
- provides case split rules for vspace_objs_of lifting

- proves the provable vspace_objs_of/vspace_obj_pred lifting rules. The
  other lifting rules will need rephrasing for AARCH64 since
  vspace_objs_of does not cover all arch objects.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Gerwin Klein f2b53b6bf0 aarch64 ainvs: vspace_obs_of and vspace_obj_pred
Shows the relationship between vspace_obs_of and vspace_obj_pred.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-10-20 17:51:27 +11:00
Corey Lewis 59529d4522 infoflow: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis a52c73ad0b crefine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis c51d812de7 riscv refine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis b614d7ec9c arm-hyp refine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis e23c379720 x64 refine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 7289575cc7 arm refine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis f9295d6a97 drefine: update for changed corres split rules
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 73a52be413 proof: change more simple corres split cases
perl -0777 -pi -e "s/corres_split_nor([\w'-]*) *\[ *OF +_ +([^_][\w'-]+) +([\w'-]+)/corres_split_nor\1\[OF \2 _ \3/g" **/*.thy
perl -0777 -pi -e 's/corres_split_nor([\w]?) *\[ *OF +_ +(?!_)/corres_split_nor\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_eqr([\w]?) *\[ *OF +_ +(?!_)/corres_split_eqr\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_mapr([\w]?) *\[ *OF +_ +(?!_)/corres_split_mapr\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_noop_rhs([\w]?) *\[ *OF +_ +(?!_)/corres_split_noop_rhs\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_dc([\w]?) *\[ *OF +_ +(?!_)/corres_split_dc\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_handle([\w]?) *\[ *OF +_ +(?!_)/corres_split_handle\1\[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_catch([\w]?) *\[ *OF +_ +(?!_)/corres_split_catch\1\[OF /g' **/*.thy
perl -0777 -pi -e "s/corres_split_eqr(\w?) *\[ *OF +([^\W_][\w'-]+) +([^\W_][\w'-]*)/corres_split_eqr\1\[OF \3 \2/g" **/*.thy
perl -0777 -pi -e 's/corres_split_nor(\w?) *(.*)\)\n\s*prefer +2/corres_split_nor\1\2\)/g' **/*.thy

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 8ffdb5eb76 proof: change simple corres_splitEE cases
perl -0777 -pi -e 's/corres_splitEE *\[ *OF +_ +([^_]\w+) +(\w+)/corres_splitEE[OF \1 _ \2/g' **/*.thy
perl -0777 -pi -e 's/corres_splitEE *\[ *OF +_ +(?!_)/corres_splitEE[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_splitEE *\[ *OF +([^_]\w+) +([^_]\w+)/corres_splitEE[OF \2 \1/g' **/*.thy
perl -0777 -pi -e 's/corres_splitEE *(.*)\)\n\s*prefer +2/corres_splitEE\1\)/g' **/*.thy

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis f4e9295424 proof: change simple corres_split_deprecated cases
perl -0777 -pi -e 's/corres_split_deprecated *\[ *OF +_ +([^_].*)\)\n\s*prefer 2/corres_split[OF \1\)/g' **/*.thy
perl -0777 -pi -e 's/corres_split_deprecated *\[ *OF +_ +(?!_)/corres_split[OF /g' **/*.thy
perl -0777 -pi -e 's/corres_split_deprecated *\[ *OF +([^_]\w+) +([^_]\w+) +(.*)\)\n\s*prefer +2/corres_split[OF \2 \1 \3\)/g' **/*.thy
perl -0777 -pi -e 's/corres_split_deprecated *\[ *OF +([^_]\w+) +([^_]\w+)/corres_split[OF \2 \1/g' **/*.thy
perl -0777 -pi -e 's/corres_split_deprecated *(.*)\)\n\s*prefer +2/corres_split\1\)/g' **/*.thy

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 6d37587b0b proof: rename corres_split' to corres_underlying_split
sed -E -i "s/\bcorres_split'\b/corres_underlying_split/g" proof/**/*.thy

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 17ed8b9f25 proof: rename corres_underlying_split to corres_split_forwards
sed -E -i "s/\bcorres_underlying_split\b/corres_split_forwards'/g" proof/**/*.thy

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Corey Lewis 2cf7c367f2 arm-hyp crefine: simplify getActiveIRQ_ccorres
This rewrites the extraction function to a simpler form, which is
consistent with how the lemma is written on the other architectures.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-10-20 08:59:52 +11:00
Gerwin Klein ba033cc300 riscv haskell+proofs: fix PageTablePTE encoding
According to the RISC-V spec, PageTablePTEs must have the access,
dirty, and user bits set to 0. This means that

- there is no user attribute that can be set on PageTablePTEs
  (removed from Haskell spec)
- the encoding for PageTablePTEs in C must have 0 in these fields
  instead of 1.

See PR seL4/seL4#880 for discussion and corresponding C changes.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-07-18 10:40:17 +10:00
Ryan Barry 800f3daecd x64 ainvs+refine+crefine: update proofs
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Ryan Barry ac6cf91606 arm_hyp refine+crefine: update proofs
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Ryan Barry 7aaaabf15b riscv refine+crefine+access+infoflow: update proofs
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Ryan Barry 23b6184766 dspec+drefine+infoflow: update misc. proofs
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Ryan Barry 9bf8cf35bb refine+crefine: update refinement proofs
Co-authored-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
Signed-off-by: Ryan Barry <ryan.barry@proofcraft.systems>
2022-06-17 15:32:16 +10:00
Rafal Kolanski 02a9ecaf00 proof: remove generic monadic_rewrite lemmas
Lemmas not relying on any specifications or more local concepts will be
moved into MonadicRewrite.thy

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-09 08:56:37 +10:00
Rafal Kolanski 6c2e8fc4eb arm-hyp+aarch64: update for stage 1 translation changes
C code changed to drop stage 1 translation from constructing VM fault
messages when in a hypervisor context.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-06 10:11:40 +10: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
Rafal Kolanski fe3a4a2287 aarch64 ainvs: clean up after Machine_AI overhaul
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski 6f757d901b aarch64 ainvs: overhaul Machine_AI
Handle abstract machine ops in large crunch passes.
Clean up some proofs, standardise others, and rearrange into topical
areas.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 420937301d aarch64 ainvs: vspace_obj_pred_aobjs lifting rule
- the lifting rule now needs an additional vcpus_of assumption
- this makes the rule not applicable any more for the proof of other
  lifting rules that are for vspace objs only; these will now need
  different proofs
- add FIXME suggestion for equivalence of projection and vspace_obj_pred

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 7a8461d286 aarch64 ainvs: define vspace_objs_of projection
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski 997883e364 aarch64 ainvs: adapt hyp lemmas/consts from ARM_HYP
This is a rough pass over all the vcpu|vppi|vgic items found in ARM_HYP
abstract invariants. Broken items and issues tagged with FIXMEs,
lemmas sorried when possible.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski 3f85320012 aarch64 ainvs: hyp pass over ArchKHeap_AI
Some definitions needed to change to take VCPUs into account, breaking
some lifting lemmas that assumed vspace objects and arch objects were
the same thing. FIXMEs added.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski a38a4a6411 aarch64 ainvs: update valid_vso_at to exclude VCPUs
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski 99fb0e728e aarch64 ainvs: add hyp machine op crunches to Machine_AI
This indicates potential for using `crunches` to shorten many of the
empty_fail, no_fail and no_irq proofs for most machine ops.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 74c1d392bc aarch64 ainvs: add asid_map sorries
Add statements about vmid/asid load, store, and invalidate.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 1dd1f54f6b aarch64 ainvs: finish vspace lemma statement pass
The statements of all VSpace-related lemmas are now in as good a state
as we can predict without proving them.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein f2a2676154 aarch64 ainvs: ArchVSpace_AI statements
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein efa83df0f4 aarch64 ainvs: ArchCSpaceInvPre_AI statements
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 1edf35a287 aarch64 aspec+ainvs: make pt_walk_is_aligned true
On RISCV64, we had the nice property that pt_walk can only produce
aligned addresses. This alignment is important for further address
computation.

It turns out that the same is true on AARCH64, because the bottom 12
bits of page table addresses are not stored in PTEs. PagePTEs can only
point to normal page tables, so there is not variation in the size of
the alignment.

This commit uses a similar encoding to RISCV64 to achieve this pt_walk
property without using an additional invariant.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein d4107e1c7c aarch64 ainvs: ArchAcc_AI statements
some follow-on effects from the removal of dmo_read_stval_inv which had
become too generic.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein e415720f5b aarch64 ainvs: lemma statements for ArchKHeap_AI
With updated statements some of the old proofs work again.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 47b90f0d64 aarch64 ainvs: new definitions for ArchADT_AI
adjusting to arm_us_global_vspace and ptes by levels.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein c6c22e90c5 aarch64 ainvs: use projections for cur_vcpu
This makes a few lifting rules much simpler and eliminates the need for
lifting completely in some circumstances.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein a5590d7f29 aarch64 ainvs: quick_and_dirty on for development
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 98bb90e0c3 Makefiles: remove unused report-regression target
This target was used in the regression test setup before this repo
switched to `run_tests` and has been unused for some time.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski 22b944f4cb aarch64 ainvs: bare minimum triage and sorrying
Starting point for AArch64 abstract invariant proofs.

In most cases, commented out or sorried what doesn't work. In some
cases, had to tweak definitions to get through. Marked all
problem/failure areas with FIXME AARCH64.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 42919b2543 aarch64 ainvs: adjust copyright order
Order should be most recent first.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Rafal Kolanski ebe0359868 aarch64 ainvs: copy missing files from RISCV64
No modifications made. Use this commit to refer to what initial sorrying
run modified from standard.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 30f50d5506 aarch64 aspec+ainvs: declare level_type a coercion
This means Isabelle will automatically insert `level_type` when it
finds a term of type `vm_level` but expects one of type `pt_type`.
This only works when the context is unambiguous, but it does make quite
a few terms shorter.

This is input-only, `level_type` will still show up in output.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 02a33f5636 aarch64 ainvs: type change of ptTranslationBits
All instances of "bool" for page table types should now be eliminated.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein e28bf2d681 aarch64 aspec+ainvs: introduce pt types
Replaces bool with a dedicated type for page table types. This should
generalise nicely to more different levels and removes the slightly
confusing occurrence of bool.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 6c229d7b0d aarch64 ainvs: use machine_word for table indices
This replaces 'a word for indices with machine_word. Since we can't use
a specific word length for a generic table index (because different
tables can have different index types), we don't win much by using 'a
word, but we do lose something: we must instantiate 'a when we use the
term, which means we need to decide at that point which type of table
we are talking about. This forces early case distinctions in proofs.

Using machine_word allows us to delay committing to a particular table
type and instead write a generic condition on the width of the index.

We are using machine_word instead of nat or a different specific word
length, because the index into the table is a slice of either an
obj_ref (in ptes_of) or a vref (when we do page table walks), both of
which are compatible with machine_word.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Gerwin Klein 8e92e1f702 aarch64 ainvs: adjustments for separate pte levels
With separate pte levels the proofs become simpler and shorter, but
some of the statements longer.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-06-03 09:36:43 +10:00
Corey Lewis 1a5ec996d7 proof: change crunch no_irq to prefix naming
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-31 11:34:29 +10:00
Corey Lewis ff975b47df lib+proof: change crunch no_fail to prefix naming
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-31 11:34:29 +10:00
Corey Lewis 66eda2a4d2 lib: add a crunch option for naming schemes
Some properties that crunch can be used for have different legacy naming
schemes. This commit makes it possible for different instances of crunch
to be configured for either prefix or suffix naming.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-31 11:34:29 +10:00
Corey Lewis 2baed2455c riscv ainvs: cleanup separate attribute declaration
It is possible to do this with one line now that crunch does not produce
duplicate attribute warnings.

Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-30 21:57:57 +10:00
Corey Lewis 4674b5ce1d squash: update other crunch instances
Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
2022-05-27 15:43:37 +10:00
Rafal Kolanski 9d404be331 crefine: split fastpath, rearrange Refine-based theory imports
Several parts of CRefine did not or should not depend on anything
C-related, but the import hierarchy (and theory content) did not reflect
this. Namely:
* Move_C and ArchMove_C were intended to hold items that could be moved
  to Refine yet used `kernel_m` locale and imported the C spec.
* IsolatedThreadAction indicates how to rearrange statements in the
  design spec and has nothing to do with the C spec or framework.
* Fastpath_C contained the design spec of the fastpath, the design spec
  rewrite proofs, and the C refinement. Having to rebuild nearly all of
  CRefine to work on rewrite proofs wasted time.

In the new import hierarchy:
* Move_C imports only Refine; ArchMove_C builds on Move_C
* IsolatedThreadAction imports only ArchMove_C
* The fastpath proofs are split into the spec definition (Fastpath_Defs)
  and rewrite proofs (Fastpath_Equiv), which don't depend on anything
  C-related, with their C refinement remaining in Fastpath_C.

While it is possible to separate out the fastpath definitions and rewire
proofs into a separate image or even move them to Refine, development
experience indicates keeping them alongside their C refinement remains
more convenient for the proof engineer involved.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-13 20:02:57 +10:00
Corey Lewis d7867393f0 crefine: remove duplicate lemmas from CLevityCatch
Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-05-11 10:54:33 +10:00
Corey Lewis 6f13828560 crefine: remove duplicate lemma
The lemma map_to_ko_atI2 was exactly the same as map_to_ko_atI.

Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-05-10 08:01:10 +10:00
Gerwin Klein 81857be49e aarch64 ainvs: prefer projections where possible
Use projections also for VCPU side conditions.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein ece07e6991 aarch64 ainvs: consolidate bit0/bit1 lemmas
Put all lemmas for vm_level from the bit1/bit0 classes into one place
so we can later assign these automatically.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein db70e3ea75 aarch64 aspec+ainvs: symbolic vs_index_len
Making vs_index_len a sybmolic value instead of a plain number means we
have to unfold config_ARM_PA_SIZE_BITS_40 less often (instead, we need
to consider both cases, which forces us to stay generic).

This also makes sure the type vs_index_len is always distinct from
pt_index_len (even if the sizes are the same), which was only
guaranteed in one of the two configurations before.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein a997a65464 aarch64: generic proof for vs_root_pt_idx_distinct
The previous proof inadvertently relied on the fact that
config_ARM_PA_SIZE_BITS_40 is not configured and solved the lemma
trivially instead of really proving that case.

This is only relevant for the config_ARM_PA_SIZE_BITS_40 configuration,
which is not the current verification target, but it is nicer to stay
generic in config_ARM_PA_SIZE_BITS_40 as far as we can.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 1a3cac0a5d aarch64 ainvs: close sorries in ArchInvariants_AI
This means that the invariants are strong enough to support all of the
basic properties of page table walks and vspace address arithmetic.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein d7b2098095 aarch64 ainvs: introduce invalid_mapping_slots
In some AArch64 configurations, some slots in the top-level table are
not accessible, because the IPA space size is smaller than the number
of bits the page tables can translate. invalid_mapping_slots indicates
which slots have to remain set to InvalidPTE in those tables.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Michael McInerney b84b6c3abe aarch64 ainvs: reduce sorries in ArchInvariants_AI
Signed-off-by: Michael McInerney <m.mcinerney@unsw.edu.au>
2022-05-05 09:17:25 +10:00
Gerwin Klein 502c143f05 aarch64 ainvs: ArchInvariant_AI proof progress
- update lemma statements to include pspace_distinct where needed,
  and adjust for multiple PT sizes.

- update most proofs accordingly, leave the rest sorried.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 1e0c99e774 aarch64 ainvs: strengthen level invariants
- introduce max_page_level to express that PagePTEs can only occur
  on levels 0-2 (regardless of PA/IPA space size)
- PageTablePTEs must always point to normal tables (can't point back
  to the top)
- PageTables at max_pt_level must be VSRootPTs

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 3f00c71a77 aarch64 ainvs: relationship between ptes_of and pts_of
This is a bit more complex than before. The general approach is to do
lemmas per level first, then combine them in the map union of pte_of.

For ptes_of_Some, with pspace_distinct, we get the expected two cases.
Without pspace_distinct we need in the second case a condition that the
first case doesn't apply (they are only mutually exclusive when
pspace_distinct holds).

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 9ac8e43b7e aarch64 ainvs: prove sync for level_pte_of/pt_of
Confirms that the two concepts line up as intended.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein f26a37cef7 aarch64 ainvs: resolve AInvs formulation FIXMEs
- void type is not used in AArch64
- remove duplication of level_of_vmsize
- state equivalence lemma
- unified formulation of valid_vspace_obj turned out to be usable so far
- confirmed that no further vmid properties are needed (in addition to
  inverse)
- removed alternative version of arch_valid_obj (but remains in history)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 00a9f40c51 aarch64 ainvs: adapt to Isabelle2021-1
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +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 9a0c45a7ea aarch64 ainvs: update lemmas for cur_vcpu and vmid
These are required as interface for Invariants_AI (and generally useful)

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein f49386bb09 aarch64 ainvs: sorry ArchInvariants_AI
At this stage ArchInvariants_AI should process cleanly, but is still
missing some interface lemmas for Invariants_AI.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski 14160ded02 aarch64 ainvs: VCPU-related invariants
Referenced from ARM_HYP and updated for AARCH64, and some tuning.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 291133761f aarch64 ainvs: first draft of AArch64 invariants
This is a first draft of what we think needs to change in the
invariants to model AArch64. VCPU-related definitions are still
missing, and further tweaks are likely.

Co-authored-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski 4ba24d0445 ainvs: remove unused requalify_consts
`wellformed_vspace_obj` is not used outside Arch locale.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 229d56cb05 aarch64 ainvs: set up ArchInvariants dependencies
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski a23e792737 aarch64 ainvs: update ArchBCorres_AI
Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Rafal Kolanski ceb63634da aarch64 ainvs: init up to ArchInvariants_AI
Copied from RISCV64 with minimal search/replace, added FIXMEs.
Should be enough for formulating architecture-specific invariants.

Signed-off-by: Rafal Kolanski <rafal.kolanski@proofcraft.systems>
2022-05-05 09:17:25 +10:00
Gerwin Klein 6418bda962 aarch64/riscv/x64: remove findVSpaceForASIDAssert
findVSpaceForASIDAssert is needed for modeling the hardware ASID lookup
on ARM. None of AARCH64, RISCV64, X64 use that mechanism and the
function is unused. There are some proof about it, but those are unused
as well. This commit removes all of these.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-20 09:16:19 +10:00
Gerwin Klein 954b42cdd9 refine: speed up CSpace1_R+CSpace_R proofs
Three main thrusts:
  - speed up the `updateMDB_the_lot` chain by using more targeted
    proof methods
  - drastically reduce goal size by removing unused assumptions when
    that becomes possible (this is the largest overall speed win)
  - use `subgoal` to unblock interactive proof progress

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-19 15:27:44 +10:00
Corey Lewis 0aaeb868ce ainvs: remove unused preconditions
Signed-off-by: Corey Lewis <corey.lewis@unsw.edu.au>
2022-04-13 13:44:45 +10:00
Gerwin Klein 3a0667c1f8 proof: add missing Makefile dependencies
Both AInvs and the refinement chain need the generated files necessary
for ASpec and ExecSpec. We could depend on ASpec directly, but that
would mess with Isabelle being able to schedule sessions as it wants
them.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-04-08 10:59:21 +10:00
Gerwin Klein 7535796778 crefine: remove useless comments
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein c953ab0396 word_lib/proofs: bundle word simp set changes
Add a bundle for global word simp set changes -- unfortunately we
can't actually do this globally, because they are mostly simp rule
removals which will be overwritten by theory merges. So this new
l4v_word_lib bundle will have to be activated/unbundled multiple times.

Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein b29a3433ef isabelle2021-1: remove no_take_bit
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 6650ba5ce7 isabelle2021-1 x64: CRefine
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein bbdc1e53db isabelle2021-1 riscv: InfoFlowC
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 74536cdef1 isabelle2021-1 riscv: CRefine
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein bf8431d765 isabelle2021-1 riscv: Infoflow
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 6c938f2a35 isabelle2021-1 riscv: Access
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein b864ae0159 isabelle2021-1 riscv: Refine
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein 5c03381bfb isabelle2021-1 riscv: AInvs
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein cbf8ded43b isabelle2021-1 x64: Refine
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00
Gerwin Klein b6cd2e0786 isabelle2021-1 x64: AInvs
Signed-off-by: Gerwin Klein <gerwin.klein@proofcraft.systems>
2022-03-29 08:38:25 +11:00