summaryrefslogtreecommitdiff
path: root/Kernel/Arch/i386/CPU.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-08 19:34:41 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-08 19:34:41 +0100
commitf39c2b653e32ee8f05a4cfc285315cf980224054 (patch)
tree5302b12ddfe7ddee7f9a4d95932a32d421fde566 /Kernel/Arch/i386/CPU.cpp
parent45231051e62b82b3214c4bc2d0b3674cdd083d10 (diff)
downloadserenity-f39c2b653e32ee8f05a4cfc285315cf980224054.zip
Kernel: Reorganize ptrace implementation a bit
The generic parts of ptrace now live in Kernel/Syscalls/ptrace.cpp and the i386 specific parts are moved to Arch/i386/CPU.cpp
Diffstat (limited to 'Kernel/Arch/i386/CPU.cpp')
-rw-r--r--Kernel/Arch/i386/CPU.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index 798e946f22..59d80c2d2b 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -2264,6 +2264,40 @@ void Processor::set_thread_specific(u8* data, size_t len)
descriptor.set_limit(len);
}
+void copy_kernel_registers_into_ptrace_registers(PtraceRegisters& ptrace_regs, const RegisterState& kernel_regs)
+{
+ ptrace_regs.eax = kernel_regs.eax,
+ ptrace_regs.ecx = kernel_regs.ecx,
+ ptrace_regs.edx = kernel_regs.edx,
+ ptrace_regs.ebx = kernel_regs.ebx,
+ ptrace_regs.esp = kernel_regs.userspace_esp,
+ ptrace_regs.ebp = kernel_regs.ebp,
+ ptrace_regs.esi = kernel_regs.esi,
+ ptrace_regs.edi = kernel_regs.edi,
+ ptrace_regs.eip = kernel_regs.eip,
+ ptrace_regs.eflags = kernel_regs.eflags,
+ ptrace_regs.cs = 0;
+ ptrace_regs.ss = 0;
+ ptrace_regs.ds = 0;
+ ptrace_regs.es = 0;
+ ptrace_regs.fs = 0;
+ ptrace_regs.gs = 0;
+}
+
+void copy_ptrace_registers_into_kernel_registers(RegisterState& kernel_regs, const PtraceRegisters& ptrace_regs)
+{
+ kernel_regs.eax = ptrace_regs.eax;
+ kernel_regs.ecx = ptrace_regs.ecx;
+ kernel_regs.edx = ptrace_regs.edx;
+ kernel_regs.ebx = ptrace_regs.ebx;
+ kernel_regs.esp = ptrace_regs.esp;
+ kernel_regs.ebp = ptrace_regs.ebp;
+ kernel_regs.esi = ptrace_regs.esi;
+ kernel_regs.edi = ptrace_regs.edi;
+ kernel_regs.eip = ptrace_regs.eip;
+ kernel_regs.eflags = (kernel_regs.eflags & ~safe_eflags_mask) | (ptrace_regs.eflags & safe_eflags_mask);
+}
+
}
#ifdef DEBUG