Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions tool/microkit/src/sdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,17 +977,6 @@ impl ProtectionDomain {
}
}
"setvar" => {
match config.arch {
Arch::Aarch64 | Arch::Riscv64 => {}
Arch::X86_64 => {
return Err(value_error(
xml_sdf,
node,
"setvar with 'region_paddr' for MR without a specified paddr is unsupported on x86_64".to_string(),
));
}
};

check_attributes(xml_sdf, &child, &["symbol", "region_paddr"])?;
let symbol = checked_lookup(xml_sdf, &child, "symbol")?.to_string();
let region = checked_lookup(xml_sdf, &child, "region_paddr")?.to_string();
Expand Down Expand Up @@ -2006,8 +1995,19 @@ pub fn parse(filename: &str, xml: &str, config: &Config) -> Result<SystemDescrip
if mr_names_with_setvar_paddr.contains(&mr.name)
&& mr.phys_addr == SysMemoryRegionPaddr::Unspecified
{
// The actual allocation is done by another part of the tool.
mr.phys_addr = SysMemoryRegionPaddr::ToolAllocated(None);
match config.arch {
Arch::Aarch64 | Arch::Riscv64 => {
// The actual allocation is done by another part of the tool.
mr.phys_addr = SysMemoryRegionPaddr::ToolAllocated(None);
}
Arch::X86_64 => {
return Err(format!(
"Error: setvar with 'region_paddr' for MR without a specified paddr is unsupported on x86-64 @ '{}' {}",
mr.name,
loc_string(&xml_sdf, mr.text_pos.unwrap()),
));
}
};
}
}

Expand Down
14 changes: 14 additions & 0 deletions tool/microkit/tests/sdf/pd_setvar_no_paddr.system
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2026, UNSW

SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<memory_region name="test_mr" size="0x1000" />
<protection_domain name="test">
<program_image path="test.elf" />

<setvar region_paddr="test_mr" symbol="test" />
</protection_domain>
</system>
14 changes: 14 additions & 0 deletions tool/microkit/tests/sdf/pd_setvar_with_paddr.system
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2026, UNSW

SPDX-License-Identifier: BSD-2-Clause
-->
<system>
<memory_region name="test_mr" size="0x1000" phys_addr="0x1_000_000" />
<protection_domain name="test">
<program_image path="test.elf" />

<setvar region_paddr="test_mr" symbol="test" />
</protection_domain>
</system>
28 changes: 28 additions & 0 deletions tool/microkit/tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,20 @@ const DEFAULT_X86_64_KERNEL_CONFIG: sel4::Config = sel4::Config {
normal_regions: None,
};

fn check_success(kernel_config: &sel4::Config, test_name: &str) {
let mut path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/sdf/");
path.push(test_name);
let sdf = std::fs::read_to_string(path).unwrap();
let parse = sdf::parse(test_name, &sdf, kernel_config);

if let Err(ref e) = parse {
eprintln!("Expected no error, instead got:\n{e}")
}

assert!(parse.is_ok());
}

fn check_error(kernel_config: &sel4::Config, test_name: &str, expected_err: &str) {
let mut path = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("tests/sdf/");
Expand Down Expand Up @@ -254,6 +268,20 @@ mod protection_domain {
)
}

#[test]
fn test_setvar_paddr_with_paddr() {
check_success(&DEFAULT_X86_64_KERNEL_CONFIG, "pd_setvar_with_paddr.system")
}

#[test]
fn test_setvar_paddr_no_paddr() {
check_error(
&DEFAULT_X86_64_KERNEL_CONFIG,
"pd_setvar_no_paddr.system",
"Error: setvar with 'region_paddr' for MR without a specified paddr is unsupported on x86-64 @",
)
}

#[test]
fn test_duplicate_program_image() {
check_error(
Expand Down