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
redox-os
relibc
Commits
a1e1a159
Verified
Commit
a1e1a159
authored
9 months ago
by
Jacob Lorentzon
Browse files
Options
Downloads
Patches
Plain Diff
Initialize altstack properly.
parent
a265c8b7
No related branches found
Branches containing commit
No related tags found
1 merge request
!480
Refactor redox runtime and impl signals in userspace
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
redox-rt/src/arch/x86_64.rs
+3
-3
3 additions, 3 deletions
redox-rt/src/arch/x86_64.rs
redox-rt/src/signal.rs
+21
-9
21 additions, 9 deletions
redox-rt/src/signal.rs
src/start.rs
+1
-1
1 addition, 1 deletion
src/start.rs
with
25 additions
and
13 deletions
redox-rt/src/arch/x86_64.rs
+
3
−
3
View file @
a1e1a159
...
...
@@ -14,9 +14,9 @@ pub(crate) const STACK_SIZE: usize = 1024 * 1024;
#[derive(Debug,
Default)]
pub
struct
SigArea
{
altstack_top
:
usize
,
altstack_bottom
:
usize
,
tmp
:
usize
,
pub
altstack_top
:
usize
,
pub
altstack_bottom
:
usize
,
pub
tmp
:
usize
,
pub
onstack
:
u64
,
pub
disable_signals_depth
:
u64
,
}
...
...
This diff is collapsed.
Click to expand it.
redox-rt/src/signal.rs
+
21
−
9
View file @
a1e1a159
use
core
::
cell
::
Cell
;
use
core
::
cell
::
{
Cell
,
UnsafeCell
}
;
use
core
::
ffi
::
c_int
;
use
core
::
sync
::
atomic
::{
AtomicU64
,
Ordering
};
...
...
@@ -43,6 +43,8 @@ pub struct SigStack {
#[inline(always)]
unsafe
fn
inner
(
stack
:
&
mut
SigStack
)
{
let
_
=
syscall
::
write
(
1
,
b"INNER SIGNAL HANDLER
\n
"
);
loop
{}
let
handler
:
extern
"C"
fn
(
c_int
)
=
core
::
mem
::
transmute
(
stack
.sa_handler
);
handler
(
stack
.sig_num
as
c_int
)
}
...
...
@@ -197,10 +199,12 @@ pub struct TmpDisableSignalsGuard { _inner: () }
pub
fn
tmp_disable_signals
()
->
TmpDisableSignalsGuard
{
unsafe
{
let
ctl
=
current_sigctl
()
.control_flags
.get
();
ctl
.write_volatile
(
ctl
.read_volatile
()
|
syscall
::
flag
::
INHIBIT_DELIVERY
);
let
ctl
=
&
current_sigctl
()
.control_flags
;
ctl
.store
(
ctl
.load
(
Ordering
::
Relaxed
)
|
syscall
::
flag
::
INHIBIT_DELIVERY
.bits
(),
Ordering
::
Release
);
core
::
sync
::
atomic
::
compiler_fence
(
Ordering
::
Acquire
);
// TODO: fence?
Tcb
::
current
()
.unwrap
()
.os_specific.arch.disable_signals_depth
+=
1
;
(
*
Tcb
::
current
()
.unwrap
()
.os_specific.arch
.
get
())
.
disable_signals_depth
+=
1
;
}
TmpDisableSignalsGuard
{
_inner
:
()
}
...
...
@@ -208,12 +212,13 @@ pub fn tmp_disable_signals() -> TmpDisableSignalsGuard {
impl
Drop
for
TmpDisableSignalsGuard
{
fn
drop
(
&
mut
self
)
{
unsafe
{
let
depth
=
&
mut
Tcb
::
current
()
.unwrap
()
.os_specific.arch.disable_signals_depth
;
let
depth
=
&
mut
(
*
Tcb
::
current
()
.unwrap
()
.os_specific.arch
.
get
())
.
disable_signals_depth
;
*
depth
-=
1
;
if
*
depth
==
0
{
let
ctl
=
current_sigctl
()
.control_flags
.get
();
ctl
.write_volatile
(
ctl
.read_volatile
()
&
!
syscall
::
flag
::
INHIBIT_DELIVERY
);
let
ctl
=
&
current_sigctl
()
.control_flags
;
ctl
.store
(
ctl
.load
(
Ordering
::
Relaxed
)
&
!
syscall
::
flag
::
INHIBIT_DELIVERY
.bits
(),
Ordering
::
Release
);
core
::
sync
::
atomic
::
compiler_fence
(
Ordering
::
Acquire
);
}
}
}
...
...
@@ -278,13 +283,20 @@ const fn sig_bit(sig: usize) -> u64 {
1
<<
(
sig
-
1
)
}
pub
fn
setup_sighandler
(
control
:
&
Sig
control
)
{
pub
fn
setup_sighandler
(
area
:
&
Rt
Sig
area
)
{
{
let
mut
sigactions
=
SIGACTIONS
.lock
();
}
let
arch
=
unsafe
{
&
mut
*
area
.arch
.get
()
};
#[cfg(target_arch
=
"x86_64"
)]
{
// The asm decides whether to use the altstack, based on whether the saved stack pointer
// was already on that stack. Thus, setting the altstack to the entire address space, is
// equivalent to not using any altstack at all (the default).
arch
.altstack_top
=
usize
::
MAX
;
arch
.altstack_bottom
=
0
;
let
cpuid_eax1_ecx
=
unsafe
{
core
::
arch
::
x86_64
::
__cpuid
(
1
)
}
.ecx
;
CPUID_EAX1_ECX
.store
(
cpuid_eax1_ecx
,
core
::
sync
::
atomic
::
Ordering
::
Relaxed
);
}
...
...
@@ -302,7 +314,7 @@ pub fn setup_sighandler(control: &Sigcontrol) {
#[derive(Debug,
Default)]
pub
struct
RtSigarea
{
pub
control
:
Sigcontrol
,
pub
arch
:
crate
::
arch
::
SigArea
,
pub
arch
:
UnsafeCell
<
crate
::
arch
::
SigArea
>
,
}
pub
fn
current_setsighandler_struct
()
->
SetSighandlerData
{
SetSighandlerData
{
...
...
This diff is collapsed.
Click to expand it.
src/start.rs
+
1
−
1
View file @
a1e1a159
...
...
@@ -158,7 +158,7 @@ pub unsafe extern "C" fn relibc_start(sp: &'static Stack) -> ! {
tcb
.linker_ptr
=
Box
::
into_raw
(
Box
::
new
(
Mutex
::
new
(
linker
)));
}
#[cfg(target_os
=
"redox"
)]
redox_rt
::
signal
::
setup_sighandler
(
&
tcb
.os_specific
.control
);
redox_rt
::
signal
::
setup_sighandler
(
&
tcb
.os_specific
);
}
// Set up argc and argv
...
...
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