Skip to content

Prove decodeSchedControl_configureFlags_ccorres and decodeInvocation_ccorres #902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: rt
Choose a base branch
from

Conversation

michaelmcinerney
Copy link
Contributor

@michaelmcinerney michaelmcinerney commented Jun 19, 2025

Test with seL4/seL4#1472

Signed-off-by: Michael McInerney <[email protected]>
The definition of decode_sched_control_configure_flags is updated
to align with the C. Additionally, TIME_ARG_SIZE/timeArgSize is
made arch dependent, and its value is corrected for RISCV64.

Signed-off-by: Michael McInerney <[email protected]>
@michaelmcinerney michaelmcinerney self-assigned this Jun 19, 2025
@michaelmcinerney michaelmcinerney added the MCS related to `rt` branch and mixed-criticality systems label Jun 19, 2025
@@ -25,6 +25,7 @@ arch_requalify_facts (A)
reply_bits_def
parse_time_arg_def
words_from_time_def
TIME_ARG_SIZE_def
Copy link
Member

Choose a reason for hiding this comment

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

Is this a good idea, given we want to do arch-split of MCS in the future? I guess it's consistent with the other ones, but when doing arch-split I'd rather keep the definition in Arch and then break it with RISCV64.TIME_ARG_SIZE_def in the places it's needed (and with a (* FIXME arch-split *) at the places where it's egregious.

I guess given how the rest are already leaking, now might not be the time, but the direction this goes in will cause friction later in a way that's annoying to detect. You'd have to notice that arch stuff is being leaked through the Arch interface after being unable to reconcile proofs on two arches, then go back to this point, investigate what this is, remove the requalify and do more rounds.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, if we can we should not export the _def. Ideally we'd only really need it in generic theories in CRefine, and only some conditions exported in the rest. Not sure if that ideal case is easily achievable, but Raf's suggestion of using the fully qualified name with a FIXME should at least help us to find them later.


lemma refillAbsoluteMax_size_helper:
"\<lbrakk>valid_cap' cap s; isSchedContextCap cap\<rbrakk>
\<Longrightarrow> MIN_REFILLS \<le> refillAbsoluteMax cap \<and> refillAbsoluteMax cap < 2 ^ LENGTH(64)"
Copy link
Member

Choose a reason for hiding this comment

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

word_size_len?

Copy link
Member

Choose a reason for hiding this comment

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

yes, please

\<and> (\<forall>v \<in> set extraCaps. s \<turnstile>' fst v)
\<and> (\<forall>v \<in> set extraCaps. \<forall>y \<in> zobj_refs' (fst v). ex_nonz_cap_to' y s)
\<and> sysargs_rel args buffer s)
\<and> isSchedControlCap cp)
Copy link
Member

Choose a reason for hiding this comment

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

indent looks off (on github at least)

(Call decodeSchedControl_ConfigureFlags_'proc)"
apply (intro ccorres_gen_asm[simplified pred_conj_def])
supply Collect_const[simp del] if_cong[cong] option.case_cong[cong]
sched_context_C_size[simp del] refill_C_size[simp del]
Copy link
Member

Choose a reason for hiding this comment

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

how come you need to hide the two _sizes?

apply (clarsimp simp: maxPeriodUs_def word_less_nat_alt)
apply (force intro: mult_le_mono3[where a="5 * unat MAX_PERIOD_US"])
apply (clarsimp simp: excaps_map_def neq_Nil_conv cte_wp_at_ctes_of dest!: interpret_excaps_eq)
done
Copy link
Member

Choose a reason for hiding this comment

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

usual comment: this proof is very hard to review without any guiding comments and not seeing the intermittent proof state myself


lemma ct_in_state'_rewrite:
"ct_in_state' st s = st_tcb_at' st (ksCurThread s) s"
by (clarsimp simp: ct_in_state'_def cur_tcb'_def)
Copy link
Member

Choose a reason for hiding this comment

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

do we want to move such things to SR_lemmas? @lsf37

Copy link
Member

Choose a reason for hiding this comment

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

In fact, isn't this just ct_in_state'_def?

In Invariants_H:

 "ct_in_state' test \<equiv> \<lambda>s. st_tcb_at' test (ksCurThread s) s"

ct_in_state'_cur_tcb' should go into Invariants_H I think.

apply (simp+)[3]
apply vcg
apply (rule ccorres_Cond_rhs)
apply (simp add: if_to_top_of_bind)
Copy link
Member

Choose a reason for hiding this comment

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

seeing a lot of if_to_top_of_bind ... are there multiple ifs in here, or is something dodgy with automation?

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 a pattern in some of the decode proofs. I don't remember exactly where anymore (maybe here), but I remember doing the same for a few of these, mostly adjusting existing ones, to avoid blowup of if cases.

Copy link
Member

@Xaphiosis Xaphiosis left a comment

Choose a reason for hiding this comment

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

Good progress. Minor comments on content.

Have an issue with the commit "rt spec+crefine: prove decodeSchedControl_ConfigureFlags_ccorres": it's doing too much. Doing a multi-arch restructure like that and making something arch-specific should be in its own commit. This will be particularly important when dealing with arch-split in future.

The decode_sched_control_configure_flags update can indeed go in with the proof commit.

Comment on lines +333 to +334
definition TIME_ARG_SIZE :: nat where
"TIME_ARG_SIZE \<equiv> 2" (* sizeof(ticks_t) / sizeof(word_t) *)
Copy link
Member

Choose a reason for hiding this comment

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

That comment is exciting, because it would actually make that definition generic. If you define it as what the comment says, only the C version of this will need to be arch specific. Not sure it does that much since words_from_time still will need to be arch specific, but you could add a comment with FIXME arch-split that this could be a generic definition so we remember when we get there.

Copy link
Member

@lsf37 lsf37 left a comment

Choose a reason for hiding this comment

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

Nice. Only some arch split and lemma moving comments, content is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MCS related to `rt` branch and mixed-criticality systems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants