-
Notifications
You must be signed in to change notification settings - Fork 307
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
[task]: Introduce namespaces io manage system resources #193
base: monolithic
Are you sure you want to change the base?
Conversation
7ab1d2a
to
801de3c
Compare
572dcea
to
4bd7557
Compare
e38cb09
to
aabfe88
Compare
RwLock::new(fd_table) | ||
}; | ||
def_resource! { | ||
#[allow(non_camel_case_types)] |
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.
Why we need this?
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.
If you mean #[allow(non_camel_case_types)]
, when we remove it then such warnings will appear:
Structure `FD_TABLE` should have UpperCamelCase name, e.g. `FdTable`
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.
We can add it before line 227:
arceos/modules/axns/src/lib.rs
Lines 223 to 227 in cb589bb
macro_rules! def_resource { | |
( $( $(#[$attr:meta])* $vis:vis static $name:ident: $ty:ty = $default:expr; )+ ) => { | |
$( | |
$(#[$attr])* | |
$vis struct $name { __value: () } |
modules/axhal/src/mem.rs
Outdated
@@ -90,6 +90,12 @@ fn kernel_image_regions() -> impl Iterator<Item = MemRegion> { | |||
flags: MemRegionFlags::RESERVED | MemRegionFlags::READ, | |||
name: ".rodata", | |||
}, | |||
MemRegion { | |||
paddr: virt_to_phys((_sinit_array as usize).into()), | |||
size: _einit_array as usize - _sinit_array as usize, |
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.
Can we use __init_array_start
and __init_array_end
only?
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.
Fixed
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.
But __init_array_end
segment may be not aligned to 4K size.
.init_array : ALIGN(4K) {
_sinit_array = .;
__init_array_start = .;
*(.init_array .init_array.*)
__init_array_end = .;
. = ALIGN(4K);
_einit_array = .;
}
And the linker scripts in Unikraft are below:
OTHER SECTIONS (aligned to 0x8)
/* Constructor tables (read-only) */
. = ALIGN(0x8);
_ctors = .;
.preinit_array : {
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
}
. = ALIGN(0x8);
.init_array : {
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
}
_ectors = .;
. = ALIGN(__PAGE_SIZE);
Then it enumerate all function pointers from __init_array_start to __init_array_end and invokes them.
Should we manually align this region to 4K like this?
MemRegion {
paddr: virt_to_phys((__init_array_start as usize).into()).align_down_4k(),
size: VirtAddr::from_usize(__init_array_end as usize).align_up_4k()
- VirtAddr::from_usize(__init_array_start as usize).align_down_4k(),
flags: MemRegionFlags::RESERVED | MemRegionFlags::READ,
name: ".init_array",
}
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.
We can put the init_array
section between .data
and .tdata
so that it will be mapped when we map _sdata.._edata
.
modules/axmm/src/lib.rs
Outdated
@@ -37,6 +37,10 @@ pub fn new_kernel_aspace() -> AxResult<AddrSpace> { | |||
axconfig::KERNEL_ASPACE_SIZE, | |||
)?; | |||
for r in axhal::mem::memory_regions() { | |||
if r.size == 0 { | |||
info!("Skip zero-size memory region: {:?}", r); |
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.
Put the empty region check in map_linear
/map_alloc
/unmap
/protect
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.
But how should we know which empty segments need to be returned normally or report error if we put empty region check in these func?
16a9bf0
to
cb589bb
Compare
They will be solved in #224 |
aabfe88
to
7e421c8
Compare
63732c8
to
f542419
Compare
No description provided.