Skip to content

Commit 04bef0b

Browse files
committed
tool: check slot of extra caps
This checks if people try to place extra caps in slot 0, which is reserved for Microkit CNode, and adds a test case for it. Signed-off-by: Terry Bai <tianyi.bai@unsw.edu.au>
1 parent b68bb06 commit 04bef0b

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

tool/microkit/src/sdf.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,6 +1372,14 @@ impl CapMap {
13721372

13731373
let slot = sdf_parse_number(checked_lookup(xml_sdf, node, "slot")?, node)?;
13741374

1375+
if slot == 0 {
1376+
return Err(value_error(
1377+
xml_sdf,
1378+
node,
1379+
format!("The destination slot 0 has been reserved for Microkit CNode"),
1380+
));
1381+
}
1382+
13751383
// TODO: Rework this so that we don't have a fixed upper limit.
13761384
if slot >= CAP_MAP_MAX_SLOT {
13771385
return Err(value_error(
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2026, UNSW
4+
5+
SPDX-License-Identifier: BSD-2-Clause
6+
-->
7+
<system>
8+
<protection_domain name="pd_a">
9+
<program_image path="test" />
10+
</protection_domain>
11+
12+
<protection_domain name="pd_b">
13+
<program_image path="test" />
14+
15+
<cspace>
16+
<cap_sc slot="0" pd="pd_a" />
17+
</cspace>
18+
</protection_domain>
19+
</system>

tool/microkit/tests/test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,15 @@ mod system {
10401040
)
10411041
}
10421042

1043+
#[test]
1044+
fn test_cap_mappings_slot_invalid() {
1045+
check_error(
1046+
&DEFAULT_AARCH64_KERNEL_CONFIG,
1047+
"cap_mappings_slot_invalid.system",
1048+
"Error: The destination slot 0 has been reserved for Microkit CNode on element 'cap_sc'",
1049+
)
1050+
}
1051+
10431052
#[test]
10441053
fn test_cap_mappings_invalid() {
10451054
check_error(

0 commit comments

Comments
 (0)