[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

PowerPC FP handling weakness.



Sergei Organov wrote:
> 
> Hello,
> 
> Here is text from 'c/src/lib/libcpu/powerpc/new_exception_processing/cpu.c':
> 
> <BEGIN>
>   /*
>    *  The FP bit of the MSR should only be enabled if this is a floating
>    *  point task.  Unfortunately, the vfprintf_r routine in newlib
>    *  ends up pushing a floating point register regardless of whether or
>    *  not a floating point number is being printed.  Serious restructuring
>    *  of vfprintf.c will be required to avoid this behavior.  At this
>    *  time (7 July 1997), this restructuring is not being done.
>    */
> 
>   /*if ( is_fp ) */
>     the_context->msr |= PPC_MSR_FP;
> <END>
> 
> Here is define from 'c/src/lib/libcpu/powerpc/new_exception_processing/cpu.h':
> 
> #define CPU_USE_DEFERRED_FP_SWITCH       TRUE
> 
> I think that enabling FP bit in MSR for non-FP tasks is mistake. It even
> doesn't solve 'printf' problem when deferred FP context switch is used (that
> is turned on by default). Actually the comment in the code is right, but the
> conclusion is wrong. The fact that 'printf' always use FP means that it is a
> mistake to call 'printf' from FP task, and doesn't mean that FP bit should be
> set for non-FP tasks. The right thing to do is to disable FP in MSR for non-FP
> tasks and use 'iprintf' and friends instead of 'printf' in non-FP tasks, I
> believe.

Why don't you send a patch that does deffered FPU registers saving... In
that case enabling FP by default is a non problem since if a task does
not use the FPU registers they will not be saved on context switch just
when a flotating point execption processing occurs because FPU usage has
been disabled...

My two cents,

-- 
   __                 
  /  `                   	Eric Valette - Canon CRF
 /--   __  o _.          	Canon Development Europe Team Leader
(___, / (_(_(__         	Rue de la touche lambert
				35517 Cesson-Sevigne  Cedex
				FRANCE
Tel: +33 (0)2 99 87 68 91	Fax: +33 (0)2 99 84 11 30
E-mail: valette at crf.canon.fr	http://www.crf.canon.fr