diff options
4 files changed, 68 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/powerpc/support/new_exception_processing/ChangeLog b/c/src/lib/libbsp/powerpc/support/new_exception_processing/ChangeLog index 4d8955d6b4..f5690d88e7 100644 --- a/c/src/lib/libbsp/powerpc/support/new_exception_processing/ChangeLog +++ b/c/src/lib/libbsp/powerpc/support/new_exception_processing/ChangeLog @@ -1,3 +1,24 @@ +2001-05-14 Till Straumann <strauman@slac.stanford.edu> + + * cpu.c: Per PR211 fix + saving/restoring floating point context. The fpsave and fprestore + routines are only used in a executing context which _is_ fp and hence + has the FPU enabled. The current behavior required the FPU always to + be on which is very dangerous if lazy context switching is used. + [Joel Note: Some ports explicitly enabled the FPU in the FP save and + restore routines to avoid this.] + + The patch also makes sure (on powerpc only) that the FPU is disabled + for integer tasks. Note that this is crucial if deferred fp context + switching is used. Otherwise, fp context corruption may go undetected! + Also note that even tasks which merely push/pop FP registers to/from + the stack without modifying them still MUST be FP tasks - otherwise + (if lazy FP context switching is used), FP register corruption (of + other, FP, tasks may occur)! + + Furthermore, (on PPC) by default, lazy FP context save/restore + is _disabled_. + 2002-04-18 Ralf Corsepius <corsepiu@faw.uni-ulm.de> * rtems/score/cpu.h: Removed. diff --git a/c/src/lib/libbsp/powerpc/support/new_exception_processing/cpu.c b/c/src/lib/libbsp/powerpc/support/new_exception_processing/cpu.c index 10d38fab1a..01c5a31e37 100644 --- a/c/src/lib/libbsp/powerpc/support/new_exception_processing/cpu.c +++ b/c/src/lib/libbsp/powerpc/support/new_exception_processing/cpu.c @@ -93,8 +93,20 @@ void _CPU_Context_Initialize( * time (7 July 1997), this restructuring is not being done. */ - /*if ( is_fp ) */ + /* Till Straumann: For deferred FPContext save/restore, make sure integer + * tasks have no FPU access in order to catch violations. + * Otherwise, the FP registers may be corrupted. + * Since we set the_contex->msr using our current MSR, + * we must make sure MSR_FP is off if (!is_fp)... + */ +#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE) + if ( is_fp ) +#endif the_context->msr |= PPC_MSR_FP; +#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE) + else + the_context->msr &= ~PPC_MSR_FP; +#endif the_context->pc = (unsigned32)entry_point; } diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/ChangeLog b/c/src/lib/libcpu/powerpc/new-exceptions/ChangeLog index 4d8955d6b4..f5690d88e7 100644 --- a/c/src/lib/libcpu/powerpc/new-exceptions/ChangeLog +++ b/c/src/lib/libcpu/powerpc/new-exceptions/ChangeLog @@ -1,3 +1,24 @@ +2001-05-14 Till Straumann <strauman@slac.stanford.edu> + + * cpu.c: Per PR211 fix + saving/restoring floating point context. The fpsave and fprestore + routines are only used in a executing context which _is_ fp and hence + has the FPU enabled. The current behavior required the FPU always to + be on which is very dangerous if lazy context switching is used. + [Joel Note: Some ports explicitly enabled the FPU in the FP save and + restore routines to avoid this.] + + The patch also makes sure (on powerpc only) that the FPU is disabled + for integer tasks. Note that this is crucial if deferred fp context + switching is used. Otherwise, fp context corruption may go undetected! + Also note that even tasks which merely push/pop FP registers to/from + the stack without modifying them still MUST be FP tasks - otherwise + (if lazy FP context switching is used), FP register corruption (of + other, FP, tasks may occur)! + + Furthermore, (on PPC) by default, lazy FP context save/restore + is _disabled_. + 2002-04-18 Ralf Corsepius <corsepiu@faw.uni-ulm.de> * rtems/score/cpu.h: Removed. diff --git a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c index 10d38fab1a..01c5a31e37 100644 --- a/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c +++ b/c/src/lib/libcpu/powerpc/new-exceptions/cpu.c @@ -93,8 +93,20 @@ void _CPU_Context_Initialize( * time (7 July 1997), this restructuring is not being done. */ - /*if ( is_fp ) */ + /* Till Straumann: For deferred FPContext save/restore, make sure integer + * tasks have no FPU access in order to catch violations. + * Otherwise, the FP registers may be corrupted. + * Since we set the_contex->msr using our current MSR, + * we must make sure MSR_FP is off if (!is_fp)... + */ +#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE) + if ( is_fp ) +#endif the_context->msr |= PPC_MSR_FP; +#if defined(CPU_USE_DEFERRED_FP_SWITCH) && (CPU_USE_DEFERRED_FP_SWITCH==TRUE) + else + the_context->msr &= ~PPC_MSR_FP; +#endif the_context->pc = (unsigned32)entry_point; } |