Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
kernel
Commits
d4b5899c
Verified
Commit
d4b5899c
authored
1 year ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
Remove allocator_owned hack.
parent
5cc05a28
No related branches found
No related tags found
1 merge request
!238
Demand paging
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/context/memory.rs
+5
-11
5 additions, 11 deletions
src/context/memory.rs
src/syscall/process.rs
+4
-6
4 additions, 6 deletions
src/syscall/process.rs
with
9 additions
and
17 deletions
src/context/memory.rs
+
5
−
11
View file @
d4b5899c
...
...
@@ -598,7 +598,6 @@ pub struct Grant {
flags
:
PageFlags
<
RmmA
>
,
mapped
:
bool
,
pub
(
crate
)
owned
:
bool
,
pub
(
crate
)
allocator_owned
:
bool
,
//TODO: This is probably a very heavy way to keep track of fmap'd files, perhaps move to the context?
pub
desc_opt
:
Option
<
GrantFileRef
>
,
}
...
...
@@ -644,7 +643,6 @@ impl Grant {
flags
,
mapped
:
true
,
owned
:
false
,
allocator_owned
:
false
,
desc_opt
:
None
,
})
}
...
...
@@ -654,10 +652,10 @@ impl Grant {
let
flush
=
unsafe
{
mapper
.map
(
page
.start_address
(),
flags
)
}
.ok_or
(
Enomem
)
?
;
flusher
.consume
(
flush
);
}
Ok
(
Grant
{
region
:
Region
{
start
:
dst
.start_address
(),
size
:
page_count
*
PAGE_SIZE
},
flags
,
mapped
:
true
,
owned
:
true
,
allocator_owned
:
true
,
desc_opt
:
None
})
Ok
(
Grant
{
region
:
Region
{
start
:
dst
.start_address
(),
size
:
page_count
*
PAGE_SIZE
},
flags
,
mapped
:
true
,
owned
:
true
,
desc_opt
:
None
})
}
pub
fn
borrow
(
src_base
:
Page
,
dst_base
:
Page
,
page_count
:
usize
,
flags
:
PageFlags
<
RmmA
>
,
desc_opt
:
Option
<
GrantFileRef
>
,
src_mapper
:
&
mut
PageMapper
,
dst_mapper
:
&
mut
PageMapper
,
dst_flusher
:
impl
Flusher
<
RmmA
>
)
->
Result
<
Grant
,
Enomem
>
{
Self
::
copy_inner
(
src_base
,
dst_base
,
page_count
,
flags
,
desc_opt
,
src_mapper
,
dst_mapper
,
(),
dst_flusher
,
false
,
false
,
false
)
Self
::
copy_inner
(
src_base
,
dst_base
,
page_count
,
flags
,
desc_opt
,
src_mapper
,
dst_mapper
,
(),
dst_flusher
,
false
,
false
)
}
pub
fn
reborrow
(
src_grant
:
&
Grant
,
dst_base
:
Page
,
src_mapper
:
&
mut
PageMapper
,
dst_mapper
:
&
mut
PageMapper
,
dst_flusher
:
impl
Flusher
<
RmmA
>
)
->
Result
<
Grant
>
{
Self
::
borrow
(
Page
::
containing_address
(
src_grant
.start_address
()),
dst_base
,
src_grant
.size
()
/
PAGE_SIZE
,
src_grant
.flags
(),
src_grant
.desc_opt
.clone
(),
src_mapper
,
dst_mapper
,
dst_flusher
)
.map_err
(
Into
::
into
)
...
...
@@ -666,7 +664,7 @@ impl Grant {
assert!
(
core
::
mem
::
replace
(
&
mut
src_grant
.mapped
,
false
));
let
desc_opt
=
src_grant
.desc_opt
.take
();
Self
::
copy_inner
(
Page
::
containing_address
(
src_grant
.start_address
()),
dst_base
,
src_grant
.size
()
/
PAGE_SIZE
,
src_grant
.flags
(),
desc_opt
,
src_mapper
,
dst_mapper
,
src_flusher
,
dst_flusher
,
src_grant
.owned
,
src_grant
.allocator_owned
,
true
)
.map_err
(
Into
::
into
)
Self
::
copy_inner
(
Page
::
containing_address
(
src_grant
.start_address
()),
dst_base
,
src_grant
.size
()
/
PAGE_SIZE
,
src_grant
.flags
(),
desc_opt
,
src_mapper
,
dst_mapper
,
src_flusher
,
dst_flusher
,
src_grant
.owned
,
true
)
.map_err
(
Into
::
into
)
}
fn
copy_inner
(
...
...
@@ -680,7 +678,6 @@ impl Grant {
mut
src_flusher
:
impl
Flusher
<
RmmA
>
,
mut
dst_flusher
:
impl
Flusher
<
RmmA
>
,
owned
:
bool
,
allocator_owned
:
bool
,
unmap
:
bool
,
)
->
Result
<
Grant
,
Enomem
>
{
let
mut
successful_count
=
0
;
...
...
@@ -716,7 +713,7 @@ impl Grant {
};
dst_flusher
.consume
(
flush
);
if
owned
&&
allocator_owned
{
if
owned
{
crate
::
memory
::
deallocate_frames
(
Frame
::
containing_address
(
frame
),
1
);
}
}
...
...
@@ -731,7 +728,6 @@ impl Grant {
flags
,
mapped
:
true
,
owned
,
allocator_owned
,
desc_opt
,
})
}
...
...
@@ -763,7 +759,7 @@ impl Grant {
let
(
entry
,
_
,
flush
)
=
unsafe
{
mapper
.unmap_phys
(
page
.start_address
(),
true
)
}
.unwrap_or_else
(||
panic!
(
"missing page at {:#0x} for grant {:?}"
,
page
.start_address
()
.data
(),
self
));
if
self
.owned
&&
self
.allocator_owned
{
if
self
.owned
{
// TODO: make sure this frame can be safely freed, physical use counter.
//
// Namely, we can either have MAP_PRIVATE or MAP_SHARED-style mappings. The former
...
...
@@ -811,7 +807,6 @@ impl Grant {
flags
:
self
.flags
,
mapped
:
self
.mapped
,
owned
:
self
.owned
,
allocator_owned
:
self
.allocator_owned
,
desc_opt
:
self
.desc_opt
.clone
(),
});
let
after_grant
=
self
.after
(
region
)
.map
(|
region
|
Grant
{
...
...
@@ -819,7 +814,6 @@ impl Grant {
flags
:
self
.flags
,
mapped
:
self
.mapped
,
owned
:
self
.owned
,
allocator_owned
:
self
.allocator_owned
,
desc_opt
:
self
.desc_opt
.clone
(),
});
...
...
This diff is collapsed.
Click to expand it.
src/syscall/process.rs
+
4
−
6
View file @
d4b5899c
...
...
@@ -590,18 +590,16 @@ pub unsafe fn usermode_bootstrap(bootstrap: &Bootstrap) -> ! {
let
mut
addr_space
=
addr_space
.write
();
let
addr_space
=
&
mut
*
addr_space
;
let
mut
grant
=
context
::
memory
::
Grant
::
physmap
(
// TODO: Mark as owned and then support reclaiming the memory to the allocator if
// deallocated?
addr_space
.grants
.insert
(
context
::
memory
::
Grant
::
physmap
(
bootstrap
.base
.clone
(),
Page
::
containing_address
(
VirtualAddress
::
new
(
0
)),
bootstrap
.page_count
,
PageFlags
::
new
()
.user
(
true
)
.write
(
true
)
.execute
(
true
),
&
mut
addr_space
.table.utable
,
PageFlushAll
::
new
(),
)
.expect
(
"failed to physmap bootstrap memory"
);
grant
.allocator_owned
=
false
;
grant
.owned
=
true
;
addr_space
.grants
.insert
(
grant
);
)
.expect
(
"failed to physmap bootstrap memory"
));
}
// Start in a minimal environment without any stack.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment