Downgrade context sigcontrol to read
This commit is contained in:
@@ -453,12 +453,11 @@ impl Context {
|
||||
let kstack = self.kstack.as_ref()?;
|
||||
Some(unsafe { &mut *kstack.initial_top().sub(size_of::<InterruptStack>()).cast() })
|
||||
}
|
||||
pub fn sigcontrol(&mut self) -> Option<(&Sigcontrol, &SigProcControl, &mut SignalState)> {
|
||||
Some(Self::sigcontrol_raw(self.sig.as_mut()?))
|
||||
pub fn sigcontrol(&self) -> Option<(&Sigcontrol, &SigProcControl, &SignalState)> {
|
||||
let (for_thread, for_proc) = Self::sigcontrol_raw(self.sig.as_ref()?);
|
||||
Some((for_thread, for_proc, self.sig.as_ref()?))
|
||||
}
|
||||
pub fn sigcontrol_raw(
|
||||
sig: &mut SignalState,
|
||||
) -> (&Sigcontrol, &SigProcControl, &mut SignalState) {
|
||||
pub fn sigcontrol_raw(sig: &SignalState) -> (&Sigcontrol, &SigProcControl) {
|
||||
let check = |off| {
|
||||
assert_eq!(usize::from(off) % align_of::<usize>(), 0);
|
||||
assert!(usize::from(off).saturating_add(size_of::<Sigcontrol>()) < PAGE_SIZE);
|
||||
@@ -475,7 +474,7 @@ impl Context {
|
||||
.byte_add(usize::from(sig.procctl_off))
|
||||
};
|
||||
|
||||
(for_thread, for_proc, sig)
|
||||
(for_thread, for_proc)
|
||||
}
|
||||
pub fn caller_ctx(&self) -> CallerCtx {
|
||||
CallerCtx {
|
||||
|
||||
@@ -4,13 +4,12 @@ use crate::{context, sync::CleanLockToken, syscall::flag::SigcontrolFlags};
|
||||
|
||||
pub fn signal_handler(token: &mut CleanLockToken) {
|
||||
let context_lock = context::current();
|
||||
let mut context_guard = context_lock.write(token.token());
|
||||
let context = &mut *context_guard;
|
||||
let context = context_lock.upgradeable_read(token.token());
|
||||
|
||||
let being_sigkilled = context.being_sigkilled;
|
||||
|
||||
if being_sigkilled {
|
||||
drop(context_guard);
|
||||
drop(context);
|
||||
drop(context_lock);
|
||||
crate::syscall::process::exit_this_context(None, token);
|
||||
}
|
||||
@@ -48,6 +47,7 @@ pub fn signal_handler(token: &mut CleanLockToken) {
|
||||
|
||||
let sigh_instr_ptr = st.user_handler.get();
|
||||
|
||||
let mut context = context.upgrade();
|
||||
let Some(regs) = context.regs_mut() else {
|
||||
// TODO: is this even reachable?
|
||||
trace!("No registers, returning");
|
||||
@@ -59,6 +59,7 @@ pub fn signal_handler(token: &mut CleanLockToken) {
|
||||
|
||||
regs.set_instr_pointer(sigh_instr_ptr);
|
||||
|
||||
let mut context = context.downgrade();
|
||||
let (thread_ctl, _, _) = context
|
||||
.sigcontrol()
|
||||
.expect("cannot have been unset while holding the lock");
|
||||
|
||||
Reference in New Issue
Block a user