Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kernel
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
23
Issues
23
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
redox-os
kernel
Commits
e5cf6efa
Verified
Commit
e5cf6efa
authored
Mar 31, 2019
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support specification of stack with clone system call and CLONE_STACK flag
parent
9ccaed71
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
133 additions
and
96 deletions
+133
-96
Cargo.lock
Cargo.lock
+75
-70
Cargo.toml
Cargo.toml
+1
-1
src/arch/x86_64/interrupt/syscall.rs
src/arch/x86_64/interrupt/syscall.rs
+8
-2
src/context/context.rs
src/context/context.rs
+1
-1
src/scheme/sys/context.rs
src/scheme/sys/context.rs
+3
-1
src/syscall/mod.rs
src/syscall/mod.rs
+9
-1
src/syscall/process.rs
src/syscall/process.rs
+35
-19
syscall
syscall
+1
-1
No files found.
Cargo.lock
View file @
e5cf6efa
This diff is collapsed.
Click to expand it.
Cargo.toml
View file @
e5cf6efa
[package]
name
=
"kernel"
version
=
"0.1.5
1
"
version
=
"0.1.5
2
"
build
=
"build.rs"
[lib]
...
...
src/arch/x86_64/interrupt/syscall.rs
View file @
e5cf6efa
...
...
@@ -159,10 +159,16 @@ pub struct SyscallStack {
pub
rip
:
usize
,
pub
cs
:
usize
,
pub
rflags
:
usize
,
// Will only be present if syscall is called from another ring
pub
rsp
:
usize
,
pub
ss
:
usize
,
}
#[naked]
pub
unsafe
extern
fn
clone_ret
()
{
asm!
(
"pop rbp"
:
:
:
:
"intel"
,
"volatile"
);
asm!
(
""
:
:
"{rax}"
(
0
)
:
:
"intel"
,
"volatile"
);
asm!
(
"
pop rbp
xor rax, rax
"
:
:
:
:
"intel"
,
"volatile"
);
}
src/context/context.rs
View file @
e5cf6efa
...
...
@@ -148,7 +148,7 @@ pub struct Context {
/// User heap
pub
heap
:
Option
<
SharedMemory
>
,
/// User stack
pub
stack
:
Option
<
Memory
>
,
pub
stack
:
Option
<
Shared
Memory
>
,
/// User signal stack
pub
sigstack
:
Option
<
Memory
>
,
/// User Thread local storage
...
...
src/scheme/sys/context.rs
View file @
e5cf6efa
...
...
@@ -75,7 +75,9 @@ pub fn resource() -> Result<Vec<u8>> {
});
}
if
let
Some
(
ref
stack
)
=
context
.stack
{
memory
+=
stack
.size
();
stack
.with
(|
stack
|
{
memory
+=
stack
.size
();
});
}
if
let
Some
(
ref
sigstack
)
=
context
.sigstack
{
memory
+=
sigstack
.size
();
...
...
src/syscall/mod.rs
View file @
e5cf6efa
...
...
@@ -93,7 +93,15 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: u
SYS_GETPID
=>
getpid
()
.map
(
ContextId
::
into
),
SYS_GETPGID
=>
getpgid
(
ContextId
::
from
(
b
))
.map
(
ContextId
::
into
),
SYS_GETPPID
=>
getppid
()
.map
(
ContextId
::
into
),
SYS_CLONE
=>
clone
(
b
,
bp
)
.map
(
ContextId
::
into
),
SYS_CLONE
=>
{
let
old_rsp
=
stack
.rsp
;
if
b
&
flag
::
CLONE_STACK
==
flag
::
CLONE_STACK
{
stack
.rsp
=
c
;
}
let
ret
=
clone
(
b
,
bp
)
.map
(
ContextId
::
into
);
stack
.rsp
=
old_rsp
;
ret
},
SYS_EXIT
=>
exit
((
b
&
0xFF
)
<<
8
),
SYS_KILL
=>
kill
(
ContextId
::
from
(
b
),
c
),
SYS_WAITPID
=>
waitpid
(
ContextId
::
from
(
b
),
c
,
d
)
.map
(
ContextId
::
into
),
...
...
src/syscall/process.rs
View file @
e5cf6efa
...
...
@@ -23,7 +23,7 @@ use scheme::FileHandle;
use
syscall
;
use
syscall
::
data
::{
SigAction
,
Stat
};
use
syscall
::
error
::
*
;
use
syscall
::
flag
::{
CLONE_VFORK
,
CLONE_VM
,
CLONE_FS
,
CLONE_FILES
,
CLONE_SIGHAND
,
use
syscall
::
flag
::{
CLONE_VFORK
,
CLONE_VM
,
CLONE_FS
,
CLONE_FILES
,
CLONE_SIGHAND
,
CLONE_STACK
,
PROT_EXEC
,
PROT_READ
,
PROT_WRITE
,
SIG_DFL
,
SIGCONT
,
SIGTERM
,
WCONTINUED
,
WNOHANG
,
WUNTRACED
,
wifcontinued
,
wifstopped
};
use
syscall
::
validate
::{
validate_slice
,
validate_slice_mut
};
...
...
@@ -186,22 +186,28 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<ContextId> {
}
}
if
let
Some
(
ref
stack
)
=
context
.stack
{
let
mut
new_stack
=
context
::
memory
::
Memory
::
new
(
VirtualAddress
::
new
(::
USER_TMP_STACK_OFFSET
),
stack
.size
(),
EntryFlags
::
PRESENT
|
EntryFlags
::
NO_EXECUTE
|
EntryFlags
::
WRITABLE
,
false
);
if
let
Some
(
ref
stack_shared
)
=
context
.stack
{
if
flags
&
CLONE_STACK
==
CLONE_STACK
{
stack_option
=
Some
(
stack_shared
.clone
());
}
else
{
stack_shared
.with
(|
stack
|
{
let
mut
new_stack
=
context
::
memory
::
Memory
::
new
(
VirtualAddress
::
new
(::
USER_TMP_STACK_OFFSET
),
stack
.size
(),
EntryFlags
::
PRESENT
|
EntryFlags
::
NO_EXECUTE
|
EntryFlags
::
WRITABLE
,
false
);
unsafe
{
intrinsics
::
copy
(
stack
.start_address
()
.get
()
as
*
const
u8
,
new_stack
.start_address
()
.get
()
as
*
mut
u8
,
stack
.size
());
}
unsafe
{
intrinsics
::
copy
(
stack
.start_address
()
.get
()
as
*
const
u8
,
new_stack
.start_address
()
.get
()
as
*
mut
u8
,
stack
.size
());
}
new_stack
.remap
(
stack
.flags
());
stack_option
=
Some
(
new_stack
);
new_stack
.remap
(
stack
.flags
());
stack_option
=
Some
(
new_stack
.to_shared
());
});
}
}
if
let
Some
(
ref
sigstack
)
=
context
.sigstack
{
...
...
@@ -457,9 +463,19 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<ContextId> {
}
// Setup user stack
if
let
Some
(
mut
stack
)
=
stack_option
{
stack
.move_to
(
VirtualAddress
::
new
(::
USER_STACK_OFFSET
),
&
mut
new_table
,
&
mut
temporary_page
);
context
.stack
=
Some
(
stack
);
if
let
Some
(
stack_shared
)
=
stack_option
{
if
flags
&
CLONE_STACK
==
CLONE_STACK
{
let
frame
=
active_table
.p4
()[::
USER_STACK_PML4
]
.pointed_frame
()
.expect
(
"user stack not mapped"
);
let
flags
=
active_table
.p4
()[::
USER_STACK_PML4
]
.flags
();
active_table
.with
(
&
mut
new_table
,
&
mut
temporary_page
,
|
mapper
|
{
mapper
.p4_mut
()[::
USER_STACK_PML4
]
.set
(
frame
,
flags
);
});
}
else
{
stack_shared
.with
(|
stack
|
{
stack
.move_to
(
VirtualAddress
::
new
(::
USER_STACK_OFFSET
),
&
mut
new_table
,
&
mut
temporary_page
);
});
}
context
.stack
=
Some
(
stack_shared
);
}
// Setup user sigstack
...
...
@@ -652,7 +668,7 @@ fn fexec_noreturn(
::
USER_STACK_SIZE
,
EntryFlags
::
NO_EXECUTE
|
EntryFlags
::
WRITABLE
|
EntryFlags
::
USER_ACCESSIBLE
,
true
));
)
.to_shared
()
);
// Map stack
context
.sigstack
=
Some
(
context
::
memory
::
Memory
::
new
(
...
...
syscall
@
11fb32af
Compare
54839d42
...
11fb32af
Subproject commit
54839d42f495e339062b1d3480415544033d0c0c
Subproject commit
11fb32afb0371789be1849e504d3421b34ef1c01
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment