Only save ip and 'archdep' regs when signalling.

This commit is contained in:
4lDO2
2024-06-27 11:15:16 +02:00
parent 12cfcfc6f2
commit e8060b259d
5 changed files with 7 additions and 36 deletions
+2 -5
View File
@@ -123,8 +123,8 @@ impl InterruptStack {
pub fn set_stack_pointer(&mut self, sp: usize) {
self.iret.sp_el0 = sp;
}
pub fn stack_pointer(&self) -> usize {
self.iret.sp_el0
pub fn sig_archdep_reg(&self) -> usize {
self.scratch.x0
}
pub fn set_instr_pointer(&mut self, ip: usize) {
self.iret.elr_el1 = ip;
@@ -132,9 +132,6 @@ impl InterruptStack {
pub fn instr_pointer(&self) -> usize {
self.iret.elr_el1
}
pub fn flags(&self) -> usize {
0 // TODO
}
// TODO: This can maybe be done in userspace?
pub fn set_syscall_ret_reg(&mut self, ret: usize) {
self.scratch.x0 = ret;
+1 -10
View File
@@ -13,12 +13,6 @@ pub struct ScratchRegisters {
}
impl ScratchRegisters {
pub fn a(&self) -> usize {
self.eax
}
pub fn b(&self) -> usize {
self.edx
}
pub fn dump(&self) {
println!("EAX: {:08x}", { self.eax });
println!("ECX: {:08x}", { self.ecx });
@@ -133,13 +127,10 @@ impl InterruptStack {
pub fn set_stack_pointer(&mut self, esp: usize) {
self.iret.esp = esp;
}
pub fn stack_pointer(&self) -> usize {
self.iret.esp
}
pub fn instr_pointer(&self) -> usize {
self.iret.eip
}
pub fn flags(&self) -> usize {
pub fn sig_archdep_reg(&self) -> usize {
self.iret.eflags
}
pub fn set_instr_pointer(&mut self, eip: usize) {
+1 -12
View File
@@ -107,13 +107,10 @@ impl InterruptStack {
pub fn set_stack_pointer(&mut self, rsp: usize) {
self.iret.rsp = rsp;
}
pub fn stack_pointer(&self) -> usize {
self.iret.rsp
}
pub fn instr_pointer(&self) -> usize {
self.iret.rip
}
pub fn flags(&self) -> usize {
pub fn sig_archdep_reg(&self) -> usize {
self.iret.rflags
}
pub fn set_instr_pointer(&mut self, rip: usize) {
@@ -199,14 +196,6 @@ impl InterruptStack {
self.iret.rflags & FLAG_SINGLESTEP == FLAG_SINGLESTEP
}
}
impl ScratchRegisters {
pub fn a(&self) -> usize {
self.rax
}
pub fn b(&self) -> usize {
self.rdx
}
}
#[macro_export]
macro_rules! push_scratch {
+2 -8
View File
@@ -83,10 +83,7 @@ pub fn signal_handler() {
};
let ip = regs.instr_pointer();
let sp = regs.stack_pointer();
let fl = regs.flags();
let scratch_a = regs.scratch.a();
let scratch_b = regs.scratch.b();
let archdep_reg = regs.sig_archdep_reg();
regs.set_instr_pointer(sigh_instr_ptr);
@@ -94,10 +91,7 @@ pub fn signal_handler() {
.expect("cannot have been unset while holding the lock");
thread_ctl.saved_ip.set(ip);
thread_ctl.saved_sp.set(sp);
thread_ctl.saved_flags.set(fl);
thread_ctl.saved_scratch_a.set(scratch_a);
thread_ctl.saved_scratch_b.set(scratch_b);
thread_ctl.saved_archdep_reg.set(archdep_reg);
thread_ctl.control_flags.store((control_flags | SigcontrolFlags::INHIBIT_DELIVERY).bits(), Ordering::Release);
}
+1 -1
Submodule syscall updated: bf01feb121...bda8fe89c6