All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai] kernel oops in giveup_fpu (file fpu.S)
@ 2015-11-02 15:00 Ralf Moder
  2015-11-02 15:03 ` Philippe Gerum
  2015-11-02 15:23 ` Philippe Gerum
  0 siblings, 2 replies; 4+ messages in thread
From: Ralf Moder @ 2015-11-02 15:00 UTC (permalink / raw)
  To: xenomai

Hi,

i have a powerpc cpu (mpc5200) running linux 3.14.17 with xenomai patch
2.6.4 on it. I use floating point in kernel, so the (assembly-)function
"giveup_fpu" (in file arch/powerpc/kernel/fpu.S) is called and throws a
kernel-oops. fpu.S is patched with ipipe-core-3.14.17-powerpc-6.patch.
In original linux (kernel 3.14.17) "giveup_fpu" looks like this:

_GLOBAL(giveup_fpu)
    mfmsr    r5
    ori    r5,r5,MSR_FP
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r5,r5,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    SYNC_601
    ISYNC_601
    MTMSRD(r5)            /* enable use of fpu now */
    SYNC_601
    isync
    PPC_LCMPI    0,r3,0
    beqlr-                /* if no previous owner, done */
    addi    r3,r3,THREAD            /* want THREAD of task */
    PPC_LL    r6,THREAD_FPSAVEAREA(r3)
    PPC_LL    r5,PT_REGS(r3)
    PPC_LCMPI    0,r6,0
    bne    2f
    addi    r6,r3,THREAD_FPSTATE
2:    PPC_LCMPI    0,r5,0
    SAVE_32FPVSRS(0, R4, R6)
    mffs    fr0
    stfd    fr0,FPSTATE_FPSCR(r6)
    beq    1f
    PPC_LL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
    li    r3,MSR_FP|MSR_FE0|MSR_FE1
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r3,r3,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    andc    r4,r4,r3        /* disable FP for previous task */
    PPC_STL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1:
#ifndef CONFIG_SMP
    li    r5,0
    LOAD_REG_ADDRBASE(r4,last_task_used_math)
    PPC_STL    r5,ADDROFF(last_task_used_math)(r4)
#endif /* CONFIG_SMP */
    blr



After ipipe patch it looks like this:

_GLOBAL(giveup_fpu)
#ifdef CONFIG_IPIPE
    mfmsr    r6
#ifdef CONFIG_PPC64   
    rldicl    r5,r6,48,1        /* clear MSR_EE */
    rotldi    r5,r5,16
#else
    rlwinm    r5,r6,0,17,15        /* clear MSR_EE */
#endif   
#else   
    mfmsr    r5
#endif   
    ori    r5,r5,MSR_FP
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r5,r5,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    SYNC_601
    ISYNC_601
    MTMSRD(r5)            /* enable use of fpu now */
    SYNC_601
    isync
    PPC_LCMPI    0,r3,0
    beq-    2f            /* if no previous owner, done */
    addi    r3,r3,THREAD            /* want THREAD of task */
    PPC_LL    r6,THREAD_FPSAVEAREA(r3)
    PPC_LL    r5,PT_REGS(r3)
    PPC_LCMPI    0,r6,0
    bne    2f
    addi    r6,r3,THREAD_FPSTATE
2:    PPC_LCMPI    0,r5,0
    SAVE_32FPVSRS(0, R4, R6)
    mffs    fr0
    stfd    fr0,FPSTATE_FPSCR(r6)
    beq    1f
    PPC_LL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
    li    r3,MSR_FP|MSR_FE0|MSR_FE1
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r3,r3,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    andc    r4,r4,r3        /* disable FP for previous task */
    PPC_STL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1:
#ifndef CONFIG_SMP
    li    r5,0
    LOAD_REG_ADDRBASE(r4,last_task_used_math)
    PPC_STL    r5,ADDROFF(last_task_used_math)(r4)
