diff --git a/tool/microkit/src/sdf.rs b/tool/microkit/src/sdf.rs index 17b5adba..b800c77e 100644 --- a/tool/microkit/src/sdf.rs +++ b/tool/microkit/src/sdf.rs @@ -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(); @@ -2006,8 +1995,19 @@ pub fn parse(filename: &str, xml: &str, config: &Config) -> Result { + // 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()), + )); + } + }; } } diff --git a/tool/microkit/tests/sdf/pd_setvar_no_paddr.system b/tool/microkit/tests/sdf/pd_setvar_no_paddr.system new file mode 100644 index 00000000..77af3c97 --- /dev/null +++ b/tool/microkit/tests/sdf/pd_setvar_no_paddr.system @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tool/microkit/tests/sdf/pd_setvar_with_paddr.system b/tool/microkit/tests/sdf/pd_setvar_with_paddr.system new file mode 100644 index 00000000..da3be915 --- /dev/null +++ b/tool/microkit/tests/sdf/pd_setvar_with_paddr.system @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tool/microkit/tests/test.rs b/tool/microkit/tests/test.rs index 2ae153b2..c4859f67 100644 --- a/tool/microkit/tests/test.rs +++ b/tool/microkit/tests/test.rs @@ -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/"); @@ -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(