Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kernel
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ACS
Public
HermitOS
kernel
Commits
3dce59e0
Commit
3dce59e0
authored
2 years ago
by
Martin Kröning
Browse files
Options
Downloads
Patches
Plain Diff
Paging: Make unmap properly generic
parent
0695e7fd
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/arch/x86_64/mm/paging.rs
+15
-17
15 additions, 17 deletions
src/arch/x86_64/mm/paging.rs
with
15 additions
and
17 deletions
src/arch/x86_64/mm/paging.rs
+
15
−
17
View file @
3dce59e0
use
core
::
fmt
::
Debug
;
use
core
::
ptr
;
use
x86_64
::
instructions
::
tlb
;
...
...
@@ -198,7 +199,11 @@ unsafe fn recursive_page_table() -> RecursivePageTable<'static> {
}
}
pub
fn
unmap
<
S
:
PageSize
>
(
virtual_address
:
VirtAddr
,
count
:
usize
)
{
pub
fn
unmap
<
S
>
(
virtual_address
:
VirtAddr
,
count
:
usize
)
where
S
:
PageSize
+
Debug
,
RecursivePageTable
<
'static
>
:
Mapper
<
S
>
,
{
trace!
(
"Unmapping virtual address {:#X} ({} pages)"
,
virtual_address
,
...
...
@@ -210,22 +215,15 @@ pub fn unmap<S: PageSize>(virtual_address: VirtAddr, count: usize) {
let
range
=
Page
::
range
(
first_page
,
last_page
);
for
page
in
range
{
match
S
::
SIZE
{
Size4KiB
::
SIZE
=>
{
let
page
=
Page
::
<
Size4KiB
>
::
from_start_address
(
page
.start_address
())
.unwrap
();
unsafe
{
match
recursive_page_table
()
.unmap
(
page
)
{
Ok
((
_frame
,
flush
))
=>
flush
.flush
(),
// FIXME: Some sentinel pages around stacks are supposed to be unmapped.
// We should handle this case there instead of here.
Err
(
UnmapError
::
PageNotMapped
)
=>
{
debug!
(
"Tried to unmap {page:?}, which was not mapped."
)
}
Err
(
err
)
=>
panic!
(
"{err:?}"
),
}
}
let
mut
page_table
=
unsafe
{
recursive_page_table
()
};
match
page_table
.unmap
(
page
)
{
Ok
((
_frame
,
flush
))
=>
flush
.flush
(),
// FIXME: Some sentinel pages around stacks are supposed to be unmapped.
// We should handle this case there instead of here.
Err
(
UnmapError
::
PageNotMapped
)
=>
{
debug!
(
"Tried to unmap {page:?}, which was not mapped."
)
}
_
=>
unimplemented!
(
),
Err
(
err
)
=>
panic!
(
"{err:?}"
),
}
}
}
...
...
@@ -233,7 +231,7 @@ pub fn unmap<S: PageSize>(virtual_address: VirtAddr, count: usize) {
#[cfg(feature
=
"acpi"
)]
pub
fn
identity_map
<
S
>
(
frame
:
PhysFrame
<
S
>
)
where
S
:
PageSize
+
core
::
fmt
::
Debug
,
S
:
PageSize
+
Debug
,
RecursivePageTable
<
'static
>
:
Mapper
<
S
>
,
{
assert!
(
...
...
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