#endif /* CONFIG_SMP */
2:
#ifdef CONFIG_IPIPE        /* restore interrupt state */
    andi.    r6,r6,MSR_EE
    beqlr
    mfmsr    r5
    ori    r5,r5,MSR_EE
    SYNC_601
    ISYNC_601
    MTMSRD(r5)
    SYNC_601
    isync
#endif
    blr


Tests have shown, that the reuse of the label "2" is the problem. If i
change "giveup_fpu" in the following way, no problems occurs:

GLOBAL(giveup_fpu)
#ifdef CONFIG_IPIPE
    mfmsr    r6
#ifdef CONFIG_PPC64   
    rldicl    r5,r6,48,1        /* clear MSR_EE */
    rotldi    r5,r5,16
#else
    rlwinm    r5,r6,0,17,15        /* clear MSR_EE */
#endif   
#else   
    mfmsr    r5
#endif   
    ori    r5,r5,MSR_FP
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r5,r5,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    SYNC_601
    ISYNC_601
    MTMSRD(r5)            /* enable use of fpu now */
    SYNC_601
    isync
    PPC_LCMPI    0,r3,0
    beq-    3f            /* if no previous owner, done */
    addi    r3,r3,THREAD            /* want THREAD of task */
    PPC_LL    r6,THREAD_FPSAVEAREA(r3)
    PPC_LL    r5,PT_REGS(r3)
    PPC_LCMPI    0,r6,0
    bne    2f
    addi    r6,r3,THREAD_FPSTATE
2:    PPC_LCMPI    0,r5,0
    SAVE_32FPVSRS(0, R4, R6)
    mffs    fr0
    stfd    fr0,FPSTATE_FPSCR(r6)
    beq    1f
    PPC_LL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
    li    r3,MSR_FP|MSR_FE0|MSR_FE1
#ifdef CONFIG_VSX
BEGIN_FTR_SECTION
    oris    r3,r3,MSR_VSX@h
END_FTR_SECTION_IFSET(CPU_FTR_VSX)
#endif
    andc    r4,r4,r3        /* disable FP for previous task */
    PPC_STL    r4,_MSR-STACK_FRAME_OVERHEAD(r5)
1:
#ifndef CONFIG_SMP
    li    r5,0
    LOAD_REG_ADDRBASE(r4,last_task_used_math)
    PPC_STL    r5,ADDROFF(last_task_used_math)(r4)
#endif /* CONFIG_SMP */
3:
#ifdef CONFIG_IPIPE        /* restore interrupt state */
    andi.    r6,r6,MSR_EE
    beqlr
    mfmsr    r5
    ori    r5,r5,MSR_EE
    SYNC_601
    ISYNC_601W
    MTMSRD(r5)
    SYNC_601
    isync
#endif
    blr



Is this the right way to solve this problem? If yes, what should i do so
that it comes in the next ipipe patch?

Best regards

Ralf Moder


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] kernel oops in giveup_fpu (file fpu.S)
  2015-11-02 15:00 [Xenomai] kernel oops in giveup_fpu (file fpu.S) Ralf Moder
@ 2015-11-02 15:03 ` Philippe Gerum
       [not found]   ` <5638511E.9030606@mail.de>
  2015-11-02 15:23 ` Philippe Gerum
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Gerum @ 2015-11-02 15:03 UTC (permalink / raw)
  To: Ralf Moder, xenomai

On 11/02/2015 04:00 PM, Ralf Moder wrote:
> Hi,
> 
> i have a powerpc cpu (mpc5200) running linux 3.14.17 with xenomai patch
> 2.6.4 on it. I use floating point in kernel, so the (assembly-)function
> "giveup_fpu" (in file arch/powerpc/kernel/fpu.S) is called and throws a
> kernel-oops. fpu.S is patched with ipipe-core-3.14.17-powerpc-6.patch.
> In original linux (kernel 3.14.17) "giveup_fpu" looks like this:
> 

Please send a diff context patch summarizing your changes.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] kernel oops in giveup_fpu (file fpu.S)
  2015-11-02 15:00 [Xenomai] kernel oops in giveup_fpu (file fpu.S) Ralf Moder
  2015-11-02 15:03 ` Philippe Gerum
