Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
redox-os
kernel
Commits
b66fef04
Verified
Commit
b66fef04
authored
Apr 15, 2019
by
Jeremy Soller
Browse files
Copy TCB if it was not initialized using kernel-allocated TLS
parent
6da3ab28
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/syscall/process.rs
View file @
b66fef04
...
...
@@ -516,7 +516,7 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<ContextId> {
// Set up TCB
let
tcb_addr
=
::
USER_TCB_OFFSET
+
context
.id
.into
()
*
PAGE_SIZE
;
let
mut
tcb
_mem
=
context
::
memory
::
Memory
::
new
(
let
mut
tcb
=
context
::
memory
::
Memory
::
new
(
VirtualAddress
::
new
(
tcb_addr
),
PAGE_SIZE
,
EntryFlags
::
NO_EXECUTE
|
EntryFlags
::
WRITABLE
|
EntryFlags
::
USER_ACCESSIBLE
,
...
...
@@ -525,17 +525,22 @@ pub fn clone(flags: usize, stack_base: usize) -> Result<ContextId> {
// Setup user TLS
if
let
Some
(
mut
tls
)
=
tls_option
{
tls
.mem
.move_to
(
VirtualAddress
::
new
(::
USER_TLS_OFFSET
),
&
mut
new_table
,
&
mut
temporary_page
);
unsafe
{
*
(
tcb_addr
as
*
mut
usize
)
=
::
USER_TLS_OFFSET
+
tls
.mem
.size
();
*
(
tcb_addr
as
*
mut
usize
)
=
tls
.mem
.start_address
()
.get
()
+
tls
.mem
.size
();
}
tls
.mem
.move_to
(
VirtualAddress
::
new
(::
USER_TLS_OFFSET
),
&
mut
new_table
,
&
mut
temporary_page
);
context
.tls
=
Some
(
tls
);
}
else
{
let
parent_tcb_addr
=
::
USER_TCB_OFFSET
+
ppid
.into
()
*
PAGE_SIZE
;
unsafe
{
intrinsics
::
copy
(
parent_tcb_addr
as
*
const
u8
,
tcb_addr
as
*
mut
u8
,
tcb
.size
());
}
}
tcb_mem
.move_to
(
VirtualAddress
::
new
(
tcb_addr
),
&
mut
new_table
,
&
mut
temporary_page
);
context
.image
.push
(
tcb_mem
.to_shared
());
tcb
.move_to
(
VirtualAddress
::
new
(
tcb_addr
),
&
mut
new_table
,
&
mut
temporary_page
);
context
.image
.push
(
tcb
.to_shared
());
context
.name
=
name
;
...
...
Write
Preview
Supports
Markdown
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