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
29460e0b
Verified
Commit
29460e0b
authored
3 years ago
by
Jeremy Soller
Browse files
Options
Downloads
Patches
Plain Diff
Use RMM for some arch-specific paging functions
parent
f90033e0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/arch/x86_64/paging/entry.rs
+5
-8
5 additions, 8 deletions
src/arch/x86_64/paging/entry.rs
src/arch/x86_64/paging/mod.rs
+22
-17
22 additions, 17 deletions
src/arch/x86_64/paging/mod.rs
with
27 additions
and
25 deletions
src/arch/x86_64/paging/entry.rs
+
5
−
8
View file @
29460e0b
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
use
crate
::
memory
::
Frame
;
use
crate
::
memory
::
Frame
;
use
super
::
PhysicalAddress
;
use
super
::
{
PhysicalAddress
,
RmmA
,
RmmArch
}
;
/// A page table entry
/// A page table entry
#[repr(packed(
8
))]
#[repr(packed(
8
))]
...
@@ -11,16 +11,13 @@ pub struct Entry(u64);
...
@@ -11,16 +11,13 @@ pub struct Entry(u64);
bitflags!
{
bitflags!
{
pub
struct
EntryFlags
:
u64
{
pub
struct
EntryFlags
:
u64
{
const
PRESENT
=
1
;
const
PRESENT
=
RmmA
::
ENTRY_FLAG_PRESENT
as
u64
;
const
WRITABLE
=
1
<<
1
;
const
WRITABLE
=
RmmA
::
ENTRY_FLAG_READWRITE
as
u64
;
const
USER_ACCESSIBLE
=
1
<<
2
;
const
USER_ACCESSIBLE
=
RmmA
::
ENTRY_FLAG_USER
as
u64
;
const
WRITE_THROUGH
=
1
<<
3
;
const
NO_CACHE
=
1
<<
4
;
const
NO_CACHE
=
1
<<
4
;
const
ACCESSED
=
1
<<
5
;
const
DIRTY
=
1
<<
6
;
const
HUGE_PAGE
=
1
<<
7
;
const
HUGE_PAGE
=
1
<<
7
;
const
GLOBAL
=
1
<<
8
;
const
GLOBAL
=
1
<<
8
;
const
NO_EXECUTE
=
1
<<
63
;
const
NO_EXECUTE
=
RmmA
::
ENTRY_FLAG_NO_EXEC
as
u64
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/arch/x86_64/paging/mod.rs
+
22
−
17
View file @
29460e0b
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
use
core
::
ops
::{
Deref
,
DerefMut
};
use
core
::
ops
::{
Deref
,
DerefMut
};
use
core
::{
mem
,
ptr
};
use
core
::{
mem
,
ptr
};
use
spin
::
Mutex
;
use
spin
::
Mutex
;
use
x86
::
{
controlregs
,
msr
,
tlb
}
;
use
x86
::
msr
;
use
crate
::
memory
::
Frame
;
use
crate
::
memory
::
Frame
;
...
@@ -12,7 +12,12 @@ use self::entry::EntryFlags;
...
@@ -12,7 +12,12 @@ use self::entry::EntryFlags;
use
self
::
mapper
::{
Mapper
,
MapperFlushAll
};
use
self
::
mapper
::{
Mapper
,
MapperFlushAll
};
use
self
::
temporary_page
::
TemporaryPage
;
use
self
::
temporary_page
::
TemporaryPage
;
pub
use
rmm
::{
PhysicalAddress
,
VirtualAddress
};
pub
use
rmm
::{
Arch
as
RmmArch
,
PhysicalAddress
,
VirtualAddress
,
X8664Arch
as
RmmA
,
};
pub
mod
entry
;
pub
mod
entry
;
pub
mod
mapper
;
pub
mod
mapper
;
...
@@ -259,25 +264,25 @@ impl ActivePageTable {
...
@@ -259,25 +264,25 @@ impl ActivePageTable {
pub
fn
switch
(
&
mut
self
,
new_table
:
InactivePageTable
)
->
InactivePageTable
{
pub
fn
switch
(
&
mut
self
,
new_table
:
InactivePageTable
)
->
InactivePageTable
{
let
old_table
=
InactivePageTable
{
let
old_table
=
InactivePageTable
{
p4_
frame
:
Frame
::
containing_address
(
PhysicalAddress
::
new
(
frame
:
Frame
::
containing_address
(
unsafe
{
unsafe
{
controlregs
::
cr3
()
}
as
usize
,
RmmA
::
table
()
)
),
}
)
};
};
unsafe
{
unsafe
{
controlregs
::
cr3_writ
e
(
new_table
.
p4_
frame
.start_address
()
.data
()
as
u64
);
RmmA
::
set_tabl
e
(
new_table
.frame
.start_address
());
}
}
old_table
old_table
}
}
pub
fn
flush
(
&
mut
self
,
page
:
Page
)
{
pub
fn
flush
(
&
mut
self
,
page
:
Page
)
{
unsafe
{
unsafe
{
tlb
::
flush
(
page
.start_address
()
.data
()
);
RmmA
::
invalidate
(
page
.start_address
());
}
}
}
}
pub
fn
flush_all
(
&
mut
self
)
{
pub
fn
flush_all
(
&
mut
self
)
{
unsafe
{
unsafe
{
tlb
::
flush
_all
();
RmmA
::
invalidate
_all
();
}
}
}
}
...
@@ -290,9 +295,9 @@ impl ActivePageTable {
...
@@ -290,9 +295,9 @@ impl ActivePageTable {
F
:
FnOnce
(
&
mut
Mapper
),
F
:
FnOnce
(
&
mut
Mapper
),
{
{
{
{
let
backup
=
Frame
::
containing_address
(
PhysicalAddress
::
new
(
unsafe
{
let
backup
=
Frame
::
containing_address
(
unsafe
{
controlregs
::
cr3
()
as
usize
RmmA
::
table
()
})
)
;
});
// map temporary_page to current p4 table
// map temporary_page to current p4 table
let
p4_table
=
temporary_page
.map_table_frame
(
let
p4_table
=
temporary_page
.map_table_frame
(
...
@@ -303,7 +308,7 @@ impl ActivePageTable {
...
@@ -303,7 +308,7 @@ impl ActivePageTable {
// overwrite recursive mapping
// overwrite recursive mapping
self
.p4_mut
()[
crate
::
RECURSIVE_PAGE_PML4
]
.set
(
self
.p4_mut
()[
crate
::
RECURSIVE_PAGE_PML4
]
.set
(
table
.
p4_
frame
.clone
(),
table
.frame
.clone
(),
EntryFlags
::
PRESENT
|
EntryFlags
::
WRITABLE
|
EntryFlags
::
NO_EXECUTE
,
EntryFlags
::
PRESENT
|
EntryFlags
::
WRITABLE
|
EntryFlags
::
NO_EXECUTE
,
);
);
self
.flush_all
();
self
.flush_all
();
...
@@ -323,7 +328,7 @@ impl ActivePageTable {
...
@@ -323,7 +328,7 @@ impl ActivePageTable {
}
}
pub
unsafe
fn
address
(
&
self
)
->
usize
{
pub
unsafe
fn
address
(
&
self
)
->
usize
{
controlregs
::
cr3
()
as
usize
RmmA
::
table
()
.data
()
}
}
}
}
...
@@ -337,7 +342,7 @@ impl Drop for ActivePageTable {
...
@@ -337,7 +342,7 @@ impl Drop for ActivePageTable {
}
}
pub
struct
InactivePageTable
{
pub
struct
InactivePageTable
{
p4_
frame
:
Frame
,
frame
:
Frame
,
}
}
impl
InactivePageTable
{
impl
InactivePageTable
{
...
@@ -362,17 +367,17 @@ impl InactivePageTable {
...
@@ -362,17 +367,17 @@ impl InactivePageTable {
}
}
temporary_page
.unmap
(
active_table
);
temporary_page
.unmap
(
active_table
);
InactivePageTable
{
p4_
frame
:
frame
}
InactivePageTable
{
frame
:
frame
}
}
}
pub
unsafe
fn
from_address
(
cr3
:
usize
)
->
InactivePageTable
{
pub
unsafe
fn
from_address
(
cr3
:
usize
)
->
InactivePageTable
{
InactivePageTable
{
InactivePageTable
{
p4_
frame
:
Frame
::
containing_address
(
PhysicalAddress
::
new
(
cr3
)),
frame
:
Frame
::
containing_address
(
PhysicalAddress
::
new
(
cr3
)),
}
}
}
}
pub
unsafe
fn
address
(
&
self
)
->
usize
{
pub
unsafe
fn
address
(
&
self
)
->
usize
{
self
.
p4_
frame
.start_address
()
.data
()
self
.frame
.start_address
()
.data
()
}
}
}
}
...
...
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