On Mon, Apr 02, 2018 at 12:56:39PM +0000, Sagi Maimon wrote:
> Hi all,
> I am working with: Powerpc e300 SOC.
> I am using: xenomai-2.6.4 version
> 
> I am experiencing this exception on my Linux :
> Unrecoverable FP Unavailable Exception 801 at c0003858
> Oops: Unrecoverable FP Unavailable Exception, sig: 6 [#1]
> 
> This happens during "alignment exception" (600)

Hello

We have also seen this issue recently with Xenomai 2.6.4 and i-pipe 
3.1.10-powerpc-2.13-06.

We have been investigating this and Adnan found that the issue seems to be in 
arch/powerpc/kernel/process.c: enable_kernel_fp().

In this function the irqs are disabled and enabled by calling 
local_irq_save_hw_cond() and local_irq_restore_hw_cond(). In between the FP bit 
is enabled and written to MSR in giveup_fpu(). However, the 
local_irq_restore_hw_cond() restores the previous MSR which does not have the 
FP bit enabled and this leads to the exception 801.

We have briefly tested that the exception 801 does not occur with the following 
patch:

--- a/arch/powerpc/kernel/process.c     2018-04-24 15:54:10.164558970 +0300
+++ b/arch/powerpc/kernel/process_new.c 2018-04-24 15:53:30.635567659 +0300
@@ -114,6 +114,11 @@ void enable_kernel_fp(void)
 #else
        giveup_fpu(last_task_used_math);
 #endif /* CONFIG_SMP */
+       /*
+        * giveup_fpu sets the FP bit in MSR, toggling it off would cause
+        * unavailable FP kernel panic. So, keep it on if it was set.
+        */
+       flags |= (mfmsr() & MSR_FP);
        local_irq_restore_hw_cond(flags);
 }
 EXPORT_SYMBOL(enable_kernel_fp);

It seems that the implementation is quite similar also in the current I-pipe 
branch ipipe-4.9.y (only the FP bit is set by msr_check_and_set() and not in 
giveup_fpu). Therefore the problem seems to exist also in the latest i-pipe.

Is our fix correct or have we missed something?

BR,
Jouko Haapaluoma
Wapice Ltd
Finland

_______________________________________________
Xenomai mailing list
Xenomai@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai

Reply via email to