Skip to content
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

verification for deferred cache flush in untyped reset #811

Merged
merged 4 commits into from
Oct 24, 2024

Conversation

lsf37
Copy link
Member

@lsf37 lsf37 commented Aug 16, 2024

Verification update for PR seL4/seL4#1289 where we defer the cache flush from untyped reset to the actual retype operation, which means that only flushes that are actually necessary will be performed.

This reduces the time for an untyped reset from 25 sec to 1.5 sec on the tx2 board with 8GB of memory. Smaller, but still significant benefits for boards with less memory.

This was a lot more fiddly than I thought and touches some ugly old proofs. I've tried to streamline them at least a little bit and make them more consistent, but they have not become much prettier.

Test with: seL4/seL4#1289

@lsf37 lsf37 force-pushed the ut-reset-caching branch from b26b52f to f5bc7ac Compare August 16, 2024 08:01
@lsf37 lsf37 requested review from corlewis and Xaphiosis August 16, 2024 08:01
@lsf37 lsf37 self-assigned this Aug 16, 2024
@lsf37 lsf37 added the seL4-PR requires merging a corresponding seL4 pull request label Aug 16, 2024
@lsf37 lsf37 force-pushed the ut-reset-caching branch from f5bc7ac to f212238 Compare August 16, 2024 08:05
@lsf37 lsf37 changed the title verification fro deferred cache flush in untyped reset verification for deferred cache flush in untyped reset Aug 16, 2024
@lsf37
Copy link
Member Author

lsf37 commented Aug 16, 2024

Right, I forgot to update RISCV64 and X64 for the new init_arch_objs parameter. Will add.

@lsf37
Copy link
Member Author

lsf37 commented Aug 17, 2024

Now done. The two additional commits should probably be squashed into the first two.

lib/Monad_Commute.thy Outdated Show resolved Hide resolved
apply (ctac (no_vcg) add: cleanCacheRange_RAM_ccorres)
apply csymbr
apply (rule ccorres_return_C; simp)
apply wp
Copy link
Member

Choose a reason for hiding this comment

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

out of curiosity: is there any reason why you prefer wp over wpsimp in this proof?

Copy link
Member Author

Choose a reason for hiding this comment

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

If the simp is not necessary, I tend to prefer just wp because it's the less complex method and adding clarsimp into the mix at the end can mask problems later (although it can also solve simple unexpected new side goals, so it's not a completley clear cut argument -- I think I just like to use the simpler methods when they should suffice)

apply monad_eq
by (force split: option.splits simp: fail_def return_def select_f_def empty_fail_def)

lemma doMachineOp_alignCheck:
Copy link
Member

Choose a reason for hiding this comment

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

I might discover this later in the review, but are all the doMachineOp lemmas in this file new, or moved?

Copy link
Member Author

Choose a reason for hiding this comment

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

changed versions of moved lemmas (some where not phrased with monad_commute before, but the originals where in the same theoory). I guess we could move them further up, but we also do not seem to need them anywhere else, so I tried to keep noise low.

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.

I think this is not that bad, and the performance improvement on the seL4 side is definitely good.
Could I ask why x64 and RISCV are having such an easier time with this compared to the Arms?
For squashing, yes, I think the proofs update can be one commit (maybe add a note as to why it's mostly Arm-related).
Also small request: can this go in after the design spec arch-split overhaul?

@lsf37
Copy link
Member Author

lsf37 commented Aug 19, 2024

I think this is not that bad, and the performance improvement on the seL4 side is definitely good. Could I ask why x64 and RISCV are having such an easier time with this compared to the Arms?

RISCV64 and X64 have different cache flushing requirements -- on X64 the architecture doesn't require it, and the RISCV boards we are currently running don't have the level of caches that would need to be flushed, so there are only interface changes for those two, but content changes for ARM.

For squashing, yes, I think the proofs update can be one commit (maybe add a note as to why it's mostly Arm-related).

👍

Also small request: can this go in after the design spec arch-split overhaul?

No problem!

@lsf37
Copy link
Member Author

lsf37 commented Oct 21, 2024

(rebased on current master)

mapM_x_commute requires "distinct" even if the operations in the mapM
don't require any guards. Add a separate version without distinct when
guard is \top.

Signed-off-by: Gerwin Klein <[email protected]>
@lsf37 lsf37 force-pushed the ut-reset-caching branch 2 times, most recently from 526ae30 to 6febd3d Compare October 23, 2024 23:24
lsf37 added 3 commits October 24, 2024 13:58
Defer the cache flush done in untyped_reset (inside clearMemory) to the
actual retype call, and only flush for the object types where that is
needed. This affects mostly the Arm architectures, but has some minor
changes for adapting the arch interface init_arch_objects in RISCV64 and
X64.

See seL4/seL4#1289 for more detailed rationale.

Signed-off-by: Gerwin Klein <[email protected]>
Most content is in the Arm architectures, RISCV64 and X64 only have
interface changes, because X64 has different cache requirements and
RISCV64 currently has no caches at level 2.

Signed-off-by: Gerwin Klein <[email protected]>
@lsf37 lsf37 merged commit f8016c1 into master Oct 24, 2024
14 checks passed
@lsf37 lsf37 deleted the ut-reset-caching branch October 24, 2024 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
seL4-PR requires merging a corresponding seL4 pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants