Skip to content

Commit dafce4d

Browse files
committed
Add support for FPU flag for PDs
Signed-off-by: Jakub Duchniewicz <j.duchniewicz@unsw.edu.au>
1 parent c83d507 commit dafce4d

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

docs/manual.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,9 +723,7 @@ This will set the program counter of the vCPU to `entry_point`.
723723

724724
Stop the execution of the VM's virtual CPU with ID `vcpu`.
725725

726-
## `void microkit_vcpu_arm_inject_irq(microkit_child vcpu, seL4_Uint16 irq,
727-
seL4_Uint8 priority, seL4_Uint8 group,
728-
seL4_Uint8 index)`
726+
## `void microkit_vcpu_arm_inject_irq(microkit_child vcpu, seL4_Uint16 irq,seL4_Uint8 priority, seL4_Uint8 group, seL4_Uint8 index)`
729727

730728
Inject a virtual ARM interrupt for a virtual CPU `vcpu` with IRQ number `irq`.
731729
The `priority` (0-31) determines what ARM GIC (generic interrupt controller)
@@ -1010,6 +1008,7 @@ It supports the following attributes:
10101008
Must be be between 4KiB and 16MiB and be 4K page-aligned. Defaults to 8KiB.
10111009
* `cpu`: (optional) set the physical CPU core this PD will run on. Defaults to zero.
10121010
* `smc`: (optional, only on ARM) Allow the PD to give an SMC call for the kernel to perform.. Defaults to false.
1011+
* `fpu`: (optional) whether this PD can access the FPU. Defaults to true.
10131012

10141013
Additionally, it supports the following child elements:
10151014

tool/microkit/src/capdl/builder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ impl CapDLSpecContainer {
322322
prio: 0,
323323
max_prio: 0,
324324
resume: false,
325+
fpu: true,
325326
ip: entry_point.into(),
326327
sp: 0.into(),
327328
gprs: Vec::new(),
@@ -468,7 +469,7 @@ pub fn build_capdl_spec(
468469
)
469470
.unwrap();
470471

471-
// At this point, all of the required objects for the monitor have been created and it caps inserted into
472+
// At this point, all of the required objects for the monitor have been created and its caps inserted into
472473
// the correct slot in the CSpace. We need to bind those objects into the TCB for the monitor to use them.
473474
// In addition, `add_elf_to_spec()` doesn't fill most the details in the TCB.
474475
// Now fill them in: stack ptr, priority, ipc buf vaddr, etc.
@@ -939,6 +940,7 @@ pub fn build_capdl_spec(
939940
affinity: Word(vcpu.cpu.0.into()),
940941
prio: virtual_machine.priority,
941942
max_prio: virtual_machine.priority,
943+
fpu: true,
942944
resume: false,
943945
// VMs do not have program images associated with them so these are always zero.
944946
ip: Word(0),
@@ -1007,6 +1009,7 @@ pub fn build_capdl_spec(
10071009
pd_tcb.extra.master_fault_ep = None; // Not used on MCS kernel.
10081010
pd_tcb.extra.prio = pd.priority;
10091011
pd_tcb.extra.max_prio = pd.priority;
1012+
pd_tcb.extra.fpu = pd.fpu;
10101013
pd_tcb.extra.resume = true;
10111014

10121015
pd_tcb.slots.extend(caps_to_bind_to_tcb);

tool/microkit/src/sdf.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ pub struct ProtectionDomain {
261261
pub cpu: CpuCore,
262262
pub program_image: PathBuf,
263263
pub program_image_for_symbols: Option<PathBuf>,
264+
/// Enable FPU for this PD.
265+
pub fpu: bool,
264266
pub maps: Vec<SysMap>,
265267
pub irqs: Vec<SysIrq>,
266268
pub ioports: Vec<IOPort>,
@@ -461,6 +463,7 @@ impl ProtectionDomain {
461463
// but we do the error-checking further down.
462464
"smc",
463465
"cpu",
466+
"fpu",
464467
];
465468
if is_child {
466469
attrs.push("id");
@@ -613,6 +616,19 @@ impl ProtectionDomain {
613616
));
614617
}
615618

619+
// FPU is enabled by default
620+
let fpu = if let Some(xml_fpu) = node.attribute("fpu") {
621+
match str_to_bool(xml_fpu) {
622+
Some(val) => val,
623+
None => {
624+
return Err(value_error(xml_sdf, node, "fpu must be 'true' or 'false'".to_string(),))
625+
}
626+
}
627+
} else {
628+
// Default to fpu enabled
629+
true
630+
};
631+
616632
for child in node.children() {
617633
if !child.is_element() {
618634
continue;
@@ -1081,6 +1097,7 @@ impl ProtectionDomain {
10811097
cpu,
10821098
program_image: program_image.unwrap(),
10831099
program_image_for_symbols,
1100+
fpu,
10841101
maps,
10851102
irqs,
10861103
ioports,
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2025, UNSW
4+
5+
SPDX-License-Identifier: BSD-2-Clause
6+
-->
7+
<system>
8+
<protection_domain name="test" fpu="foo">
9+
</protection_domain>
10+
</system>

tool/microkit/tests/test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,4 +917,13 @@ mod system {
917917
"Error: too many protection domains (64) defined. Maximum is 63.",
918918
)
919919
}
920+
921+
#[test]
922+
fn test_fpu_flag_wrong_value() {
923+
check_error(
924+
&DEFAULT_AARCH64_KERNEL_CONFIG,
925+
"wrong_fpu_flag_value.system",
926+
"Error: fpu must be 'true' or 'false'",
927+
)
928+
}
920929
}

0 commit comments

Comments
 (0)