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
cbd02a84
Commit
cbd02a84
authored
1 year ago
by
Jacob Lorentzon
Committed by
Jeremy Soller
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Set relocation-model=static
parent
652aa4f1
No related branches found
No related tags found
1 merge request
!240
Set relocation-model=static
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
linkers/x86_64.ld
+1
-1
1 addition, 1 deletion
linkers/x86_64.ld
src/arch/x86_64/consts.rs
+29
-26
29 additions, 26 deletions
src/arch/x86_64/consts.rs
src/context/switch.rs
+1
-2
1 addition, 2 deletions
src/context/switch.rs
targets/x86_64-unknown-kernel.json
+1
-1
1 addition, 1 deletion
targets/x86_64-unknown-kernel.json
with
32 additions
and
30 deletions
linkers/x86_64.ld
+
1
−
1
View file @
cbd02a84
ENTRY(kstart)
OUTPUT_FORMAT(elf64-x86-64)
KERNEL_OFFSET = 0xFFFFFF
000
0000000;
KERNEL_OFFSET = 0xFFFFFF
FF8
0000000;
SECTIONS {
. = KERNEL_OFFSET;
...
...
This diff is collapsed.
Click to expand it.
src/arch/x86_64/consts.rs
+
29
−
26
View file @
cbd02a84
// Because the memory map is so important to not be aliased, it is defined here, in one place
// The lower 256 PML4 entries are reserved for userspace
// Each PML4 entry references up to 512 GB of memory
// The second from the top (510) PML4 is reserved for the kernel
/// The size of a single PML4
pub
const
PML4_SIZE
:
usize
=
0x0000_0080_0000_0000
;
pub
const
PML4_MASK
:
usize
=
0x0000_ff80_0000_0000
;
// Because the memory map is so important to not be aliased, it is defined here, in one place.
//
// - The lower half (256 PML4 entries; 128 TiB) is reserved for userspace. These mappings are
// associated with _address spaces_, and change when context switching, unless the address spaces
// match.
// - The upper half is reserved for the kernel. Kernel mappings are preserved across context
// switches.
//
// Each PML4 entry references 512 GiB of virtual memory.
/// Offset of recur
si
v
e
paging (deprecated, but still reserved)
pub
const
RECURSIVE_PAGE_OFFSET
:
usize
=
(
-
(
PML4_SIZE
as
isize
))
as
usize
;
pub
const
RECURSIVE_PAGE_PML4
:
usize
=
(
RECURSIVE_PAGE_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// The
si
z
e
of a single PML4
pub
const
PML4_SIZE
:
usize
=
0x0000_0080_0000_0000
;
pub
const
PML4_MASK
:
usize
=
0x0000_ff80_0000_0000
;
/// Offset of kernel
pub
const
KERNEL_OFFSET
:
usize
=
RECURSIVE_PAGE_OFFSET
-
PML4_SIZE
;
pub
const
KERNEL_PML4
:
usize
=
(
KERNEL_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Offset of kernel
pub
const
KERNEL_MAX_SIZE
:
usize
=
1_usize
<<
31
;
pub
const
KERNEL_OFFSET
:
usize
=
KERNEL_MAX_SIZE
.wrapping_neg
();
pub
const
KERNEL_PML4
:
usize
=
(
KERNEL_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Offset to kernel heap
pub
const
KERNEL_HEAP_OFFSET
:
usize
=
KERNEL_OFFSET
-
PML4_SIZE
;
pub
const
KERNEL_HEAP_PML4
:
usize
=
(
KERNEL_HEAP_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Size of kernel heap
pub
const
KERNEL_HEAP_SIZE
:
usize
=
1
*
1024
*
1024
;
// 1 MB
/// Offset to kernel heap
pub
const
KERNEL_HEAP_OFFSET
:
usize
=
KERNEL_OFFSET
-
PML4_SIZE
;
pub
const
KERNEL_HEAP_PML4
:
usize
=
(
KERNEL_HEAP_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Size of kernel heap
pub
const
KERNEL_HEAP_SIZE
:
usize
=
1
*
1024
*
1024
;
// 1 MB
/// Offset of physmap
// This needs to match RMM's PHYS_OFFSET
pub
const
PHYS_OFFSET
:
usize
=
0xFFFF_8000_0000_0000
;
pub
const
PHYS_PML4
:
usize
=
(
PHYS_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Offset of physmap
// This needs to match RMM's PHYS_OFFSET
pub
const
PHYS_OFFSET
:
usize
=
0xFFFF_8000_0000_0000
;
pub
const
PHYS_PML4
:
usize
=
(
PHYS_OFFSET
&
PML4_MASK
)
/
PML4_SIZE
;
/// Offset to user image
pub
const
USER_OFFSET
:
usize
=
0
;
/// Offset to user image
pub
const
USER_OFFSET
:
usize
=
0
;
/// End offset of the user image, i.e. kernel start
pub
const
USER_END_OFFSET
:
usize
=
256
*
PML4_SIZE
;
/// End offset of the user image, i.e. kernel start
pub
const
USER_END_OFFSET
:
usize
=
256
*
PML4_SIZE
;
This diff is collapsed.
Click to expand it.
src/context/switch.rs
+
1
−
2
View file @
cbd02a84
...
...
@@ -8,7 +8,6 @@ use spin::{RwLock, RwLockWriteGuard};
use
crate
::
context
::
signal
::
signal_handler
;
use
crate
::
context
::{
arch
,
contexts
,
Context
};
use
crate
::
gdt
;
use
crate
::
interrupt
;
use
crate
::
percpu
::
PercpuBlock
;
use
crate
::
ptrace
;
...
...
@@ -187,7 +186,7 @@ pub unsafe fn switch() -> bool {
#[cfg(any(target_arch
=
"x86"
,
target_arch
=
"x86_64"
))]
{
if
let
Some
(
ref
stack
)
=
next_context
.kstack
{
gdt
::
set_tss_stack
(
stack
.as_ptr
()
as
usize
+
stack
.len
());
crate
::
gdt
::
set_tss_stack
(
stack
.as_ptr
()
as
usize
+
stack
.len
());
}
}
let
percpu
=
PercpuBlock
::
current
();
...
...
This diff is collapsed.
Click to expand it.
targets/x86_64-unknown-kernel.json
+
1
−
1
View file @
cbd02a84
...
...
@@ -16,7 +16,7 @@
"features"
:
"-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2,+soft-float"
,
"dynamic-linking"
:
false
,
"executables"
:
false
,
"relocation-model"
:
"
p
ic"
,
"relocation-model"
:
"
stat
ic"
,
"code-model"
:
"kernel"
,
"disable-redzone"
:
true
,
"frame-pointer"
:
"always"
,
...
...
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