From: Michael Neuling <mikey@neuling.org>
To: Kumar Gala <galak@kernel.crashing.org>
Cc: linuxppc-dev@ozlabs.org, Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct.
Date: Wed, 25 Jun 2008 10:25:18 +1000 [thread overview]
Message-ID: <13124.1214353518@neuling.org> (raw)
In-Reply-To: <0DCAAAC2-52AB-4704-98C0-4E9235C3AC88@kernel.crashing.org>
In message <0DCAAAC2-52AB-4704-98C0-4E9235C3AC88@kernel.crashing.org> you wrote
:
>
> On Jun 24, 2008, at 5:57 AM, Michael Neuling wrote:
>
> > We are going to change where the floating point registers are stored
> > in the thread_struct, so in preparation add some macros to access the
> > floating point registers. Update all code to use these new macros.
> >
> > Signed-off-by: Michael Neuling <mikey@neuling.org>
> > ---
> >
> > arch/powerpc/kernel/align.c | 6 ++--
> > arch/powerpc/kernel/process.c | 5 ++-
> > arch/powerpc/kernel/ptrace.c | 14 +++++----
> > arch/powerpc/kernel/ptrace32.c | 14 +++++++--
> > arch/powerpc/kernel/softemu8xx.c | 4 +-
> > arch/powerpc/math-emu/math.c | 56 ++++++++++++++++++
> > +--------------------
> > include/asm-powerpc/ppc_asm.h | 5 ++-
> > include/asm-powerpc/processor.h | 3 ++
> > 8 files changed, 61 insertions(+), 46 deletions(-)
> >
>
> > Index: linux-2.6-ozlabs/arch/powerpc/kernel/ptrace.c
> > ===================================================================
> > --- linux-2.6-ozlabs.orig/arch/powerpc/kernel/ptrace.c
> > +++ linux-2.6-ozlabs/arch/powerpc/kernel/ptrace.c
> > @@ -218,10 +218,10 @@ static int fpr_get(struct task_struct *t
> > flush_fp_to_thread(target);
> >
> > BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
> > - offsetof(struct thread_struct, fpr[32]));
> > + offsetof(struct thread_struct, TS_FPR(32)));
> >
> > return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> > - &target->thread.fpr, 0, -1);
> > + target->thread.fpr, 0, -1);
>
> is there a reason we can drop the '&'? (I'm only look at this as a
> textual diff, not at what the code is trying to do).
Oops.. I'll fix.
> >
> > }
> >
> > static int fpr_set(struct task_struct *target, const struct
> > user_regset *regset,
> > @@ -231,10 +231,10 @@ static int fpr_set(struct task_struct *t
> > flush_fp_to_thread(target);
> >
> > BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
> > - offsetof(struct thread_struct, fpr[32]));
> > + offsetof(struct thread_struct, TS_FPR(32)));
> >
> > return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
> > - &target->thread.fpr, 0, -1);
> > + target->thread.fpr, 0, -1);
>
> ditto.
> >
> > }
> >
> >
> > @@ -728,7 +728,8 @@ long arch_ptrace(struct task_struct *chi
> > tmp = ptrace_get_reg(child, (int) index);
> > } else {
> > flush_fp_to_thread(child);
> > - tmp = ((unsigned long *)child->thread.fpr)[index - PT_F
PR0];
> > + tmp = ((unsigned long *)child->thread.fpr)
> > + [TS_FPRSPACING * (index - PT_FPR0)];
> > }
> > ret = put_user(tmp,(unsigned long __user *) data);
> > break;
> > @@ -755,7 +756,8 @@ long arch_ptrace(struct task_struct *chi
> > ret = ptrace_put_reg(child, index, data);
> > } else {
> > flush_fp_to_thread(child);
> > - ((unsigned long *)child->thread.fpr)[index - PT_FPR0] =
data;
> > + ((unsigned long *)child->thread.fpr)
> > + [TS_FPRSPACING * (index - PT_FPR0)] = data;
> > ret = 0;
> > }
> > break;
> > Index: linux-2.6-ozlabs/arch/powerpc/kernel/ptrace32.c
> > ===================================================================
> > --- linux-2.6-ozlabs.orig/arch/powerpc/kernel/ptrace32.c
> > +++ linux-2.6-ozlabs/arch/powerpc/kernel/ptrace32.c
> > @@ -64,6 +64,11 @@ static long compat_ptrace_old(struct tas
> > return -EPERM;
> > }
> >
> > +/* Macros to workout the correct index for the FPR in the thread
> > struct */
> > +#define FPRNUMBER(i) (((i) - PT_FPR0) >> 1)
> > +#define FPRHALF(i) (((i) - PT_FPR0) % 2)
> > +#define FPRINDEX(i) TS_FPRSPACING * FPRNUMBER(i) + FPRHALF(i)
>
> we should either use this macros in both ptrace.c and ptrace32.c or
> drop them
This set of macros is really only 32 bit specific since in ptrace 32 we
access the registers as 32 bits (hence needing two accesses to get the
full 64 bits), but in ptrace 64, we access them as 64 bit (hence only 1
access).
Theses macros are really only here to deal with the unique indexing into
the thread struct that we now need to do for ptrace 32 only (thanks to
paulus who pointed out I got this wrong first time).
The only macro here that could potentially be reused is FPRNUMER(i).
>
> >
> > +
> > long compat_arch_ptrace(struct task_struct *child, compat_long_t
> > request,
> > compat_ulong_t caddr, compat_ulong_t cdata)
> > {
> > @@ -122,7 +127,8 @@ long compat_arch_ptrace(struct task_stru
> > * to be an array of unsigned int (32 bits) - the
> > * index passed in is based on this assumption.
> > */
> > - tmp = ((unsigned int *)child->thread.fpr)[index - PT_FP
R0];
> > + tmp = ((unsigned int *)child->thread.fpr)
> > + [FPRINDEX(index)];
> > }
> > ret = put_user((unsigned int)tmp, (u32 __user *)data);
> > break;
> > @@ -162,7 +168,8 @@ long compat_arch_ptrace(struct task_stru
> > CHECK_FULL_REGS(child->thread.regs);
> > if (numReg >= PT_FPR0) {
> > flush_fp_to_thread(child);
> > - tmp = ((unsigned long int *)child->thread.fpr)[numReg -
PT_FPR0];
> > + tmp = ((unsigned long int *)child->thread.fpr)
> > + [FPRINDEX(numReg)];
> > } else { /* register within PT_REGS struct */
> > tmp = ptrace_get_reg(child, numReg);
> > }
> > @@ -217,7 +224,8 @@ long compat_arch_ptrace(struct task_stru
> > * to be an array of unsigned int (32 bits) - the
> > * index passed in is based on this assumption.
> > */
> > - ((unsigned int *)child->thread.fpr)[index - PT_FPR0] =
data;
> > + ((unsigned int *)child->thread.fpr)
> > + [TS_FPRSPACING * (index - PT_FPR0)] = data;
>
> is there a reason this isn't FPRINDEX(index)?
Oops, fixed.
Can you tell I only tested peek not poke user :-D
>
> - k
>
next prev parent reply other threads:[~2008-06-25 0:25 UTC|newest]
Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-18 0:47 [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Michael Neuling
2008-06-18 0:47 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-18 14:53 ` Kumar Gala
2008-06-18 23:55 ` Michael Neuling
2008-06-18 0:47 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-18 0:47 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-18 0:47 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-18 0:47 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-18 19:35 ` Kumar Gala
2008-06-18 22:58 ` Paul Mackerras
2008-06-19 4:13 ` Kumar Gala
2008-06-19 4:30 ` Michael Neuling
2008-06-19 4:22 ` Kumar Gala
2008-06-19 4:35 ` Michael Neuling
2008-06-19 4:58 ` Kumar Gala
2008-06-19 5:37 ` Michael Neuling
2008-06-19 5:47 ` Kumar Gala
2008-06-19 6:01 ` Michael Neuling
2008-06-19 6:10 ` Kumar Gala
2008-06-19 9:33 ` Benjamin Herrenschmidt
2008-06-19 13:24 ` Kumar Gala
2008-06-18 0:47 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
2008-06-18 0:47 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-18 0:47 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-18 16:28 ` Joel Schopp
2008-06-19 6:51 ` David Woodhouse
2008-06-19 7:00 ` Michael Neuling
2008-06-18 0:47 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-18 13:05 ` [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Kumar Gala
2008-06-18 23:54 ` Michael Neuling
2008-06-20 4:13 ` Michael Neuling
2008-06-20 4:13 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-20 6:39 ` Kumar Gala
2008-06-22 11:29 ` Michael Neuling
2008-06-20 4:13 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
2008-06-20 4:13 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-20 4:13 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-20 6:35 ` Kumar Gala
2008-06-20 4:13 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-20 6:44 ` Kumar Gala
2008-06-20 4:13 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-20 4:13 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-20 4:13 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-20 4:13 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-20 6:37 ` [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Kumar Gala
2008-06-20 8:15 ` Michael Neuling
2008-06-23 5:31 ` Michael Neuling
2008-06-23 5:31 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-23 5:31 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-23 5:31 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-23 5:31 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-23 5:31 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-23 5:31 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-23 5:31 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-23 5:31 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
2008-06-23 5:31 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-23 7:38 ` [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Michael Neuling
2008-06-23 7:38 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-23 14:46 ` Kumar Gala
2008-06-23 7:38 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-23 7:38 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-23 7:38 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-23 7:38 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-23 7:38 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-23 7:38 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
2008-06-23 7:38 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-23 7:38 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-24 10:57 ` [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Michael Neuling
2008-06-24 10:57 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-24 10:57 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-24 14:07 ` Kumar Gala
2008-06-24 16:33 ` Segher Boessenkool
2008-06-25 0:25 ` Michael Neuling [this message]
2008-06-24 10:57 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-24 13:47 ` Kumar Gala
2008-06-24 10:57 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-24 10:57 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
2008-06-24 14:19 ` Kumar Gala
2008-06-24 10:57 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-24 14:06 ` Kumar Gala
2008-06-25 0:06 ` Michael Neuling
2008-06-25 2:19 ` Kumar Gala
2008-06-24 10:57 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-24 14:19 ` Kumar Gala
2008-06-24 10:57 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-24 14:01 ` Kumar Gala
2008-06-24 10:57 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-25 4:07 ` [PATCH 0/9] powerpc: Add kernel support for POWER7 VSX Michael Neuling
2008-06-25 4:07 ` [PATCH 2/9] powerpc: Add macros to access floating point registers in thread_struct Michael Neuling
2008-06-25 14:08 ` Kumar Gala
2008-06-25 15:34 ` Scott Wood
2008-06-25 16:12 ` Gabriel Paubert
2008-06-25 16:17 ` Scott Wood
2008-06-25 17:07 ` Kumar Gala
2008-06-26 0:09 ` Michael Neuling
2008-06-26 7:07 ` [PATCH] " Michael Neuling
2008-06-26 10:44 ` [PATCH 2/9] " Gabriel Paubert
2008-06-25 17:08 ` Andreas Schwab
2008-06-25 4:07 ` [PATCH 1/9] powerpc: Fix msr setting in 32 bit signal code Michael Neuling
2008-06-25 4:07 ` [PATCH 7/9] powerpc: Add VSX assembler code macros Michael Neuling
2008-06-25 4:07 ` [PATCH 8/9] powerpc: Add VSX context save/restore, ptrace and signal support Michael Neuling
2008-06-25 4:07 ` [PATCH 5/9] powerpc: Introduce VSX thread_struct and CONFIG_VSX Michael Neuling
2008-06-25 4:07 ` [PATCH 4/9] powerpc: Make load_up_fpu and load_up_altivec callable Michael Neuling
2008-06-25 4:07 ` [PATCH 6/9] powerpc: Add VSX CPU feature Michael Neuling
2008-06-25 4:07 ` [PATCH 3/9] powerpc: Move altivec_unavailable Michael Neuling
2008-06-25 4:07 ` [PATCH 9/9] powerpc: Add CONFIG_VSX config option Michael Neuling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13124.1214353518@neuling.org \
--to=mikey@neuling.org \
--cc=galak@kernel.crashing.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).