diff options
author | Chris Metcalf <cmetcalf@ezchip.com> | 2016-01-25 15:05:34 -0500 |
---|---|---|
committer | Chris Metcalf <cmetcalf@ezchip.com> | 2016-03-02 15:19:44 -0500 |
commit | 77ef8f5177599efd0cedeb52c1950c1bd73fa5e3 (patch) | |
tree | b6091bf407bc008da5fd6e68d4eaca4d543efe58 | |
parent | 81f70ba233d5f660e1ea5fe23260ee323af5d53a (diff) |
tile kgdb: fix bug in copy to gdb regs, and optimize memset
David Binderman pointed out that we were doing a full memset()
of the gdb register buffer and then doing a memcpy() to it that
was almost as big. This commit optimizes that by only doing a
memset() of the registers that are intended to be zero.
While making this change I noticed that we were not copying the
link register (LR, number 55) due to a fencepost error in commit
f419e6f63c5a ("arch: tile: kernel: kgdb.c: Use memcpy() instead of
pointer copy one by one"), and I've corrected that as well.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
-rw-r--r-- | arch/tile/kernel/kgdb.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/arch/tile/kernel/kgdb.c b/arch/tile/kernel/kgdb.c index a506c2c28943..6ad99925900e 100644 --- a/arch/tile/kernel/kgdb.c +++ b/arch/tile/kernel/kgdb.c | |||
@@ -126,15 +126,15 @@ void | |||
126 | sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task) | 126 | sleeping_thread_to_gdb_regs(unsigned long *gdb_regs, struct task_struct *task) |
127 | { | 127 | { |
128 | struct pt_regs *thread_regs; | 128 | struct pt_regs *thread_regs; |
129 | const int NGPRS = TREG_LAST_GPR + 1; | ||
129 | 130 | ||
130 | if (task == NULL) | 131 | if (task == NULL) |
131 | return; | 132 | return; |
132 | 133 | ||
133 | /* Initialize to zero. */ | ||
134 | memset(gdb_regs, 0, NUMREGBYTES); | ||
135 | |||
136 | thread_regs = task_pt_regs(task); | 134 | thread_regs = task_pt_regs(task); |
137 | memcpy(gdb_regs, thread_regs, TREG_LAST_GPR * sizeof(unsigned long)); | 135 | memcpy(gdb_regs, thread_regs, NGPRS * sizeof(unsigned long)); |
136 | memset(&gdb_regs[NGPRS], 0, | ||
137 | (TILEGX_PC_REGNUM - NGPRS) * sizeof(unsigned long)); | ||
138 | gdb_regs[TILEGX_PC_REGNUM] = thread_regs->pc; | 138 | gdb_regs[TILEGX_PC_REGNUM] = thread_regs->pc; |
139 | gdb_regs[TILEGX_FAULTNUM_REGNUM] = thread_regs->faultnum; | 139 | gdb_regs[TILEGX_FAULTNUM_REGNUM] = thread_regs->faultnum; |
140 | } | 140 | } |