-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aarch64 abstract+machine: update abstract to use semi-lazy FPU switching
This includes extending the machine interface with new ops, adding the current owner of the FPU state to the kernel state, and adding the new seL4_TCB_Set_Flags syscall and related functions. Signed-off-by: Corey Lewis <corey.lewis@proofcraft.systems>
- Loading branch information
Showing
16 changed files
with
203 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
(* | ||
* Copyright 2024, Proofcraft Pty Ltd | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-only | ||
*) | ||
|
||
chapter "AARCH64 FPU Functions" | ||
|
||
theory FPU_A | ||
imports | ||
KHeap_A | ||
begin | ||
|
||
context Arch begin arch_global_naming (A) | ||
|
||
definition save_fpu_state :: "obj_ref \<Rightarrow> (unit,'z::state_ext) s_monad" where | ||
"save_fpu_state t \<equiv> do | ||
fpu_state \<leftarrow> do_machine_op readFpuState; | ||
as_user t (setFPUState fpu_state) | ||
od" | ||
|
||
definition load_fpu_state :: "obj_ref \<Rightarrow> (unit,'z::state_ext) s_monad" where | ||
"load_fpu_state t \<equiv> do | ||
fpu_state \<leftarrow> as_user t getFPUState; | ||
do_machine_op (writeFpuState fpu_state) | ||
od" | ||
|
||
\<comment> \<open>FIXME: maybe use a case instead of the if (depends on if wpc or if_split is easier)\<close> | ||
definition switch_local_fpu_owner :: "obj_ref option \<Rightarrow> (unit,'z::state_ext) s_monad" where | ||
"switch_local_fpu_owner new_owner \<equiv> do | ||
do_machine_op enableFpu; | ||
cur_fpu_owner \<leftarrow> gets (arm_current_fpu_owner \<circ> arch_state); | ||
when (cur_fpu_owner \<noteq> None) $ save_fpu_state (the cur_fpu_owner); | ||
if (new_owner \<noteq> None) | ||
then load_fpu_state (the new_owner) | ||
else do_machine_op disableFpu; | ||
modify (\<lambda>s. s \<lparr>arch_state := arch_state s\<lparr>arm_current_fpu_owner := new_owner\<rparr>\<rparr>) | ||
od" | ||
|
||
definition fpu_release :: "obj_ref \<Rightarrow> (unit,'z::state_ext) s_monad" where | ||
"fpu_release thread_ptr \<equiv> do | ||
cur_fpu_owner \<leftarrow> gets (arm_current_fpu_owner \<circ> arch_state); | ||
when (cur_fpu_owner = Some thread_ptr) $ switch_local_fpu_owner None | ||
od" | ||
|
||
definition lazy_fpu_restore :: "obj_ref \<Rightarrow> (unit,'z::state_ext) s_monad" where | ||
"lazy_fpu_restore thread_ptr \<equiv> do | ||
flags \<leftarrow> thread_get tcb_flags thread_ptr; | ||
if (ArchFlag FpuDisabled \<in> flags) | ||
then do_machine_op disableFpu | ||
else do | ||
do_machine_op enableFpu; | ||
switch_local_fpu_owner (Some thread_ptr) | ||
od | ||
od" | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.