* [PATCH] store sign-extend register values for PTRACE_GETREGS
@ 2007-03-03 17:41 Atsushi Nemoto
2007-10-25 15:53 ` Atsushi Nemoto
0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2007-03-03 17:41 UTC (permalink / raw)
To: linux-mips; +Cc: ralf
A comment on ptrace_getregs() states "Registers are sign extended to
fill the available space." but it is not true. Fix code to match the
comment. Also fix casts on each caller to get rid of some warnings.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 478355a..5560b6d 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -66,13 +66,13 @@ int ptrace_getregs (struct task_struct *
regs = task_pt_regs(child);
for (i = 0; i < 32; i++)
- __put_user (regs->regs[i], data + i);
- __put_user (regs->lo, data + EF_LO - EF_R0);
- __put_user (regs->hi, data + EF_HI - EF_R0);
- __put_user (regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
- __put_user (regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
- __put_user (regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
- __put_user (regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
+ __put_user ((long)regs->regs[i], data + i);
+ __put_user ((long)regs->lo, data + EF_LO - EF_R0);
+ __put_user ((long)regs->hi, data + EF_HI - EF_R0);
+ __put_user ((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
+ __put_user ((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
+ __put_user ((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
+ __put_user ((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
return 0;
}
@@ -403,11 +403,11 @@ long arch_ptrace(struct task_struct *chi
}
case PTRACE_GETREGS:
- ret = ptrace_getregs (child, (__u64 __user *) data);
+ ret = ptrace_getregs (child, (__s64 __user *) data);
break;
case PTRACE_SETREGS:
- ret = ptrace_setregs (child, (__u64 __user *) data);
+ ret = ptrace_setregs (child, (__s64 __user *) data);
break;
case PTRACE_GETFPREGS:
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index d9a39c1..2c60320 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -346,11 +346,11 @@ asmlinkage int sys32_ptrace(int request,
}
case PTRACE_GETREGS:
- ret = ptrace_getregs (child, (__u64 __user *) (__u64) data);
+ ret = ptrace_getregs (child, (__s64 __user *) (__u64) data);
break;
case PTRACE_SETREGS:
- ret = ptrace_setregs (child, (__u64 __user *) (__u64) data);
+ ret = ptrace_setregs (child, (__s64 __user *) (__u64) data);
break;
case PTRACE_GETFPREGS:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] store sign-extend register values for PTRACE_GETREGS
2007-03-03 17:41 [PATCH] store sign-extend register values for PTRACE_GETREGS Atsushi Nemoto
@ 2007-10-25 15:53 ` Atsushi Nemoto
2007-10-28 19:34 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2007-10-25 15:53 UTC (permalink / raw)
To: linux-mips; +Cc: ralf
On Sun, 04 Mar 2007 02:41:52 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> A comment on ptrace_getregs() states "Registers are sign extended to
> fill the available space." but it is not true. Fix code to match the
> comment. Also fix casts on each caller to get rid of some warnings.
Revised for current git tree.
------------------------------------------------------
Subject: [PATCH] store sign-extend register values for PTRACE_GETREGS
From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
A comment on ptrace_getregs() states "Registers are sign extended to
fill the available space." but it is not true. Fix code to match the
comment. Also fix casts on each caller to get rid of some warnings.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
arch/mips/kernel/ptrace.c | 18 +++++++++---------
arch/mips/kernel/ptrace32.c | 4 ++--
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
index 999f785..35234b9 100644
--- a/arch/mips/kernel/ptrace.c
+++ b/arch/mips/kernel/ptrace.c
@@ -65,13 +65,13 @@ int ptrace_getregs(struct task_struct *child, __s64 __user *data)
regs = task_pt_regs(child);
for (i = 0; i < 32; i++)
- __put_user(regs->regs[i], data + i);
- __put_user(regs->lo, data + EF_LO - EF_R0);
- __put_user(regs->hi, data + EF_HI - EF_R0);
- __put_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
- __put_user(regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
- __put_user(regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
- __put_user(regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
+ __put_user((long)regs->regs[i], data + i);
+ __put_user((long)regs->lo, data + EF_LO - EF_R0);
+ __put_user((long)regs->hi, data + EF_HI - EF_R0);
+ __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
+ __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
+ __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
+ __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
return 0;
}
@@ -390,11 +390,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
}
case PTRACE_GETREGS:
- ret = ptrace_getregs(child, (__u64 __user *) data);
+ ret = ptrace_getregs(child, (__s64 __user *) data);
break;
case PTRACE_SETREGS:
- ret = ptrace_setregs(child, (__u64 __user *) data);
+ ret = ptrace_setregs(child, (__s64 __user *) data);
break;
case PTRACE_GETFPREGS:
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
index f2bffed..76818be 100644
--- a/arch/mips/kernel/ptrace32.c
+++ b/arch/mips/kernel/ptrace32.c
@@ -346,11 +346,11 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
}
case PTRACE_GETREGS:
- ret = ptrace_getregs(child, (__u64 __user *) (__u64) data);
+ ret = ptrace_getregs(child, (__s64 __user *) (__u64) data);
break;
case PTRACE_SETREGS:
- ret = ptrace_setregs(child, (__u64 __user *) (__u64) data);
+ ret = ptrace_setregs(child, (__s64 __user *) (__u64) data);
break;
case PTRACE_GETFPREGS:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] store sign-extend register values for PTRACE_GETREGS
2007-10-25 15:53 ` Atsushi Nemoto
@ 2007-10-28 19:34 ` Ralf Baechle
2007-10-28 19:52 ` Daniel Jacobowitz
0 siblings, 1 reply; 5+ messages in thread
From: Ralf Baechle @ 2007-10-28 19:34 UTC (permalink / raw)
To: Atsushi Nemoto, Daniel Jacobowitz; +Cc: linux-mips
On Fri, Oct 26, 2007 at 12:53:02AM +0900, Atsushi Nemoto wrote:
Daniel, do you see any debugger compatibility issues with this patch?
> From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> Date: Fri, 26 Oct 2007 00:53:02 +0900 (JST)
> To: linux-mips@linux-mips.org
> Cc: ralf@linux-mips.org
> Subject: Re: [PATCH] store sign-extend register values for PTRACE_GETREGS
> Content-Type: Text/Plain; charset=us-ascii
>
> On Sun, 04 Mar 2007 02:41:52 +0900 (JST), Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:
> > A comment on ptrace_getregs() states "Registers are sign extended to
> > fill the available space." but it is not true. Fix code to match the
> > comment. Also fix casts on each caller to get rid of some warnings.
>
> Revised for current git tree.
>
> ------------------------------------------------------
> Subject: [PATCH] store sign-extend register values for PTRACE_GETREGS
> From: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
>
> A comment on ptrace_getregs() states "Registers are sign extended to
> fill the available space." but it is not true. Fix code to match the
> comment. Also fix casts on each caller to get rid of some warnings.
>
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> arch/mips/kernel/ptrace.c | 18 +++++++++---------
> arch/mips/kernel/ptrace32.c | 4 ++--
> 2 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
> index 999f785..35234b9 100644
> --- a/arch/mips/kernel/ptrace.c
> +++ b/arch/mips/kernel/ptrace.c
> @@ -65,13 +65,13 @@ int ptrace_getregs(struct task_struct *child, __s64 __user *data)
> regs = task_pt_regs(child);
>
> for (i = 0; i < 32; i++)
> - __put_user(regs->regs[i], data + i);
> - __put_user(regs->lo, data + EF_LO - EF_R0);
> - __put_user(regs->hi, data + EF_HI - EF_R0);
> - __put_user(regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
> - __put_user(regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
> - __put_user(regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
> - __put_user(regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
> + __put_user((long)regs->regs[i], data + i);
> + __put_user((long)regs->lo, data + EF_LO - EF_R0);
> + __put_user((long)regs->hi, data + EF_HI - EF_R0);
> + __put_user((long)regs->cp0_epc, data + EF_CP0_EPC - EF_R0);
> + __put_user((long)regs->cp0_badvaddr, data + EF_CP0_BADVADDR - EF_R0);
> + __put_user((long)regs->cp0_status, data + EF_CP0_STATUS - EF_R0);
> + __put_user((long)regs->cp0_cause, data + EF_CP0_CAUSE - EF_R0);
>
> return 0;
> }
> @@ -390,11 +390,11 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
> }
>
> case PTRACE_GETREGS:
> - ret = ptrace_getregs(child, (__u64 __user *) data);
> + ret = ptrace_getregs(child, (__s64 __user *) data);
> break;
>
> case PTRACE_SETREGS:
> - ret = ptrace_setregs(child, (__u64 __user *) data);
> + ret = ptrace_setregs(child, (__s64 __user *) data);
> break;
>
> case PTRACE_GETFPREGS:
> diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c
> index f2bffed..76818be 100644
> --- a/arch/mips/kernel/ptrace32.c
> +++ b/arch/mips/kernel/ptrace32.c
> @@ -346,11 +346,11 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data)
> }
>
> case PTRACE_GETREGS:
> - ret = ptrace_getregs(child, (__u64 __user *) (__u64) data);
> + ret = ptrace_getregs(child, (__s64 __user *) (__u64) data);
> break;
>
> case PTRACE_SETREGS:
> - ret = ptrace_setregs(child, (__u64 __user *) (__u64) data);
> + ret = ptrace_setregs(child, (__s64 __user *) (__u64) data);
> break;
>
> case PTRACE_GETFPREGS:
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] store sign-extend register values for PTRACE_GETREGS
2007-10-28 19:34 ` Ralf Baechle
@ 2007-10-28 19:52 ` Daniel Jacobowitz
2007-10-29 18:31 ` Ralf Baechle
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Jacobowitz @ 2007-10-28 19:52 UTC (permalink / raw)
To: Ralf Baechle; +Cc: Atsushi Nemoto, linux-mips
On Sun, Oct 28, 2007 at 07:34:21PM +0000, Ralf Baechle wrote:
> On Fri, Oct 26, 2007 at 12:53:02AM +0900, Atsushi Nemoto wrote:
>
> Daniel, do you see any debugger compatibility issues with this patch?
I don't think so; I'm pretty sure I wrote the code at fault here,
and I can't remember any reason I would have deliberately made the
registers unsigned. Looking at the fix I think I just guessed
wrong about the type used by __put_user.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] store sign-extend register values for PTRACE_GETREGS
2007-10-28 19:52 ` Daniel Jacobowitz
@ 2007-10-29 18:31 ` Ralf Baechle
0 siblings, 0 replies; 5+ messages in thread
From: Ralf Baechle @ 2007-10-29 18:31 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Atsushi Nemoto, linux-mips
On Sun, Oct 28, 2007 at 03:52:11PM -0400, Daniel Jacobowitz wrote:
> On Sun, Oct 28, 2007 at 07:34:21PM +0000, Ralf Baechle wrote:
> > On Fri, Oct 26, 2007 at 12:53:02AM +0900, Atsushi Nemoto wrote:
> >
> > Daniel, do you see any debugger compatibility issues with this patch?
>
> I don't think so; I'm pretty sure I wrote the code at fault here,
> and I can't remember any reason I would have deliberately made the
> registers unsigned. Looking at the fix I think I just guessed
> wrong about the type used by __put_user.
Good. So I just applied it.
Ralf
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-10-29 18:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-03 17:41 [PATCH] store sign-extend register values for PTRACE_GETREGS Atsushi Nemoto
2007-10-25 15:53 ` Atsushi Nemoto
2007-10-28 19:34 ` Ralf Baechle
2007-10-28 19:52 ` Daniel Jacobowitz
2007-10-29 18:31 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox