-
Notifications
You must be signed in to change notification settings - Fork 75
seL4Config: remove duplicated constants #547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright 2026, UNSW | ||
| * | ||
| * SPDX-License-Identifier: BSD-2-Clause | ||
| */ | ||
|
|
||
| #include <sel4/arch/constants.h> | ||
| #include <sel4/constants.h> | ||
| #include <sel4/plat/api/constants.h> | ||
| #include <sel4/sel4_arch/constants.h> | ||
|
|
||
| page_table_index_bits: seL4_PageTableIndexBits | ||
| vspace_user_top: seL4_UserVSpaceTop | ||
|
|
||
| #ifdef seL4_VSpaceIndexBits | ||
| vspace_index_bits: seL4_VSpaceIndexBits | ||
| #endif | ||
|
|
||
| #ifdef seL4_IOPageTableIndexBits | ||
| io_page_table_index_bits: seL4_IOPageTableIndexBits | ||
| #endif |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,10 +19,10 @@ use microkit_tool::elf::ElfFile; | |
| use microkit_tool::loader::Loader; | ||
| use microkit_tool::report::write_report; | ||
| use microkit_tool::sdf::{parse, SysMemoryRegion, SysMemoryRegionPaddr}; | ||
| use microkit_tool::sdk::Sdk; | ||
| use microkit_tool::sdk::{AvailableConfig, Sdk}; | ||
| use microkit_tool::sel4::{ | ||
| emulate_kernel_boot, emulate_kernel_boot_partial, Arch, Config, PlatformConfig, | ||
| RiscvVirtualMemory, | ||
| emulate_kernel_boot, emulate_kernel_boot_partial, AddressSpaceConstants, Arch, Config, | ||
| ObjectSizes, PlatformConfig, RiscvVirtualMemory, | ||
| }; | ||
| use microkit_tool::symbols::patch_symbols; | ||
| use microkit_tool::util::{ | ||
|
|
@@ -95,6 +95,17 @@ fn bail_if_not_exists(description: &'static str, path: &Path) -> Result<(), Stri | |
| Ok(()) | ||
| } | ||
|
|
||
| fn parse_json_file<T: serde::de::DeserializeOwned>( | ||
| file_name: &str, | ||
| file_description: &'static str, | ||
| current_config: &AvailableConfig, | ||
| ) -> Result<T, String> { | ||
| let path = current_config.config_dir.join(file_name); | ||
| bail_if_not_exists(file_description, &path)?; | ||
| serde_json::from_str(&fs::read_to_string(&path).expect("Error: Unable to read {path}")) | ||
| .map_err(|err| format!("Error: Unable to parse {file_name}: {err}")) | ||
| } | ||
|
|
||
| fn main() -> Result<(), String> { | ||
| let sdk = match Sdk::discover() { | ||
| Ok(discovered_info) => discovered_info, | ||
|
|
@@ -197,12 +208,17 @@ fn main() -> Result<(), String> { | |
| } | ||
| }; | ||
|
|
||
| let object_sizes = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a reason why you removed the existing pattern here? I can't see what was wrong with it It's much nicer IMO.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm interesting I don't see the point in the scope, maybe a function would make more sense?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The scope makes a new namespace, so you can define several variables without populating global scope. Also, it logically groups things. It's sort of like a function in that way yes. BTW, clipppy failed, and you need to rebase.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on it
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I look this commit is alr rebased?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The parent of 711c607 was 'tests: add test cases for bootinfo prefilling', which is several commits behind latest main.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, you likely only have the au-ts remote, as tbe parent of that commit is the current au-ts microkit fork. You need to have an additional seL4 remote following seL4/microkit that main tracks: because we work on a fork.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmmm so a fork can have a different origin main state?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I understand this a bit now, kinda annoying behaviour
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, they're not linked in any way. |
||
| let object_sizes_path = current_config.config_dir.join("object_sizes.json"); | ||
| bail_if_not_exists("kernel object sizes file", &object_sizes_path)?; | ||
| let object_sizes: ObjectSizes = parse_json_file( | ||
| "object_sizes.json", | ||
| "kernel object sizes file", | ||
| current_config, | ||
| )?; | ||
|
|
||
| serde_json::from_str(&fs::read_to_string(object_sizes_path).unwrap()).unwrap() | ||
| }; | ||
| let address_space_constants: AddressSpaceConstants = parse_json_file( | ||
| "address_space_constants.json", | ||
| "kernel address space constants file", | ||
| current_config, | ||
| )?; | ||
|
|
||
| let hypervisor = match arch { | ||
| Arch::Aarch64 => json_str_as_bool(&kernel_config_json, "ARM_HYPERVISOR_SUPPORT")?, | ||
|
|
@@ -238,7 +254,7 @@ fn main() -> Result<(), String> { | |
| let kernel_config = Config { | ||
| arch, | ||
| word_size: json_str_as_u64(&kernel_config_json, "WORD_SIZE")?, | ||
| minimum_page_size: 4096, | ||
| minimum_page_size: 1 << object_sizes.small_page, | ||
| paddr_user_device_top: json_str_as_u64(&kernel_config_json, "PADDR_USER_DEVICE_TOP")?, | ||
| kernel_frame_size, | ||
| init_cnode_bits: json_str_as_u64(&kernel_config_json, "ROOT_CNODE_SIZE_BITS")?, | ||
|
|
@@ -265,6 +281,7 @@ fn main() -> Result<(), String> { | |
| device_regions, | ||
| normal_regions, | ||
| object_sizes, | ||
| address_space_constants, | ||
| }; | ||
|
|
||
| if kernel_config.arch != Arch::X86_64 && !loader_elf_path.exists() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, having to do math here is slightly weird. I suppose there's no way around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless we extract from part of the compiled tu