LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 00/10 v6]  Fix 8xx MMU/TLB
From: Joakim Tjernlund @ 2009-11-27 10:57 UTC (permalink / raw)
  Cc: Scott Wood, linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <1258712471-3104-1-git-send-email-Joakim.Tjernlund@transmode.se>

Scott and Rex, I think we need you s-o-b to make it into the kernel proper.

Marcelo and Vitaly, I noticed you guys are listed as 8xx maintainers.
Have you seen this? What do you think?

        Jocke

Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote on 20/11/2009 11:21:01:
>
> Yet again an iteration of the series.
> Rex & Scott, please test and signoff.
> Changes since last version:
>  - Fix rlwimi insn(from Scott)
>
> Joakim Tjernlund (10):
>   8xx: invalidate non present TLBs
>   8xx: Update TLB asm so it behaves as linux mm expects.
>   8xx: Tag DAR with 0x00f0 to catch buggy instructions.
>   8xx: Always pin kernel instruction TLB
>   8xx: Fixup DAR from buggy dcbX instructions.
>   8xx: Add missing Guarded setting in DTLB Error.
>   8xx: Restore _PAGE_WRITETHRU
>   8xx: start using dcbX instructions in various copy routines
>   8xx: Remove DIRTY pte handling in DTLB Error.
>   8xx: DTLB Miss cleanup
>
>  arch/powerpc/include/asm/pte-8xx.h |   14 +-
>  arch/powerpc/kernel/head_8xx.S     |  315 ++++++++++++++++++++++--------------
>  arch/powerpc/kernel/misc_32.S      |   18 --
>  arch/powerpc/lib/copy_32.S         |   24 ---
>  arch/powerpc/mm/fault.c            |    8 +-
>  5 files changed, 211 insertions(+), 168 deletions(-)
>

^ permalink raw reply

* Re: [PATCH] fix PPC floating point debug
From: Benjamin Herrenschmidt @ 2009-11-27 11:01 UTC (permalink / raw)
  To: Stefani Seibold; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1259312340.9648.6.camel@wall-e>

On Fri, 2009-11-27 at 09:59 +0100, Stefani Seibold wrote:
> The PPC architecture is unable to debug applications using hardware
> floating point, because it would not save the floating point registers.
> 
> After returning from the debugger, the contents of register was
> modified. This patch fix this bug.

I'm not sure what problem you are trying to fix... debugging FP apps
works just fine afaik. You don't need to flush the FP state into the
thread when delivering the SIGTRAP. If you have a signal handler, that
will be done for you by the signal code before laying out the signal
frame. If you are using ptrace, you should be using the appropriate
ptrace calls to retrieve the FP state and they should do the right thing
to.

Do you have a precise example that doesn't work and which is fixed by
your patch ?

Cheers,
Ben.

> Signed-off-by: Stefani Seibold <stefani@seibold.net>
> ---
>  traps.c |    6 ++++++
>  1 file changed, 6 insertions(+)
> 
> --- linux-2.6.32-rc5/arch/powerpc/kernel/traps.c.orig	2009-11-27 09:47:37.989943124 +0100
> +++ linux-2.6.32-rc5/arch/powerpc/kernel/traps.c	2009-11-27 09:47:41.088330825 +0100
> @@ -559,6 +559,8 @@ void instruction_breakpoint_exception(st
>  		return;
>  	if (debugger_iabr_match(regs))
>  		return;
> +	if (regs->msr & MSR_FP)
> +		giveup_fpu(current);
>  	_exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip);
>  }
>  
> @@ -577,6 +579,8 @@ void __kprobes single_step_exception(str
>  	if (debugger_sstep(regs))
>  		return;
>  
> +	if (regs->msr & MSR_FP)
> +		giveup_fpu(current);
>  	_exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
>  }
>  
> @@ -834,6 +838,8 @@ void __kprobes program_check_exception(s
>  			regs->nip += 4;
>  			return;
>  		}
> +		if (regs->msr & MSR_FP)
> +			giveup_fpu(current);
>  		_exception(SIGTRAP, regs, TRAP_BRKPT, regs->nip);
>  		return;
>  	}
> 
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH] Reserve memory for kdump kernel within RMO region
From: Simon Horman @ 2009-11-27 11:51 UTC (permalink / raw)
  To: M. Mohan Kumar; +Cc: Bernhard Walle, kexec, ppcdev
In-Reply-To: <4B0F8F62.3050000@in.ibm.com>

On Fri, Nov 27, 2009 at 02:05:46PM +0530, M. Mohan Kumar wrote:
> On 11/27/2009 12:56 AM, Bernhard Walle wrote:
> >M. Mohan Kumar schrieb:
> >>On 11/26/2009 12:22 AM, Bernhard Walle wrote:
> >>>M. Mohan Kumar schrieb:
> >>>>Reserve memory for kdump kernel within RMO region
> >>>>
> >>>>When the kernel size exceeds 32MB(observed with some distros), memory
> >>>>for kdump kernel can not be reserved as kdump kernel base is assumed to
> >>>>be 32MB always. When the kernel has CONFIG_RELOCATABLE option enabled,
> >>>>provide the feature to reserve the memory for kdump kernel anywhere in
> >>>>the RMO region.
> >>
> >>Hi Bernhard,
> >>
> >>>Correct me if I'm wrong, but: CONFIG_RELOCATABLE is for the kernel that
> >>>gets loaded as crashkernel, not for the kernel that loads the
> >>>crashkernel. So it would be perfectly fine that a kernel that has not
> >>>CONFIG_RELOCATABLE set would load another kernel that has
> >>>CONFIG_RELOCATABLE set on an address != 32 M.
> >>
> >>No, with relocatable option, the same kernel is used as both production
> >>and kdump kernel.
> >
> >Can be, but it's not strictly necessary. It depends what userland does.
> >Especially it's possible that a non-relocatable, self-compiled kernel
> >loads a relocatable distribution kernel as capture kernel.
> >
> 
> I don't understand why a non-relocatable kernel will use relocatable
> kernel for capturing kdump kernel. The idea for relocatable kernel
> is to avoid using two different kernels to capture kernel dump.

True, but that doesn't necessarily mean that using a relocatable
kdump kernel is required. Well, hopefully not.

> >Also, it would make sense to make the behaviour symmetric across
> >platforms. Currently we have:
> >
> >  - x86 and ia64: Without offset on command line, use any offset
> >                  With offset on command line, use that offset and fail
> >                  if no memory is available at that offset.
> >  - ppc64: Always use 32M and ignore the offset.
> >
> >If your patch gets applied, we have:
> >
> >  - ppc64: With CONFIG_RELOCATABLE, use any offset
> >           With offset on command
> >
> >I don't see why the behaviour on ppc64 should be completely different.
> >
> >Having maintained kdump for SUSE for x86, ia64 and partly ppc64 in the
> >past, I always felt that ppc64 is more different from x86 than ia64 is
> >from x86. That's one more step into that direction without a technical
> >reason.
> 
> Also with the crashkernel=auto parameter (patches are not yet
> merged), the crashkernel base (offset) by default would be 32MB. In
> this case if a kernel passed with crashkernel=auto and if the first
> kernel size exceeds 32MB, memory for kdump kernel will always fail.
> 
> >
> >Having that all said: If your patch gets in mainline kernel, than we
> >should change the behaviour also for x86 and ia64.
> >
> >
> >
> >Regards,
> >Bernhard
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply

* Re: [RFC PATCH 02/19] powerpc: gamecube: device tree
From: Segher Boessenkool @ 2009-11-27 12:07 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <4B0D7AD0.5030605@yahoo.es>

