Skip to content

Conversation

@ryybrr
Copy link
Contributor

@ryybrr ryybrr commented Dec 6, 2025

Partial information flow proofs for AArch64. Please see c75ee1a when reviewing the bulk of the changes as this provides the most minimal diff.

  • Removed various instances of pspace_aligned, valid_vspace_objs, and
    valid_arch_state. This mirrors previous cleanup efforts for access control (see: a759ea1).
  • Strengthened domain_sep_inv, allowing proofs to relate getActiveIRQ instances with different flags.
  • Ported the RISCV64 InfoFlow proofs to AARCH64. The majority of breakages have been addressed, with outstanding proof obligations deferred using the sorry command. Additional context is provided by FIXME AARCH64 IF comments in the theory files.

Remove various instances of pspace_aligned, valid_vspace_objs, and
valid_arch_state

Signed-off-by: Ryan Barry <[email protected]>
Assert that non-kernel IRQs are non-timer IRQs

Signed-off-by: Ryan Barry <[email protected]>
Use the RISCV64 InfoFlow proofs as a basis for AARCH64. Proofs have been
copied verbatim modulo renaming the architecture.

Signed-off-by: Ryan Barry <[email protected]>
Initial sorry run for AARCH64 InfoFlow proofs

Signed-off-by: Ryan Barry <[email protected]>

