Date: Wed, 2 Mar 2011 20:04:54 +0000 (UTC) From: Dmitry Chagin <dchagin@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r219204 - in stable/8/sys: amd64/amd64 amd64/include i386/i386 i386/include Message-ID: <201103022004.p22K4sKI045902@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dchagin Date: Wed Mar 2 20:04:54 2011 New Revision: 219204 URL: http://svn.freebsd.org/changeset/base/219204 Log: MFC r218744: To avoid excessive code duplication create wrapper for fill regs from stack frame. Change the trap() code to use newly created function instead of explicit regs assignment. Modified: stable/8/sys/amd64/amd64/machdep.c stable/8/sys/amd64/amd64/trap.c stable/8/sys/amd64/include/reg.h stable/8/sys/i386/i386/machdep.c stable/8/sys/i386/i386/trap.c stable/8/sys/i386/include/reg.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/amd64/amd64/machdep.c ============================================================================== --- stable/8/sys/amd64/amd64/machdep.c Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/amd64/amd64/machdep.c Wed Mar 2 20:04:54 2011 (r219204) @@ -1848,6 +1848,12 @@ fill_regs(struct thread *td, struct reg struct trapframe *tp; tp = td->td_frame; + return (fill_frame_regs(tp, regs)); +} + +int +fill_frame_regs(struct trapframe *tp, struct reg *regs) +{ regs->r_r15 = tp->tf_r15; regs->r_r14 = tp->tf_r14; regs->r_r13 = tp->tf_r13; Modified: stable/8/sys/amd64/amd64/trap.c ============================================================================== --- stable/8/sys/amd64/amd64/trap.c Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/amd64/amd64/trap.c Wed Mar 2 20:04:54 2011 (r219204) @@ -253,38 +253,8 @@ trap(struct trapframe *frame) if (type == T_DTRACE_PROBE || type == T_DTRACE_RET || type == T_BPTFLT) { struct reg regs; - - regs.r_r15 = frame->tf_r15; - regs.r_r14 = frame->tf_r14; - regs.r_r13 = frame->tf_r13; - regs.r_r12 = frame->tf_r12; - regs.r_r11 = frame->tf_r11; - regs.r_r10 = frame->tf_r10; - regs.r_r9 = frame->tf_r9; - regs.r_r8 = frame->tf_r8; - regs.r_rdi = frame->tf_rdi; - regs.r_rsi = frame->tf_rsi; - regs.r_rbp = frame->tf_rbp; - regs.r_rbx = frame->tf_rbx; - regs.r_rdx = frame->tf_rdx; - regs.r_rcx = frame->tf_rcx; - regs.r_rax = frame->tf_rax; - regs.r_rip = frame->tf_rip; - regs.r_cs = frame->tf_cs; - regs.r_rflags = frame->tf_rflags; - regs.r_rsp = frame->tf_rsp; - regs.r_ss = frame->tf_ss; - if (frame->tf_flags & TF_HASSEGS) { - regs.r_ds = frame->tf_ds; - regs.r_es = frame->tf_es; - regs.r_fs = frame->tf_fs; - regs.r_gs = frame->tf_gs; - } else { - regs.r_ds = 0; - regs.r_es = 0; - regs.r_fs = 0; - regs.r_gs = 0; - } + + fill_frame_regs(frame, ®s); if (type == T_DTRACE_PROBE && dtrace_fasttrap_probe_ptr != NULL && dtrace_fasttrap_probe_ptr(®s) == 0) Modified: stable/8/sys/amd64/include/reg.h ============================================================================== --- stable/8/sys/amd64/include/reg.h Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/amd64/include/reg.h Wed Mar 2 20:04:54 2011 (r219204) @@ -130,6 +130,7 @@ struct dbreg { * XXX these interfaces are MI, so they should be declared in a MI place. */ int fill_regs(struct thread *, struct reg *); +int fill_frame_regs(struct trapframe *, struct reg *); int set_regs(struct thread *, struct reg *); int fill_fpregs(struct thread *, struct fpreg *); int set_fpregs(struct thread *, struct fpreg *); Modified: stable/8/sys/i386/i386/machdep.c ============================================================================== --- stable/8/sys/i386/i386/machdep.c Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/i386/i386/machdep.c Wed Mar 2 20:04:54 2011 (r219204) @@ -3113,6 +3113,13 @@ fill_regs(struct thread *td, struct reg tp = td->td_frame; pcb = td->td_pcb; + regs->r_gs = pcb->pcb_gs; + return (fill_frame_regs(tp, regs)); +} + +int +fill_frame_regs(struct trapframe *tp, struct reg *regs) +{ regs->r_fs = tp->tf_fs; regs->r_es = tp->tf_es; regs->r_ds = tp->tf_ds; @@ -3128,7 +3135,6 @@ fill_regs(struct thread *td, struct reg regs->r_eflags = tp->tf_eflags; regs->r_esp = tp->tf_esp; regs->r_ss = tp->tf_ss; - regs->r_gs = pcb->pcb_gs; return (0); } Modified: stable/8/sys/i386/i386/trap.c ============================================================================== --- stable/8/sys/i386/i386/trap.c Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/i386/i386/trap.c Wed Mar 2 20:04:54 2011 (r219204) @@ -275,21 +275,7 @@ trap(struct trapframe *frame) type == T_BPTFLT) { struct reg regs; - regs.r_fs = frame->tf_fs; - regs.r_es = frame->tf_es; - regs.r_ds = frame->tf_ds; - regs.r_edi = frame->tf_edi; - regs.r_esi = frame->tf_esi; - regs.r_ebp = frame->tf_ebp; - regs.r_ebx = frame->tf_ebx; - regs.r_edx = frame->tf_edx; - regs.r_ecx = frame->tf_ecx; - regs.r_eax = frame->tf_eax; - regs.r_eip = frame->tf_eip; - regs.r_cs = frame->tf_cs; - regs.r_eflags = frame->tf_eflags; - regs.r_esp = frame->tf_esp; - regs.r_ss = frame->tf_ss; + fill_frame_regs(frame, ®s); if (type == T_DTRACE_PROBE && dtrace_fasttrap_probe_ptr != NULL && dtrace_fasttrap_probe_ptr(®s) == 0) Modified: stable/8/sys/i386/include/reg.h ============================================================================== --- stable/8/sys/i386/include/reg.h Wed Mar 2 20:02:52 2011 (r219203) +++ stable/8/sys/i386/include/reg.h Wed Mar 2 20:04:54 2011 (r219204) @@ -161,6 +161,7 @@ struct dbreg { * XXX these interfaces are MI, so they should be declared in a MI place. */ int fill_regs(struct thread *, struct reg *); +int fill_frame_regs(struct trapframe *, struct reg *); int set_regs(struct thread *, struct reg *); int fill_fpregs(struct thread *, struct fpreg *); int set_fpregs(struct thread *, struct fpreg *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103022004.p22K4sKI045902>