Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
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
Peter Limkilde Svendsen
relibc
Commits
b58ad5bf
Verified
Commit
b58ad5bf
authored
2 years ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
In clone, use better asm function names and align.
parent
4e5ccbff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/platform/redox/clone.rs
+24
-15
24 additions, 15 deletions
src/platform/redox/clone.rs
with
24 additions
and
15 deletions
src/platform/redox/clone.rs
+
24
−
15
View file @
b58ad5bf
...
...
@@ -81,7 +81,7 @@ pub unsafe fn pte_clone_impl(stack: *mut usize) -> Result<usize> {
let
cur_addr_space_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
cur_pid_fd
,
b"addrspace"
)
?
);
let
new_addr_space_sel_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
new_pid_fd
,
b"current-addrspace"
)
?
);
let
buf
=
create_set_addr_space_buf
(
*
cur_addr_space_fd
,
pte_clone_ret
as
usize
,
stack
as
usize
);
let
buf
=
create_set_addr_space_buf
(
*
cur_addr_space_fd
,
__relibc_internal_
pte_clone_ret
as
usize
,
stack
as
usize
);
let
_
=
syscall
::
write
(
*
new_addr_space_sel_fd
,
&
buf
)
?
;
}
...
...
@@ -106,6 +106,7 @@ pub unsafe fn pte_clone_impl(stack: *mut usize) -> Result<usize> {
// Unblock context.
syscall
::
kill
(
new_pid
,
SIGCONT
)
?
;
let
_
=
syscall
::
waitpid
(
new_pid
,
&
mut
0
,
syscall
::
WUNTRACED
|
syscall
::
WCONTINUED
);
Ok
(
0
)
}
...
...
@@ -114,7 +115,7 @@ pub unsafe fn pte_clone_impl(stack: *mut usize) -> Result<usize> {
/// descriptors are reobtained through `fmap`. Other mappings are kept but duplicated using CoW.
pub
fn
fork_impl
()
->
Result
<
usize
>
{
unsafe
{
Error
::
demux
(
fork_wrapper
())
Error
::
demux
(
__relibc_internal_
fork_wrapper
())
}
}
...
...
@@ -209,7 +210,7 @@ fn fork_inner(initial_rsp: *mut usize) -> Result<usize> {
}
let
new_addr_space_sel_fd
=
FdGuard
::
new
(
syscall
::
dup
(
*
new_pid_fd
,
b"current-addrspace"
)
?
);
let
buf
=
create_set_addr_space_buf
(
*
new_addr_space_fd
,
fork_ret
as
usize
,
initial_rsp
as
usize
);
let
buf
=
create_set_addr_space_buf
(
*
new_addr_space_fd
,
__relibc_internal_
fork_ret
as
usize
,
initial_rsp
as
usize
);
let
_
=
syscall
::
write
(
*
new_addr_space_sel_fd
,
&
buf
)
?
;
}
copy_env_regs
(
*
cur_pid_fd
,
*
new_pid_fd
)
?
;
...
...
@@ -249,9 +250,9 @@ unsafe extern "sysv64" fn __relibc_internal_fork_hook(cur_filetable_fd: usize, n
#[no_mangle]
core
::
arch
::
global_asm!
(
"
.p2align 6
.globl fork_wrapper
.type fork_wrapper, @function
fork_wrapper:
.globl
__relibc_internal_
fork_wrapper
.type
__relibc_internal_
fork_wrapper, @function
__relibc_internal_
fork_wrapper:
push rbp
mov rbp, rsp
...
...
@@ -271,7 +272,11 @@ fork_wrapper:
call __relibc_internal_fork_impl
jmp 2f
fork_ret:
.size __relibc_internal_fork_wrapper, . - __relibc_internal_fork_wrapper
.p2align 6
.type __relibc_internal_fork_ret, @function
__relibc_internal_fork_ret:
mov rdi, [rsp]
mov rsi, [rsp + 8]
call __relibc_internal_fork_hook
...
...
@@ -280,6 +285,8 @@ fork_ret:
fldcw [rsp+24]
xor rax, rax
.p2align 4
2:
add rsp, 32
pop r15
...
...
@@ -291,11 +298,13 @@ fork_ret:
pop rbp
ret
.size fork_wrapper, . - fork_wrapper
.globl pte_clone_ret
.type pte_clone_ret, @function
pte_clone_ret:
.size __relibc_internal_fork_ret, . - __relibc_internal_fork_ret
.globl __relibc_internal_pte_clone_ret
.type __relibc_internal_pte_clone_ret, @function
.p2align 6
__relibc_internal_pte_clone_ret:
# Load registers
pop rax
pop rdi
...
...
@@ -318,11 +327,11 @@ pte_clone_ret:
call rax
ret
.size pte_clone_ret, . - pte_clone_ret
.size
__relibc_internal_
pte_clone_ret, . -
__relibc_internal_
pte_clone_ret
"
);
extern
"sysv64"
{
fn
fork_wrapper
()
->
usize
;
fn
fork_ret
();
fn
pte_clone_ret
();
fn
__relibc_internal_
fork_wrapper
()
->
usize
;
fn
__relibc_internal_
fork_ret
();
fn
__relibc_internal_
pte_clone_ret
();
}
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