@ 2015-11-02 15:23 ` Philippe Gerum
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Gerum @ 2015-11-02 15:23 UTC (permalink / raw)
  To: Ralf Moder, xenomai

On 11/02/2015 04:00 PM, Ralf Moder wrote:

> Is this the right way to solve this problem? 

Please try that patch instead:

http://git.xenomai.org/ipipe.git/commit/?h=ipipe-3.14&id=14665691d7e387d33a9b15774e541121aa513c27

-- 
Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Xenomai] kernel oops in giveup_fpu (file fpu.S)
       [not found]   ` <5638511E.9030606@mail.de>
@ 2015-11-03  7:59     ` Philippe Gerum
  0 siblings, 0 replies; 4+ messages in thread
From: Philippe Gerum @ 2015-11-03  7:59 UTC (permalink / raw)
  To: Ralf Moder; +Cc: Xenomai@xenomai.org

On 11/03/2015 07:15 AM, Ralf Moder wrote:
> Am 02.11.2015 um 16:03 schrieb Philippe Gerum:
>> On 11/02/2015 04:00 PM, Ralf Moder wrote:
>>> Hi,
>>>
>>> i have a powerpc cpu (mpc5200) running linux 3.14.17 with xenomai patch
>>> 2.6.4 on it. I use floating point in kernel, so the (assembly-)function
>>> "giveup_fpu" (in file arch/powerpc/kernel/fpu.S) is called and throws a
>>> kernel-oops. fpu.S is patched with ipipe-core-3.14.17-powerpc-6.patch.
>>> In original linux (kernel 3.14.17) "giveup_fpu" looks like this:
>>>
>> Please send a diff context patch summarizing your changes.
>>
> 
> Here is my diff:
> 
> --- build/linux-3.14.17/arch/powerpc/kernel/fpu.S    2015-10-22
> 12:06:38.167507290 +0200
> +++
> /home/ralf/qx_ralf/quantumx/projects/ppc/workspace/build/linux-3.14.17/arch/powerpc/kernel/fpu.S   
> 2015-11-02 13:11:57.000000000 +0100
> @@ -218,7 +218,7 @@
>      SYNC_601
>      isync
>      PPC_LCMPI    0,r3,0
> -    beq-    2f            /* if no previous owner, done */
> +    beq-    3f            /* if no previous owner, done */
>      addi    r3,r3,THREAD            /* want THREAD of task */
>      PPC_LL    r6,THREAD_FPSAVEAREA(r3)
>      PPC_LL    r5,PT_REGS(r3)
> @@ -245,7 +245,7 @@
>      LOAD_REG_ADDRBASE(r4,last_task_used_math)
>      PPC_STL    r5,ADDROFF(last_task_used_math)(r4)
>  #endif /* CONFIG_SMP */
> -2:
> +3:
>  #ifdef CONFIG_IPIPE        /* restore interrupt state */
>      andi.    r6,r6,MSR_EE
>      beqlr
> 
> As you can see, i only changed the label name (from "2:" to "3:") and
> the branch to this label. I did that because after applying the
> ipipe-patch two labels with name "2:" exists in giveup_fpu and an
> objdump has shown that "beq 2f" jumps to the wrong label.
> 

Ok, I'll pick it, thanks. You may want to pick the patch I mentioned
lately as well, not to rely on r6 for keeping the machine state register.

-- 
Philippe.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-03  7:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-02 15:00 [Xenomai] kernel oops in giveup_fpu (file fpu.S) Ralf Moder
2015-11-02 15:03 ` Philippe Gerum
     [not found]   ` <5638511E.9030606@mail.de>
2015-11-03  7:59     ` Philippe Gerum
2015-11-02 15:23 ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.