>>> +	soc {
>>> +		#address-cells = <1>;
>>> +		#size-cells = <1>;
>>> +		#interrupt-cells = <1>;
>>
>> This isn't an interrupt controller, don't put #interrupt-cells
>> here.
>
> Isn't this needed to define what is to be expected in the  
> "interrupts" properties of the child nodes?

Nope.  Only interrupt controllers have a #interrupt-cells.  When
interpreting the "interrupts" property of some node, you walk the
interrupt tree (which can be the same as the device tree, or fully
separate, or share some things; and doesn't have to be a tree either)
up to the next interrupt controller, and use the #interrupt-cells
from that.  (This is simplified a little bit).

>>> +		auxram@0c005000 {
>>> +			compatible = "nintendo,flipper-auxram";
>>> +			reg = <0x0c005000 0x200>;	/* DSP */
>>> +			interrupts = <6>;
>>> +			interrupt-parent = <&pic>;
>>> +		};
>>> +
>>> +		audio@0c005000 {
>>> +			compatible = "nintendo,flipper-audio";
>>> +			reg = <0x0c005000 0x200		/* DSP */
>>> +			       0x0c006c00 0x20>;	/* AI */
>>> +			interrupts = <6>;
>>> +			interrupt-parent = <&pic>;
>>> +		};
>>
>> These two have the same address, not good.  Just remove the
>> auxram node?
>
> The DSP and the ARAM control/status bits share some registers in  
> the same block.
>
> How should I match the aram block driver if I remove the auxram node?

You can make aram a child node of dsp, which allows you to show
its size as well.  I.e. you do #a-cells=1 #s-cells=1 in the dsp
node, and reg=<0 01000000> in the aram node.

Or you can do a simple property in the dsp node saying how big
the aram is, and assume the driver(s) that match know(s) how to
drive it.  You have to assume this anyway, you're not putting
e.g. bytecode drivers in the device tree ;-)

>> ...and all the applicable things I mentioned in my Wii dev tree
>> reply, of course.
>>
>> Wow, it wasn't as bad as I expected actually.  But you cheated,
>> you omitted most devices from the device trees :-)
>
> You're welcome to add them too if you have information about them :)

I'll do that later, yes.  It's not so big a problem if the device
tree doesn't describe devices you do not support at all.


Segher

^ permalink raw reply

* Re: [RFC PATCH 02/19] powerpc: gamecube: device tree
From: Segher Boessenkool @ 2009-11-27 12:09 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Albert Herranz, linuxppc-dev
In-Reply-To: <1259209392.16367.242.camel@pasglop>

>> Similarly, it is better to use a compatible value of something like:
>> compatible = "nintendo,flipper-immr"; (instead of "nintendo,flipper")
>> because your describing just the internal bus, not the entire chip.
>
> I would just call the nodes "flipper" and "hollywood".

Either that, or not have these omnibus nodes at all, they are useless
and do not describe the hardware very well either.


Segher

^ permalink raw reply

* Re: [RFC PATCH 06/19] powerpc: gamecube/wii: introduce GAMECUBE_COMMON
From: Segher Boessenkool @ 2009-11-27 12:12 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: Albert Herranz, linuxppc-dev
In-Reply-To: <1259212129.16367.262.camel@pasglop>

>>>> Add a config option GAMECUBE_COMMON to be used as a dependency  
>>>> for all
>>>> options common to the Nintendo GameCube and Wii video game  
>>>> consoles.
>>>
>>> Maybe something like GAMECUBE_OR_WII instead?  "COMMON" is so
>>> common it's meaningless.
>>
>> I don't like either GAMECUBE_OR_WII.
>> It looks as if it can be used to match options for the GAMECUBE  
>> _or_ WII. But that's not the meaning of it.
>>
>> This option should be used only for options applicable to both the  
>> GAMECUBE and WII, i.e. basically those options in the WII which  
>> where "inherited" from the GAMECUBE to make it retro-compatible.
>>
>> If GAMECUBE_COMMON is unacceptable, maybe GAMECUBE_LEGACY or  
>> GAMECUBE_COMPAT?
>
> I don't have any strong opinion. Maybe NINTENDO_COMMON ?

That is much worse than GAMECUBE_COMMON.

Can you call the "common" option GAMECUBE, and have WII be for support
for whatever is new on the Wii?  Or is there some significant code that
is only needed on the old gamecube?


Segher

^ permalink raw reply

* Re: [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support
From: Segher Boessenkool @ 2009-11-27 12:17 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Albert Herranz, linuxppc-dev
In-Reply-To: <9741644C-BED3-45D9-B405-4C4FC2184DC7@kernel.crashing.org>

>>>>>> +/*
>>>>>> + * Each interrupt has a corresponding bit in both
>>>>>> + * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
>>>>>> + *
>>>>>> + * Enabling/disabling an interrupt line involves asserting/ 
>>>>>> clearing
>>>>>> + * the corresponding bit in IMR. ACK'ing a request simply  
>>>>>> involves
>>>>>> + * asserting the corresponding bit in ICR.
>>>>>> + */
>>>
>>> I looked it up in YAGCD; it says that _reading_ the ICR reg already
>>> acks all interrupts (and clears the bits), you never write this reg!
>>
>> YAGCD is not always right. You should not take it as _the truth_.
>
> Oh I know.  But I have no better source of information.  Well I could
> actually test it, that's very easy using OF :-)  Let's do that.

I tested it.  It turns out that neither reading or writing this register
does anything; the bits are automatically cleared when the source  
deasserts.

I didn't test all interrupts, some are harder to generate "on demand"  
than
others.


Segher

^ permalink raw reply

* Re: [PATCH] fix PPC floating point debug
From: Stefani Seibold @ 2009-11-27 12:44 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, linux-kernel
In-Reply-To: <1259319716.2076.3.camel@pasglop>

Am Freitag, den 27.11.2009, 22:01 +1100 schrieb Benjamin Herrenschmidt: 
> On Fri, 2009-11-27 at 09:59 +0100, Stefani Seibold wrote:
> > The PPC architecture is unable to debug applications using hardware
> > floating point, because it would not save the floating point registers.
> > 
> > After returning from the debugger, the contents of register was
> > modified. This patch fix this bug.
> 
> I'm not sure what problem you are trying to fix... debugging FP apps
> works just fine afaik. You don't need to flush the FP state into the
> thread when delivering the SIGTRAP. If you have a signal handler, that
> will be done for you by the signal code before laying out the signal
> frame. If you are using ptrace, you should be using the appropriate
> ptrace calls to retrieve the FP state and they should do the right thing
> to.
> 

Aeh... Forget it! Thank you for the support.

Stefani

^ permalink raw reply

* Re: [PATCH] Reserve memory for kdump kernel within RMO region
From: M. Mohan Kumar @ 2009-11-27 12:54 UTC (permalink / raw)
  To: Bernhard Walle; +Cc: kexec, ppcdev
In-Reply-To: <4B0ED674.6050501@bwalle.de>

Hi,

As of now the kdump kernel base is fixed to be 32MB. The intention of 
this patch is to modify that behaviour (for relocatable kernels)

* Regular kernel size may exceed 32MB, in this case we can't have kdump 
kernelbase as 32MB.

* crashkernel=auto also assumes that kdump kernelbase as 32MB, and it 
may also fail in reserving memory for kdump kernel.

On 11/27/2009 12:56 AM, Bernhard Walle wrote:
> M. Mohan Kumar schrieb:
>> On 11/26/2009 12:22 AM, Bernhard Walle wrote:
>>> M. Mohan Kumar schrieb:
>>>> Reserve memory for kdump kernel within RMO region
>>>>
>>>> When the kernel size exceeds 32MB(observed with some distros), memory
>>>> for kdump kernel can not be reserved as kdump kernel base is assumed to
>>>> be 32MB always. When the kernel has CONFIG_RELOCATABLE option enabled,
>>>> provide the feature to reserve the memory for kdump kernel anywhere in
>>>> the RMO region.
>>
>> Hi Bernhard,
>>
>>> Correct me if I'm wrong, but: CONFIG_RELOCATABLE is for the kernel that
>>> gets loaded as crashkernel, not for the kernel that loads the
>>> crashkernel. So it would be perfectly fine that a kernel that has not
>>> CONFIG_RELOCATABLE set would load another kernel that has
>>> CONFIG_RELOCATABLE set on an address != 32 M.
>>
>> No, with relocatable option, the same kernel is used as both production
>> and kdump kernel.
>
> Can be, but it's not strictly necessary. It depends what userland does.
> Especially it's possible that a non-relocatable, self-compiled kernel
> loads a relocatable distribution kernel as capture kernel.
>
> Also, it would make sense to make the behaviour symmetric across
> platforms. Currently we have:
>
>   - x86 and ia64: Without offset on command line, use any offset
>                   With offset on command line, use that offset and fail
>                   if no memory is available at that offset.
>   - ppc64: Always use 32M and ignore the offset.
>
> If your patch gets applied, we have:
>
>   - ppc64: With CONFIG_RELOCATABLE, use any offset
>            With offset on command
>
> I don't see why the behaviour on ppc64 should be completely different.
>
> Having maintained kdump for SUSE for x86, ia64 and partly ppc64 in the
> past, I always felt that ppc64 is more different from x86 than ia64 is
> from x86. That's one more step into that direction without a technical
> reason.
>
> Having that all said: If your patch gets in mainline kernel, than we
> should change the behaviour also for x86 and ia64.
>
>
>
> Regards,
> Bernhard
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply

* [PATCH 2.6.31] windfarm: add detection for second cpu pump
From: Bolko Maass @ 2009-11-27 15:44 UTC (permalink / raw)
  To: linuxppc-dev

Windfarm SMU control is explicitly missing support for a second CPU pump in G5 PowerMacs. Such machines actually exist  (specifically Quads with a second pump), so this patch adds detection for it.



diff -uprN a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
--- a/drivers/macintosh/windfarm_smu_controls.c 2009-11-27 16:24:55.000000000 +0100
+++ b/drivers/macintosh/windfarm_smu_controls.c 2009-11-16 18:22:33.000000000 +0100
@@ -202,6 +202,8 @@ static struct smu_fan_control *smu_fan_c
                fct->ctrl.name = "cpu-front-fan-1";
        else if (!strcmp(l, "CPU A PUMP"))
                fct->ctrl.name = "cpu-pump-0";
+       else if (!strcmp(l, "CPU B PUMP"))
+               fct->ctrl.name = "cpu-pump-1";
        else if (!strcmp(l, "Slots Fan") || !strcmp(l, "Slots fan") ||
                 !strcmp(l, "EXPANSION SLOTS INTAKE"))
                fct->ctrl.name = "slots-fan";



Signed-off by: Bolko Maass <bmaass@math.uni-bremen.de>

^ permalink raw reply

* [PATCH] powerpc: Add Kconfig dependency on PCI_MSI for XICS and select for PSERIES
From: Mel Gorman @ 2009-11-27 16:33 UTC (permalink / raw)
  To: Benjamin Herrenschmidt; +Cc: linuxppc-dev, Paul Mackerras, linux-kernel
In-Reply-To: <1259289626.2076.1.camel@pasglop>

On Fri, Nov 27, 2009 at 01:40:26PM +1100, Benjamin Herrenschmidt wrote:
> On Wed, 2009-11-18 at 17:05 +0000, Mel Gorman wrote:
> 
> > 
> > diff --git a/arch/powerpc/platforms/Kconfig b/arch/powerpc/platforms/Kconfig
> > index 04a8061..a82c470 100644
> > --- a/arch/powerpc/platforms/Kconfig
> > +++ b/arch/powerpc/platforms/Kconfig
> > @@ -52,9 +52,9 @@ config PPC_UDBG_BEAT
> >  	default n
> >  
> >  config XICS
> > -	depends on PPC_PSERIES
> > +	depends on PCI_MSI
> >  	bool
> > -	default y
> > +	default n
> 
> Why the above ? XICS only exist on PSERIES and select bypass depends in
> nasty ways anyways.
> 

You're right. When I made that change, I assumed that a "select foo"
would also resolve the dependencies. It doesn't but I failed to back
this out as being unnecessary.

> >  config IPIC
> >  	bool
> > diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
> > index f0e6f28..81c2289 100644
> > --- a/arch/powerpc/platforms/pseries/Kconfig
> > +++ b/arch/powerpc/platforms/pseries/Kconfig
> > @@ -5,6 +5,8 @@ config PPC_PSERIES
> >  	select PPC_I8259
> >  	select PPC_RTAS
> >  	select RTAS_ERROR_LOGGING
> > +	select PCI_MSI
> > +	select XICS
> >  	select PPC_UDBG_16550
> >  	select PPC_NATIVE
> >  	select PPC_PCI_CHOICE if EMBEDDED
> 
> The above bits look plenty enough. Can you also stick it next to the
> MPIC one ?
> 

They are. I can.

==== CUT HERE ====
powerpc: Add Kconfig dependency on PCI_MSI for XICS and select for PSERIES

It's possible to set CONFIG_XICS without CONFIG_PCI_MSI. When that happens,
the kernel fails to build with

arch/powerpc/platforms/built-in.o: In function `.xics_startup':
xics.c:(.text+0x12f60): undefined reference to `.unmask_msi_irq' make: ***
[.tmp_vmlinux1] Error 1

Furthermore, as noted by Benjamin Herrenschmidt, "CONFIG_XICS should be
made invisible and selected by PSERIES."

This patch adds the dependency in KConfig for XICS on PCI_MSI. When PSERIES
support is being configured, both options are silently selected.

Signed-off-by: Mel Gorman <mel[at]csn.ul.ie>
---
 arch/powerpc/platforms/pseries/Kconfig |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/Kconfig b/arch/powerpc/platforms/pseries/Kconfig
index f0e6f28..60d53ed 100644
--- a/arch/powerpc/platforms/pseries/Kconfig
+++ b/arch/powerpc/platforms/pseries/Kconfig
@@ -2,6 +2,8 @@ config PPC_PSERIES
 	depends on PPC64 && PPC_BOOK3S
 	bool "IBM pSeries & new (POWER5-based) iSeries"
 	select MPIC
+	select PCI_MSI
+	select XICS
 	select PPC_I8259
 	select PPC_RTAS
 	select RTAS_ERROR_LOGGING

^ permalink raw reply related

* Re: [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support
From: Albert Herranz @ 2009-11-27 17:27 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: linuxppc-dev
In-Reply-To: <786BBFA3-39AF-4100-8406-6B32258D3174@kernel.crashing.org>

Segher Boessenkool wrote:
>>>>>>> +/*
>>>>>>> + * Each interrupt has a corresponding bit in both
>>>>>>> + * the Interrupt Cause (ICR) and Interrupt Mask (IMR) registers.
>>>>>>> + *
>>>>>>> + * Enabling/disabling an interrupt line involves asserting/clearing
>>>>>>> + * the corresponding bit in IMR. ACK'ing a request simply involves
>>>>>>> + * asserting the corresponding bit in ICR.
>>>>>>> + */
>>>>
>>>> I looked it up in YAGCD; it says that _reading_ the ICR reg already
>>>> acks all interrupts (and clears the bits), you never write this reg!
>>>
>>> YAGCD is not always right. You should not take it as _the truth_.
>>
>> Oh I know.  But I have no better source of information.  Well I could
>> actually test it, that's very easy using OF :-)  Let's do that.
> 
> I tested it.  It turns out that neither reading or writing this register
> does anything; the bits are automatically cleared when the source
> deasserts.
> 

I checked it too on the Nintendo GameCube making the ack a no-op.

It turns out that we _need_ to ack the RSW (Reset Switch) interrupt.
The other interrupt sources checked (EXI, VI, DI, AI, DSP/ARAM) need no explicit ack.

> I didn't test all interrupts, some are harder to generate "on demand" than
> others.
> 

Thanks,
Albert

^ permalink raw reply

* Re: [PATCH] Reserve memory for kdump kernel within RMO region
From: Bernhard Walle @ 2009-11-27 18:39 UTC (permalink / raw)
  To: M. Mohan Kumar; +Cc: kexec, ppcdev
In-Reply-To: <4B0FCC0C.8060103@in.ibm.com>

M. Mohan Kumar schrieb:
> Hi,
> 
> As of now the kdump kernel base is fixed to be 32MB. The intention of 
> this patch is to modify that behaviour (for relocatable kernels)
> 
> * Regular kernel size may exceed 32MB, in this case we can't have kdump 
> kernelbase as 32MB.
> 
> * crashkernel=auto also assumes that kdump kernelbase as 32MB, and it 
> may also fail in reserving memory for kdump kernel.

I'm not opposed to remove the 32MB restriction, but I would like to make
the behaviour independent of CONFIG_RELOCATABLE like it's on x86:

 - Use 32M if one specifies xxx@32M
 - Use preferrably 32M, but fall back to another address if one
   specifies xxx or xxx@0M.

I don't see any problem with that. But it would make behaviour equal
accross platforms.



Regards,
Bernhard

^ permalink raw reply

* Re: [RFC PATCH 11/19] powerpc: gamecube/wii: flipper interrupt controller support
From: Benjamin Herrenschmidt @ 2009-11-27 21:34 UTC (permalink / raw)
  To: Albert Herranz; +Cc: linuxppc-dev
In-Reply-To: <4B100BF4.5080209@yahoo.es>

On Fri, 2009-11-27 at 18:27 +0100, Albert Herranz wrote:
> 
> I checked it too on the Nintendo GameCube making the ack a no-op.
> 
> It turns out that we _need_ to ack the RSW (Reset Switch) interrupt.
> The other interrupt sources checked (EXI, VI, DI, AI, DSP/ARAM) need
> no explicit ack.

That would probably mean that the reset switch interrupt is an edge
interrupt. Which means that you also use the wrong flow handler btw :-)
No biggie here tho, if it's acked before the handler is called, which
should be the case, and if masking it doesn't prevent the edge detector
from latching, then it should be allright.

But you may want to make sure you don't have another edge irq somewhere
in there...

Cheers,
Ben.

^ permalink raw reply

* Re: [RFC PATCH 12/19] powerpc: gamecube: platform support
From: Benjamin Herrenschmidt @ 2009-11-27 21:35 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: Albert Herranz, linuxppc-dev
In-Reply-To: <BBB65A84-B871-474F-8666-90CCD10D90B6@kernel.crashing.org>

On Fri, 2009-11-27 at 01:09 +0100, Segher Boessenkool wrote:
> >>> We need it as it currently doesn't match with the default bus ids.
> >>
> >>> Should I introduce a .type property matching any of those above  
> >>> in the
> >>> soc node, and get rid of the explicit bus probe?
> >>
> >> You don't need any fake bus as far as I can see, just probe the  
> >> devices
> >> you want.
> >
> > But it's way easier to let the bus probe do it for us. I don't see  
> > the win here.
> 
> As long as this doesn't leak into the device tree in any way, I don't
> care.  How's that? :-)

I still like having the node that encloses all the devices. Not sure
why, but I like it :-)

Cheers,
Ben.

^ permalink raw reply

* Re: [PATCH 2.6.31] windfarm: add detection for second cpu pump
From: Benjamin Herrenschmidt @ 2009-11-27 21:36 UTC (permalink / raw)
  To: bmaass; +Cc: linuxppc-dev
In-Reply-To: <20091127164433.0b5087de.krautilein@gmx.de>

On Fri, 2009-11-27 at 16:44 +0100, Bolko Maass wrote:
> Windfarm SMU control is explicitly missing support for a second CPU pump in G5 PowerMacs. 
> Such machines actually exist  (specifically Quads with a second pump), so this patch adds detection for it.
> 

Thanks.

BTW. The Signed-off-by: line normally goes -before- the patch :-) (And
after the description).

I'll get that upstream asap.

Cheers,
Ben.

> 
> diff -uprN a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
> --- a/drivers/macintosh/windfarm_smu_controls.c 2009-11-27 16:24:55.000000000 +0100
> +++ b/drivers/macintosh/windfarm_smu_controls.c 2009-11-16 18:22:33.000000000 +0100
> @@ -202,6 +202,8 @@ static struct smu_fan_control *smu_fan_c
>                 fct->ctrl.name = "cpu-front-fan-1";
>         else if (!strcmp(l, "CPU A PUMP"))
>                 fct->ctrl.name = "cpu-pump-0";
> +       else if (!strcmp(l, "CPU B PUMP"))
> +               fct->ctrl.name = "cpu-pump-1";
>         else if (!strcmp(l, "Slots Fan") || !strcmp(l, "Slots fan") ||
>                  !strcmp(l, "EXPANSION SLOTS INTAKE"))
>                 fct->ctrl.name = "slots-fan";
> 
> 
> 
> Signed-off by: Bolko Maass <bmaass@math.uni-bremen.de>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* Re: [PATCH 00/10 v6]  Fix 8xx MMU/TLB
From: Benjamin Herrenschmidt @ 2009-11-27 21:37 UTC (permalink / raw)
  To: Joakim Tjernlund; +Cc: Scott Wood, linuxppc-dev@ozlabs.org, Rex Feany
In-Reply-To: <OF44DA1806.2D9916D9-ONC125767B.003BE84B-C125767B.003C3CD7@transmode.se>

On Fri, 2009-11-27 at 11:57 +0100, Joakim Tjernlund wrote:
> Scott and Rex, I think we need you s-o-b to make it into the kernel proper.
> 
> Marcelo and Vitaly, I noticed you guys are listed as 8xx maintainers.
> Have you seen this? What do you think?

I think Marcelo isn't much involved with 8xx anymore. I'd say if Scott
and Vitaly are ok, then the patches are good. But I'll wait for at least
Scott to give an Ack as he can at least test which I can't :-)

Cheers,
Ben.

>         Jocke
> 
> Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote on 20/11/2009 11:21:01:
> >
> > Yet again an iteration of the series.
> > Rex & Scott, please test and signoff.
> > Changes since last version:
> >  - Fix rlwimi insn(from Scott)
> >
> > Joakim Tjernlund (10):
> >   8xx: invalidate non present TLBs
> >   8xx: Update TLB asm so it behaves as linux mm expects.
> >   8xx: Tag DAR with 0x00f0 to catch buggy instructions.
> >   8xx: Always pin kernel instruction TLB
> >   8xx: Fixup DAR from buggy dcbX instructions.
> >   8xx: Add missing Guarded setting in DTLB Error.
> >   8xx: Restore _PAGE_WRITETHRU
> >   8xx: start using dcbX instructions in various copy routines
> >   8xx: Remove DIRTY pte handling in DTLB Error.
> >   8xx: DTLB Miss cleanup
> >
> >  arch/powerpc/include/asm/pte-8xx.h |   14 +-
> >  arch/powerpc/kernel/head_8xx.S     |  315 ++++++++++++++++++++++--------------
> >  arch/powerpc/kernel/misc_32.S      |   18 --
> >  arch/powerpc/lib/copy_32.S         |   24 ---
> >  arch/powerpc/mm/fault.c            |    8 +-
> >  5 files changed, 211 insertions(+), 168 deletions(-)
> >
> 
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev

^ permalink raw reply

* [PATCH 0/8 userland!] systemtap: Add initial support for ppc32
From: Anton Vorontsov @ 2009-11-27 22:32 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev

Hi all,

Here are some patches that add systemtap support for ppc32 machines.

This is all pretty straightforward, though I didn't test it much,
only run few 'hello world' taps and decided that it's good enough. ;-)

I plan to test it more thoughtfully sometime next week, and fix missing
things (if any). But so far I'm interested in the feedback on this
initial support.

Thanks!

p.s. I though it would be a good idea to cc linuxppc-dev. At least
kexec-tools guys tend to do it as well.

-- 
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply

* [PATCH 1/8] Rename uprobes_ppc64.c to uprobes_ppc.c, use it for ppc32
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

The code *looks* generic enough, so I think it can be used for ppc32
without modifications.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/uprobes/uprobes_arch.c  |    4 +-
 runtime/uprobes/uprobes_arch.h  |    4 +-
 runtime/uprobes/uprobes_ppc.c   |  147 +++++++++++++++++++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc.h   |   82 ++++++++++++++++++++++
 runtime/uprobes/uprobes_ppc64.c |  147 ---------------------------------------
 runtime/uprobes/uprobes_ppc64.h |   82 ----------------------
 runtime/uprobes2/uprobes_arch.c |    4 +-
 runtime/uprobes2/uprobes_arch.h |    4 +-
 8 files changed, 237 insertions(+), 237 deletions(-)
 create mode 100644 runtime/uprobes/uprobes_ppc.c
 create mode 100644 runtime/uprobes/uprobes_ppc.h
 delete mode 100644 runtime/uprobes/uprobes_ppc64.c
 delete mode 100644 runtime/uprobes/uprobes_ppc64.h

diff --git a/runtime/uprobes/uprobes_arch.c b/runtime/uprobes/uprobes_arch.c
index 99ef54c..6c58d5f 100644
--- a/runtime/uprobes/uprobes_arch.c
+++ b/runtime/uprobes/uprobes_arch.c
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.c"
 #elif defined (__i386__)
 #include "uprobes_i386.c"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.c"
 #else
diff --git a/runtime/uprobes/uprobes_arch.h b/runtime/uprobes/uprobes_arch.h
index 0223e28..f642f52 100644
--- a/runtime/uprobes/uprobes_arch.h
+++ b/runtime/uprobes/uprobes_arch.h
@@ -2,8 +2,8 @@
 #include "uprobes_x86_64.h"
 #elif defined (__i386__)
 #include "uprobes_i386.h"
-#elif defined (__powerpc64__)
-#include "uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "uprobes_s390.h"
 #else
diff --git a/runtime/uprobes/uprobes_ppc.c b/runtime/uprobes/uprobes_ppc.c
new file mode 100644
index 0000000..819ac73
--- /dev/null
+++ b/runtime/uprobes/uprobes_ppc.c
@@ -0,0 +1,147 @@
+/*
+ * Userspace Probes (UProbes) for PowerPC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ */
+/*
+ * In versions of uprobes built in the SystemTap runtime, this file
+ * is #included at the end of uprobes.c.
+ */
+
+/*
+ * Replace the return address with the trampoline address.  Returns
+ * the original return address.
+ */
+static
+unsigned long arch_hijack_uret_addr(unsigned long trampoline_address,
+		struct pt_regs *regs, struct uprobe_task *utask)
+{
+	unsigned long orig_ret_addr = regs->link;
+
+	regs->link = trampoline_address;
+	return orig_ret_addr;
+}
+
+/*
+ * Get an instruction slot from the process's SSOL area, containing the
+ * instruction at ppt's probepoint.  Point the eip at that slot, in preparation
+ * for single-stepping out of line.
+ */
+static
+void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
+		struct pt_regs *regs)
+{
+	struct uprobe_ssol_slot *slot;
+
+	slot = uprobe_get_insn_slot(ppt);
+	if (!slot) {
+		utask->doomed = 1;
+		return;
+	}
+	regs->nip = (long)slot->insn;
+}
+
+
+static inline void calc_offset(struct uprobe_probept *ppt,
+	       struct pt_regs *regs)
+{
+	int offset = 0;
+	unsigned int opcode = 0;
+	unsigned int insn = *ppt->insn;
+
+	opcode = insn >> 26;
+	switch (opcode) {
+	case 16:	/* bc */
+		if ((insn & 2) == 0) {
+			offset = (signed short)(insn & 0xfffc);
+			regs->nip = ppt->vaddr + offset;
+		}
+		if (insn & 1)
+			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
+		break;
+	case 17:	/* sc */
+		/* Do we need to do anything */
+		break;
+	case 18:	/* b */
+		if ((insn & 2) == 0) {
+			offset = insn & 0x03fffffc;
+			if (offset & 0x02000000)
+				offset -= 0x04000000;
+			regs->nip = ppt->vaddr + offset;
+		}
+		if (insn & 1)
+			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
+		break;
+	}
+#ifdef UPROBES_DEBUG
+	printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n",
+			ppt->vaddr, regs->nip, offset);
+	if (insn & 1)
+		printk (KERN_ERR "regs->link=%p \n", regs->link);
+#endif
+	return;
+}
+
+/*
+ * Called after single-stepping.  ppt->vaddr is the address of the
+ * instruction which was replaced by a breakpoint instruction.  To avoid
+ * the SMP problems that can occur when we temporarily put back the
+ * original opcode to single-step, we single-stepped a copy of the
+ * instruction.
+ *
+ * This function prepares to return from the post-single-step
+ * interrupt.
+ *
+ * 1) Typically, the new nip is relative to the copied instruction.  We
+ * need to make it relative to the original instruction.  Exceptions are
+ * branch instructions.
+ *
+ * 2) For branch instructions, update the nip if the branch uses
+ * relative addressing.  Update the link instruction to the instruction
+ * following the original instruction address.
+ */
+
+static
+void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
+		struct pt_regs *regs)
+{
+	unsigned long copy_nip;
+
+	copy_nip = (unsigned long) ppt->slot->insn;
+	up_read(&ppt->slot->rwsem);
+
+	/*
+	 * If the single stepped instruction is non-branch instruction
+	 * then update the IP to be relative to probepoint.
+	 */
+	if (regs->nip == copy_nip + MAX_UINSN_BYTES)
+		regs->nip = ppt->vaddr + MAX_UINSN_BYTES;
+	else
+		calc_offset(ppt,regs);
+}
+
+static
+int arch_validate_probed_insn(struct uprobe_probept *ppt,
+		 struct task_struct *tsk)
+{
+	if ((unsigned long)ppt->vaddr & 0x03) {
+		printk(KERN_WARNING
+			"Attempt to register uprobe at an unaligned addr\n");
+		return -EINVAL;
+	}
+	return 0;
+}
diff --git a/runtime/uprobes/uprobes_ppc.h b/runtime/uprobes/uprobes_ppc.h
new file mode 100644
index 0000000..5604635
--- /dev/null
+++ b/runtime/uprobes/uprobes_ppc.h
@@ -0,0 +1,82 @@
+#ifndef _ASM_UPROBES_H
+#define _ASM_UPROBES_H
+/*
+ * Userspace Probes (UProbes) for PowerPC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ */
+#include <linux/types.h>
+#include <linux/ptrace.h>
+#include <linux/signal.h>
+
+#define BREAKPOINT_SIGNAL SIGTRAP
+#define SSTEP_SIGNAL SIGTRAP
+
+/* Normally defined in Kconfig */
+#define CONFIG_UPROBES_SSOL
+#define CONFIG_URETPROBES 1
+
+typedef unsigned int uprobe_opcode_t;
+#define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
+#define BP_INSN_SIZE 4
+#define MAX_UINSN_BYTES 4
+#define SLOT_IP(tsk) 32	/* instruction pointer slot from include/asm/elf.h */
+
+struct uprobe_probept_arch_info {};
+struct uprobe_task_arch_info {};
+
+/* Architecture specific switch for where the IP points after a bp hit */
+#define ARCH_BP_INST_PTR(inst_ptr)	(inst_ptr)
+
+struct uprobe_probept;
+struct uprobe_task;
+struct task_struct;
+
+/* On powerpc, nip points to the trap. */
+static inline unsigned long arch_get_probept(struct pt_regs *regs)
+{
+	return (unsigned long)(regs->nip);
+}
+
+static inline void arch_reset_ip_for_sstep(struct pt_regs *regs)
+{
+}
+
+static inline int arch_validate_probed_insn(struct uprobe_probept *ppt,
+						struct task_struct *tsk);
+
+static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr,
+		struct pt_regs *regs, struct uprobe_task *utask);
+
+static inline void arch_restore_uret_addr(unsigned long ret_addr,
+		struct pt_regs *regs)
+{
+	regs->nip = ret_addr;
+}
+
+static unsigned long arch_get_cur_sp(struct pt_regs *regs)
+{
+	return (unsigned long)(regs->gpr[1]);
+}
+
+static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs,
+		struct task_struct *tsk)
+{
+	return (unsigned long)(regs->gpr[1]);
+}
+
+#endif				/* _ASM_UPROBES_H */
diff --git a/runtime/uprobes/uprobes_ppc64.c b/runtime/uprobes/uprobes_ppc64.c
deleted file mode 100644
index 819ac73..0000000
--- a/runtime/uprobes/uprobes_ppc64.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Userspace Probes (UProbes) for PowerPC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation, 2007
- */
-/*
- * In versions of uprobes built in the SystemTap runtime, this file
- * is #included at the end of uprobes.c.
- */
-
-/*
- * Replace the return address with the trampoline address.  Returns
- * the original return address.
- */
-static
-unsigned long arch_hijack_uret_addr(unsigned long trampoline_address,
-		struct pt_regs *regs, struct uprobe_task *utask)
-{
-	unsigned long orig_ret_addr = regs->link;
-
-	regs->link = trampoline_address;
-	return orig_ret_addr;
-}
-
-/*
- * Get an instruction slot from the process's SSOL area, containing the
- * instruction at ppt's probepoint.  Point the eip at that slot, in preparation
- * for single-stepping out of line.
- */
-static
-void uprobe_pre_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
-		struct pt_regs *regs)
-{
-	struct uprobe_ssol_slot *slot;
-
-	slot = uprobe_get_insn_slot(ppt);
-	if (!slot) {
-		utask->doomed = 1;
-		return;
-	}
-	regs->nip = (long)slot->insn;
-}
-
-
-static inline void calc_offset(struct uprobe_probept *ppt,
-	       struct pt_regs *regs)
-{
-	int offset = 0;
-	unsigned int opcode = 0;
-	unsigned int insn = *ppt->insn;
-
-	opcode = insn >> 26;
-	switch (opcode) {
-	case 16:	/* bc */
-		if ((insn & 2) == 0) {
-			offset = (signed short)(insn & 0xfffc);
-			regs->nip = ppt->vaddr + offset;
-		}
-		if (insn & 1)
-			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
-		break;
-	case 17:	/* sc */
-		/* Do we need to do anything */
-		break;
-	case 18:	/* b */
-		if ((insn & 2) == 0) {
-			offset = insn & 0x03fffffc;
-			if (offset & 0x02000000)
-				offset -= 0x04000000;
-			regs->nip = ppt->vaddr + offset;
-		}
-		if (insn & 1)
-			regs->link = ppt->vaddr + MAX_UINSN_BYTES;
-		break;
-	}
-#ifdef UPROBES_DEBUG
-	printk (KERN_ERR "ppt->vaddr=%p, regs->nip=%p, offset=%ld\n",
-			ppt->vaddr, regs->nip, offset);
-	if (insn & 1)
-		printk (KERN_ERR "regs->link=%p \n", regs->link);
-#endif
-	return;
-}
-
-/*
- * Called after single-stepping.  ppt->vaddr is the address of the
- * instruction which was replaced by a breakpoint instruction.  To avoid
- * the SMP problems that can occur when we temporarily put back the
- * original opcode to single-step, we single-stepped a copy of the
- * instruction.
- *
- * This function prepares to return from the post-single-step
- * interrupt.
- *
- * 1) Typically, the new nip is relative to the copied instruction.  We
- * need to make it relative to the original instruction.  Exceptions are
- * branch instructions.
- *
- * 2) For branch instructions, update the nip if the branch uses
- * relative addressing.  Update the link instruction to the instruction
- * following the original instruction address.
- */
-
-static
-void uprobe_post_ssout(struct uprobe_task *utask, struct uprobe_probept *ppt,
-		struct pt_regs *regs)
-{
-	unsigned long copy_nip;
-
-	copy_nip = (unsigned long) ppt->slot->insn;
-	up_read(&ppt->slot->rwsem);
-
-	/*
-	 * If the single stepped instruction is non-branch instruction
-	 * then update the IP to be relative to probepoint.
-	 */
-	if (regs->nip == copy_nip + MAX_UINSN_BYTES)
-		regs->nip = ppt->vaddr + MAX_UINSN_BYTES;
-	else
-		calc_offset(ppt,regs);
-}
-
-static
-int arch_validate_probed_insn(struct uprobe_probept *ppt,
-		 struct task_struct *tsk)
-{
-	if ((unsigned long)ppt->vaddr & 0x03) {
-		printk(KERN_WARNING
-			"Attempt to register uprobe at an unaligned addr\n");
-		return -EINVAL;
-	}
-	return 0;
-}
diff --git a/runtime/uprobes/uprobes_ppc64.h b/runtime/uprobes/uprobes_ppc64.h
deleted file mode 100644
index 5604635..0000000
--- a/runtime/uprobes/uprobes_ppc64.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef _ASM_UPROBES_H
-#define _ASM_UPROBES_H
-/*
- * Userspace Probes (UProbes) for PowerPC
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * Copyright IBM Corporation, 2007
- */
-#include <linux/types.h>
-#include <linux/ptrace.h>
-#include <linux/signal.h>
-
-#define BREAKPOINT_SIGNAL SIGTRAP
-#define SSTEP_SIGNAL SIGTRAP
-
-/* Normally defined in Kconfig */
-#define CONFIG_UPROBES_SSOL
-#define CONFIG_URETPROBES 1
-
-typedef unsigned int uprobe_opcode_t;
-#define BREAKPOINT_INSTRUCTION	0x7fe00008	/* trap */
-#define BP_INSN_SIZE 4
-#define MAX_UINSN_BYTES 4
-#define SLOT_IP(tsk) 32	/* instruction pointer slot from include/asm/elf.h */
-
-struct uprobe_probept_arch_info {};
-struct uprobe_task_arch_info {};
-
-/* Architecture specific switch for where the IP points after a bp hit */
-#define ARCH_BP_INST_PTR(inst_ptr)	(inst_ptr)
-
-struct uprobe_probept;
-struct uprobe_task;
-struct task_struct;
-
-/* On powerpc, nip points to the trap. */
-static inline unsigned long arch_get_probept(struct pt_regs *regs)
-{
-	return (unsigned long)(regs->nip);
-}
-
-static inline void arch_reset_ip_for_sstep(struct pt_regs *regs)
-{
-}
-
-static inline int arch_validate_probed_insn(struct uprobe_probept *ppt,
-						struct task_struct *tsk);
-
-static unsigned long arch_hijack_uret_addr(unsigned long trampoline_addr,
-		struct pt_regs *regs, struct uprobe_task *utask);
-
-static inline void arch_restore_uret_addr(unsigned long ret_addr,
-		struct pt_regs *regs)
-{
-	regs->nip = ret_addr;
-}
-
-static unsigned long arch_get_cur_sp(struct pt_regs *regs)
-{
-	return (unsigned long)(regs->gpr[1]);
-}
-
-static unsigned long arch_predict_sp_at_ret(struct pt_regs *regs,
-		struct task_struct *tsk)
-{
-	return (unsigned long)(regs->gpr[1]);
-}
-
-#endif				/* _ASM_UPROBES_H */
diff --git a/runtime/uprobes2/uprobes_arch.c b/runtime/uprobes2/uprobes_arch.c
index 3c86804..a91d5b6 100644
--- a/runtime/uprobes2/uprobes_arch.c
+++ b/runtime/uprobes2/uprobes_arch.c
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.c"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.c"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.c"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.c"
 #elif defined (__ia64__)
diff --git a/runtime/uprobes2/uprobes_arch.h b/runtime/uprobes2/uprobes_arch.h
index 87e0cc8..cce5775 100644
--- a/runtime/uprobes2/uprobes_arch.h
+++ b/runtime/uprobes2/uprobes_arch.h
@@ -1,7 +1,7 @@
 #if defined (__x86_64__) || defined(__i386)
 #include "uprobes_x86.h"
-#elif defined (__powerpc64__)
-#include "../uprobes/uprobes_ppc64.h"
+#elif defined (__powerpc__)
+#include "../uprobes/uprobes_ppc.h"
 #elif defined (__s390__) || defined (__s390x__)
 #include "../uprobes/uprobes_s390.h"
 #elif defined (__ia64__)
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 2/8] Rename stack-ppc64.c to stack-ppc.c
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

There should be no functional changes in this patch.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stack-ppc.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++++
 runtime/stack-ppc64.c |   62 -------------------------------------------------
 runtime/stack.c       |    2 +-
 3 files changed, 63 insertions(+), 63 deletions(-)
 create mode 100644 runtime/stack-ppc.c
 delete mode 100644 runtime/stack-ppc64.c

diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c
new file mode 100644
index 0000000..3267194
--- /dev/null
+++ b/runtime/stack-ppc.c
@@ -0,0 +1,62 @@
+/* -*- linux-c -*-
+ * ppc64 stack tracing functions
+ *
+ * This file is part of systemtap, and is free software.  You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
+                               struct task_struct *tsk)
+{
+	unsigned long ip, newsp, lr = 0;
+	int count = 0;
+	int firstframe = 1;
+	unsigned long *_sp = (unsigned long *)&REG_SP(regs);	
+	unsigned long sp = (unsigned long)_sp;
+	lr = 0;
+	do {
+		if (sp < KERNELBASE)
+			return;
+		_sp = (unsigned long *) sp;
+		newsp = _sp[0];
+		ip = _sp[2];
+		if (!firstframe || ip != lr) {
+			if (verbose) {
+				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
+				_stp_symbol_print(ip);
+				if (firstframe)
+					_stp_print(" (unreliable)");
+				_stp_print_char('\n');
+			}
+			else
+				_stp_printf("0x%016lx ", ip);
+		}
+		firstframe = 0;
+		/*
+		 * See if this is an exception frame.
+		 * We look for the "regshere" marker in the current frame.
+		 */
+		if ( _sp[12] == 0x7265677368657265ul) {
+			struct pt_regs *regs = (struct pt_regs *)
+				(sp + STACK_FRAME_OVERHEAD);
+			if (verbose) {
+				_stp_printf("--- Exception: %lx at ",regs->trap);
+				_stp_symbol_print(regs->nip);
+				_stp_print_char('\n');
+				lr = regs->link;
+				_stp_print("    LR =");
+				_stp_symbol_print(lr);
+				_stp_print_char('\n');
+				firstframe = 1;
+			}
+			else {
+				_stp_printf("0x%016lx ",regs->nip);
+				_stp_printf("0x%016lx ",regs->link);
+			}
+		}
+
+		sp = newsp;
+	} while (count++ < MAXBACKTRACE);
+}
diff --git a/runtime/stack-ppc64.c b/runtime/stack-ppc64.c
deleted file mode 100644
index 3267194..0000000
--- a/runtime/stack-ppc64.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* -*- linux-c -*-
- * ppc64 stack tracing functions
- *
- * This file is part of systemtap, and is free software.  You can
- * redistribute it and/or modify it under the terms of the GNU General
- * Public License (GPL); either version 2, or (at your option) any
- * later version.
- */
-
-static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
-                               struct task_struct *tsk)
-{
-	unsigned long ip, newsp, lr = 0;
-	int count = 0;
-	int firstframe = 1;
-	unsigned long *_sp = (unsigned long *)&REG_SP(regs);	
-	unsigned long sp = (unsigned long)_sp;
-	lr = 0;
-	do {
-		if (sp < KERNELBASE)
-			return;
-		_sp = (unsigned long *) sp;
-		newsp = _sp[0];
-		ip = _sp[2];
-		if (!firstframe || ip != lr) {
-			if (verbose) {
-				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
-				_stp_symbol_print(ip);
-				if (firstframe)
-					_stp_print(" (unreliable)");
-				_stp_print_char('\n');
-			}
-			else
-				_stp_printf("0x%016lx ", ip);
-		}
-		firstframe = 0;
-		/*
-		 * See if this is an exception frame.
-		 * We look for the "regshere" marker in the current frame.
-		 */
-		if ( _sp[12] == 0x7265677368657265ul) {
-			struct pt_regs *regs = (struct pt_regs *)
-				(sp + STACK_FRAME_OVERHEAD);
-			if (verbose) {
-				_stp_printf("--- Exception: %lx at ",regs->trap);
-				_stp_symbol_print(regs->nip);
-				_stp_print_char('\n');
-				lr = regs->link;
-				_stp_print("    LR =");
-				_stp_symbol_print(lr);
-				_stp_print_char('\n');
-				firstframe = 1;
-			}
-			else {
-				_stp_printf("0x%016lx ",regs->nip);
-				_stp_printf("0x%016lx ",regs->link);
-			}
-		}
-
-		sp = newsp;
-	} while (count++ < MAXBACKTRACE);
-}
diff --git a/runtime/stack.c b/runtime/stack.c
index 042f44c..ae89995 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -41,7 +41,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #elif  defined (__i386__)
 #include "stack-i386.c"
 #elif defined (__powerpc64__)
-#include "stack-ppc64.c"
+#include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
 #elif defined (__s390__) || defined (__s390x__)
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 3/8] stack-ppc: Adjust for ppc32
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

Get rid of magic numbers, use appropriate defines from ptrace.h.

>From now on stack-ppc.c should be suitable for ppc32.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stack-ppc.c |    4 ++--
 runtime/stack.c     |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/runtime/stack-ppc.c b/runtime/stack-ppc.c
index 3267194..df2db15 100644
--- a/runtime/stack-ppc.c
+++ b/runtime/stack-ppc.c
@@ -21,7 +21,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 			return;
 		_sp = (unsigned long *) sp;
 		newsp = _sp[0];
-		ip = _sp[2];
+		ip = _sp[STACK_FRAME_LR_SAVE];
 		if (!firstframe || ip != lr) {
 			if (verbose) {
 				_stp_printf("[0x%016lx] [0x%016lx] ", sp, ip);
@@ -38,7 +38,7 @@ static void __stp_stack_print (struct pt_regs *regs, int verbose, int levels,
 		 * See if this is an exception frame.
 		 * We look for the "regshere" marker in the current frame.
 		 */
-		if ( _sp[12] == 0x7265677368657265ul) {
+		if (_sp[STACK_FRAME_MARKER] == STACK_FRAME_REGS_MARKER) {
 			struct pt_regs *regs = (struct pt_regs *)
 				(sp + STACK_FRAME_OVERHEAD);
 			if (verbose) {
diff --git a/runtime/stack.c b/runtime/stack.c
index ae89995..25dbdbb 100644
--- a/runtime/stack.c
+++ b/runtime/stack.c
@@ -40,7 +40,7 @@ static void _stp_stack_print_fallback(unsigned long, int, int);
 #include "stack-ia64.c"
 #elif  defined (__i386__)
 #include "stack-i386.c"
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 #include "stack-ppc.c"
 #elif defined (__arm__)
 #include "stack-arm.c"
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 4/8] Implement ppc32 variant of __is_user_regs
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

* tapset/nd_syscalls.stp: Implement ppc32 variant of __is_user_regs.
* tapset/syscalls.stp: Ditto.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 tapset/nd_syscalls.stp |    3 +++
 tapset/syscalls.stp    |    3 +++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/tapset/nd_syscalls.stp b/tapset/nd_syscalls.stp
index f9a6ffc..e7492a1 100644
--- a/tapset/nd_syscalls.stp
+++ b/tapset/nd_syscalls.stp
@@ -1320,6 +1320,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
diff --git a/tapset/syscalls.stp b/tapset/syscalls.stp
index dde0ca9..430d37f 100644
--- a/tapset/syscalls.stp
+++ b/tapset/syscalls.stp
@@ -1093,6 +1093,9 @@ function __is_user_regs:long (regs:long)
 #elif defined(__powerpc64__)
 	unsigned long msr = kread(&regs->msr);
 	THIS->__retvalue = ((msr >> MSR_PR_LG) & 0x1);
+#elif defined(__powerpc__)
+	unsigned long msr = kread(&regs->msr);
+	THIS->__retvalue = ((msr >> MSR_PR) != 0);
 #elif defined(__arm__)
 	long cpsr = kread(&regs->ARM_cpsr);
 	THIS->__retvalue = ((cpsr & 0xf) == 0);
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 5/8] Share ppc64 and ppc32 code where possible
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

* runtime/copy.c: Can use ppc64's code.
* runtime/regs.h: Ditto.
* runtime/string.h: Ditto.
* tapset/context.stp: Ditto.
* tapset/errno.stp: Ditto.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/copy.c     |    2 +-
 runtime/regs.h     |    2 +-
 runtime/string.h   |    6 +++---
 tapset/context.stp |    2 +-
 tapset/errno.stp   |    2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/runtime/copy.c b/runtime/copy.c
index 4fb8725..40f1511 100644
--- a/runtime/copy.c
+++ b/runtime/copy.c
@@ -105,7 +105,7 @@ do {									   \
 		: "i"(-EFAULT), "0"(count), "1"(count), "3"(src), "4"(dst) \
 		: "memory");						   \
 } while (0)
-#elif defined (__powerpc64__) || defined (__ia64__) || defined (__arm__)
+#elif defined (__powerpc__) || defined (__ia64__) || defined (__arm__)
 #define __stp_strncpy_from_user(dst,src,count,res) \
 	do { res = __strncpy_from_user(dst, src, count); } while(0)
 
diff --git a/runtime/regs.h b/runtime/regs.h
index dc6b50a..08449aa 100644
--- a/runtime/regs.h
+++ b/runtime/regs.h
@@ -36,7 +36,7 @@
   (((regs)->cr_iip = (x) & ~3UL), (ia64_psr(regs)->ri = (x) & 3UL))
 
 
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 
 #define REG_IP(regs) regs->nip
 #define REG_SP(regs) regs->gpr[1]
diff --git a/runtime/string.h b/runtime/string.h
index f4d4cc0..b08304e 100644
--- a/runtime/string.h
+++ b/runtime/string.h
@@ -19,14 +19,14 @@ static void _stp_text_str(char *out, char *in, int len, int quoted, int user);
  * is provided without the paranoid check. Use it if available, fall back
  * to __get_user() if not. Other archs can use __get_user() as is
  */
-#ifdef __powerpc64__
+#if defined(__powerpc__)
 #ifdef __get_user_inatomic
 #define __stp_get_user(x, ptr) __get_user_inatomic(x, ptr)
 #else /* __get_user_inatomic */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
 #endif /* __get_user_inatomic */
-#else /* __powerpc64__ */
+#else /* defined(__powerpc__) */
 #define __stp_get_user(x, ptr) __get_user(x, ptr)
-#endif /* __powerpc64__ */
+#endif /* defined(__powerpc__) */
 
 #endif /* _STRING_H_ */
diff --git a/tapset/context.stp b/tapset/context.stp
index 36701e6..b30f7dc 100644
--- a/tapset/context.stp
+++ b/tapset/context.stp
@@ -15,7 +15,7 @@
 %{
 #include <asm/processor.h>
 
-#if defined(__powerpc64__)
+#if defined(__powerpc__)
 #if !defined(task_pt_regs)
 #define task_pt_regs(tsk)       ((struct pt_regs *)(tsk)->thread.regs)
 #endif
diff --git a/tapset/errno.stp b/tapset/errno.stp
index 011ff7e..d4d571b 100644
--- a/tapset/errno.stp
+++ b/tapset/errno.stp
@@ -369,7 +369,7 @@ static long _stp_returnval(struct pt_regs *regs) {
 #elif defined (__x86_64__)
 		// TODO: Handle -m32 apps.
 		return regs->rax;
-#elif defined (__powerpc64__)
+#elif defined (__powerpc__)
 		return regs->gpr[3];
 #elif defined (__ia64__)
 		return regs->r8;
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 6/8] Use proper types for do_div
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

do_div accepts unsigned 64-bit integer type for dividend, signed types
would cause do_div's typecheck fail:

stat-common.c: In function 'needed_space':
stat-common.c:50: error: comparison of distinct pointer types lacks a cast
...same errors in time.c and tapset-timers.cxx's generated code...

A fix for time.c is special, on ppc32 cycles_t is 32-bit, so technically
we don't need do_div, but since the whole _stp_gettimeofday_ns() operates
on 64-bit types we'd better be safe and use uint64_t for the math.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/stat-common.c |    8 ++++----
 runtime/time.c        |    3 ++-
 tapset-timers.cxx     |    2 +-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/runtime/stat-common.c b/runtime/stat-common.c
index 7123dc8..f970304 100644
--- a/runtime/stat-common.c
+++ b/runtime/stat-common.c
@@ -34,7 +34,7 @@ static int _stp_stat_calc_buckets(int stop, int start, int interval)
 	return buckets;
 }
 
-static int needed_space(int64_t v)
+static int needed_space(uint64_t v)
 {
 	int space = 0;
 
@@ -134,7 +134,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 {
 	int scale, i, j, val_space, cnt_space;
 	int low_bucket = -1, high_bucket = 0, over = 0, under = 0;
-	int64_t val, v, valmax = 0;
+	uint64_t val, v, valmax = 0;
 	int eliding = 0;
 	char *cur_buf = buf, *fake = buf;
 	char **bufptr = (buf == NULL ? &fake : &cur_buf);
@@ -186,7 +186,7 @@ static void _stp_stat_print_histogram_buf(char *buf, size_t size, Hist st, stat
 	if (valmax <= HIST_WIDTH)
 		scale = 1;
 	else {
-		int64_t tmp = valmax;
+		uint64_t tmp = valmax;
 		int rem = do_div(tmp, HIST_WIDTH);
 		scale = tmp;
 		if (rem) scale++;
@@ -282,7 +282,7 @@ static void _stp_stat_print_histogram(Hist st, stat *sd)
 	_stp_print_flush();
 }
 
-static void __stp_stat_add (Hist st, stat *sd, int64_t val)
+static void __stp_stat_add (Hist st, stat *sd, uint64_t val)
 {
 	int n;
 	if (sd->count == 0) {
diff --git a/runtime/time.c b/runtime/time.c
index 58c23e5..d588370 100644
--- a/runtime/time.c
+++ b/runtime/time.c
@@ -275,7 +275,8 @@ static int64_t
 _stp_gettimeofday_ns(void)
 {
     int64_t base;
-    cycles_t last, delta;
+    cycles_t last;
+    uint64_t delta;
     unsigned int freq;
     unsigned int seq;
     stp_time_t *time;
diff --git a/tapset-timers.cxx b/tapset-timers.cxx
index 6574626..7195cfa 100644
--- a/tapset-timers.cxx
+++ b/tapset-timers.cxx
@@ -241,7 +241,7 @@ hrtimer_derived_probe_group::emit_interval (translator_output* o)
 {
   o->line() << "({";
   o->newline(1) << "unsigned long nsecs;";
-  o->newline() << "int64_t i = stp->intrv;";
+  o->newline() << "uint64_t i = stp->intrv;";
   o->newline() << "if (stp->rnd != 0) {";
   // XXX: why not use stp_random_pm instead of this?
   o->newline(1) << "int64_t r;";
-- 
1.6.3.3

^ permalink raw reply related

* [PATCH 7/8] Implement _div64 and _mod64 for ppc32
From: Anton Vorontsov @ 2009-11-27 22:33 UTC (permalink / raw)
  To: systemtap; +Cc: linuxppc-dev
In-Reply-To: <20091127223251.GA17065@oksana.dev.rtsoft.ru>

_div64 and _mod64 arch-specific details were taken from gcc/longlong.h,
just as it was done for i386.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
 runtime/arith.c |   42 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/runtime/arith.c b/runtime/arith.c
index 4c818a7..a032e9c 100644
--- a/runtime/arith.c
+++ b/runtime/arith.c
@@ -20,7 +20,8 @@
 /* 64-bit division for 64-bit cpus and i386 */
 /* Other 32-bit cpus will need to modify this file. */
 
-#if defined (__i386__) || defined(__arm__)
+#if defined (__i386__) || defined(__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 static long long _div64 (long long u, long long v);
 static long long _mod64 (long long u, long long v);
 #endif
@@ -114,7 +115,8 @@ static int _stp_random_pm (unsigned n)
 
 
 
-#if defined (__i386__) || defined (__arm__)
+#if defined (__i386__) || defined (__arm__) || \
+	(defined(__powerpc__) && !defined(__powerpc64__))
 
 /* 64-bit division functions extracted from libgcc */
 typedef long long DWtype;
@@ -181,6 +183,40 @@ typedef union
 		(count) = __cbtmp ^ 31;					\
 	} while (0)
 
+#elif defined (__powerpc__)
+/* these are the ppc versions of these macros from gcc/longlong.h */
+
+#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
+  do {									\
+    if (__builtin_constant_p (ah) && (ah) == 0)				\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2"	\
+	       : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == 0)			\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0)		\
+      __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2"		\
+	       : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
+    else								\
+      __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2"	\
+	       : "=r" (sh), "=&r" (sl)					\
+	       : "r" (ah), "r" (bh), "rI" (al), "r" (bl));		\
+  } while (0)
+
+#define count_leading_zeros(count, x) \
+  __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
+#define COUNT_LEADING_ZEROS_0 32
+
+#define umul_ppmm(ph, pl, m0, m1) \
+  do {									\
+    USItype __m0 = (m0), __m1 = (m1);					\
+    __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1));	\
+    (pl) = __m0 * __m1;							\
+  } while (0)
+
 #elif defined (__arm__)
 
 #define sub_ddmmss(sh, sl, ah, al, bh, bl) \
@@ -548,6 +584,6 @@ static long long _mod64 (long long u, long long v)
 	return w;
 }
 
-#endif /* __i386__ || __arm__ */
+#endif /* __i386__ || __arm__ || (__powerpc__ && !__powerpc64__) */
 
 #endif /* _ARITH_C_ */
-- 
1.6.3.3

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox