From 56f55a3b97c9d51317500b776e45583a8cc72c71 Mon Sep 17 00:00:00 2001 From: jD91mZM2 <me@krake.one> Date: Wed, 8 Jul 2020 11:47:12 +0200 Subject: [PATCH] Always save proccess registers Not sure if this is going to be required, and I'm not sure if this will hurt performance, y'know, *always* doing this. --- src/arch/x86_64/interrupt/exception.rs | 8 -------- src/arch/x86_64/interrupt/irq.rs | 1 - src/arch/x86_64/macros.rs | 1 + 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/arch/x86_64/interrupt/exception.rs b/src/arch/x86_64/interrupt/exception.rs index b55a13e..5c0e8ea 100644 --- a/src/arch/x86_64/interrupt/exception.rs +++ b/src/arch/x86_64/interrupt/exception.rs @@ -18,8 +18,6 @@ interrupt_stack!(divide_by_zero, stack, { interrupt_stack!(debug, stack, { let mut handled = false; - let guard = ptrace::set_process_regs(stack); - // Disable singlestep before there is a breakpoint, since the breakpoint // handler might end up setting it again but unless it does we want the // default to be false. @@ -33,8 +31,6 @@ interrupt_stack!(debug, stack, { stack.set_singlestep(had_singlestep); } - drop(guard); - if !handled { println!("Debug trap"); stack.dump(); @@ -61,11 +57,7 @@ interrupt_stack!(breakpoint, stack, { // int3 instruction. After all, it's the sanest thing to do. stack.iret.rip -= 1; - let guard = ptrace::set_process_regs(stack); - if ptrace::breakpoint_callback(PTRACE_STOP_BREAKPOINT, None).is_none() { - drop(guard); - println!("Breakpoint trap"); stack.dump(); ksignal(SIGTRAP); diff --git a/src/arch/x86_64/interrupt/irq.rs b/src/arch/x86_64/interrupt/irq.rs index a01196f..291879c 100644 --- a/src/arch/x86_64/interrupt/irq.rs +++ b/src/arch/x86_64/interrupt/irq.rs @@ -189,7 +189,6 @@ interrupt_stack!(pit, stack, { timeout::trigger(); if PIT_TICKS.fetch_add(1, Ordering::SeqCst) >= 10 { - let _guard = ptrace::set_process_regs(stack); let _ = context::switch(); } }); diff --git a/src/arch/x86_64/macros.rs b/src/arch/x86_64/macros.rs index 29d0d10..f3d54d9 100644 --- a/src/arch/x86_64/macros.rs +++ b/src/arch/x86_64/macros.rs @@ -335,6 +335,7 @@ macro_rules! interrupt_stack { pub unsafe extern fn $name () { #[inline(never)] unsafe fn inner($stack: &mut $crate::arch::x86_64::macros::InterruptStack) { + let _guard = ptrace::set_process_regs($stack); $func } -- GitLab