EXCLUDE["ARM"]=[]
EXCLUDE["ARM"]=[
"InfoFlow" # for development only
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. You're saying "build InfoFlow with sorries" in ROOT in this commit, but you're disabling InfoFlow testing for all arches that had it? Wouldn't we want to still test those arches, but have AARCH64 run through with sorries?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there are changes to the generic files that are temporarily breaking the infoflow proofs on ARM/RISCV. @ryybrr is that the case? If not, we should indeed not remove them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, have made changes to the generic files without updating ARM/RISCV. I was planning to leave them for now; since this PR also includes partial proofs, the interface may shift further. If you'd prefer, I could see if it's a quick fix?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth checking out, but not high priority. We're not expecting this to be a very long-lived branch.

apply fastforce
apply fastforce
apply fastforce
apply fastforce
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proof indentation

lemma thread_set_tcb_arch_update_silc_inv[wp]:
"\<lbrace>silc_inv aag st\<rbrace>
thread_set (tcb_arch_update blah) t
\<lbrace>\<lambda>_. silc_inv aag st\<rbrace>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trivial: can use thread_set (tcb_arch_update blah) t ⦃silc_inv aag st⦄ short syntax for same pre/post and no rv

done

lemma thread_set_context_state_hyp_refs_of[CNode_AC_assms]:
"thread_set (tcb_arch_update (arch_tcb_context_set ctxt)) t \<lbrace>\<lambda>s. P (state_hyp_refs_of s)\<rbrace>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of thing feels like it could be moved to AInvs during cleanup, possible FIXME move?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should be able to cut it altogether. CNode_AC_assms appearing here makes me think it's an unused remnant from WIP proofs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely. I think normally we don't unfold it, i.e.

lemma arch_thread_set_is_thread_set:
  "arch_thread_set f t = thread_set (tcb_arch_update f) t"

but then we have this:

lemma arch_thread_set_sym_refs_hyp':
  "⟦⋀tcb. hyp_refs_of (TCB tcb) = hyp_refs_of (TCB (tcb_arch_update f tcb))⟧
   ⟹ arch_thread_set f t ⦃λs. P (state_hyp_refs_of s)⦄

which can't be interfaced directly. There's an instantiated version for FPU state, but not one for state_hyp_refs_of. There's also an ominous comment a bit above it in ArchTcbAcc_AI:

― ‹FIXME: Shouldn't state_hyp_refs_of be generic? If it was, then this and
          arch_thread_set_sym_refs_hyp' could be generic as well›

so that might be worth fixing up.

apply (wps thread_set_state_vrefs thread_set_context_state_hyp_refs_of)
apply (rule hoare_lift_Pf2[where f="caps_of_state"])
apply (rule hoare_lift_Pf2[where f="thread_st_auth"])
apply (rule hoare_lift_Pf2[where f="thread_bound_ntfns"])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no chance for wps for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll review, but I recall there being a reason why it didn't work.

"irq_at pos masks \<equiv> let i = irq_oracle pos in (if masks i then None else Some i)"

lemma dmo_getActiveIRQ_globals_equiv[CNode_IF_assms]:
"\<lbrace>globals_equiv st\<rbrace> do_machine_op (getActiveIRQ in_kernel) \<lbrace>\<lambda>_. globals_equiv st\<rbrace>"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can use short form

lemma arch_thread_get_reads_respects[wp]:
"reads_respects aag l (K (aag_can_read_or_affect aag l t)) (arch_thread_get f t)"
unfolding arch_thread_get_def
apply (wpsimp)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parentheses, can use two line by proof

apply (rename_tac n)
apply (case_tac n; clarsimp)
apply (clarsimp simp: pt_bits_left_def pageBits_def ptTranslationBits_def max_pt_level_def asid_pool_level_def split: if_splits)
apply (clarsimp simp: pt_bits_left_def pageBits_def ptTranslationBits_def max_pt_level_def asid_pool_level_def pt_bits_left_bound_def split: if_splits)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AARCH64 we have level_defs and bit_simps which should greatly reduce the amount of things you need to mention; you can find them by doing:

find_names asid_pool_level_def
find_names ptTranslationBits_def

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related, but these lemmas tagged with FIXME AARCH64 IF: move were copied from other architectures as I couldn't find equivalent rules. Do you know if something similar exists for AARCH64 already?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RISCV64 has these in ArchInvariants_AI.thy but I'm not seeing anything in AARCH64 (if you mean "is there something like pt_bits_left_le_canonical already in AARCH64)

apply (clarsimp simp: pt_lookup_slot_def)
apply (rule_tac pt_lookup_slot_from_level_is_subject)
apply fastforce+
apply (rule requiv_get_pt_entry_eq; fastforce)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

potentially can fold into previous with intro!: requiv_get_pt_entry_eq, no?

\<lbrace>P\<rbrace>"
apply (simp add: do_machine_op_def getActiveIRQ_def non_kernel_IRQs_def)
apply (wp modify_wp | wpc)+
apply clarsimp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wpsimp usually supplants wpc and clarsimp

for silc_inv[FinalCaps_assms, wp]: "silc_inv aag st"
(wp: crunch_wps)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra newline?

\<lbrace>\<lambda>_. globals_equiv s\<rbrace>"
unfolding set_cap_def
apply (simp only: split_def)
apply (wp set_object_globals_equiv hoare_vcg_all_lift get_object_wp | wpc | simp)+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wpsimp possible here?

| InvokePage oper \<Rightarrow> authorised_for_globals_page_inv oper
| _ \<Rightarrow> \<top>"

(*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag with FIXME?

notes reads_respects_f_inv' = reads_respects_f_inv[where st=st]
notes whenE_wps[wp_split del]
shows reads_respects_f_check_vspace_root[wp]:
"reads_respects_f aag l \<top> (check_vspace_root cap arg)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hang on, can't the name move from the shows to the lemma? this is very unusual format

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, unless we have multiple parts to the shows (separated with and), the name should be at lemma so it remains searchable.

apply (clarsimp simp: valid_arch_cap_def wellformed_mapdata_def)
done

lemma helper:
Copy link
Member

@Xaphiosis Xaphiosis Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

helper is a poor name, usually these are named after the lemma(s) they help with (e.g. blah_update_helper)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the file comes under a previous FIXME AARCH64 IF: proof cleanup comment, so ideally this lemma would be removed altogether. I wanted to brute force a proof but didn't have the time to perform the proper cleanup.

@Xaphiosis
Copy link
Member

Proof-wise, the quality is very good, thank you. I found some nitpicks while looking around to figure out what's going on (as I'm a rather behind on the Access/InfoFlow comprehension).

My main concern for this one is for the comprehension/longer-term maintenance aspect. Commits:

  • relax assumptions : were these unnecessary assumptions? what's the reason for their removal? might want to say that in the commit message, even briefly
  • access: strengthen domain_sep_inv: again, I feel like there was discussion about this. The commit only says what the commit contains, but is this a conclusion of some deeper discussion?

None of the commits say anything about what's happened, what's majorly different/difficult for AARCH64 (e.g. the kernel interrupt situation). I feel like we'd want more of the "why" in the historical record. I looked through the commits and didn't see any comments talking about any of this stuff either (indeed, not many comments at all aside from the FIXMEs).

Now, it may be the case that the interrupt situation was already handled by Access and I missed it somehow, or the problem is brushed under the sorries at the moment (fine for initial setup), but I feel like I would've come across some trace of documentation in this one.

@lsf37 lsf37 added the Aarch64 AArch64-specific proofs, specs, etc label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Aarch64 AArch64-specific proofs, specs, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants